diff --git a/cross/play.php b/cross/play.php index 3210e0b..6ba0b65 100755 --- a/cross/play.php +++ b/cross/play.php @@ -92,7 +92,10 @@ function showlegend( $legend, $title) echo "
$title
"; foreach( $legend as $key => $line) + { + $line = game_repairquestion( $line); echo game_filtertext( "$key: $line
", 0); + } } function game_cross_play( $id, $game, $attempt, $crossrec, $g, $onlyshow, $showsolution, $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton,$showstudentguess, $context) diff --git a/cryptex/play.php b/cryptex/play.php index 842f715..7737590 100755 --- a/cryptex/play.php +++ b/cryptex/play.php @@ -84,17 +84,6 @@ function game_cryptex_continue( $id, $game, $attempt, $cryptexrec, $endofgame, $ return game_cryptex_play( $id, $game, $attempt, $cryptexrec, $crossm, false, false, false, $context); } -function cryptex_showlegend( $legend, $title) -{ - if( count( $legend) == 0) - return; - - echo "
$title
"; - foreach( $legend as $key => $line) - echo "$key: $line
"; -} - - //q means game_queries.id function game_cryptex_check( $id, $game, $attempt, $cryptexrec, $q, $answer, $context) { @@ -268,7 +257,7 @@ width: 240pt; $i = 0; $else = ''; $contextglossary = false; - foreach( $questions as $key => $q){//print_r( $q); + foreach( $questions as $key => $q){ $i++; if( $showsolution == false){ //When I want to show the solution a want to show the questions to. @@ -278,7 +267,7 @@ width: 240pt; } $question = "$i. ".$q->questiontext; - $question = game_filterquestion(str_replace( '\"', '"', $question), $q->questionid, $context->id, $game->course); + $question = game_filterquestion(str_replace( array( "\'", '\"'), array( "'", '"'), $question), $q->questionid, $context->id, $game->course); $question2 = strip_tags($question); //ADDED BY DP (AUG 2009) - fixes " breaking the Answer button for this question if( ($onlyshow == false) and ($showsolution == false)){ if( ($game->param8 == 0) || ($game->param8 > $q->tries)) diff --git a/hangman/play.php b/hangman/play.php index 4b470a8..64895bb 100755 --- a/hangman/play.php +++ b/hangman/play.php @@ -297,7 +297,8 @@ function hangman_showpage(&$done, &$correct, &$wrong, $max, &$word_line, &$word_ if( $query->questionid) { - $query->questiontext = game_filterquestion(str_replace( '\"', '"', $query->questiontext), $query->questionid, $context->id, $game->course); + $questiontext = str_replace( array("\'", '\"'), array("'", '"'), $query->questiontext); + $query->questiontext = game_filterquestion($questiontext, $query->questionid, $context->id, $game->course); }else { $cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course); diff --git a/locallib.php b/locallib.php index d786001..20bb65a 100755 --- a/locallib.php +++ b/locallib.php @@ -416,7 +416,7 @@ function game_questions_selectrandom_detail( $table, $select, $id_field="id", $c return $a; }else { - $id = array_rand( $a, $count); + $id = array_rand( $a, $count);print_r( $a); echo "count=$count
"; return ( $count == 1 ? array( $id) : $id); } } @@ -1321,9 +1321,8 @@ function game_repairquestion( $s){ } $s = substr( $s, 0, -6); } - - $s = str_replace( "\'", "'", $s); - + $s = str_replace( array("\'", '\"'), array("'", '"'), $s); + return $s; } diff --git a/millionaire/play.php b/millionaire/play.php index dfc81be..81c8d2a 100755 --- a/millionaire/play.php +++ b/millionaire/play.php @@ -86,7 +86,7 @@ function game_millionaire_showgrid( $game, $millionaire, $id, $query, $aAnswer, { global $OUTPUT; - $question = str_replace( '\"', '"', $query->questiontext); + $question = str_replace( array("\'", '\"'), array("'", '"'), $query->questiontext); if( $game->param8 == '') $color = 408080; diff --git a/showanswers.php b/showanswers.php index 72fc673..d6ae1a1 100755 --- a/showanswers.php +++ b/showanswers.php @@ -30,7 +30,7 @@ echo '

'; $existsbook = ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')); - game_showanswers( $game, $existsbook); + game_showanswers( $game, $existsbook, $context); echo $OUTPUT->footer(); @@ -106,7 +106,7 @@ function game_showusers($game) echo $output . '' . "\n"; } -function game_showanswers( $game, $existsbook) +function game_showanswers( $game, $existsbook, $context) { if( $game->gamekind == 'bookquiz' and $existsbook){ game_showanswers_bookquiz( $game); @@ -115,13 +115,13 @@ function game_showanswers( $game, $existsbook) switch( $game->sourcemodule){ case 'question': - game_showanswers_question( $game); + game_showanswers_question( $game, $context); break; case 'glossary': game_showanswers_glossary( $game); break; case 'quiz': - game_showanswers_quiz( $game); + game_showanswers_quiz( $game, $context); break; } } @@ -144,7 +144,7 @@ function game_showanswers_appendselect( $game) return ''; } -function game_showanswers_question( $game) +function game_showanswers_question( $game, $context) { global $DB; @@ -159,8 +159,8 @@ function game_showanswers_question( $game) } }else { - $context = get_context_instance(50, $COURSE->id); - $select = " contextid in ($context->id)"; + $context2 = get_context_instance(50, $COURSE->id); + $select = " contextid in ($context2->id)"; $select2 = ''; if( $recs = $DB->get_records_select( 'question_categories', $select, null, 'id,id')){ foreach( $recs as $rec){ @@ -175,11 +175,11 @@ function game_showanswers_question( $game) $showcategories = ($game->gamekind == 'bookquiz'); $order = ($showcategories ? 'category,questiontext' : 'questiontext'); - game_showanswers_question_select( $game, '{question} q', $select, '*', $order, $showcategories, $game->course); + game_showanswers_question_select( $game, '{question} q', $select, '*', $order, $showcategories, $game->course, $context); } -function game_showanswers_quiz( $game) +function game_showanswers_quiz( $game, $context) { global $CFG; @@ -189,11 +189,11 @@ function game_showanswers_quiz( $game) game_showanswers_appendselect( $game); $table = '{question} q,{quiz_question_instances} qqi'; - game_showanswers_question_select( $game, $table, $select, 'q.*', 'category,questiontext', false, $game->course); + game_showanswers_question_select( $game, $table, $select, 'q.*', 'category,questiontext', false, $game->course, $context); } -function game_showanswers_question_select( $game, $table, $select, $fields='*', $order='questiontext', $showcategoryname=false, $courseid=0) +function game_showanswers_question_select( $game, $table, $select, $fields, $order, $showcategoryname, $courseid, $context) { global $CFG, $DB, $OUTPUT; @@ -219,7 +219,7 @@ function game_showanswers_question_select( $game, $table, $select, $fields='*', $select = "course=$courseid"; }else{ $context = get_context_instance(50, $courseid); - $select = " contextid in ($context->id)"; + $select = " contextid in ($context->id)"; } break; } @@ -260,7 +260,8 @@ function game_showanswers_question_select( $game, $table, $select, $fields='*', echo ''; echo "wwwroot}/question/question.php?inpopup=1&id=$question->id&courseid=$courseid\" target=\"_blank\">pix_url('t/edit')."\" alt=\"Edit\" /> "; - echo $question->questiontext.''; + + echo game_filterquestion(str_replace( array( "\'", '\"'), array( "'", '"'), $question->questiontext), $question->id, $context->id, $game->course); switch( $question->qtype){ case 'shortanswer': diff --git a/version.php b/version.php index cf46154..4761a67 100755 --- a/version.php +++ b/version.php @@ -11,7 +11,7 @@ defined('MOODLE_INTERNAL') || die(); $module->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$module->version = 2013072901; // The current module version (Date: YYYYMMDDXX) +$module->version = 2013072902; // The current module version (Date: YYYYMMDDXX) $module->requires = 2010112400; // Requires Moodle 2.0 $module->cron = 0; // Period for cron to check this module (secs) -$module->release = '3.7.29'; +$module->release = '3.7.29.2';