don't get extra fields which are not needed from course table
[moodle.git] / mod / quiz / report / analysis / report.php
Content-type: text/html Official Moodle git projects - moodle.git/blame - mod/quiz/report/analysis/report.php


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 8) line 1, <$fd> line 243.
CommitLineData
0fc59399 1<?php // $Id$
2
3/// Item analysis displays a table of quiz questions and their performance
4
0fc59399 5 require_once($CFG->libdir.'/tablelib.php');
6
7
8function stats_sumx($sum, $data){
9 $sum[0] += $data[0];
10 $sum[1] += $data[1];
11 return $sum;
12}
13
14function stats_sumx2($sum, $data){
15 $sum[0] += $data[0]*$data[0];
16 $sum[1] += $data[1]*$data[1];
17 return $sum;
18}
19
20function stats_sumxy($sum, $data){
21 $sum[0] += $data[0]*$data[1];
22 return $sum;
23}
24
25
26/// Item analysis displays a table of quiz questions and their performance
27
28class quiz_report extends quiz_default_report {
29
30 function display($quiz, $cm, $course) { /// This function just displays the report
31
32 global $CFG, $SESSION, $db, $QUIZ_QTYPES;
1b6fe500 33 define('QUIZ_ALLATTEMPTS', 0);
34 define('QUIZ_HIGHESTATTEMPT', 1);
35 define('QUIZ_FIRSTATTEMPT', 2);
36 define('QUIZ_LASTATTEMPT', 3);
0fc59399 37
38 $strnoquiz = get_string('noquiz','quiz');
39 $strnoattempts = get_string('noattempts','quiz');
40 $strtimeformat = get_string('strftimedatetime');
41
42 if (!$quiz->questions) {
43 print_heading($strnoattempts);
44 return true;
45 }
46
47 /// Check to see if groups are being used in this quiz
48 if ($groupmode = groupmode($course, $cm)) { // Groups are being used
49 $currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id&amp;mode=overview");
50 } else {
51 $currentgroup = false;
52 }
53
54 /// Get all users: teachers and students
55 if ($currentgroup) {
1b6fe500 56 $users = get_group_students($currentgroup);
0fc59399 57 }
58 else {
1b6fe500 59 $users = get_course_students($course->id);
0fc59399 60 }
61
1b6fe500 62
0fc59399 63 if(empty($users)) {
64 print_heading($strnoattempts);
65 return true;
66 }
67
68 // set tTable and Analysis stats options
69 if(!isset($SESSION->quiz_analysis_table)) {
70 $SESSION->quiz_analysis_table = array('attemptselection' => 0, 'lowmarklimit' => 0);
71 }
72
73 foreach($SESSION->quiz_analysis_table as $option => $value) {
74 $urlparam = optional_param($option, NULL);
75 if($urlparam === NULL) {
76 $$option = $value;
77 }
78 else {
79 $$option = $SESSION->quiz_analysis_table[$option] = $urlparam;
80 }
81 }
82
83 $scorelimit = $quiz->grade * $lowmarklimit/ 100;
84
85 // ULPGC ecastro DEBUG this is here to allow for differnt SQL to select attempts
86 switch ($attemptselection) {
87 case QUIZ_ALLATTEMPTS :
88 $limit = '';
89 $group = '';
90 break;
91 case QUIZ_HIGHESTATTEMPT :
92 $limit = ', max(qa.sumgrades) ';
93 $group = ' GROUP BY qa.userid ';
94 break;
95 case QUIZ_FIRSTATTEMPT :
96 $limit = ', min(qa.timemodified) ';
97 $group = ' GROUP BY qa.userid ';
98 break;
99 case QUIZ_LASTATTEMPT :
100 $limit = ', max(qa.timemodified) ';
101 $group = ' GROUP BY qa.userid ';
102 break;
103 }
104
105 $select = 'SELECT qa.* '.$limit;
106 $sql = 'FROM '.$CFG->prefix.'user u '.
107 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid '.
108 'LEFT JOIN '.$CFG->prefix.'quiz_states qr ON qr.attempt = qa.id '. // es posible
109 'WHERE u.id IN ('.implode(',', array_keys($users)).') AND ( qa.quiz = '.$quiz->id.') '. // ULPGC ecastro
110 ' AND ( qa.sumgrades >= '.$scorelimit.' ) ';
111