This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teacherview.subcontroller.php
107 lines (92 loc) · 4.33 KB
/
teacherview.subcontroller.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
<?php
/**
* @package mod-scheduler
* @category mod
* @author Valery Fremaux > 1.8
*
* This is a controller for major teacher side use cases
*
* @usecase addappointed
* @usecase updateappointed
* @usecase doremoveappointed
* @usecase doaddappointed
*/
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from view.php in mod/scheduler
}
switch($subaction){
/**************************** Make form for adding a student for appointment *************************************/
case 'addappointed':
get_slot_data($form);
$form->what = $action;
$form->appointments = unserialize(stripslashes(required_param('appointments', PARAM_RAW)));
$form->subaction = 'doaddappointed';
$form->studentid = 0;
$form->attended = 0;
$form->grade = '';
$form->slotid = optional_param('slotid', -1, PARAM_INT);
print_heading(get_string('appointingstudent', 'scheduler'), 'center', 3);
print_simple_box_start('center', '', '');
include_once('appoint.html');
print_simple_box_end();
echo '<br />';
// return code for include
return -1;
/**************************** Make form for updating an appointed student *************************************/
case 'updateappointed':
$studentid = required_param('studentid', PARAM_INT);
$form->what = $action;
get_slot_data($form);
$form->appointments = unserialize(stripslashes(optional_param('appointments', '', PARAM_RAW)));
$form->appointmentssaved = unserialize(stripslashes(optional_param('appointments', '', PARAM_RAW)));
$form->studentid = $studentid;
$form->slotid = optional_param('slotid', 0, PARAM_INT);
$form->attended = $form->appointments[$studentid]->attended;
$form->grade = $form->appointments[$studentid]->grade;
$form->appointmentnote = $form->appointments[$studentid]->appointmentnote;
// play again this appointment
unset($form->appointments[$studentid]);
print_heading(get_string('updatingappointment', 'scheduler'), 'center', 3);
print_simple_box_start('center', '', '');
include_once('appoint.html');
print_simple_box_end();
echo '<br />';
// return code for include
return -1;
/**************************** Removes an appointed student from list *************************************/
case 'doremoveappointed':
unset($erroritem);
$erroritem->message = get_string('dontforgetsaveadvice', 'scheduler');
$erroritem->on = '';
$errors[] = $erroritem;
get_slot_data($form);
$form->what = 'doaddupdateslot';
$form->studentid = optional_param('studentid', '', PARAM_INT);
if (!empty($form->studentid)){
$form->appointments = unserialize(stripslashes(optional_param('appointments', '', PARAM_RAW)));
unset($form->appointments[$form->studentid]);
}
$form->availableslots = scheduler_get_available_slots($form->studentid, $scheduler->id);
$form->slotid = optional_param('slotid', -1, PARAM_INT);
break;
/**************************** Adds a student to appointed list *************************************/
case 'doaddappointed':
unset($erroritem);
$erroritem->message = get_string('dontforgetsaveadvice', 'scheduler');
$erroritem->on = '';
$errors[] = $erroritem;
get_slot_data($form);
$form->what = 'doaddupdateslot';
$form->appointments = unserialize(stripslashes(required_param('appointments', PARAM_RAW)));
$form->slotid = optional_param('slotid', -1, PARAM_INT);
$form->studentid = $appointment->studentid = required_param('studenttoadd', PARAM_INT);
$form->availableslots = scheduler_get_available_slots($form->studentid, $scheduler->id);
$appointment->attended = optional_param('attended', 0, PARAM_INT);
$appointment->appointmentnote = optional_param('appointmentnote', '', PARAM_TEXT);
$appointment->grade = optional_param('grade', 0, PARAM_CLEAN);
$appointment->timecreated = time();
$appointment->timemodified = time();
$form->appointments[$appointment->studentid] = $appointment;
break;
}
?>