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

Details

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

    Description

      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

      Attachments

        Activity

          People

            bdaloukas Vasilis Daloukas
            kisa-chan Tania Ramirez
            Vasilis Daloukas
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: