Facilitation saisie questions/quiz (rang affiché)

This commit is contained in:
Fabrice PENHOËT 2020-08-13 12:53:29 +02:00
parent 25efc8ae7b
commit 86c5be23be

View File

@ -188,7 +188,7 @@ const initialise = async () =>
addElement(divQuestions, "h4", txtQuestion.introTitle);// remplace l'existant dans divQuestions addElement(divQuestions, "h4", txtQuestion.introTitle);// remplace l'existant dans divQuestions
let listQuestions=""; let listQuestions="";
for(let i in Questions) for(let i in Questions)
listQuestions+="<li>"+Questions[i].Question.text+" | <a href='#updateQuestion"+Questions[i].Question.id+"' id='#updateQuestion"+Questions[i].Question.id+"' >"+txt.updateBtnTxt+"</a> | <a href='#deleteQuestion"+Questions[i].Question.id+"' id='#deleteQuestion"+Questions[i].Question.id+"' >"+txt.deleteBtnTxt+"</a></li>"; listQuestions+="<li>"+Questions[i].Question.rank+" - "+Questions[i].Question.text+" | <a href='#updateQuestion"+Questions[i].Question.id+"' id='#updateQuestion"+Questions[i].Question.id+"' >"+txt.updateBtnTxt+"</a> | <a href='#deleteQuestion"+Questions[i].Question.id+"' id='#deleteQuestion"+Questions[i].Question.id+"' >"+txt.deleteBtnTxt+"</a></li>";
if(listQuestions==="") if(listQuestions==="")
listQuestions="<li>"+txtQuestion.introNoQuestion+"</li>"; listQuestions="<li>"+txtQuestion.introNoQuestion+"</li>";
addElement(divQuestions, "ul", listQuestions, "", ["information"], "", false);// à intégrer dans le DOM pour pouvoir ajouter des addEventListener ensuite addElement(divQuestions, "ul", listQuestions, "", ["information"], "", false);// à intégrer dans le DOM pour pouvoir ajouter des addEventListener ensuite
@ -209,10 +209,6 @@ const initialise = async () =>
}); });
} }
console.log(config.nbQuestionsMax);
console.log(Questions.length);
if(config.nbQuestionsMax > Questions.length || config.nbQuestionsMax===0) if(config.nbQuestionsMax > Questions.length || config.nbQuestionsMax===0)
{ {
if(Questions.length < config.nbQuestionsMin) if(Questions.length < config.nbQuestionsMin)
@ -225,7 +221,7 @@ const initialise = async () =>
hideAllForms(); hideAllForms();
formQuestion.style.display="block"; formQuestion.style.display="block";
formQuestion.elements["QuestionnaireId"].value=formQuestionnaire.elements["id"].value; formQuestion.elements["QuestionnaireId"].value=formQuestionnaire.elements["id"].value;
formQuestion.elements["rank"].value=config.Question.rank.defaultValue; formQuestion.elements["rank"].value=(Questions.length===0) ? config.Question.rank.defaultValue : Questions.length+1;
window.location.assign("#questions"); window.location.assign("#questions");
setAttributesToInputs(config.Question, formQuestion); setAttributesToInputs(config.Question, formQuestion);
}); });
@ -691,9 +687,6 @@ const initialise = async () =>
e.preventDefault(); e.preventDefault();
sendQuestionForm(); sendQuestionForm();
}); });
} }
} }
} }