mirrored from git://git.moodle.org/moodle.git
/
report.php
639 lines (572 loc) · 27.5 KB
/
report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
<?php
/**
* This script lists student attempts
*
* @version $Id$
* @author Martin Dougiamas, Tim Hunt and others.
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package quiz
*//** */
require_once($CFG->libdir.'/tablelib.php');
require_once($CFG->dirroot.'/mod/quiz/report/overview/overviewsettings_form.php');
class quiz_report extends quiz_default_report {
/**
* Display the report.
*/
function display($quiz, $cm, $course) {
global $CFG, $db;
// Define some strings
$strreallydel = addslashes(get_string('deleteattemptcheck','quiz'));
$strtimeformat = get_string('strftimedatetime');
$strreviewquestion = get_string('reviewresponse', 'quiz');
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// Only print headers if not asked to download data
if (!$download = optional_param('download', NULL)) {
$this->print_header_and_tabs($cm, $course, $quiz, "overview");
}
if($attemptids = optional_param('attemptid', array(), PARAM_INT)) {
//attempts need to be deleted
require_capability('mod/quiz:deleteattempts', $context);
$attemptids = optional_param('attemptid', array(), PARAM_INT);
foreach($attemptids as $attemptid) {
add_to_log($course->id, 'quiz', 'delete attempt', 'report.php?id=' . $cm->id,
$attemptid, $cm->id);
quiz_delete_attempt($attemptid, $quiz);
}
//No need for a redirect, any attemptids that do not exist are ignored.
//So no problem if the user refreshes and tries to delete the same attempts
//twice.
}
// Work out some display options - whether there is feedback, and whether scores should be shown.
$hasfeedback = quiz_has_feedback($quiz->id) && $quiz->grade > 1.e-7 && $quiz->sumgrades > 1.e-7;
$fakeattempt = new stdClass();
$fakeattempt->preview = false;
$fakeattempt->timefinish = $quiz->timeopen;
$reviewoptions = quiz_get_reviewoptions($quiz, $fakeattempt, $context);
$showgrades = $quiz->grade && $quiz->sumgrades && $reviewoptions->scores;
if (!$reviewoptions->scores) {
$detailedmarks = 0;
}
$pageoptions = array();
$pageoptions['id'] = $cm->id;
$pageoptions['q'] = $quiz->id;
$pageoptions['mode'] = 'overview';
$reporturl = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $pageoptions);
$qmsubselect = quiz_report_qm_filter_subselect($quiz);
$mform = new mod_quiz_report_overview_settings($reporturl, compact('qmsubselect', 'quiz'));
if ($fromform = $mform->get_data()){
$attemptsmode = $fromform->attemptsmode;
if ($qmsubselect){
//control is not on the form if
//the grading method is not set
//to grade one attempt per user eg. for average attempt grade.
$qmfilter = $fromform->qmfilter;
} else {
$qmfilter = 0;
}
set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks);
set_user_preference('quiz_report_pagesize', $fromform->pagesize);
$detailedmarks = $fromform->detailedmarks;
$pagesize = $fromform->pagesize;
} else {
$qmfilter = optional_param('qmfilter', 0, PARAM_INT);
$attemptsmode = optional_param('attemptsmode', QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH, PARAM_INT);
$detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1);
$pagesize = get_user_preferences('quiz_report_pagesize', 0);
}
if ($pagesize < 1) {
$pagesize = QUIZ_REPORT_DEFAULT_PAGE_SIZE;
}
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/quiz:deleteattempts', $context)
&& ($attemptsmode!= QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
$displayoptions = array();
$displayoptions['attemptsmode'] = $attemptsmode;
$displayoptions['qmfilter'] = $qmfilter;
$reporturlwithdisplayoptions = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', $pageoptions + $displayoptions);
/// find out current groups mode
$currentgroup = groups_get_activity_group($cm, true);
if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
if (!$download) {
groups_print_activity_menu($cm, $reporturlwithdisplayoptions->out());
}
}
// Print information on the number of existing attempts
if (!$download) { //do not print notices when downloading
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, false, $currentgroup)) {
echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>';
}
}
// Print information on the grading method and whether we are displaying
//
if (!$download) { //do not print notices when downloading
if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) {
echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>';
}
}
// Now check if asked download of data
if ($download) {
$filename = clean_filename("$course->shortname ".format_string($quiz->name,true));
}
// Define table columns
$columns = array();
$headers = array();
if (!$download && $candelete) {
$columns[]= 'checkbox';
$headers[]= NULL;
}
if (!$download && $CFG->grade_report_showuserimage) {
$columns[]= 'picture';
$headers[]= '';
}
$columns[]= 'fullname';
$headers[]= get_string('name');
if ($CFG->grade_report_showuseridnumber) {
$columns[]= 'idnumber';
$headers[]= get_string('idnumber');
}
$columns[]= 'timestart';
$headers[]= get_string('startedon', 'quiz');
$columns[]= 'timefinish';
$headers[]= get_string('timecompleted','quiz');
$columns[]= 'duration';
$headers[]= get_string('attemptduration', 'quiz');
if ($showgrades) {
$columns[] = 'sumgrades';
$headers[] = get_string('grade', 'quiz').'/'.$quiz->grade;
}
if ($detailedmarks) {
// we want to display marks for all questions
$questions = quiz_report_load_questions($quiz);
foreach ($questions as $id => $question) {
// Ignore questions of zero length
$columns[] = '$'.$id;
$headers[] = '#'.$question->number;
}
}
if ($hasfeedback) {
$columns[] = 'feedbacktext';
$headers[] = get_string('feedback', 'quiz');
}
if (!$download) {
// Set up the table
$table = new flexible_table('mod-quiz-report-overview-report');
$table->define_columns($columns);
$table->define_headers($headers);
$table->define_baseurl($reporturlwithdisplayoptions->out());
$table->sortable(true);
$table->collapsible(true);
$table->column_suppress('picture');
$table->column_suppress('fullname');
$table->no_sorting('feedbacktext');
$table->column_class('picture', 'picture');
$table->column_class('fullname', 'bold');
$table->column_class('sumgrades', 'bold');
$table->set_attribute('cellspacing', '0');
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
// Start working -- this is necessary as soon as the niceties are over
$table->setup();
} else if ($download =='ODS') {
require_once("$CFG->libdir/odslib.class.php");
$filename .= ".ods";
// Creating a workbook
$workbook = new MoodleODSWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('reportoverview','quiz');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
// Here starts workshhet headers
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0,$colnum,$item,$formatbc);
$colnum++;
}
$rownum=1;
} else if ($download =='Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
// Creating a workbook
$workbook = new MoodleExcelWorkbook("-");
// Sending HTTP headers
$workbook->send($filename);
// Creating the first worksheet
$sheettitle = get_string('reportoverview','quiz');
$myxls =& $workbook->add_worksheet($sheettitle);
// format types
$format =& $workbook->add_format();
$format->set_bold(0);
$formatbc =& $workbook->add_format();
$formatbc->set_bold(1);
$formatbc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatr =& $workbook->add_format();
$formatr->set_bold(1);
$formatr->set_color('red');
$formatr->set_align('center');
$formatg =& $workbook->add_format();
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0,$colnum,$item,$formatbc);
$colnum++;
}
$rownum=1;
} else if ($download=='CSV') {
$filename .= ".txt";
header("Content-Type: application/download\n");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Expires: 0");
header("Cache-Control: must-revalidate,post-check=0,pre-check=0");
header("Pragma: public");
echo implode("\t", $headers)." \n";
}
$students = join(',',array_keys(get_users_by_capability($context, 'mod/quiz:attempt','','','','','','',false)));
if (empty($currentgroup)) {
// all users who can attempt quizzes
$groupstudents = '';
$allowed = $students;
} else {
// all users who can attempt quizzes and who are in the currently selected group
$groupstudents = join(',',array_keys(get_users_by_capability($context, 'mod/quiz:attempt','','','','',$currentgroup,'',false)));
$allowed = $groupstudents;
}
// Construct the SQL
$select = 'SELECT '.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS uniqueid, '.
($qmsubselect?$qmsubselect.' AS gradedattempt, ':'').
'qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname, u.lastname, u.picture, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';
// This part is the same for all cases - join users and quiz_attempts tables
$from = 'FROM '.$CFG->prefix.'user u ';
$from .= 'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON qa.userid = u.id AND qa.quiz = '.$quiz->id;
if ($qmsubselect && $qmfilter){
$from .= ' AND '.$qmsubselect;
}
switch ($attemptsmode){
case QUIZ_REPORT_ATTEMPTS_ALL:
// Show all attempts, including students who are no longer in the course
$where = ' WHERE qa.id IS NOT NULL AND qa.preview = 0';
break;
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH:
// Show only students with attempts
$where = ' WHERE u.id IN (' .$allowed. ') AND qa.preview = 0 AND qa.id IS NOT NULL';
break;
case QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
// Show only students without attempts
$where = ' WHERE u.id IN (' .$allowed. ') AND qa.id IS NULL';
break;
case QUIZ_REPORT_ATTEMPTS_ALL_STUDENTS:
// Show all students with or without attempts
$where = ' WHERE u.id IN (' .$allowed. ') AND (qa.preview = 0 OR qa.preview IS NULL)';
break;
}
$countsql = 'SELECT COUNT(DISTINCT('.sql_concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
if ($download) {
$sort = '';
} else {
// Add extra limits due to initials bar
if($table->get_sql_where()) {
$where .= ' AND '.$table->get_sql_where();
}
// Count the records NOW, before funky question grade sorting messes up $from
if (!empty($countsql)) {
$totalinitials = count_records_sql($countsql);
if ($table->get_sql_where()) {
$countsql .= ' AND '.$table->get_sql_where();
}
$total = count_records_sql($countsql);
}
// Add extra limits due to sorting by question grade
if($sort = $table->get_sql_sort()) {
$sortparts = explode(',', $sort);
$newsort = array();
$questionsort = false;
foreach($sortparts as $sortpart) {
$sortpart = trim($sortpart);
if(substr($sortpart, 0, 1) == '$') {
if(!$questionsort) {
$qid = intval(substr($sortpart, 1));
$select .= ', qs.grade AS qgrade ';
$from .= ' LEFT JOIN '.$CFG->prefix.'question_sessions qns ON qns.attemptid = qa.uniqueid '.
'LEFT JOIN '.$CFG->prefix.'question_states qs ON qs.id = qns.newgraded ';
$where .= ' AND (qns.questionid IS NULL OR qns.questionid = '.$qid.')';
$newsort[] = 'qgrade '.(strpos($sortpart, 'ASC')? 'ASC' : 'DESC');
$questionsort = true;
}
} else {
$newsort[] = $sortpart;
}
}
// Reconstruct the sort string
$sort = ' ORDER BY '.implode(', ', $newsort);
}
// Fix some wired sorting
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
}
$table->pagesize($pagesize, $total);
}
// Fetch the attempts
if (!$download) {
$attempts = get_records_sql($select.$from.$where.$sort,
$table->get_page_start(), $table->get_page_size());
} else {
$attempts = get_records_sql($select.$from.$where.$sort);
}
// Build table rows
if (!$download) {
$table->initialbars($totalinitials>20);
}
if ($attempts) {
if($detailedmarks) {
//get all the attempt ids we want to display on this page
//or to export for download.
$attemptids = array();
foreach ($attempts as $attempt){
if ($attempt->attemptuniqueid > 0){
$attemptids[] = $attempt->attemptuniqueid;
}
}
$gradedstatesbyattempt = quiz_get_newgraded_states($attemptids);
}
foreach ($attempts as $attempt) {
$picture = print_user_picture($attempt->userid, $course->id, $attempt->picture, false, true);
$userlink = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$attempt->userid.
'&course='.$course->id.'">'.fullname($attempt).'</a>';
// Username columns.
$row = array();
if (in_array('checkbox', $columns)){
if ($attempt->attempt){
$row[] = '<input type="checkbox" name="attemptid[]" value="'.$attempt->attempt.'" />';
} else {
$row[] = '';
}
}
if (in_array('picture', $columns)){
$row[] = $picture;
}
if (!$download){
$row[] = $userlink;
} else {
$row[] = fullname($attempt);
}
if (in_array('idnumber', $columns)){
$row[] = $attempt->idnumber;
}
// Timing columns.
if ($attempt->attempt) {
$startdate = userdate($attempt->timestart, $strtimeformat);
if (!$download) {
$row[] = '<a href="review.php?q='.$quiz->id.'&attempt='.$attempt->attempt.'">'.$startdate.'</a>';
} else {
$row[] = $startdate;
}
if ($attempt->timefinish) {
$timefinish = userdate($attempt->timefinish, $strtimeformat);
$duration = format_time($attempt->duration);
if (!$download) {
$row[] = '<a href="review.php?q='.$quiz->id.'&attempt='.$attempt->attempt.'">'.$timefinish.'</a>';
} else {
$row[] = $timefinish;
}
$row[] = $duration;
} else {
$row[] = '-';
$row[] = get_string('unfinished', 'quiz');
}
} else {
$row[] = '-';
$row[] = '-';
$row[] = '-';
}
// Grades columns.
if ($showgrades) {
if ($attempt->timefinish) {
$grade = quiz_rescale_grade($attempt->sumgrades, $quiz);
if (!$download) {
$gradehtml = '<a href="review.php?q='.$quiz->id.'&attempt='.$attempt->attempt.'">'.$grade.'</a>';
if ($qmsubselect && $attempt->gradedattempt){
$gradehtml = '<div class="highlight">'.$gradehtml.'</div>';
}
$row[] = $gradehtml;
} else {
$row[] = $grade;
}
} else {
$row[] = '-';
}
}
if($detailedmarks) {
//get the detailled grade data for this attempt
if(empty($attempt->attempt)) {
foreach($questions as $question) {
$row[] = '-';
}
} else {
foreach($questions as $questionid => $question) {
$stateforqinattempt = $gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
if (question_state_is_graded($stateforqinattempt)) {
$grade = quiz_rescale_grade($stateforqinattempt->grade, $quiz);
} else {
$grade = '--';
}
if (!$download) {
$grade = $grade.'/'.quiz_rescale_grade($question->grade, $quiz);
$row[] = link_to_popup_window('/mod/quiz/reviewquestion.php?state='.
$stateforqinattempt->id.'&number='.$question->number,
'reviewquestion', $grade, 450, 650, $strreviewquestion, 'none', true);
} else {
$row[] = $grade;
}
}
}
}
// Feedback column.
if ($hasfeedback) {
if ($attempt->timefinish) {
$row[] = quiz_report_feedback_for_grade(quiz_rescale_grade($attempt->sumgrades, $quiz), $quiz->id);
} else {
$row[] = '-';
}
}
if (!$download) {
$table->add_data($row);
} else if ($download == 'Excel' or $download == 'ODS') {
$colnum = 0;
foreach($row as $item){
$myxls->write($rownum,$colnum,$item,$format);
$colnum++;
}
$rownum++;
} else if ($download=='CSV') {
$text = implode("\t", $row);
echo $text." \n";
}
}
//end of adding data from attempts data to table / download
//now add averages :
if (!$download && $attempts){
$averagesql = "SELECT AVG(qg.grade) AS grade " .
"FROM {$CFG->prefix}quiz_grades qg " .
"WHERE quiz=".$quiz->id;
$table->add_separator();
if ($groupstudents){
$groupaveragesql = $averagesql." AND qg.userid IN ($groupstudents)";
$groupaverage = get_record_sql($groupaveragesql);
$groupaveragerow = array('fullname' => get_string('groupavg', 'grades'),
'sumgrades' => round($groupaverage->grade, $quiz->decimalpoints),
'feedbacktext'=> quiz_report_feedback_for_grade($groupaverage->grade, $quiz->id));
if($detailedmarks && $qmfilter) {
$avggradebyq = quiz_get_average_grade_for_questions($quiz, $groupstudents);
$groupaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $questions, $quiz, $download);
}
$table->add_data_keyed($groupaveragerow);
}
$overallaverage = get_record_sql($averagesql." AND qg.userid IN ($students)");
$overallaveragerow = array('fullname' => get_string('overallaverage', 'grades'),
'sumgrades' => round($overallaverage->grade, $quiz->decimalpoints),
'feedbacktext'=> quiz_report_feedback_for_grade($overallaverage->grade, $quiz->id));
if($detailedmarks && $qmfilter) {
$avggradebyq = quiz_get_average_grade_for_questions($quiz, $students);
$overallaveragerow += quiz_format_average_grade_for_questions($avggradebyq, $questions, $quiz, $download);
}
$table->add_data_keyed($overallaveragerow);
}
if (!$download) {
// Start form
echo '<div id="tablecontainer">';
echo '<form id="attemptsform" method="post" action="' . $reporturlwithdisplayoptions->out(true) .
'" onsubmit="confirm(\''.$strreallydel.'\');">';
echo $reporturlwithdisplayoptions->hidden_params_out();
echo '<div>';
// Print table
$table->print_html();
// Print "Select all" etc.
if (!empty($attempts) && $candelete) {
echo '<table id="commands">';
echo '<tr><td>';
echo '<a href="javascript:select_all_in(\'DIV\',null,\'tablecontainer\');">'.
get_string('selectall', 'quiz').'</a> / ';
echo '<a href="javascript:deselect_all_in(\'DIV\',null,\'tablecontainer\');">'.
get_string('selectnone', 'quiz').'</a> ';
echo ' ';
echo '<input type="submit" value="'.get_string('deleteselected', 'quiz_overview').'"/>';
echo '</td></tr></table>';
}
// Close form
echo '</div>';
echo '</form></div>';
if (!empty($attempts)) {
echo '<table class="boxaligncenter"><tr>';
echo '<td>';
print_single_button($reporturl->out(true), $pageoptions + $displayoptions + array('download' => 'ODS'),
get_string('downloadods'));
echo "</td>\n";
echo '<td>';
print_single_button($reporturl->out(true), $pageoptions + $displayoptions + array('download' => 'Excel'),
get_string('downloadexcel'));
echo "</td>\n";
echo '<td>';
print_single_button($reporturl->out(true), $pageoptions + $displayoptions + array('download' => 'CSV'),
get_string('downloadtext'));
echo "</td>\n";
echo "<td>";
helpbutton('overviewdownload', get_string('overviewdownload', 'quiz_overview'), 'quiz');
echo "</td>\n";
echo '</tr></table>';
}
}
} else {
if (!$download) {
$table->print_html();
}
}
if ($download == 'Excel' or $download == 'ODS') {
$workbook->close();
exit;
} else if ($download == 'CSV') {
exit;
}
if (!$download) {
// Print display options
$mform->set_data($displayoptions +compact('detailedmarks', 'pagesize'));
$mform->display();
if ($attempts){
$imageurl = $CFG->wwwroot.'/mod/quiz/report/overview/overviewgraph.php?id='.$quiz->id;
print_heading(get_string('overviewreportgraph', 'quiz_overview'));
echo '<div class="mdl-align"><img src="'.$imageurl.'" alt="'.get_string('overviewreportgraph', 'quiz_overview').'" /></div>';
}
}
return true;
}
}
?>