update questions file in for admin
This commit is contained in:
parent
54ec4bf618
commit
ede7a45ae5
@ -16,3 +16,11 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.questionType{
|
||||
border: thin solid red;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.question input{
|
||||
width: 100%;
|
||||
margin: 10px;
|
||||
}
|
||||
|
@ -51,3 +51,44 @@ function saveFormTraits(){
|
||||
}
|
||||
makeAPIRequest("admin/setTraits", {"traits": data, "lang": "FR"}, {"content": "json"})
|
||||
}
|
||||
|
||||
|
||||
|
||||
//functions for questions.html
|
||||
|
||||
|
||||
|
||||
|
||||
function addEntry(button){
|
||||
let questionTypeContent = button.parentNode.querySelector(".questionTypeContent");
|
||||
let newQuestion = questionTypeContent.querySelector(".question").cloneNode(true);
|
||||
newQuestion.id = "";
|
||||
newQuestion.querySelector("input").value = "";
|
||||
questionTypeContent.appendChild(newQuestion);
|
||||
}
|
||||
|
||||
function deleteEntry(buttonNode){
|
||||
let placeNode = buttonNode.parentNode;
|
||||
placeNode.parentNode.removeChild(placeNode);
|
||||
}
|
||||
|
||||
function saveFormQuestions(){
|
||||
let data = [];
|
||||
|
||||
for(let questionTypeNode of allQuestions.querySelectorAll(".questionType")){
|
||||
let questionsJson = [];
|
||||
let questionTypeJson = {"questions": questionsJson};
|
||||
data.push(questionTypeJson);
|
||||
|
||||
for(let questionNode of questionTypeNode.querySelectorAll("input")){
|
||||
questionsJson.push({"text": questionNode.value})
|
||||
}
|
||||
}
|
||||
|
||||
makeAPIRequest("admin/setQuestions", {"questions": data, "lang": "FR"}, {"content": "json"})
|
||||
}
|
||||
|
||||
function changeLang(){
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<title>Admin Page</title>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="admin_ui.css">
|
||||
<script src="/static/js/admin.js"></script>
|
||||
<script src="/static/js/api.js"></script>
|
||||
</head>
|
||||
<body>>
|
||||
|
||||
<a href="/admin"> go Back </a> <br>
|
||||
|
||||
<select id="langs" onchange="changeLang()">
|
||||
@ -25,54 +36,6 @@
|
||||
|
||||
<br>
|
||||
|
||||
<button onclick="saveForm()"> Save changes </button>
|
||||
|
||||
<style>
|
||||
.questionType{
|
||||
border: thin solid red;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.question input{
|
||||
width: 100%;
|
||||
margin: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="/static/js/api.js"></script>
|
||||
<script>
|
||||
|
||||
|
||||
function addEntry(button){
|
||||
let questionTypeContent = button.parentNode.querySelector(".questionTypeContent");
|
||||
let newQuestion = questionTypeContent.querySelector(".question").cloneNode(true);
|
||||
newQuestion.id = "";
|
||||
newQuestion.querySelector("input").value = "";
|
||||
questionTypeContent.appendChild(newQuestion);
|
||||
}
|
||||
|
||||
function deleteEntry(buttonNode){
|
||||
let placeNode = buttonNode.parentNode;
|
||||
placeNode.parentNode.removeChild(placeNode);
|
||||
}
|
||||
|
||||
function saveForm(){
|
||||
let data = [];
|
||||
|
||||
for(let questionTypeNode of allQuestions.querySelectorAll(".questionType")){
|
||||
let questionsJson = [];
|
||||
let questionTypeJson = {"questions": questionsJson};
|
||||
data.push(questionTypeJson);
|
||||
|
||||
for(let questionNode of questionTypeNode.querySelectorAll("input")){
|
||||
questionsJson.push({"text": questionNode.value})
|
||||
}
|
||||
}
|
||||
|
||||
makeAPIRequest("admin/setQuestions", {"questions": data, "lang": "FR"}, {"content": "json"})
|
||||
}
|
||||
|
||||
function changeLang(){
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<button onclick="saveFormQuestions()"> Save changes </button>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user