@ -1,4 +1,19 @@
<?php // $Id: exporthtml_snakes.php,v 1.4 2011/07/23 12:34:08 bdaloukas Exp $
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see < http: / / www . gnu . org / licenses / > .
/**
/**
* This page export the game snakes to html
* This page export the game snakes to html
*
*
@ -46,7 +61,7 @@ background: #999 url('images/backdropJungle.png') no-repeat fixed left top;
< body >
< body >
< script language = "JavaScript" >
< script language = "JavaScript" >
//Snakes for Moodle by Maria Rigkou
// Snakes for Moodle by Maria Rigkou.
var boards = 1;
var boards = 1;
var board_images = new Array( boards);
var board_images = new Array( boards);
@ -93,27 +108,29 @@ pawn_height [0]= 40;
<?php
<?php
echo "var countofquestionsM=$countofquestionsM ;\r\n";
echo "var countofquestionsM=$countofquestionsm ;\r\n";
echo 'var countofquestionsS='.count($questionsS ).";\r\n";
echo 'var countofquestionsS='.count($questionss ).";\r\n";
foreach( $questionsS as $line)
foreach ($questionss as $line) {
{
$s = $line->question.'#'.str_replace( array( '"', '#'), array( "'", ' '), $line->answer);
$s = $line->question.'#'.str_replace( array( '"', '#'), array( "'", ' '), $line->answer);
if( $questionsM != '')
if ($questionsm != '') {
$questionsM .= ",\r";
$questionsm .= ",\r";
$questionsM .= '"'.base64_encode( game_upper( $s)).'"';
}
$questionsm .= '"'.base64_encode( game_upper( $s)).'"';
$s = '#'.str_replace( array( '"', '#'), array( "'", ' '), $line->feedback);
$s = '#'.str_replace( array( '"', '#'), array( "'", ' '), $line->feedback);
if( $retfeedback != '')
if ( $retfeedback != '') {
$retfeedback .= ",\r";
$retfeedback .= ",\r";
}
$retfeedback .= '"'.base64_encode( $s).'"';
$retfeedback .= '"'.base64_encode( $s).'"';
}
}
$rettimesasked = '';
$rettimesasked = '';
for($i=0;$i< $countofquestionsM+count($questionsS);$i++)
for ($i = 0; $i < $countofquestionsm + count($questionss); $i++) {
$rettimesasked .= ',0';
$rettimesasked .= ',0';
}
$rettimesasked = substr( $rettimesasked, 1);
$rettimesasked = substr( $rettimesasked, 1);
echo "var questions=new Array( $questionsM );\r\n";
echo "var questions=new Array( $questionsm );\r\n";
echo "var feedbacks=new Array( $retfeedback);\r\n";
echo "var feedbacks=new Array( $retfeedback);\r\n";
echo "var quest_times_asked=new Array( $rettimesasked); //How many times is used a question\r\n";
echo "var quest_times_asked=new Array( $rettimesasked); //How many times is used a question\r\n";
@ -365,7 +382,11 @@ function display_quest()
function display_quest_M()
function display_quest_M()
{
{
s = '< table width = "250px" > < tr > < td > < div id = "show_dice" > < img src = "images/dice' + current_dice + '.png" > < / div > < / td > < td align = right > < div id = "show_score" style = "color: #FFFFFF; font-weight:bold; font-size: 20px;" > < strong > '+str_score+': < / strong > < strong class = "score" > ' +score+ '< / strong > < / div > < / td > < / tr > < / table > ';
s = '< table width = "250px" > < tr > < td > < div id = "show_dice" > ';
s = s + '< img src = "images/dice' + current_dice + '.png" > < / div > < / td > ';
s = s + '< td align = right > < div id = "show_score" style = "color: #FFFFFF; font-weight:bold; font-size: 20px;" > ';
s = s + '< strong > '+str_score+': < / strong > ';
s = s + '< strong class = "score" > ' +score+ '< / strong > < / div > < / td > < / tr > < / table > ';
s = s + '< div id = "question_area" > ' + quest_text+'< / div > ';
s = s + '< div id = "question_area" > ' + quest_text+'< / div > ';
s = s + '< form name = "snakesform" > ';
s = s + '< form name = "snakesform" > ';
@ -381,10 +402,17 @@ function display_quest_M()
mchoice_positions[ j] = temp;
mchoice_positions[ j] = temp;
}
}
for(i=0; i < mchoice_count ; i + + )
for(i=0; i < mchoice_count ; i + + ) {
s = s + '< input type = "radio" name = "radio_answer" id = "radio_answer" value = "'+i+'" / > '+quest_resp[ mchoice_positions[ i]] + '< br / > ';
s = s + '< input type = "radio" name = "radio_answer" id = "radio_answer" value = "';
s = s + i+'" />'+quest_resp[ mchoice_positions[ i]] + '< br / > ';
}
s = s + '< br / > < input type = "button" id = "check_btn" value = "'+str_check+'" onclick = "check_answer();" > < br / > < div id = "feedb_area" > < div id = "feedb_wrong" style = "display:none; color:yellow;" > '+quest_feedb+' < / div > < br / > < div id = "feedb" style = "display:none; color:yellow;" > '+quest_feedb+'. Θα προχωρήσεις '+current_dice+' τετράγωνα μπροστά!< / div > < br / > < div id = "OK_btn" style = "display:none;" > < input type = "button" onclick = "display_quest();" value = "OK" / > < / div > < / div > < / form > ';
s = s + '< br / > < input type = "button" id = "check_btn" value = "'+str_check;
s = s + '" onclick="check_answer();"> < br / > < div id = "feedb_area" > < div id = "feedb_wrong" style = "display:none; color:yellow;" > ';
s = s + quest_feedb+' < / div > < br / > < div id = "feedb" style = "display:none; color:yellow;" > ';
s = s + quest_feedb+'. Θα προχωρήσεις ';
s = s + current_dice+' τετράγωνα μπροστά!< / div > < br / > < div id = "OK_btn" ' ;
s = s + 'style="display:none;">< input type = "button" onclick = "display_quest();" value = "OK" / > < / div > < / div > < / form > ';
document.getElementById("dicecont").innerHTML = s;
document.getElementById("dicecont").innerHTML = s;
@ -394,8 +422,19 @@ function display_quest_M()
function display_quest_S()
function display_quest_S()
{
{
document.getElementById("dicecont").innerHTML = '< table width = "250px" > < tr > < td > < div id = "show_dice" > < img src = "images/dice' + current_dice + '.png" > < / div > < / td > < td align = right > < div id = "show_score" style = "color: #FFFFFF; font-weight:bold; font-size: 20px;" > < strong > '+str_score+': < / strong > < strong class = "score" > ' +score+ '< / strong > < / div > < / td > < / tr > < / table > < div id = "question_area" > ' +quest_text+'< / div > < br / > < input type = "text" id = "answer" / > < br / > < br / > < input type = "button" id = "check_btn" value = "'+str_check+'" onclick = "check_answer();" > < br / > < div id = "feedb_area" > < div id = "feedb_wrong" style = "display:none; color:yellow;" > '+feedb_wrong_S+' < / div > < div id = "feedb" style = "display:none; color:yellow;" > '+feedb_correct_S+'< / div > < br / > < div id = "OK_btn" style = "display:none;" > < input type = "button" onclick = "display_quest();" value = "OK" / > < / div > < / div > ';
var s = "";
s = '< table width = "250px" > < tr > < td > < div id = "show_dice" > < img src = "images/dice';
s = s + current_dice + '.png"> < / div > < / td > < td align = right > ';
s = s + '< div id = "show_score" style = "color: #FFFFFF; font-weight:bold; font-size: 20px;" > < strong > ';
s = s + str_score+': < / strong > < strong class = "score" > ' +score+ '< / strong > < / div > < / td > < / tr > < / table > < div id = "question_area" > ';
s = s + quest_text+'< / div > < br / > < input type = "text" id = "answer" / > < br / > < br / > < input type = "button" id = "check_btn" value = "';
s = s + str_check+'" onclick="check_answer();"> < br / > < div id = "feedb_area" > ';
s = s + ' < div id = "feedb_wrong" style = "display:none; color:yellow;" > ';
s = s + feedb_wrong_S+' < / div > < div id = "feedb" style = "display:none; color:yellow;" > ';
s = s + feedb_correct_S+'< / div > < br / > < div id = "OK_btn" style = "display:none;" > ';
s = s + '< input type = "button" onclick = "display_quest();" value = "OK" / > < / div > < / div > ';
document.getElementById("dicecont").innerHTML = s;
document.getElementById("question_area").style.display = "block";
document.getElementById("question_area").style.display = "block";
document.getElementById("check_btn").style.display = "block";
document.getElementById("check_btn").style.display = "block";
}
}