This repository has been archived on 2024-12-04. You can view files and clone it, but cannot push or open issues or pull requests.
KlausurSlide/Klausur.html

599 lines
22 KiB
HTML

<!DOCTYPE html>
<!--
MIT License
Copyright (c) 2022 (Pingger Shikkoken)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<html style="background-color: #fff;">
<!-- DON'T LOOK AT THIS CODE! -->
<!-- IT WORKS! DON'T TOUCH IT -->
<head>
<meta charset="utf-8" />
</head>
<body style="background-color: #fff;">
<div id="header">
<h1 align="center" id="titleh1">Klausurhelfer</h1>
</div>
<div id="clock_div">
<progress style="width: 100vw;height: 3vh; background-color: #fff;" value="0" max="100" id="timebar">&nbsp;</progress>
<h1 id="clock" class="time" style="text-align: center">...</h1>
</div>
<div id="left">
<div id="seating">
<h2>Sitzordnung</h2>
<table id="sitzordnung"></table>
<ul>
<li>Beginnend von der Tafel aus</li>
<li id="infoSeatingRows">1 Reihe belegt, 1 Reihe frei</li>
<li id="infoSeatingSeats">2 freie Plätze zwischen den belegten Plätzen innerhalb einer Reihe</li>
<li>Die blauen Plätze in der Abbildung nutzen</li>
</ul>
</div>
</div>
<div id="right">
<div id="inputs" style="display: block; overflow-y: scroll">
<form id="settingsForm" formmethod="GET">
<table>
<tr>
<!--- ------------------------------------ -->
<td colspan="100%"><h2>Einstellungen</h2></td>
<!--- ------------------------------------ -->
</tr>
<tr>
<td><label for="inputExamTitle">Titel</label></td>
<td><input id="inputExamTitle" name="inputExamTitle" type="text" required="required" placeholder="Betriebssysteme Klausur" size="64" value="Klausur" /><label for="inputExamTitle"></label></td>
</tr>
<tr>
<td><label for="inputExamDuration">Bearbeitungszeit</label></td>
<td><input id="inputExamDuration" name="inputExamDuration" type="number" pattern="[0-9]+" value="60" max="180" min="30" required="required" /><label for="inputExamDuration"> Minuten</label></td>
</tr>
<tr>
<td><label for="inputExtraDuration">Extra Zeit</label></td>
<td><input id="inputExtraDuration" name="inputExtraDuration" type="number" pattern="[0-9]+" value="5" max="30" min="0" required="required" /><label for="inputExtraDuration"> Minuten</label></td>
</tr>
<tr>
<td><label for="inputEarlyCutoff">Vorzeitige Abgabefrist</label></td>
<td><input id="inputEarlyCutoff" name="inputEarlyCutoff" type="number" pattern="[0-9]+" value="15" max="180" min="0" required="required" /><label for="inputEarlyCutoff"> Minuten vor Ende der Bearbeitungszeit</label></td>
</tr>
<tr>
<td colspan="100%" style="font-size: 70%"><label for="inputEarlyCutoff">Ein Wert von 0 Minuten blendet die Vorzeitige Abgabe vollständig aus</label></td>
</tr>
<tr>
<td><label for="inputHelpSheet">Hilfszettel</label></td>
<td><input id="inputHelpSheet" name="inputHelpSheet" type="number" pattern="[0-9]+" value="2" max="180" min="0" required="required" /><label for="inputHelpSheet"> Seiten (2 = 1 Blatt)</label></td>
</tr>
<tr>
<td colspan="100%" style="font-size: 70%"><label for="inputHelpSheet">Ein Wert von 0 Seiten blendet die Info zum Hilfszettel vollständig aus</label></td>
</tr>
<tr>
<!--- -------------------------------- -->
<td colspan="100%"><h5>Sitzordnung</h2></td>
<!--- -------------------------------- -->
</tr>
<tr>
<td><label for="inputSeatingRowsUsed">Reihen benutzt</label></td>
<td><input id="inputSeatingRowsUsed" name="inputSeatingRowsUsed" type="number" pattern="[0-9]+" value="1" max="180" min="1" required="required" /><label for="inputSeatingRowsUsed"></label></td>
</tr>
<tr>
<td><label for="inputSeatingRowsFree">Reihen frei</label></td>
<td><input id="inputSeatingRowsFree" name="inputSeatingRowsFree" type="number" pattern="[0-9]+" value="1" max="180" min="0" required="required" /><label for="inputSeatingRowsFree"></label></td>
</tr>
<tr>
<td><label for="inputSeatingSeatsFree">Sitze frei</label></td>
<td><input id="inputSeatingSeatsFree" name="inputSeatingSeatsFree" type="number" pattern="[0-9]+" value="2" max="180" min="0" required="required" /><label for="inputSeatingSeatsFree"></label></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Nächster Schritt" id="settingsFormSubmit" /></td>
</tr>
<tr>
<!--- -------------------------------- -->
<td colspan="100%"><h5>Erweitert</h2></td>
<!--- -------------------------------- -->
</tr>
<tr>
<td><label for="inputExamStart">Startzeitpunkt</label></td>
<td><input id="inputExamStart" name="inputExamStart" type="text" pattern="[0-9]{4}-(0?[1-9]|1[0-2])-(0?[1-9]|[12][0-9]|30|31) ((0?|1)[0-9]|2[0-3]):([0-5][0-9])" placeholder="YYYY-MM-DD HH:mm" /><label for="inputExamStart"></label></td>
</tr>
<tr>
<td colspan="100%" style="font-size: 70%"><label for="inputExamStart">Wird normalerweise beim Klicken vom <i>Start</i>-Button gesetzt. Wenn in das Feld ein Zeitstempel eingetragen ist, so wird beim Betätigen des <i>Nächster Schritt</i>-Buttons auch automatisch der <i>Start</i>-Button betätigt.</label></td>
</tr>
</table>
<style>
#settingsForm input:invalid {
background-color: #faa;
}
</style>
</form>
<script>
var get_params = {};
location.search
.substr(1)
.split("&")
.forEach(function (item) {
var sp = item.split("=");
get_params[sp[0]] = decodeURIComponent(sp[1]);
switch(sp[0]) {
case "inputExamDuration":
case "inputExtraDuration":
case "inputEarlyCutoff":
case "inputHelpSheet":
case "inputSeatingRowsUsed":
case "inputSeatingRowsFree":
case "inputSeatingSeatsFree":
get_params[sp[0]]-=0; // Convert to Number
document.getElementById(sp[0]).value=get_params[sp[0]];
break;
default:
break;
}
});
if(!("inputExamStart" in get_params)) {
document.getElementById("inputExamStart").value="";
}
console.log("Parsed Parameters");
console.log(get_params);
var on_load_time = new Date();
console.log(on_load_time.toLocaleString('sv'));
</script>
</div>
<div style="display: none" id="Vorbereitung">
<h2>Vorbereitung</h2>
<ul>
<li>Elektronische Geräte ausschalten und in der Tasche verstauen. (auch Smart-Watches)</li>
<li>Ein Etui gehört in die Tasche</li>
<li>Studierendennachweis (oder Studierendenausweis) <b>UND</b> Lichtbildausweis bereit legen</li>
<li id="vorTauja">Taschen und Jacken in die Sitzreihe vor Ihnen legen.</li>
<li>Am Platz sollten sich befinden:
<ul>
<li>dokumentenechtes Schreibwerkzeug (aka. Kugelschreiber)</li>
<li>Studierendennachweis</li>
<li>Lichtbildausweis</li>
<li id="vorHelpsheet">1 DIN-A4 <i>Spickzettel</i></li>
<li>Getränk und Verpflegung</li>
<li>Wörterbuch</li>
</ul>
</li>
</ul>
</div>
<div id="inExam" style="display: none;">
<table>
<tr>
<td>Start: </td>
<td class="time" id="inExamStart"></td>
</tr>
<tr>
<td>Start der Bearbeitungszeit: </td>
<td class="time" id="inExamExamStart"></td>
</tr>
<tr id="inExamEarlyCutoffRow">
<td>Vorzeitige Abgabe bis: </td>
<td class="time" id="inExamEarlyCutoff"></td>
</tr>
<tr style="text-decoration: underline; font-size: 5vh;">
<td>Ende der Bearbeitungszeit: </td>
<td class="time" id="inExamEnd"></td>
</tr>
</table>
</div>
</div>
<div id="start_btn"><input type="submit" value="Start" autofocus="autofocus" /></div>
<div id="reset_btn"><input type="submit" value="Reset" /></div>
<div id="fullscreen_btn"><input type="submit" value="Vollbild" /></div>
<div id="copyright" style="position: absolute; right:0; bottom: 0;"><!-- Dieser Copyright-Hinweis darf nicht entfernt werden --><a href="https://git.cs.tu-dortmund.de/felix.homa/KlausurSlide" target="_blank">git.cs.tu-dortmund.de/felix.homa/KlausurSlide</a></div>
<script>
var startTime = null;
var endTime = null;
var examStartTime = null; // Start der Bearbeitungszeit
var examCutoffTime = null; // Zeitpunkt der letzten vorzeitigen Abgabe
var halfHourWarningTime = null;
var halfHourWarningTime2 = null;
var halfHourWarningBlinkCount = 2
var inputs=["inputExamDuration","inputExtraDuration","inputEarlyCutoff","inputHelpSheet","inputSeatingRowsUsed","inputSeatingRowsFree","inputSeatingSeatsFree","inputExamTitle"];
function start_exam() {
document.getElementById("start_btn").onclick=""; // Aktion für den Start-Button deaktivieren
document.getElementById("start_btn").innerHTML=""; // Start-Button entfernen
document.getElementById("inputs").style.display="none";
document.getElementById("Vorbereitung").style.display="none";
document.getElementById("seating").style.display="none";
document.getElementById("inExam").style.display="block";
fullscreenFunc();
var now = new Date();
var exam_duration = document.getElementById("inputExamDuration").valueAsNumber; // Normale Bearbeitungszeit in Minuten
var extra_duration = document.getElementById("inputExtraDuration").valueAsNumber; // "Namen eintragen"-Zeit in Minuten
var early_cutoff = document.getElementById("inputEarlyCutoff").valueAsNumber; // Frühzeitige Abgabefrist in Minuten vom Ende
if(document.getElementById("inputExamStart").value.length!=0) {
startTime = new Date(document.getElementById("inputExamStart").value);
}
else {
startTime = new Date(now);
startTime.setSeconds(0);
startTime.setMinutes(now.getMinutes()+1);
document.getElementById("inputExamStart").value=
( startTime.getYear() +1900) +"-"
+((startTime.getMonth()+1)<10?"0":"")+(startTime.getMonth()+1)+"-"
+( startTime.getDate() <10?"0":"")+ startTime.getDate() +" "
+( startTime.getHours() <10?"0":"")+ startTime.getHours() +":"
+( startTime.getMinutes() <10?"0":"")+ startTime.getMinutes()
}
endTime = new Date(startTime);
endTime.setMinutes(startTime.getMinutes()+exam_duration+extra_duration);
examStartTime = new Date(startTime);
examStartTime.setMinutes(startTime.getMinutes()+extra_duration);
examCutoffTime = new Date(endTime);
examCutoffTime.setMinutes(endTime.getMinutes()-early_cutoff);
halfHourWarningTime = new Date(endTime);
halfHourWarningTime.setMinutes(endTime.getMinutes()-30);
halfHourWarningTime2 = new Date(halfHourWarningTime);
halfHourWarningTime2.setSeconds(halfHourWarningTime.getSeconds()+halfHourWarningBlinkCount);
console.log("Now: " + now);
console.log("Start: " + startTime);
console.log("Exam Start: " + examStartTime);
console.log("Early Cutoff: " + examCutoffTime);
console.log("End: " + endTime);
/*
* Query-String mit Start-Zeitpunkt bauen.
*/
var queryString="";
for(var i in inputs) {
queryString+="&"+inputs[i]+"="+encodeURIComponent(document.getElementById(inputs[i]).value); // Hier werden Zahlen erwartet ... die müssen nicht encoded werden
}
queryString+="&inputExamStart="+encodeURIComponent(document.getElementById("inputExamStart").value);
queryString="?"+queryString.substr(1);
window.history.pushState({},"", queryString);
/*
* "InExam"-Setzen. Also die Zeiten Anzeigen
*/
document.getElementById("inExamStart").innerHTML=startTime.getHours()+":"+(startTime.getMinutes()<10?"0":"")+startTime.getMinutes();
document.getElementById("inExamExamStart").innerHTML=examStartTime.getHours()+":"+(examStartTime.getMinutes()<10?"0":"")+examStartTime.getMinutes();
document.getElementById("inExamEarlyCutoff").innerHTML=examCutoffTime.getHours()+":"+(examCutoffTime.getMinutes()<10?"0":"")+examCutoffTime.getMinutes();
document.getElementById("inExamEnd").innerHTML=endTime.getHours()+":"+(endTime.getMinutes()<10?"0":"")+endTime.getMinutes();
if(early_cutoff==0) {
document.getElementById("inExamEarlyCutoffRow").style.display="none";
}
// Reset-Button Animation
document.getElementById("reset_btn").style.display="block";
setTimeout(function() {
document.getElementById("reset_btn").style.transform="scale(1)";
document.getElementById("reset_btn").style.left="0";
document.getElementById("reset_btn").style.bottom="0";
}, 1);
}
var clockUpdate = function() {
var now = new Date();
//document.getElementById("clock").innerHTML = new Date().toISOString().replace("T"," ").replace("Z","");
/*
* "Große"-Uhr aktualisieren
*/
document.getElementById("clock").innerHTML = (now.getHours()<10?"&nbsp;":"")+now.getHours() + ":" + (now.getMinutes()<10?"0":"")+now.getMinutes();
if(endTime!=null) {
var dur = endTime-startTime;
var rem = endTime-now;
var per = 100-(rem/dur*100);
document.getElementById("timebar").value=per;
document.getElementById("timebar").max=100;
}
/*
* Hintergrund signalisierung:
* Normal: weiß
* 30 minuten warnung: 2 mal 500ms gelb, 500ms weiß
* Bearbeitungszeit zu ende: rot
*/
if(endTime!=null && now>endTime) {
document.body.style.backgroundColor="#faa";
}
else if(endTime!=null && now>halfHourWarningTime && now<=halfHourWarningTime2 && now.getMilliseconds()<500) {
document.body.style.backgroundColor="#ffa";
}
else {
document.body.style.backgroundColor="#fff";
}
};
function rebuildSeating()
{
var rowsFree = document.getElementById("inputSeatingRowsFree").valueAsNumber;
var rowsUsed = document.getElementById("inputSeatingRowsUsed").valueAsNumber;
var rowInterval = rowsFree+rowsUsed;
var seatsFree = document.getElementById("inputSeatingSeatsFree").valueAsNumber;
// Tabelleninhalt
var so = "<tr><td colspan=\"100%\" style=\"text-align: center;\">Tafel (vorne)</td></tr>";
for(var row=0;row<10;row++) {
var r = row % rowInterval;
so+="<tr>";
for(var seat=0;seat<31;seat++) {
var use = r<rowsUsed && ((seat%(seatsFree+1))==0); // true = diese Reihe benutzen UND diesen Sitz benutzen
// console.log("Row: " + row + " - Seat: " + seat + " => " + use);
if(use) {
so+="<td class=\"ok\"></td>";
}
else {
so+="<td class=\"nok\"></td>";
}
}
so+="</tr>";
}
document.getElementById("sitzordnung").innerHTML=so;
if(rowsFree==0) {
document.getElementById("infoSeatingRows").innerText="Alle Reihen benutzen!";
}
else {
document.getElementById("infoSeatingRows").innerText=rowsUsed+" Reihe"+(rowsUsed>1?"n":"")+" belegt, " + rowsFree+" Reihe"+(rowsFree>1?"n":"") + " frei";
}
if(rowsFree>=1) {
if(rowsUsed==1) {
document.getElementById("vorTauja").style.display="list-item";
document.getElementById("vorTauja").innerText="Taschen und Jacken in die Sitzreihe vor Ihnen legen";
} else if(rowsUsed==2) {
document.getElementById("vorTauja").style.display="list-item";
document.getElementById("vorTauja").innerText="Taschen und Jacken in die leere Sitzreihe vor/hinter Ihnen legen";
}
}
else {
document.getElementById("vorTauja").style.display="none";
}
if(seatsFree==0 && rowsFree==0) {
document.getElementById("infoSeatingSeats").innerText="Alle Plätze in allen Reihen nutzen"
}
else if(seatsFree==0) {
document.getElementById("infoSeatingSeats").innerText="Alle Plätze in den entsprechenden Reihen nutzen"
}
else {
document.getElementById("infoSeatingSeats").innerText=seatsFree+ (seatsFree==1?" freien Platz":" freie Plätze")+" zwischen den belegten Plätzen innerhalb einer Reihe";
}
}
function settingsFormSubmitFunc() {
document.body.requestFullscreen().catch(function(rej){});
/*
* Query-String für die URL zusammenbauen
*/
var queryString="";
for(var i in inputs) {
queryString+="&"+inputs[i]+"="+encodeURIComponent(document.getElementById(inputs[i]).value); // Hier werden Zahlen erwartet ... die müssen nicht encoded werden
}
queryString="?"+queryString.substr(1);
window.history.pushState({},"", queryString);
// Wenn der "Startzeitpunkt" gesetzt ist, dann URL entsprechend updaten und starten
if(document.getElementById("inputExamStart").value.length != 0) {
window.history.pushState({},"", queryString);
queryString+="&inputExamStart="+encodeURIComponent(document.getElementById("inputExamStart").value);
start_exam();
return false;
}
// Andere Divs anzeigen
document.getElementById("inputs").style.display="none";
document.getElementById("Vorbereitung").style.display="block";
// Spickzettel
var sp = document.getElementById("inputHelpSheet").valueAsNumber;
if(sp==0) {
document.getElementById("vorHelpsheet").style.display="none";
}
else {
document.getElementById("vorHelpsheet").innerHTML=(sp%2==0?sp/2:sp)+" "+(sp%2==0?sp>2?"Bl&amul;tter":"Blatt":sp>1?"Seiten":"Seite") + " DIN-A4 <i>Spickzettel</i> (<b>handbeschrieben</b>)"
}
// Start-Button Animation
document.getElementById("start_btn").style.display="block";
setTimeout(function() {
document.getElementById("start_btn").style.transform="scale(1)";
document.getElementById("start_btn").style.left="0";
document.getElementById("start_btn").style.bottom="0";
}, 1);
document.getElementById("start_btn").focus();
return false;
}
function fullscreenFunc() {
document.body.requestFullscreen().then(function() {
var b = document.getElementById("fullscreen_btn").style;
b.transform="scale(1)";
b.right="25vw";
b.bottom=0;
b.display="block";
}).catch(function(rej){});
}
function resetPage() {
var queryString="";
for(var i in inputs) {
queryString+="&"+inputs[i]+"="+encodeURIComponent(document.getElementById(inputs[i]).value);
}
queryString="?"+queryString.substr(1);
window.history.pushState({},"", queryString);
location.reload();
}
function updateTitle() {
document.getElementById("titleh1").innerText=document.getElementById("inputExamTitle").value;
}
var seatingInputs=["inputSeatingRowsUsed","inputSeatingRowsFree","inputSeatingSeatsFree"]
for(let eid in seatingInputs) {
document.getElementById(seatingInputs[eid]).onchange=rebuildSeating;
}
rebuildSeating();
document.getElementById("inputExamTitle").onchange=updateTitle;
document.getElementById("inputExamTitle").oninput=updateTitle;
updateTitle();
setInterval(clockUpdate, 50);
document.getElementById("start_btn").onclick=start_exam;
document.getElementById("start_btn").firstChild.onsubmit=start_exam;
document.getElementById("settingsFormSubmit").onclick=settingsFormSubmitFunc;
document.getElementById("reset_btn").onclick=resetPage;
document.getElementById("reset_btn").firstChild.onsubmit=resetPage;
document.getElementById("fullscreen_btn").onclick=fullscreenFunc;
document.getElementById("fullscreen_btn").firstChild.onsubmit=fullscreenFunc;
if(("inputExamStart" in get_params)) {
console.log(document.getElementById("fullscreen_btn").style.display="block");
settingsFormSubmitFunc();
console.log("Yay");
}
</script>
<style>
body {
display: grid;
height: 100vh;
width: 100vw;
overflow: hidden;
grid-template-rows: 15vh 15vh 70vh;
grid-template-columns: 50vw 50vw;
padding: 0px;
margin: 0px;
font-family: sans-serif;
}
h1 {
text-align: center;
font-size: 8vh;
margin: 4px;
padding: 4px;
}
h2 {
font-size: 4vh;
text-align: center;
margin: 4px;
padding: 4px;
}
h3,h4,h5,h6 {
text-align: center;
margin: 0px;
padding: 0px;
}
li{
padding-top: 1vh;
list-style-type: '- ';
}
.time {
/*font-family: monospace;*/
text-align: right;
}
#header {
/*background-color: #ff8;*/
grid-area: 1 / 1 / span 1 / span 2;
text-align: center;
font-weight: 600;
}
#clock_div {
/*background-color: #ff8;*/
grid-area: 2 / 1 / span 1 / span 2;
text-align: center;
font-weight: 600;
}
#clock {
font-size: 12vh;
}
#left {
/*background-color: #f88;*/
grid-area: 3 / 1;
font-size: 3vh;
}
#right {
/*background-color: #8f8;*/
grid-area: 3 / 2;
font-size: 3vh;
}
#inputs {
font-size: 2vh;
}
#inExam table {
padding-top: 15vh;
font-size: 4vh;
}
#inExam td {
padding-top: 1vh;
padding-left: 1vw;
}
#inExam td.time {
margin: 0.5vh;
padding-left: 1vw;
font-weight: 600;
}
#settingsForm td:nth-child(1) {
width: 15vw;
}
#sitzordnung {
width: 100%;
}
#sitzordnung td {
height: 2vh;
width: 2vh;
}
#sitzordnung .ok {
background-color: #88f;
}
#sitzordnung .nok {
background-color: #f88;
}
#start_btn {
position: absolute;
bottom: 40vh;
left: 30vw;
display: none;
transform: scale(20);
transition-duration: 3s;
transition-property: all;
}
#reset_btn {
position: absolute;
bottom: 0;
left: 100vw;
display: none;
transition-duration: 3s;
transition-property: all;
}
#fullscreen_btn {
transform: scale(10);
width: 5vw;
height: 2vh;
bottom: 60vh;
right: 70vw;
position: absolute;
display: none;
transition-duration: 1s;
transition-property: all;
}
</style>
</body>
</html>