From 8ed358dbca9f2b934bdcb23238e88db73447f12e Mon Sep 17 00:00:00 2001
From: tjhunt <tjhunt>
Date: Thu, 26 Feb 2009 06:06:18 +0000
Subject: [PATCH] qtype admin: MDL-16412 Enforce the allowed question types
 when a user tries to create a question.

---
 question/question.php | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/question/question.php b/question/question.php
index 5f0ee6d809..7bb670fc0c 100644
--- a/question/question.php
+++ b/question/question.php
@@ -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);
 }
-- 
2.39.5