Browse Source

Moodle 3.3 compatibility - Export hangman

MOODLE_20_STABLE
Vasilis Daloukas 8 years ago
parent
commit
177d1a1b2b
  1. 6
      export/exporthtml_hangman.php
  2. 26
      locallib.php

6
export/exporthtml_hangman.php

@ -178,7 +178,7 @@ function selectLetter(l)
if (display_word.indexOf("#") == -1) { if (display_word.indexOf("#") == -1) {
// won // won
alert( "<?php echo game_get_string_lang( 'win', 'game', $lang); ?>"); alert( "<?php echo game_get_string_lang( 'win', 'mod_game', $lang); ?>");
can_play = false; can_play = false;
reset(); reset();
} }
@ -195,7 +195,7 @@ if ($html->type != 'hangmanp') {
?> ?>
if (wrong_guesses == <?php echo $game->param10 + 1;?>) { if (wrong_guesses == <?php echo $game->param10 + 1;?>) {
// lost // lost
alert( "<?php echo strip_tags( game_get_string_lang( 'hangman_loose', 'game', $lang)); ?>"); alert( "<?php echo strip_tags( game_get_string_lang( 'hangman_loose', 'mod_game', $lang)); ?>");
can_play = false; can_play = false;
reset(); reset();
} }
@ -362,7 +362,7 @@ var Base64 = {
<div id="question"></div> <div id="question"></div>
<img src="<?php echo ($html->type == 'hangmanp' ? '' : 'hangman_0.jpg');?>" name="hm"> <img src="<?php echo ($html->type == 'hangmanp' ? '' : 'hangman_0.jpg');?>" name="hm">
<a href="javascript:reset();"><?php echo game_get_string_lang( 'html_hangman_new', 'game', $lang); ?></a> <a href="javascript:reset();"><?php echo game_get_string_lang( 'html_hangman_new', 'mod_game', $lang); ?></a>
<form name="game"> <form name="game">
<div id="displayWord"> </div> <div id="displayWord"> </div>
<div id="usedLetters"> </div> <div id="usedLetters"> </div>

26
locallib.php

@ -1821,29 +1821,7 @@ function game_create_zip( $srcdir, $courseid, $filename) {
function game_get_string_lang( $identifier, $module, $lang) { function game_get_string_lang( $identifier, $module, $lang) {
global $CFG; global $CFG;
$langfile = "{$CFG->dirroot}/mod/game/lang/$lang/game.php"; return get_string_manager()->get_string($identifier, $module, null, $lang);
$result = get_string_from_file( $identifier, $langfile, "\$ret");
if ($result != '') {
$pos = strpos( $result, '=');
if ($pos > 0) {
$result = substr( $result, $pos + 1);
$pos = strpos( $result, "'");
if ($pos > 0) {
$result = substr( $result, $pos + 1);
$pos = strpos( $result, "'");
if ($pos > 0) {
$result = substr( $result, 0, $pos);
}
}
}
}
if ($result != '') {
return $result;
} else {
return get_string( $identifier, $module);
}
} }
function get_string_from_file($identifier, $langfile, $destination) { function get_string_from_file($identifier, $langfile, $destination) {
@ -1861,7 +1839,7 @@ function get_string_from_file($identifier, $langfile, $destination) {
return false; return false;
} }
return $destination .'= sprintf("'. $string[$identifier] .'");'; return $string[ $identifier];
} }
// Inserts a record to game_attempts. // Inserts a record to game_attempts.

Loading…
Cancel
Save