Browse Source

New: Auto detects common problems in millionaire

MOODLE_20_STABLE
bdaloukas 7 years ago
parent
commit
f806d6a1bd
  1. 18
      check.php
  2. 1
      lang/en/game.php
  3. 4
      showanswers.php
  4. 4
      version.php

18
check.php

@ -100,6 +100,7 @@ function game_check_common_problems_multichoice_question($game, &$warnings) {
$select = 'q.category in ('.implode(',', $cats).')'; $select = 'q.category in ('.implode(',', $cats).')';
} }
} }
$select0 = $select;
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";
@ -114,6 +115,19 @@ function game_check_common_problems_multichoice_question($game, &$warnings) {
if ($rec->c != 0) { if ($rec->c != 0) {
$warnings[] = get_string( 'millionaire_also_multichoice', 'game').': '.$rec->c; $warnings[] = get_string( 'millionaire_also_multichoice', 'game').': '.$rec->c;
} }
$select = $select0;
if (game_get_moodle_version() < '02.06') {
$select .= " AND qtype='multichoice' AND qmo.single = 1 AND qmo.question=q.id";
} else {
$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) {
$warnings[] = get_string( 'millionaire_no_multichoice_questions', 'game');
}
} }
/** /**
@ -216,8 +230,10 @@ function game_check_common_problems_shortanswer_question($game, &$warnings) {
foreach ($recs as $rec) { foreach ($recs as $rec) {
// Maybe there are more answers to one question. I use as correct the one with bigger fraction. // Maybe there are more answers to one question. I use as correct the one with bigger fraction.
$sql = "SELECT DISTINCT answer FROM {$CFG->prefix}question_answers WHERE question={$rec->id} ORDER BY fraction DESC"; $sql = "SELECT DISTINCT answer FROM {$CFG->prefix}question_answers WHERE question={$rec->id} ORDER BY fraction DESC";
if (($rec2 = $DB->get_record_sql( $sql, null, 0, 1)) != false) { $recs2 = $DB->get_records_sql( $sql);
foreach( $recs2 as $rec2) {
$a[] = $rec2->answer; $a[] = $rec2->answer;
break;
} }
} }
game_check_common_problems_shortanswer_allowspaces( $game, $warnings, $a); game_check_common_problems_shortanswer_allowspaces( $game, $warnings, $a);

1
lang/en/game.php

@ -42,6 +42,7 @@ $string[ 'millionaire_also_multichoice'] = 'Multichoice answers without single c
$string[ 'common_problems_allowspaces'] = 'There are words with spaces but in the game, spaces are not allowed'; $string[ 'common_problems_allowspaces'] = 'There are words with spaces but in the game, spaces are not allowed';
$string[ 'common_problems_shortanswer_hangman'] = 'Not all characters are in the language of game'; $string[ 'common_problems_shortanswer_hangman'] = 'Not all characters are in the language of game';
$string[ 'common_problems_crossword_param1'] = "'Maximum number of cols/rows' is too small"; $string[ 'common_problems_crossword_param1'] = "'Maximum number of cols/rows' is too small";
$string[ 'millionaire_no_multichoice_questions'] = 'There are no multichoice questions';
// Classes. // Classes.
$string[ 'eventgamecreated'] = 'Game created'; $string[ 'eventgamecreated'] = 'Game created';

4
showanswers.php

@ -206,7 +206,9 @@ function game_showanswers_question( $game, $context) {
if ($game->subcategories) { if ($game->subcategories) {
$cats = question_categorylist( $game->questioncategoryid); $cats = question_categorylist( $game->questioncategoryid);
if (strpos( $cats, ',') > 0) { if (is_array( $cats)) {
$select = ' category in ('.implode( ',', $cats).')';
} else if (strpos( $cats, ',') > 0) {
$select = ' category in ('.$cats.')'; $select = ' category in ('.$cats.')';
} }
} }

4
version.php

@ -35,10 +35,10 @@ 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 = 2017081302; // The current module version (Date: YYYYMMDDXX). $plugin->version = 2017081401; // 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-08-13'; $plugin->release = '2017-08-14';
$plugin->maturity = MATURITY_STABLE; $plugin->maturity = MATURITY_STABLE;
if ($useplugin != 2) { if ($useplugin != 2) {

Loading…
Cancel
Save