From 4b99463645d75fbd63421a9d15d1fdef7bbe44d6 Mon Sep 17 00:00:00 2001 From: ubuntu Date: Fri, 16 Aug 2013 16:58:18 +0300 Subject: [PATCH] Fix: Rename header.php to headergame.php --- export.php | 2 +- headergame.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ preview.php | 2 +- showanswers.php | 2 +- showattempts.php | 2 +- version.php | 4 +-- 6 files changed, 83 insertions(+), 6 deletions(-) create mode 100755 headergame.php diff --git a/export.php b/export.php index 85f31fd..6e52ff3 100755 --- a/export.php +++ b/export.php @@ -12,7 +12,7 @@ ob_start(); require_once ($CFG->dirroot.'/lib/formslib.php'); require( 'locallib.php'); -require( 'header.php'); +require( 'headergame.php'); $context = get_context_instance(CONTEXT_MODULE, $cm->id); if (!has_capability('mod/game:viewreports', $context)) diff --git a/headergame.php b/headergame.php new file mode 100755 index 0000000..89126fc --- /dev/null +++ b/headergame.php @@ -0,0 +1,77 @@ +libdir.'/gradelib.php'); + require_once($CFG->dirroot.'/mod/game/locallib.php'); + require_once($CFG->libdir . '/completionlib.php'); + + $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or + $q = optional_param('q', 0, PARAM_INT); // game ID + + if ($id) { + if (! $cm = get_coursemodule_from_id('game', $id)) { + print_error('invalidcoursemodule'); + } + if (! $course = $DB->get_record('course', array('id' => $cm->course))) { + print_error('coursemisconf'); + } + if (! $game = $DB->get_record('game', array('id' => $cm->instance))) { + print_error('invalidcoursemodule'); + } + } else { + if (! $game = $DB->get_record('game', array('id' => $q))) { + print_error('invalidgameid q='.$q, 'game'); + } + if (! $course = $DB->get_record('course', array('id' => $game->course))) { + print_error('invalidcourseid'); + } + if (! $cm = get_coursemodule_from_instance('game', $game->id, $course->id)) { + print_error('invalidcoursemodule'); + } + } + +/// Check login and get context. + require_login($course->id, false, $cm); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + require_capability('mod/game:view', $context); + +/// Cache some other capabilites we use several times. + $canattempt = has_capability('mod/game:attempt', $context); + $canreviewmine = has_capability('mod/game:reviewmyattempts', $context); + +/// Create an object to manage all the other (non-roles) access rules. + $timenow = time(); + //$accessmanager = new game_access_manager(game::create($game->id, $USER->id), $timenow); + +/// If no questions have been set up yet redirect to edit.php + //if (!$game->questions && has_capability('mod/game:manage', $context)) { + // redirect($CFG->wwwroot . '/mod/game/edit.php?cmid=' . $cm->id); + //} + +/// Log this request. + add_to_log($course->id, 'game', 'view', "view.php?id=$cm->id", $game->id, $cm->id); + +/// Initialize $PAGE, compute blocks + $PAGE->set_url('/mod/game/view.php', array('id' => $cm->id)); + + $edit = optional_param('edit', -1, PARAM_BOOL); + if ($edit != -1 && $PAGE->user_allowed_editing()) { + $USER->editing = $edit; + } + + // Note: MDL-19010 there will be further changes to printing header and blocks. + // The code will be much nicer than this eventually. + $title = $course->shortname . ': ' . format_string($game->name); + + if ($PAGE->user_allowed_editing() && !empty($CFG->showblocksonmodpages)) { + $buttons = '
'. + ''. + ''. + '
'; + $PAGE->set_button($buttons); + } + + $PAGE->set_title($title); + $PAGE->set_heading($course->fullname); + + echo $OUTPUT->header(); diff --git a/preview.php b/preview.php index 9417f02..87f5f0c 100755 --- a/preview.php +++ b/preview.php @@ -18,7 +18,7 @@ require_once( "sudoku/play.php"); require_once( "bookquiz/play.php"); - require_once( "header.php"); + require_once( "headergame.php"); $context = get_context_instance(CONTEXT_MODULE, $cm->id); diff --git a/showanswers.php b/showanswers.php index d6ae1a1..5b404e7 100755 --- a/showanswers.php +++ b/showanswers.php @@ -8,7 +8,7 @@ **/ require_once("../../config.php"); - require_once( "header.php"); + require_once( "headergame.php"); if (!has_capability('mod/game:viewreports', $context)){ print_error( get_string( 'only_teachers', 'game')); diff --git a/showattempts.php b/showattempts.php index 041c16f..a708aaf 100755 --- a/showattempts.php +++ b/showattempts.php @@ -8,7 +8,7 @@ **/ require_once("../../config.php"); - require_once( "header.php"); + require_once( "headergame.php"); if (!has_capability('mod/game:viewreports', $context)){ print_error( get_string( 'only_teachers', 'game')); diff --git a/version.php b/version.php index 0450899..2b3fddc 100755 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ defined('MOODLE_INTERNAL') || die(); $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$module->version = 2013081301; // The current module version (Date: YYYYMMDDXX) +$module->version = 2013081601; // The current module version (Date: YYYYMMDDXX) $module->requires = 2010112400; // Requires Moodle 2.0 $module->cron = 0; // Period for cron to check this module (secs) -$module->release = '3.8.13'; +$module->release = '3.8.16';