diff --git a/lang/en/game.php b/lang/en/game.php index 2f252e4..28d8d18 100644 --- a/lang/en/game.php +++ b/lang/en/game.php @@ -300,6 +300,7 @@ $string[ 'sudoku_maxquestions'] = 'Maximum number of questions'; $string[ 'sudoku_options'] = 'Sudoku options'; $string[ 'toptext'] = 'Text at the top of page'; $string[ 'userdefined'] = 'User defined'; +$string[ 'different_glossary_category'] = "The selected category doesn't corespond to selected glossary"; // File preview.php. $string[ 'only_teachers'] = 'Only teacher can see this page'; diff --git a/mod_form.php b/mod_form.php index 3542108..ba0c187 100644 --- a/mod_form.php +++ b/mod_form.php @@ -442,6 +442,8 @@ class mod_game_mod_form extends moodleform_mod { * @return moodle_url */ public function validation($data, $files) { + global $CFG, $DB; + $errors = parent::validation($data, $files); // Check open and close times are consistent. @@ -450,6 +452,19 @@ class mod_game_mod_form extends moodleform_mod { $errors['timeclose'] = get_string('closebeforeopen', 'quiz'); } + if( $data['glossarycategoryid'] != 0) { + $sql = "SELECT glossaryid FROM {$CFG->prefix}glossary_categories ". + " WHERE id=".$data[ 'glossarycategoryid']; + $rec = $DB->get_record_sql( $sql); + if( $rec != false) { + if( $data[ 'glossaryid'] != $rec->glossaryid) { + $s = get_string( 'different_glossary_category', 'game'); + $errors['glossaryid'] = $s; + $errors['glossarycategoryid'] = $s; + } + } + } + return $errors; } diff --git a/version.php b/version.php index 507d0bd..658dcdc 100644 --- a/version.php +++ b/version.php @@ -35,7 +35,7 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017062901; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017062902; // 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 = '2017-06-29';