From 1bba3bc469efbc227d03e2fd6cd6c01b216facd0 Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Mon, 28 Dec 2015 19:12:35 +0200 Subject: [PATCH] Fix:Coding style --- classes/plugininfo/booktool.php~ | 20 ------------------ lib.php | 35 +++++++++++++++++++++----------- locallib.php | 12 +++++++++++ report.php | 14 ++++++++----- review.php | 18 +++++++++------- tabs.php | 4 ++-- 6 files changed, 57 insertions(+), 46 deletions(-) delete mode 100644 classes/plugininfo/booktool.php~ diff --git a/classes/plugininfo/booktool.php~ b/classes/plugininfo/booktool.php~ deleted file mode 100644 index dff2874..0000000 --- a/classes/plugininfo/booktool.php~ +++ /dev/null @@ -1,20 +0,0 @@ -param4; if (isset( $game->id)) { $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); file_save_draft_area_files($draftitemid, $modcontext->id, 'mod_game', 'snakes_file', $game->id, 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)); } - $modinfo =& get_fast_modinfo($course); + $modinfo = get_fast_modinfo($course); $cm = $modinfo->cms[$cmid]; @@ -539,8 +539,7 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course $groupjoin = ""; } - if (!$attempts = $DB->get_records_sql("SELECT qa.*, q.grade, - u.firstname, u.lastname, u.email, u.picture + 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 FROM {game_attempts} qa JOIN {game} q ON q.id = qa.gameid JOIN {user} u ON u.id = qa.userid @@ -551,11 +550,10 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course return; } - $cmcontext = get_context_instance(CONTEXT_MODULE, $cm->id); + $cmcontext = game_get_context_module_instance( $cm->id); $grader = has_capability('moodle/grade:viewall', $cmcontext); $accessallgroups = has_capability('moodle/site:accessallgroups', $cmcontext); $viewfullnames = has_capability('moodle/site:viewfullnames', $cmcontext); - $grader = has_capability('mod/game:grade', $cmcontext); $groupmode = groups_get_activity_groupmode($cm, $course); if (is_null($modinfo->groups)) { @@ -586,31 +584,43 @@ function game_get_recent_mod_activity(&$activities, &$index, $timestart, $course $tmpactivity = new object(); $tmpactivity->type = 'game'; + $tmpactivity->gameid = $attempt->gameid; $tmpactivity->cmid = $cm->id; $tmpactivity->name = $aname; $tmpactivity->sectionnum = $cm->sectionnum; $tmpactivity->timestamp = $attempt->timefinish; + $tmpactivity->content = new object(); $tmpactivity->content->attemptid = $attempt->id; $tmpactivity->content->sumgrades = $attempt->score * $attempt->grade; $tmpactivity->content->maxgrade = $attempt->grade; $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->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->imagealt = $attempt->imagealt; + $tmpactivity->user->email = $attempt->email; $activities[$index++] = $tmpactivity; } } function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames) { - global $CFG; + global $CFG, $OUTPUT; echo ''; echo "
"; - 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 ""; if ($detail) { @@ -625,7 +635,8 @@ function game_print_recent_mod_activity($activity, $courseid, $detail, $modnames echo '
'; echo get_string("attempt", "game")." {$activity->content->attempt}: "; $grades = "({$activity->content->sumgrades} / {$activity->content->maxgrade})"; - echo "wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}\">$grades"; + + echo "wwwroot}/mod/game/review.php?attempt={$activity->content->attemptid}&q={$activity->gameid}\">$grades"; echo '
'; echo '
'; @@ -975,7 +986,7 @@ function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedow $questionid = $args[ 0]; $file = $args[ 1]; $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'); } $a = array( 'component' => 'question', 'filearea' => 'questiontext', @@ -993,7 +1004,7 @@ function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedow $answerid = $args[ 0]; $file = $args[ 1]; - if (!$contextcourse = get_context_instance(CONTEXT_COURSE, $course->id)) { + if (!$contextcourse = game_get_context_course_instance( $course->id)) { print_error('nocontext'); } $rec = $DB->get_record( 'files', array( 'component' => 'question', 'filearea' => 'answer', diff --git a/locallib.php b/locallib.php index d9c4a20..f734401 100755 --- a/locallib.php +++ b/locallib.php @@ -2132,3 +2132,15 @@ function game_use_events() { 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 ''; +} diff --git a/report.php b/report.php index b533fc4..6cd2bcf 100755 --- a/report.php +++ b/report.php @@ -18,12 +18,15 @@ require_once("../../config.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. $q = optional_param('q', 0, PARAM_INT); // Game ID. -$mode = optional_param('mode', 'overview', PARAM_ALPHA); // Report mode. if ($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"); } } +*/ -require_login($course->id, false); -$context = get_context_instance(CONTEXT_MODULE, $cm->id); +$context = game_get_context_module_instance( $cm->id); 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. +$mode = optional_param('mode', 'overview', PARAM_ALPHA); // Report mode. $mode = clean_param( $mode, PARAM_SAFEDIR); diff --git a/review.php b/review.php index 027756f..0cce3ff 100755 --- a/review.php +++ b/review.php @@ -44,13 +44,15 @@ $grade = game_score_to_grade( $attempt->score, $game); $feedback = game_feedback_for_grade( $grade, $attempt->gameid); require_login( $course->id, false, $cm); -$context = get_context_instance( CONTEXT_MODULE, $cm->id); -$coursecontext = get_context_instance( CONTEXT_COURSE, $cm->course); -$isteacher = isteacher( $game->course, $USER->id); +$context = game_get_context_module_instance( $cm->id); +$coursecontext = game_get_context_course_instance( $cm->course); + +$isteacher = has_capability('mod/game:manage', $context); + $options = game_get_reviewoptions( $game, $attempt, $context); $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&attempt=$attempt->id", "$game->id", "$cm->id"); +//add_to_log($course->id, "game", "review", "review.php?id=$cm->id&attempt=$attempt->id", "$game->id", "$cm->id"); // Print the page header. @@ -68,6 +70,8 @@ $strupdatemodule = has_capability('moodle/course:manageactivities', $strgames = get_string("modulenameplural", "game"); $strgame = get_string("modulename", "game"); +require( "headergame.php"); +/* if (function_exists( 'build_navigation')) { $navigation = build_navigation('', $cm); 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), navmenu($course, $cm)); } - +*/ echo ''; // For overlib. // 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) { + global $QTYPES; + $pagequestions = explode(',', $pagelist); $number = game_first_questionnumber( $attempt->layout, $pagelist); foreach ($pagequestions as $i) { @@ -308,8 +314,6 @@ function game_print_questions( $pagelist, $attempt, $questions, $options, $state $options->feedback = 0; $options->readonly = 0; - global $QTYPES; - unset( $cmoptions); $cmoptions->course = $game->course; $cmoptions->optionflags->optionflags = 0; diff --git a/tabs.php b/tabs.php index 3383de0..9aa44ab 100755 --- a/tabs.php +++ b/tabs.php @@ -35,7 +35,7 @@ if (!isset($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(); $row = array(); @@ -50,7 +50,7 @@ if (has_capability('mod/game:view', $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')); } -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')); } if (has_capability('mod/game:manage', $context)) {