mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
Merge branch 'MDL-59081-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
f7c77ea189
@ -117,9 +117,14 @@ if (!$result->correctanswer && !$result->noanswer && !$result->isessayquestion &
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'pageid'=>$result->newpageid));
|
||||
|
||||
if ($lesson->review && !$result->correctanswer && !$result->noanswer && !$result->isessayquestion && !$result->maxattemptsreached) {
|
||||
// Button to continue the lesson (the page to go is configured by the teacher).
|
||||
echo $OUTPUT->single_button($url, get_string('reviewquestioncontinue', 'lesson'));
|
||||
// If both the "Yes, I'd like to try again" and "No, I just want to go on to the next question" point to the same
|
||||
// page then don't show the "No, I just want to go on to the next question" button. It's confusing.
|
||||
if ($page->id != $result->newpageid) {
|
||||
// Button to continue the lesson (the page to go is configured by the teacher).
|
||||
echo $OUTPUT->single_button($url, get_string('reviewquestioncontinue', 'lesson'));
|
||||
}
|
||||
} else {
|
||||
// Normal continue button
|
||||
echo $OUTPUT->single_button($url, get_string('continue', 'lesson'));
|
||||
|
@ -137,6 +137,8 @@ if ($edit) {
|
||||
}
|
||||
$answerscount++;
|
||||
}
|
||||
// Let the lesson pages make updates if required.
|
||||
$data = $editpage->update_form_data($data);
|
||||
|
||||
$mform->set_data($data);
|
||||
$PAGE->navbar->add(get_string('edit'), new moodle_url('/mod/lesson/edit.php', array('id'=>$id)));
|
||||
|
@ -59,6 +59,9 @@ $string['additionalattemptsremaining'] = 'Completed, You can re-attempt this les
|
||||
$string['addpage'] = 'Add a page';
|
||||
$string['addshortanswer'] = 'Create a Short answer question page';
|
||||
$string['addtruefalse'] = 'Create a True/false question page';
|
||||
$string['allotheranswers'] = 'All other answers';
|
||||
$string['allotheranswersjump'] = 'All other answers jump';
|
||||
$string['allotheranswersscore'] = 'All other answers score';
|
||||
$string['allowofflineattempts'] = 'Allow lesson to be attempted offline using the mobile app';
|
||||
$string['allowofflineattempts_help'] = 'If enabled, a mobile app user can download the lesson and attempt it offline.
|
||||
All the possible answers and correct responses will be downloaded as well.
|
||||
@ -162,7 +165,7 @@ $string['displayleftmenu'] = 'Display menu';
|
||||
$string['displayleftmenu_help'] = 'If enabled, a menu allowing users to navigate through the list of pages is displayed.';
|
||||
$string['displayofgrade'] = 'Display of grade (for students only)';
|
||||
$string['displayreview'] = 'Provide option to try a question again';
|
||||
$string['displayreview_help'] = 'If enabled, when a question is answered incorrectly, the student is given the option to try it again for no point credit, or continue with the lesson.';
|
||||
$string['displayreview_help'] = 'If enabled, when a question is answered incorrectly, the student is given the option to try it again for no point credit, or continue with the lesson. If the student clicks to move on to another question then the selected (wrong) answer will be followed. By default wrong answer jumps are set to "this page" and have a score of 0, so it is recommended that you set the wrong answer jump to a different page to avoid confusion with your students.';
|
||||
$string['displayscorewithessays'] = '<p>You earned {$a->score} out of {$a->tempmaxgrade} for the automatically graded questions.</p>
|
||||
<p>Your {$a->essayquestions} essay question(s) will be graded and added into your final score at a later date.</p>
|
||||
<p>Your current grade without the essay question(s) is {$a->score} out of {$a->grade}.</p>';
|
||||
|
@ -61,6 +61,9 @@ define("LESSON_MAX_EVENT_LENGTH", "432000");
|
||||
/** Answer format is HTML */
|
||||
define("LESSON_ANSWER_HTML", "HTML");
|
||||
|
||||
/** Placeholder answer for all other answers. */
|
||||
define("LESSON_OTHER_ANSWERS", "@#wronganswer#@");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
/// Any other lesson functions go here. Each of them must have a name that
|
||||
/// starts with lesson_
|
||||
@ -4456,7 +4459,7 @@ abstract class lesson_page extends lesson_base {
|
||||
$DB->insert_record("lesson_answers", $answer);
|
||||
}
|
||||
} else {
|
||||
for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
|
||||
for ($i = 0; $i < count($properties->answer_editor); $i++) {
|
||||
if (!array_key_exists($i, $this->answers)) {
|
||||
$this->answers[$i] = new stdClass;
|
||||
$this->answers[$i]->lessonid = $this->lesson->id;
|
||||
@ -4575,7 +4578,7 @@ abstract class lesson_page extends lesson_base {
|
||||
|
||||
$answers = array();
|
||||
|
||||
for ($i = 0; $i < $this->lesson->maxanswers; $i++) {
|
||||
for ($i = 0; $i < ($this->lesson->maxanswers + 1); $i++) {
|
||||
$answer = clone($newanswer);
|
||||
|
||||
if (isset($properties->answer_editor[$i])) {
|
||||
@ -4610,8 +4613,6 @@ abstract class lesson_page extends lesson_base {
|
||||
$properties->answer_editor[$i]);
|
||||
}
|
||||
$answers[$answer->id] = new lesson_page_answer($answer);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -4901,6 +4902,17 @@ abstract class lesson_page extends lesson_base {
|
||||
return $fs->get_area_files($this->lesson->context->id, 'mod_lesson', 'page_contents', $this->properties->id,
|
||||
'itemid, filepath, filename', $includedirs, $updatedsince);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make updates to the form data if required.
|
||||
*
|
||||
* @since Moodle 3.7
|
||||
* @param stdClass $data The form data to update.
|
||||
* @return stdClass The updated fom data.
|
||||
*/
|
||||
public function update_form_data(stdClass $data) : stdClass {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,6 +71,43 @@ class lesson_page_type_numerical extends lesson_page {
|
||||
$event->trigger();
|
||||
return $mform->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates answers for this page type.
|
||||
*
|
||||
* @param object $properties The answer properties.
|
||||
*/
|
||||
public function create_answers($properties) {
|
||||
if (isset($properties->enableotheranswers) && $properties->enableotheranswers) {
|
||||
$properties->response_editor = array_values($properties->response_editor);
|
||||
$properties->jumpto = array_values($properties->jumpto);
|
||||
$properties->score = array_values($properties->score);
|
||||
$wrongresponse = end($properties->response_editor);
|
||||
$wrongkey = key($properties->response_editor);
|
||||
$properties->answer_editor[$wrongkey] = LESSON_OTHER_ANSWERS;
|
||||
}
|
||||
parent::create_answers($properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the answers for this page type.
|
||||
*
|
||||
* @param object $properties The answer properties.
|
||||
* @param context $context The context for this module.
|
||||
* @param int $maxbytes The maximum bytes for any uploades.
|
||||
*/
|
||||
public function update($properties, $context = null, $maxbytes = null) {
|
||||
if ($properties->enableotheranswers) {
|
||||
$properties->response_editor = array_values($properties->response_editor);
|
||||
$properties->jumpto = array_values($properties->jumpto);
|
||||
$properties->score = array_values($properties->score);
|
||||
$wrongresponse = end($properties->response_editor);
|
||||
$wrongkey = key($properties->response_editor);
|
||||
$properties->answer_editor[$wrongkey] = LESSON_OTHER_ANSWERS;
|
||||
}
|
||||
parent::update($properties, $context, $maxbytes);
|
||||
}
|
||||
|
||||
public function check_answer() {
|
||||
global $CFG;
|
||||
$result = parent::check_answer();
|
||||
@ -125,6 +162,22 @@ class lesson_page_type_numerical extends lesson_page {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
// We could check here to see if we have a wrong answer jump to use.
|
||||
if ($result->answerid == 0) {
|
||||
// Use the all other answers jump details if it is set up.
|
||||
$lastanswer = end($answers);
|
||||
// Double check that this is the @#wronganswer#@ answer.
|
||||
if (strpos($lastanswer->answer, LESSON_OTHER_ANSWERS) !== false) {
|
||||
$otheranswers = end($answers);
|
||||
$result->newpageid = $otheranswers->jumpto;
|
||||
$result->response = format_text($otheranswers->response, $otheranswers->responseformat, $formattextdefoptions);
|
||||
// Does this also need to do the jumpto_is_correct?
|
||||
if ($this->lesson->custom) {
|
||||
$result->correctanswer = ($otheranswers->score > 0);
|
||||
}
|
||||
$result->answerid = $otheranswers->id;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -259,6 +312,35 @@ class lesson_page_type_numerical extends lesson_page {
|
||||
}
|
||||
return $answerpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make updates to the form data if required. In this case to put the all other answer data into the write section of the form.
|
||||
*
|
||||
* @param stdClass $data The form data to update.
|
||||
* @return stdClass The updated fom data.
|
||||
*/
|
||||
public function update_form_data(stdClass $data) : stdClass {
|
||||
$answercount = count($this->get_answers());
|
||||
// Check for other answer entry.
|
||||
$lastanswer = $data->{'answer_editor[' . ($answercount - 1) . ']'};
|
||||
if (strpos($lastanswer, LESSON_OTHER_ANSWERS) !== false) {
|
||||
$data->{'answer_editor[' . ($this->lesson->maxanswers + 1) . ']'} =
|
||||
$data->{'answer_editor[' . ($answercount - 1) . ']'};
|
||||
$data->{'response_editor[' . ($this->lesson->maxanswers + 1) . ']'} =
|
||||
$data->{'response_editor[' . ($answercount - 1) . ']'};
|
||||
$data->{'jumpto[' . ($this->lesson->maxanswers + 1) . ']'} = $data->{'jumpto[' . ($answercount - 1) . ']'};
|
||||
$data->{'score[' . ($this->lesson->maxanswers + 1) . ']'} = $data->{'score[' . ($answercount - 1) . ']'};
|
||||
$data->enableotheranswers = true;
|
||||
|
||||
// Unset the old values.
|
||||
unset($data->{'answer_editor[' . ($answercount - 1) . ']'});
|
||||
unset($data->{'response_editor[' . ($answercount - 1) . ']'});
|
||||
unset($data->{'jumpto['. ($answercount - 1) . ']'});
|
||||
unset($data->{'score[' . ($answercount - 1) . ']'});
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
class lesson_add_page_form_numerical extends lesson_add_page_form_base {
|
||||
@ -269,13 +351,21 @@ class lesson_add_page_form_numerical extends lesson_add_page_form_base {
|
||||
protected $responseformat = LESSON_ANSWER_HTML;
|
||||
|
||||
public function custom_definition() {
|
||||
for ($i = 0; $i < $this->_customdata['lesson']->maxanswers; $i++) {
|
||||
$answercount = $this->_customdata['lesson']->maxanswers;
|
||||
for ($i = 0; $i < $answercount; $i++) {
|
||||
$this->_form->addElement('header', 'answertitle'.$i, get_string('answer').' '.($i+1));
|
||||
$this->add_answer($i, null, ($i < 1));
|
||||
$this->add_response($i);
|
||||
$this->add_jumpto($i, null, ($i == 0 ? LESSON_NEXTPAGE : LESSON_THISPAGE));
|
||||
$this->add_score($i, null, ($i===0)?1:0);
|
||||
}
|
||||
// Wrong answer jump.
|
||||
$this->_form->addElement('header', 'wronganswer', get_string('allotheranswers', 'lesson'));
|
||||
$newcount = $answercount + 1;
|
||||
$this->_form->addElement('advcheckbox', 'enableotheranswers', get_string('enabled', 'lesson'));
|
||||
$this->add_response($newcount);
|
||||
$this->add_jumpto($newcount, get_string('allotheranswersjump', 'lesson'), LESSON_NEXTPAGE);
|
||||
$this->add_score($newcount, get_string('allotheranswersscore', 'lesson'), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,44 @@ class lesson_page_type_shortanswer extends lesson_page {
|
||||
$event->trigger();
|
||||
return $mform->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates answers for this page type.
|
||||
*
|
||||
* @param object $properties The answer properties.
|
||||
*/
|
||||
public function create_answers($properties) {
|
||||
if (isset($properties->enableotheranswers) && $properties->enableotheranswers) {
|
||||
$properties->response_editor = array_values($properties->response_editor);
|
||||
$properties->jumpto = array_values($properties->jumpto);
|
||||
$properties->score = array_values($properties->score);
|
||||
$wrongresponse = end($properties->response_editor);
|
||||
$wrongkey = key($properties->response_editor);
|
||||
$properties->answer_editor[$wrongkey] = LESSON_OTHER_ANSWERS;
|
||||
}
|
||||
parent::create_answers($properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the answers for this page type.
|
||||
*
|
||||
* @param object $properties The answer properties.
|
||||
* @param context $context The context for this module.
|
||||
* @param int $maxbytes The maximum bytes for any uploades.
|
||||
*/
|
||||
public function update($properties, $context = null, $maxbytes = null) {
|
||||
if ($properties->enableotheranswers) {
|
||||
$properties->response_editor = array_values($properties->response_editor);
|
||||
$properties->jumpto = array_values($properties->jumpto);
|
||||
$properties->score = array_values($properties->score);
|
||||
$wrongresponse = end($properties->response_editor);
|
||||
$wrongkey = key($properties->response_editor);
|
||||
$properties->answer_editor[$wrongkey] = LESSON_OTHER_ANSWERS;
|
||||
}
|
||||
parent::update($properties, $context, $maxbytes);
|
||||
}
|
||||
|
||||
|
||||
public function check_answer() {
|
||||
global $CFG;
|
||||
$result = parent::check_answer();
|
||||
@ -176,6 +214,26 @@ class lesson_page_type_shortanswer extends lesson_page {
|
||||
break; // quit answer analysis immediately after a match has been found
|
||||
}
|
||||
}
|
||||
|
||||
// We could check here to see if we have a wrong answer jump to use.
|
||||
if ($result->answerid == 0) {
|
||||
// Use the all other answers jump details if it is set up.
|
||||
$lastanswer = end($answers);
|
||||
// Double check that this is the @#wronganswer#@ answer.
|
||||
if (strpos($lastanswer->answer, LESSON_OTHER_ANSWERS) !== false) {
|
||||
$otheranswers = end($answers);
|
||||
$result->newpageid = $otheranswers->jumpto;
|
||||
$options = new stdClass();
|
||||
$options->para = false;
|
||||
$result->response = format_text($otheranswers->response, $otheranswers->responseformat, $options);
|
||||
// Does this also need to do the jumpto_is_correct?
|
||||
if ($this->lesson->custom) {
|
||||
$result->correctanswer = ($otheranswers->score > 0);
|
||||
}
|
||||
$result->answerid = $otheranswers->id;
|
||||
}
|
||||
}
|
||||
|
||||
$result->userresponse = $studentanswer;
|
||||
//clean student answer as it goes to output.
|
||||
$result->studentanswer = s($studentanswer);
|
||||
@ -325,6 +383,33 @@ class lesson_page_type_shortanswer extends lesson_page {
|
||||
}
|
||||
return $answerpage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make updates to the form data if required. In this case to put the all other answer data into the write section of the form.
|
||||
*
|
||||
* @param stdClass $data The form data to update.
|
||||
* @return stdClass The updated fom data.
|
||||
*/
|
||||
public function update_form_data(stdClass $data) : stdClass {
|
||||
$answercount = count($this->get_answers());
|
||||
// Check for other answer entry.
|
||||
$lastanswer = $data->{'answer_editor[' . ($answercount - 1) . ']'};
|
||||
if (strpos($lastanswer, LESSON_OTHER_ANSWERS) !== false) {
|
||||
$data->{'answer_editor[' . ($this->lesson->maxanswers + 1) . ']'} =
|
||||
$data->{'answer_editor[' . ($answercount - 1) . ']'};
|
||||
$data->{'response_editor[' . ($this->lesson->maxanswers + 1) . ']'} =
|
||||
$data->{'response_editor[' . ($answercount - 1) . ']'};
|
||||
$data->{'jumpto[' . ($this->lesson->maxanswers + 1) . ']'} = $data->{'jumpto[' . ($answercount - 1) . ']'};
|
||||
$data->{'score[' . ($this->lesson->maxanswers + 1) . ']'} = $data->{'score[' . ($answercount - 1) . ']'};
|
||||
$data->enableotheranswers = true;
|
||||
// Unset the old values.
|
||||
unset($data->{'answer_editor[' . ($answercount - 1) . ']'});
|
||||
unset($data->{'response_editor[' . ($answercount - 1) . ']'});
|
||||
unset($data->{'jumpto[' . ($answercount - 1) . ']'});
|
||||
unset($data->{'score[' . ($answercount - 1) . ']'});
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -340,7 +425,8 @@ class lesson_add_page_form_shortanswer extends lesson_add_page_form_base {
|
||||
$this->_form->setDefault('qoption', 0);
|
||||
$this->_form->addHelpButton('qoption', 'casesensitive', 'lesson');
|
||||
|
||||
for ($i = 0; $i < $this->_customdata['lesson']->maxanswers; $i++) {
|
||||
$answercount = $this->_customdata['lesson']->maxanswers;
|
||||
for ($i = 0; $i < $answercount; $i++) {
|
||||
$this->_form->addElement('header', 'answertitle'.$i, get_string('answer').' '.($i+1));
|
||||
// Only first answer is required.
|
||||
$this->add_answer($i, null, ($i < 1));
|
||||
@ -348,6 +434,14 @@ class lesson_add_page_form_shortanswer extends lesson_add_page_form_base {
|
||||
$this->add_jumpto($i, null, ($i == 0 ? LESSON_NEXTPAGE : LESSON_THISPAGE));
|
||||
$this->add_score($i, null, ($i===0)?1:0);
|
||||
}
|
||||
|
||||
// Other answer jump.
|
||||
$this->_form->addElement('header', 'wronganswer', get_string('allotheranswers', 'lesson'));
|
||||
$newcount = $answercount + 1;
|
||||
$this->_form->addElement('advcheckbox', 'enableotheranswers', get_string('enabled', 'lesson'));
|
||||
$this->add_response($newcount);
|
||||
$this->add_jumpto($newcount, get_string('allotheranswersjump', 'lesson'), LESSON_NEXTPAGE);
|
||||
$this->add_score($newcount, get_string('allotheranswersscore', 'lesson'), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
95
mod/lesson/tests/behat/all_other_answers_catch.feature
Normal file
95
mod/lesson/tests/behat/all_other_answers_catch.feature
Normal file
@ -0,0 +1,95 @@
|
||||
@mod @mod_lesson
|
||||
Feature: Numeric and short answer questions have a section to catch all other student answers.
|
||||
In order for lesson pages to catch any student answer
|
||||
As a teacher
|
||||
I need to fill in the sections to catch all other student answers
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Lesson" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Test lesson name |
|
||||
| Description | Test lesson description |
|
||||
| Provide option to try a question again | Yes |
|
||||
| Maximum number of attempts | 3 |
|
||||
And I press "Save and display"
|
||||
|
||||
Scenario: I can create a numerical question with an option to catch all student responses.
|
||||
Given I follow "Add a question page"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
And I set the following fields to these values:
|
||||
| Page title | Numerical question |
|
||||
| Page contents | What is 1 + 2? |
|
||||
| id_answer_editor_0 | 3 |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
| id_enableotheranswers | 1 |
|
||||
| id_jumpto_6 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Add a content page" from the "qtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Page title | Just move on page |
|
||||
| Page contents | You are here to move on |
|
||||
| id_answer_editor_0 | End this lesson |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
And I press "Save page"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
And I set the field "Your answer" to "5"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
And I press "Yes, I'd like to try again"
|
||||
And I should see "What is 1 + 2?"
|
||||
And I set the field "Your answer" to "7"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
When I press "No, I just want to go on to the next question"
|
||||
Then I should see "You are here to move on"
|
||||
|
||||
Scenario: I can create a shortanswer question with an option to catch all student responses.
|
||||
Given I follow "Add a question page"
|
||||
And I set the field "Select a question type" to "Short answer"
|
||||
And I press "Add a question page"
|
||||
And I set the following fields to these values:
|
||||
| Page title | Short answer question |
|
||||
| Page contents | Please type in cat |
|
||||
| id_answer_editor_0 | 3 |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
| id_enableotheranswers | 1 |
|
||||
| id_jumpto_6 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Add a content page" from the "qtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Page title | Just move on page |
|
||||
| Page contents | You are here to move on |
|
||||
| id_answer_editor_0 | End this lesson |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
And I press "Save page"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
And I set the field "Your answer" to "dog"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
And I press "Yes, I'd like to try again"
|
||||
And I should see "Please type in cat"
|
||||
And I set the field "Your answer" to "bird"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
When I press "No, I just want to go on to the next question"
|
||||
Then I should see "You are here to move on"
|
85
mod/lesson/tests/behat/wrong_answer_continue.feature
Normal file
85
mod/lesson/tests/behat/wrong_answer_continue.feature
Normal file
@ -0,0 +1,85 @@
|
||||
@mod @mod_lesson
|
||||
Feature: An incorrect response to an answer with multiple attempts show appropriate continue buttons
|
||||
In order for lesson the appropriate continue button to be displayed
|
||||
As a teacher
|
||||
I need to create a lesson with multiple attempts for each question
|
||||
|
||||
Background:
|
||||
Given the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| student1 | Student | 1 | student1@example.com |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| student1 | C1 | student |
|
||||
And I log in as "teacher1"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I add a "Lesson" to section "1"
|
||||
And I set the following fields to these values:
|
||||
| Name | Test lesson name |
|
||||
| Description | Test lesson description |
|
||||
| Provide option to try a question again | Yes |
|
||||
| Maximum number of attempts | 2 |
|
||||
And I press "Save and display"
|
||||
|
||||
Scenario: A student answering incorrectly to a question will see an option to move to the next question if set up.
|
||||
Given I follow "Add a question page"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
And I set the following fields to these values:
|
||||
| Page title | Numerical question |
|
||||
| Page contents | What is 1 + 2? |
|
||||
| id_answer_editor_0 | 3 |
|
||||
| id_jumpto_0 | Next page |
|
||||
| id_answer_editor_1 | 2 |
|
||||
| id_jumpto_1 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Add a content page" from the "qtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Page title | Just move on page |
|
||||
| Page contents | You are here to move on |
|
||||
| id_answer_editor_0 | End this lesson |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
And I press "Save page"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
When I set the field "Your answer" to "2"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
And I should see "No, I just want to go on to the next question"
|
||||
And I press "No, I just want to go on to the next question"
|
||||
Then I should see "You are here to move on"
|
||||
|
||||
Scenario: A student answering incorrectly to a question will only see an option to try again if there is no matching wrong response.
|
||||
Given I follow "Add a question page"
|
||||
And I set the field "Select a question type" to "Numerical"
|
||||
And I press "Add a question page"
|
||||
And I set the following fields to these values:
|
||||
| Page title | Numerical question |
|
||||
| Page contents | What is 1 + 2? |
|
||||
| id_answer_editor_0 | 3 |
|
||||
| id_jumpto_0 | Next page |
|
||||
And I press "Save page"
|
||||
And I select "Add a content page" from the "qtype" singleselect
|
||||
And I set the following fields to these values:
|
||||
| Page title | Just move on page |
|
||||
| Page contents | You are here to move on |
|
||||
| id_answer_editor_0 | End this lesson |
|
||||
| id_jumpto_0 | End of lesson |
|
||||
And I press "Save page"
|
||||
And I log out
|
||||
And I log in as "student1"
|
||||
And I am on "Course 1" course homepage
|
||||
And I follow "Test lesson name"
|
||||
When I set the field "Your answer" to "2"
|
||||
And I press "Submit"
|
||||
And I should see "That's the wrong answer"
|
||||
Then I should not see "No, I just want to go on to the next question"
|
||||
And I press "Yes, I'd like to try again"
|
||||
And I should see "What is 1 + 2?"
|
@ -1,5 +1,10 @@
|
||||
This files describes API changes in the lesson code.
|
||||
|
||||
=== 3.6.1 ===
|
||||
|
||||
* A new function update_form_data() has been added to lesson_page class. This can be overridden by the individual page types
|
||||
to alter the form data before being sent to the mform.
|
||||
|
||||
=== 3.4 ===
|
||||
|
||||
* External function mod_lesson_external::get_user_attempt() now returns the full page object inside each answerpages.
|
||||
|
Loading…
x
Reference in New Issue
Block a user