summaryrefslogtreecommitdiffstats
path: root/modules-available/exams/install.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/exams/install.inc.php')
-rw-r--r--modules-available/exams/install.inc.php25
1 files changed, 19 insertions, 6 deletions
diff --git a/modules-available/exams/install.inc.php b/modules-available/exams/install.inc.php
index b61a0af2..aa8c9a0d 100644
--- a/modules-available/exams/install.inc.php
+++ b/modules-available/exams/install.inc.php
@@ -3,13 +3,26 @@
$res = array();
$res[] = tableCreate('exams', '
- `examid` int(11) NOT NULL AUTO_INCREMENT,
- `starttime` int(11) NOT NULL,
- `endtime` int(11) NOT NULL,
- `description` varchar(100) DEFAULT NULL,
- PRIMARY KEY (`examid`)
- ');
+ `examid` int(11) NOT NULL AUTO_INCREMENT,
+ `starttime` int(11) NOT NULL,
+ `endtime` int(11) NOT NULL,
+ `description` varchar(100) DEFAULT NULL,
+ PRIMARY KEY (`examid`)
+ ');
+$res[] = tableCreate('exams_x_location', '
+ `examid` int(11) NOT NULL,
+ `locationid` int(11) NOT NULL,
+ PRIMARY KEY (`examid`, `locationid`)
+');
+
+if (Database::exec("ALTER TABLE exams ADD INDEX `idx_daterange` ( `starttime` , `endtime` )") === false) {
+ if (!preg_match('/\b1061\b/', Database::lastError())) {
+ finalResponse(UPDATE_FAILED, 'Could not add startdate/enddate index: ' . Database::lastError());
+ }
+} else {
+ $res[] = UPDATE_DONE;
+}
if (in_array(UPDATE_DONE, $res)) {
finalResponse(UPDATE_DONE, 'Tables created successfully');