/
helpers.php
108 lines (94 loc) · 2.05 KB
/
helpers.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
<?php
/*
* general utility functions and constants
*/
require_once 'dom.php';
const CURRENT_YEAR = 2015;
const CURRENT_SEMESTER = 'spring';
/**
* list TA hours
*/
function list_ta_hours() {
$hours = array();
for ($i = 1; $i <= 20; $i++) {
$hours[$i] = $i;
}
return $hours;
}
function list_semesters() {
return array(
"fall" => "Fall",
"spring" => "Spring",
"summer1" => "Summer 1",
"summer2" => "Summer 2"
);
}
function list_years() {
$years = array();
for ($i=CURRENT_YEAR+1; $i > CURRENT_YEAR - 15; $i--) {
$years[$i] = $i;
}
return $years;
}
/**
* aggregates all data from schemas for
* the purpose of html drop down selectors
*/
function all_teachers_data() {
$teachers = array();
$all_teachers = get_all_profs();
while ($row = mysql_fetch_assoc($all_teachers)) {
$teachers[$row['id']] = $row['username'] . ' - ' . $row['first_name'] . " " . $row['last_name'];
}
return $teachers;
}
function all_sections_data() {
$sections = array();
$all_sections = get_all_sections();
while ($row = mysql_fetch_assoc($all_sections)) {
$sections[$row['id']] = $row['crn'];
}
return $sections;
}
function all_course_data() {
$courses = array();
$all_courses = get_all_courses();
while ($row = mysql_fetch_assoc($all_courses)) {
$courses[$row['id']] = $row['code'] . ' - ' . $row['title'];
}
return $courses;
}
function all_ta_data() {
$tas = array();
$all_tas = get_all_tas();
while ($row = mysql_fetch_assoc($all_tas)) {
$tas[$row['id']] = $row['first_name'] . ' ' . $row['last_name'];
}
return $tas;
}
function all_eraiders_data() {
$data = array();
$all = get_all_eraiders();
while ($row = mysql_fetch_assoc($all)) {
$data[$row['username']] = $row['username'] . ' - ' . $row['first_name'] . ' ' . $row['last_name'];
}
return $data;
}
/*
*
* php sucks...
*/
function bool($b) {
if ($b) {
return 'true';
} else {
return 'false';
}
}
function get($arr, $key, $default=null) {
if (isset($arr[$key])) {
return $arr[$key];
} else {
return $default;
}
}