forked from tsugiproject/tsugi
/
index.php
81 lines (63 loc) · 2.04 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
<?php
require_once "../../config.php";
require_once $CFG->dirroot."/pdo.php";
require_once $CFG->dirroot."/lib/lms_lib.php";
require_once "data_util.php";
require_once "names.php";
require_once "locations.php";
use \Tsugi\Core\Settings;
use \Tsugi\Core\LTIX;
use \Tsugi\UI\SettingsForm;
$LTI = LTIX::requireData();
$p = $CFG->dbprefix;
if ( SettingsForm::handleSettingsPost() ) {
header( 'Location: '.addSession('index.php') ) ;
return;
}
// All the assignments we support
$assignments = array(
'regex_sum.php' => 'Sum with a Regular Expression',
'a12a.php' => 'Exploring HyperText Transport Protocol',
'comment_html.php' => 'Sum data from HTML',
'knows.php' => 'Follow links in a series of web pages.',
'comment_xml.php' => 'Sum data from XML',
'comment_json.php' => 'Sum data from JSON',
'geo_json.php' => 'Retrieve data from a JSON API'
);
$oldsettings = Settings::linkGetAll();
$assn = Settings::linkGet('exercise');
// Get any due date information
$dueDate = SettingsForm::getDueDate();
// Let the assignment handle the POST
if ( count($_POST) > 0 && $assn && isset($assignments[$assn]) ) {
require($assn);
return;
}
// View
$OUTPUT->header();
$OUTPUT->bodyStart();
// Settings button and dialog
echo('<span style="position: fixed; right: 10px; top: 5px;">');
if ( $USER->instructor ) {
echo('<a href="grades.php" target="_blank"><button class="btn btn-info">Grade detail</button></a> '."\n");
}
SettingsForm::button();
$OUTPUT->exitButton();
echo('</span>');
SettingsForm::start();
SettingsForm::select("exercise", __('Please select an assignment'),$assignments);
SettingsForm::dueDate();
SettingsForm::done();
SettingsForm::end();
$OUTPUT->welcomeUserCourse();
$OUTPUT->flashMessages();
if ( $assn && isset($assignments[$assn]) ) {
require($assn);
} else {
if ( $USER->instructor ) {
echo("<p>Please use settings to select an assignment for this tool.</p>\n");
} else {
echo("<p>This tool needs to be configured - please see your instructor.</p>\n");
}
}
$OUTPUT->footer();