Пример #1
0
 /**
  * @param $course
  * @param $cm
  * @param $quiz
  * @return array to display in table or spreadsheet.
  */
 public function get_formatted_quiz_info_data($course, $cm, $quiz)
 {
     // You can edit this array to control which statistics are displayed.
     $todisplay = array('firstattemptscount' => 'number', 'allattemptscount' => 'number', 'firstattemptsavg' => 'summarks_as_percentage', 'allattemptsavg' => 'summarks_as_percentage', 'lastattemptsavg' => 'summarks_as_percentage', 'highestattemptsavg' => 'summarks_as_percentage', 'median' => 'summarks_as_percentage', 'standarddeviation' => 'summarks_as_percentage', 'skewness' => 'number_format', 'kurtosis' => 'number_format', 'cic' => 'number_format_percent', 'errorratio' => 'number_format_percent', 'standarderror' => 'summarks_as_percentage');
     // General information about the quiz.
     $quizinfo = array();
     $quizinfo[get_string('quizname', 'quiz_statistics')] = format_string($quiz->name);
     $quizinfo[get_string('coursename', 'quiz_statistics')] = format_string($course->fullname);
     if ($cm->idnumber) {
         $quizinfo[get_string('idnumbermod')] = $cm->idnumber;
     }
     if ($quiz->timeopen) {
         $quizinfo[get_string('quizopen', 'quiz')] = userdate($quiz->timeopen);
     }
     if ($quiz->timeclose) {
         $quizinfo[get_string('quizclose', 'quiz')] = userdate($quiz->timeclose);
     }
     if ($quiz->timeopen && $quiz->timeclose) {
         $quizinfo[get_string('duration', 'quiz_statistics')] = format_time($quiz->timeclose - $quiz->timeopen);
     }
     // The statistics.
     foreach ($todisplay as $property => $format) {
         if (!isset($this->{$property}) || !$format) {
             continue;
         }
         $value = $this->{$property};
         switch ($format) {
             case 'summarks_as_percentage':
                 $formattedvalue = quiz_report_scale_summarks_as_percentage($value, $quiz);
                 break;
             case 'number_format_percent':
                 $formattedvalue = quiz_format_grade($quiz, $value) . '%';
                 break;
             case 'number_format':
                 // 2 extra decimal places, since not a percentage,
                 // and we want the same number of sig figs.
                 $formattedvalue = format_float($value, $quiz->decimalpoints + 2);
                 break;
             case 'number':
                 $formattedvalue = $value + 0;
                 break;
             default:
                 $formattedvalue = $value;
         }
         $quizinfo[get_string($property, 'quiz_statistics', calculator::using_attempts_lang_string($this->whichattempts))] = $formattedvalue;
     }
     return $quizinfo;
 }