From 88f3ed390fe14493b86038df10808b384bc52ecf Mon Sep 17 00:00:00 2001 From: thepurpleblob Date: Thu, 26 Jul 2007 10:54:53 +0000 Subject: [PATCH] MDL-9123: Check that the selected category is allowed. --- question/import.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/question/import.php b/question/import.php index ce434ff2834..c3afc6fc28f 100644 --- a/question/import.php +++ b/question/import.php @@ -73,10 +73,14 @@ } } - if (!$courseid) { // need to get the course from the chosen category - $courseid = $category->course; + // check category is valid (against THIS courseid, before we change it) + $validcats = question_category_options( $courseid, true, true ); + if (!array_key_exists( $categoryid, $validcats )) { + print_error( 'invalidcategory', 'quiz' ); } + $courseid = $category->course; + if (!$course = get_record("course", "id", $courseid)) { error("Invalid course!"); }