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. 312
      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

312
lib.php

@ -863,116 +863,256 @@ function game_extend_settings_navigation($settings, $gamenode) {
}
}
/**
* Returns an array of game type objects to construct
* menu list when adding new game
*
*/
function game_get_types() {
global $DB;
$config = get_config('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');
}
$types = array();
if (!defined('USE_GET_SHORTCUTS')) {
function game_get_types() {
global $DB;
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game_group_start";
$type->typestr = '--'.get_string( 'modulenameplural', 'game');
$types[] = $type;
$config = get_config('game');
$hide = ( isset( $config->hidehangman) ? ($config->hidehangman != 0) : false);
$types = array();
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=hangman";
$type->typestr = get_string('game_hangman', 'game');
$type->type = "game_group_start";
$type->typestr = '--'.get_string( 'modulenameplural', 'game');
$types[] = $type;
}
if (isset( $config->hidecross)) {
$hide = ($config->hidecross != 0);
} else {
$hide = false;
}
$hide = ( isset( $config->hidehangman) ? ($config->hidehangman != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=cross";
$type->typestr = get_string('game_cross', 'game');
$types[] = $type;
}
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=hangman";
$type->typestr = get_string('game_hangman', 'game');
$types[] = $type;
}
if (isset( $config->hidecryptex)) {
$hide = ($config->hidecryptex != 0);
} else {
$hide = false;
}
if (isset( $config->hidecross)) {
$hide = ($config->hidecross != 0);
} else {
$hide = false;
}
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=cryptex";
$type->typestr = get_string('game_cryptex', 'game');
$types[] = $type;
}
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=cross";
$type->typestr = get_string('game_cross', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidemillionaire) ? ($config->hidemillionaire != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=millionaire";
$type->typestr = get_string('game_millionaire', 'game');
$types[] = $type;
}
if (isset( $config->hidecryptex)) {
$hide = ($config->hidecryptex != 0);
} else {
$hide = false;
}
$hide = (isset( $config->hidesudoku) ? ($config->hidesudoku != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=sudoku";
$type->typestr = get_string('game_sudoku', 'game');
$types[] = $type;
}
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=cryptex";
$type->typestr = get_string('game_cryptex', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidesnakes) ? ($config->hidesnakes != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=snakes";
$type->typestr = get_string('game_snakes', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidemillionaire) ? ($config->hidemillionaire != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=millionaire";
$type->typestr = get_string('game_millionaire', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidesudoku) ? ($config->hidesudoku != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=sudoku";
$type->typestr = get_string('game_sudoku', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidesnakes) ? ($config->hidesnakes != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=snakes";
$type->typestr = get_string('game_snakes', 'game');
$types[] = $type;
}
$hide = (isset( $config->hidehiddenpicture) ? ($config->hidehiddenpicture != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=hiddenpicture";
$type->typestr = get_string('game_hiddenpicture', '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->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=bookquiz";
$type->typestr = get_string('game_bookquiz', 'game');
$types[] = $type;
}
}
$hide = (isset( $config->hidehiddenpicture) ? ($config->hidehiddenpicture != 0) : false);
if ($hide == false) {
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=hiddenpicture";
$type->typestr = get_string('game_hiddenpicture', 'game');
$type->type = "game_group_end";
$type->typestr = '--';
$types[] = $type;
return $types;
}
}
$hide = (isset( $config->hidebookquiz) ? ($config->hidebookquiz != 0) : false);
if ($hide == false) {
if ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')) {
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->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game&type=bookquiz";
$type->typestr = get_string('game_bookquiz', 'game');
$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;
}
$type = new stdClass;
$type->modclass = MOD_CLASS_ACTIVITY;
$type->type = "game_group_end";
$type->typestr = '--';
$types[] = $type;
return $types;
}
function mod_game_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {

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