diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 56ba4ef3f9c..a67efe0fcb0 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -112,7 +112,6 @@ define('PARAM_BOOL', 0x0800); //convert to value 1 or 0 using empty() * Definition of page types */ define('PAGE_COURSE_VIEW', 'course-view'); -define('PAGE_QUIZ_VIEW', 'mod-quiz-view'); /// PARAMETER HANDLING //////////////////////////////////////////////////// diff --git a/lib/pagelib.php b/lib/pagelib.php index 78e6a9d06b7..a380447537f 100644 --- a/lib/pagelib.php +++ b/lib/pagelib.php @@ -69,8 +69,7 @@ function page_map_class($type, $classname = NULL) { if ($mappings === NULL) { $mappings = array( - PAGE_COURSE_VIEW => 'page_course', - PAGE_QUIZ_VIEW => 'page_quiz' + PAGE_COURSE_VIEW => 'page_course' ); } @@ -559,78 +558,4 @@ class page_generic_activity extends page_base { } } -/** - * Class that models the behavior of a quiz - * - * @author Jon Papaioannou - * @package pages - */ - -class page_quiz extends page_generic_activity { - - function init_quick($data) { - if(empty($data->pageid)) { - error('Cannot quickly initialize page: empty course id'); - } - $this->activityname = 'quiz'; - parent::init_quick($data); - } - - function print_header($title, $morebreadcrumbs = NULL) { - global $USER, $CFG; - - $this->init_full(); - $replacements = array( - '%fullname%' => $this->activityrecord->name - ); - foreach($replacements as $search => $replace) { - $title = str_replace($search, $replace, $title); - } - - $breadcrumbs = array( - $this->courserecord->shortname => $CFG->wwwroot.'/course/view.php?id='.$this->courserecord->id, - get_string('modulenameplural', 'quiz') => $CFG->wwwroot.'/mod/quiz/index.php?id='.$this->courserecord->id, - $this->activityrecord->name => $CFG->wwwroot.'/mod/quiz/view.php?id='.$this->modulerecord->id, - ); - - if(!empty($morebreadcrumbs)) { - $breadcrumbs = array_merge($breadcrumbs, $morebreadcrumbs); - } - - $total = count($breadcrumbs); - $current = 1; - $crumbtext = ''; - foreach($breadcrumbs as $text => $href) { - if($current++ == $total) { - $crumbtext .= ' '.$text; - } - else { - $crumbtext .= ' '.$text.' ->'; - } - } - - if(empty($morebreadcrumbs) && $this->user_allowed_editing()) { - $buttons = ''. - '
'. - ''. - '
'. - update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'quiz')). - '
'. - ''. - ''. - '
'; - } - else { - $buttons = ' '; - } - print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord)); - - } - - function get_type() { - return PAGE_QUIZ_VIEW; - } -} - - ?> diff --git a/mod/chat/pagelib.php b/mod/chat/pagelib.php index d008a796664..b50c4b54612 100644 --- a/mod/chat/pagelib.php +++ b/mod/chat/pagelib.php @@ -4,7 +4,7 @@ require_once($CFG->libdir.'/pagelib.php'); define('PAGE_CHAT_VIEW', 'mod-chat-view'); -page_map_class('mod-chat-view', 'page_chat'); +page_map_class(PAGE_CHAT_VIEW, 'page_chat'); /** * Class that models the behavior of a chat diff --git a/mod/chat/view.php b/mod/chat/view.php index da9910576b1..d3c417868dc 100644 --- a/mod/chat/view.php +++ b/mod/chat/view.php @@ -4,7 +4,7 @@ require_once('../../config.php'); require_once('lib.php'); - require_once($CFG->dirroot.'/lib/blocklib.php'); + require_once($CFG->libdir.'/blocklib.php'); require_once('pagelib.php'); $id = optional_param('id', 0, PARAM_INT); diff --git a/mod/quiz/pagelib.php b/mod/quiz/pagelib.php new file mode 100644 index 00000000000..ed878cf8b55 --- /dev/null +++ b/mod/quiz/pagelib.php @@ -0,0 +1,82 @@ +libdir.'/pagelib.php'); + +define('PAGE_QUIZ_VIEW', 'mod-quiz-view'); + +page_map_class(PAGE_QUIZ_VIEW, 'page_quiz'); + +/** + * Class that models the behavior of a quiz + * + * @author Jon Papaioannou + * @package pages + */ + +class page_quiz extends page_generic_activity { + + function init_quick($data) { + if(empty($data->pageid)) { + error('Cannot quickly initialize page: empty course id'); + } + $this->activityname = 'quiz'; + parent::init_quick($data); + } + + function print_header($title, $morebreadcrumbs = NULL) { + global $USER, $CFG; + + $this->init_full(); + $replacements = array( + '%fullname%' => $this->activityrecord->name + ); + foreach($replacements as $search => $replace) { + $title = str_replace($search, $replace, $title); + } + + $breadcrumbs = array( + $this->courserecord->shortname => $CFG->wwwroot.'/course/view.php?id='.$this->courserecord->id, + get_string('modulenameplural', 'quiz') => $CFG->wwwroot.'/mod/quiz/index.php?id='.$this->courserecord->id, + $this->activityrecord->name => $CFG->wwwroot.'/mod/quiz/view.php?id='.$this->modulerecord->id, + ); + + if(!empty($morebreadcrumbs)) { + $breadcrumbs = array_merge($breadcrumbs, $morebreadcrumbs); + } + + $total = count($breadcrumbs); + $current = 1; + $crumbtext = ''; + foreach($breadcrumbs as $text => $href) { + if($current++ == $total) { + $crumbtext .= ' '.$text; + } + else { + $crumbtext .= ' '.$text.' ->'; + } + } + + if(empty($morebreadcrumbs) && $this->user_allowed_editing()) { + $buttons = ''. + '
'. + ''. + '
'. + update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'quiz')). + '
'. + ''. + ''. + '
'; + } + else { + $buttons = ' '; + } + print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord)); + + } + + function get_type() { + return PAGE_QUIZ_VIEW; + } +} + +?> \ No newline at end of file diff --git a/mod/quiz/view.php b/mod/quiz/view.php index 0ae18213fcc..f37759a9223 100644 --- a/mod/quiz/view.php +++ b/mod/quiz/view.php @@ -4,7 +4,8 @@ require_once("../../config.php"); require_once("locallib.php"); - require_once($CFG->dirroot.'/lib/blocklib.php'); + require_once($CFG->libdir.'/blocklib.php'); + require_once('pagelib.php'); $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or $q = optional_param('q', 0, PARAM_INT); // quiz ID