mirror of
https://github.com/moodle/moodle.git
synced 2025-01-30 03:58:34 +01:00
MDL-52738 quiz: Previous button during attempt review.
This is to be consistent with places like forum and book, where if we have a next link, we also have a previous link. At the same time I have amended the links/buttons from 'Previous'/'Next' to 'Previous page'/'Next page' because I think that is clearer. Also, on the last page of the quiz, I have changed 'Next' to 'Finish attempt ...' for consistency with the link in the navigation block. AMOS BEGIN CPY [navigatenext,mod_assignment],[navigatenext,mod_quiz] CPY [navigateprevious,mod_assignment],[navigateprevious,mod_quiz] AMOS END
This commit is contained in:
parent
e8d5100212
commit
c67ab86fa9
@ -498,6 +498,8 @@ $string['multichoice'] = 'Multiple choice';
|
||||
$string['multipleanswers'] = 'Choose at least one answer.';
|
||||
$string['mustbesubmittedby'] = 'This attempt must be submitted by {$a}.';
|
||||
$string['name'] = 'Name';
|
||||
$string['navigatenext'] = 'Next page';
|
||||
$string['navigateprevious'] = 'Previous page';
|
||||
$string['navmethod'] = 'Navigation method';
|
||||
$string['navmethod_free'] = 'Free';
|
||||
$string['navmethod_help'] = 'When sequential navigation is enabled a student must progress through the quiz in order and may not return to previous pages nor skip ahead.';
|
||||
|
@ -39,6 +39,7 @@ $timenow = time();
|
||||
$attemptid = required_param('attempt', PARAM_INT);
|
||||
$thispage = optional_param('thispage', 0, PARAM_INT);
|
||||
$nextpage = optional_param('nextpage', 0, PARAM_INT);
|
||||
$previous = optional_param('previous', false, PARAM_BOOL);
|
||||
$next = optional_param('next', false, PARAM_BOOL);
|
||||
$finishattempt = optional_param('finishattempt', false, PARAM_BOOL);
|
||||
$timeup = optional_param('timeup', 0, PARAM_BOOL); // True if form was submitted by timer.
|
||||
@ -50,6 +51,8 @@ $attemptobj = quiz_attempt::create($attemptid);
|
||||
// Set $nexturl now.
|
||||
if ($next) {
|
||||
$page = $nextpage;
|
||||
} else if ($previous && $thispage > 0) {
|
||||
$page = $thispage - 1;
|
||||
} else {
|
||||
$page = $thispage;
|
||||
}
|
||||
|
@ -237,25 +237,36 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
array($url), false, quiz_get_js_module());
|
||||
return html_writer::empty_tag('input', array('type' => 'button',
|
||||
'value' => get_string('finishreview', 'quiz'),
|
||||
'id' => 'secureclosebutton'));
|
||||
'id' => 'secureclosebutton',
|
||||
'class' => 'mod_quiz-next-nav'));
|
||||
|
||||
} else {
|
||||
return html_writer::link($url, get_string('finishreview', 'quiz'));
|
||||
return html_writer::link($url, get_string('finishreview', 'quiz'),
|
||||
array('class' => 'mod_quiz-next-nav'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a next page arrow or the finishing link
|
||||
* Creates the navigation links/buttons at the bottom of the reivew attempt page.
|
||||
*
|
||||
* Note, the name of this function is no longer accurate, but when the design
|
||||
* changed, it was decided to keep the old name for backwards compatibility.
|
||||
*
|
||||
* @param quiz_attempt $attemptobj instance of quiz_attempt
|
||||
* @param int $page the current page
|
||||
* @param bool $lastpage if true current page is the last page
|
||||
*/
|
||||
public function review_next_navigation(quiz_attempt $attemptobj, $page, $lastpage) {
|
||||
$nav = '';
|
||||
if ($page > 0) {
|
||||
$nav .= link_arrow_left(get_string('navigateprevious', 'quiz'),
|
||||
$attemptobj->review_url(null, $page - 1), false, 'mod_quiz-prev-nav');
|
||||
}
|
||||
if ($lastpage) {
|
||||
$nav = $this->finish_review_link($attemptobj);
|
||||
$nav .= $this->finish_review_link($attemptobj);
|
||||
} else {
|
||||
$nav = link_arrow_right(get_string('next'), $attemptobj->review_url(null, $page + 1));
|
||||
$nav .= link_arrow_right(get_string('navigatenext', 'quiz'),
|
||||
$attemptobj->review_url(null, $page + 1), false, 'mod_quiz-next-nav');
|
||||
}
|
||||
return html_writer::tag('div', $nav, array('class' => 'submitbtns'));
|
||||
}
|
||||
@ -476,10 +487,7 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
$attemptobj->attempt_url($slot, $page), $this);
|
||||
}
|
||||
|
||||
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next',
|
||||
'value' => get_string('next')));
|
||||
$output .= html_writer::end_tag('div');
|
||||
$output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page));
|
||||
|
||||
// Some hidden fields to trach what is going on.
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'attempt',
|
||||
@ -510,6 +518,33 @@ class mod_quiz_renderer extends plugin_renderer_base {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the prev/next buttons that go at the bottom of each page of the attempt.
|
||||
*
|
||||
* @param int $page the page number. Starts at 0 for the first page.
|
||||
* @param bool $lastpage is this the last page in the quiz?
|
||||
* @return string HTML fragment.
|
||||
*/
|
||||
protected function attempt_navigation_buttons($page, $lastpage) {
|
||||
$output = '';
|
||||
|
||||
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
|
||||
if ($page > 0) {
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'previous',
|
||||
'value' => get_string('navigateprevious', 'quiz'), 'class' => 'mod_quiz-prev-nav'));
|
||||
}
|
||||
if ($lastpage) {
|
||||
$nextlabel = get_string('endtest', 'quiz');
|
||||
} else {
|
||||
$nextlabel = get_string('navigatenext', 'quiz');
|
||||
}
|
||||
$output .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'next',
|
||||
'value' => $nextlabel, 'class' => 'mod_quiz-next-nav'));
|
||||
$output .= html_writer::end_tag('div');
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a button which allows students to redo a question in the attempt.
|
||||
*
|
||||
|
@ -18,12 +18,20 @@
|
||||
text-align: left;
|
||||
padding-top: 1.5em;
|
||||
}
|
||||
|
||||
#page-mod-quiz-attempt.dir-rtl .submitbtns,
|
||||
#page-mod-quiz-review.dir-rtl .submitbtns {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#page-mod-quiz-attempt .submitbtns .mod_quiz-next-nav,
|
||||
#page-mod-quiz-review .submitbtns .mod_quiz-next-nav {
|
||||
float: right;
|
||||
}
|
||||
#page-mod-quiz-attempt.dir-rtl .submitbtns .mod_quiz-next-nav,
|
||||
#page-mod-quiz-review.dir-rtl .submitbtns .mod_quiz-next-nav {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.path-mod-quiz .mod_quiz-redo_question_button {
|
||||
margin: 0;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ Feature: Add a quiz
|
||||
Then I should see "Question 1"
|
||||
And I should see "Answer the first question"
|
||||
And I set the field "True" to "1"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I should see "Answer saved"
|
||||
And I press "Submit all and finish"
|
||||
|
||||
|
@ -37,7 +37,7 @@ Feature: Attemp a quiz where some questions require that the previous question h
|
||||
And I press "Attempt quiz now"
|
||||
And I click on "True" "radio" in the "First question" "question"
|
||||
And I click on "False" "radio" in the "Second question" "question"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
|
||||
Then I should see "25.00 out of 100.00"
|
||||
@ -99,3 +99,36 @@ Feature: Attemp a quiz where some questions require that the previous question h
|
||||
And I should see question "4" in section "Section 2" in the quiz navigation
|
||||
And I should see question "5" in section "Section 3" in the quiz navigation
|
||||
And I should see question "6" in section "Section 3" in the quiz navigation
|
||||
|
||||
@javascript
|
||||
Scenario: Next and previous navigation
|
||||
Given the following "questions" exist:
|
||||
| questioncategory | qtype | name | questiontext |
|
||||
| Test questions | truefalse | TF1 | Text of the first question |
|
||||
| Test questions | truefalse | TF2 | Text of the second question |
|
||||
And quiz "Quiz 1" contains the following questions:
|
||||
| question | page |
|
||||
| TF1 | 1 |
|
||||
| TF2 | 2 |
|
||||
When I log in as "student"
|
||||
And I follow "Course 1"
|
||||
And I follow "Quiz 1"
|
||||
And I press "Attempt quiz now"
|
||||
Then I should see "Text of the first question"
|
||||
And I press "Next page"
|
||||
And I should see "Text of the second question"
|
||||
And I click on "Finish attempt ..." "button" in the "region-main" "region"
|
||||
And I should see "Summary of attempt"
|
||||
And I press "Return to attempt"
|
||||
And I should see "Text of the second question"
|
||||
And I press "Previous page"
|
||||
And I should see "Text of the first question"
|
||||
And I follow "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
|
||||
And I follow "Show one page at a time"
|
||||
And I should see "Text of the first question"
|
||||
And I follow "Next page"
|
||||
And I should see "Text of the second question"
|
||||
And I follow "Previous page"
|
||||
And I should see "Text of the first question"
|
||||
|
@ -63,7 +63,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
|
||||
And I press "Attempt quiz now"
|
||||
And I click on "False" "radio" in the "First question" "question"
|
||||
And I click on "Check" "button" in the "First question" "question"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
|
||||
Then "Redo question" "button" should not exist
|
||||
@ -75,7 +75,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a
|
||||
And I click on "False" "radio" in the "First question" "question"
|
||||
And I click on "Check" "button" in the "First question" "question"
|
||||
And I press "Redo question"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
|
||||
And I log out
|
||||
|
@ -99,7 +99,7 @@ Feature: Attemp a quiz where some questions require that the previous question h
|
||||
And I follow "Course 1"
|
||||
And I follow "Quiz 1"
|
||||
And I press "Attempt quiz now"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
|
||||
|
||||
@ -177,7 +177,7 @@ Feature: Attemp a quiz where some questions require that the previous question h
|
||||
And I follow "Course 1"
|
||||
And I follow "Quiz 1"
|
||||
And I press "Attempt quiz now"
|
||||
And I press "Next"
|
||||
And I press "Next page"
|
||||
|
||||
Then I should see "Second question"
|
||||
And I should not see "This question cannot be attempted until the previous question has been completed."
|
||||
|
@ -38,14 +38,14 @@ Feature: Set a quiz to be marked complete when the student uses all attempts all
|
||||
And I follow "Test quiz name"
|
||||
And I press "Attempt quiz now"
|
||||
And I set the field "False" to "1"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I follow "C1"
|
||||
And the "Test quiz name" "quiz" activity with "auto" completion should be marked as not complete
|
||||
And I follow "Test quiz name"
|
||||
And I press "Re-attempt quiz"
|
||||
And I set the field "False" to "1"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I follow "C1"
|
||||
Then "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element"
|
||||
|
@ -38,7 +38,7 @@ Feature: Set a quiz to be marked complete when the student passes
|
||||
And I follow "Test quiz name"
|
||||
And I press "Attempt quiz now"
|
||||
And I set the field "True" to "1"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I follow "C1"
|
||||
Then "//img[contains(@alt, 'Completed: Test quiz name')]" "xpath_element" should exist in the "li.modtype_quiz" "css_element"
|
||||
|
@ -39,7 +39,7 @@ Feature: Quiz reset
|
||||
And I follow "Test quiz name"
|
||||
And I press "Attempt quiz now"
|
||||
And I set the field "True" to "1"
|
||||
And I press "Next"
|
||||
And I press "Finish attempt ..."
|
||||
And I press "Submit all and finish"
|
||||
And I log out
|
||||
And I log in as "teacher1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user