From 07d60b818b69e4f8e22179022ec6363a47444a3a Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Sun, 13 Aug 2017 11:55:16 +0300 Subject: [PATCH] New: High score --- hangman/play.php | 11 ++++++++--- version.php | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hangman/play.php b/hangman/play.php index ee36a53..d7bbac1 100644 --- a/hangman/play.php +++ b/hangman/play.php @@ -300,7 +300,7 @@ function game_hangman_play( $id, $game, $attempt, $hangman, $onlyshow, $showsolu } if ($hangman->finishedword == false) { - echo "


".get_string( 'hangman_letters', 'game').$links."\r\n"; + echo "


".get_string( 'hangman_letters', 'game').' '.$links."\r\n"; } } } else { @@ -310,8 +310,10 @@ function game_hangman_play( $id, $game, $attempt, $hangman, $onlyshow, $showsolu echo "

".get_string( 'grade', 'game').' : '.round( $query->percent * 100).' %'; if ($hangman->maxtries > 1) { + $percent = ($correct - $wrong / $max) / game_strlen( $query->answertext); + $score = $hangman->corrects / $hangman->maxtries + $percent / 100; echo '

'.get_string( 'hangman_gradeinstance', 'game').' : '. - round( $hangman->corrects / $hangman->maxtries * 100).' %'; + round( $score * 100).' %'; } if ($game->bottomtext != '') { @@ -478,7 +480,10 @@ function hangman_showpage(&$done, &$correct, &$wrong, $max, &$wordline, &$wordli } else { $score = -1; } - + if( $hangman->maxtries > 0) { + $percent = ($correct - $wrong / $max) / game_strlen( $word); + $score = $hangman->corrects / $hangman->maxtries + $percent / 100; + } game_updateattempts( $game, $attempt, $score, $finished); game_update_queries( $game, $attempt, $query, $score, $answer); } diff --git a/version.php b/version.php index a59196e..1559abf 100644 --- a/version.php +++ b/version.php @@ -35,10 +35,10 @@ if (!isset( $plugin)) { } $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2017081104; // The current module version (Date: YYYYMMDDXX). +$plugin->version = 2017081301; // The current module version (Date: YYYYMMDDXX). $plugin->requires = 2010112400; // Requires Moodle 2.0. $plugin->cron = 0; // Period for cron to check this module (secs). -$plugin->release = '2017-08-11'; +$plugin->release = '2017-08-13'; $plugin->maturity = MATURITY_STABLE; if ($useplugin != 2) {