Bringing Quiz in line with Martin's "make Chat into a showcase for pages" idea.

This commit is contained in:
defacer
2005-02-10 01:59:11 +00:00
parent 29ba5158ad
commit 4f0d565da6
6 changed files with 87 additions and 80 deletions
-1
View File
@@ -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 ////////////////////////////////////////////////////
+1 -76
View File
@@ -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 .= ' <a href="'.$href.'">'.$text.'</a> ->';
}
}
if(empty($morebreadcrumbs) && $this->user_allowed_editing()) {
$buttons = '<table><tr><td><form target="'.$CFG->framename.'" method="get" action="edit.php">'.
'<input type="hidden" name="quizid" value="'.$this->activityrecord->id.'" />'.
'<input type="submit" value="'.get_string('editquestions', 'quiz').'" /></form></td><td>'.
update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'quiz')).
'</td>'.
'<td><form target="'.$CFG->framename.'" method="get" action="view.php">'.
'<input type="hidden" name="id" value="'.$this->modulerecord->id.'" />'.
'<input type="hidden" name="edit" value="'.($this->user_is_editing()?'off':'on').'" />'.
'<input type="submit" value="'.get_string($this->user_is_editing()?'turneditingoff':'blocksaddedit').'" /></form></td></tr></table>';
}
else {
$buttons = '&nbsp;';
}
print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord));
}
function get_type() {
return PAGE_QUIZ_VIEW;
}
}
?>
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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);
+82
View File
@@ -0,0 +1,82 @@
<?php // $Id$
require_once($CFG->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 .= ' <a href="'.$href.'">'.$text.'</a> ->';
}
}
if(empty($morebreadcrumbs) && $this->user_allowed_editing()) {
$buttons = '<table><tr><td><form target="'.$CFG->framename.'" method="get" action="edit.php">'.
'<input type="hidden" name="quizid" value="'.$this->activityrecord->id.'" />'.
'<input type="submit" value="'.get_string('editquestions', 'quiz').'" /></form></td><td>'.
update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'quiz')).
'</td>'.
'<td><form target="'.$CFG->framename.'" method="get" action="view.php">'.
'<input type="hidden" name="id" value="'.$this->modulerecord->id.'" />'.
'<input type="hidden" name="edit" value="'.($this->user_is_editing()?'off':'on').'" />'.
'<input type="submit" value="'.get_string($this->user_is_editing()?'turneditingoff':'blocksaddedit').'" /></form></td></tr></table>';
}
else {
$buttons = '&nbsp;';
}
print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord));
}
function get_type() {
return PAGE_QUIZ_VIEW;
}
}
?>
+2 -1
View File
@@ -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