-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadmin.php
70 lines (59 loc) · 2.23 KB
/
admin.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
<?php
require_once "../config.php";
use \Tsugi\Blob\BlobUtil;
require_once "peer_util.php";
use \Tsugi\UI\Table;
use \Tsugi\Core\LTIX;
// Sanity checks
$LAUNCH = LTIX::requireData();
if ( ! $USER->instructor ) die("Requires instructor role");
$p = $CFG->dbprefix;
// Load the assignment data
$row = loadAssignment();
$assn_json = json_decode(upgradeSubmission($row['json']));
if ( $assn_json == null ) die('Not yet configured');
// Gets counts and max of the submissions
$query_parms = array(":LID" => $LINK->id);
$orderfields = array("S.user_id", "displayname", "email", "S.updated_at", "user_key", "S.rating", "max_score", "scores", "flagged", "min_score", "inst_points");
$searchfields = array("S.user_id", "displayname", "email", "S.updated_at", "user_key");
// Load up our data dpending on the kind of assessment we have
$inst_points = $assn_json->instructorpoints > 0 ? "inst_points, " : "";
$max_min_scores = $assn_json->peerpoints > 0 ? "MAX(points) as max_score, MIN(points) AS min_score," : "";
$count_scores = $assn_json->maxassess > 0 ? "COUNT(points) as scores," : "";
$ratings = $assn_json->rating > 0 ? "S.rating AS rating," : "";
$sql =
"SELECT S.user_id AS user_id, displayname, email, S.submit_id as _submit_id,
$max_min_scores
$ratings
$count_scores
$inst_points
COUNT(DISTINCT flag_id) as flagged,
MAX(S.updated_at) AS updated_at, user_key
FROM {$p}peer_assn AS A JOIN {$p}peer_submit as S
ON A.assn_id = S.assn_id
LEFT JOIN {$p}peer_grade AS G
ON S.submit_id = G.submit_id
LEFT JOIN {$p}peer_flag AS F
ON S.submit_id = F.submit_id
JOIN {$p}lti_user AS U
ON S.user_id = U.user_id
WHERE A.link_id = :LID
GROUP BY S.submit_id";
$menu = new \Tsugi\UI\MenuSet();
if ( $USER->instructor ) {
$menu->addLeft('Done', 'index.php');
}
// View
$OUTPUT->header();
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
$OUTPUT->flashMessages();
$OUTPUT->welcomeUserCourse();
// Make us a paged table and by default sort by flagged descending
$parm = $_GET;
if ( ! isset($parm['order_by']) ) {
$parm['order_by'] = 'flagged';
$parm['desc'] = '1';
}
Table::pagedAuto($sql, $query_parms, $searchfields, $orderfields, "student.php", $parm );
$OUTPUT->footer();