-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.php
More file actions
48 lines (35 loc) · 1.29 KB
/
index.php
File metadata and controls
48 lines (35 loc) · 1.29 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
<?php
require_once('../config.php');
require_once('dao/QW_DAO.php');
use \Tsugi\Core\LTIX;
use \QW\DAO\QW_DAO;
// Retrieve the launch data if present
$LAUNCH = LTIX::requireData();
$p = $CFG->dbprefix;
$QW_DAO = new QW_DAO($PDOX, $p);
$currentTime = new DateTime('now', new DateTimeZone($CFG->timezone));
$currentTime = $currentTime->format("Y-m-d H:i:s");
if ( $USER->instructor ) {
$_SESSION["qw_id"] = $QW_DAO->getOrCreateMain($USER->id, $CONTEXT->id, $LINK->id, $currentTime);
$hasQuestions = $QW_DAO->getQuestions($_SESSION["qw_id"]);
if (!$hasQuestions) {
// No questions check if user wants to see the splash on new instances of tool
$skipSplash = $QW_DAO->skipSplash($USER->id);
if ($skipSplash) {
header( 'Location: '.addSession('instructor-home.php') ) ;
} else {
header('Location: '.addSession('splash.php'));
}
} else {
// Instructor has already setup this instance
header( 'Location: '.addSession('instructor-home.php') ) ;
}
} else { // student
$mainId = $QW_DAO->getMainID($CONTEXT->id, $LINK->id);
if (!$mainId) {
echo ("<h1>Instructor needs to do stuff");
} else {
$_SESSION["qw_id"] = $mainId;
header( 'Location: '.addSession('student-home.php') ) ;
}
}