From 4e48edf6d07dbf8a518bb5ce5f7992a94a3028a0 Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Sat, 24 Aug 2013 10:36:34 +0300 Subject: [PATCH] Fix: Backward compatibility with Moodle 2.0 and textlib --- lang/en/game.php | 2 ++ locallib.php | 30 ++++++++++++++++-------------- mod_form.php | 2 +- version.php | 4 ++-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lang/en/game.php b/lang/en/game.php index bd2fc6a..4161a0f 100755 --- a/lang/en/game.php +++ b/lang/en/game.php @@ -218,6 +218,8 @@ $string[ 'cryptex_maxtries'] = 'Max tries'; $string[ 'cryptex_options'] = 'Cryptex options'; $string[ 'gameclose'] = 'Close 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[ 'hangman_allowspaces'] = 'Allow spaces in words'; $string[ 'hangman_allowsub'] = 'Allow the symbol - in words'; diff --git a/locallib.php b/locallib.php index 0285839..e821a56 100755 --- a/locallib.php +++ b/locallib.php @@ -1945,10 +1945,10 @@ function game_can_start_new_attempt( $game) function game_strlen( $str) { - if( game_get_moodle_version() < '02.03') - return textlib_get_instance()->strlen( $str); - else + if( game_get_moodle_version() >= '02.04') return textlib::strlen( $str); + else + return textlib_get_instance()->strlen( $str); } function game_substr() @@ -1958,32 +1958,34 @@ function game_substr() if( $num == 3) { - if( game_get_moodle_version() < '02.03') - return textlib_get_instance()->substr( $a[ 0], $a[ 1], $a[ 2]); - else + if( game_get_moodle_version() >= '02.04') 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) { - if( game_get_moodle_version() < '02.03') - return textlib_get_instance()->substr( $a[ 0], $a[ 1]); - else + if( game_get_moodle_version() >= '02.04') return textlib::substr( $a[ 0], $a[ 1]); + else + return textlib_get_instance()->substr( $a[ 0], $a[ 1]); }else die( 'Substr requires 2 or 3 parameters'); } 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); else - return textlib::strtoupper( $str); + return textlib_get_instance()->qstrtoupper( $str); } function game_strpos( $haystack, $needle, $offset = 0) { - if( game_get_moodle_version() < '02.03') - return textlib_get_instance()->strpos( $haystack, $needle, $offset); - else + if( game_get_moodle_version() >= '02.04') return textlib::strpos( $haystack, $needle, $offset); + else + return textlib_get_instance()->strpos( $haystack, $needle, $offset); } diff --git a/mod_form.php b/mod_form.php index 487cd63..505f620 100755 --- a/mod_form.php +++ b/mod_form.php @@ -179,7 +179,7 @@ class mod_game_mod_form extends moodleform_mod { // Open and close dates. $mform->addElement('date_time_selector', 'timeopen', get_string('gameopen', 'game'), 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'), array('optional' => true, 'step' => 1)); diff --git a/version.php b/version.php index d0fcedf..48ae58c 100755 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ defined('MOODLE_INTERNAL') || die(); $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->cron = 0; // Period for cron to check this module (secs) -$module->release = '3.8.24.4'; +$module->release = '3.8.24.5';