forked from csev/py4e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
87 lines (69 loc) · 2.25 KB
/
index.php
File metadata and controls
87 lines (69 loc) · 2.25 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
<?php
require_once "../config.php";
require_once "data/data_util.php";
require_once "data/names.php";
require_once "data/locations.php";
use \Tsugi\Core\Settings;
use \Tsugi\Core\LTIX;
use \Tsugi\UI\SettingsForm;
$LAUNCH = 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',
'http_headers.php' => 'Exploring HyperText Transport Protocol',
'comment_html.php' => 'Sum comment data from HTML',
'knows.php' => 'Follow links in a series of web pages.',
'comment_xml.php' => 'Sum comment data from XML',
'comment_json.php' => 'Sum comment data from JSON',
'geo_json.php' => 'Retrieve GEO data from a JSON API'
);
$oldsettings = Settings::linkGetAll();
$assn = Settings::linkGet('exercise');
$custom = LTIX::customGet('exercise');
if ( $assn && isset($assignments[$assn]) ) {
// Configured
} else if ( strlen($custom) > 0 && isset($assignments[$custom]) ) {
Settings::linkSet('exercise', $custom);
$assn = $custom;
}
// 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();
$OUTPUT->topNav();
// 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();