]> git.mjollnir.org Git - moodle.git/commitdiff
Get the contexts without referring to undefined variables.
authortjhunt <tjhunt>
Wed, 23 Aug 2006 15:12:52 +0000 (15:12 +0000)
committertjhunt <tjhunt>
Wed, 23 Aug 2006 15:12:52 +0000 (15:12 +0000)
mod/quiz/edit.php

index e2d0d0db93dd81b8c8ceca6a6ef518f7f3d856e4..80b3b2b05d4992d368a68256f1db44713d947ed8 100644 (file)
             }
             $modform->instance = $modform->id;
             $SESSION->modform = $modform;    // Save the form in the current session
-
-            $cm = get_coursemodule_from_instance('quiz', $modform->instance);
-            $modform->cmid = $cm->id;
-            // We don't log all visits to this page but only those that recreate modform
-            add_to_log($cm->course, 'quiz', 'editquestions',
-                               "view.php?id=$cm->id",
-                               "$quizid", $cm->id);
         }
 
     } else if (!empty($sortorder)) {
@@ -96,15 +89,23 @@ if (self.name == 'editquestion') {
         }
     }
 
+    // Get the course object and related bits.
     if (! $course = get_record("course", "id", $modform->course)) {
         error("This course doesn't exist");
     }
-    
-    $coursecontext = get_context_instance(CONTEXT_COURSE, $id);
+    $coursecontext = get_context_instance(CONTEXT_COURSE, $modform->course);
 
     require_login($course->id, false);
-
+    
+    // Get the module and related bits.
+    $cm = get_coursemodule_from_instance('quiz', $modform->instance);
+    $modform->cmid = $cm->id;
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+    // Log this visit.
+    add_to_log($cm->course, 'quiz', 'editquestions',
+            "view.php?id=$cm->id", "$quizid", $cm->id);
+
     require_capability('mod/quiz:manage', $context);
 
     if (isset($modform->instance)