From dacf10553b2494add15fae2eb66a75dc847b49a0 Mon Sep 17 00:00:00 2001 From: juliotoscano Date: Tue, 22 Nov 2016 09:12:04 -0300 Subject: [PATCH] created file modalExam Js #362 --- exam/static/js/modalExam.js | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ exam/templates/exam/create.html | 6 +++--- 2 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 exam/static/js/modalExam.js diff --git a/exam/static/js/modalExam.js b/exam/static/js/modalExam.js new file mode 100644 index 0000000..9f5a197 --- /dev/null +++ b/exam/static/js/modalExam.js @@ -0,0 +1,147 @@ + +//Insert Create select with question type + var idQuestionType = 1; + $("#addQuestion").on("click", function(event){ + var element = + '
' + + '' + '
' + + '' + + '
' + + '
' + '
' + ; + if (idQuestionType == 1){ + $(element).insertAfter('#buttonAddQuestion'); + }else{ + var idhr = '#hr_'+(idQuestionType-1); + $(element).insertAfter(idhr); + } + idQuestionType++; + }) + + //Insert question choice + function showDiv (elem, questionType_id) { + if (elem.value == 0) { + var questionChoice = + '
' + + '
'+ + ''+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'; + } else if (elem.value == 1) { + var questionChoice = + '
'+ + '
'+ + ''+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + ''+ + ''+ + '
'+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'; + } else if (elem.value == 3) { + var questionChoice = + '
'+ + '
'+ + ''+ + '
'+ + ''+ + '
'+ + '
'+ + '
'; + } + if(document.getElementById('questionChoice_'+ questionType_id)){ + $('#questionChoice_'+ questionType_id).detach(); + } + $(questionChoice).insertBefore('#hr_'+questionType_id); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. + } +//Bug quando criamos sem ser na ordem +function functionNewAlternative(Question_Id){ + var alternative = parseInt($("div input").last().val()) + 1; + var element = '
' + + ''+ + '
'; + $(Question_Id).append(element); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. +} +function functionNewAlternativeTF(Question_Id){ + var alternative = parseInt($("div").last().val()) + 1; + var element = + '
'+ + ''+ + ''+ + ''+ + '
'; + $(Question_Id).append(element); + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. +} \ No newline at end of file diff --git a/exam/templates/exam/create.html b/exam/templates/exam/create.html index 44ddb97..3a7140e 100644 --- a/exam/templates/exam/create.html +++ b/exam/templates/exam/create.html @@ -4,7 +4,7 @@ {# {% block style %} #} - + {# {% endblock %} #} @@ -93,9 +93,9 @@ var id = 1; $("#add_question").click(function(){ $.get("{% url 'course:exam:true_or_false_question' %}", function(data){ - + $("#questions").append(data); - + $("#0").attr("id","true_" + id++); }); }); -- libgit2 0.21.2