-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeletePoll.php
More file actions
30 lines (25 loc) · 858 Bytes
/
deletePoll.php
File metadata and controls
30 lines (25 loc) · 858 Bytes
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
<?php
require_once "../config.php";
use \Tsugi\Core\LTIX;
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
if (!$USER->instructor) {
header('Location: ' . addSession('student-home.php'));
return;
}
if (!isset($_GET["p"]) || $_GET["p"] == '') {
$_SESSION["error"] = "Unable to delete unknown poll.";
} else {
$currentActivePollId = $LAUNCH->link->settingsGet("active-poll-id", false);
if ($currentActivePollId == $_GET["p"]) {
// Poll was already the active one so set to inactive
$LAUNCH->link->settingsSet("active-poll-id", false);
}
$deletePollStmt = $PDOX->prepare("DELETE FROM {$p}qp_poll WHERE poll_id = :pollId");
$deletePollStmt->execute(array(
":pollId" => $_GET["p"]
));
}
$_SESSION["success"] = "Poll successfully deleted.";
header('Location: ' . addSession('build.php'));
return;