Browse files

Fix for bug 4810

  • Loading branch information...
1 parent 1d0f9df commit fbf0e2a2042af6393e421652c221e3517501d155 gustav_delius committed Feb 20, 2006
Showing with 9 additions and 3 deletions.
  1. +9 −3 mod/quiz/import.php
View
12 mod/quiz/import.php
@@ -134,16 +134,22 @@
print_heading_with_help($strimportquestions, "import", "quiz");
/// Get all the existing categories now
- $sql = "SELECT c.*
+ if (isadmin()) { // the admin can import into all categories
+ if (!$categories = get_records_select("quiz_categories", "course = '{$course->id}' OR publish = '1'", "parent, sortorder, name ASC")) {
+ error("Could not find any question categories!"); // Something is really wrong
+ }
+ } else { // select only the categories to which the teacher has write access
+ $sql = "SELECT c.*
FROM {$CFG->prefix}quiz_categories AS c,
{$CFG->prefix}user_teachers AS t
WHERE t.userid = '$USER->id'
AND t.course = c.course
AND (c.course = '$course->id'
OR (c.publish = '1' AND t.editall = '1'))
ORDER BY c.parent ASC, c.sortorder ASC, c.name ASC";
- if (!$categories = get_records_sql($sql)) {
- error("Could not find any question categories!");
+ if (!$categories = get_records_sql($sql)) {
+ error("Could not find any question categories!");
+ }
}
$categories = add_indented_names($categories);
foreach ($categories as $key => $cat) {

0 comments on commit fbf0e2a

Please sign in to comment.