Browse Source

Fix: Backward compatibility with Moodle 2.0 and textlib

MOODLE_20_STABLE
bdaloukas 12 years ago
parent
commit
4e48edf6d0
  1. 2
      lang/en/game.php
  2. 30
      locallib.php
  3. 2
      mod_form.php
  4. 4
      version.php

2
lang/en/game.php

@ -218,6 +218,8 @@ $string[ 'cryptex_maxtries'] = 'Max tries';
$string[ 'cryptex_options'] = 'Cryptex options'; $string[ 'cryptex_options'] = 'Cryptex options';
$string[ 'gameclose'] = 'Close the game'; $string[ 'gameclose'] = 'Close the game';
$string[ 'gameopen'] = 'Open the game'; $string[ 'gameopen'] = 'Open the game';
$string[ 'gameopenclose'] = 'Open and close dates';
$string[ 'gameopenclose_help'] = 'Students can only start their attempt(s) after the open time and they must complete their attempts before the close time.';
$string[ 'grademethod'] = 'Grading method'; $string[ 'grademethod'] = 'Grading method';
$string[ 'hangman_allowspaces'] = 'Allow spaces in words'; $string[ 'hangman_allowspaces'] = 'Allow spaces in words';
$string[ 'hangman_allowsub'] = 'Allow the symbol - in words'; $string[ 'hangman_allowsub'] = 'Allow the symbol - in words';

30
locallib.php

@ -1945,10 +1945,10 @@ function game_can_start_new_attempt( $game)
function game_strlen( $str) function game_strlen( $str)
{ {
if( game_get_moodle_version() < '02.03') if( game_get_moodle_version() >= '02.04')
return textlib_get_instance()->strlen( $str);
else
return textlib::strlen( $str); return textlib::strlen( $str);
else
return textlib_get_instance()->strlen( $str);
} }
function game_substr() function game_substr()
@ -1958,32 +1958,34 @@ function game_substr()
if( $num == 3) if( $num == 3)
{ {
if( game_get_moodle_version() < '02.03') if( game_get_moodle_version() >= '02.04')
return textlib_get_instance()->substr( $a[ 0], $a[ 1], $a[ 2]);
else
return textlib::substr( $a[ 0], $a[ 1], $a[ 2]); return textlib::substr( $a[ 0], $a[ 1], $a[ 2]);
else
return textlib_get_instance()->substr( $a[ 0], $a[ 1], $a[ 2]);
}else if( $num == 2) }else if( $num == 2)
{ {
if( game_get_moodle_version() < '02.03') if( game_get_moodle_version() >= '02.04')
return textlib_get_instance()->substr( $a[ 0], $a[ 1]);
else
return textlib::substr( $a[ 0], $a[ 1]); return textlib::substr( $a[ 0], $a[ 1]);
else
return textlib_get_instance()->substr( $a[ 0], $a[ 1]);
}else }else
die( 'Substr requires 2 or 3 parameters'); die( 'Substr requires 2 or 3 parameters');
} }
function game_strtoupper( $str) function game_strtoupper( $str)
{ {
if( game_get_moodle_version() < '02.03') if( game_get_moodle_version() >= '02.04')
return textlib::strtoupper( $str);
else if( game_get_moodle_version() >= '02.01')
return textlib_get_instance()->strtoupper( $str); return textlib_get_instance()->strtoupper( $str);
else else
return textlib::strtoupper( $str); return textlib_get_instance()->qstrtoupper( $str);
} }
function game_strpos( $haystack, $needle, $offset = 0) function game_strpos( $haystack, $needle, $offset = 0)
{ {
if( game_get_moodle_version() < '02.03') if( game_get_moodle_version() >= '02.04')
return textlib_get_instance()->strpos( $haystack, $needle, $offset);
else
return textlib::strpos( $haystack, $needle, $offset); return textlib::strpos( $haystack, $needle, $offset);
else
return textlib_get_instance()->strpos( $haystack, $needle, $offset);
} }

2
mod_form.php

@ -179,7 +179,7 @@ class mod_game_mod_form extends moodleform_mod {
// Open and close dates. // Open and close dates.
$mform->addElement('date_time_selector', 'timeopen', get_string('gameopen', 'game'), $mform->addElement('date_time_selector', 'timeopen', get_string('gameopen', 'game'),
array('optional' => true, 'step' => 1)); array('optional' => true, 'step' => 1));
$mform->addHelpButton('timeopen', 'quizopenclose', 'quiz'); $mform->addHelpButton('timeopen', 'gameopenclose', 'game');
$mform->addElement('date_time_selector', 'timeclose', get_string('gameclose', 'game'), $mform->addElement('date_time_selector', 'timeclose', get_string('gameclose', 'game'),
array('optional' => true, 'step' => 1)); array('optional' => true, 'step' => 1));

4
version.php

@ -11,7 +11,7 @@
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
$module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics)
$module->version = 2013082404; // The current module version (Date: YYYYMMDDXX) $module->version = 2013082405; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2010112400; // Requires Moodle 2.0 $module->requires = 2010112400; // Requires Moodle 2.0
$module->cron = 0; // Period for cron to check this module (secs) $module->cron = 0; // Period for cron to check this module (secs)
$module->release = '3.8.24.4'; $module->release = '3.8.24.5';

Loading…
Cancel
Save