Browse Source

Use get_types or get_shortcuts depended on version of Moodle

MOODLE_20_STABLE
Vasilis Daloukas 9 years ago
parent
commit
5df3dcb124
  1. 4
      CHANGES.md
  2. 150
      lib.php
  3. 4
      version.php

4
CHANGES.md

@ -1,3 +1,7 @@
Changes in version 2016-04-26 (20160426)
----------------------------------------
- Fix Use get_types or get_shortcuts depended on version of Moodle
Changes in version 2016-03-03 (20160302)
------------------------------------------------------------------
- New: Max compute time in crossword and cryptex

150
lib.php

@ -863,11 +863,14 @@ function game_extend_settings_navigation($settings, $gamenode) {
}
}
/**
* Returns an array of game type objects to construct
* menu list when adding new game
*
*/
/* Returns an array of game type objects to construct
menu list when adding new game */
require_once($CFG->dirroot.'/version.php');
if ($branch >= '31') {
define('USE_GET_SHORTCUTS', '1');
}
if (!defined('USE_GET_SHORTCUTS')) {
function game_get_types() {
global $DB;
@ -974,6 +977,143 @@ function game_get_types() {
return $types;
}
}
if (defined('USE_GET_SHORTCUTS')) {
/**
* Returns an array of game type objects to construct
* menu list when adding new game
*
*/
function game_get_shortcuts($defaultitem) {
global $DB, $CFG;
$config = get_config('game');
$types = array();
$hide = ( isset( $config->hidehangman) ? ($config->hidehangman != 0) : false);
if ($hide == false) {
$type = new stdClass;
$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->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')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
if (isset( $config->hidecross)) {
$hide = ($config->hidecross != 0);
} else {
$hide = false;
}
if ($hide == false) {
$type = new stdClass;
$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->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')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
if (isset( $config->hidecryptex)) {
$hide = ($config->hidecryptex != 0);
} else {
$hide = false;
}
if ($hide == false) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=cryptex";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
$hide = (isset( $config->hidemillionaire) ? ($config->hidemillionaire != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=millionaire";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
$hide = (isset( $config->hidesudoku) ? ($config->hidesudoku != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=sudoku";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
$hide = (isset( $config->hidesnakes) ? ($config->hidesnakes != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=snakes";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
$hide = (isset( $config->hidehiddenpicture) ? ($config->hidehiddenpicture != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=hiddenpicture";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
$hide = (isset( $config->hidebookquiz) ? ($config->hidebookquiz != 0) : false);
if ($hide == false) {
if ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')) {
$type = new stdClass;
$type->archetype = MOD_CLASS_ACTIVITY;
$type->type = "game&type=bookquiz";
$type->title = 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) &&
get_string_manager()->string_exists('help' . $type->name, 'game')) {
$type->help = get_string('help' . $type->name, 'game');
}
$types[] = $type;
}
}
return $types;
}
}
function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
global $CFG, $DB;

4
version.php

@ -36,10 +36,10 @@ if (!isset( $plugin)) {
}
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2016031202; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2016042601; // 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-03-12';
$plugin->release = '2016-04-26';
if ($useplugin != 2) {
$module = $plugin;

Loading…
Cancel
Save