g3.9
This commit is contained in:
1 parent
76258c2291
commit
b4aa7bb628
4 files changed
+61
-42
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ async function createTemp() {
|
||||
await couchDB.set("users", {
|
||||
"turtle": {
|
||||
"password": "1234",
|
||||
"level": 0,
|
||||
"level": 4,
|
||||
"xp": 0,
|
||||
"avatar": null,
|
||||
"abilities": [],
|
||||
|
||||
@@ -263,13 +263,16 @@ async function init() {
|
||||
|
||||
async function getXpPoints(elm, xp, name, pos) {
|
||||
elm.remove();
|
||||
playLevelSound();
|
||||
const course = await couchDB.get("course:" + name);
|
||||
|
||||
const data = course.result_history[pos];
|
||||
data["got_xp"] = true;
|
||||
|
||||
await levelUpXP(couchDB, userData, xp);
|
||||
if (await levelUpXP(couchDB, userData, xp)) {
|
||||
playLevelSound();
|
||||
} else {
|
||||
playXPSound();
|
||||
}
|
||||
|
||||
await couchDB.set("course:" + name, course);
|
||||
}
|
||||
|
||||
+47
-36
@@ -255,10 +255,14 @@ button.auswertung:hover {
|
||||
|
||||
<script>
|
||||
(async () => {
|
||||
const courseList = document.getElementById("course-list");
|
||||
|
||||
await setUserData(couchDB);
|
||||
await setCourseView();
|
||||
})();
|
||||
|
||||
async function setCourseView() {
|
||||
const courseList = document.getElementById("course-list");
|
||||
courseList.innerHTML = "";
|
||||
|
||||
for(const courseId of userData.courses) {
|
||||
const course = await couchDB.get("course:" + courseId);
|
||||
|
||||
@@ -286,16 +290,16 @@ button.auswertung:hover {
|
||||
`;
|
||||
courseList.appendChild(card);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
function createCourseNewEvaluation() {
|
||||
const elm = getOverlay("createCourse");
|
||||
if (elm == null) return;
|
||||
|
||||
const evaluations = elm.querySelector(".evaluations > div");
|
||||
evaluations.innerHTML += createEvaluation({
|
||||
evaluations.appendChild(createEvaluation({
|
||||
"title": "", "type": "text"
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
async function saveCreateCourse() {
|
||||
@@ -310,22 +314,19 @@ async function saveCreateCourse() {
|
||||
}
|
||||
|
||||
const courseId = title.replace(/\s+/g, "_");
|
||||
|
||||
|
||||
const sDateInp = inputs[inputs.length-2];
|
||||
const eDateInp = inputs[inputs.length-1];
|
||||
|
||||
const data = {
|
||||
"title": title,
|
||||
"description": description.value,
|
||||
"owner": userData.name,
|
||||
"questions": [],
|
||||
"result": [],
|
||||
"result_history": [
|
||||
{
|
||||
"date": "",
|
||||
"questions": [],
|
||||
"result": []
|
||||
}
|
||||
],
|
||||
"start_date": inputs[1].value || "",
|
||||
"expire_date": inputs[2].value || ""
|
||||
"result_history": [],
|
||||
"start_date": sDateInp.value || "",
|
||||
"expire_date": eDateInp.value || ""
|
||||
};
|
||||
|
||||
const evaluations = elm.querySelector(".evaluations > div");
|
||||
@@ -473,13 +474,17 @@ async function showEditCourse(name) { //
|
||||
inputs[0].value = data.title;
|
||||
inputs[0].setAttribute("oldID", name);
|
||||
description.value = data.description;
|
||||
inputs[1].value = data["start_date"] ?? "";
|
||||
inputs[2].value = data["expire_date"] ?? "";
|
||||
|
||||
const sDateInp = inputs[inputs.length-2];
|
||||
const eDateInp = inputs[inputs.length-1];
|
||||
|
||||
sDateInp.value = data["start_date"] ?? "";
|
||||
eDateInp.value = data["expire_date"] ?? "";
|
||||
|
||||
const evaluations = elm.querySelector(".evaluations > div");
|
||||
|
||||
for (var i of data.questions) {
|
||||
evaluations.innerHTML += createEvaluation(i);
|
||||
evaluations.appendChild(createEvaluation(i));
|
||||
}
|
||||
}
|
||||
function createNewEvaluation() {
|
||||
@@ -487,22 +492,25 @@ function createNewEvaluation() {
|
||||
if (elm == null) return;
|
||||
|
||||
const evaluations = elm.querySelector(".evaluations > div");
|
||||
evaluations.innerHTML += createEvaluation({
|
||||
"title": "", "type": "text"
|
||||
});
|
||||
evaluations.appendChild(
|
||||
createEvaluation({
|
||||
"title": "", "type": "text"
|
||||
})
|
||||
);
|
||||
}
|
||||
function createEvaluation(question) {
|
||||
return `
|
||||
<div class="evaluation">
|
||||
<button onclick="this.parentElement.remove();">🗑</button>
|
||||
<input value="${question.title}">
|
||||
<select>
|
||||
<option value="text" ${question.type == "text" ? "selected": ""}>Text</option>
|
||||
<option value="scala" ${question.type == "scala" ? "selected": ""}>Scala</option>
|
||||
<option value="emoji" ${question.type == "emoji" ? "selected": ""}>Emoji</option>
|
||||
</select>
|
||||
</div>
|
||||
const div = document.createElement("div");
|
||||
div.classList.add("evaluation");
|
||||
div.innerHTML = `
|
||||
<button onclick="this.parentElement.remove();">🗑</button>
|
||||
<input value="${question.title}">
|
||||
<select>
|
||||
<option value="text" ${question.type == "text" ? "selected": ""}>Text</option>
|
||||
<option value="scala" ${question.type == "scala" ? "selected": ""}>Scala</option>
|
||||
<option value="emoji" ${question.type == "emoji" ? "selected": ""}>Emoji</option>
|
||||
</select>
|
||||
`;
|
||||
return div;
|
||||
}
|
||||
async function saveEditCourse() {
|
||||
const elm = getOverlay("edit_course");
|
||||
@@ -530,12 +538,15 @@ async function saveEditCourse() {
|
||||
data["questions"] = questions;
|
||||
evaluations.remove();
|
||||
|
||||
if (inputs[1].value.length > 0) {
|
||||
let dateObject = new Date(inputs[1].value);
|
||||
const sDateInp = inputs[inputs.length-2];
|
||||
const eDateInp = inputs[inputs.length-1];
|
||||
|
||||
if (sDateInp.value.length > 0) {
|
||||
let dateObject = new Date(sDateInp.value);
|
||||
let dateString = dateObject.toISOString().split('T')[0];
|
||||
data["start_date"] = dateString;
|
||||
} if (inputs[2].value.length > 0) {
|
||||
let dateObject = new Date(inputs[2].value);
|
||||
} if (eDateInp.value.length > 0) {
|
||||
let dateObject = new Date(eDateInp.value);
|
||||
let dateString = dateObject.toISOString().split('T')[0];
|
||||
data["expire_date"] = dateString;
|
||||
}
|
||||
@@ -544,7 +555,7 @@ async function saveEditCourse() {
|
||||
await couchDB.set("course:" + oldID, data);
|
||||
|
||||
hideOverlay("edit_course");
|
||||
location.reload();
|
||||
setCourseView();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
<div class="end-dialog">
|
||||
<h2>Vielen Dank für deine Teilnahme!</h2><br>
|
||||
<h3 id="level_up" style="display: none;">Level up!<br><br><br></h3>
|
||||
<h3 id="xp_up" style="display: none;">+1 XP-Punkt<br><br><br></h3>
|
||||
<button class="weiter-btn" onclick="onEndEvent(this)">
|
||||
Zurück zur Hauptseite
|
||||
</button>
|
||||
@@ -274,11 +275,15 @@ function updateContent(old_page, page) {
|
||||
}
|
||||
|
||||
async function onFinishEva() {
|
||||
await playLevelSound();
|
||||
await updateCourseAnswer(finalResult);
|
||||
if (await levelUpXP(couchDB)) {
|
||||
const lvlElm = getId("level_up");
|
||||
if (lvlElm) lvlElm.style.display = "unset";
|
||||
const e = getId("level_up");
|
||||
if (e) e.style.display = "unset";
|
||||
await playLevelSound();
|
||||
} else {
|
||||
const e = getId("xp_up");
|
||||
if (e) e.style.display = "unset";
|
||||
await playXPSound();
|
||||
}
|
||||
}
|
||||
async function onEndEvent() {
|
||||
|
||||
Reference in new issue
Block a user