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

Hangman (and maybe other games) won't respect attempt limit while reloading the attempt page

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.9.8
    • Module: Game
    • None
    • 2020081901
    • MOODLE_39_STABLE

      We got reported that the Hangman game was not respecting the attempt limit when a student finished the game. The problem was that, when a student finished all its attempts it reloaded the page so it gets a brand new attempt.
      To correct this problem (just for the Hangman game) we added a this code at the mod/game/attempt.php file, in the game_do_attempt() function and before the if ($continue) statement:

       

          if ($game->gamekind == "hangman") {
              global $USER, $CFG;
              $unfinishedattempt = game_get_user_attempt_unfinished($game->id, $USER->id);
              if ((!$unfinishedattempt) && (!game_can_start_new_attempt($game))) {
                  $continue = false;
                  $redirect_url = $CFG->wwwroot . '/mod/game/view.php?id=' . $cm->id;
                  redirect($redirect_url);
              }
          }
      

       

      Our current Moodle version is 3.9.4

            bdaloukas Vasilis Daloukas
            kisa-chan Tania Ramirez
            Votes:
            0 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.