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
85 lines (67 loc) · 2.16 KB
/
index.php
File metadata and controls
85 lines (67 loc) · 2.16 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
<?php
require_once "../config.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(
'single_mysql.php' => 'Single Table MySQL (Users)',
'many_many_mysql.php' => 'Many-to-Many MySQL (Courses)',
'single_lite.php' => 'Single Table SQLITE (Users)',
'count_lite.php' => 'Email Counter SQLITE',
'many_one_lite.php' => 'Many-to-One SQLITE (Tracks)',
'many_many_lite.php' => 'Many-to-Many SQLITE (Courses)',
);
$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]) ) {
include($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();
$OUTPUT->bodyStart();
$OUTPUT->topNav($menu);
// Settings dialog
SettingsForm::start();
SettingsForm::select("exercise", __('Please select an assignment'),$assignments);
SettingsForm::dueDate();
SettingsForm::done();
SettingsForm::end();
$OUTPUT->flashMessages();
$OUTPUT->welcomeUserCourse();
if ( $assn && isset($assignments[$assn]) ) {
include($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();