diff --git a/CHANGES.md b/CHANGES.md index 70c99a2..5e1266a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +Changes in version 2017-06-30 (2017063002) +- in mod_form.php shows the correct numbers of correspondings questions/glossaryentries +- in showanswrs.php shows the correspondings questions/glossaryentries + Changes in version 2017-06-27 (20170627) - Fix conversation of columns (cols,rows) from string to int diff --git a/mod_form.php b/mod_form.php index 1bebca5..fa70673 100644 --- a/mod_form.php +++ b/mod_form.php @@ -420,14 +420,14 @@ class mod_game_mod_form extends moodleform_mod { $a = array(); - //Fills with the count of entries in each glossary. + // Fills with the count of entries in each glossary. $sql2 = "SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries ge WHERE ge.glossaryid=g.id"; $sql = "SELECT id, name, ($sql2) as c FROM {$CFG->prefix}glossary g WHERE $select"; $recs = $DB->get_records_sql( $sql); - foreach( $recs as $rec) { + foreach ( $recs as $rec) { $a[ - $rec->id] = $rec->name.' -> ('.$rec->c.')'; } - //Fills with the count of entries in each category. + // Fills with the count of entries in each category. $sql2 = "SELECT COUNT(*) ". " FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec". " WHERE gec.categoryid=gc.id AND gec.entryid=ge.id"; @@ -448,6 +448,7 @@ class mod_game_mod_form extends moodleform_mod { * Computes the categories of all question of the current course; * * @param int $courseid + * @param string $gamekind * * @return array of question categories */ @@ -459,7 +460,7 @@ class mod_game_mod_form extends moodleform_mod { $a = array(); $table = "{$CFG->prefix}question q"; $select = ''; - if( $gamekind == 'millionaire') { + if ($gamekind == 'millionaire') { if (game_get_moodle_version() < '02.06') { $table = "{$CFG->prefix}question q, {$CFG->prefix}question_multichoice qmo"; $select = " AND q.qtype='multichoice' AND qmo.single = 1 AND qmo.question=q.id"; @@ -468,7 +469,7 @@ class mod_game_mod_form extends moodleform_mod { $select = " AND q.qtype='multichoice' AND qmo.single = 1 AND qmo.questionid=q.id"; } } else if (($gamekind == 'hangman') or ($gamekind == 'cryptex') or ($gamekind == 'cross')) { - //Single answer questions. + // Single answer questions. $select = " AND q.qtype='shortanswer'"; } $sql2 = "SELECT COUNT(*) FROM $table WHERE q.category = qc.id $select"; @@ -501,13 +502,13 @@ class mod_game_mod_form extends moodleform_mod { $errors['timeclose'] = get_string('closebeforeopen', 'quiz'); } - if( array_key_exists( 'glossarycategoryid', $data)) { - if( $data['glossarycategoryid'] != 0) { + if (array_key_exists( 'glossarycategoryid', $data)) { + 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) { + if ($rec != false) { + if ($data[ 'glossaryid'] != $rec->glossaryid) { $s = get_string( 'different_glossary_category', 'game'); $errors['glossaryid'] = $s; $errors['glossarycategoryid'] = $s; diff --git a/showanswers.php b/showanswers.php index 0e0f34c..d2ab2d4 100644 --- a/showanswers.php +++ b/showanswers.php @@ -53,7 +53,7 @@ echo '

'; $existsbook = ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')); game_showanswers( $game, $existsbook, $context); if ($game->gamekind == 'millionaire') { - game_showanswers_extra_millionaire( $game); + game_showanswers_extra_millionaire( $game); } echo $OUTPUT->footer(); @@ -518,8 +518,12 @@ function game_showanswers_bookquiz( $game, $context) { "bc.pagenum,questiontext", $showcategories, $game->course, $context); } -function game_showanswers_extra_millionaire( $game) -{ +/** + * Show extra info for answers in millionaire + * + * @param stdClass $game + */ +function game_showanswers_extra_millionaire( $game) { global $CFG, $DB; if ($game->questioncategoryid == 0) { @@ -533,19 +537,19 @@ function game_showanswers_extra_millionaire( $game) if (count( $cats)) { $select = 'q.category in ('.implode(',', $cats).')'; } - } + } - if (game_get_moodle_version() < '02.06') { + if (game_get_moodle_version() < '02.06') { $table = "{$CFG->prefix}question q, {$CFG->prefix}question_multichoice qmo"; $select .= " AND qtype='multichoice' AND qmo.single <> 1 AND qmo.question=q.id"; - } else { + } else { $table = "{$CFG->prefix}question q, {$CFG->prefix}qtype_multichoice_options qmo"; $select .= " AND qtype='multichoice' AND qmo.single <> 1 AND qmo.questionid=q.id"; - } + } - $sql = "SELECT COUNT(*) as c FROM $table WHERE $select"; - $rec = $DB->get_record_sql( $sql); - if ($rec->c != 0) { - echo get_string( 'millionaire_also_multichoice', 'game').': '.$rec->c; - } + $sql = "SELECT COUNT(*) as c FROM $table WHERE $select"; + $rec = $DB->get_record_sql( $sql); + if ($rec->c != 0) { + echo get_string( 'millionaire_also_multichoice', 'game').': '.$rec->c; + } } diff --git a/version.php b/version.php index 783c5af..f586f86 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 = 2017063001; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017063002; // 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-30';