diff --git a/mod/lesson/continue.php b/mod/lesson/continue.php index d207aaee0d0..9010f446b5f 100644 --- a/mod/lesson/continue.php +++ b/mod/lesson/continue.php @@ -180,12 +180,12 @@ echo $result->feedback; // User is modifying attempts - save button and some instructions if (isset($USER->modattempts[$lesson->id])) { $url = $CFG->wwwroot.'/mod/lesson/view.php'; - $content = $OUTPUT->box(get_string("savechangesandeol", "lesson"), 'center'); + $content = $OUTPUT->box(get_string("gotoendoflesson", "lesson"), 'center'); $content .= $OUTPUT->box(get_string("or", "lesson"), 'center'); - $content .= $OUTPUT->box(get_string("continuetoanswer", "lesson"), 'center'); + $content .= $OUTPUT->box(get_string("continuetonextpage", "lesson"), 'center'); $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'id', 'value'=>$cm->id)); $content .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'pageid', 'value'=>LESSON_EOL)); - $content .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'submit', 'value'=>get_string('savechanges', 'lesson'))); + $content .= html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'submit', 'value'=>get_string('finish', 'lesson'))); echo html_writer::tag('form', "
$content
", array('method'=>'post', 'action'=>$url)); } diff --git a/mod/lesson/lang/en/lesson.php b/mod/lesson/lang/en/lesson.php index abc853a62ab..c94473e29c2 100644 --- a/mod/lesson/lang/en/lesson.php +++ b/mod/lesson/lang/en/lesson.php @@ -108,7 +108,7 @@ $string['confirmdelete'] = 'Delete page'; $string['confirmdeletionofthispage'] = 'Confirm deletion of this page'; $string['congratulations'] = 'Congratulations - end of lesson reached'; $string['continue'] = 'Continue'; -$string['continuetoanswer'] = 'Continue to change answers.'; +$string['continuetonextpage'] = 'Continue to next page.'; $string['correctanswerjump'] = 'Correct answer jump'; $string['correctanswerscore'] = 'Correct answer score'; $string['correctresponse'] = 'Correct response'; @@ -166,11 +166,13 @@ $string['essayemailsubject'] = 'Your grade for {$a} question'; $string['essays'] = 'Essays'; $string['essayscore'] = 'Essay score'; $string['fileformat'] = 'File format'; +$string['finish'] = 'Finish'; $string['firstanswershould'] = 'First answer should jump to the "Correct" page'; $string['firstwrong'] = 'Unfortunately you cannot earn this one point, because your response was not correct. Would you like to keep guessing, just for the sheer joy of learning (but for no point credit)?'; $string['flowcontrol'] = 'Flow control'; $string['full'] = 'Expanded'; $string['general'] = 'General'; +$string['gotoendoflesson'] = 'Go to the end of the lesson'; $string['grade'] = 'Grade'; $string['gradebetterthan'] = 'Grade better than (%)'; $string['gradebetterthanerror'] = 'Earn a grade better than {$a} percent'; diff --git a/mod/lesson/pagetypes/matching.php b/mod/lesson/pagetypes/matching.php index 3e40c63f92a..63713ac5d62 100644 --- a/mod/lesson/pagetypes/matching.php +++ b/mod/lesson/pagetypes/matching.php @@ -61,7 +61,14 @@ class lesson_page_type_matching extends lesson_page { protected function make_answer_form($attempt=null) { global $USER, $CFG; // don't shuffle answers (could be an option??) - $answers = array_slice($this->get_answers(), 2); + $getanswers = array_slice($this->get_answers(), 2); + + //reassing array keys for answers + $answers = array(); + foreach ($getanswers as $getanswer) { + $answers[$getanswer->id] = $getanswer; + } + $responses = array(); foreach ($answers as $answer) { // get all the response @@ -503,7 +510,7 @@ class lesson_display_answer_form_matching extends moodleform { if ($answer->response != NULL) { $mform->addElement('select', 'response['.$answer->id.']', format_text($answer->answer,$answer->answerformat,$options), $responseoptions); $mform->setType('response['.$answer->id.']', PARAM_TEXT); - if (isset($USER->modattempts[$lessonid])) { + if (isset($useranswers) && !empty($useranswers)) { $mform->setDefault('response['.$answer->id.']', htmlspecialchars(trim($answers[$useranswers[$i]]->response))); //TODO: this is suspicious } else { $mform->setDefault('response['.$answer->id.']', 'answeroption'); diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php index f29268fe679..10e604e93c0 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -506,7 +506,7 @@ class lesson_display_answer_form_multichoice_singleanswer extends moodleform { $mform->addElement('radio','answerid',null,format_text($answer->answer, $answer->answerformat, $options),$answer->id); $mform->setType('answer'.$i, PARAM_INT); if (isset($USER->modattempts[$lessonid]) && $answer->id == $USER->modattempts[$lessonid]->answerid) { - $mform->setDefault('answerid', true); + $mform->setDefault('answerid', $USER->modattempts[$lessonid]->answerid); } $mform->addElement('html', ''); $i++; diff --git a/mod/lesson/pagetypes/truefalse.php b/mod/lesson/pagetypes/truefalse.php index 61a1a7e343d..7154062d694 100644 --- a/mod/lesson/pagetypes/truefalse.php +++ b/mod/lesson/pagetypes/truefalse.php @@ -319,7 +319,7 @@ class lesson_display_answer_form_truefalse extends moodleform { $mform->addElement('radio', 'answerid', null, format_text($answer->answer, $answer->answerformat, $options), $answer->id); $mform->setType('answerid', PARAM_INT); if (isset($USER->modattempts[$lessonid]) && $answer->id == $attempt->answerid) { - $mform->setDefault('answerid', true); + $mform->setDefault('answerid', $attempt->answerid); } $mform->addElement('html', ''); $i++; diff --git a/mod/lesson/view.php b/mod/lesson/view.php index c82d5895dcd..3cff462262e 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -359,6 +359,7 @@ if ($pageid != LESSON_EOL) { } else { $attempt = false; } + $USER->modattempts[$lesson->id] = $attempt; $lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt); } else { $data = new stdClass;