forked from drlippman/IMathAS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgb-excuse.php
More file actions
91 lines (85 loc) · 3.42 KB
/
gb-excuse.php
File metadata and controls
91 lines (85 loc) · 3.42 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
<?php
//IMathAS: Excuse Assignment
//(c) 2018 David Lippman
require_once __DIR__ . '/../includes/checkdata.php';
if (!isset($imasroot)) {
echo "This file cannot be called directly";
exit;
}
$now = time();
if (!isset($_POST['assesschk'])) { $_POST['assesschk'] = array();}
if (!isset($_POST['offlinechk'])) { $_POST['offlinechk'] = array();}
if (!isset($_POST['discusschk'])) { $_POST['discusschk'] = array();}
if (!isset($_POST['exttoolchk'])) { $_POST['exttoolchk'] = array();}
if (!isset($_POST['stus'])) { $_POST['stus'] = array();}
if (!empty($_POST['assesschk'])) {
$_POST['assesschk'] = filter_items_by_course($_POST['assesschk'], 'imas_assessments', $cid);
}
if (!empty($_POST['offlinechk'])) {
$_POST['offlinechk'] = filter_items_by_course($_POST['offlinechk'], 'imas_gbitems', $cid);
}
if (!empty($_POST['discusschk'])) {
$_POST['discusschk'] = filter_items_by_course($_POST['discusschk'], 'imas_forums', $cid);
}
if (!empty($_POST['exttoolchk'])) {
$_POST['exttoolchk'] = filter_items_by_course($_POST['exttoolchk'], 'imas_linkedtext', $cid);
}
if (!empty($_POST['stus'])) {
$_POST['stus'] = filter_users_by_course($_POST['stus'], $cid);
}
if ($calledfrom=='gb' && $_POST['posted']==_("Excuse Grade") && $stu>0) {
$vals = array();
foreach($_POST['assesschk'] as $aid) {
array_push($vals, $stu, $cid, 'A', $aid, $now);
}
foreach($_POST['offlinechk'] as $oid) {
array_push($vals, $stu, $cid, 'O', $oid, $now);
}
foreach($_POST['discusschk'] as $fid) {
array_push($vals, $stu, $cid, 'F', $fid, $now);
}
foreach($_POST['exttoolchk'] as $lid) {
array_push($vals, $stu, $cid, 'E', $lid, $now);
}
if (count($vals)>0) {
$ph = Sanitize::generateQueryPlaceholdersGrouped($vals, 5);
$stm = $DBH->prepare("REPLACE INTO imas_excused (userid, courseid, type, typeid, dateset) VALUES $ph");
$stm->execute($vals);
}
} else if ($calledfrom=='gb' && $_POST['posted']==_("Un-excuse Grade") && $stu>0) {
$delstm = $DBH->prepare("DELETE FROM imas_excused WHERE userid=? AND type=? AND typeid=?");
foreach($_POST['assesschk'] as $aid) {
$delstm->execute(array($stu, 'A', $aid));
}
foreach($_POST['offlinechk'] as $oid) {
$delstm->execute(array($stu, 'O', $oid));
}
foreach($_POST['discusschk'] as $fid) {
$delstm->execute(array($stu, 'F', $fid));
}
foreach($_POST['exttoolchk'] as $lid) {
$delstm->execute(array($stu, 'E', $lid));
}
} else if ($calledfrom=='isolateassess' && $_POST['posted']==_("Excuse Grade")) {
$vals = array();
foreach($_POST['stus'] as $stu) {
array_push($vals, $stu, $cid, 'A', $aid, $now);
}
if (count($vals)>0) {
$ph = Sanitize::generateQueryPlaceholdersGrouped($vals, 5);
$stm = $DBH->prepare("REPLACE INTO imas_excused (userid, courseid, type, typeid, dateset) VALUES $ph");
$stm->execute($vals);
}
} else if ($calledfrom=='isolateassess' && $_POST['posted']==_("Un-excuse Grade")) {
$delstm = $DBH->prepare("DELETE FROM imas_excused WHERE userid=? AND type=? AND typeid=?");
foreach($_POST['stus'] as $stu) {
$delstm->execute(array($stu, 'A', $aid));
}
}
if ($calledfrom=='gb') {
header('Location: ' . $GLOBALS['basesiteurl'] . "/course/gradebook.php?cid=".Sanitize::courseId($cid) . "&stu=".Sanitize::onlyInt($stu) . "&r=" . Sanitize::randomQueryStringParam());
exit;
} else if ($calledfrom=='isolateassess') {
header('Location: ' . $GLOBALS['basesiteurl'] . "/course/isolateassessgrade.php?cid=".Sanitize::courseId($cid) . "&aid=".Sanitize::onlyInt($aid) . "&r=" . Sanitize::randomQueryStringParam());
exit;
}