MDL-14928 - Adding random questions from a category with an apostrophe in the name does not work. Stupid bloody addslashes. Roll on dmllib 2.0.

This commit is contained in:
tjhunt
2008-05-20 17:09:40 +00:00
parent 46293bd7b7
commit 949c59ace0
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -416,9 +416,9 @@ class question_category_object {
//never move category where it is the default
if (1 != count_records_sql("SELECT count(*) FROM {$CFG->prefix}question_categories c1, {$CFG->prefix}question_categories c2 WHERE c2.id = $updateid AND c1.contextid = c2.contextid")){
// If the question name has changed, rename any random questions in that category.
if ($oldcat->name != $cat->name) {
if (addslashes($oldcat->name) != $cat->name) {
$randomqname = $QTYPES[RANDOM]->question_name($cat);
set_field('question', 'name', $randomqname, 'category', $cat->id, 'qtype', RANDOM);
set_field('question', 'name', addslashes($randomqname), 'category', $cat->id, 'qtype', RANDOM);
// Ignore errors here. It is not a big deal if the questions are not renamed.
}
+1 -1
View File
@@ -57,7 +57,7 @@ class random_qtype extends default_questiontype {
print_error('cannotretrieveqcat', 'question');
}
$question->name = $this->question_name($category);
if (!set_field('question', 'name', $question->name, 'id', $question->id)) {
if (!set_field('question', 'name', addslashes($question->name), 'id', $question->id)) {
print_error('cannotupdaterandomqname', 'question');
}
return $question;