update questions file in for admin
This commit is contained in:
parent
54ec4bf618
commit
ede7a45ae5
@ -16,3 +16,11 @@
|
|||||||
width: 100%;
|
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"})
|
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,78 +1,41 @@
|
|||||||
<a href="/admin"> go Back </a> <br>
|
<!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>>
|
||||||
|
|
||||||
<select id="langs" onchange="changeLang()">
|
<a href="/admin"> go Back </a> <br>
|
||||||
{%for lang in langs%}
|
|
||||||
<option value="{{lang}}">{{lang}}</option>
|
<select id="langs" onchange="changeLang()">
|
||||||
{%endfor%}
|
{%for lang in langs%}
|
||||||
</select>
|
<option value="{{lang}}">{{lang}}</option>
|
||||||
|
{%endfor%}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<section id="allQuestions">
|
<section id="allQuestions">
|
||||||
{%for questionType in questions%}
|
{%for questionType in questions%}
|
||||||
<div class="questionType">
|
<div class="questionType">
|
||||||
<section class="questionTypeContent">
|
<section class="questionTypeContent">
|
||||||
{%for question in questionType["questions"]%}
|
{%for question in questionType["questions"]%}
|
||||||
<section class="question">
|
<section class="question">
|
||||||
<input value="{{question['text']}}">
|
<input value="{{question['text']}}">
|
||||||
<button onclick="deleteEntry(this)">Delete question</button>
|
<button onclick="deleteEntry(this)">Delete question</button>
|
||||||
</section>
|
</section>
|
||||||
|
{%endfor%}
|
||||||
|
</section>
|
||||||
|
<button onclick="addEntry(this)">Add new</button>
|
||||||
|
</div>
|
||||||
{%endfor%}
|
{%endfor%}
|
||||||
</section>
|
</section>
|
||||||
<button onclick="addEntry(this)">Add new</button>
|
|
||||||
</div>
|
|
||||||
{%endfor%}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<button onclick="saveForm()"> Save changes </button>
|
<button onclick="saveFormQuestions()"> Save changes </button>
|
||||||
|
</body>
|
||||||
<style>
|
</html>
|
||||||
.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>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user