]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14204 "Content for Quiz Statistics report table - Random_guess_score" oops ought...
authorjamiesensei <jamiesensei>
Mon, 16 Jun 2008 13:59:30 +0000 (13:59 +0000)
committerjamiesensei <jamiesensei>
Mon, 16 Jun 2008 13:59:30 +0000 (13:59 +0000)
lib/questionlib.php
mod/quiz/report/statistics/statistics_table.php
question/type/match/questiontype.php
question/type/multianswer/questiontype.php
question/type/multichoice/questiontype.php
question/type/questiontype.php
question/type/random/questiontype.php
question/type/randomsamatch/questiontype.php
question/type/shortanswer/questiontype.php
question/type/truefalse/questiontype.php

index d47bace320313bf2fb6d1749d9ec805c2cb4527b..e813eea954bb82dd11f2a023975438b602f63d64 100644 (file)
@@ -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);
index 6d308a1b31df2cc051f208e8be1cc675a738ebc3..463b2b52b68e5f7155087d728dfd48adff998ccc 100644 (file)
@@ -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.
+        }
     }
-            
-
 }
 ?>
index f0c56b55cfdb857175765a4457c30c7a97320fb5..3eb40cd70fdf0595e5752fff594ff0eb2bd3b5c2 100644 (file)
@@ -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);
index 7e01145c9436aa519e3fade1e3a4767d7d0f3ea6..d02ba8a7fac33eace31e15eee6ad41db56d610da 100644 (file)
@@ -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);
     }
index d81ff88d28480d99b1d7e252fed0b6a302db7425..4d8f51719811d3307ce84ca53a7623d1d5e42cbf 100644 (file)
@@ -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;
index 9c8d20209bc7736daee7c1a21905cd5cf799fd4b..ed5d91b7b18b2f9f40721a84d52a254aacba36a3 100644 (file)
@@ -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;
index e0dbb459e8e0b06f6b2dd890f9f6caee11be49ff..89720c8f85db0ccdbed738506fa85ec9ae3b6cae 100644 (file)
@@ -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 ////
index cf034ece1f633f09b8311ca41181fa247c52ce39..8fb52dc38709f9d64985f631c2dda92817938da3 100644 (file)
@@ -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
index 99b10546565d2cac735fd079d4b5e9bcbb9b68d7..78828205fef6e37c4c686c37093a02bce60985bf 100644 (file)
@@ -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;
index 8017f5fa4d886bb2068bb64f7c97511bbc1d16bd..305dc1ad5e98fdcbe85c516fbb7dfc83b0e453ab 100644 (file)
@@ -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;