summaryrefslogtreecommitdiffstats
path: root/modules-available/exams
diff options
context:
space:
mode:
authorSimon Rettberg2016-09-06 15:50:08 +0200
committerSimon Rettberg2016-09-06 15:50:08 +0200
commit1fe7c76c21d24184706775d18cd34c379f8f863d (patch)
treec7ecca4a252477da5ed1e6359b5ea84476886822 /modules-available/exams
parentMerge branch 'modularization' of dnbd3:openslx-ng/slx-admin into modularization (diff)
downloadslx-admin-1fe7c76c21d24184706775d18cd34c379f8f863d.tar.gz
slx-admin-1fe7c76c21d24184706775d18cd34c379f8f863d.tar.xz
slx-admin-1fe7c76c21d24184706775d18cd34c379f8f863d.zip
[exams] Implement autostart checkbox
Diffstat (limited to 'modules-available/exams')
-rw-r--r--modules-available/exams/baseconfig/getconfig.inc.php5
-rw-r--r--modules-available/exams/inc/exams.inc.php5
-rw-r--r--modules-available/exams/install.inc.php4
-rw-r--r--modules-available/exams/lang/de/template-tags.json4
-rw-r--r--modules-available/exams/page.inc.php73
-rw-r--r--modules-available/exams/templates/page-add-edit-exam.html4
6 files changed, 57 insertions, 38 deletions
diff --git a/modules-available/exams/baseconfig/getconfig.inc.php b/modules-available/exams/baseconfig/getconfig.inc.php
index 6a9bf03a..5e506755 100644
--- a/modules-available/exams/baseconfig/getconfig.inc.php
+++ b/modules-available/exams/baseconfig/getconfig.inc.php
@@ -5,9 +5,12 @@ if (isset($configVars["SLX_LOCATIONS"])) {
} else {
$locationIds = array();
}
-if (Exams::isInExamMode($locationIds, $lectureId)) {
+if (Exams::isInExamMode($locationIds, $lectureId, $autoLogin)) {
$configVars['SLX_EXAM'] = 'yes';
if (strlen($lectureId) > 0) {
$configVars['SLX_EXAM_START'] = $lectureId;
}
+ if (strlen($autoLogin) > 0) {
+ $configVars['SLX_AUTOLOGIN'] = $autoLogin;
+ }
}
diff --git a/modules-available/exams/inc/exams.inc.php b/modules-available/exams/inc/exams.inc.php
index 5fc497c7..dfc38273 100644
--- a/modules-available/exams/inc/exams.inc.php
+++ b/modules-available/exams/inc/exams.inc.php
@@ -7,17 +7,18 @@ class Exams
* @param int[] of location ids. must bot be an associative array.
* @return: bool true iff for any of the given location ids an exam is scheduled.
**/
- public static function isInExamMode($locationIds, &$lectureId)
+ public static function isInExamMode($locationIds, &$lectureId = false, &$autoLogin = false)
{
if (!is_array($locationIds)) {
$locationIds = array($locationIds);
}
$l = str_repeat(',?', count($locationIds));
- $res = Database::queryFirst("SELECT lectureid FROM exams"
+ $res = Database::queryFirst("SELECT lectureid, autologin FROM exams"
. " INNER JOIN exams_x_location USING (examid)"
. " WHERE UNIX_TIMESTAMP() BETWEEN starttime AND endtime AND locationid IN (0$l) LIMIT 1", $locationIds);
if ($res !== false) {
$lectureId = $res['lectureid'];
+ $autoLogin = $res['autologin'];
}
return $res !== false;
}
diff --git a/modules-available/exams/install.inc.php b/modules-available/exams/install.inc.php
index b1032118..45e9e41a 100644
--- a/modules-available/exams/install.inc.php
+++ b/modules-available/exams/install.inc.php
@@ -7,6 +7,7 @@ $res[] = tableCreate('exams', '
`lectureid` char(36) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,
`starttime` int(11) NOT NULL,
`endtime` int(11) NOT NULL,
+ `autologin` char(36) NULL,
`description` varchar(500) DEFAULT NULL,
PRIMARY KEY (`examid`)
');
@@ -28,6 +29,9 @@ if (Database::exec("ALTER TABLE exams ADD INDEX `idx_daterange` ( `starttime` ,
if (!tableHasColumn('exams', 'lectureid')) {
Database::exec("ALTER TABLE `exams` ADD `lectureid` CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NULL DEFAULT NULL AFTER `examid`");
}
+if (!tableHasColumn('exams', 'autologin')) {
+ Database::exec("ALTER TABLE `exams` ADD `autologin` CHAR(36) NULL DEFAULT NULL AFTER `endtime`");
+}
Database::exec("ALTER TABLE `exams` CHANGE `description` `description` varchar(500) DEFAULT NULL");
diff --git a/modules-available/exams/lang/de/template-tags.json b/modules-available/exams/lang/de/template-tags.json
index 22f777ad..6f4dce62 100644
--- a/modules-available/exams/lang/de/template-tags.json
+++ b/modules-available/exams/lang/de/template-tags.json
@@ -3,7 +3,9 @@
"lang_addExam": "Zeitraum hinzuf\u00fcgen",
"lang_addingBasedOnLecture": "F\u00fcge neuen Pr\u00fcfungszeitraum basierend auf vorhandener Veranstaltung an",
"lang_allExamPeriods": "Alle Pr\u00fcfungszeitr\u00e4ume",
- "lang_autoStartInfo": "W\u00e4hlen Sie hier optional eine Veranstaltung, die automatisch nach dem Booten der Rechner auf den Clients gestartet werden soll. Die Studierenden sehen keine Loginmaske und keinen vmChooser. Dadurch ist der Benutzer nicht angemeldet, und es steht u.a. kein Home-Verzeichnis zur Verf\u00fcgung. Diese Funktion eignet sich somit nur, wenn in der Pr\u00fcfung keine Autentifizierung des Benutzers notwendig ist, oder diese anderweitig innerhalb der VM-Sitzung umgesetzt wird, z.B. indem sich der Pr\u00fcfling gesondert auf einer Lernplattform im Browser anmeldet. Beachten Sie au\u00dferdem, dass die gew\u00e4hlte Veranstaltung zum Pr\u00fcfungszeitraum durch den Dozenten aktiviert sein muss. Wird keine Veranstaltung f\u00fcr den Autostart ausgew\u00e4hlt, sieht der Pr\u00fcfling nach wie vor eine Anmeldemaske und anschlie\u00dfend den vmChooser, in dem dann jedoch ausschlie\u00dflich als Pr\u00fcfung markierte Veranstaltungen aufgelistet werden.",
+ "lang_autoLogin": "Login \u00fcberspringen",
+ "lang_autoLoginInfo": "Wenn Sie diese Option w\u00e4hlen, wird die bwLehrpool Loginmaske \u00fcbersprungen und eine anonyme Sitzung gestartet, d.h. die Studierenden sehen nach dem Booten des Rechners keine Loginmaske, sondern direkt den vmChooser mit den f\u00fcr den Raum verf\u00fcgbaren Pr\u00fcfungen. Dies ist z.B. sinnvoll, wenn die Studierenden zur Abgabe ein LMS nutzen, an dem sie sich separat authentifizieren. Bedenken Sie, dass in diesem Modus keine Home-Verzeichnisse zur Verf\u00fcgung stehen. Wenn Sie zus\u00e4tzlich eine automatisch zu startende Veranstaltung w\u00e4hlen, wird der vmChooser nicht angezeigt, sodass die Rechner ohne Nutzerinteraktion direkt in die ausgew\u00e4hlte Veranstaltung booten.",
+ "lang_autoStartInfo": "W\u00e4hlen Sie hier optional eine Veranstaltung, die automatisch auf den Clients gestartet werden soll. Die Studierenden sehen nach der Loginmaske keinen vmChooser; die hier festgelegte Veranstaltung wird direkt gestartet. Beachten Sie, dass die gew\u00e4hlte Veranstaltung zum Pr\u00fcfungszeitraum durch den Dozenten aktiviert sein muss. Wird keine Veranstaltung f\u00fcr den Autostart ausgew\u00e4hlt, sieht der Pr\u00fcfling nach wie vor den vmChooser, in dem dann jedoch ausschlie\u00dflich als Pr\u00fcfung markierte Veranstaltungen aufgelistet werden. Sie k\u00f6nnen diese Funktion mit der Option \"Login \u00fcberspringen\" kombinieren, um einen komplett automatisierten Start zu erm\u00f6glichen.",
"lang_autoStartLecture": "Automatisch zu startende Veranstaltung",
"lang_autostart": "Autostart-Veranstaltung",
"lang_begin": "Beginn",
diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php
index e70fc3c7..49b48bb6 100644
--- a/modules-available/exams/page.inc.php
+++ b/modules-available/exams/page.inc.php
@@ -30,7 +30,7 @@ class Page_Exams extends Page
protected function readExams()
{
- $tmp = Database::simpleQuery("SELECT e.examid, l.displayname AS lecturename, e.starttime, e.endtime, e.description, GROUP_CONCAT(exl.locationid) AS locationids, "
+ $tmp = Database::simpleQuery("SELECT e.examid, e.autologin, l.displayname AS lecturename, e.starttime, e.endtime, e.description, GROUP_CONCAT(exl.locationid) AS locationids, "
. "GROUP_CONCAT(loc.locationname SEPARATOR ', ') AS locationnames FROM exams e "
. "NATURAL LEFT JOIN exams_x_location exl "
. "NATURAL LEFT JOIN location loc "
@@ -75,26 +75,28 @@ class Page_Exams extends Page
*/
$unique_ids = 1;
/* add the red shadows */
- foreach ($this->exams as $e) {
- if ($e['starttime'] > $this->rangeMax || $e['endtime'] < $this->rangeMin)
- continue;
- $locationids = explode(',', $e['locationids']);
- if ($locationids[0] == 0) {
- $locationids = [];
- foreach($this->locations as $location) {
- $locationids[] = $location['locationid'];
+ if (is_array($this->exams)) {
+ foreach ($this->exams as $e) {
+ if ($e['starttime'] > $this->rangeMax || $e['endtime'] < $this->rangeMin)
+ continue;
+ $locationids = explode(',', $e['locationids']);
+ if ($locationids[0] == 0) {
+ $locationids = [];
+ foreach ($this->locations as $location) {
+ $locationids[] = $location['locationid'];
+ }
+ }
+ foreach ($locationids as $locationid) {
+ $out[] = [
+ 'id' => 'shadow_' . $unique_ids++,
+ 'content' => $e['description'],
+ 'title' => $e['description'],
+ 'start' => intval($e['starttime']) * 1000,
+ 'end' => intval($e['endtime']) * 1000,
+ 'type' => 'background',
+ 'group' => $locationid,
+ ];
}
- }
- foreach ($locationids as $locationid) {
- $out[] = [
- 'id' => 'shadow_' . $unique_ids++,
- 'content' => $e['description'],
- 'title' => $e['description'],
- 'start' => intval($e['starttime']) * 1000,
- 'end' => intval($e['endtime']) * 1000,
- 'type' => 'background',
- 'group' => $locationid,
- ];
}
}
/* add the lectures */
@@ -142,17 +144,19 @@ class Page_Exams extends Page
{
$out = [];
$now = time();
- foreach ($this->exams as $exam) {
- if ($exam['endtime'] < $now) {
- $exam['rowClass'] = 'text-muted';
- $exam['btnClass'] = 'btn-success';
- $exam['liesInPast'] = true;
- } else {
- $exam['btnClass'] = 'btn-default';
+ if (is_array($this->exams)) {
+ foreach ($this->exams as $exam) {
+ if ($exam['endtime'] < $now) {
+ $exam['rowClass'] = 'text-muted';
+ $exam['btnClass'] = 'btn-success';
+ $exam['liesInPast'] = true;
+ } else {
+ $exam['btnClass'] = 'btn-default';
+ }
+ $exam['starttime_s'] = date('Y-m-d H:i', $exam['starttime']);
+ $exam['endtime_s'] = date('Y-m-d H:i', $exam['endtime']);
+ $out[] = $exam;
}
- $exam['starttime_s'] = date('Y-m-d H:i', $exam['starttime']);
- $exam['endtime_s'] = date('Y-m-d H:i', $exam['endtime']);
- $out[] = $exam;
}
return $out;
}
@@ -216,6 +220,7 @@ class Page_Exams extends Page
$endtime = strtotime(Request::post('endtime_date') . " " . Request::post('endtime_time'));
$description = Request::post('description', '', 'string');
$lectureid = Request::post('lectureid', '', 'string');
+ $autologin = Request::post('autologin', '', 'string');
if (!$this->isDateSane($starttime)) {
Message::addError('starttime-invalid', Request::post('starttime_date') . " " . Request::post('starttime_time'));
Util::redirect('?do=exams');
@@ -231,8 +236,8 @@ class Page_Exams extends Page
if ($examid === 0) {
// No examid given, is add
- $res = Database::exec("INSERT INTO exams(lectureid, starttime, endtime, description) VALUES(:lectureid, :starttime, :endtime, :description);",
- compact('lectureid', 'starttime', 'endtime', 'description')) !== false;
+ $res = Database::exec("INSERT INTO exams(lectureid, starttime, endtime, autologin, description) VALUES(:lectureid, :starttime, :endtime, :autologin, :description);",
+ compact('lectureid', 'starttime', 'endtime', 'autologin', 'description')) !== false;
$exam_id = Database::lastInsertId();
foreach ($locationids as $lid) {
@@ -255,8 +260,8 @@ class Page_Exams extends Page
}
/* update fields */
- $res = Database::exec("UPDATE exams SET lectureid = :lectureid, starttime = :starttime, endtime = :endtime, description = :description WHERE examid = :examid",
- compact('lectureid', 'starttime', 'endtime', 'description', 'examid')) !== false;
+ $res = Database::exec("UPDATE exams SET lectureid = :lectureid, starttime = :starttime, endtime = :endtime, autologin = :autologin, description = :description WHERE examid = :examid",
+ compact('lectureid', 'starttime', 'endtime', 'description', 'examid', 'autologin')) !== false;
/* drop all connections and reconnect to rooms */
$res = $res && Database::exec("DELETE FROM exams_x_location WHERE examid = :examid", compact('examid')) !== false;
/* reconnect */
diff --git a/modules-available/exams/templates/page-add-edit-exam.html b/modules-available/exams/templates/page-add-edit-exam.html
index 744aad29..74e7d52b 100644
--- a/modules-available/exams/templates/page-add-edit-exam.html
+++ b/modules-available/exams/templates/page-add-edit-exam.html
@@ -91,6 +91,10 @@
</select>
</div>
</div>
+ <div class="form-group col-xs-12">
+ <div class="checkbox"><input id="autologin" type="checkbox" name="autologin" value="demo" class="form-control" {{#exam.autologin}}checked{{/exam.autologin}}><label for="autologin">{{lang_autoLogin}}</label></div>
+ <p><i>{{lang_autoLoginInfo}}</i></p>
+ </div>
<div class="col-xs-12" id="lecture-info">
bla
</div>