Uploaded image for project: 'Plugins'
  1. Plugins
  2. CONTRIB-9385

sudoku using glossary does not work with Moodle 4.x

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 4.0.7, 4.1.5, 4.2.2
    • Module: Game
    • None
    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE

      Did not see that bug tracker for this module is here.

      So just reposting https://github.com/bdaloukas/moodle-mod_game/issues/60

      Steps to reproduce

      • Create a sudoku which is using glossary as source.
      • Try to launch the game.

      Result

      {{Unknown column 'qv.questionbankentryid' in 'field list'
      SELECT ge.id,qv.questionbankentryid,qv.version FROM mdl_glossary_entries ge WHERE (glossaryid='1' OR sourceglossaryid='1') ORDER BY qv.questionbankentryid,qv.version DESC
      [array (
      )]
      Error code: dmlreadexception

      line 494 of /lib/dml/moodle_database.php: dml_read_exception thrown
      line 293 of /lib/dml/moodle_read_slave_trait.php: call to moodle_database->query_end()
      line 1282 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->query_end()
      line 621 of /mod/game/locallib.php: call to mysqli_native_moodle_database->get_records_sql()
      line 580 of /mod/game/locallib.php: call to game_questions_selectrandom_detail()
      line 79 of /mod/game/sudoku/play.php: call to game_questions_selectrandom()
      line 280 of /mod/game/attempt.php: call to game_sudoku_continue()
      line 242 of /mod/game/attempt.php: call to game_create()
      line 40 of /mod/game/attempt.php: call to game_do_attempt()}}
       

      Analysis

      In 9316457 you introduced question/quiz specific fields in the query used in
      moodle-mod_game/locallib.php

      Line 620 in e4109a7
       

      $sql = "SELECT $idfield{$fields} FROM $table WHERE $select $order";

      making it no more compatible with glossary as source.

       

      Solution / Workaround

      Waiting a cleaner solution below an ugly patch I've done as workaround to prevent glossaries to crash.

      ---
       locallib.php | 7 ++++---
       1 file changed, 4 insertions(+), 3 deletions(-)
       
      diff --git a/locallib.php b/locallib.php
      index 87118bd..595bbd3 100644
      --- a/locallib.php
      +++ b/locallib.php
      @@ -614,8 +614,9 @@ function game_questions_selectrandom_detail( $table, $select, $idfield="id", $co
           global $DB;
       
           $versions = game_get_moodle_version() >= '04.00';
      -    $fields = $versions ? ',qv.questionbankentryid,qv.version' : '';
      -    $order = $versions ? ' ORDER BY qv.questionbankentryid,qv.version DESC' : '';
      +    $usequestionbank = !in_array($table, ["{glossary_entries} ge"]);
      +    $fields = ($usequestionbank && $versions) ? ',qv.questionbankentryid,qv.version' : '';
      +    $order = ($usequestionbank && $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) {
      @@ -626,7 +627,7 @@ function game_questions_selectrandom_detail( $table, $select, $idfield="id", $co
           $map = array();
           $a = array();
           foreach ($recs as $rec) {
      -        if( $versions) {
      +        if( $usequestionback && $versions) {
                   if( array_key_exists( $rec->questionbankentryid, $map)) {
                       continue;
                   } else {
      --
      

            bdaloukas Vasilis Daloukas
            andil Andil
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.