diff --git a/lang/en_utf8/quiz_statistics.php b/lang/en_utf8/quiz_statistics.php index 7feab43a30d..f6341df9f35 100644 --- a/lang/en_utf8/quiz_statistics.php +++ b/lang/en_utf8/quiz_statistics.php @@ -28,4 +28,8 @@ $string['kurtosis'] = 'Score distribution kurtosis'; $string['cic'] = 'Coefficient of internal consistency'; $string['errorratio'] = 'Error ratio'; $string['standarderror'] = 'Standard error'; +$string['questionnumber'] = 'Q#'; +$string['quizstructureanalysis'] = 'Quiz structure analysis'; +$string['questiontype'] = 'Q type'; +$string['intended_weight'] = 'Intended question weight'; ?> \ No newline at end of file diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index 7780c5089cf..ea931266da3 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -55,9 +55,9 @@ class quiz_report extends quiz_default_report { $allowedlist = $groupstudentslist; } - $questions = quiz_report_load_questions($quiz); + $questions = question_load_questions(quiz_questions_in_quiz($quiz->questions)); - $table = new quiz_report_statistics_table($quiz , $questions, $reporturl); + $table = new quiz_report_statistics_table(); $table->is_downloading($download, get_string('reportstatistics','quiz_statistics'), "$course->shortname ".format_string($quiz->name,true)); if (!$table->is_downloading()) { @@ -261,8 +261,16 @@ class quiz_report extends quiz_default_report { $quizattsstatistics->data[] = array(get_string('standarderror', 'quiz_statistics'), quiz_report_scale_sumgrades_as_percentage($standarderror, $quiz)); print_table($quizattsstatistics); - + } + if (!$table->is_downloading()){ + print_heading(get_string('quizstructureanalysis', 'quiz_statistics')); + } + $table->setup($quiz, $cm->id, $reporturl); + foreach ($questions as $question){ + $table->add_data_keyed($table->format_row($question)); + } + $table->finish_output(); return true; } diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index 38941bb398b..6d4889c36a2 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -1,211 +1,94 @@ quiz = $quiz; - $this->questions = $questions; - $this->reporturl = $reporturl; - } - function build_table(){ - global $CFG, $DB; + $this->cmid = $cmid; + // Define table columns + $columns = array(); + $headers = array(); + + $columns[]= 'number'; + $headers[]= get_string('questionnumber', 'quiz_statistics'); + + if (!$this->is_downloading()){ + $columns[]= 'icon'; + $headers[]= ''; + $columns[]= 'actions'; + $headers[]= ''; + } else { + $columns[]= 'qtype'; + $headers[]= get_string('questiontype', 'quiz_statistics'); + } + $columns[]= 'name'; + $headers[]= get_string('questionname', 'quiz'); + + $columns[]= 'intended_weight'; + $headers[]= get_string('intended_weight', 'quiz_statistics'); + + $this->define_columns($columns); + $this->define_headers($headers); + $this->sortable(false); - if ($this->rawdata) { - // Define some things we need later to process raw data from db. - $this->strtimeformat = get_string('strftimedatetime'); - parent::build_table(); - //end of adding data from attempts data to table / download - //now add averages at bottom of table : - $averagesql = "SELECT AVG(qg.grade) AS grade " . - "FROM {quiz_grades} qg " . - "WHERE quiz=".$this->quiz->id; - - $this->add_separator(); - if ($this->is_downloading()){ - $namekey = 'lastname'; - } else { - $namekey = 'fullname'; - } - if ($this->groupstudents){ - $groupaveragesql = $averagesql." AND qg.userid IN ($this->groupstudents)"; - $groupaverage = $DB->get_record_sql($groupaveragesql); - $groupaveragerow = array($namekey => get_string('groupavg', 'grades'), - 'sumgrades' => round($groupaverage->grade, $this->quiz->decimalpoints), - 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($groupaverage->grade, $this->quiz->id))); - if($this->detailedmarks && $this->qmsubselect) { - $avggradebyq = quiz_get_average_grade_for_questions($this->quiz, $this->groupstudents); - $groupaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $this->questions, $this->quiz, $this->is_downloading()); - } - $this->add_data_keyed($groupaveragerow); - } - $overallaverage = $DB->get_record_sql($averagesql." AND qg.userid IN ($this->students)"); - $overallaveragerow = array($namekey => get_string('overallaverage', 'grades'), - 'sumgrades' => round($overallaverage->grade, $this->quiz->decimalpoints), - 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade($overallaverage->grade, $this->quiz->id))); - if($this->detailedmarks && $this->qmsubselect) { - $avggradebyq = quiz_get_average_grade_for_questions($this->quiz, $this->students); - $overallaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $this->questions, $this->quiz, $this->is_downloading()); - } - $this->add_data_keyed($overallaveragerow); - } - } - - function wrap_html_start(){ - if (!$this->is_downloading()) { - if ($this->candelete) { - // Start form - $strreallydel = addslashes_js(get_string('deleteattemptcheck','quiz')); - echo '