Browse files

Fixed bug described in http://moodle.org/mod/forum/discuss.php?d=26880

…(missing addslashes before DB insert).
  • Loading branch information...
1 parent 4027500 commit c1b6ab811885a75658de63a2898bde18765a5a80 mindforge committed Jul 8, 2005
View
3 mod/quiz/questiontypes/multianswer/editquestion.php
@@ -43,7 +43,8 @@
set_field('quiz_questions', 'questiontext', $parsableanswerdef,
'id', $wrapped->id);
} else {
- $parsableanswerdef = $wrapped->questiontext;
+ $parsableanswerdef = str_replace('&#', '&\#',
+ $wrapped->questiontext);
}
//echo "{#$key}<br />";
//echo $parsableanswerdef.'<br />';
View
23 mod/quiz/questiontypes/multianswer/questiontype.php
@@ -366,6 +366,7 @@ function quiz_qtype_multianswer_extract_question($text) {
// Handle the entity encoded ampersand in entities (e.g. &amp;lt; -> &lt;)
$text = preg_replace('/&amp;(.{2,9}?;)/', '&${1}', $text);
+ $text = stripslashes($text);
// ANSWER_ALTERNATIVE regexes
define("ANSWER_ALTERNATIVE_FRACTION_REGEX",
@@ -423,8 +424,8 @@ function quiz_qtype_multianswer_extract_question($text) {
////////////////////////////////////////
$question = new stdClass;
- $question->qtype= MULTIANSWER;
- $question->questiontext= stripslashes($text);
+ $question->qtype = MULTIANSWER;
+ $question->questiontext = $text;
$question->options->questions = array();
$question->defaultgrade = 0; // Will be increased for each answer norm
@@ -468,31 +469,35 @@ function quiz_qtype_multianswer_extract_question($text) {
} else {
$wrapped->fraction[] = '0';
}
- $wrapped->feedback[] =
+ $wrapped->feedback[] = addslashes(str_replace('&\#', '&#',
isset($altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK])
- ? $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK] : '';
+ ? $altregs[ANSWER_ALTERNATIVE_REGEX_FEEDBACK] : ''));
if (!empty($answerregs[ANSWER_REGEX_ANSWER_TYPE_NUMERICAL])
&& ereg(NUMERICAL_ALTERNATIVE_REGEX,
$altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER],
$numregs) )
{
- $wrapped->answer[] = $numregs[NUMERICAL_CORRECT_ANSWER];
+ $wrapped->answer[] =
+ addslashes($numregs[NUMERICAL_CORRECT_ANSWER]);
if ($numregs[NUMERICAL_ABS_ERROR_MARGIN]) {
- $wrapped->tolerance[] = $numregs[NUMERICAL_ABS_ERROR_MARGIN];
+ $wrapped->tolerance[] =
+ $numregs[NUMERICAL_ABS_ERROR_MARGIN];
} else {
$wrapped->tolerance[] = 0;
}
} else { // Tolerance can stay undefined for non numerical questions
- $wrapped->answer[] = $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER];
+ $wrapped->answer[] = addslashes(str_replace('&\#', '&#',
+ $altregs[ANSWER_ALTERNATIVE_REGEX_ANSWER]));
}
$tmp = explode($altregs[0], $remainingalts, 2);
$remainingalts = $tmp[1];
}
$question->defaultgrade += $wrapped->defaultgrade;
$question->options->questions[$positionkey] = clone($wrapped);
- $question->questiontext = implode("{#$positionkey}",
- explode($answerregs[0], $question->questiontext, 2));
+ $question->questiontext = addslashes(str_replace('&\#', '&#',
+ implode("{#$positionkey}", explode($answerregs[0],
+ $question->questiontext, 2))));
}
return $question;
}

0 comments on commit c1b6ab8

Please sign in to comment.