Browse Source

New: User defined language at hangman and crossword

MOODLE_20_STABLE
Vasilis Daloukas 10 years ago
parent
commit
ab99b86308
  1. 4
      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

4
cross/play.php

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

2
hangman/play.php

@ -51,7 +51,7 @@ function game_hangman_continue( $id, $game, $attempt, $hangman, $newletter, $act
$answer2 = str_replace( '-', '', $answer2);
}
$allletters = game_getallletters( $answer2, $game->language);
$allletters = game_getallletters( $answer2, $game->language, $game->userlanguage);
if( $allletters == ''){
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_showlast'] = 'Show last letter of hangman';
$string[ 'hangman_showquestion'] = 'Show the questions ?';
$string[ 'language_user_defined'] = 'User defined language';
$string[ 'hiddenpicture_across'] = 'Cells horizontal';
$string[ 'hiddenpicture_down'] = 'Cells down';
$string[ 'hiddenpicture_height'] = 'Set height of picture to (in pixels)';

33
locallib.php

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

5
mod_form.php

@ -232,8 +232,13 @@ class mod_game_mod_form extends moodleform_mod {
$a = array();
$a = get_string_manager()->get_list_of_translations();
$a[ ''] = '----------';
$a[ 'user'] = get_string('language_user_defined', 'game');
ksort( $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;
$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->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)
$module = $plugin;

Loading…
Cancel
Save