diff --git a/db/upgrade.php b/db/upgrade.php index ebaae23..e32b0c5 100755 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -1535,5 +1535,14 @@ function xmldb_game_upgrade($oldversion) { upgrade_mod_savepoint(true, $ver, 'game'); } + if ($oldversion < ($ver = 2016031202)) { + $table = new xmldb_table('game'); + $field = new xmldb_field('glossaryonlyapproved', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, '0'); + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + + upgrade_mod_savepoint(true, $ver, 'game'); + } return true; } diff --git a/lang/en/game.php b/lang/en/game.php index 9b8237c..68a4e5c 100755 --- a/lang/en/game.php +++ b/lang/en/game.php @@ -245,6 +245,7 @@ $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[ 'glossary_only_approved'] = "Only approved or teacher's glossary entries"; $string[ 'hangman_allowspaces'] = 'Allow spaces in words'; $string[ 'hangman_allowsub'] = 'Allow the symbol - in words'; $string[ 'hangman_imageset'] = 'Select the images of hangman'; diff --git a/locallib.php b/locallib.php index 3aad1f8..89d4344 100755 --- a/locallib.php +++ b/locallib.php @@ -139,6 +139,11 @@ function game_question_shortanswer_glossary( $game, $allowspaces, $userepetition $select .= " AND concept NOT LIKE '% %' "; } + if ($game->glossaryonlyapproved) { + // Only approved glossary entries will be used. + $select .= ' AND (ge.approved=1 OR teacherentry=1)'; + } + if (($id = game_question_selectrandom( $game, $table, $select, 'ge.id', $userepetitions)) == false) { return false; } diff --git a/mod_form.php b/mod_form.php index a050241..105af67 100755 --- a/mod_form.php +++ b/mod_form.php @@ -116,6 +116,10 @@ class mod_game_mod_form extends moodleform_mod { } $mform->addElement('select', 'glossarycategoryid', get_string('sourcemodule_glossarycategory', 'game'), $a); $mform->disabledIf('glossarycategoryid', 'sourcemodule', 'neq', 'glossary'); + + // Only approved. + $mform->addElement('selectyesno', 'glossaryonlyapproved', get_string('glossary_only_approved', 'game')); + $mform->disabledIf('subcategories', 'sourcemodule', 'neq', 'glossary'); } // Question Category - Short Answer. diff --git a/showanswers.php b/showanswers.php index 0951133..f0cca3a 100755 --- a/showanswers.php +++ b/showanswers.php @@ -362,6 +362,10 @@ function game_showanswers_glossary( $game) { " AND gec.categoryid = {$game->glossarycategoryid}"; $table .= ",{glossary_entries_categories} gec"; } + if ($game->glossaryonlyapproved) { + // Only approved glossary entries will be used. + $select .= ' AND (ge.approved=1 OR teacherentry=1)'; + } $sql = "SELECT ge.id,definition,concept FROM $table WHERE $select ORDER BY definition"; if (($questions = $DB->get_records_sql( $sql)) === false) { return; diff --git a/version.php b/version.php index bd599c4..43dad29 100755 --- a/version.php +++ b/version.php @@ -36,10 +36,10 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2016030201; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2016031202; // 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-02'; +$plugin->release = '2016-03-12'; if ($useplugin != 2) { $module = $plugin;