Browse Source

Fix: In millionaire shows the correct number of good multichoice questions

MOODLE_20_STABLE
Vasilis Daloukas 8 years ago
parent
commit
8f25c8cb85
  1. 1
      lang/en/game.php
  2. 42
      showanswers.php

1
lang/en/game.php

@ -341,6 +341,7 @@ $string[ 'clearrepetitions'] = 'Clear statistics';
$string[ 'computerepetitions'] = 'Compute statistics again';
$string[ 'feedbacks'] = 'Messages correct answer';
$string[ 'repetitions'] = 'Repetitions';
$string[ 'millionaire_also_multichoice'] = 'Multichoice answers without single correct answer';
// File showattempts.php.
$string[ 'lastip'] = 'IP student';

42
showanswers.php

@ -52,6 +52,9 @@ echo '<br><br>';
$existsbook = ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id'));
game_showanswers( $game, $existsbook, $context);
if ($game->gamekind == 'millionaire') {
game_showanswers_extra_millionaire( $game);
}
echo $OUTPUT->footer();
@ -224,8 +227,12 @@ function game_showanswers_question( $game, $context) {
$order = ($showcategories ? 'category,questiontext' : 'questiontext');
$table = '{question} q';
if ($game->gamekind == 'millionaire') {
$select .= " AND qtype='multichoice' AND qmo.single=1 AND qmo.questionid=q.id";
$table = '{question} q, {qtype_multichoice_options} qmo';
$select .= " AND q.qtype='multichoice' AND qmo.single=1 AND qmo.question=q.id";
if (game_get_moodle_version() < '02.06') {
$table .= ',{question_multichoice} qmo';
} else {
$table .= ',{qtype_multichoice_options} qmo';
}
}
game_showanswers_question_select( $game, $table, $select, '*', $order, $showcategories, $game->course, $context);
}
@ -506,3 +513,34 @@ function game_showanswers_bookquiz( $game, $context) {
game_showanswers_question_select( $game, $table, $select, "DISTINCT q.*",
"bc.pagenum,questiontext", $showcategories, $game->course, $context);
}
function game_showanswers_extra_millionaire( $game)
{
global $CFG, $DB;
if ($game->questioncategoryid == 0) {
print_error( get_string( 'must_select_questioncategory', 'game'));
}
// Include subcategories.
$select = 'category='.$game->questioncategoryid;
if ($game->subcategories) {
$cats = question_categorylist( $game->questioncategoryid);
if (count( $cats)) {
$select = 'q.category in ('.implode(',', $cats).')';
}
}
$select .= " AND qtype='multichoice' AND qmo.single <> 1 AND qmo.question=q.id";
if (game_get_moodle_version() < '02.06') {
$table = "{$CFG->prefix}question q, {$CFG->prefix}question_multichoice qmo";
} else {
$table = "{$CFG->prefix}question q, {$CFG->prefix}qtype_multichoice_options qmo";
}
$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;
}
}

Loading…
Cancel
Save