From 8e66c259a31c443d1a328f3e5acd6a200c75e35d Mon Sep 17 00:00:00 2001 From: Vasilis Daloukas Date: Tue, 14 Jul 2015 12:58:36 +0300 Subject: [PATCH] New: Multianswer questions on Book with questions Game --- bookquiz/play.php | 2 +- locallib.php | 20 +++++++++++++------- version.php | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bookquiz/play.php b/bookquiz/play.php index ca1aba6..b5e138b 100755 --- a/bookquiz/play.php +++ b/bookquiz/play.php @@ -343,7 +343,7 @@ function game_bookquiz_check_questions( $id, $game, $attempt, $bookquiz, $contex continue; } $grade = $grades[ $question->id]; - if( $grade->grade < 0.5){ + if( $grade->grade < 0.99){ continue; } diff --git a/locallib.php b/locallib.php index cb937e5..a229a33 100755 --- a/locallib.php +++ b/locallib.php @@ -2013,17 +2013,23 @@ function game_grade_questions( $questions) $id = game_question_get_id_from_name_prefix( $key); if( $id === false) continue; - - $grade = new stdClass(); - $grade->id = $id; - $grade->response = $value; - $grade->grade = 0; + + if( array_key_exists( $id, $grades)) + $grade = $grades[ $id]; + else + { + $grade = new stdClass(); + $grade->grade = 0; + $grade->id = $id; + } + + $grade->response = $value; $question = $questions[ $id]; if( $question->qtype == 'multichoice') { $answer = $question->options->answers[ $value]; - $grade->grade = $answer->fraction; + $grade->grade += $answer->fraction; }else if( $question->qtype == 'shortanswer') { foreach( $question->options->answers as $answerid => $answer) @@ -2034,7 +2040,7 @@ function game_grade_questions( $questions) } } } - + $grades[ $grade->id] = $grade; } diff --git a/version.php b/version.php index 3c19086..6b70b08 100755 --- a/version.php +++ b/version.php @@ -22,10 +22,10 @@ if( !isset( $plugin)) $useplugin = 2; $plugin->component = 'mod_game'; // Full name of the plugin (used for diagnostics) -$plugin->version = 2015071403; // The current module version (Date: YYYYMMDDXX) +$plugin->version = 2015071404; // The current module version (Date: YYYYMMDDXX) $plugin->requires = 2010112400; // Requires Moodle 2.0 $plugin->cron = 0; // Period for cron to check this module (secs) -$plugin->release = '3.30.14.3'; +$plugin->release = '3.30.14.4'; if( $useplugin != 2) $module = $plugin;