forked from WebPA/WebPA
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
206 lines (167 loc) · 7.66 KB
/
index.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
<?php
/**
*
* INDEX - Student index
*
*
* @copyright 2007 Loughborough University
* @license http://www.gnu.org/licenses/gpl.txt
* @version 1.0.0.0
*
*/
require_once("../includes/inc_global.php");
require_once('../includes/classes/class_group_handler.php');
require_once('../includes/classes/class_simple_object_iterator.php');
require_once('../includes/functions/lib_university_functions.php');
require_once('../includes/classes/class_assessment.php');
if (!check_user($_user, APP__USER_TYPE_STUDENT)){
header('Location:'. APP__WWW .'/logout.php?msg=denied');
exit;
}
// --------------------------------------------------------------------------------
global $group_handler;
$group_handler = new GroupHandler();
// Get a list of collections that the user is a member of
$collections = $group_handler->get_member_collections($_user->id, APP__ID, 'assessment');
$collection_ids = array_extract_column($collections, 'collection_id');
$collection_clause = $DB->build_set($collection_ids);
// Get a list of assessments that match the user's collections (for this year)
$academic_year = get_academic_year();
$start_date = mktime(0, 0, 0, APP__ACADEMIC_YEAR_START_MONTH, 1, $academic_year);
$end_date = mktime(0, 0, 0, APP__ACADEMIC_YEAR_START_MONTH, 1, $academic_year + 1);
$sql_start_date = date(MYSQL_DATETIME_FORMAT, $start_date);
$sql_end_date = date(MYSQL_DATETIME_FORMAT, $end_date);
$assessments = $DB->fetch('SELECT a.* FROM ' . APP__DB_TABLE_PREFIX . 'assessment a ' .
"WHERE (a.module_id = {$_module_id}) AND " .
"(a.collection_id IN $collection_clause) AND " .
"(a.open_date >= '{$sql_start_date}') AND " .
"(a.open_date < '{$sql_end_date}') " .
'ORDER BY a.open_date, a.close_date, a.assessment_name');
// Get a list of those assessments that the user has already taken
$assessment_ids = array_extract_column($assessments, 'assessment_id');
$assessment_clause = $DB->build_set($assessment_ids);
$assessments_with_response = $DB->fetch_col('SELECT DISTINCT um.assessment_id ' .
'FROM ' . APP__DB_TABLE_PREFIX . 'user_mark um ' .
"WHERE (a.module_id = {$_module_id}) AND " .
"(um.assessment_id IN {$assessment_clause}) AND " .
"(um.user_id = {$_user->id}) " .
'ORDER BY um.assessment_id');
// Split the assessments into pending, open and finished
$pending_assessments = null;
$open_assessments = null;
$finished_assessments = null;
if ($assessments) {
foreach($assessments as $i => $assessment) {
if ( (is_array($assessments_with_response)) && (in_array($assessment['assessment_id'], $assessments_with_response)) ) {
$finished_assessments[] = $assessment;
} else {
$now = time();
$open_date = strtotime($assessment['open_date']);
$close_date = strtotime($assessment['close_date']);
if ($close_date<=$now) {
$finished_assessments[] = $assessment;
} else {
if ($open_date>$now) {
$pending_assessments[] = $assessment;
} else {
$open_assessments[] = $assessment;
}
}
}
}
}
//------------------------------------------------
//strings to be used in the page
$getting_help = gettext('You will need to seek help from your tutor.');
// --------------------------------------------------------------------------------
// Begin Page
$UI->page_title = APP__NAME;
$UI->menu_selected = 'home';
$UI->breadcrumbs = array ('home' => null ,
);
$UI->help_link = '?q=node/329';
$UI->head();
$UI->body();
$UI->content_start();
?>
<p><?php echo gettext('Welcome to WebPA, the easiest way for you to complete your peer assessment on the web.');?></p>
<div class="content_box">
<?php
if (!$open_assessments) {
?>
<p><?php echo gettext('There are no assessments in this module available for you to take at the moment.');?></p>
<p><?php echo gettext('To view all the assessments you are registered on, please check the <a href="assessments/">my assessments</a> section.');?></p>
<?php
} else {
?>
<p><?php echo gettext('Below is a list of the assessments in this module you can take now.');?></p>
<p><?php echo gettext('To view all the assessments you are registered on in this module, please check the <a href="assessments/">my assessments</a> section.');?></p>
<h2><?php echo gettext('Open Assessments');?></h2>
<div class="form_section">
<?php
$status = 'open';
$status_capitalized = ucfirst($status);
$assessment_iterator = new SimpleObjectIterator($open_assessments,'Assessment','$DB');
for ($assessment_iterator->reset(); $assessment_iterator->is_valid(); $assessment_iterator->next()) {
$assessment =& $assessment_iterator->current();
$take_url = "assessments/take/index.php?a={$assessment->id}";
echo("<div class=\"assessment_open\">");
echo('<table class="assessment_info" cellpadding="0" cellspacing="0">');
echo('<tr>');
echo(" <td width=\"24\"><img src=\"../images/icons/{$status}_icon.gif\" alt=\"$status_capitalized\" title=\"$status_capitalized\" height=\"24\" width=\"24\" /></td>");
echo(' <td valign="top">');
echo(' <div class="assessment_info">');
echo(" <div class=\"assessment_name\">{$assessment->name}</div>");
echo(' <div class="assessment_schedule">'.gettext('scheduled:').' '.$assessment->get_date_string('open_date') .' - '. $assessment->get_date_string('close_date') . ' </div>');
echo(' </div>');
echo(' </td>');
echo(' <td class="buttons" style="line-height: 2em; text-align: right;">');
echo(" <a class=\"button\" href=\"$take_url\">".gettext('Take Assessment')."</a>");
echo(' </td>');
echo('</tr>');
echo('</table>');
echo('</div>');
}
?>
</div>
<?php
}
if ($pending_assessments) {
?>
<h2><?php echo gettext('Pending Assessments');?></h2>
<p><?php echo gettext('These assessments scheduled for some point in the future.');?></p>
<div class="form_section form_line">
<?php
$status = 'pending';
$status_capitalized = ucfirst($status);
$assessment_iterator = new SimpleObjectIterator($pending_assessments,'Assessment','$DB');
for ($assessment_iterator->reset(); $assessment_iterator->is_valid(); $assessment_iterator->next()) {
$assessment =& $assessment_iterator->current();
$take_url = "/assessments/take/index.php?a={$assessment->id}";
echo("<div class=\"assessment\">");
echo('<table class="assessment_info" cellpadding="0" cellspacing="0">');
echo('<tr>');
echo(" <td width=\"24\"><img src=\"/images/icons/{$status}_icon.gif\" alt=\"$status_capitalized\" title=\"$status_capitalized\" height=\"24\" width=\"24\" /></td>");
echo(' <td valign="top">');
echo(' <div class="assessment_info">');
echo(" <div class=\"assessment_name\">{$assessment->name}</div>");
echo(' <div class="assessment_schedule">'.gettext('scheduled:').' '.$assessment->get_date_string('open_date') .' - '. $assessment->get_date_string('close_date') . ' </div>');
echo(' </div>');
echo(' </td>');
echo('</tr>');
echo('</table>');
echo('</div>');
}
?>
</div>
<?php
}
?>
</div>
<h2><?php echo gettext('Getting Help'); ?></h2>
<p><?php
echo $getting_help;
?></p>
<?php
$UI->content_end();
?>