From b0ffb2d355b641310fbce6ff81f6bef95ffee242 Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Wed, 31 May 2017 06:23:41 +0300 Subject: [PATCH] Fix: PHP coding style problems --- cross/crossdb_class.php | 2 +- cross/play.php | 894 ++++++++++++++-------------- cryptex/play.php | 132 ++-- db/access.php | 2 +- db/importsnakes.php | 2 + db/importsudoku.php | 2 + db/upgrade.php | 11 +- export.php | 4 +- export/html/snakes/css/game.css | 40 +- export/html/snakes/css/modal.css | 54 +- export/html/snakes/css/snakes.css | 142 +++-- export/html/snakes/css/style.css | 16 +- export/html/snakes/css/subModal.css | 101 ++-- export/html/snakes/js/snakes-mod.js | 230 ++++--- exporthtml.php | 6 +- exporthtml_hangman.php | 196 +++--- exporthtml_millionaire.php | 413 +++++++------ exporthtml_snakes.php | 463 +++++++------- 18 files changed, 1322 insertions(+), 1388 deletions(-) diff --git a/cross/crossdb_class.php b/cross/crossdb_class.php index 86932ad..edf9fe3 100644 --- a/cross/crossdb_class.php +++ b/cross/crossdb_class.php @@ -18,7 +18,7 @@ defined('MOODLE_INTERNAL') || die(); -/** +/* * This class is a cross that can load and save to a table * * @author bdaloukas diff --git a/cross/play.php b/cross/play.php index 61e4591..5d90f3d 100644 --- a/cross/play.php +++ b/cross/play.php @@ -352,7 +352,7 @@ if (document.getElementById("waitmessage") != null) for (var x = 0; x < CrosswordWidth; x++){ TableDownWord[x] = new Array(CrosswordHeight); } - + GuessLeter = new Array(CrosswordWidth); for (var x = 0; x < CrosswordWidth; x++) { GuessLeter[x] = new Array(CrosswordHeight); @@ -368,14 +368,14 @@ if (document.getElementById("waitmessage") != null) solu[ x][ y] = ""; } } - + for (var y = 0; y < CrosswordHeight; y++) { for (var x = 0; x < CrosswordWidth; x++) { TableAcrossWord[x][y] = -1; TableDownWord[x][y] = -1; } - } - // First, add the horizontal words to the puzzle. + } + // First, add the horizontal words to the puzzle. for (var i = 0; i <= LastHorizontalWord; i++) { x = WordX[i]; y = WordY[i]; @@ -395,7 +395,7 @@ if (document.getElementById("waitmessage") != null) solu[ x+j][ y] = c; } } - + // Second, add the vertical words to the puzzle. for (var i = LastHorizontalWord + 1; i < Words; i++) { x = WordX[i]; @@ -416,12 +416,12 @@ if (document.getElementById("waitmessage") != null) solu[ x][ y+j] = c; } } - + document.writeln(""); for (var x = 0; x < CrosswordWidth; x++) { document.write("" + (x+1) + " "); //col numbers } - + // Now, insert the row HTML into the table. for (var y = 0; y < CrosswordHeight; y++) { document.writeln(""); @@ -447,11 +447,11 @@ if (document.getElementById("waitmessage") != null) } document.writeln(""); } - + // Finally, show the crossword and hide the wait message. Initialized = true; document.getElementById("waitmessage").style.display = "none"; - document.getElementById("crossword").style.display = "block"; + document.getElementById("crossword").style.display = "block"; } // ---------- @@ -460,315 +460,319 @@ if (document.getElementById("waitmessage") != null) // Raised when a key is pressed in the word entry box. function WordEntryKeyPress(event) { - if (CrosswordFinished) return; - // Treat an Enter keypress as an OK click. - if (CurrentWord >= 0 && event.keyCode == 13) OKClick(); + if (CrosswordFinished) return; + // Treat an Enter keypress as an OK click. + if (CurrentWord >= 0 && event.keyCode == 13) OKClick(); } // ---------- // Helper functions // 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; +function ContainsBadChars(theirWord) { + return false; + + for (var i = 0; i < theirWord.length; i++) { + if (BadChars.indexOf(theirWord.charAt(i)) >= 0) return true; + } + return false; } // Pads a number out to three characters. -function PadNumber(number) -{ - if (number < 10) - return "00" + number; - else if (number < 100) - return "0" + number; - else - return "" + number; +function PadNumber(number) { + if (number < 10) } + return "00" + number; + } else if (number < 100) { + return "0" + number; + } else { + return "" + number; + } } // Returns the table cell at a particular pair of coordinates. -function CellAt(x, y) -{ - return document.getElementById("c" + PadNumber(x) + PadNumber(y)); +function CellAt(x, y) { + return document.getElementById("c" + PadNumber(x) + PadNumber(y)); } // Deselects the current word, if there's a word selected. DOES not change the value of CurrentWord. -function DeselectCurrentWord() -{ - if (CurrentWord < 0) return; - var x, y, i; - - document.getElementById("answerbox").style.display = "none"; - document.getElementById("answerbox2").style.display = "none"; - ChangeCurrentWordSelectedStyle(false); - CurrentWord = -1; - +function DeselectCurrentWord() { + if (CurrentWord < 0) { + return; + } + + var x, y, i; + + document.getElementById("answerbox").style.display = "none"; + document.getElementById("answerbox2").style.display = "none"; + ChangeCurrentWordSelectedStyle( false); + CurrentWord = -1; } // Changes the style of the cells in the current word. -function ChangeWordStyle(WordNumber, NewStyle) -{ - if (WordNumber< 0) return; - var x = WordX[WordNumber]; - var y = WordY[WordNumber]; - - if (WordNumber<= LastHorizontalWord) - for (i = 0; i < WordLength[WordNumber]; i++) - CellAt(x + i, y).className = NewStyle; - else - for (i = 0; i < WordLength[WordNumber]; i++) - CellAt(x, y + i).className = NewStyle; +function ChangeWordStyle(WordNumber, NewStyle) { + if (WordNumber< 0) { + return; + } + var x = WordX[WordNumber]; + var y = WordY[WordNumber]; + + if (WordNumber<= LastHorizontalWord) { + for (i = 0; i < WordLength[WordNumber]; i++) { + CellAt(x + i, y).className = NewStyle; + } + } else { + for (i = 0; i < WordLength[WordNumber]; i++) { + CellAt(x, y + i).className = NewStyle; + } + } } // Changes the style of the cells in the current word between the selected/unselected form. -function ChangeCurrentWordSelectedStyle(IsSelected) -{ - if (CurrentWord < 0) return; - var x = WordX[CurrentWord]; - var y = WordY[CurrentWord]; - - if (CurrentWord <= LastHorizontalWord) - for (i = 0; i < WordLength[CurrentWord]; i++) - CellAt(x + i, y).className = CellAt(x + i, y).className.replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel"); - else - for (i = 0; i < WordLength[CurrentWord]; i++) - CellAt(x, y + i).className = CellAt(x, y + i).className.replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel"); +function ChangeCurrentWordSelectedStyle(IsSelected) { + if (CurrentWord < 0) { + return; + } + var x = WordX[CurrentWord]; + var y = WordY[CurrentWord]; + + if (CurrentWord <= LastHorizontalWord) { + for (i = 0; i < WordLength[CurrentWord]; i++) { + CellAt(x + i, y).className = CellAt(x + i, y).className. + replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel"); + } + } else { + for (i = 0; i < WordLength[CurrentWord]; i++) { + CellAt(x, y + i).className = CellAt(x, y + i).className. + replace(IsSelected ? "_unsel" : "_sel", IsSelected ? "_sel" : "_unsel"); + } + } } // Selects the new word by parsing the name of the TD element referenced by the // event object, and then applying styles as necessary. -function SelectThisWord(event) -{ - if (CrosswordFinished) return; - var x, y, i, TheirWord, TableCell; - - // Deselect the previous word if one was selected. - document.getElementById("welcomemessage").style.display = "none"; - if (CurrentWord >= 0) OKClick(); - DeselectCurrentWord(); - - // Determine the coordinates of the cell they clicked, and then the word that - // they clicked. - var target = (event.srcElement ? event.srcElement: event.target); - x = parseInt(target.id.substring(1, 4), 10); - y = parseInt(target.id.substring(4, 7), 10); - - // If they clicked an intersection, choose the type of word that was NOT selected last time. - if (TableAcrossWord[x][y] >= 0 && TableDownWord[x][y] >= 0) - CurrentWord = PrevWordHorizontal ? TableDownWord[x][y] : TableAcrossWord[x][y]; - else if (TableAcrossWord[x][y] >= 0) - CurrentWord = TableAcrossWord[x][y]; - else if (TableDownWord[x][y] >= 0) - CurrentWord = TableDownWord[x][y]; - - PrevWordHorizontal = (CurrentWord <= LastHorizontalWord); - - // Now, change the style of the cells in this word. - ChangeCurrentWordSelectedStyle(true); - - // Then, prepare the answer box. - x = WordX[CurrentWord]; - y = WordY[CurrentWord]; - TheirWord = ""; - var TheirWordLength = 0; - for (i = 0; i < WordLength[CurrentWord]; i++) - { - // Find the appropriate table cell. - if (CurrentWord <= LastHorizontalWord) - TableCell = CellAt(x + i, y); - else - TableCell = CellAt(x, y + i); - // Add its contents to the word we're building. +function SelectThisWord(event) { + if (CrosswordFinished) { + return; + } + var x, y, i, TheirWord, TableCell; + + // Deselect the previous word if one was selected. + document.getElementById("welcomemessage").style.display = "none"; + if (CurrentWord >= 0) { + OKClick(); + } + DeselectCurrentWord(); + + // Determine the coordinates of the cell they clicked, and then the word that + // they clicked. + var target = (event.srcElement ? event.srcElement: event.target); + x = parseInt(target.id.substring(1, 4), 10); + y = parseInt(target.id.substring(4, 7), 10); + + // If they clicked an intersection, choose the type of word that was NOT selected last time. + if (TableAcrossWord[x][y] >= 0 && TableDownWord[x][y] >= 0) { + CurrentWord = PrevWordHorizontal ? TableDownWord[x][y] : TableAcrossWord[x][y]; + } else if (TableAcrossWord[x][y] >= 0) { + CurrentWord = TableAcrossWord[x][y]; + } else if (TableDownWord[x][y] >= 0) { + CurrentWord = TableDownWord[x][y]; + } + + PrevWordHorizontal = (CurrentWord <= LastHorizontalWord); + + // Now, change the style of the cells in this word. + ChangeCurrentWordSelectedStyle(true); + + // Then, prepare the answer box. + x = WordX[CurrentWord]; + y = WordY[CurrentWord]; + TheirWord = ""; + var TheirWordLength = 0; + for (i = 0; i < WordLength[CurrentWord]; i++) { + // Find the appropriate table cell. + if (CurrentWord <= LastHorizontalWord) { + TableCell = CellAt(x + i, y); + } else { + TableCell = CellAt(x, y + i); + } + // Add its contents to the word we're building. if (TableCell.innerHTML != null && TableCell.innerHTML.length > 0 && TableCell.innerHTML != " " && TableCell.innerHTML.toLowerCase() != " ") { - TheirWord += TableCell.innerHTML.toUpperCase(); - TheirWordLength++; - } else { - TheirWord += "•"; - } - } - - document.getElementById("wordlabel").innerHTML = TheirWord; - + TheirWord += TableCell.innerHTML.toUpperCase(); + TheirWordLength++; + } else { + TheirWord += "•"; + } + } + + document.getElementById("wordlabel").innerHTML = TheirWord; + var s = ((CurrentWord <= LastHorizontalWord) ? ); s = s + WordLength[CurrentWord] + (WordLength[CurrentWord] == 1 ? ); document.getElementById("wordinfo").innerHTML = s; - document.getElementById("wordclue").innerHTML = Clue[CurrentWord]; - document.getElementById("worderror").style.display = "none"; - //document.getElementById("cheatbutton").style.display = (Word.length == 0) ? "none" : ""; - if (TheirWordLength == WordLength[CurrentWord]) - document.getElementById("wordentry").value = TheirWord; - else - document.getElementById("wordentry").value = ""; - - // Finally, show the answer box. - document.getElementById("answerbox").style.display = "block"; - document.getElementById("answerbox2").style.display = "block"; - try - { - document.getElementById("wordentry").focus(); - document.getElementById("wordentry").select(); - } - catch (e) - { - } - + document.getElementById("wordclue").innerHTML = Clue[CurrentWord]; + document.getElementById("worderror").style.display = "none"; + + if (TheirWordLength == WordLength[CurrentWord]) { + document.getElementById("wordentry").value = TheirWord; + } else { + document.getElementById("wordentry").value = ""; + } + + // Finally, show the answer box. + document.getElementById("answerbox").style.display = "block"; + document.getElementById("answerbox2").style.display = "block"; + try { + document.getElementById("wordentry").focus(); + document.getElementById("wordentry").select(); + } + catch (e) { + } } // Called when the user clicks the OK link. -function OKClick() -{ - var TheirWord, x, y, i, TableCell; - if (CrosswordFinished) return; - if (document.getElementById("okbutton").disabled) return; - - // First, validate the entry. - TheirWord = document.getElementById("wordentry").value.toUpperCase(); - if (TheirWord.length == 0) - { - DeselectCurrentWord(); - return; - } - if (ContainsBadChars(TheirWord)) - { - document.getElementById("worderror").innerHTML = ""; - document.getElementById("worderror").style.display = "block"; - return; - } - if (TheirWord.length < WordLength[CurrentWord]) - { +function OKClick() { + var TheirWord, x, y, i, TableCell; + if (CrosswordFinished) { + return; + } + if (document.getElementById("okbutton").disabled) { + return; + } + + // First, validate the entry. + TheirWord = document.getElementById("wordentry").value.toUpperCase(); + if (TheirWord.length == 0) { + DeselectCurrentWord(); + return; + } + if (ContainsBadChars(TheirWord)) { + document.getElementById("worderror").innerHTML = ""; + document.getElementById("worderror").style.display = "block"; + return; + } + if (TheirWord.length < WordLength[CurrentWord]) { var s = ""; s = s + WordLength[CurrentWord] + " "; document.getElementById("worderror").innerHTML = s; - document.getElementById("worderror").style.display = "block"; - return; - } - if (TheirWord.length > WordLength[CurrentWord]) - { + document.getElementById("worderror").style.display = "block"; + return; + } + if (TheirWord.length > WordLength[CurrentWord]) { var s = ""; s = s + WordLength[CurrentWord] + " "; document.getElementById("worderror").innerHTML = s; - document.getElementById("worderror").style.display = "block"; - return; - } - - // If we made it this far, they typed an acceptable word, so add these letters to the puzzle and hide the entry box. - x = WordX[CurrentWord]; - y = WordY[CurrentWord]; - for (i = 0; i < TheirWord.length; i++) - { - TableCell = CellAt(x + (CurrentWord <= LastHorizontalWord ? i : 0), y + (CurrentWord > LastHorizontalWord ? i : 0)); - TableCell.innerHTML = TheirWord.substring(i, i + 1); - } - DeselectCurrentWord(); + document.getElementById("worderror").style.display = "block"; + return; + } + + // If we made it this far, they typed an acceptable word, so add these letters to the puzzle and hide the entry box. + x = WordX[CurrentWord]; + y = WordY[CurrentWord]; + for (i = 0; i < TheirWord.length; i++) { + TableCell = CellAt(x + (CurrentWord <= LastHorizontalWord ? i : 0), y + (CurrentWord > LastHorizontalWord ? i : 0)); + TableCell.innerHTML = TheirWord.substring(i, i + 1); + } + DeselectCurrentWord(); } - -function PackPuzzle( sData) -{ - var i; - var s; - var s2; - var n; - var j; - - s = ""; - len = sData.length; - for(i=0; i < len; i++) - { - c = sData.charAt( i); - if( (c > "0") && (c <= "9")) - { - s = s.concat( '/'); +function PackPuzzle( sData) { + var i, s, s2, n, j; + + s = ""; + len = sData.length; + for(i=0; i < len; i++) { + c = sData.charAt( i); + if( (c > "0") && (c <= "9")) { + s = s.concat( '/'); + } + s = s.concat( c); } - s = s.concat( c); - } - - for(;;) - { - i = s.indexOf( "__"); - if( i == -1) - break; - len = s.length; - - for( j=i ; j < len; j++) - { - if( s.charAt( j) != "_") - break; + + for(;;) { + i = s.indexOf( "__"); + if( i == -1) { + break; + } + len = s.length; + + for( j=i ; j < len; j++) { + if( s.charAt( j) != "_") { + break; + } + } + n = j - i; + s2 = s.substr( 0, i); + s2 = s2.concat( n); + s = s2.concat( s.substr( j)); } - n = j - i; - s2 = s.substr( 0, i); - s2 = s2.concat( n); - s = s2.concat( s.substr( j)); - } - return encodeURIComponent( s); + return encodeURIComponent( s); } // Called when the "check server" link is clicked. -function CheckServerClick( endofgame) -{ - var i, j, x, y, UserEntry, ErrorsFound = 0, EmptyFound = 0, TableCell; - if (CrosswordFinished) - return; - DeselectCurrentWord(); - - for (y = 0; y < CrosswordHeight; y++) - for (x = 0; x < CrosswordWidth; x++) - { - if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) - { - TableCell = CellAt(x, y); - if (TableCell.className == "box boxerror_unsel") - TableCell.className = "box boxnormal_unsel"; - } - } - - sData = ""; - for (i = 0; i < Words; i++) - { - // Get the user's entry for this word. - UserEntry = ""; - for (j = 0; j < WordLength[i]; j++) - { - if (i <= LastHorizontalWord) - TableCell = CellAt(WordX[i] + j, WordY[i]); - else - TableCell = CellAt(WordX[i], WordY[i] + j); - if (TableCell.innerHTML.length > 0 && TableCell.innerHTML.toLowerCase() != " ") - UserEntry += TableCell.innerHTML.toUpperCase(); - else if( TableCell.innerHTML.toLowerCase() == " ") - UserEntry += " "; - else - UserEntry += "_"; - } - sData += UserEntry; - } - - sData = PackPuzzle( sData); - - if( endofgame) - sData += "&finishattempt=1"; - -wwwroot}/mod/game/attempt.php?$params\"+ sData;\r\n"; +function CheckServerClick( endofgame) { + var i, j, x, y, UserEntry, ErrorsFound = 0, EmptyFound = 0, TableCell; + if (CrosswordFinished) { + return; + } + DeselectCurrentWord(); + + for (y = 0; y < CrosswordHeight; y++) { + for (x = 0; x < CrosswordWidth; x++) { + if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) { + TableCell = CellAt(x, y); + if (TableCell.className == "box boxerror_unsel") { + TableCell.className = "box boxnormal_unsel"; + } + } } -?> + } + + sData = ""; + for (i = 0; i < Words; i++) { + // Get the user's entry for this word. + UserEntry = ""; + for (j = 0; j < WordLength[i]; j++) { + if (i <= LastHorizontalWord) { + TableCell = CellAt(WordX[i] + j, WordY[i]); + } else { + TableCell = CellAt(WordX[i], WordY[i] + j); + } + if (TableCell.innerHTML.length > 0 && TableCell.innerHTML.toLowerCase() != " ") { + UserEntry += TableCell.innerHTML.toUpperCase(); + } else if( TableCell.innerHTML.toLowerCase() == " ") { + UserEntry += " "; + } else { + UserEntry += "_"; + } + } + sData += UserEntry; + } + + sData = PackPuzzle( sData); + + if( endofgame) { + sData += "&finishattempt=1"; + } + + wwwroot}/mod/game/attempt.php?$params\"+ sData;\r\n"; + } + ?> } function OnPrint() @@ -781,13 +785,12 @@ function OnPrint() } - function PrintHtmlClick() - { - document.getElementById("printhtmlbutton").style.display = "none"; - - document.getElementById("checkhtmlbutton").style.display = "none"; document.getElementById("checkhtmlbutton").style.display = "block"; - document.getElementById("printhtmlbutton").style.display = "block"; + document.getElementById("printhtmlbutton").style.display = "block"; } /** @@ -817,112 +820,104 @@ function OnPrint() var Base64 = { - // private property - _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - - // public method for decoding - decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);bgColor = "Black"; - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } - - output = Base64._utf8_decode(output); - - return output; - - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - while ( i < utftext.length ) { - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; - } - + // private property + _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + + // public method for decoding + decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);bgColor = "Black"; + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + } + + output = Base64._utf8_decode(output); + + return output; + + }, + + // private method for UTF-8 decoding + _utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; + while ( i < utftext.length ) { + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + } + + return string; + } } // Called when the "checkhtml" link is clicked. -function CheckHtmlClick() -{ - var i, TableCell, UserEntry, sData, solution; - - sData = ""; - for (i = 0; i < Words; i++) - { - solution = Base64.decode( HtmlSolutions[ i]); - // Get the user's entry for this word. - UserEntry = ""; - for (j = 0; j < WordLength[i]; j++) - { - if (i <= LastHorizontalWord) - TableCell = CellAt(WordX[i] + j, WordY[i]); - else - TableCell = CellAt(WordX[i], WordY[i] + j); - if (TableCell.innerHTML.length > 0 && TableCell.innerHTML.toLowerCase() != " ") - UserEntry += TableCell.innerHTML.toUpperCase(); - else if( TableCell.innerHTML.toLowerCase() == " ") - UserEntry += " "; - else - UserEntry += "_"; - - if( UserEntry[ j] != solution[ j]) - { - TableCell.innerHTML = " "; - } - } - - } +function CheckHtmlClick() { + var i, TableCell, UserEntry, sData, solution; + + sData = ""; + for (i = 0; i < Words; i++) { + solution = Base64.decode( HtmlSolutions[ i]); + // Get the user's entry for this word. + UserEntry = ""; + for (j = 0; j < WordLength[i]; j++) { + if (i <= LastHorizontalWord) { + TableCell = CellAt(WordX[i] + j, WordY[i]); + } else { + TableCell = CellAt(WordX[i], WordY[i] + j); + } + if (TableCell.innerHTML.length > 0 && TableCell.innerHTML.toLowerCase() != " ") { + UserEntry += TableCell.innerHTML.toUpperCase(); + } else if( TableCell.innerHTML.toLowerCase() == " ") { + UserEntry += " "; + } else { + UserEntry += "_"; + } + + if( UserEntry[ j] != solution[ j]) { + TableCell.innerHTML = " "; + } + } + } } function decodeutf8(utftext) { var string = ""; @@ -954,7 +949,7 @@ function CheckHtmlClick() return string; } //--> @@ -962,92 +957,91 @@ function CheckHtmlClick() -param3 == 2) { - echo '     '; - game_cross_show_legends( $cross); - } else { - game_cross_show_welcome( $game); - } +param3 == 2) { + echo '     '; + game_cross_show_legends( $cross); +} else { + game_cross_show_welcome( $game); +} ?> -'; - - echo ''; + + echo '     '; + if ($game->param5 == 1 or $game->param5 == null) { + echo '     '; + } - echo '     '; - if ($game->param5 == 1 or $game->param5 == null) { - echo '     '; - } + echo "\r\n"; +} - echo "\r\n"; - } +if ($showhtmlsolutions or $showhtmlprintbutton) { + echo '
'; +} - if ($showhtmlsolutions or $showhtmlprintbutton) { - echo '
'; - } +if ($showhtmlsolutions) { + echo ''; +} +if ($showhtmlprintbutton) { if ($showhtmlsolutions) { - echo ''; - } - - if ($showhtmlprintbutton) { - if ($showhtmlsolutions) { - echo "    "; - } - echo ''; + echo "    "; } + echo ''; +} - if ($game->param3 == 2) { - echo '     '; - game_cross_show_welcome( $game); - } else { - game_cross_show_legends( $cross); - } +if ($game->param3 == 2) { + echo '     '; + game_cross_show_welcome( $game); +} else { + game_cross_show_legends( $cross); +} - if ($game->bottomtext != '') { - echo '

'.$game->bottomtext; - } +if ($game->bottomtext != '') { + echo '

'.$game->bottomtext; +} - if ($attempt != false) { - if ($attempt->timefinish == 0 and $endofgame == 0) { +if ($attempt != false) { + if ($attempt->timefinish == 0 and $endofgame == 0) { ?> - +} +//--> + @@ -1079,17 +1073,17 @@ function game_cross_show_welcome0( $game) {
onkeypress="WordEntryKeyPress(event)" onchange="WordEntryKeyPress(event)" autocomplete="off">
param3 == 2) { - game_cross_show_welcome( $game); - } +if ($game->param3 == 2) { + game_cross_show_welcome( $game); +} ?> diff --git a/cryptex/play.php b/cryptex/play.php index 3ecb343..04a05bf 100644 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -16,11 +16,13 @@ /** * This page plays the cryptex game - * + * * @author bdaloukas * @package game **/ +defined('MOODLE_INTERNAL') || die(); + require_once( "cryptexdb_class.php"); function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $context) { @@ -267,27 +269,25 @@ width: 240pt; '; - echo '
'; - } +if ($showhtmlprintbutton) { + echo '
'; + echo '
'; +} - if ($showhtmlprintbutton) { +if ($showhtmlprintbutton) { ?> $q) { - $i++; - if ($showsolution == false) { - // When I want to show the solution a want to show the questions to. - if (array_key_exists( $q->id, $corrects)) { - continue; - } +$i = 0; +$else = ''; +$contextglossary = false; +foreach ($questions as $key => $q) { + $i++; + if ($showsolution == false) { + // When I want to show the solution a want to show the questions to. + if (array_key_exists( $q->id, $corrects)) { + continue; } + } - $question = game_show_query( $game, $q, "$i. ".$q->questiontext, $context); - $question2 = strip_tags($question); // ADDED BY DP (AUG 2009) - fixes " breaking the Answer button for this question. - - echo "'; - if (($onlyshow == false) and ($showsolution == false)) { - if (($game->param8 == 0) || ($game->param8 > $q->tries)) { - $question .= '  id});\" />"; - } - } - echo $question; + $question = game_show_query( $game, $q, "$i. ".$q->questiontext, $context); + $question2 = strip_tags($question); // ADDED BY DP (AUG 2009) - fixes " breaking the Answer button for this question. - if ($showsolution) { - echo "    $q->answertext"; + echo "'; + if (($onlyshow == false) and ($showsolution == false)) { + if (($game->param8 == 0) || ($game->param8 > $q->tries)) { + $question .= '  id});\" />"; } - echo '
'; } + echo $question; - if ($game->bottomtext != '') { - echo '

'.$game->bottomtext; + if ($showsolution) { + echo "    $q->answertext"; } + echo '
'; +} + +if ($game->bottomtext != '') { + echo '

'.$game->bottomtext; +} ?> - + '; - } else { - echo ''; - } +if ($print) { + echo ''; +} else { + echo ''; +} } function game_cryptex_onfinished( $id, $game, $attempt, $cryptexrec) { diff --git a/db/access.php b/db/access.php index 76fe84a..8a1db34 100644 --- a/db/access.php +++ b/db/access.php @@ -16,7 +16,7 @@ defined('MOODLE_INTERNAL') || die(); -/** +/* * Capability definitions for the game module. * * For naming conventions, see lib/db/access.php. diff --git a/db/importsnakes.php b/db/importsnakes.php index 33dfe49..7f1374c 100644 --- a/db/importsnakes.php +++ b/db/importsnakes.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + game_importsnakes(); function game_importsnakes() { diff --git a/db/importsudoku.php b/db/importsudoku.php index cdc93f5..76bf847 100644 --- a/db/importsudoku.php +++ b/db/importsudoku.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 26, ". "'A73IEDB8642I16875CF85237A94539712D6HBGFC849158415FI3G28913BE64GFDB89753175C41692H')"); $DB->execute( "INSERT INTO {game_sudoku_database}( level, opened, data) VALUES (1, 29, ". diff --git a/db/upgrade.php b/db/upgrade.php index 3aca593..d8a39ba 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -33,6 +33,8 @@ * before any action that may take longer time to finish. */ +defined('MOODLE_INTERNAL') || die(); + function xmldb_game_upgrade($oldversion) { global $CFG, $DB; @@ -1544,15 +1546,14 @@ function xmldb_game_upgrade($oldversion) { upgrade_mod_savepoint(true, $ver, 'game'); } - - if ($oldversion < ($ver = 2016062603)) { + + if ($oldversion < ($ver = 2016062603)) { $table = new xmldb_table('game_cross'); $field = new xmldb_field('createscore', XMLDB_TYPE_FLOAT, null, null, null, null, '0'); - // Launch change of type for field thisfield + // Launch change of type for field thisfield. $dbman->change_field_type($table, $field); } - - + return true; } diff --git a/export.php b/export.php index 0d420f7..47d630c 100644 --- a/export.php +++ b/export.php @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** +/* * This page exports a game to another platform e.g. html, jar - * + * * @author bdaloukas * @package game **/ diff --git a/export/html/snakes/css/game.css b/export/html/snakes/css/game.css index 936fe91..bd597b9 100644 --- a/export/html/snakes/css/game.css +++ b/export/html/snakes/css/game.css @@ -1,37 +1,33 @@ .nodis { - list-style-type:none; + list-style-type:none; } #cont { - position:relative; - display:none; + position:relative; + display:none; } - - .img1 { - position:absolute; - display:none; + position:absolute; + display:none; } - #dicecont { - float:right; - width:250px; - background-image: url(../images/meter.png); - background-repeat: repeat; - font-family: Arial, Helvetica, sans-serif; - font-weight: normal; - /*font-variant: small-caps;*/ - color: #FFFFFF; - border: 0.5em solid #333333; - top: 30px; - position: absolute; - left: 500px; - font-size: 14px; - padding: 10px; + float:right; + width:250px; + background-image: url(../images/meter.png); + background-repeat: repeat; + font-family: Arial, Helvetica, sans-serif; + font-weight: normal; + color: #FFFFFF; + border: 0.5em solid #333333; + top: 30px; + position: absolute; + left: 500px; + font-size: 14px; + padding: 10px; } diff --git a/export/html/snakes/css/modal.css b/export/html/snakes/css/modal.css index 976ab1f..cc0ab50 100644 --- a/export/html/snakes/css/modal.css +++ b/export/html/snakes/css/modal.css @@ -1,39 +1,39 @@ @charset "utf-8"; #fade { /*--Transparent background layer--*/ - display: none; /*--hidden by default--*/ - background: #000; - position: fixed; left: 0; top: 0; - width: 100%; height: 100%; - opacity: .80; - z-index: 9999; + display: none; /*--hidden by default--*/ + background: #000; + position: fixed; left: 0; top: 0; + width: 100%; height: 100%; + opacity: .80; + z-index: 9999; } .popup_block{ - display: none; /*--hidden by default--*/ - background: #fff; - padding: 20px; - border: 20px solid #ddd; - float: left; - font-size: 1.2em; - position: fixed; - top: 50%; left: 50%; - z-index: 99999; - /*--CSS3 Box Shadows--*/ - -webkit-box-shadow: 0px 0px 20px #000; - -moz-box-shadow: 0px 0px 20px #000; - box-shadow: 0px 0px 20px #000; - /*--CSS3 Rounded Corners--*/ - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - border-radius: 10px; + display: none; /*--hidden by default--*/ + background: #fff; + padding: 20px; + border: 20px solid #ddd; + float: left; + font-size: 1.2em; + position: fixed; + top: 50%; left: 50%; + z-index: 99999; + /*--CSS3 Box Shadows--*/ + -webkit-box-shadow: 0px 0px 20px #000; + -moz-box-shadow: 0px 0px 20px #000; + box-shadow: 0px 0px 20px #000; + /*--CSS3 Rounded Corners--*/ + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; } img.btn_close { - float: right; - margin: -55px -55px 0 0; + float: right; + margin: -55px -55px 0 0; } /*--Making IE6 Understand Fixed Positioning--*/ *html #fade { - position: absolute; + position: absolute; } *html .popup_block { - position: absolute; + position: absolute; } diff --git a/export/html/snakes/css/snakes.css b/export/html/snakes/css/snakes.css index d73d048..4047561 100644 --- a/export/html/snakes/css/snakes.css +++ b/export/html/snakes/css/snakes.css @@ -2,130 +2,126 @@ Husain Limdiyawala(MSc IT DA-IICT) Any Duplication of this code should be avoided*/ - .blocks { - font-family: Arial, Helvetica, sans-serif; - /*color: #FFFFFF;*/ - margin-left: 5px; - margin-top:2px; - margin-bottom:2px; - padding: 0px; - float:left; - height: 52px; - width: 52px; - display:block; - position:relative; - background-image: url(../square52.png); + font-family: Arial, Helvetica, sans-serif; + margin-left: 5px; + margin-top:2px; + margin-bottom:2px; + padding: 0px; + float:left; + height: 52px; + width: 52px; + display:block; + position:relative; + background-image: url(../square52.png); } .nodis { - list-style-type:none; + list-style-type:none; } #cont { - position:relative; - display:none; + position:relative; + display:none; } #diceimg { - display:none; - width:45px; + display:none; + width:45px; height:44px; } .img1 { - position:absolute; - display:none; + position:absolute; + display:none; } body { -background:#CCCCCC; + background:#CCCCCC; } #player { - display:none; - z-index:5; - position:absolute; + display:none; + z-index:5; + position:absolute; } #players { - margin-top: 0.3em; - margin-bottom: 1em; + margin-top: 0.3em; + margin-bottom: 1em; } #dicecont { - float:right; - width:170px; - background-image: url(../images/meter.png); - background-repeat: repeat; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - /*font-variant: small-caps;*/ - color: #FFFFFF; - border: 0.5em solid #333333; - top: 30px; - position: absolute; - right: 880px; + float:right; + width:170px; + background-image: url(../images/meter.png); + background-repeat: repeat; + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; + color: #FFFFFF; + border: 0.5em solid #333333; + top: 30px; + position: absolute; + right: 880px; } #playbtn { - margin-left:0.5em; - font-family: Arial, Helvetica, sans-serif; - font-weight: bold; - /*font-variant: small-caps;*/ - color: #000000; - background-color: #FC0; - padding: 1em; + margin-left:0.5em; + font-family: Arial, Helvetica, sans-serif; + font-weight: bold; + color: #000000; + background-color: #FC0; + padding: 1em; } /*-- from modal window coding --*/ #fade { /*--Transparent background layer--*/ - display: none; /*--hidden by default--*/ - background: #000; - position: fixed; left: 0; top: 0; - width: 100%; height: 100%; - opacity: .80; - z-index: 9999; + display: none; /*--hidden by default--*/ + background: #000; + position: fixed; left: 0; top: 0; + width: 100%; height: 100%; + opacity: .80; + z-index: 9999; } .popup_block{ - display: none; /*--hidden by default--*/ - background: #fff; - padding: 20px; - border: 20px solid #ddd; - float: left; - font-size: 1.2em; - position: fixed; - top: 50%; left: 50%; - z-index: 99999; - /*--CSS3 Box Shadows--*/ - -webkit-box-shadow: 0px 0px 20px #000; - -moz-box-shadow: 0px 0px 20px #000; - box-shadow: 0px 0px 20px #000; - /*--CSS3 Rounded Corners--*/ - -webkit-border-radius: 10px; - -moz-border-radius: 10px; - border-radius: 10px; + display: none; /*--hidden by default--*/ + background: #fff; + padding: 20px; + border: 20px solid #ddd; + float: left; + font-size: 1.2em; + position: fixed; + top: 50%; left: 50%; + z-index: 99999; + /*--CSS3 Box Shadows--*/ + -webkit-box-shadow: 0px 0px 20px #000; + -moz-box-shadow: 0px 0px 20px #000; + box-shadow: 0px 0px 20px #000; + /*--CSS3 Rounded Corners--*/ + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; } img.btn_close { - float: right; - margin: -55px -55px 0 0; - border: 0; + float: right; + margin: -55px -55px 0 0; + border: 0; } /*--Making IE6 Understand Fixed Positioning--*/ *html #fade { - position: absolute; + position: absolute; } *html .popup_block { - position: absolute; + position: absolute; } diff --git a/export/html/snakes/css/style.css b/export/html/snakes/css/style.css index f66fe34..7f5a35e 100644 --- a/export/html/snakes/css/style.css +++ b/export/html/snakes/css/style.css @@ -1,15 +1,15 @@ body { - background-color: #efefef; + background-color: #efefef; } body, html, input { - font-family:Verdana, Arial, Helvetica, sans-serif; - font-size:11px; - color: #333333; + font-family:Verdana, Arial, Helvetica, sans-serif; + font-size:11px; + color: #333333; } .info { - font-style:italic; - font-size: 0.9em; - color: #666666; -} \ No newline at end of file + font-style:italic; + font-size: 0.9em; + color: #666666; +} diff --git a/export/html/snakes/css/subModal.css b/export/html/snakes/css/subModal.css index 7b0f465..30e7958 100644 --- a/export/html/snakes/css/subModal.css +++ b/export/html/snakes/css/subModal.css @@ -2,68 +2,69 @@ * POPUP CONTAINER STYLES */ #popupMask { - position: absolute; - z-index: 200; - top: 0px; - left: 0px; - width: 100%; - height: 100%; - opacity: .4; - filter: alpha(opacity=50); - /* this hack is so it works in IE + position: absolute; + z-index: 200; + top: 0px; + left: 0px; + width: 100%; + height: 100%; + opacity: .4; + filter: alpha(opacity=50); + /* this hack is so it works in IE * I find setting the color in the css gives me more flexibility - * than the PNG solution. - */ - background-color:transparent !important; - background-color: #333333; - /* this hack is for opera support - * you can uncomment the background-image if you don't care about opera. - * this gives you the flexibility to use any bg color that you want, instead of the png - */ - background-image/**/: url("../images/maskBG.png") !important; // For browsers Moz, Opera, etc. - background-image:none; - background-repeat: repeat; - display:none; + * than the PNG solution. + */ + background-color:transparent !important; + background-color: #333333; + /* this hack is for opera support + * you can uncomment the background-image if you don't care about opera. + * this gives you the flexibility to use any bg color that you want, instead of the png + */ + background-image/**/: url("../images/maskBG.png") !important; // For browsers Moz, Opera, etc. + background-image:none; + background-repeat: repeat; + display:none; } + #popupContainer { - position: absolute; - z-index: 201; - top: 0px; - left: 0px; - display:none; - padding: 0px; + position: absolute; + z-index: 201; + top: 0px; + left: 0px; + display:none; + padding: 0px; } #popupInner { - border: 2px solid #000000; - background-color: #ffffff; + border: 2px solid #000000; + background-color: #ffffff; } #popupFrame { - margin: 0px; - width: 100%; - height: 100%; - position: relative; - z-index: 202; + margin: 0px; + width: 100%; + height: 100%; + position: relative; + z-index: 202; } #popupTitleBar { - background-color: #090; - color: # 000; - font-weight: bold; - height: 1.3em; - padding: 5px; - border-bottom: 2px solid #000000; - border-top: 1px solid #78A3F2; - border-left: 1px solid #78A3F2; - border-right: 1px solid #204095; - position: relative; - z-index: 203; + background-color: #090; + color: # 000; + font-weight: bold; + height: 1.3em; + padding: 5px; + border-bottom: 2px solid #000000; + border-top: 1px solid #78A3F2; + border-left: 1px solid #78A3F2; + border-right: 1px solid #204095; + position: relative; + z-index: 203; } #popupTitle { - float:left; - font-size: 1.1em; + float:left; + font-size: 1.1em; } #popupControls { - float: right; - cursor: pointer; - cursor: hand; + float: right; + cursor: pointer; + cursor: hand; } diff --git a/export/html/snakes/js/snakes-mod.js b/export/html/snakes/js/snakes-mod.js index 24ec151..b7c8e00 100644 --- a/export/html/snakes/js/snakes-mod.js +++ b/export/html/snakes/js/snakes-mod.js @@ -6,7 +6,7 @@ $(document).ready(function () { }); -//Global Variables +// Global Variables. var totblocks = 0; var data = ""; var currentblock = 0; @@ -20,12 +20,12 @@ var destsnake = new Array(4); var ladsrc = new Array(3); var laddest = new Array(3); -var quest = new Array(); //available questions along with multiple answers -var COR_answered = new Array(); //record all questions (along with answers) the user responded CORRECTLY -var WRO_answered = new Array(); //record all questions (along with answers) the user responded WRONGLY +var quest = new Array(); // Available questions along with multiple answers. +var COR_answered = new Array(); // Record all questions (along with answers) the user responded CORRECTLY. +var WRO_answered = new Array(); // Record all questions (along with answers) the user responded WRONGLY. var user = new Array(); -//Constract table with questions and answers and pick question to display +// Constract table with questions and answers and pick question to display. quest[0] = "Spell 1"; quest[1] = "one"; @@ -45,30 +45,29 @@ quest[14] = "three"; quest[15] = "one"; z = 0; for (z = 0; quest[z] != null; z++) { - // Do nothing + // Do nothing. } allQuest = z / 4; -function selectQuest(all) -{ +function selectQuest(all) { pickOne = Math.floor((Math.random() * all)); return pickOne; } -//The Below Function will hide all the snakes +// The Below Function will hide all the snakes. function hideAll() { - document.getElementById("img1").style.display = "none"; - document.getElementById("img2").style.display = "none"; - document.getElementById("img3").style.display = "none"; - document.getElementById("img4").style.display = "none"; + document.getElementById("img1").style.display = "none"; + document.getElementById("img2").style.display = "none"; + document.getElementById("img3").style.display = "none"; + document.getElementById("img4").style.display = "none"; - document.getElementById("lad1").style.display = "none"; - document.getElementById("lad2").style.display = "none"; + document.getElementById("lad1").style.display = "none"; + document.getElementById("lad2").style.display = "none"; document.getElementById("lad3").style.display = "none"; } -//The Below Function will Render The Main Board +// The Below Function will Render The Main Board. function paintBoard(a) { totblocks = (a * a); @@ -88,42 +87,42 @@ function paintBoard(a) { currentblock -= (a - 1); } } else { - currentblock = (a * a); - for (j = 0; j < (a / 2); j++) { - for (i = 0; i < a; i++) { - data += "
" + currentblock + "
"; - currentblock--; - } - - currentblock -= (a - 1); - - if (currentblock < 2) { - break; - } - - for (i = 0; i < a; i++) { - data += "
" + currentblock + "
"; - currentblock++; - } - currentblock -= (a + 1); - } - } + currentblock = (a * a); + for (j = 0; j < (a / 2); j++) { + for (i = 0; i < a; i++) { + data += "
" + currentblock + "
"; + currentblock--; + } + + currentblock -= (a - 1); + + if (currentblock < 2) { + break; + } + + for (i = 0; i < a; i++) { + data += "
" + currentblock + "
"; + currentblock++; + } + currentblock -= (a + 1); + } + } document.getElementById("cont").style.width = (a * 52 + 52) + "px" - document.getElementById("cont").innerHTML = data; - $("#cont").slideDown("slow"); - $("#cont").effect("shake",3000); - $("img:hidden").fadeIn(5000); + document.getElementById("cont").innerHTML = data; + $("#cont").slideDown("slow"); + $("#cont").effect("shake",3000); + $("img:hidden").fadeIn(5000); - if (a == 6) { - registerSnake(158, 196, "img1", 14, 3, 0); - registerSnake(62, 183, "img2", 27, 24, 1); - registerSnake(175, 18, "img3", 18, 4, 2); - registerSnake(10, 45, "img4", 32, 23, 3); + if (a == 6) { + registerSnake(158, 196, "img1", 14, 3, 0); + registerSnake(62, 183, "img2", 27, 24, 1); + registerSnake(175, 18, "img3", 18, 4, 2); + registerSnake(10, 45, "img4", 32, 23, 3); - registerLadder(27, 132, "lad1", 28, 34, 0); - registerLadder(90, 22, "lad2", 19, 30, 1); - registerLadder(179, 137, "lad3", 2, 16, 2); + registerLadder(27, 132, "lad1", 28, 34, 0); + registerLadder(90, 22, "lad2", 19, 30, 1); + registerLadder(179, 137, "lad3", 2, 16, 2); } else if (a == 8) { registerSnake(300, 380, "img1", 44, 29, 0); registerSnake(180, 550, "img2", 51, 46, 1); @@ -136,98 +135,97 @@ function paintBoard(a) { } } -//The below Function will simulate throwing of a dice +// The below Function will simulate throwing of a dice. function throwDice(i) { - randomno = Math.floor((Math.random() * 6)) + 1; - document.getElementById("diceimg").src = "images/dice_" + randomno + ".PNG"; + randomno = Math.floor((Math.random() * 6)) + 1; + document.getElementById("diceimg").src = "images/dice_" + randomno + ".PNG"; document.getElementById("diceimg").style.display = "block"; - if (lastposition[i] > 0) { + if (lastposition[i] > 0) { document.getElementById(lastposition[i]).style.background = "url(images/square52.png)"; - } - tots[i] += randomno; + } + tots[i] += randomno; - if (totblocks - tots[i] >= 0) { + if (totblocks - tots[i] >= 0) { lastposition[i] = tots[i]; document.getElementById(tots[i]).style.background = "url(images/pawn1.png)"; - } else { + } else { tots[i] -= randomno; document.getElementById(tots[i]).style.background = "url(images/pawn1.png)"; - } + } } // The below Function Checks The Snake Biting for a user. function snakescheck(k) { - i = 0; - - for(i = 0; i <= srcsnake.length; i++) { - if (srcsnake[i] == tots[k]) { - alert("Ωχ! Σε τσίμπησε φίδι στο τετράγωνο " + srcsnake[i] + " και θα πρέπει να γυρίσεις στο τετράγωνο " + destsnake[i] + ", εκτός κι αν απαντήσεις σωστά στην ερώτηση που ακολουθεί."); - document.getElementById(destsnake[i]).style.background = "url(images/pawn1.png)"; - document.getElementById(tots[k]).style.background = "url(images/square52.png)"; - lastposition[k] = destsnake[i]; - tots[k] = destsnake[i]; - break; - } - } + i = 0; + + for(i = 0; i <= srcsnake.length; i++) { + if (srcsnake[i] == tots[k]) { + alert("Ωχ! Σε τσίμπησε φίδι στο τετράγωνο " + srcsnake[i] + " και θα πρέπει να γυρίσεις στο τετράγωνο " + destsnake[i] + ", εκτός κι αν απαντήσεις σωστά στην ερώτηση που ακολουθεί."); + document.getElementById(destsnake[i]).style.background = "url(images/pawn1.png)"; + document.getElementById(tots[k]).style.background = "url(images/square52.png)"; + lastposition[k] = destsnake[i]; + tots[k] = destsnake[i]; + break; + } + } if (!checkWin(k)) { - alert("???d?se?!S???a??t???a!"); + alert("???d?se?!S???a??t???a!"); } } -//The below function checks the ladders for a user +// The below function checks the ladders for a user. function laddercheck(k) { - i = 0; + i = 0; - for(i = 0; i <= ladsrc.length; i++) { - if (ladsrc[i] == tots[k]) { + for(i = 0; i <= ladsrc.length; i++) { + if (ladsrc[i] == tots[k]) { alert("Υπάρχει μια σκάλα στο τετράγωνο " + ladsrc[i] + " και θα σας οδηγήσει κατευθείαν στο τετράγωνο " + laddest[i] + "αν απαντήσεις σωστά στην ερώτηση που ακολουθεί."); - document.getElementById(laddest[i]).style.background = "url(images/pawn1.png)"; - document.getElementById(tots[k]).style.background = "url(images/square52.png)"; - lastposition[k] = laddest[i]; - tots[k] = laddest[i]; - break; - } - } - if(!checkWin(k)) { - alert("You have won!"); + document.getElementById(laddest[i]).style.background = "url(images/pawn1.png)"; + document.getElementById(tots[k]).style.background = "url(images/square52.png)"; + lastposition[k] = laddest[i]; + tots[k] = laddest[i]; + break; + } + } + if(!checkWin(k)) { + alert("You have won!"); } } -//The below Function checks for pythons +// The below Function checks for pythons. function pythoncheck(k) { i = 0; - for (i = 0; i < pythons.length; i++) { - - if (pythons[i] == tots[k]) { - alert("You have been eaten up by a python.Your game is over"); - document.getElementById(tots[k]).style.background = "url(images/csnake.gif) #000000"; - lastposition[k] = null; - tots[k] = null; - break; - } - } + for (i = 0; i < pythons.length; i++) { + if (pythons[i] == tots[k]) { + alert("You have been eaten up by a python.Your game is over"); + document.getElementById(tots[k]).style.background = "url(images/csnake.gif) #000000"; + lastposition[k] = null; + tots[k] = null; + break; + } + } } // The below function will register a snake. function registerSnake(tp, lft, dv, src, dest, i) { - document.getElementById(dv).style.top = tp + "px"; - document.getElementById(dv).style.left = lft + "px"; - srcsnake[i] = src; - destsnake[i] = dest; + document.getElementById(dv).style.top = tp + "px"; + document.getElementById(dv).style.left = lft + "px"; + srcsnake[i] = src; + destsnake[i] = dest; } -// The below function will register a ladder.. +// The below function will register a ladder. function registerLadder(tp, lft, dv, src, dest, i) { - document.getElementById(dv).style.top = tp + "px"; - document.getElementById(dv).style.left = lft + "px"; - ladsrc[i] = src; - laddest[i] = dest; + document.getElementById(dv).style.top = tp + "px"; + document.getElementById(dv).style.left = lft + "px"; + ladsrc[i] = src; + laddest[i] = dest; } -//The below function checks the change in the boardtype selection combobox +// The below function checks the change in the boardtype selection combobox. function selectBoard() { totblocks = 0; data = ""; @@ -244,24 +242,24 @@ function selectBoard() { function selectPlayer() { if (document.getElementById("players").value != null) { user[document.getElementById("players").value - 1] = 0; - tots[document.getElementById("players").value - 1] = 0; - lastposition[document.getElementById("players").value - 1] = 0; - for(var j = 0; j < lastposition.length; j++) { + tots[document.getElementById("players").value - 1] = 0; + lastposition[document.getElementById("players").value - 1] = 0; + for(var j = 0; j < lastposition.length; j++) { lastposition[j] = 0; tots[j] = 0; - } - } + } + } } // The below function starts the play. function play() { - if (tots[l] != null) { + if (tots[l] != null) { disableField(); document.getElementById("status").innerHTML = "
  • O Paiktis " + (l + 1) + "
  • brisketai sto tetragwno " + tots[l] + "
"; Question(); document.getElementById("status").innerHTML = "
  • O Paiktis " + (l + 1) + "
  • vrisketai sto tetragwno " + tots[l] + "
"; - } else { + } else { document.getElementById("status").innerHTML = "
  • Molis exases...
"; } @@ -277,7 +275,7 @@ function doit(i) { throwDice(i); if (checkWin(i)) { snakescheck(i); - laddercheck(i); + laddercheck(i); } else { alert("ÏëïêëÞñùóåò ôçí ðßóôá, óõã÷áñçôÞñéá!!!"); } @@ -285,7 +283,7 @@ function doit(i) { // The below function checks whether the player has won or not. function checkWin(i) { - if( tots[i] == totblocks) { + if( tots[i] == totblocks) { return false; } else { return true; @@ -294,8 +292,8 @@ function checkWin(i) { // The below function will disable both the combobox . function disableField() { - document.getElementById("players").disabled = "disabled"; - document.getElementById("boardtype").disabled = "disabled"; + document.getElementById("players").disabled = "disabled"; + document.getElementById("boardtype").disabled = "disabled"; } function Question() { @@ -312,6 +310,6 @@ function Question() { WRO_answered.concat(quest.splice(picked * 4, 4)); } - // Remove question and answers from available questions - (thus not allowing to have a Repeated question) ---XOXOXO + // Remove question and answers from available questions - (thus not allowing to have a Repeated question). allQuest--; } diff --git a/exporthtml.php b/exporthtml.php index a285b29..d002712 100644 --- a/exporthtml.php +++ b/exporthtml.php @@ -14,13 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** +/* * This page export the game to html for games: cross, hangman - * + * * @author bdaloukas * @package game **/ +defined('MOODLE_INTERNAL') || die(); + require_once( "locallib.php"); require_once( "exportjavame.php"); diff --git a/exporthtml_hangman.php b/exporthtml_hangman.php index 58cea1d..9629de5 100644 --- a/exporthtml_hangman.php +++ b/exporthtml_hangman.php @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** +/* * This page export the game hangman to html - * + * * @author bdaloukas * @package game **/ @@ -129,7 +129,7 @@ var display_word = ""; var used_letters = ""; var wrong_guesses = 0; var used_letters_all = ""; -var all_letters = new Array( 0) { @@ -149,24 +149,21 @@ function selectLetter(l) { return; } - - used_letters_all += l; - - if( to_guess.indexOf(l) == -1) - { + + used_letters_all += l; + + if( to_guess.indexOf(l) == -1) { used_letters += l; document.getElementById('usedLetters').innerHTML = used_letters; } - - if (to_guess.indexOf(l) != -1) - { + + if (to_guess.indexOf(l) != -1) { // correct letter guess pos = 0; temp_mask = display_word; - while (to_guess.indexOf(l, pos) != -1) - { - pos = to_guess.indexOf(l, pos); + while (to_guess.indexOf(l, pos) != -1) { + pos = to_guess.indexOf(l, pos); end = pos + 1; start_text = temp_mask.substring(0, pos); @@ -178,16 +175,14 @@ function selectLetter(l) display_word = temp_mask; document.getElementById('displayWord').innerHTML=display_word; - - if (display_word.indexOf("#") == -1) - { + + if (display_word.indexOf("#") == -1) { // won alert( ""); can_play = false; reset(); } - }else - { + } else { wrong_guesses++; type != 'hangmanp') { - if (wrong_guesses == param10 + 1;?>) - { + if (wrong_guesses == param10 + 1;?>) { // lost alert( ""); can_play = false; @@ -216,8 +210,7 @@ function stripHTML(oldString) { } -function reset() -{ +function reset() { selectWord(); document.getElementById('usedLetters').innerHTML = " "; @@ -234,25 +227,22 @@ if ($html->type != 'hangmanp') { } -function showallletters() -{ +function showallletters() { var letters = ""; var next = all_letters.length / 4; var letter = ""; - for( i=0; i < all_letters.length; i++) - { - if( i > next) - { + for( i=0; i < all_letters.length; i++) { + if( i > next) { next += all_letters.length / 4; letters += " "; } letter = all_letters[ i]; - if( used_letters_all.length > 0) - { - if( used_letters_all.indexOf( letter) > -1) + if( used_letters_all.length > 0) { + if( used_letters_all.indexOf( letter) > -1) { continue; + } } letters = letters + "" + letter + "" @@ -260,14 +250,13 @@ function showallletters() document.getElementById( "letters").innerHTML = letters; } -function selectWord() -{ +function selectWord() { can_play = true; random_number = Math.round(Math.random() * (words.length - 1)); to_guess = Base64.decode( words[random_number]); to_question = Base64.decode( questions[random_number]); - - // display masked word + + // Display masked word. masked_word = createMask(to_guess); document.getElementById('displayWord').innerHTML=masked_word; @@ -288,8 +277,7 @@ function createMask(m) word_lenght = m.length; - for (i = 0; i < word_lenght; i ++) - { + for (i = 0; i < word_lenght; i++) { mask += "#"; } @@ -305,76 +293,69 @@ function createMask(m) var Base64 = { - // private property - _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - - // public method for decoding - decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } - - output = Base64._utf8_decode(output); - - return output; - - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while ( i < utftext.length ) { - - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; - } + // Private property. + _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + + // Public method for decoding. + decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + } + + output = Base64._utf8_decode(output); + + return output; + }, + // Private method for UTF-8 decoding. + _utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; + + while ( i < utftext.length ) { + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + } + + return string; + } } @@ -389,4 +370,3 @@ var Base64 = {
- diff --git a/exporthtml_millionaire.php b/exporthtml_millionaire.php index 458b0f8..cf91793 100644 --- a/exporthtml_millionaire.php +++ b/exporthtml_millionaire.php @@ -16,7 +16,7 @@ /** * This page export the game millionaire to html - * + * * @author bdaloukas * @package game **/ @@ -120,28 +120,28 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { var countQuestions = 0; var maxQuestions = ; - function Highlite( ans) { - document.getElementById( "btAnswer" + ans).style.backgroundColor = ''; - } - - function Restore( ans) { - document.getElementById( "btAnswer" + ans).style.backgroundColor = ''; - } - - function OnSelectAnswer( ans) { - if ( posCorrect == ans) { - if( level+1 > 15) { - alert( ""); - Reset(); - } else { - UpdateLevel( level+1); - SelectNextQuestion(); - } - } else { - OnGameOver( ans); - } - } - + function Highlite( ans) { + document.getElementById( "btAnswer" + ans).style.backgroundColor = ''; + } + + function Restore( ans) { + document.getElementById( "btAnswer" + ans).style.backgroundColor = ''; + } + + function OnSelectAnswer( ans) { + if ( posCorrect == ans) { + if( level+1 > 15) { + alert( ""); + Reset(); + } else { + UpdateLevel( level+1); + SelectNextQuestion(); + } + } else { + OnGameOver( ans); + } + } + function OnGameOver( ans) { document.getElementById( "info").innerHTML = " " + document.getElementById( "lblAnswer" + posCorrect).innerHTML; @@ -150,38 +150,38 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { document.getElementById( "lblAnswer" + posCorrect).style.backgroundColor = ''; alert( ""); - + Restore( posCorrect); document.getElementById( "lblAnswer" + posCorrect).style.backgroundColor = ''; - + Reset(); } - - function UpdateLevel( newlevel) { - if ( level > 0) { - document.getElementById( "levela" + level).bgColor = ""; - document.getElementById( "levelb" + level).bgColor = ""; - document.getElementById( "levelc" + level).bgColor = ""; - document.getElementById( "levela" + level).style.color = ""; - document.getElementById( "levelb" + level).style.color = ""; - document.getElementById( "levelc" + level).style.color = ""; - } - - level = newlevel; - - document.getElementById( "levela" + level).bgColor = ""; - document.getElementById( "levelb" + level).bgColor = ""; - document.getElementById( "levelc" + level).bgColor = ""; - document.getElementById( "levela" + level).style.color = ""; - document.getElementById( "levelb" + level).style.color = ""; - document.getElementById( "levelc" + level).style.color = ""; - } - - function OnHelp5050( ans) { - if (flag5050) { - return; + + function UpdateLevel( newlevel) { + if ( level > 0) { + document.getElementById( "levela" + level).bgColor = ""; + document.getElementById( "levelb" + level).bgColor = ""; + document.getElementById( "levelc" + level).bgColor = ""; + document.getElementById( "levela" + level).style.color = ""; + document.getElementById( "levelb" + level).style.color = ""; + document.getElementById( "levelc" + level).style.color = ""; } - + + level = newlevel; + + document.getElementById( "levela" + level).bgColor = ""; + document.getElementById( "levelb" + level).bgColor = ""; + document.getElementById( "levelc" + level).bgColor = ""; + document.getElementById( "levela" + level).style.color = ""; + document.getElementById( "levelb" + level).style.color = ""; + document.getElementById( "levelc" + level).style.color = ""; + } + + function OnHelp5050( ans) { + if (flag5050) { + return; + } + document.getElementById( "Help5050").src = "5050x.png"; flag5050 = 1; @@ -190,54 +190,54 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { for (i=1; i <= countQuestions; i++) { if( (i != pos) && (i != posCorrect)) { document.getElementById( "lblAnswer" + i).style.visibility = 'hidden'; - document.getElementById( "btAnswer" + i).style.visibility = 'hidden'; - } + document.getElementById( "btAnswer" + i).style.visibility = 'hidden'; + } } - } + } - function OnHelpTelephone( ans) { - if( flagTelephone) { - return; + function OnHelpTelephone( ans) { + if( flagTelephone) { + return; } - flagTelephone = 1; + flagTelephone = 1; document.getElementById( "HelpTelephone").src = "telephonex.png"; - - if (countQuestions < 2) { - wrong = posCorrect; - } else { - for(;;) { - wrong = 1 + Math.floor(Math.random() * countQuestions); - if ( wrong != posCorrect) { - break; - } - } - } - - // With 80% gives the correct answer. - if (Math.random() <= 0.8) { - pos = posCorrect; - } else { - pos = wrong; + + if (countQuestions < 2) { + wrong = posCorrect; + } else { + for(;;) { + wrong = 1 + Math.floor(Math.random() * countQuestions); + if ( wrong != posCorrect) { + break; + } + } + } + + // With 80% gives the correct answer. + if (Math.random() <= 0.8) { + pos = posCorrect; + } else { + pos = wrong; } - + info = "';?> "; info += document.getElementById( "lblAnswer" + pos).innerHTML; document.getElementById( "info").innerHTML = info; - } + } - function OnHelpPeople( ans) { + function OnHelpPeople( ans) { if( flagPeople) { - return; + return; } - flagPeople = 1; + flagPeople = 1; document.getElementById( "HelpPeople").src = "peoplex.png"; - + sum = 0; var aPercent = new Array(); for( i = 0; i < countQuestions-1; i++) { - percent = Math.floor(Math.random()*(100-sum)); - aPercent[ i] = percent; - sum += percent; + percent = Math.floor(Math.random()*(100-sum)); + aPercent[ i] = percent; + sum += percent; } aPercent[ countQuestions - 1] = 100 - sum; if( Math.random() <= 0.8) { @@ -256,24 +256,24 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { info = "'.get_string( 'millionaire_info_people', 'game').':
';?>"; for( i=0; i < countQuestions; i++) { info += "
" + letters.charAt( i) + " : " + aPercent[ i] + " %"; - } - - document.getElementById( "info").innerHTML = info; - } - - function OnQuit( ans) { - Reset(); - } - - function Reset() { - for(i=1; i <= 15; i++) { - document.getElementById( "levela" + i).bgColor = ""; - document.getElementById( "levelb" + i).bgColor = ""; - document.getElementById( "levelc" + i).bgColor = ""; - document.getElementById( "levela" + i).style.color = ""; - document.getElementById( "levelb" + i).style.color = ""; - document.getElementById( "levelc" + i).style.color = ""; - } + } + + document.getElementById( "info").innerHTML = info; + } + + function OnQuit( ans) { + Reset(); + } + + function Reset() { + for(i=1; i <= 15; i++) { + document.getElementById( "levela" + i).bgColor = ""; + document.getElementById( "levelb" + i).bgColor = ""; + document.getElementById( "levelc" + i).bgColor = ""; + document.getElementById( "levela" + i).style.color = ""; + document.getElementById( "levelb" + i).style.color = ""; + document.getElementById( "levelc" + i).style.color = ""; + } flag5050 = 0; flagTelephone = 0; @@ -283,10 +283,10 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { document.getElementById( "HelpPeople").src = "people.png"; document.getElementById( "HelpTelephone").src = "telephone.png"; - document.getElementById( "info").innerHTML = ""; - UpdateLevel( 1); - SelectNextQuestion(); - } + document.getElementById( "info").innerHTML = ""; + UpdateLevel( 1); + SelectNextQuestion(); + } function RandomizeAnswers( elements) { posCorrect = 1; @@ -305,30 +305,27 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { } } - function SelectNextQuestion() - { - current_question = Math.floor(Math.random()*questions.length); - question = Base64.decode( questions[ current_question]); - - var elements = new Array(); + function SelectNextQuestion() { + current_question = Math.floor(Math.random()*questions.length); + question = Base64.decode( questions[ current_question]); + + var elements = new Array(); elements = question.split('#'); RandomizeAnswers( elements); - document.getElementById( "question").innerHTML = elements[ 0]; - for( i=1; i < elements.length; i++) - { - document.getElementById( "lblAnswer" + i).innerHTML = elements[ i]; - document.getElementById( "lblAnswer" + i).style.visibility = 'visible'; - document.getElementById( "btAnswer" + i).style.visibility = 'visible'; - } - for( i=elements.length; i<= maxQuestions; i++) - { - document.getElementById( "lblAnswer" + i).style.visibility = 'hidden'; - document.getElementById( "btAnswer" + i).style.visibility = 'hidden'; - } - - document.getElementById( "info").innerHTML = ""; + document.getElementById( "question").innerHTML = elements[ 0]; + for( i=1; i < elements.length; i++) { + document.getElementById( "lblAnswer" + i).innerHTML = elements[ i]; + document.getElementById( "lblAnswer" + i).style.visibility = 'visible'; + document.getElementById( "btAnswer" + i).style.visibility = 'visible'; + } + for( i=elements.length; i<= maxQuestions; i++) { + document.getElementById( "lblAnswer" + i).style.visibility = 'hidden'; + document.getElementById( "btAnswer" + i).style.visibility = 'hidden'; + } + + document.getElementById( "info").innerHTML = ""; } /** @@ -340,79 +337,71 @@ function game_millionaire_html_print( $game, $questions, $maxquestions) { var Base64 = { - // private property - _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", - - // public method for decoding - decode : function (input) { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } - - output = Base64._utf8_decode(output); - - return output; - - }, - - // private method for UTF-8 decoding - _utf8_decode : function (utftext) { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - while ( i < utftext.length ) { - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = utftext.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = utftext.charCodeAt(i+1); - c3 = utftext.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - - return string; - } - -} - - + // Private property. + _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + + // Public method for decoding. + decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + } + + output = Base64._utf8_decode(output); + + return output; + }, + + // private method for UTF-8 decoding + _utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; + while ( i < utftext.length ) { + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); + i += 2; + } else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + } + + return string; + } +} + @@ -499,23 +488,23 @@ var Base64 = { \n"; - echo "\n"; - echo "\n"; - if ( $i == 1) { - echo "\n"; - } - echo "\n"; +$letters = get_string( 'lettersall', 'game'); +for ($i = 1; $i <= $maxquestions; $i++) { + $s = game_substr( $letters, $i - 1, 1); + echo "\n"; + echo "\n"; + echo "\n"; + if ( $i == 1) { + echo "\n"; } + echo "\n"; +} ?> diff --git a/exporthtml_snakes.php b/exporthtml_snakes.php index 3739e90..a0638f0 100644 --- a/exporthtml_snakes.php +++ b/exporthtml_snakes.php @@ -14,9 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** +/* * This page export the game snakes to html - * + * * @author bdaloukas * @package game **/ @@ -39,26 +39,27 @@ defined('MOODLE_INTERNAL') || die(); - -
"; - echo ""; - echo "  
"; + echo ""; + echo "