]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14928 - Adding random questions from a category with an apostrophe in the name...
authortjhunt <tjhunt>
Tue, 20 May 2008 17:09:40 +0000 (17:09 +0000)
committertjhunt <tjhunt>
Tue, 20 May 2008 17:09:40 +0000 (17:09 +0000)
question/category_class.php
question/type/random/questiontype.php

index 0469f2e5b27a27b840817c1dddc785d9d1214e99..732f38eb762876610db5474460e727f13e78ec12 100644 (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.
             }
 
index 239e43d28da584115062ba42e9a5a74c6e60f486..75ab2da7b4593824a08051446c8164617d289940 100644 (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;