diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 3b0a042c2c7..32c00b0cf70 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -154,7 +154,7 @@ function quiz_update_instance($quiz, $mform) { quiz_delete_previews($quiz); // Repaginate, if asked to. - if (!empty($quiz->repaginatenow)) { + if (!empty($quiz->repaginatenow) && !quiz_has_attempts($quiz->id)) { quiz_repaginate_questions($quiz->id, $quiz->questionsperpage); } diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 86bf35bdc80..ed05ab6c58e 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -146,7 +146,7 @@ class mod_quiz_mod_form extends moodleform_mod { get_string('newpage', 'quiz'), quiz_questions_per_page_options(), array('id' => 'id_questionsperpage')); $mform->setDefault('questionsperpage', $quizconfig->questionsperpage); - if (!empty($this->_cm)) { + if (!empty($this->_cm) && !quiz_has_attempts($this->_cm->instance)) { $pagegroup[] = $mform->createElement('checkbox', 'repaginatenow', '', get_string('repaginatenow', 'quiz'), array('id' => 'id_repaginatenow')); } diff --git a/mod/quiz/tests/behat/settings_form_fields_disableif.feature b/mod/quiz/tests/behat/settings_form_fields_disableif.feature index 6fc5b11ba75..6cca9356331 100644 --- a/mod/quiz/tests/behat/settings_form_fields_disableif.feature +++ b/mod/quiz/tests/behat/settings_form_fields_disableif.feature @@ -18,12 +18,12 @@ Feature: Settings form fields disabled if not required | teacher | C1 | editingteacher | | student1 | C1 | student | | student2 | C1 | student | - And I log in as "teacher" - And I am on "Course 1" course homepage with editing mode on @javascript Scenario: Depending on the number of attempts, different form fields are disabled. - When I add a "Quiz" to section "1" + When I log in as "teacher" + And I am on "Course 1" course homepage with editing mode on + And I add a "Quiz" to section "1" And I expand all fieldsets And I set the field "Name" to "Test quiz" And I set the field "Attempts allowed" to "1" @@ -32,25 +32,25 @@ Feature: Settings form fields disabled if not required And the "id_delay1_enabled" "field" should be disabled And the "id_delay2_enabled" "field" should be disabled - When I set the field "Attempts allowed" to "2" - Then the "Grading method" "field" should be enabled + And I set the field "Attempts allowed" to "2" + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled And the "id_delay1_enabled" "field" should be enabled And the "id_delay2_enabled" "field" should be disabled - When I set the field "Attempts allowed" to "3" - Then the "Grading method" "field" should be enabled + And I set the field "Attempts allowed" to "3" + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled And the "id_delay1_enabled" "field" should be enabled And the "id_delay2_enabled" "field" should be enabled - When I set the field "Attempts allowed" to "Unlimited" - Then the "Grading method" "field" should be enabled + And I set the field "Attempts allowed" to "Unlimited" + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled # And the "id_delay1_enabled" "field" should be enabled # And the "id_delay2_enabled" "field" should be enabled - When I press "Save and display" + And I press "Save and display" And I navigate to "User overrides" in current page administration And I press "Add user override" And I set the following fields to these values: @@ -61,12 +61,12 @@ Feature: Settings form fields disabled if not required And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "Attempts allowed" to "1" - Then the "Grading method" "field" should be enabled + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled And the "id_delay1_enabled" "field" should be enabled And the "id_delay2_enabled" "field" should be enabled - When I press "Save and display" + And I press "Save and display" And I navigate to "User overrides" in current page administration And I click on "Edit" "link" in the "region-main" "region" And I set the field "Attempts allowed" to "2" @@ -75,12 +75,12 @@ Feature: Settings form fields disabled if not required And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "Attempts allowed" to "1" - Then the "Grading method" "field" should be enabled + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled And the "id_delay1_enabled" "field" should be enabled And the "id_delay2_enabled" "field" should be disabled - When I press "Save and display" + And I press "Save and display" And I navigate to "User overrides" in current page administration And I press "Add user override" And I set the following fields to these values: @@ -91,28 +91,56 @@ Feature: Settings form fields disabled if not required And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "Attempts allowed" to "1" - Then the "Grading method" "field" should be enabled + And the "Grading method" "field" should be enabled And the "Each attempt builds on the last" "field" should be enabled And the "id_delay1_enabled" "field" should be enabled And the "id_delay2_enabled" "field" should be enabled @javascript Scenario: Depending on whether there is a close date, some review options are disabled. - When I add a "Quiz" to section "1" + When I log in as "teacher" + And I am on "Course 1" course homepage with editing mode on + And I add a "Quiz" to section "1" And I expand all fieldsets And I set the field "Name" to "Test quiz" Then the "id_attemptclosed" "checkbox" should be disabled - Then the "id_correctnessclosed" "checkbox" should be disabled - Then the "id_marksclosed" "checkbox" should be disabled - Then the "id_specificfeedbackclosed" "checkbox" should be disabled - Then the "id_generalfeedbackclosed" "checkbox" should be disabled - Then the "id_rightanswerclosed" "checkbox" should be disabled - Then the "id_overallfeedbackclosed" "checkbox" should be disabled + And the "id_correctnessclosed" "checkbox" should be disabled + And the "id_marksclosed" "checkbox" should be disabled + And the "id_specificfeedbackclosed" "checkbox" should be disabled + And the "id_generalfeedbackclosed" "checkbox" should be disabled + And the "id_rightanswerclosed" "checkbox" should be disabled + And the "id_overallfeedbackclosed" "checkbox" should be disabled And I set the field "id_timeclose_enabled" to "1" - Then the "id_attemptclosed" "checkbox" should be enabled - Then the "id_correctnessclosed" "checkbox" should be enabled - Then the "id_marksclosed" "checkbox" should be enabled - Then the "id_specificfeedbackclosed" "checkbox" should be enabled - Then the "id_generalfeedbackclosed" "checkbox" should be enabled - Then the "id_rightanswerclosed" "checkbox" should be enabled - Then the "id_overallfeedbackclosed" "checkbox" should be enabled + And the "id_attemptclosed" "checkbox" should be enabled + And the "id_correctnessclosed" "checkbox" should be enabled + And the "id_marksclosed" "checkbox" should be enabled + And the "id_specificfeedbackclosed" "checkbox" should be enabled + And the "id_generalfeedbackclosed" "checkbox" should be enabled + And the "id_rightanswerclosed" "checkbox" should be enabled + And the "id_overallfeedbackclosed" "checkbox" should be enabled + And I should not see "Repaginate now" + + @javascript + Scenario: If there are quiz attempts, there is not option to repaginate. + Given the following "activities" exist: + | activity | name | intro | course | idnumber | + | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | TF1 | First question | + | Test questions | truefalse | TF2 | Second question | + And quiz "Quiz 1" contains the following questions: + | question | page | maxmark | + | TF1 | 1 | | + When I am on the "Quiz 1" "quiz activity editing" page logged in as teacher + And I expand all fieldsets + Then I should see "Repaginate now" + And user "student1" has attempted "Quiz 1" with responses: + | slot | response | + | 1 | True | + And I am on the "Quiz 1" "quiz activity editing" page + And I expand all fieldsets + And I should not see "Repaginate now"