Browse Source

Fix: Problem when a question contains an apostrophe

MOODLE_20_STABLE
bdaloukas 12 years ago
parent
commit
974d20341e
  1. 3
      cross/play.php
  2. 15
      cryptex/play.php
  3. 3
      hangman/play.php
  4. 5
      locallib.php
  5. 2
      millionaire/play.php
  6. 25
      showanswers.php
  7. 4
      version.php

3
cross/play.php

@ -92,7 +92,10 @@ function showlegend( $legend, $title)
echo "<br><b>$title</b><br>";
foreach( $legend as $key => $line)
{
$line = game_repairquestion( $line);
echo game_filtertext( "$key: $line<br>", 0);
}
}
function game_cross_play( $id, $game, $attempt, $crossrec, $g, $onlyshow, $showsolution, $endofgame, $print, $checkbutton, $showhtmlsolutions, $showhtmlprintbutton,$showstudentguess, $context)

15
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 "<br><b>$title</b><br>";
foreach( $legend as $key => $line)
echo "$key: $line<br>";
}
//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))

3
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);

5
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<br>";
return ( $count == 1 ? array( $id) : $id);
}
}
@ -1321,8 +1321,7 @@ function game_repairquestion( $s){
}
$s = substr( $s, 0, -6);
}
$s = str_replace( "\'", "'", $s);
$s = str_replace( array("\'", '\"'), array("'", '"'), $s);
return $s;
}

2
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;

25
showanswers.php

@ -30,7 +30,7 @@
echo '<br><br>';
$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 . '</select>' . "\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;
@ -260,7 +260,8 @@ function game_showanswers_question_select( $game, $table, $select, $fields='*',
echo '<td>';
echo "<a title=\"Edit\" href=\"{$CFG->wwwroot}/question/question.php?inpopup=1&amp;id=$question->id&courseid=$courseid\" target=\"_blank\"><img src=\"".$OUTPUT->pix_url('t/edit')."\" alt=\"Edit\" /></a> ";
echo $question->questiontext.'</td>';
echo game_filterquestion(str_replace( array( "\'", '\"'), array( "'", '"'), $question->questiontext), $question->id, $context->id, $game->course);
switch( $question->qtype){
case 'shortanswer':

4
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';

Loading…
Cancel
Save