-
Notifications
You must be signed in to change notification settings - Fork 86
/
teacherview.php
676 lines (544 loc) · 25.7 KB
/
teacherview.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
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
<?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/>.
/**
* Contains various sub-screens that a teacher can see.
*
* @package mod_scheduler
* @copyright 2016 Henning Bostelmann and others (see README.txt)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use \mod_scheduler\model\scheduler;
/**
* Print a selection box of existing slots to be scheduler in
*
* @param scheduler $scheduler
* @param int $studentid student to schedule
* @param int $groupid group to schedule
*/
function scheduler_print_schedulebox(scheduler $scheduler, $studentid, $groupid = 0) {
global $output;
$availableslots = $scheduler->get_slots_available_to_student($studentid);
$startdatemem = '';
$starttimemem = '';
$availableslotsmenu = array();
foreach ($availableslots as $slot) {
$startdatecnv = $output->userdate($slot->starttime);
$starttimecnv = $output->usertime($slot->starttime);
$startdatestr = ($startdatemem != '' && $startdatemem == $startdatecnv) ? "-----------------" : $startdatecnv;
$starttimestr = ($starttimemem != '' && $starttimemem == $starttimecnv) ? '' : $starttimecnv;
$startdatemem = $startdatecnv;
$starttimemem = $starttimecnv;
$url = new moodle_url('/mod/scheduler/view.php',
array('id' => $scheduler->cmid, 'slotid' => $slot->id, 'sesskey' => sesskey()));
if ($groupid) {
$url->param('what', 'schedulegroup');
$url->param('subaction', 'dochooseslot');
$url->param('groupid', $groupid);
} else {
$url->param('what', 'schedule');
$url->param('subaction', 'dochooseslot');
$url->param('studentid', $studentid);
}
$availableslotsmenu[$url->out()] = "$startdatestr $starttimestr";
}
$chooser = new url_select($availableslotsmenu);
if ($availableslots) {
echo $output->box_start();
echo $output->heading(get_string('chooseexisting', 'scheduler'), 3);
echo $output->render($chooser);
echo $output->box_end();
}
}
// Load group restrictions.
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = false;
if ($groupmode) {
$currentgroup = groups_get_activity_group($cm, true);
}
// All group arrays in the following are in the format used by groups_get_all_groups.
// The special value '' (empty string) is used to signal "all groups" (no restrictions).
// Find groups which the current teacher can see ($groupsicansee, $groupsicurrentlysee).
// $groupsicansee contains all groups that a teacher potentially has access to.
// $groupsicurrentlysee may be restricted by the user to one group, using the drop-down box.
$userfilter = $USER->id;
if (has_capability('moodle/site:accessallgroups', $context)) {
$userfilter = 0;
}
$groupsicansee = '';
$groupsicurrentlysee = '';
if ($groupmode) {
if ($userfilter) {
$groupsicansee = groups_get_all_groups($COURSE->id, $userfilter, $cm->groupingid);
}
$groupsicurrentlysee = $groupsicansee;
if ($currentgroup) {
if ($userfilter && !groups_is_member($currentgroup, $userfilter)) {
$groupsicurrentlysee = array();
} else {
$cgobj = groups_get_group($currentgroup);
$groupsicurrentlysee = array($currentgroup => $cgobj);
}
}
}
// Find groups which the current teacher can schedule as a group ($groupsicanschedule).
$groupsicanschedule = array();
if ($scheduler->is_group_scheduling_enabled()) {
$groupsicanschedule = groups_get_all_groups($COURSE->id, $userfilter, $scheduler->bookingrouping);
}
// Find groups which can book an appointment with the current teacher ($groupsthatcanseeme).
$groupsthatcanseeme = '';
if ($groupmode) {
$groupsthatcanseeme = groups_get_all_groups($COURSE->id, $USER->id, $cm->groupingid);
}
$taburl = new moodle_url('/mod/scheduler/view.php', array('id' => $scheduler->cmid, 'what' => 'view', 'subpage' => $subpage));
$baseurl = new moodle_url('/mod/scheduler/view.php', array(
'id' => $scheduler->cmid,
'subpage' => $subpage,
'offset' => $offset
));
// The URL that is used for jumping back to the view (e.g., after an action is performed).
$viewurl = new moodle_url($baseurl, array('what' => 'view'));
$PAGE->set_url($viewurl);
if ($action != 'view') {
require_once($CFG->dirroot.'/mod/scheduler/slotforms.php');
require_once($CFG->dirroot.'/mod/scheduler/teacherview.controller.php');
}
/************************************ View : New single slot form ****************************************/
if ($action == 'addslot') {
$permissions->ensure($permissions->can_edit_own_slots());
$actionurl = new moodle_url($baseurl, array('what' => 'addslot'));
if (!$scheduler->has_available_teachers()) {
throw new moodle_exception('needteachers', 'scheduler', $viewurl);
}
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee);
if ($mform->is_cancelled()) {
redirect($viewurl);
} else if ($formdata = $mform->get_data()) {
$slot = $mform->save_slot(0, $formdata);
\mod_scheduler\event\slot_added::create_from_slot($slot)->trigger();
redirect($viewurl,
get_string('oneslotadded', 'scheduler'),
0,
\core\output\notification::NOTIFY_SUCCESS);
} else {
echo $output->header();
echo $output->heading(get_string('addsingleslot', 'scheduler'));
$mform->display();
echo $output->footer($course);
die;
}
}
/************************************ View : Update single slot form ****************************************/
if ($action == 'updateslot') {
$slotid = required_param('slotid', PARAM_INT);
$slot = $scheduler->get_slot($slotid);
$permissions->ensure($permissions->can_edit_slot($slot));
if ($slot->starttime % 300 !== 0 || $slot->duration % 5 !== 0) {
$timeoptions = array('step' => 1, 'optional' => false);
} else {
$timeoptions = array('step' => 5, 'optional' => false);
}
$actionurl = new moodle_url($baseurl, array('what' => 'updateslot', 'slotid' => $slotid));
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee, array(
'slotid' => $slotid,
'timeoptions' => $timeoptions)
);
$data = $mform->prepare_formdata($slot);
$mform->set_data($data);
if ($mform->is_cancelled()) {
redirect($viewurl);
} else if ($formdata = $mform->get_data()) {
$mform->save_slot($slotid, $formdata);
redirect($viewurl,
get_string('slotupdated', 'scheduler'),
0,
\core\output\notification::NOTIFY_SUCCESS);
} else {
echo $output->header();
echo $output->heading(get_string('updatesingleslot', 'scheduler'));
$mform->display();
echo $output->footer($course);
die;
}
}
/************************************ Add session multiple slots form ****************************************/
if ($action == 'addsession') {
$permissions->ensure($permissions->can_edit_own_slots());
$actionurl = new moodle_url($baseurl, array('what' => 'addsession'));
if (!$scheduler->has_available_teachers()) {
throw new moodle_exception('needteachers', 'scheduler', $viewurl);
}
$mform = new scheduler_addsession_form($actionurl, $scheduler, $cm, $groupsicansee);
if ($mform->is_cancelled()) {
redirect($viewurl);
} else if ($formdata = $mform->get_data()) {
scheduler_action_doaddsession($scheduler, $formdata, $viewurl);
} else {
echo $output->header();
echo $output->heading(get_string('addsession', 'scheduler'));
$mform->display();
echo $output->footer();
die;
}
}
/************************************ Schedule a student form ***********************************************/
if ($action == 'schedule') {
$permissions->ensure($permissions->can_edit_own_slots());
echo $output->header();
if ($subaction == 'dochooseslot') {
$slotid = required_param('slotid', PARAM_INT);
$slot = $scheduler->get_slot($slotid);
$studentid = required_param('studentid', PARAM_INT);
$actionurl = new moodle_url($baseurl, array('what' => 'updateslot', 'slotid' => $slotid));
$repeats = $slot->get_appointment_count() + 1;
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee,
array('slotid' => $slotid, 'repeats' => $repeats));
$data = $mform->prepare_formdata($slot);
$data->studentid[] = $studentid;
$mform->set_data($data);
echo $output->heading(get_string('updatesingleslot', 'scheduler'), 2);
$mform->display();
} else if (empty($subaction)) {
$studentid = required_param('studentid', PARAM_INT);
$student = $DB->get_record('user', array('id' => $studentid), '*', MUST_EXIST);
$actionurl = new moodle_url($baseurl, array('what' => 'addslot'));
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee);
$data = array();
$data['studentid'][0] = $studentid;
$mform->set_data($data);
echo $output->heading(get_string('scheduleappointment', 'scheduler', fullname($student)));
scheduler_print_schedulebox($scheduler, $studentid);
echo $output->box_start();
echo $output->heading(get_string('scheduleinnew', 'scheduler'), 3);
$mform->display();
echo $output->box_end();
}
echo $output->footer();
die();
}
/************************************ Schedule a whole group in form ***********************************************/
if ($action == 'schedulegroup') {
$permissions->ensure($permissions->can_edit_own_slots());
$groupid = required_param('groupid', PARAM_INT);
$group = $DB->get_record('groups', array('id' => $groupid), '*', MUST_EXIST);
$members = groups_get_members($groupid);
echo $output->header();
if ($subaction == 'dochooseslot') {
$slotid = required_param('slotid', PARAM_INT);
$groupid = required_param('groupid', PARAM_INT);
$slot = $scheduler->get_slot($slotid);
$actionurl = new moodle_url($baseurl, array('what' => 'updateslot', 'slotid' => $slotid));
$repeats = $slot->get_appointment_count() + count($members);
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee,
array('slotid' => $slotid, 'repeats' => $repeats));
$data = $mform->prepare_formdata($slot);
foreach ($members as $member) {
$data->studentid[] = $member->id;
}
$mform->set_data($data);
echo $output->heading(get_string('updatesingleslot', 'scheduler'), 3);
$mform->display();
} else if (empty($subaction)) {
$actionurl = new moodle_url($baseurl, array('what' => 'addslot'));
$data = array();
$i = 0;
foreach ($members as $member) {
$data['studentid'][$i] = $member->id;
$i++;
}
$data['exclusivity'] = $i;
$mform = new scheduler_editslot_form($actionurl, $scheduler, $cm, $groupsicansee, array('repeats' => $i));
$mform->set_data($data);
echo $output->heading(get_string('scheduleappointment', 'scheduler', $group->name));
scheduler_print_schedulebox($scheduler, 0, $groupid);
echo $output->box_start();
echo $output->heading(get_string('scheduleinnew', 'scheduler'), 3);
$mform->display();
echo $output->box_end();
}
echo $output->footer();
die();
}
/************************************ Send message to students ****************************************/
if ($action == 'sendmessage') {
$permissions->ensure($permissions->can_edit_own_slots());
require_once($CFG->dirroot.'/mod/scheduler/message_form.php');
$template = optional_param('template', 'none', PARAM_ALPHA);
$recipientids = required_param('recipients', PARAM_SEQUENCE);
$actionurl = new moodle_url('/mod/scheduler/view.php',
array('what' => 'sendmessage', 'id' => $cm->id, 'subpage' => $subpage,
'template' => $template, 'recipients' => $recipientids));
$templatedata = array();
if ($template != 'none') {
$vars = scheduler_messenger::get_scheduler_variables($scheduler, null, $USER, null, $COURSE, null);
$templatedata['subject'] = scheduler_messenger::compile_mail_template($template, 'subject', $vars);
$templatedata['body'] = scheduler_messenger::compile_mail_template($template, 'html', $vars);
}
$templatedata['recipients'] = $DB->get_records_list('user', 'id', explode(',', $recipientids), 'lastname,firstname');
$mform = new scheduler_message_form($actionurl, $scheduler, $templatedata);
if ($mform->is_cancelled()) {
redirect($viewurl);
} else if ($formdata = $mform->get_data()) {
scheduler_action_dosendmessage($scheduler, $formdata, $viewurl);
} else {
echo $output->header();
echo $output->heading(get_string('sendmessage', 'scheduler'));
$mform->display();
echo $output->footer();
die;
}
}
/****************** Standard view ***********************************************/
// Trigger view event.
\mod_scheduler\event\appointment_list_viewed::create_from_scheduler($scheduler)->trigger();
// Print top tabs.
$actionurl = new moodle_url($viewurl, array('sesskey' => sesskey()));
$inactive = array();
if ($DB->count_records('scheduler_slots', array('schedulerid' => $scheduler->id)) <=
$DB->count_records('scheduler_slots', array('schedulerid' => $scheduler->id, 'teacherid' => $USER->id)) ) {
// We are alone in this scheduler.
$inactive[] = 'allappointments';
if ($subpage = 'allappointments') {
$subpage = 'myappointments';
}
}
echo $output->header();
echo $output->teacherview_tabs($scheduler, $permissions, $taburl, $subpage, $inactive);
if ($groupmode) {
if ($subpage == 'allappointments') {
groups_print_activity_menu($cm, $taburl);
} else {
$a = new stdClass();
$a->groupmode = get_string($groupmode == VISIBLEGROUPS ? 'groupsvisible' : 'groupsseparate');
$groupnames = array();
foreach ($groupsthatcanseeme as $id => $group) {
$groupnames[] = $group->name;
}
$a->grouplist = implode(', ', $groupnames);
$messagekey = $groupsthatcanseeme ? 'groupmodeyourgroups' : 'groupmodeyourgroupsempty';
$message = get_string($messagekey, 'scheduler', $a);
echo html_writer::div($message, 'groupmodeyourgroups');
}
}
if ($subpage == 'allappointments') {
$teacherid = 0;
$slotgroup = $currentgroup;
} else {
$teacherid = $USER->id;
$slotgroup = 0;
$subpage = 'myappointments';
}
$sqlcount = $scheduler->count_slots_for_teacher($teacherid, $slotgroup);
$pagesize = 25;
if ($offset == -1) {
if ($sqlcount > $pagesize) {
$offsetcount = $scheduler->count_slots_for_teacher($teacherid, $slotgroup, true);
$offset = floor($offsetcount / $pagesize);
} else {
$offset = 0;
}
}
if ($offset * $pagesize >= $sqlcount && $sqlcount > 0) {
$offset = floor(($sqlcount - 1) / $pagesize);
}
$slots = $scheduler->get_slots_for_teacher($teacherid, $slotgroup, $offset * $pagesize, $pagesize);
echo $output->heading(get_string('slots', 'scheduler'));
// Print instructions and button for creating slots.
$key = ($slots) ? 'addslot' : 'welcomenewteacher';
echo html_writer::div(get_string($key, 'scheduler'));
$commandbar = new scheduler_command_bar();
$commandbar->title = get_string('actions', 'scheduler');
$addbuttons = array();
$addbuttons[] = $commandbar->action_menu_link(new moodle_url($actionurl, array('what' => 'addsession')), 'addsession', 't/add');
$addbuttons[] = $commandbar->action_menu_link(new moodle_url($actionurl, array('what' => 'addslot')), 'addsingleslot', 't/add');
$commandbar->add_group(get_string('addcommands', 'scheduler'), $addbuttons);
// If slots already exist, also show delete buttons.
if ($slots) {
$delbuttons = array();
$delselectedurl = new moodle_url($actionurl, array('what' => 'deleteslots'));
$PAGE->requires->js_call_amd('mod_scheduler/delselected', 'init', [$delselectedurl->out(false)]);
$delselected = $commandbar->action_menu_link($delselectedurl, 'deleteselection', 't/delete',
'confirmdelete-selected', 'delselected');
$delselected->formid = 'delselected';
$delbuttons[] = $delselected;
if ($permissions->can_edit_all_slots() && $subpage == 'allappointments') {
$delbuttons[] = $commandbar->action_menu_link(
new moodle_url($actionurl, array('what' => 'deleteall')),
'deleteallslots', 't/delete', 'confirmdelete-all');
$delbuttons[] = $commandbar->action_menu_link(
new moodle_url($actionurl, array('what' => 'deleteallunused')),
'deleteallunusedslots', 't/delete', 'confirmdelete-unused');
}
$delbuttons[] = $commandbar->action_menu_link(
new moodle_url($actionurl, array('what' => 'deleteunused')),
'deleteunusedslots', 't/delete', 'confirmdelete-myunused');
$delbuttons[] = $commandbar->action_menu_link(
new moodle_url($actionurl, array('what' => 'deleteonlymine')),
'deletemyslots', 't/delete', 'confirmdelete-mine');
$commandbar->add_group(get_string('deletecommands', 'scheduler'), $delbuttons);
}
echo $output->render($commandbar);
// Some slots already exist - prepare the table of slots.
if ($slots) {
$slotman = new scheduler_slot_manager($scheduler, $actionurl);
$slotman->showteacher = ($subpage == 'allappointments');
foreach ($slots as $slot) {
$editable = $permissions->can_edit_slot($slot);
$studlist = new scheduler_student_list($slotman->scheduler);
$studlist->expandable = false;
$studlist->expanded = true;
$studlist->editable = $editable;
$studlist->linkappointment = true;
$studlist->checkboxname = 'seen[]';
$studlist->buttontext = get_string('saveseen', 'scheduler');
$studlist->actionurl = new moodle_url($actionurl, array('what' => 'saveseen', 'slotid' => $slot->id));
foreach ($slot->get_appointments() as $app) {
$studlist->add_student($app, false, $app->is_attended(), true, $scheduler->uses_studentdata(),
$permissions->can_edit_attended($app));
}
$slotman->add_slot($slot, $studlist, $editable);
}
echo $output->render($slotman);
if ($sqlcount > $pagesize) {
echo $output->paging_bar($sqlcount, $offset, $pagesize, $actionurl, 'offset');
}
// Instruction for teacher to click Seen box after appointment.
echo html_writer::div(get_string('markseen', 'scheduler'));
}
$groupfilter = ($subpage == 'myappointments') ? $groupsthatcanseeme : $groupsicurrentlysee;
$maxlistsize = get_config('mod_scheduler', 'maxstudentlistsize');
$students = array();
$reminderstudents = array();
if ($groupfilter === '') {
$students = $scheduler->get_students_for_scheduling('', $maxlistsize);
if ($scheduler->allows_unlimited_bookings()) {
$reminderstudents = $scheduler->get_students_for_scheduling('', $maxlistsize, true);
} else {
$reminderstudents = $students;
}
} else if (count($groupfilter) > 0) {
$students = $scheduler->get_students_for_scheduling(array_keys($groupfilter), $maxlistsize);
if ($scheduler->allows_unlimited_bookings()) {
$reminderstudents = $scheduler->get_students_for_scheduling(array_keys($groupfilter), $maxlistsize, true);
} else {
$reminderstudents = $students;
}
}
if ($students === 0) {
$nostudentstr = get_string('noexistingstudents', 'scheduler');
if ($COURSE->id == SITEID) {
$nostudentstr .= '<br/>'.get_string('howtoaddstudents', 'scheduler');
}
echo $output->notification($nostudentstr, 'notifyproblem');
} else if (is_integer($students)) {
// There are too many students who still have to make appointments, don't display a list.
$toomanystr = get_string('missingstudentsmany', 'scheduler', $students);
echo $output->notification($toomanystr, 'notifymessage');
} else if (count($students) > 0) {
if (count($reminderstudents) > 0) {
$studids = implode(',', array_keys($reminderstudents));
$messageurl = new moodle_url($actionurl, array('what' => 'sendmessage', 'recipients' => $studids));
$invitationurl = new moodle_url($messageurl, array('template' => 'invite'));
$reminderurl = new moodle_url($messageurl, array('template' => 'invitereminder'));
$maildisplay = '';
$maildisplay .= html_writer::link($invitationurl, get_string('sendinvitation', 'scheduler'));
$maildisplay .= ' — ';
$maildisplay .= html_writer::link($reminderurl, get_string('sendreminder', 'scheduler'));
echo $output->box_start('maildisplay');
// Print number of students who still have to make an appointment.
echo $output->heading(get_string('missingstudents', 'scheduler', count($reminderstudents)), 3);
// Print e-mail addresses and mailto links.
echo $maildisplay;
echo $output->box_end();
}
$userfields = scheduler_get_user_fields(null, $context);
$fieldtitles = array();
foreach ($userfields as $f) {
$fieldtitles[] = $f->title;
}
$studtable = new scheduler_scheduling_list($scheduler, $fieldtitles);
$studtable->id = 'studentstoschedule';
foreach ($students as $student) {
$picture = $output->user_picture($student);
$name = $output->user_profile_link($scheduler, $student);
$actions = array();
$actions[] = new action_menu_link_secondary(
new moodle_url($actionurl, array('what' => 'schedule', 'studentid' => $student->id)),
new pix_icon('e/insert_date', '', 'moodle'),
get_string('scheduleinslot', 'scheduler') );
$actions[] = new action_menu_link_secondary(
new moodle_url($actionurl, array('what' => 'markasseennow', 'studentid' => $student->id)),
new pix_icon('t/approve', '', 'moodle'),
get_string('markasseennow', 'scheduler') );
$userfields = scheduler_get_user_fields($student, $context);
$fieldvals = array();
foreach ($userfields as $f) {
$fieldvals[] = $f->value;
}
$studtable->add_line($picture, $name, $fieldvals, $actions);
}
$divclass = 'schedulelist '.($scheduler->is_group_scheduling_enabled() ? 'halfsize' : 'fullsize');
echo html_writer::start_div($divclass);
echo $output->heading(get_string('schedulestudents', 'scheduler'), 3);
// Print table of students who still have to make appointments.
echo $output->render($studtable);
echo html_writer::end_div();
if ($scheduler->is_group_scheduling_enabled()) {
// Print list of groups that can be scheduled.
echo html_writer::start_div('schedulelist halfsize');
echo $output->heading(get_string('schedulegroups', 'scheduler'), 3);
if (empty($groupsicanschedule)) {
echo $output->notification(get_string('nogroups', 'scheduler'));
} else {
$grouptable = new scheduler_scheduling_list($scheduler, array());
$grouptable->id = 'groupstoschedule';
$groupcnt = 0;
foreach ($groupsicanschedule as $group) {
$members = groups_get_members($group->id, 'u.*', 'u.lastname, u.firstname');
if (empty($members)) {
continue;
}
if (!$scheduler->has_slots_booked_for_group($group->id, false, $scheduler->schedulermode == 'onetime')) {
$picture = print_group_picture($group, $course->id, false, true, true);
$name = $group->name;
$groupmembers = array();
foreach ($members as $member) {
$groupmembers[] = fullname($member);
}
$name .= ' ['. implode(', ', $groupmembers) . ']';
$actions = array();
$actions[] = new action_menu_link_secondary(
new moodle_url($actionurl, array('what' => 'schedulegroup', 'groupid' => $group->id)),
new pix_icon('e/insert_date', '', 'moodle'),
get_string('scheduleinslot', 'scheduler') );
$grouptable->add_line($picture, $name, array(), $actions);
$groupcnt++;
}
}
// Print table of groups that still need to make appointments.
if ($groupcnt > 0) {
echo $output->render($grouptable);
} else {
echo $output->notification(get_string('nogroups', 'scheduler'));
}
}
echo html_writer::end_div();
}
} else {
echo $output->notification(get_string('noexistingstudents', 'scheduler'));
}
echo $output->footer();