]> git.mjollnir.org Git - moodle.git/commitdiff
qtype admin: MDL-16412 Enforce the allowed question types when a user tries to create...
authortjhunt <tjhunt>
Thu, 26 Feb 2009 06:06:18 +0000 (06:06 +0000)
committertjhunt <tjhunt>
Thu, 26 Feb 2009 06:06:18 +0000 (06:06 +0000)
question/question.php

index 5f0ee6d809bc54143c7ce47db8ced2071883b8c6..7bb670fc0ce117cd1d1cc84f0810c2d6803561b7 100644 (file)
@@ -61,6 +61,12 @@ if ($id) {
     $question = new stdClass;
     $question->category = $categoryid;
     $question->qtype = $qtype;
+
+    // Check that users are allowed to create this question type at the moment.
+    $allowedtypes = question_type_menu();
+    if (!isset($allowedtypes[$qtype])) {
+        print_error('cannotenable', 'question', $returnurl, $qtype);
+    }
 } else {
     print_error('notenoughdatatoeditaquestion', 'question', $returnurl);
 }