|
@ -30,7 +30,7 @@ |
|
|
echo '<br><br>'; |
|
|
echo '<br><br>'; |
|
|
|
|
|
|
|
|
$existsbook = ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')); |
|
|
$existsbook = ($DB->get_record( 'modules', array( 'name' => 'book'), 'id,id')); |
|
|
game_showanswers( $game, $existsbook); |
|
|
game_showanswers( $game, $existsbook, $context); |
|
|
|
|
|
|
|
|
echo $OUTPUT->footer(); |
|
|
echo $OUTPUT->footer(); |
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ function game_showusers($game) |
|
|
echo $output . '</select>' . "\n"; |
|
|
echo $output . '</select>' . "\n"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function game_showanswers( $game, $existsbook) |
|
|
function game_showanswers( $game, $existsbook, $context) |
|
|
{ |
|
|
{ |
|
|
if( $game->gamekind == 'bookquiz' and $existsbook){ |
|
|
if( $game->gamekind == 'bookquiz' and $existsbook){ |
|
|
game_showanswers_bookquiz( $game); |
|
|
game_showanswers_bookquiz( $game); |
|
@ -115,13 +115,13 @@ function game_showanswers( $game, $existsbook) |
|
|
|
|
|
|
|
|
switch( $game->sourcemodule){ |
|
|
switch( $game->sourcemodule){ |
|
|
case 'question': |
|
|
case 'question': |
|
|
game_showanswers_question( $game); |
|
|
game_showanswers_question( $game, $context); |
|
|
break; |
|
|
break; |
|
|
case 'glossary': |
|
|
case 'glossary': |
|
|
game_showanswers_glossary( $game); |
|
|
game_showanswers_glossary( $game); |
|
|
break; |
|
|
break; |
|
|
case 'quiz': |
|
|
case 'quiz': |
|
|
game_showanswers_quiz( $game); |
|
|
game_showanswers_quiz( $game, $context); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -144,7 +144,7 @@ function game_showanswers_appendselect( $game) |
|
|
return ''; |
|
|
return ''; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function game_showanswers_question( $game) |
|
|
function game_showanswers_question( $game, $context) |
|
|
{ |
|
|
{ |
|
|
global $DB; |
|
|
global $DB; |
|
|
|
|
|
|
|
@ -159,8 +159,8 @@ function game_showanswers_question( $game) |
|
|
} |
|
|
} |
|
|
}else |
|
|
}else |
|
|
{ |
|
|
{ |
|
|
$context = get_context_instance(50, $COURSE->id); |
|
|
$context2 = get_context_instance(50, $COURSE->id); |
|
|
$select = " contextid in ($context->id)"; |
|
|
$select = " contextid in ($context2->id)"; |
|
|
$select2 = ''; |
|
|
$select2 = ''; |
|
|
if( $recs = $DB->get_records_select( 'question_categories', $select, null, 'id,id')){ |
|
|
if( $recs = $DB->get_records_select( 'question_categories', $select, null, 'id,id')){ |
|
|
foreach( $recs as $rec){ |
|
|
foreach( $recs as $rec){ |
|
@ -175,11 +175,11 @@ function game_showanswers_question( $game) |
|
|
|
|
|
|
|
|
$showcategories = ($game->gamekind == 'bookquiz'); |
|
|
$showcategories = ($game->gamekind == 'bookquiz'); |
|
|
$order = ($showcategories ? 'category,questiontext' : 'questiontext'); |
|
|
$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; |
|
|
global $CFG; |
|
|
|
|
|
|
|
@ -189,11 +189,11 @@ function game_showanswers_quiz( $game) |
|
|
game_showanswers_appendselect( $game); |
|
|
game_showanswers_appendselect( $game); |
|
|
$table = '{question} q,{quiz_question_instances} qqi'; |
|
|
$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; |
|
|
global $CFG, $DB, $OUTPUT; |
|
|
|
|
|
|
|
@ -260,7 +260,8 @@ function game_showanswers_question_select( $game, $table, $select, $fields='*', |
|
|
|
|
|
|
|
|
echo '<td>'; |
|
|
echo '<td>'; |
|
|
echo "<a title=\"Edit\" href=\"{$CFG->wwwroot}/question/question.php?inpopup=1&id=$question->id&courseid=$courseid\" target=\"_blank\"><img src=\"".$OUTPUT->pix_url('t/edit')."\" alt=\"Edit\" /></a> "; |
|
|
echo "<a title=\"Edit\" href=\"{$CFG->wwwroot}/question/question.php?inpopup=1&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){ |
|
|
switch( $question->qtype){ |
|
|
case 'shortanswer': |
|
|
case 'shortanswer': |
|
|