From 57a4bd032bb8917dc8ffcae44f287ab61bfe4444 Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Wed, 22 Jun 2011 17:33:34 +0800 Subject: [PATCH] MDL-27955 lesson module: fixed error for reviewing lesson and update string to continue or finish reviewing --- mod/lesson/continue.php | 6 +++--- mod/lesson/lang/en/lesson.php | 4 +++- mod/lesson/pagetypes/matching.php | 11 +++++++++-- mod/lesson/pagetypes/multichoice.php | 2 +- mod/lesson/pagetypes/truefalse.php | 2 +- mod/lesson/view.php | 1 + 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/mod/lesson/continue.php b/mod/lesson/continue.php index d207aaee0d086..9010f446b5f38 100644 --- a/mod/lesson/continue.php +++ b/mod/lesson/continue.php @@ -180,12 +180,12 @@ // 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 abc853a62ab33..c94473e29c2fb 100644 --- a/mod/lesson/lang/en/lesson.php +++ b/mod/lesson/lang/en/lesson.php @@ -108,7 +108,7 @@ $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['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 3e40c63f92a0f..63713ac5d62b4 100644 --- a/mod/lesson/pagetypes/matching.php +++ b/mod/lesson/pagetypes/matching.php @@ -61,7 +61,14 @@ public function display($renderer, $attempt) { 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 @@ public function definition() { 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 f29268fe679f0..10e604e93c039 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -506,7 +506,7 @@ public function definition() { $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 61a1a7e343d3d..7154062d69474 100644 --- a/mod/lesson/pagetypes/truefalse.php +++ b/mod/lesson/pagetypes/truefalse.php @@ -319,7 +319,7 @@ public function definition() { $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 c82d5895dcdfc..3cff462262eb8 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -359,6 +359,7 @@ } else { $attempt = false; } + $USER->modattempts[$lesson->id] = $attempt; $lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt); } else { $data = new stdClass;