Skip to content

Commit

Permalink
MDL-27955 lesson module: fixed error for reviewing lesson and update …
Browse files Browse the repository at this point in the history
…string to continue or finish reviewing
  • Loading branch information
Rossiani Wijaya committed Jun 28, 2011
1 parent 7fde489 commit 57a4bd0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions mod/lesson/continue.php
Expand Up @@ -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', "<div>$content</div>", array('method'=>'post', 'action'=>$url));
}

Expand Down
4 changes: 3 additions & 1 deletion mod/lesson/lang/en/lesson.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (&#37;)';
$string['gradebetterthanerror'] = 'Earn a grade better than {$a} percent';
Expand Down
11 changes: 9 additions & 2 deletions mod/lesson/pagetypes/matching.php
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/pagetypes/multichoice.php
Expand Up @@ -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', '</div>');
$i++;
Expand Down
2 changes: 1 addition & 1 deletion mod/lesson/pagetypes/truefalse.php
Expand Up @@ -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', '</div>');
$i++;
Expand Down
1 change: 1 addition & 0 deletions mod/lesson/view.php
Expand Up @@ -359,6 +359,7 @@
} else {
$attempt = false;
}
$USER->modattempts[$lesson->id] = $attempt;
$lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt);
} else {
$data = new stdClass;
Expand Down

0 comments on commit 57a4bd0

Please sign in to comment.