function game_hangman_play($id, $game, $attempt, $hangman, $onlyshow, $showsolution, $context) { global $CFG, $DB, $OUTPUT; $query = $DB->get_record('game_queries', array('id' => $hangman->queryid)); if ($attempt->language != '') { $wordrtl = game_right_to_left($attempt->language); } else { $wordrtl = right_to_left(); } $reverseprint = $wordrtl != right_to_left(); if ($game->toptext != '') { echo $game->toptext . '<br>'; } $max = $game->param10; // Maximum number of wrongs. if ($max <= 0) { $max = 6; } hangman_showpage($done, $correct, $wrong, $max, $wordline, $wordline2, $links, $game, $attempt, $hangman, $query, $onlyshow, $showsolution, $context); if (!$done) { if ($wrong > $max) { $wrong = $max; } if ($game->param3 == 0) { $game->param3 = 1; } echo "\r\n<br/><img src=\"" . $OUTPUT->pix_url('hangman/' . $game->param3 . '/hangman_' . $wrong, 'mod_game') . "\""; $message = sprintf(get_string('hangman_wrongnum', 'game'), $wrong, $max); echo ' ALIGN="MIDDLE" BORDER="0" HEIGHT="100" alt="' . $message . '"/>'; if ($wrong >= $max) { // This word is incorrect. If reach the max number of word I have to finish else continue with next word. hangman_onincorrect($id, $wordline, $query->answertext, $game, $attempt, $hangman, $onlyshow, $showsolution); } else { $i = $max - $wrong; if ($i > 1) { echo ' ' . get_string('hangman_restletters_many', 'game', $i); } else { echo ' ' . get_string('hangman_restletters_one', 'game'); } if ($reverseprint) { echo '<SPAN dir="' . ($wordrtl ? 'rtl' : 'ltr') . '">'; } echo "<br/><font size=\"5\">\n{$wordline}</font>\r\n"; if ($wordline2 != '') { echo "<br/><font size=\"5\">\n{$wordline2}</font>\r\n"; } if ($reverseprint) { echo "</SPAN>"; } if ($hangman->finishedword == false) { echo "<br/><br/><BR/>" . get_string('hangman_letters', 'game') . $links . "\r\n"; } } } else { // This word is correct. If reach the max number of word I have to finish else continue with next word. hangman_oncorrect($id, $wordline, $game, $attempt, $hangman, $query); } echo "<br/><br/>" . get_string('grade', 'game') . ' : ' . round($query->percent * 100) . ' %'; if ($hangman->maxtries > 1) { echo '<br/><br/>' . get_string('hangman_gradeinstance', 'game') . ' : ' . round($hangman->corrects / $hangman->maxtries * 100) . ' %'; } if ($game->bottomtext != '') { echo '<br><br>' . $game->bottomtext; } }
function game_hangman_play($id, $game, $attempt, $hangman, $onlyshow = false, $showsolution = false) { global $CFG; $query = get_record('game_queries', 'id', $hangman->queryid); if ($game->toptext != '') { echo $game->toptext . '<br>'; } $max = 6; // maximum number of wrong hangman_showpage($done, $correct, $wrong, $max, $word_line, $word_line2, $links, $game, $attempt, $hangman, $query, $onlyshow, $showsolution); if (!$done) { if ($wrong > 6) { $wrong = 6; } if ($game->param3 == 0) { $game->param3 = 1; } echo "\r\n<BR/><img src=\"" . $CFG->wwwroot . '/mod/game/hangman/' . $game->param3 . '/hangman_' . $wrong . '.jpg"'; $message = sprintf(get_string('hangman_wrongnum', 'game'), $wrong, $max); echo ' ALIGN="MIDDLE" BORDER="0" HEIGHT="100" alt="' . $message . '"/>'; if ($wrong >= $max) { //This word is incorrect. If reach the max number of word I have to finish else continue with next word hangman_oninncorrect($id, $word_line, $query->answertext, $game, $attempt, $hangman); } else { $i = $max - $wrong; echo ' ' . get_string('hangman_restletters_' . ($i > 1 ? 'many' : 'one'), 'game', $i); echo "<br/><font size=\"5\">\n{$word_line}</font>\r\n"; if ($word_line2 != '') { echo "<br/><font size=\"5\">\n{$word_line2}</font>\r\n"; } if ($hangman->finishedword == false) { echo "<br/><br/><BR/>" . get_string('hangman_letters', 'game') . $links . "\r\n"; } } } else { //This word is correct. If reach the max number of word I have to finish else continue with next word hangman_oncorrect($id, $word_line, $game, $attempt, $hangman, $query); } echo "<br/><br/>" . get_string('hangman_grade', 'game') . ' : ' . round($query->percent * 100) . ' %'; if ($hangman->maxtries > 1) { echo '<br/><br/>' . get_string('hangman_gradeinstance', 'game') . ' : ' . round($hangman->corrects / $hangman->maxtries * 100) . ' %'; } if ($game->bottomtext != '') { echo '<br><br>' . $game->bottomtext; } }