## Activities: Game

mod_game
Maintained by Vasilis Daloukas
The game activity module makes use of questions, quizzes and glossaries to create offer a variety of interactive games.
4731 sites
165 fans
Moodle 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8

This module gets input from quiz, glossary or questions and plays some games. The games are:

* hangman
* crossword
* cryptex
* millionaire
* sudoku
* The hidden picture
* Book with questions

If you like this module please consider donating via PayPal at   to help me continue working on this project. When you donate you can ask for new facilities e.g. support for new languages, new games, new statistics, more documentation on some forms or extra support.
It's a project that has been active since 2007 and is the number 6 on downloads in the last 12 months according to https://moodle.org/plugins/stats.php?plugin_category=1.
This module is and will remain free, but your donation allows me to continue the development, and any amount is greatly appreciated.

Now is GDPR compliant.

### Sets

This plugin is part of set Gamification.

### Awards

• Fri, Apr 26, 2019, 8:43 PM
Fix CONTRIB-7699 Problem with upgrading game plugin
• Thu, May 2, 2019, 5:37 PM
• Tue, May 7, 2019, 4:36 AM
Cantineo Que te veo: Can you tell which version of Game do you have and which version of Game do you want to install?
Can you send me the exact error message (this will be very helpfull).
• Sun, Jun 23, 2019, 5:08 PM
Dear Vasilis,

I have moodle 3.7+ installed and created a glossary to use in a crossword game. The crossword appears alright and the answers are entered/checked correctly when the user enters them (i.e. wrong number of letters).

But, after the user has completed the crossword, pressing either the check crossword option or the complete crossword option leads to simply reload the crossword with a blank one and the previous attempt is recorded as a total failure (0%), even if the user has completed all the answers correctly.

Is it something I am doing wrong? Maybe with the glossary?

Thank you very much...
• Sun, Jun 23, 2019, 5:16 PM
..hello again...the same also happens to a cryptex. When clicking on "Answer" a textbox appears where the user can enter his/her answers, but upon clicking "OK", again, the cryptex is reloaded. If the user clicks "End of game" it simply reloads the cryptex by not recording any "finished attempt".

• Sun, Jun 23, 2019, 9:21 PM
OK...coming back with this issue, after all it is not an error, but it is happening only for the "admin" user. If the "admin" user tries any game then this behavior occurs, which is not a big deal actuslly, since your plugins are excellent and with very qualitative code.
If another user is delegated as an administrator to the site, this behavior does NOT happen.

Finally, one error that is reported is when one tries to preview, or see the solution of a completed cryptex, via the administration menu of the "Show attempts" choice. It reports with the error:
"Too few arguments to function game_cryptex_play(), 9 passed in [dirroot]/mod/game/preview.php on line 81 and exactly 12 expected".
I added these extra three parameters as I saw fit and everything worked fine!

Thank you again, and keep up the good work!
• Sat, Jun 29, 2019, 1:02 PM
• Sat, Jun 29, 2019, 7:40 PM
Yes! I downloaded and installed the new version and the error is gone. However, the "admin" behavior continues, in case you looked at it also, but again I think it might be intentional.

Have a nice weekend!
• Sat, Jun 29, 2019, 9:35 PM
This is really good!
• Fri, Jul 12, 2019, 4:39 PM
Dear Vassilis Goodmorning,

I have spotted a few bugs in the hangman game which I would like to share them with you along with some proposed fixes. Most of them concern the "Show Attemtps" administrative menu, after the user has completed the game successfully, or not successfully.

1) More in particular, when the user fully completes the game (i.e. finds all of the words) and the manager goes in the "Show Attempts" menu then the following happens:
If the "Preview" button is clicked, then the preview of the last word is shown, along with the game score. If the administrator returns back to the previous screen and refreshes the screen, then the user's score is increased to 200 and the number of attempts by one. If the Preview button is pressed again and the administrator returns back and refereshes the "Show attempts" screen, then the score remains at 200 and the attemtps again go up by one. Every time the "Preview" button is clicked, the attempts go up by one and the score remains at 200. The same score is also displayed in the user's view of attempts (i.e. it is updated in the DB).

2) If the user completely fails the test (achieves 0 score), then if the Administrator clicks on the "Solution" button, then it does not show the solution, but the preview.

3) If the game had more than one words, then in both the solution and the preview screens, the "Grade in the Whole Game" displayed is increased by 0,25 (25%). For example, if the game had 4 words and the user found only 1, then the Grade in the whole game will be displayed 50% instead of 25% and so on.

PROPOSED FIXES
Since you are the architect of this very nice and complicated set of code, I would like to contribute with some proposed solutions and if you find them fit, you could incorporate them.

All the fixes are in the moodle_dir/mod/game/hangman/play.php file.

1) LINE 312, the call to hangman_oncorrect should incorporate the $onlyshow parameter, to account for that case also hangman_oncorrect($cm, $wordline,$game, $attempt,$hangman, $onlyshow,$query, $course); 2) LINE 320, the calculation of the total score, should not include the percent calculation if we Preview or view the solution of the game: if ($done or $onlyshow or$showsolution) {
$percent = 0; } 3) LINE 475, it should take into account the$onlyshow, because it erroneously increases the corrects by one, increasing the Grade of the Whole game at the end:
if ($done and !$onlyshow) {
$hangman->corrects =$hangman->corrects + 1;
$updrec->corrects =$hangman->corrects;
}

4) LINES 527 and 540, in the hangman_oncorrect method, both the signature of the method should include the $onlyshow and at the end should skip the game_hangman_show_nextword method call if$onlyshow is used, because it updates the database with increased number of attempts for every preview click
function hangman_oncorrect( $cm,$wordline, $game,$attempt, $hangman,$onlyshow, $query,$course) {
.......
......
if ($onlyshow) { return; } game_hangman_show_nextword($cm, $game,$attempt, $hangman,$course);

5) LINE 565 in the hangman_onincorrect method, should differentiate between the onlyshow and showsolution cases, because it does not display the solution at all if the user did not solve the word at all:
// REPLACE THIS with the one below if ( $onlyshow or$showsolution ) {
if ( $onlyshow ) { return; } and in the same method at the end include the$showsolution check before the game_hangman_show_nextword method:
if ($showsolution) { return; } game_hangman_show_nextword($cm, $game,$attempt, $hangman,$course);
............

And that's it. Hope that I have helped. The version we are using is Moodle 3.7.1, the latest.

Best Regards,

-Fk
• Fri, Jul 12, 2019, 6:55 PM
Thanks "Filippos Kolovos". I included your proposals. Please take again a look.
• Fri, Jul 12, 2019, 6:57 PM
Thanks "Filippos Kolovos". I included your proposals. Please take again a look.
• Fri, Jul 12, 2019, 8:21 PM
Oh Thanks! Glad to have helped!!
• Sat, Jul 13, 2019, 1:06 PM
I always loved Snakes and Ladders games
• Tue, Nov 12, 2019, 2:10 PM
thankyou