Commit d6ae13a125ebd50c9addd574aedff8e864529a12
Committed by
GitHub
Exists in
master
and in
5 other branches
Merge pull request #425 from amadeusproject/exam_page
js works #362
Showing
3 changed files
with
27 additions
and
68 deletions
Show diff stats
amadeus/staticfiles/js/modal_exam.js
... | ... | @@ -1,43 +0,0 @@ |
1 | -//controles do modal | |
2 | -$(window).ready(function() { // utilizado para abrir o modal quando tiver tido algum erro no preenchimento do formulario | |
3 | - if($('.not_submited').length){ | |
4 | - $('#exam').modal('show'); | |
5 | - } | |
6 | -}); | |
7 | -var Answer = { | |
8 | - init: function(url) { // utilizado para adicionar um novo campo de resposta | |
9 | - $.get(url, function(data){ | |
10 | - $("#form").append(data); | |
11 | - var cont = 1; | |
12 | - $("#form div div div input").each(function(){ | |
13 | - $(this).attr('name',cont++); | |
14 | - }); | |
15 | - }); | |
16 | - } | |
17 | -}; | |
18 | - | |
19 | -var Submite = { | |
20 | - post: function(url,dados){ | |
21 | - $('#exam').modal('hide'); | |
22 | - $.post(url,dados, function(data){ | |
23 | - }).fail(function(data){ | |
24 | - $("div.modal-backdrop.fade.in").remove(); | |
25 | - $("#modal_exam").empty(); | |
26 | - $("#modal_exam").append(data.responseText); | |
27 | - }); | |
28 | - }, | |
29 | - remove: function(url,dados, id_li_link){ | |
30 | - $('#exam').modal('hide'); | |
31 | - $.post(url,dados, function(data){ | |
32 | - $(id_li_link).remove(); | |
33 | - $("#modal_exam").empty(); | |
34 | - $("div.modal-backdrop.fade.in").remove(); | |
35 | - }).fail(function(){ | |
36 | - $("#modal_exam").empty(); | |
37 | - $("#modal_exam").append(data); | |
38 | - $('#exam').modal('show'); | |
39 | - }); | |
40 | - } | |
41 | -} | |
42 | - | |
43 | -alert("essfd"); |
exam/static/js/Exam.js
1 | -//Insert Create select with question type | |
2 | - var idQuestionType = 1; | |
3 | - $("#addQuestion").on("click", function(event){ | |
4 | - var element = | |
5 | - '<div class="row form-group" id="questionType_' + idQuestionType +'">' + | |
6 | - '<label for="questionType" class="col-md-2 control-label">' + | |
7 | - '{% trans "Question Type" %}</label>' + '<div class="col-md-10">' + | |
8 | - '<select id="questionType'+ idQuestionType +'" class="form-control" name="option_question" onchange="showDiv (this, '+ idQuestionType +')">' + | |
9 | - '<option selected disabled>{% trans "Question Type" %}</option>' + | |
10 | - '<option value="0">{% trans "Multiple Choice" %}</option>' + | |
11 | - '<option value="1">{% trans "True or False" %}</option>' + | |
12 | - '<option value="2">{% trans "Gap Filling" %}</option>' + | |
13 | - '<option value="3">{% trans "Discursive Question" %}</option>' + | |
14 | - '</select>' + | |
15 | - '</div>' + | |
16 | - '</div>' + '<hr id="hr_'+idQuestionType+'">' | |
17 | - ; | |
18 | - if (idQuestionType == 1){ | |
19 | - $(element).insertAfter('#buttonAddQuestion'); | |
20 | - }else{ | |
21 | - var idhr = '#hr_'+(idQuestionType-1); | |
22 | - $(element).insertAfter(idhr); | |
23 | - } | |
24 | - idQuestionType++; | |
25 | - }) | |
26 | 1 | |
27 | 2 | //Insert question choice |
28 | 3 | function showDiv (elem, questionType_id) { | ... | ... |
exam/templates/exam/create.html
... | ... | @@ -55,6 +55,33 @@ |
55 | 55 | |
56 | 56 | {% block javascript %} |
57 | 57 | <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
58 | + <script type="text/javascript"> | |
59 | + //Insert Create select with question type | |
60 | + var idQuestionType = 1; | |
61 | + $("#addQuestion").on("click", function(event){ | |
62 | + var element = | |
63 | + '<div class="row form-group" id="questionType_' + idQuestionType +'">' + | |
64 | + '<label for="questionType" class="col-md-2 control-label">' + | |
65 | + '{% trans "Question Type" %}</label>' + '<div class="col-md-10">' + | |
66 | + '<select id="questionType'+ idQuestionType +'" class="form-control" name="option_question" onchange="showDiv (this, '+ idQuestionType +')">' + | |
67 | + '<option selected disabled>{% trans "Question Type" %}</option>' + | |
68 | + '<option value="0">{% trans "Multiple Choice" %}</option>' + | |
69 | + '<option value="1">{% trans "True or False" %}</option>' + | |
70 | + '<option value="2">{% trans "Gap Filling" %}</option>' + | |
71 | + '<option value="3">{% trans "Discursive Question" %}</option>' + | |
72 | + '</select>' + | |
73 | + '</div>' + | |
74 | + '</div>' + '<hr id="hr_'+idQuestionType+'">' | |
75 | + ; | |
76 | + if (idQuestionType == 1){ | |
77 | + $(element).insertAfter('#buttonAddQuestion'); | |
78 | + }else{ | |
79 | + var idhr = '#hr_'+(idQuestionType-1); | |
80 | + $(element).insertAfter(idhr); | |
81 | + } | |
82 | + idQuestionType++; | |
83 | + }) | |
84 | + </script> | |
58 | 85 | <script src="{% static 'js/Exam.js' %}"></script> |
59 | 86 | <!-- Init material Bootstrap --> |
60 | 87 | <script type="text/javascript">$.material.init()</script><!-- O botao radio volta a funcionar quando coloco essa função--> | ... | ... |