-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewstudent.php
More file actions
114 lines (103 loc) · 4.4 KB
/
Copy pathviewstudent.php
File metadata and controls
114 lines (103 loc) · 4.4 KB
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
<?php
/**
* Prints the screen that displays a single student to a teacher.
*
* @package mod
* @subpackage simplescheduler
* @copyright 2013 Nathan White and others (see README.txt)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @todo eliminate save comment javascript method in place of a save button at the bottom.
*/
defined('MOODLE_INTERNAL') || die();
require_once $CFG->dirroot.'/mod/simplescheduler/locallib.php';
$studentid = required_param('studentid', PARAM_INT);
$order = optional_param('order','ASC',PARAM_ALPHA);
if (!in_array($order,array('ASC','DESC'))) {
$order='ASC';
}
$usehtmleditor = can_use_html_editor();
if ($subaction != ''){
include $CFG->dirroot.'/mod/simplescheduler/viewstudent.controller.php';
}
simplescheduler_print_user($DB->get_record('user', array('id' => $studentid)), $course);
//print tabs
$tabrows = array();
$row = array();
if($page == 'appointments'){
$currenttab = get_string('appointments', 'simplescheduler');
} else {
$currenttab = get_string('notes', 'simplescheduler');
}
$tabname = get_string('appointments', 'simplescheduler');
$row[] = new tabobject($tabname, "view.php?what=viewstudent&id={$cm->id}&studentid={$studentid}&course={$simplescheduler->course}&order={$order}&page=appointments", $tabname);
$tabrows[] = $row;
print_tabs($tabrows, $currenttab);
/// if slots have been booked
$sql = "
SELECT
s.*,
a.id as appid,
a.studentid,
a.appointmentnote,
a.timemodified as apptimemodified
FROM
{simplescheduler_slots} s,
{simplescheduler_appointment} a
WHERE
s.id = a.slotid AND
simpleschedulerid = ? AND
studentid = ?
ORDER BY
starttime $order
";
if ($slots = $DB->get_records_sql($sql, array($simplescheduler->id, $studentid, $order))) {
/// provide link to sort in the opposite direction
if($order == 'DESC'){
$orderlink = "<a href=\"view.php?what=viewstudent&id=$cm->id&studentid=".$studentid."&course=$simplescheduler->course&order=ASC&page=$page\">";
} else {
$orderlink = "<a href=\"view.php?what=viewstudent&id=$cm->id&studentid=".$studentid."&course=$simplescheduler->course&order=DESC&page=$page\">";
}
$table = new html_table();
/// print page header and prepare table headers
if ($page == 'appointments'){
echo $OUTPUT->heading(get_string('slots' ,'simplescheduler'));
$table->head = array ($strdate, $strstart, $strend, $strnote, s(simplescheduler_get_teacher_name($simplescheduler)));
$table->align = array ('LEFT', 'LEFT', 'LEFT', 'LEFT', 'LEFT');
$table->width = '80%';
}
foreach($slots as $slot) {
$startdate = simplescheduler_userdate($slot->starttime,1);
$starttime = simplescheduler_usertime($slot->starttime,1);
$endtime = simplescheduler_usertime($slot->starttime + ($slot->duration * 60),1);
$distributecheck = '';
if ($page == 'appointments'){
if ($DB->count_records('simplescheduler_appointment', array('slotid' => $slot->id)) > 1){
$distributecheck = "<br/><input type=\"checkbox\" name=\"distribute{$slot->appid}\" value=\"1\" /> ".get_string('distributetoslot', 'simplescheduler')."\n";
}
//display appointments
//$slot->appointmentnote .= "<br/><span class=\"timelabel\">[".userdate($slot->apptimemodified)."]</span>";
$teacher = $DB->get_record('user', array('id'=>$slot->teacherid));
$table->data[] = array ($startdate, $starttime, $endtime, $slot->appointmentnote, fullname($teacher));
}
}
// print slots table
if ($page == 'appointments'){
echo '<form name="studentform" action="view.php" method="post">';
echo "<input type=\"hidden\" name=\"id\" value=\"{$cm->id}\" />\n";
echo "<input type=\"hidden\" name=\"subaction\" value=\"updategrades\" />\n";
echo "<input type=\"hidden\" name=\"what\" value=\"viewstudent\" />\n";
echo "<input type=\"hidden\" name=\"page\" value=\"appointments\" />\n";
echo "<input type=\"hidden\" name=\"studentid\" value=\"{$studentid}\" />\n";
}
echo html_writer::table($table);
if ($page == 'appointments'){
echo '</form>';
}
}
echo $OUTPUT->continue_button($CFG->wwwroot.'/mod/simplescheduler/view.php?id='.$cm->id);
return;
/// Finish the page
echo $OUTPUT->footer($course);
exit;
?>