From e3fa6587ee45ca8117996ca1ba895e1bb89daa40 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Thu, 9 Aug 2007 15:38:35 +0000 Subject: [PATCH] Helper method to help when calling print_error from a question type. --- question/type/questiontype.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 31a80022cc..9c6499f7c3 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -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 //////////////////////////// /* -- 2.39.5