diff --git a/attempt.php b/attempt.php
index 6bcc556..f4b0675 100755
--- a/attempt.php
+++ b/attempt.php
@@ -55,7 +55,7 @@
/// Check login and get context.
require_login($course->id, false, $cm);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = game_get_context_module_instance( $cm->id);
require_capability('mod/game:view', $context);
/// Cache some other capabilites we use several times.
diff --git a/bookquiz/play.php b/bookquiz/play.php
index 5eebbb7..ca1aba6 100755
--- a/bookquiz/play.php
+++ b/bookquiz/play.php
@@ -86,6 +86,7 @@ $previd = null;
$nextid = null;
$found = 0;
$scoreattempt = 0;
+$lastid = 0;
foreach ($chapters as $ch) {
$scoreattempt++;
if ($found) {
@@ -98,6 +99,7 @@ foreach ($chapters as $ch) {
if (!$found) {
$previd = $ch->id;
}
+ $lastid = $ch->id;
}
if ($ch == current($chapters)) {
$nextid = $ch->id;
@@ -132,7 +134,9 @@ if ($nextid) {
game_updateattempts_maxgrade( $game, $attempt, 1, 0);
$sec = '';
if( !isset( $cm))
- $cm = get_coursemodule_from_id('game', $game->id);
+ {
+ $cm = get_coursemodule_from_instance('game', $game->id, $game->course);
+ }
if ($section = $DB->get_record('course_sections', array( 'id' => $cm->section))) {
$sec = $section->section;
}
@@ -140,7 +144,7 @@ if ($nextid) {
if (! $cm = $DB->get_record('course_modules', array( 'id' => $id))) {
print_error("Course Module ID was incorrect id=$id");
}
- $chnavigation .= '';
+ $chnavigation .= 'pix_url('bookquiz/nav_exit', 'mod_game').'" class="bigicon" alt="'.get_string('navexit', 'book').'" />';
}
require( 'toc.php');
@@ -188,7 +192,9 @@ $tocwidth = '10%';
$content .= '
'.$currtitle.'
'.$currsubtitle.'
';
}
}
- $content .= $chapter->content;
+ $cmbook = get_coursemodule_from_instance( 'book', $game->bookid, $game->course);
+ $modcontext = game_get_context_module_instance( $cmbook->id);
+ $content .= game_filterbook( $chapter->content, $chapter->id, $modcontext->id, $game->course);
$nocleanoption = new object();
$nocleanoption->noclean = true;
@@ -196,7 +202,7 @@ $tocwidth = '10%';
if( $nextbutton != ''){
echo $nextbutton;
}
- echo format_text($content, FORMAT_HTML, $nocleanoption, $id);
+ echo format_text($content, FORMAT_HTML, $nocleanoption);
if( $nextbutton != ''){
echo $nextbutton;
}
@@ -221,7 +227,13 @@ function game_bookquiz_play_computelastchapter( $game, &$bookquiz)
{
global $DB;
+ if( $game->bookid == 0)
+ {
+ print_error( 'Not defined a book on this game');
+ }
+
$pagenum = $DB->get_field( 'book_chapters', 'min(pagenum) as p', array('bookid' => $game->bookid));
+
if( $pagenum){
$bookquiz->lastchapterid = $DB->get_field( 'book_chapters', 'id', array('bookid' => $game->bookid, 'pagenum' => $pagenum));
diff --git a/bookquiz/questions.php b/bookquiz/questions.php
index 5e9ae70..dc65371 100755
--- a/bookquiz/questions.php
+++ b/bookquiz/questions.php
@@ -8,7 +8,7 @@
**/
require_once("../../../config.php");
- require_once( "../header.php");
+ require_once( "../headergame.php");
require_once("../locallib.php");
$attempt = game_getattempt( $game, $detail);
@@ -21,7 +21,7 @@
$ids = explode( ',', $form->ids);
game_bookquiz_save( $game->id, $game->bookid, $ids, $form);
- redirect("{$CFG->wwwroot}/mod/game/bookquiz/questions.php?id=$cm->id", '', 0);
+ //redirect("{$CFG->wwwroot}/mod/game/bookquiz/questions.php?id=$cm->id", '', 0);
}
/// Print upload form
@@ -36,7 +36,7 @@
}
}
- $context = get_context_instance(50, $COURSE->id);
+ $context = game_get_context_course_instance( $COURSE->id);
$select = " contextid in ($context->id)";
$a = array();
@@ -160,7 +160,7 @@ function game_bookquiz_save( $gameid, $bookid, $ids, $form)
}
}else
{
- unset( $updrec);
+ $updrec = new StdClass;
$updrec->id = $recids[ $chapterid];
$updrec->questioncategoryid = $categoryid;
if (($DB->update_record( 'game_bookquiz_questions', $updrec)) == false) {
diff --git a/cross/cross_class.php b/cross/cross_class.php
index 16f4c97..352d330 100755
--- a/cross/cross_class.php
+++ b/cross/cross_class.php
@@ -630,7 +630,7 @@ class Cross
if( $game->glossaryid)
{
$cmglossary = get_coursemodule_from_instance('glossary', $game->glossaryid, $game->course);
- $contextglossary = get_context_instance(CONTEXT_MODULE, $cmglossary->id);
+ $contextglossary = game_get_context_module_instance( $cmglossary->id);
}
foreach ($crossd as $rec)
{
diff --git a/cross/play.php b/cross/play.php
index 3ad4823..680dede 100755
--- a/cross/play.php
+++ b/cross/play.php
@@ -1042,7 +1042,7 @@ if( $attempt != false){