From 378b613d8ee7ab723e777116ff8dcfbd22d2adf5 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 29 Apr 2005 18:32:13 +0000 Subject: [PATCH] Some changes to add format_text() to answers and feedback across all the module. Note: Essay questions and their teacher's feedback. I'm not pretty sure it they should support the format_text() too. And currently, they are cleaned at input, so it is impossible to write or tags with them! --- mod/lesson/report.php | 23 +++++++++++++---------- mod/lesson/view.php | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 802069c124e..1267857d8af 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -270,6 +270,9 @@ **************************************************************************/ else if ($action == 'detail') { + + $formattextdefoptions->para = false; //I'll use it widely in this page + $userid = optional_param('userid', NULL, PARAM_INT); // if empty, then will display the general detailed view $try = optional_param('try', NULL, PARAM_INT); @@ -407,7 +410,7 @@ $answerdata = new stdClass; $answerpage->title = format_string($page->title); - $answerpage->contents = $page->contents; + $answerpage->contents = format_text($page->contents); // get the page qtype switch ($page->qtype) { @@ -517,9 +520,9 @@ $data = ""; } if (($answer->score > 0 && $lesson->custom) || (lesson_iscorrect($page->id, $answer->jumpto) && !$lesson->custom)) { - $data .= "$answer->answer"; + $data .= "".format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions).""; } else { - $data .= $answer->answer; + $data .= format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions); } } else { if ($answer->id == $useranswer->answerid) { @@ -546,9 +549,9 @@ $data = ""; } if (($answer->score > 0 && $lesson->custom) || (lesson_iscorrect($page->id, $answer->jumpto) && !$lesson->custom)) { - $data .= "$answer->answer"; + $data .= "".format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions).""; } else { - $data .= $answer->answer; + $data .= format_text($answer->answer,FORMAT_MOODLE,$formattextdefoptions); } } if (isset($pagestats[$page->id][$answer->id])) { @@ -655,12 +658,12 @@ $answerdata->score = get_string("didnotreceivecredit", "lesson"); } } - $data = ""; + $data = ""; if ($useranswer != NULL) { $userresponse = explode(",", $useranswer->useranswer); - $data .= ""; + $data .= ""; } else { - $data .= ""; + $data .= ""; } if ($n == 2) { @@ -722,7 +725,7 @@ $answerdata->answers[] = array($essayinfo->answer, $avescore); break; case LESSON_BRANCHTABLE : - $data = "id\" value=\"$answer->answer\" disabled=\"disabled\"> "; + $data = "id\" value=\"".strip_tags(format_text($answer->answer, FORMAT_MOODLE,$formattextdefoptions))."\" disabled=\"disabled\"> "; $data .= get_string("jumptsto", "lesson").": "; if ($answer->jumpto == 0) { $data .= get_string("thispage", "lesson"); @@ -856,7 +859,7 @@ $table->data[] = $modified; } if ($page->answerdata->response != NULL) { - $table->data[] = array($fontstart.get_string("response", "lesson").":
".$fontend.$fontstart2.$page->answerdata->response.$fontend2, " "); + $table->data[] = array($fontstart.get_string("response", "lesson").":
".$fontend.$fontstart2.format_text($page->answerdata->response,FORMAT_MOODLE,$formattextdefoptions).$fontend2, " "); } $table->data[] = array($page->answerdata->score, " "); print_table($table); diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 5060689acd1..9ab8fe0d687 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -686,7 +686,8 @@ foreach ($answers as $answer) { if ($answer->response != NULL) { echo ""; - echo "$answer->answer: "; + $options->para = false; + echo "".format_text($answer->answer,FORMAT_MOODLE,$options).": "; echo "jumpto;document.answerform.submit();\"". - "value = \"$otherjump->answer\" />"; + "value = \"".strip_tags(format_text($otherjump->answer,FORMAT_MOODLE,$options))."\" />"; } echo ""; foreach ($nextprevious as $jump) { @@ -762,10 +764,11 @@ echo "jumpto;document.answerform.submit();\"". "value = \"$jump->answer\" />"; } - } + } + $options->para = false; foreach ($otherjumps as $otherjump) { echo "jumpto;document.answerform.submit();\"". - "value = \"$otherjump->answer\" />"; + "value = \"".strip_tags(format_text($otherjump->answer,FORMAT_MOODLE,$options))."\" />"; } foreach ($nextprevious as $jump) { if ($jump->jumpto == LESSON_PREVIOUSPAGE) { @@ -776,9 +779,10 @@ } /* if(!$lesson->slideshow) { + $options->para = false; foreach ($answers as $answer) { echo ""; - echo "answer\""; + echo "answer,FORMAT_MOODLE,$options))."\""; echo "onclick=\"document.answerform.jumpto.value=$answer->jumpto;document.answerform.submit();\" />"; echo ""; } @@ -1411,6 +1415,7 @@ $jumptitle = "".get_string("notdefined", "lesson").""; } } + $jumptitle = format_string($jumptitle,true); /// CDC-FLAG /// if ($page->qtype == LESSON_MATCHING) { if ($i == 1) { @@ -1661,7 +1666,7 @@ unset($table->data); $table->head = array(get_string("comments", "lesson")); - $table->data[] = array("\n"); + $table->data[] = array("\n"); if ($lesson->custom) { for ($i=$answer->score; $i>=0; $i--) { $options[$i] = $i; @@ -1779,10 +1784,10 @@ $message .= $pages[$essay->pageid]->contents; $message .= "

"; $message .= get_string('yourresponse', 'lesson').":
"; - $message .= $essayinfo->answer; + $message .= format_text($essayinfo->answer); $message .= "

"; $message .= get_string('commentswithname', 'lesson', $USER).":
"; - $message .= $essayinfo->response; + $message .= format_text($essayinfo->response); $message .= "

"; $grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $essay->userid", "completed", "*", $essay->retry, 1); $grade = current($grades);