diff --git a/includes/class-sensei-quiz.php b/includes/class-sensei-quiz.php index 6595f985e1..6380f810ab 100755 --- a/includes/class-sensei-quiz.php +++ b/includes/class-sensei-quiz.php @@ -35,10 +35,10 @@ public function __construct( $file = __FILE__ ) { add_action( 'template_redirect', array( $this, 'reset_button_click_listener' ) ); // Fire the complete quiz button submit for grading action. - add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_quiz_submit_listener' ) ); + add_action( 'template_redirect', array( $this, 'user_quiz_submit_listener' ) ); // Fire the save user answers quiz button click responder. - add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'user_save_quiz_answers_listener' ) ); + add_action( 'template_redirect', array( $this, 'user_save_quiz_answers_listener' ) ); // Fire the load global data function. add_action( 'sensei_single_quiz_content_inside_before', array( $this, 'load_global_quiz_data' ), 80 ); @@ -179,6 +179,9 @@ public function user_save_quiz_answers_listener() { // remove the hook as it should only fire once per click remove_action( 'sensei_single_quiz_content_inside_before', 'user_save_quiz_answers_listener' ); + // Prevent duplicate submit on page reload. + wp_safe_redirect( get_permalink() ); + } // end user_save_quiz_answers_listener /** @@ -355,6 +358,9 @@ public function user_quiz_submit_listener() { self::submit_answers_for_grading( $quiz_answers, $_FILES, $lesson_id, $current_user->ID ); + // Prevent duplicate submit on page reload. + wp_safe_redirect( get_permalink() ); + } // End sensei_complete_quiz() /**