]> git.mjollnir.org Git - moodle.git/commitdiff
Helper method to help when calling print_error from a question type.
authortjhunt <tjhunt>
Thu, 9 Aug 2007 15:38:35 +0000 (15:38 +0000)
committertjhunt <tjhunt>
Thu, 9 Aug 2007 15:38:35 +0000 (15:38 +0000)
question/type/questiontype.php

index 31a80022cc76bec4a89d90b2515c4821e7b5a469..9c6499f7c306b42289fe31a18383e62b3d1be561 100644 (file)
@@ -1345,6 +1345,22 @@ class default_questiontype {
         return format_text($text, $textformat, $formatoptions, $cmoptions === NULL ? NULL : $cmoptions->course);
     }
 
+    /**
+     * @return the best link to pass to print_error.
+     * @param $cmoptions as passed in from outside.
+     */
+    function error_link($cmoptions) {
+        global $CFG;
+        $cm = get_coursemodule_from_instance('quiz', $cmoptions->id);
+        if (!empty($cm->id)) {
+            return $CFG->wwwroot . '/mod/quiz/view.php?id=' . $cm->id;
+        } else if (!empty($cm->course)) {
+            return $CFG->wwwroot . '/course/view.php?id=' . $cm->course;
+        } else {
+            return '';
+        }
+    }
+
 /// BACKUP FUNCTIONS ////////////////////////////
 
     /*