Skip to content

Commit

Permalink
Fix: In Snakes and Ladders uses last version of questions.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdaloukas committed Aug 16, 2023
1 parent ed9ed85 commit 9316457
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in version 2023-08-16-06
* Fix: In Snakes and Ladders uses last version of questions.

Changes in version 2023-08-16-05
* Fix: Showing equation in crossword.

Expand Down
16 changes: 14 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,15 +613,27 @@ function game_questions_selectrandom( $game, $count=1) {
function game_questions_selectrandom_detail( $table, $select, $idfield="id", $count=1) {
global $DB;

$sql = "SELECT $idfield FROM $table WHERE $select";
$versions = game_get_moodle_version() >= '04.00';
$fields = $versions ? ',qv.questionbankentryid,qv.version' : '';
$order = $versions ? ' ORDER BY qv.questionbankentryid,qv.version DESC' : '';

$sql = "SELECT $idfield{$fields} FROM $table WHERE $select $order";
if (($recs = $DB->get_records_sql( $sql)) == false) {
return false;
}

// The array contains the ids of all questions.
$map = array();
$a = array();
foreach ($recs as $rec) {
$a[$rec->id] = $rec->id;
if( $versions) {
if( array_key_exists( $rec->questionbankentryid, $map)) {
continue;
} else {
$map[ $rec->questionbankentryid] = 1;
}
}
$a[ $rec->id] = $rec->id;
}

if ($count >= count( $a)) {
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
}

$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics).
$plugin->version = 2023081605; // The current module version (Date: YYYYMMDDXX).
$plugin->version = 2023081606; // 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 = '2023-08-16-05';
$plugin->release = '2023-08-16-06';
$plugin->maturity = MATURITY_STABLE;

if ($useplugin != 2) {
Expand Down

0 comments on commit 9316457

Please sign in to comment.