Browse Source

New: User defined language at hangman and crossword

MOODLE_20_STABLE
Vasilis Daloukas 10 years ago
parent
commit
ab99b86308
  1. 6
      cross/play.php
  2. 2
      hangman/play.php
  3. 1
      lang/en/game.php
  4. 33
      locallib.php
  5. 5
      mod_form.php
  6. 4
      version.php

6
cross/play.php

@ -457,7 +457,7 @@ function WordEntryKeyPress(event)
// Returns true if the string passed in contains any characters prone to evil. // Returns true if the string passed in contains any characters prone to evil.
function ContainsBadChars(theirWord) function ContainsBadChars(theirWord)
{ {return false;
for (var i = 0; i < theirWord.length; i++) for (var i = 0; i < theirWord.length; i++)
if (BadChars.indexOf(theirWord.charAt(i)) >= 0) return true; if (BadChars.indexOf(theirWord.charAt(i)) >= 0) return true;
return false; return false;
@ -693,7 +693,7 @@ function PackPuzzle( sData)
s = s2.concat( s.substr( j)); s = s2.concat( s.substr( j));
} }
return s; return encodeURIComponent( s);
} }
// Called when the "check server" link is clicked. // Called when the "check server" link is clicked.
@ -735,7 +735,7 @@ function CheckServerClick( endofgame)
} }
sData += UserEntry; sData += UserEntry;
} }
sData = PackPuzzle( sData); sData = PackPuzzle( sData);
if( endofgame) if( endofgame)

2
hangman/play.php

@ -51,7 +51,7 @@ function game_hangman_continue( $id, $game, $attempt, $hangman, $newletter, $act
$answer2 = str_replace( '-', '', $answer2); $answer2 = str_replace( '-', '', $answer2);
} }
$allletters = game_getallletters( $answer2, $game->language); $allletters = game_getallletters( $answer2, $game->language, $game->userlanguage);
if( $allletters == ''){ if( $allletters == ''){
continue; continue;

1
lang/en/game.php

@ -241,6 +241,7 @@ $string[ 'hangman_showcorrectanswer'] = 'Show the correct answer after the end';
$string[ 'hangman_showfirst'] = 'Show first letter of hangman'; $string[ 'hangman_showfirst'] = 'Show first letter of hangman';
$string[ 'hangman_showlast'] = 'Show last letter of hangman'; $string[ 'hangman_showlast'] = 'Show last letter of hangman';
$string[ 'hangman_showquestion'] = 'Show the questions ?'; $string[ 'hangman_showquestion'] = 'Show the questions ?';
$string[ 'language_user_defined'] = 'User defined language';
$string[ 'hiddenpicture_across'] = 'Cells horizontal'; $string[ 'hiddenpicture_across'] = 'Cells horizontal';
$string[ 'hiddenpicture_down'] = 'Cells down'; $string[ 'hiddenpicture_down'] = 'Cells down';
$string[ 'hiddenpicture_height'] = 'Set height of picture to (in pixels)'; $string[ 'hiddenpicture_height'] = 'Set height of picture to (in pixels)';

33
locallib.php

@ -508,25 +508,34 @@ function game_detectlanguage( $word){
//The words maybe are in two languages e.g. greek or english //The words maybe are in two languages e.g. greek or english
//so I try to find the correct one. //so I try to find the correct one.
function game_getallletters( $word, $lang='') function game_getallletters( $word, $lang='', $userlanguage='')
{ {
for(;;) for(;;)
{ {
$strings = get_string_manager()->load_component_strings( 'game', ($lang == '' ? 'en' : $lang)); if( $lang == 'user')
if( isset( $strings[ 'lettersall']))
{ {
$letters = $strings[ 'lettersall']; $letters = $userlanguage;
$word2 = game_upper( $word, $lang); if( hangman_existall( $word, $letters))
if( hangman_existall( $word2, $letters))
return $letters; return $letters;
} else
return '';
}else
{
$strings = get_string_manager()->load_component_strings( 'game', ($lang == '' ? 'en' : $lang));
if( isset( $strings[ 'lettersall']))
{
$letters = $strings[ 'lettersall'];
$word2 = game_upper( $word, $lang);
if( hangman_existall( $word2, $letters))
return $letters;
}
if( $lang == '') if( $lang == '')
break; break;
else else
$lang = ''; $lang = '';
}
} }
return ''; return '';
} }

5
mod_form.php

@ -232,8 +232,13 @@ class mod_game_mod_form extends moodleform_mod {
$a = array(); $a = array();
$a = get_string_manager()->get_list_of_translations(); $a = get_string_manager()->get_list_of_translations();
$a[ ''] = '----------'; $a[ ''] = '----------';
$a[ 'user'] = get_string('language_user_defined', 'game');
ksort( $a); ksort( $a);
$mform->addElement('select', 'language', get_string('hangman_language','game'), $a); $mform->addElement('select', 'language', get_string('hangman_language','game'), $a);
$mform->addElement('text', 'userlanguage', get_string('language_user_defined','game'));
$mform->setType('userlanguage', PARAM_TEXT);
$mform->disabledIf('userlanguage', 'language', 'neq', 'user');
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

4
version.php

@ -22,10 +22,10 @@ if( !isset( $plugin))
$useplugin = 2; $useplugin = 2;
$plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics) $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics)
$plugin->version = 2015071502; // The current module version (Date: YYYYMMDDXX) $plugin->version = 2015071503; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2010112400; // Requires Moodle 2.0 $plugin->requires = 2010112400; // Requires Moodle 2.0
$plugin->cron = 0; // Period for cron to check this module (secs) $plugin->cron = 0; // Period for cron to check this module (secs)
$plugin->release = '3.30.15.2'; $plugin->release = '3.30.15.3';
if( $useplugin != 2) if( $useplugin != 2)
$module = $plugin; $module = $plugin;

Loading…
Cancel
Save