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

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.8
    • Fix Version/s: None
    • Component/s: Module: Game
    • Labels:
      None
    • Plugin Version:
      2020081901
    • Affected Branches:
      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

            Assignee:
            bdaloukas Vasilis Daloukas
            Reporter:
            kisa-chan Tania Ramirez
            Participants:
            Component watchers:
            Vasilis Daloukas
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: