g2.5
This commit is contained in:
1 parent
322c62ec80
commit
753ff9b4d9
1 file changed
+33
-7
+33
-7
@@ -58,7 +58,7 @@ setUserData(couchDB);
|
|||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
.edit_course .evaluation span {
|
.edit_course .evaluation input {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
font-size: 20px !important;
|
font-size: 20px !important;
|
||||||
width: calc(100% - 80px);
|
width: calc(100% - 80px);
|
||||||
@@ -93,7 +93,7 @@ setUserData(couchDB);
|
|||||||
<textarea placeholder="Beschreibung"></textarea><br><br>
|
<textarea placeholder="Beschreibung"></textarea><br><br>
|
||||||
<div class="evaluations">
|
<div class="evaluations">
|
||||||
<div></div>
|
<div></div>
|
||||||
<button class="add_button">+</button>
|
<button class="add_button" onclick="createNewEvaluation()">+</button>
|
||||||
</div><br>
|
</div><br>
|
||||||
<button onclick="saveEditCourse()">Speichern</button>
|
<button onclick="saveEditCourse()">Speichern</button>
|
||||||
</overlay>
|
</overlay>
|
||||||
@@ -102,7 +102,10 @@ setUserData(couchDB);
|
|||||||
|
|
||||||
async function showEditCourse(name) {
|
async function showEditCourse(name) {
|
||||||
const data = await couchDB.get("course:" + name);
|
const data = await couchDB.get("course:" + name);
|
||||||
if (data.owner != userData.name) return;
|
if (data.owner != userData.name) {
|
||||||
|
console.error("User is not author");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
showOverlay("edit_course");
|
showOverlay("edit_course");
|
||||||
|
|
||||||
@@ -121,17 +124,26 @@ async function showEditCourse(name) {
|
|||||||
evaluations.innerHTML += createEvaluation(i);
|
evaluations.innerHTML += createEvaluation(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function createNewEvaluation() {
|
||||||
|
const elm = getOverlay("edit_course");
|
||||||
|
if (elm == null) return;
|
||||||
|
|
||||||
|
const evaluations = elm.querySelector(".evaluations > div");
|
||||||
|
evaluations.innerHTML += createEvaluation({
|
||||||
|
"title": "", "type": "text"
|
||||||
|
});
|
||||||
|
}
|
||||||
function createEvaluation(question) {
|
function createEvaluation(question) {
|
||||||
return `
|
return `
|
||||||
<div class="evaluation">
|
<div class="evaluation">
|
||||||
<button>🗑</button>
|
<button onclick="this.parentElement.remove();">🗑</button>
|
||||||
<span>${question.title}</span>
|
<input value="${question.title}">
|
||||||
<select>
|
<select>
|
||||||
<option value="text" ${question.type == "text" ? "selected": ""}>Text</option>
|
<option value="text" ${question.type == "text" ? "selected": ""}>Text</option>
|
||||||
<option value="scala" ${question.type == "scala" ? "selected": ""}>Scala</option>
|
<option value="scala" ${question.type == "scala" ? "selected": ""}>Scala</option>
|
||||||
<option value="emoji" ${question.type == "emoji" ? "selected": ""}>Emoji</option>
|
<option value="emoji" ${question.type == "emoji" ? "selected": ""}>Emoji</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
async function saveEditCourse() {
|
async function saveEditCourse() {
|
||||||
@@ -145,6 +157,20 @@ async function saveEditCourse() {
|
|||||||
data["title"] = title.value;
|
data["title"] = title.value;
|
||||||
data["description"] = description.value;
|
data["description"] = description.value;
|
||||||
|
|
||||||
|
const evaluations = elm.querySelector(".evaluations > div");
|
||||||
|
const questions = [];
|
||||||
|
for (var i of evaluations.getElementsByClassName("evaluation")) {
|
||||||
|
const inpE = i.querySelector("input");
|
||||||
|
const selE = i.querySelector("select");
|
||||||
|
if (inpE.value.length == 0) continue;
|
||||||
|
|
||||||
|
questions.push({
|
||||||
|
"title": inpE.value,
|
||||||
|
"type": selE.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
data["questions"] = questions;
|
||||||
|
|
||||||
await couchDB.delete("course:" + oldID);
|
await couchDB.delete("course:" + oldID);
|
||||||
await couchDB.set("course:" + title.value.toLowerCase(), data);
|
await couchDB.set("course:" + title.value.toLowerCase(), data);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user