Browse Source

Fix:Coding style

MOODLE_20_STABLE
Vasilis Daloukas 9 years ago
parent
commit
1bba3bc469
  1. 20
      classes/plugininfo/booktool.php~
  2. 35
      lib.php
  3. 12
      locallib.php
  4. 14
      report.php
  5. 18
      review.php
  6. 4
      tabs.php

20
classes/plugininfo/booktool.php~

@ -1,20 +0,0 @@
<?php
/**
* Subplugin info class.
*
* @package mod_game
* @copyright 2014 Vasilis Daloukas
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_book\plugininfo;
use core\plugininfo\base;
defined('MOODLE_INTERNAL') || die();
class gametool extends base {
public function is_uninstall_allowed() {
return true;
}
}

35
lib.php

@ -158,7 +158,7 @@ function game_before_add_or_update(&$game) {
$draftitemid = $game->param4; $draftitemid = $game->param4;
if (isset( $game->id)) { if (isset( $game->id)) {
$cmg = get_coursemodule_from_instance('game', $game->id, $game->course); $cmg = get_coursemodule_from_instance('game', $game->id, $game->course);
$modcontext = get_context_instance(CONTEXT_MODULE, $cmg->id); $modcontext = game_get_context_module_instance( $cmg->id);
$attachmentoptions = array('subdirs' => 0, 'maxbytes' => 9999999, 'maxfiles' => 1); $attachmentoptions = array('subdirs' => 0, 'maxbytes' => 9999999, 'maxfiles' => 1);
file_save_draft_area_files($draftitemid, $modcontext->id, 'mod_game', 'snakes_file', $game->id, file_save_draft_area_files($draftitemid, $modcontext->id, 'mod_game', 'snakes_file', $game->id,
array('subdirs' => 0, 'maxbytes' => 9999999, 'maxfiles' => 1)); array('subdirs' => 0, 'maxbytes' => 9999999, 'maxfiles' => 1));
@ -521,7 +521,7 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$course = $DB->get_record('course', array( 'id' => $courseid)); $course = $DB->get_record('course', array( 'id' => $courseid));
} }
$modinfo =& get_fast_modinfo($course); $modinfo = get_fast_modinfo($course);
$cm = $modinfo->cms[$cmid]; $cm = $modinfo->cms[$cmid];
@ -539,8 +539,7 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$groupjoin = ""; $groupjoin = "";
} }
if (!$attempts = $DB->get_records_sql("SELECT qa.*, q.grade, if (!$attempts = $DB->get_records_sql("SELECT qa.*, qa.gameid, q.grade, u.lastname,u.firstname, firstnamephonetic, u.lastnamephonetic, u.middlename, u.alternatename, u.lastnamephonetic, u.picture
u.firstname, u.lastname, u.email, u.picture
FROM {game_attempts} qa FROM {game_attempts} qa
JOIN {game} q ON q.id = qa.gameid JOIN {game} q ON q.id = qa.gameid
JOIN {user} u ON u.id = qa.userid JOIN {user} u ON u.id = qa.userid
@ -551,11 +550,10 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
return; return;
} }
$cmcontext = get_context_instance(CONTEXT_MODULE, $cm->id); $cmcontext = game_get_context_module_instance( $cm->id);
$grader = has_capability('moodle/grade:viewall', $cmcontext); $grader = has_capability('moodle/grade:viewall', $cmcontext);
$accessallgroups = has_capability('moodle/site:accessallgroups', $cmcontext); $accessallgroups = has_capability('moodle/site:accessallgroups', $cmcontext);
$viewfullnames = has_capability('moodle/site:viewfullnames', $cmcontext); $viewfullnames = has_capability('moodle/site:viewfullnames', $cmcontext);
$grader = has_capability('mod/game:grade', $cmcontext);
$groupmode = groups_get_activity_groupmode($cm, $course); $groupmode = groups_get_activity_groupmode($cm, $course);
if (is_null($modinfo->groups)) { if (is_null($modinfo->groups)) {
@ -586,31 +584,43 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course
$tmpactivity = new object(); $tmpactivity = new object();
$tmpactivity->type = 'game'; $tmpactivity->type = 'game';
$tmpactivity->gameid = $attempt->gameid;
$tmpactivity->cmid = $cm->id; $tmpactivity->cmid = $cm->id;
$tmpactivity->name = $aname; $tmpactivity->name = $aname;
$tmpactivity->sectionnum = $cm->sectionnum; $tmpactivity->sectionnum = $cm->sectionnum;
$tmpactivity->timestamp = $attempt->timefinish; $tmpactivity->timestamp = $attempt->timefinish;
$tmpactivity->content = new object();
$tmpactivity->content->attemptid = $attempt->id; $tmpactivity->content->attemptid = $attempt->id;
$tmpactivity->content->sumgrades = $attempt->score * $attempt->grade; $tmpactivity->content->sumgrades = $attempt->score * $attempt->grade;
$tmpactivity->content->maxgrade = $attempt->grade; $tmpactivity->content->maxgrade = $attempt->grade;
$tmpactivity->content->attempt = $attempt->attempt; $tmpactivity->content->attempt = $attempt->attempt;
$tmpactivity->user->userid = $attempt->userid; $tmpactivity->user = new object();
$tmpactivity->user->userid = $tmpactivity->user->id = $attempt->userid;
$tmpactivity->user->fullname = fullname($attempt, $viewfullnames); $tmpactivity->user->fullname = fullname($attempt, $viewfullnames);
$tmpactivity->user->firstname = $attempt->firstname;
$tmpactivity->user->lastname = $attempt->lastname;
$tmpactivity->user->alternatename = $attempt->alternatename;
$tmpactivity->user->middlename = $attempt->middlename;
$tmpactivity->user->firstnamephonetic = $attempt->firstnamephonetic;
$tmpactivity->user->lastnamephonetic = $attempt->lastnamephonetic;
$tmpactivity->user->picture = $attempt->picture; $tmpactivity->user->picture = $attempt->picture;
$tmpactivity->user->imagealt = $attempt->imagealt;
$tmpactivity->user->email = $attempt->email;
$activities[$index++] = $tmpactivity; $activities[$index++] = $tmpactivity;
} }
} }
function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames) { function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames) {
global $CFG; global $CFG, $OUTPUT;
echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">'; echo '<table border="0" cellpadding="3" cellspacing="0" class="forum-recent">';
echo "<tr><td class=\"userpicture\" valign=\"top\">"; echo "<tr><td class=\"userpicture\" valign=\"top\">";
print_user_picture($activity->user->userid, $courseid, $activity->user->picture); //print_user_picture($activity->user->userid, $courseid, $activity->user->picture);
echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid));
echo "</td><td>"; echo "</td><td>";
if ($detail) { if ($detail) {
@ -625,7 +635,8 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames
echo '<div class="grade">'; echo '<div class="grade">';
echo get_string("attempt", "game")." {$activity->content->attempt}: "; echo get_string("attempt", "game")." {$activity->content->attempt}: ";
$grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})"; $grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})";
echo "<a href=\"{$CFG->wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}\">$grades</a>";
echo "<a href=\"{$CFG->wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades</a>";
echo '</div>'; echo '</div>';
echo '<div class="user">'; echo '<div class="user">';
@ -975,7 +986,7 @@ function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
$questionid = $args[ 0]; $questionid = $args[ 0];
$file = $args[ 1]; $file = $args[ 1];
$a = explode( '/', $context->path); $a = explode( '/', $context->path);
if (!$contextcourse = get_context_instance(CONTEXT_COURSE, $course->id)) { if (!$contextcourse = game_get_context_course_instance( $course->id)) {
print_error('nocontext'); print_error('nocontext');
} }
$a = array( 'component' => 'question', 'filearea' => 'questiontext', $a = array( 'component' => 'question', 'filearea' => 'questiontext',
@ -993,7 +1004,7 @@ function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedow
$answerid = $args[ 0]; $answerid = $args[ 0];
$file = $args[ 1]; $file = $args[ 1];
if (!$contextcourse = get_context_instance(CONTEXT_COURSE, $course->id)) { if (!$contextcourse = game_get_context_course_instance( $course->id)) {
print_error('nocontext'); print_error('nocontext');
} }
$rec = $DB->get_record( 'files', array( 'component' => 'question', 'filearea' => 'answer', $rec = $DB->get_record( 'files', array( 'component' => 'question', 'filearea' => 'answer',

12
locallib.php

@ -2132,3 +2132,15 @@ function game_use_events() {
return( $version >= '02.07'); return( $version >= '02.07');
} }
/**
* Get the feedback text that should be show to a student who
* got this grade on this game.
*
* @param float $grade a grade on this game.
* @param integer $gameid the id of the game object.
* @return string the comment that corresponds to this grade (empty string if there is not one.
*/
function game_feedback_for_grade($grade, $gameid) {
return '';
}

14
report.php

@ -18,12 +18,15 @@
require_once("../../config.php"); require_once("../../config.php");
require_once($CFG->dirroot.'/mod/game/locallib.php'); require_once($CFG->dirroot.'/mod/game/locallib.php');
require_once($CFG->dirroot.'/mod/game/report/reportlib.php');
//require_login($course->id, false);
require_once($CFG->dirroot.'/mod/game/headergame.php');
//require_once($CFG->dirroot.'/mod/game/report/reportlib.php');
/*
$id = optional_param('id', 0, PARAM_INT); // Course Module ID. $id = optional_param('id', 0, PARAM_INT); // Course Module ID.
$q = optional_param('q', 0, PARAM_INT); // Game ID. $q = optional_param('q', 0, PARAM_INT); // Game ID.
$mode = optional_param('mode', 'overview', PARAM_ALPHA); // Report mode.
if ($id) { if ($id) {
if (! $cm = get_coursemodule_from_id('game', $id)) { if (! $cm = get_coursemodule_from_id('game', $id)) {
@ -48,14 +51,15 @@ if ($id) {
print_error( "The course module for the game with id $q is missing"); print_error( "The course module for the game with id $q is missing");
} }
} }
*/
require_login($course->id, false); $context = game_get_context_module_instance( $cm->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/game:viewreports', $context); require_capability('mod/game:viewreports', $context);
add_to_log($course->id, "game", "report", "report.php?id=$cm->id", "$game->id", "$cm->id"); //add_to_log($course->id, "game", "report", "report.php?id=$cm->id", "$game->id", "$cm->id");
// Open the selected game report and display it. // Open the selected game report and display it.
$mode = optional_param('mode', 'overview', PARAM_ALPHA); // Report mode.
$mode = clean_param( $mode, PARAM_SAFEDIR); $mode = clean_param( $mode, PARAM_SAFEDIR);

18
review.php

@ -44,13 +44,15 @@ $grade = game_score_to_grade( $attempt->score, $game);
$feedback = game_feedback_for_grade( $grade, $attempt->gameid); $feedback = game_feedback_for_grade( $grade, $attempt->gameid);
require_login( $course->id, false, $cm); require_login( $course->id, false, $cm);
$context = get_context_instance( CONTEXT_MODULE, $cm->id); $context = game_get_context_module_instance( $cm->id);
$coursecontext = get_context_instance( CONTEXT_COURSE, $cm->course); $coursecontext = game_get_context_course_instance( $cm->course);
$isteacher = isteacher( $game->course, $USER->id);
$isteacher = has_capability('mod/game:manage', $context);
$options = game_get_reviewoptions( $game, $attempt, $context); $options = game_get_reviewoptions( $game, $attempt, $context);
$popup = $isteacher ? 0 : $game->popup; // Controls whether this is shown in a javascript-protected window. $popup = $isteacher ? 0 : $game->popup; // Controls whether this is shown in a javascript-protected window.
add_to_log($course->id, "game", "review", "review.php?id=$cm->id&amp;attempt=$attempt->id", "$game->id", "$cm->id"); //add_to_log($course->id, "game", "review", "review.php?id=$cm->id&amp;attempt=$attempt->id", "$game->id", "$cm->id");
// Print the page header. // Print the page header.
@ -68,6 +70,8 @@ $strupdatemodule = has_capability('moodle/course:manageactivities',
$strgames = get_string("modulenameplural", "game"); $strgames = get_string("modulenameplural", "game");
$strgame = get_string("modulename", "game"); $strgame = get_string("modulename", "game");
require( "headergame.php");
/*
if (function_exists( 'build_navigation')) { if (function_exists( 'build_navigation')) {
$navigation = build_navigation('', $cm); $navigation = build_navigation('', $cm);
echo $OUTPUT->heading("$course->shortname: $game->name", "$course->shortname: $game->name", $navigation, echo $OUTPUT->heading("$course->shortname: $game->name", "$course->shortname: $game->name", $navigation,
@ -85,7 +89,7 @@ if (function_exists( 'build_navigation')) {
"", "", true, update_module_button($cm->id, $course->id, $strgame), "", "", true, update_module_button($cm->id, $course->id, $strgame),
navmenu($course, $cm)); navmenu($course, $cm));
} }
*/
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // For overlib. echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'; // For overlib.
// Print heading and tabs if this is part of a preview. // Print heading and tabs if this is part of a preview.
@ -282,6 +286,8 @@ function game_compute_states( $game, $questions) {
} }
function game_print_questions( $pagelist, $attempt, $questions, $options, $states, $game) { function game_print_questions( $pagelist, $attempt, $questions, $options, $states, $game) {
global $QTYPES;
$pagequestions = explode(',', $pagelist); $pagequestions = explode(',', $pagelist);
$number = game_first_questionnumber( $attempt->layout, $pagelist); $number = game_first_questionnumber( $attempt->layout, $pagelist);
foreach ($pagequestions as $i) { foreach ($pagequestions as $i) {
@ -308,8 +314,6 @@ function game_print_questions( $pagelist, $attempt, $questions, $options, $state
$options->feedback = 0; $options->feedback = 0;
$options->readonly = 0; $options->readonly = 0;
global $QTYPES;
unset( $cmoptions); unset( $cmoptions);
$cmoptions->course = $game->course; $cmoptions->course = $game->course;
$cmoptions->optionflags->optionflags = 0; $cmoptions->optionflags->optionflags = 0;

4
tabs.php

@ -35,7 +35,7 @@ if (!isset($course)) {
$course = $DB->get_record('course', array( 'id' => $game->course)); $course = $DB->get_record('course', array( 'id' => $game->course));
} }
$context = get_context_instance(CONTEXT_MODULE, $cm->id); $context = game_get_context_module_instance( $cm->id);
$tabs = array(); $tabs = array();
$row = array(); $row = array();
@ -50,7 +50,7 @@ if (has_capability('mod/game:view', $context)) {
if (has_capability('mod/game:viewreports', $context)) { if (has_capability('mod/game:viewreports', $context)) {
$row[] = new tabobject('reports', "{$CFG->wwwroot}/mod/game/report.php?q=$game->id", get_string('results', 'game')); $row[] = new tabobject('reports', "{$CFG->wwwroot}/mod/game/report.php?q=$game->id", get_string('results', 'game'));
} }
if (has_capability('mod/game:preview', $context)) { if (has_capability('mod/game:manage', $context)) {
$row[] = new tabobject('preview', "{$CFG->wwwroot}/mod/game/attempt.php?a=$game->id", get_string('preview', 'game')); $row[] = new tabobject('preview', "{$CFG->wwwroot}/mod/game/attempt.php?a=$game->id", get_string('preview', 'game'));
} }
if (has_capability('mod/game:manage', $context)) { if (has_capability('mod/game:manage', $context)) {

Loading…
Cancel
Save