Permalink
Browse files

MDL-28438 Aiken question import broken since MDL-24594.

  • Loading branch information...
1 parent 3a5778e commit 8ad92a30f12783ebcca5ef3430e0994b7f20ee6f @timhunt timhunt committed Aug 15, 2011
View
@@ -595,7 +595,9 @@ protected function defaultquestion() {
$question->image = "";
$question->usecase = 0;
$question->multiplier = array();
+ $question->questiontextformat = FORMAT_MOODLE;
$question->generalfeedback = '';
+ $question->generalfeedbackformat = FORMAT_MOODLE;
$question->correctfeedback = '';
$question->partiallycorrectfeedback = '';
$question->incorrectfeedback = '';
@@ -76,12 +76,11 @@ public function readquestions($lines) {
}
if (preg_match('/^[A-Z][).][ \t]/', $nowline)) {
// A choice. Trim off the label and space, then save
- $question->answer[] = htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES);
+ $question->answer[] = $this->text_field(
+ htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES));
$question->fraction[] = 0;
- $question->feedback[] = '';
- continue;
- }
- if (preg_match('/^ANSWER:/', $nowline)) {
+ $question->feedback[] = $this->text_field('');
+ } else if (preg_match('/^ANSWER:/', $nowline)) {
// The line that indicates the correct answer. This question is finised.
$ans = trim(substr($nowline, strpos($nowline, ':') + 1));
$ans = substr($ans, 0, 1);
@@ -97,15 +96,31 @@ public function readquestions($lines) {
// Must be the first line of a new question, since no recognised prefix.
$question->qtype = MULTICHOICE;
$question->name = shorten_text(s($nowline), 50);
- $question->questiontext = s($nowline);
+ $question->questiontext = htmlspecialchars(trim($nowline), ENT_NOQUOTES);
+ $question->questiontextformat = FORMAT_HTML;
+ $question->generalfeedback = '';
+ $question->generalfeedbackformat = FORMAT_HTML;
$question->single = 1;
- $question->feedback[] = '';
+ $question->answer = array();
+ $question->fraction = array();
+ $question->feedback = array();
+ $question->correctfeedback = $this->text_field('');
+ $question->partiallycorrectfeedback = $this->text_field('');
+ $question->incorrectfeedback = $this->text_field('');
}
}
}
return $questions;
}
+ protected function text_field($text) {
+ return array(
+ 'text' => htmlspecialchars(trim($text), ENT_NOQUOTES),
+ 'format' => FORMAT_HTML,
+ 'files' => array(),
+ );
+ }
+
public function readquestion($lines) {
//this is no longer needed but might still be called by default.php
return;
@@ -0,0 +1,11 @@
+The Moodle project was started by:
+A) Petr Skoda
+B) Martin Dougiamas
+C) Eloy Lafuente
+D) Tim Hunt
+ANSWER: B
+
+Moodle's abilities include handling user input that includes <html class="cool"> & images:
+A) True
+B) False
+ANSWER: A

0 comments on commit 8ad92a3

Please sign in to comment.