From 80c129876fa67c8a8b59c6cb7f9f1a58d8b0e014 Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Tue, 30 May 2017 04:48:18 +0300 Subject: [PATCH] Moodle 3.3 compatibility --- hangman/play.php | 2 +- lib.php | 26 ++++++++++++++++++-------- millionaire/play.php | 10 +++++----- version.php | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/hangman/play.php b/hangman/play.php index b8e7c0b..3ad37ff 100644 --- a/hangman/play.php +++ b/hangman/play.php @@ -234,7 +234,7 @@ function game_hangman_play( $id, $game, $attempt, $hangman, $onlyshow, $showsolu if ($game->param3 == 0) { $game->param3 = 1; } - echo "\r\n
pix_url('hangman/'.$game->param3.'/hangman_'.$wrong, 'mod_game')."\""; + echo "\r\n
param3.'/hangman_'.$wrong, 'mod_game')."\""; $message = sprintf( get_string( 'hangman_wrongnum', 'game'), $wrong, $max); echo ' ALIGN="MIDDLE" BORDER="0" HEIGHT="100" alt="'.$message.'"/>'; diff --git a/lib.php b/lib.php index 8a574f0..43b3a0c 100644 --- a/lib.php +++ b/lib.php @@ -984,7 +984,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=hangman"; $type->name = preg_replace('/.*type=/', '', $type->type); - $type->title = get_string('game_hangman', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_hangman', 'game'); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && get_string_manager()->string_exists('help' . $type->name, 'game')) { @@ -1002,7 +1002,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=cross"; $type->name = preg_replace('/.*type=/', '', $type->type); - $type->title = get_string('game_cross', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_cross', 'game'); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && get_string_manager()->string_exists('help' . $type->name, 'game')) { @@ -1019,7 +1019,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=cryptex"; - $type->title = get_string('game_cryptex', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_cryptex', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1033,7 +1033,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=millionaire"; - $type->title = get_string('game_millionaire', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_millionaire', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1047,7 +1047,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=sudoku"; - $type->title = get_string('game_sudoku', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_sudoku', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1061,7 +1061,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=snakes"; - $type->title = get_string('game_snakes', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_snakes', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1075,7 +1075,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=hiddenpicture"; - $type->title = get_string('game_hiddenpicture', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_hiddenpicture', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1090,7 +1090,7 @@ if (defined('USE_GET_SHORTCUTS')) { $type = new stdClass; $type->archetype = MOD_CLASS_ACTIVITY; $type->type = "game&type=bookquiz"; - $type->title = get_string('game_bookquiz', 'game'); + $type->title = get_string('pluginname', 'game').' - '.get_string('game_bookquiz', 'game'); $type->name = preg_replace('/.*type=/', '', $type->type); $type->link = new moodle_url($defaultitem->link, array('type' => $type->name)); if (empty($type->help) && !empty($type->name) && @@ -1356,3 +1356,13 @@ function game_get_context_course_instance( $courseid) { return get_context_instance( CONTEXT_COURSE, $courseid); } + +function game_pix_url( $filename) { + global $OUTPUT; + + if (game_get_moodle_version() >= '03.03') { + return $OUTPUT->image_url($filename, 'mod_game'); + } else { + return $OUTPUT->pix_url($filename, 'mod_game'); + } +} diff --git a/millionaire/play.php b/millionaire/play.php index c57b136..bf47023 100644 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -135,8 +135,8 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer, $gif = "5050"; $disabled = ""; } - echo ' '; + $src = game_pix_url($dirgif.$gif, 'mod_game'); + echo ' '; if ($state & 2) { $gif = "telephonex"; @@ -148,7 +148,7 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer, echo ' '; + '" src="'.game_pix_url($dirgif.$gif, 'mod_game').'" alt="" border="0"> '; if ($state & 4) { $gif = "peoplex"; @@ -159,11 +159,11 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aanswer, } echo ' '; + game_pix_url($dirgif.$gif, 'mod_game').'" alt="" border="0"> '; echo ' '; + game_pix_url($dirgif.'x', 'mod_game').'" alt="" border="0"> '; echo "\r\n"; echo "\r\n"; diff --git a/version.php b/version.php index a65bc9d..4e45a41 100644 --- a/version.php +++ b/version.php @@ -36,10 +36,10 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017041701; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017053001; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->cron = 0; // Period for cron to check this module (secs). -$plugin->release = '2016-09-17'; +$plugin->release = '2017-05-30'; if ($useplugin != 2) { $module = $plugin;