Browse Source

Fix mod_form, show_answers: show numbers of entries in each glossary and question category

MOODLE_20_STABLE
bdaloukas 8 years ago
parent
commit
4fbea1a66a
  1. 4
      CHANGES.md
  2. 19
      mod_form.php
  3. 8
      showanswers.php
  4. 2
      version.php

4
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) Changes in version 2017-06-27 (20170627)
- Fix conversation of columns (cols,rows) from string to int - Fix conversation of columns (cols,rows) from string to int

19
mod_form.php

@ -420,14 +420,14 @@ class mod_game_mod_form extends moodleform_mod {
$a = array(); $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"; $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"; $sql = "SELECT id, name, ($sql2) as c FROM {$CFG->prefix}glossary g WHERE $select";
$recs = $DB->get_records_sql( $sql); $recs = $DB->get_records_sql( $sql);
foreach( $recs as $rec) { foreach ( $recs as $rec) {
$a[ - $rec->id] = $rec->name.' -> ('.$rec->c.')'; $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(*) ". $sql2 = "SELECT COUNT(*) ".
" FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec". " FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories gec".
" WHERE gec.categoryid=gc.id AND gec.entryid=ge.id"; " 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; * Computes the categories of all question of the current course;
* *
* @param int $courseid * @param int $courseid
* @param string $gamekind
* *
* @return array of question categories * @return array of question categories
*/ */
@ -459,7 +460,7 @@ class mod_game_mod_form extends moodleform_mod {
$a = array(); $a = array();
$table = "{$CFG->prefix}question q"; $table = "{$CFG->prefix}question q";
$select = ''; $select = '';
if( $gamekind == 'millionaire') { if ($gamekind == 'millionaire') {
if (game_get_moodle_version() < '02.06') { if (game_get_moodle_version() < '02.06') {
$table = "{$CFG->prefix}question q, {$CFG->prefix}question_multichoice qmo"; $table = "{$CFG->prefix}question q, {$CFG->prefix}question_multichoice qmo";
$select = " AND q.qtype='multichoice' AND qmo.single = 1 AND qmo.question=q.id"; $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"; $select = " AND q.qtype='multichoice' AND qmo.single = 1 AND qmo.questionid=q.id";
} }
} else if (($gamekind == 'hangman') or ($gamekind == 'cryptex') or ($gamekind == 'cross')) { } else if (($gamekind == 'hangman') or ($gamekind == 'cryptex') or ($gamekind == 'cross')) {
//Single answer questions. // Single answer questions.
$select = " AND q.qtype='shortanswer'"; $select = " AND q.qtype='shortanswer'";
} }
$sql2 = "SELECT COUNT(*) FROM $table WHERE q.category = qc.id $select"; $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'); $errors['timeclose'] = get_string('closebeforeopen', 'quiz');
} }
if( array_key_exists( 'glossarycategoryid', $data)) { if (array_key_exists( 'glossarycategoryid', $data)) {
if( $data['glossarycategoryid'] != 0) { if ($data['glossarycategoryid'] != 0) {
$sql = "SELECT glossaryid FROM {$CFG->prefix}glossary_categories ". $sql = "SELECT glossaryid FROM {$CFG->prefix}glossary_categories ".
" WHERE id=".$data[ 'glossarycategoryid']; " WHERE id=".$data[ 'glossarycategoryid'];
$rec = $DB->get_record_sql( $sql); $rec = $DB->get_record_sql( $sql);
if( $rec != false) { if ($rec != false) {
if( $data[ 'glossaryid'] != $rec->glossaryid) { if ($data[ 'glossaryid'] != $rec->glossaryid) {
$s = get_string( 'different_glossary_category', 'game'); $s = get_string( 'different_glossary_category', 'game');
$errors['glossaryid'] = $s; $errors['glossaryid'] = $s;
$errors['glossarycategoryid'] = $s; $errors['glossarycategoryid'] = $s;

8
showanswers.php

@ -518,8 +518,12 @@ function game_showanswers_bookquiz( $game, $context) {
"bc.pagenum,questiontext", $showcategories, $game->course, $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; global $CFG, $DB;
if ($game->questioncategoryid == 0) { if ($game->questioncategoryid == 0) {

2
version.php

@ -35,7 +35,7 @@ if (!isset( $plugin)) {
} }
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). $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->requires = 2010112400; // Requires Moodle 2.0.
$plugin->cron = 0; // Period for cron to check this module (secs). $plugin->cron = 0; // Period for cron to check this module (secs).
$plugin->release = '2017-06-30'; $plugin->release = '2017-06-30';

Loading…
Cancel
Save