-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.php
595 lines (528 loc) · 27.3 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
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Displays the lesson statistics.
*
* @package mod
* @subpackage customlesson
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @copyright 2012-2013 Silecs et Institut Mines-Télécom
* @notice customlesson is heavily based on the official lesson module and large portions of code are copied from there.
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
**/
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/customlesson/locallib.php');
$id = required_param('id', PARAM_INT); // Course Module ID
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
$action = optional_param('action', 'reportoverview', PARAM_ALPHA); // action to take
$nothingtodisplay = false;
$cm = get_coursemodule_from_id('customlesson', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$lesson = new customlesson($DB->get_record('customlesson', array('id' => $cm->instance), '*', MUST_EXIST));
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/customlesson:manage', $context);
$ufields = user_picture::fields('u'); // These fields are enough
$params = array("lessonid" => $lesson->id);
list($sort, $sortparams) = users_order_by_sql('u');
$params = array_merge($params, $sortparams);
// TODO: Improve this. Fetching all students always is crazy!
if (!empty($cm->groupingid)) {
$params["groupid"] = $cm->groupingid;
$sql = "SELECT DISTINCT $ufields
FROM {customlesson_attempts} a
INNER JOIN {user} u ON u.id = a.userid
INNER JOIN {groups_members} gm ON gm.userid = u.id
INNER JOIN {groupings_groups} gg ON gm.groupid = :groupid
WHERE a.lessonid = :lessonid
ORDER BY $sort";
} else {
$sql = "SELECT DISTINCT $ufields
FROM {user} u,
{customlesson_attempts} a
WHERE a.lessonid = :lessonid and
u.id = a.userid
ORDER BY $sort";
}
if (! $students = $DB->get_records_sql($sql, $params)) {
$nothingtodisplay = true;
}
$url = new moodle_url('/mod/customlesson/report.php', array('id'=>$id));
if ($action !== 'reportoverview') {
$url->param('action', $action);
}
if ($pageid !== NULL) {
$url->param('pageid', $pageid);
}
$PAGE->set_url($url);
if ($action == 'reportoverview') {
$PAGE->navbar->add(get_string('reports', 'customlesson'));
$PAGE->navbar->add(get_string('overview', 'customlesson'));
}
$lessonoutput = $PAGE->get_renderer('mod_customlesson');
if (! $attempts = $DB->get_records('customlesson_attempts', array('lessonid' => $lesson->id), 'timeseen')) {
$nothingtodisplay = true;
}
if (! $grades = $DB->get_records('customlesson_grades', array('lessonid' => $lesson->id), 'completed')) {
$grades = array();
}
if (! $times = $DB->get_records('customlesson_timer', array('lessonid' => $lesson->id), 'starttime')) {
$times = array();
}
if ($nothingtodisplay) {
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('nolessonattempts', 'customlesson'));
echo $OUTPUT->notification(get_string('nolessonattempts', 'customlesson'));
echo $OUTPUT->footer();
exit();
}
if ($action === 'delete') {
/// Process any form data before fetching attempts, grades and times
if (has_capability('mod/customlesson:edit', $context) and $form = data_submitted() and confirm_sesskey()) {
/// Cycle through array of userids with nested arrays of tries
if (!empty($form->attempts)) {
foreach ($form->attempts as $userid => $tries) {
// Modifier IS VERY IMPORTANT! What does it do?
// Well, it is for when you delete multiple attempts for the same user.
// If you delete try 1 and 3 for a user, then after deleting try 1, try 3 then
// becomes try 2 (because try 1 is gone and all tries after try 1 get decremented).
// So, the modifier makes sure that the submitted try refers to the current try in the
// database - hope this all makes sense :)
$modifier = 0;
foreach ($tries as $try => $junk) {
$try -= $modifier;
/// Clean up the timer table by removing using the order - this is silly, it should be linked to specific attempt (skodak)
$params = array ("userid" => $userid, "lessonid" => $lesson->id);
$timers = $DB->get_records_sql("SELECT id FROM {customlesson_timer}
WHERE userid = :userid AND lessonid = :lessonid
ORDER BY starttime", $params, $try, 1);
if ($timers) {
$timer = reset($timers);
$DB->delete_records('customlesson_timer', array('id' => $timer->id));
}
/// Remove the grade from the grades and high_scores tables - this is silly, it should be linked to specific attempt (skodak)
$grades = $DB->get_records_sql("SELECT id FROM {customlesson_grades}
WHERE userid = :userid AND lessonid = :lessonid
ORDER BY completed", $params, $try, 1);
if ($grades) {
$grade = reset($grades);
$DB->delete_records('customlesson_grades', array('id' => $grade->id));
$DB->delete_records('customlesson_high_scores', array('gradeid' => $grade->id, 'lessonid' => $lesson->id, 'userid' => $userid));
}
/// Remove attempts and update the retry number
$DB->delete_records('customlesson_attempts', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
$DB->execute("UPDATE {customlesson_attempts} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
/// Remove seen branches and update the retry number
$DB->delete_records('customlesson_branch', array('userid' => $userid, 'lessonid' => $lesson->id, 'retry' => $try));
$DB->execute("UPDATE {customlesson_branch} SET retry = retry - 1 WHERE userid = ? AND lessonid = ? AND retry > ?", array($userid, $lesson->id, $try));
/// update central gradebook
customlesson_update_grades($lesson, $userid);
$modifier++;
}
}
}
}
redirect(new moodle_url($PAGE->url, array('action'=>'reportoverview')));
} else if ($action === 'reportoverview') {
/**************************************************************************
this action is for default view and overview view
**************************************************************************/
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('overview', 'customlesson'));
$course_context = context_course::instance($course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
$seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
$seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));
echo $OUTPUT->box($seeallgradeslink, 'allcoursegrades');
}
$studentdata = array();
// build an array for output
foreach ($attempts as $attempt) {
// if the user is not in the array or if the retry number is not in the sub array, add the data for that try.
if (!array_key_exists($attempt->userid, $studentdata) || !array_key_exists($attempt->retry, $studentdata[$attempt->userid])) {
// restore/setup defaults
$n = 0;
$timestart = 0;
$timeend = 0;
$usergrade = NULL;
// search for the grade record for this try. if not there, the nulls defined above will be used.
foreach($grades as $grade) {
// check to see if the grade matches the correct user
if ($grade->userid == $attempt->userid) {
// see if n is = to the retry
if ($n == $attempt->retry) {
// get grade info
$usergrade = round($grade->grade, 2); // round it here so we only have to do it once
break;
}
$n++; // if not equal, then increment n
}
}
$n = 0;
// search for the time record for this try. if not there, the nulls defined above will be used.
foreach($times as $time) {
// check to see if the grade matches the correct user
if ($time->userid == $attempt->userid) {
// see if n is = to the retry
if ($n == $attempt->retry) {
// get grade info
$timeend = $time->lessontime;
$timestart = $time->starttime;
break;
}
$n++; // if not equal, then increment n
}
}
// build up the array.
// this array represents each student and all of their tries at the lesson
$studentdata[$attempt->userid][$attempt->retry] = array( "timestart" => $timestart,
"timeend" => $timeend,
"grade" => $usergrade,
"try" => $attempt->retry,
"userid" => $attempt->userid);
}
}
// set all the stats variables
$numofattempts = 0;
$avescore = 0;
$avetime = 0;
$highscore = NULL;
$lowscore = NULL;
$hightime = NULL;
$lowtime = NULL;
$table = new html_table();
// set up the table object
$table->head = array(get_string('name'), get_string('attempts', 'customlesson'), get_string('highscore', 'customlesson'));
$table->align = array('center', 'left', 'left');
$table->wrap = array('nowrap', 'nowrap', 'nowrap');
$table->attributes['class'] = 'standardtable generaltable';
$table->size = array(null, '70%', null);
// print out the $studentdata array
// going through each student that has attempted the lesson, so, each student should have something to be displayed
foreach ($students as $student) {
// check to see if the student has attempts to print out
if (array_key_exists($student->id, $studentdata)) {
// set/reset some variables
$attempts = array();
// gather the data for each user attempt
$bestgrade = 0;
$bestgradefound = false;
// $tries holds all the tries/retries a student has done
$tries = $studentdata[$student->id];
$studentname = "{$student->lastname}, $student->firstname";
foreach ($tries as $try) {
// start to build up the checkbox and link
if (has_capability('mod/customlesson:edit', $context)) {
$temp = '<input type="checkbox" id="attempts" name="attempts['.$try['userid'].']['.$try['try'].']" /> ';
} else {
$temp = '';
}
$temp .= "<a href=\"report.php?id=$cm->id&action=reportdetail&userid=".$try['userid'].'&try='.$try['try'].'">';
if ($try["grade"] !== NULL) { // if NULL then not done yet
// this is what the link does when the user has completed the try
$timetotake = $try["timeend"] - $try["timestart"];
$temp .= $try["grade"]."%";
$bestgradefound = true;
if ($try["grade"] > $bestgrade) {
$bestgrade = $try["grade"];
}
$temp .= " ".userdate($try["timestart"]);
$temp .= ", (".format_time($timetotake).")</a>";
} else {
// this is what the link does/looks like when the user has not completed the try
$temp .= get_string("notcompleted", "customlesson");
$temp .= " ".userdate($try["timestart"])."</a>";
$timetotake = NULL;
}
// build up the attempts array
$attempts[] = $temp;
// run these lines for the stats only if the user finnished the lesson
if ($try["grade"] !== NULL) {
$numofattempts++;
$avescore += $try["grade"];
$avetime += $timetotake;
if ($try["grade"] > $highscore || $highscore == NULL) {
$highscore = $try["grade"];
}
if ($try["grade"] < $lowscore || $lowscore == NULL) {
$lowscore = $try["grade"];
}
if ($timetotake > $hightime || $hightime == NULL) {
$hightime = $timetotake;
}
if ($timetotake < $lowtime || $lowtime == NULL) {
$lowtime = $timetotake;
}
}
}
// get line breaks in after each attempt
$attempts = implode("<br />\n", $attempts);
// add it to the table data[] object
$table->data[] = array($studentname, $attempts, $bestgrade."%");
}
}
// print it all out !
if (has_capability('mod/customlesson:edit', $context)) {
echo "<form id=\"theform\" method=\"post\" action=\"report.php\">\n
<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n
<input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
}
echo html_writer::table($table);
if (has_capability('mod/customlesson:edit', $context)) {
$checklinks = '<a href="javascript: checkall();">'.get_string('selectall').'</a> / ';
$checklinks .= '<a href="javascript: checknone();">'.get_string('deselectall').'</a>';
$checklinks .= html_writer::label('action', 'menuaction', false, array('class' => 'accesshide'));
$checklinks .= html_writer::select(array('delete' => get_string('deleteselected')), 'action', 0, array(''=>'choosedots'), array('id'=>'actionid', 'class' => 'autosubmit'));
$PAGE->requires->yui_module('moodle-core-formautosubmit',
'M.core.init_formautosubmit',
array(array('selectid' => 'actionid', 'nothing' => false))
);
echo $OUTPUT->box($checklinks, 'center');
echo '</form>';
}
// some stat calculations
if ($numofattempts == 0) {
$avescore = get_string("notcompleted", "customlesson");
} else {
$avescore = format_float($avescore/$numofattempts, 2);
}
if ($avetime == NULL) {
$avetime = get_string("notcompleted", "customlesson");
} else {
$avetime = format_float($avetime/$numofattempts, 0);
$avetime = format_time($avetime);
}
if ($hightime == NULL) {
$hightime = get_string("notcompleted", "customlesson");
} else {
$hightime = format_time($hightime);
}
if ($lowtime == NULL) {
$lowtime = get_string("notcompleted", "customlesson");
} else {
$lowtime = format_time($lowtime);
}
if ($highscore == NULL) {
$highscore = get_string("notcompleted", "customlesson");
}
if ($lowscore == NULL) {
$lowscore = get_string("notcompleted", "customlesson");
}
// output the stats
echo $OUTPUT->heading(get_string('lessonstats', 'customlesson'));
$stattable = new html_table();
$stattable->head = array(get_string('averagescore', 'customlesson'), get_string('averagetime', 'customlesson'),
get_string('highscore', 'customlesson'), get_string('lowscore', 'customlesson'),
get_string('hightime', 'customlesson'), get_string('lowtime', 'customlesson'));
$stattable->align = array('center', 'center', 'center', 'center', 'center', 'center');
$stattable->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap');
$stattable->attributes['class'] = 'standardtable generaltable';
$stattable->data[] = array($avescore.'%', $avetime, $highscore.'%', $lowscore.'%', $hightime, $lowtime);
echo html_writer::table($stattable);
} else if ($action === 'reportdetail') {
/**************************************************************************
this action is for a student detailed view and for the general detailed view
General flow of this section of the code
1. Generate a object which holds values for the statistics for each question/answer
2. Cycle through all the pages to create a object. Foreach page, see if the student actually answered
the page. Then process the page appropriatly. Display all info about the question,
Highlight correct answers, show how the user answered the question, and display statistics
about each page
3. Print out info about the try (if needed)
4. Print out the object which contains all the try info
**************************************************************************/
echo $lessonoutput->header($lesson, $cm, $action, false, null, get_string('detailedstats', 'customlesson'));
$course_context = context_course::instance($course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
$seeallgradeslink = new moodle_url('/grade/report/grader/index.php', array('id'=>$course->id));
$seeallgradeslink = html_writer::link($seeallgradeslink, get_string('seeallcoursegrades', 'grades'));
echo $OUTPUT->box($seeallgradeslink, 'allcoursegrades');
}
$formattextdefoptions = new stdClass;
$formattextdefoptions->para = false; //I'll use it widely in this page
$formattextdefoptions->overflowdiv = true;
$userid = optional_param('userid', NULL, PARAM_INT); // if empty, then will display the general detailed view
$try = optional_param('try', NULL, PARAM_INT);
$lessonpages = $lesson->load_all_pages();
foreach ($lessonpages as $lessonpage) {
if ($lessonpage->prevpageid == 0) {
$pageid = $lessonpage->id;
}
}
// now gather the stats into an object
$firstpageid = $pageid;
$pagestats = array();
while ($pageid != 0) { // EOL
$page = $lessonpages[$pageid];
$params = array ("lessonid" => $lesson->id, "pageid" => $page->id);
if ($allanswers = $DB->get_records_select("customlesson_attempts", "lessonid = :lessonid AND pageid = :pageid", $params, "timeseen")) {
// get them ready for processing
$orderedanswers = array();
foreach ($allanswers as $singleanswer) {
// ordering them like this, will help to find the single attempt record that we want to keep.
$orderedanswers[$singleanswer->userid][$singleanswer->retry][] = $singleanswer;
}
// this is foreach user and for each try for that user, keep one attempt record
foreach ($orderedanswers as $orderedanswer) {
foreach($orderedanswer as $tries) {
$page->stats($pagestats, $tries);
}
}
} else {
// no one answered yet...
}
//unset($orderedanswers); initialized above now
$pageid = $page->nextpageid;
}
$manager = customlesson_page_type_manager::get($lesson);
$qtypes = $manager->get_page_type_strings();
$answerpages = array();
$answerpage = "";
$pageid = $firstpageid;
// cycle through all the pages
// foreach page, add to the $answerpages[] array all the data that is needed
// from the question, the users attempt, and the statistics
// grayout pages that the user did not answer and Branch, end of branch, cluster
// and end of cluster pages
while ($pageid != 0) { // EOL
$page = $lessonpages[$pageid];
$answerpage = new stdClass;
$data ='';
$answerdata = new stdClass;
// Set some defaults for the answer data.
$answerdata->score = NULL;
$answerdata->response = NULL;
$answerdata->responseformat = FORMAT_PLAIN;
$answerpage->title = format_string($page->title);
$options = new stdClass;
$options->noclean = true;
$options->overflowdiv = true;
$answerpage->contents = format_text($page->contents, $page->contentsformat, $options);
$answerpage->qtype = $qtypes[$page->qtype].$page->option_description_string();
$answerpage->grayout = $page->grayout;
$answerpage->context = $context;
if (empty($userid)) {
// there is no userid, so set these vars and display stats.
$answerpage->grayout = 0;
$useranswer = NULL;
} elseif ($useranswers = $DB->get_records("customlesson_attempts",array("lessonid"=>$lesson->id, "userid"=>$userid, "retry"=>$try,"pageid"=>$page->id), "timeseen")) {
// get the user's answer for this page
// need to find the right one
$i = 0;
foreach ($useranswers as $userattempt) {
$useranswer = $userattempt;
$i++;
if ($lesson->maxattempts == $i) {
break; // reached maxattempts, break out
}
}
} else {
// user did not answer this page, gray it out and set some nulls
$answerpage->grayout = 1;
$useranswer = NULL;
}
$i = 0;
$n = 0;
$answerpages[] = $page->report_answers(clone($answerpage), clone($answerdata), $useranswer, $pagestats, $i, $n);
$pageid = $page->nextpageid;
}
/// actually start printing something
$table = new html_table();
$table->wrap = array();
$table->width = "60%";
if (!empty($userid)) {
// if looking at a students try, print out some basic stats at the top
// print out users name
//$headingobject->lastname = $students[$userid]->lastname;
//$headingobject->firstname = $students[$userid]->firstname;
//$headingobject->attempt = $try + 1;
//print_heading(get_string("studentattemptlesson", "customlesson", $headingobject));
echo $OUTPUT->heading(get_string('attempt', 'customlesson', $try+1));
$table->head = array();
$table->align = array('right', 'left');
$table->attributes['class'] = 'compacttable generaltable';
$params = array("lessonid"=>$lesson->id, "userid"=>$userid);
if (!$grades = $DB->get_records_select("customlesson_grades", "lessonid = :lessonid and userid = :userid", $params, "completed", "*", $try, 1)) {
$grade = -1;
$completed = -1;
} else {
$grade = current($grades);
$completed = $grade->completed;
$grade = round($grade->grade, 2);
}
if (!$times = $DB->get_records_select("customlesson_timer", "lessonid = :lessonid and userid = :userid", $params, "starttime", "*", $try, 1)) {
$timetotake = -1;
} else {
$timetotake = current($times);
$timetotake = $timetotake->lessontime - $timetotake->starttime;
}
if ($timetotake == -1 || $completed == -1 || $grade == -1) {
$table->align = array("center");
$table->data[] = array(get_string("notcompleted", "customlesson"));
} else {
$user = $students[$userid];
$gradeinfo = customlesson_grade($lesson, $try, $user->id);
$table->data[] = array(get_string('name').':', $OUTPUT->user_picture($user, array('courseid'=>$course->id)).fullname($user, true));
$table->data[] = array(get_string("timetaken", "customlesson").":", format_time($timetotake));
$table->data[] = array(get_string("completed", "customlesson").":", userdate($completed));
$table->data[] = array(get_string('rawgrade', 'customlesson').':', $gradeinfo->earned.'/'.$gradeinfo->total);
$table->data[] = array(get_string("grade", "customlesson").":", $grade."%");
}
echo html_writer::table($table);
// Don't want this class for later tables
$table->attributes['class'] = '';
}
$table->align = array('left', 'left');
$table->size = array('70%', null);
$table->attributes['class'] = 'compacttable generaltable';
foreach ($answerpages as $page) {
unset($table->data);
if ($page->grayout) { // set the color of text
$fontstart = "<span class=\"dimmed\">";
$fontend = "</font>";
$fontstart2 = $fontstart;
$fontend2 = $fontend;
} else {
$fontstart = "";
$fontend = "";
$fontstart2 = "";
$fontend2 = "";
}
$table->head = array($fontstart2.$page->qtype.": ".format_string($page->title).$fontend2, $fontstart2.get_string("classstats", "customlesson").$fontend2);
$table->data[] = array($fontstart.get_string("question", "customlesson").": <br />".$fontend.$fontstart2.$page->contents.$fontend2, " ");
$table->data[] = array($fontstart.get_string("answer", "customlesson").":".$fontend, ' ');
// apply the font to each answer
if (!empty($page->answerdata)) {
foreach ($page->answerdata->answers as $answer){
$modified = array();
foreach ($answer as $single) {
// need to apply a font to each one
$modified[] = $fontstart2.$single.$fontend2;
}
$table->data[] = $modified;
}
if (isset($page->answerdata->response)) {
$table->data[] = array($fontstart.get_string("response", "customlesson").": <br />".$fontend.$fontstart2.format_text($page->answerdata->response,$page->answerdata->responseformat,$formattextdefoptions).$fontend2, " ");
}
$table->data[] = array($page->answerdata->score, " ");
} else {
$table->data[] = array(get_string('didnotanswerquestion', 'customlesson'), " ");
}
echo html_writer::table($table);
}
} else {
print_error('unknowaction');
}
/// Finish the page
echo $OUTPUT->footer();