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
98 lines (81 loc) · 2.53 KB
/
index.php
File metadata and controls
98 lines (81 loc) · 2.53 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
92
93
94
95
96
97
<?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 data from OpenStreetMap JSON API',
'google_geo_json.php' => 'Retrieve GEO data from a JSON API (Deprecated)',
'freebie.php' => 'Choose your own grade',
);
$oldsettings = Settings::linkGetAll();
$assn = Settings::linkGet('exercise');
$custom = LTIX::ltiCustomGet('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;
}
$menu = false;
if ( $LAUNCH->link && $LAUNCH->user && $LAUNCH->user->instructor ) {
$menu = new \Tsugi\UI\MenuSet();
$menu->addLeft('Student Data', 'grades.php');
if ( $CFG->launchactivity ) {
$menu->addRight(__('Launches'), 'analytics');
}
$menu->addRight(__('Settings'), '#', /* push */ false, SettingsForm::attr());
}
// View
$OUTPUT->header();
?>
<style>
a {
text-decoration: underline;
color: blue;
}
</style>
<?php
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
// Settings dialog
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();