From 455c3efa137366539bec9a98eee0c98e356474f8 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Mon, 16 Jun 2008 13:59:30 +0000 Subject: [PATCH] MDL-14204 "Content for Quiz Statistics report table - Random_guess_score" oops ought to give that function name a 'question_' prefix --- lib/questionlib.php | 2 +- mod/quiz/report/statistics/statistics_table.php | 11 +++++++---- question/type/match/questiontype.php | 5 +++-- question/type/multianswer/questiontype.php | 7 ++++--- question/type/multichoice/questiontype.php | 5 +++-- question/type/questiontype.php | 5 +++-- question/type/random/questiontype.php | 11 +++++++++++ question/type/randomsamatch/questiontype.php | 5 +++-- question/type/shortanswer/questiontype.php | 5 +++-- question/type/truefalse/questiontype.php | 5 +++-- 10 files changed, 41 insertions(+), 20 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index d47bace320..e813eea954 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1798,7 +1798,7 @@ function get_question_fraction_grade($question, $state) { * @return integer grade out of 1 that a random guess by a student might score. */ // ULPGc ecastro -function get_random_guess_score($question) { +function question_get_random_guess_score($question) { global $QTYPES; $r = $QTYPES[$question->qtype]->get_random_guess_score($question); diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index 6d308a1b31..463b2b52b6 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -93,11 +93,14 @@ class quiz_report_statistics_table extends flexible_table { function col_intended_weight($question){ return quiz_report_scale_sumgrades_as_percentage($question->grade, $this->quiz); } - + function col_random_guess_score($question){ - return number_format(get_random_guess_score($question) * 100, 2).' %'; + $randomguessscore = question_get_random_guess_score($question); + if (is_number($randomguessscore)){ + return number_format($randomguessscore * 100, 2).' %'; + } else { + return $randomguessscore; // empty string returned by random question. + } } - - } ?> diff --git a/question/type/match/questiontype.php b/question/type/match/questiontype.php index f0c56b55cf..3eb40cd70f 100644 --- a/question/type/match/questiontype.php +++ b/question/type/match/questiontype.php @@ -429,8 +429,9 @@ class question_match_qtype extends default_questiontype { /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { return 1 / count($question->options->subquestions); diff --git a/question/type/multianswer/questiontype.php b/question/type/multianswer/questiontype.php index 7e01145c94..d02ba8a7fa 100644 --- a/question/type/multianswer/questiontype.php +++ b/question/type/multianswer/questiontype.php @@ -517,13 +517,14 @@ class embedded_cloze_qtype extends default_questiontype { /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { $totalfraction = 0; foreach (array_keys($question->options->questions) as $key){ - $totalfraction += get_random_guess_score($question->options->questions[$key]); + $totalfraction += question_get_random_guess_score($question->options->questions[$key]); } return $totalfraction / count($question->options->questions); } diff --git a/question/type/multichoice/questiontype.php b/question/type/multichoice/questiontype.php index d81ff88d28..4d8f517198 100644 --- a/question/type/multichoice/questiontype.php +++ b/question/type/multichoice/questiontype.php @@ -398,8 +398,9 @@ class question_multichoice_qtype extends default_questiontype { } /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { $totalfraction = 0; diff --git a/question/type/questiontype.php b/question/type/questiontype.php index 9c8d20209b..ed5d91b7b1 100644 --- a/question/type/questiontype.php +++ b/question/type/questiontype.php @@ -677,8 +677,9 @@ class default_questiontype { /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { return 0; diff --git a/question/type/random/questiontype.php b/question/type/random/questiontype.php index e0dbb459e8..89720c8f85 100644 --- a/question/type/random/questiontype.php +++ b/question/type/random/questiontype.php @@ -327,6 +327,17 @@ class random_qtype extends default_questiontype { return $answer_field; } + + /** + * For random question type return empty string which means won't calculate. + * @param object $question + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. + */ + function get_random_guess_score($question) { + return ''; + } } //// END OF CLASS //// diff --git a/question/type/randomsamatch/questiontype.php b/question/type/randomsamatch/questiontype.php index cf034ece1f..8fb52dc387 100644 --- a/question/type/randomsamatch/questiontype.php +++ b/question/type/randomsamatch/questiontype.php @@ -274,8 +274,9 @@ class question_randomsamatch_qtype extends question_match_qtype { } /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { //Effectively $subquestions multi choice questions with equal weighting diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php index 99b1054656..78828205fe 100644 --- a/question/type/shortanswer/questiontype.php +++ b/question/type/shortanswer/questiontype.php @@ -241,8 +241,9 @@ class question_shortanswer_qtype extends default_questiontype { } /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { $answers = &$question->options->answers; diff --git a/question/type/truefalse/questiontype.php b/question/type/truefalse/questiontype.php index 8017f5fa4d..305dc1ad5e 100644 --- a/question/type/truefalse/questiontype.php +++ b/question/type/truefalse/questiontype.php @@ -247,8 +247,9 @@ class question_truefalse_qtype extends default_questiontype { } /** * @param object $question - * @return integer a score out of 1 that the average random guess by a - * student might give. + * @return mixed either a integer score out of 1 that the average random + * guess by a student might give or an empty string which means will not + * calculate. */ function get_random_guess_score($question) { return 0.5; -- 2.39.5