Commit 98ca47818dacc5f40d55d4ac3fc660ddaf11e773
Exists in
master
and in
5 other branches
Merge branch 'dev' of https://github.com/amadeusproject/amadeuslms into dev
Showing
7 changed files
with
188 additions
and
91 deletions
Show diff stats
app/templates/admin_settings.html
... | ... | @@ -17,32 +17,34 @@ |
17 | 17 | </div> |
18 | 18 | {% endfor %} |
19 | 19 | <!-- Nav tabs --> |
20 | + | |
20 | 21 | <ul class="nav nav-tabs md-pills pills-ins" role="tablist"> |
22 | + {% if form.safe_conection.errors or form.host.errors or form.default_from_email.errors %} | |
23 | + <li class="nav-item"> | |
24 | + <a class="nav-link {% if page == 'system' %}active{% endif %}" data-toggle="tab" href="#system" role="tab"><i class="fa fa-cog"></i> {% trans "System" %}</a> | |
25 | + </li> | |
26 | + <li class="nav-item"> | |
27 | + <a class="nav-link {% if page == 'mail_sender' %}active{% endif %}" data-toggle="tab" href="#mail_sender" role="tab"><i class="fa fa-envelope"></i> {% trans "Mail Sender" %}</a> | |
28 | + </li> | |
29 | + {% else %} | |
30 | + <li class="nav-item"> | |
31 | + <a class="nav-link {% if page == 'system' %}active{% endif %}" data-toggle="tab" href="#system" role="tab"><i class="fa fa-cog"></i> {% trans "System" %}</a> | |
32 | + <li class="nav-item"> | |
33 | + <a class="nav-link {% if page == 'mail_sender' %}active{% endif %}" data-toggle="tab" href="#mail_sender" role="tab"><i class="fa fa-envelope"></i> {% trans "Mail Sender" %}</a> | |
34 | + </li> | |
35 | + {% endif %} | |
21 | 36 | <li class="nav-item"> |
22 | - {% if form.safe_conection.errors or form.host.errors or form.default_from_email.errors %} | |
23 | - <a class="nav-link" data-toggle="tab" href="#panel1" role="tab"><i class="fa fa-cog"></i> {% trans "System" %}</a> | |
24 | - </li> | |
25 | - <li class="nav-item"> | |
26 | - <a class="nav-link active" data-toggle="tab" href="#panel2" role="tab"><i class="fa fa-envelope"></i> {% trans "Mail Sender" %}</a> | |
37 | + <a class="nav-link {% if page == 'security' %}active{% endif %}" data-toggle="tab" href="#security" role="tab"><i class="fa fa-lock"></i> {% trans "Security" %}</a> | |
27 | 38 | </li> |
28 | - {% else %} | |
29 | - <a class="nav-link active" data-toggle="tab" href="#panel1" role="tab"><i class="fa fa-cog"></i> {% trans "System" %}</a> | |
30 | -<li class="nav-item"> | |
31 | - <a class="nav-link" data-toggle="tab" href="#panel2" role="tab"><i class="fa fa-envelope"></i> {% trans "Mail Sender" %}</a> | |
32 | -</li> | |
33 | -{% endif %} | |
34 | -<li class="nav-item"> | |
35 | - <a class="nav-link" data-toggle="tab" href="#panel3" role="tab"><i class="fa fa-lock"></i> {% trans "Security" %}</a> | |
36 | -</li> | |
37 | 39 | </ul> |
38 | 40 | |
39 | 41 | <!-- Tab panels --> |
40 | 42 | <div class="tab-content"> |
41 | 43 | <!--Panel 1--> |
42 | 44 | {% if form.errors %} |
43 | - <div class="tab-pane fade" id="panel1" role="tabpanel"> | |
45 | + <div class="tab-pane fade" id="system" role="tabpanel"> | |
44 | 46 | {% else %} |
45 | - <div class="tab-pane fade in active" id="panel1" role="tabpanel"> | |
47 | + <div class="tab-pane fade {% if page == 'system' %}in active{% endif %}" id="system" role="tabpanel"> | |
46 | 48 | {% endif %} |
47 | 49 | <div class="panel panel-default"> |
48 | 50 | <div class="panel-body"> |
... | ... | @@ -60,10 +62,10 @@ |
60 | 62 | |
61 | 63 | <!--Panel 2--> |
62 | 64 | {% if form.errors %} |
63 | - <div class="tab-pane fade in active" id="panel2" role="tabpanel"> | |
65 | + <div class="tab-pane fade in active" id="mail_sender" role="tabpanel"> | |
64 | 66 | {% else %} |
65 | - <div class="tab-pane fade" id="panel2" role="tabpanel"> | |
66 | - {% endif %} | |
67 | + <div class="tab-pane fade {% if page == 'mail_sender' %}in active{% endif %}" id="mail_sender" role="tabpanel"> | |
68 | + {% endif %} | |
67 | 69 | <div class="panel panel-default"> |
68 | 70 | <form class="form-horizontal" method="post"> |
69 | 71 | {% csrf_token %} |
... | ... | @@ -252,7 +254,7 @@ |
252 | 254 | <!--/.Panel 2--> |
253 | 255 | |
254 | 256 | <!--Panel 3--> |
255 | - <div class="tab-pane fade" id="panel3" role="tabpanel"> | |
257 | + <div class="tab-pane fade {% if page == 'security' %}in active{% endif %}" id="security" role="tabpanel"> | |
256 | 258 | <div class="panel panel-default"> |
257 | 259 | <div class="panel-body"> |
258 | 260 | <div class="togglebutton"> | ... | ... |
app/templates/home.html
... | ... | @@ -110,9 +110,9 @@ |
110 | 110 | <a href="#menu_settings" class="accordion" data-toggle="collapse">{% trans 'Settings' %}<span class="pull-right glyphicon glyphicon-chevron-down"></span></a> |
111 | 111 | <div id="menu_settings" class="collapse"> |
112 | 112 | <ul class="nav nav-pill nav-stacked accordion_list"> |
113 | - <li> <a href="{% url 'app:settings' %}">{% trans "System" %}</a></li> | |
114 | - <li> <a href="{% url 'app:settings' %}">{% trans "Mail Sender" %}</a></li> | |
115 | - <li> <a href="{% url 'app:settings' %}">{% trans "Security" %}</a></li> | |
113 | + <li> <a href="{% url 'app:settings' page='system' %}">{% trans "System" %}</a></li> | |
114 | + <li> <a href="{% url 'app:settings' page='mail_sender' %}">{% trans "Mail Sender" %}</a></li> | |
115 | + <li> <a href="{% url 'app:settings' page='security' %}">{% trans "Security" %}</a></li> | |
116 | 116 | </ul> |
117 | 117 | </div> |
118 | 118 | </li> | ... | ... |
app/urls.py
... | ... | @@ -4,5 +4,5 @@ from . import views |
4 | 4 | |
5 | 5 | urlpatterns = [ |
6 | 6 | url(r'^$', views.AppIndex.as_view(), name='index'), |
7 | - url(r'^settings/$', views.AmadeusSettings.as_view(), name='settings'), | |
7 | + url(r'^settings/(?P<page>[\w_-]+)/$', views.AmadeusSettings.as_view(), name='settings'), | |
8 | 8 | ] | ... | ... |
app/views.py
... | ... | @@ -51,7 +51,10 @@ class AmadeusSettings(LoginRequiredMixin, HasRoleMixin, generic.CreateView): |
51 | 51 | model = EmailBackend |
52 | 52 | template_name = 'admin_settings.html' |
53 | 53 | form_class = EmailBackendForm |
54 | - success_url = reverse_lazy('app:settings') | |
54 | + #success_url = reverse_lazy('app:settings') | |
55 | + | |
56 | + def get_success_url(self): | |
57 | + return reverse_lazy('app:settings', kwargs = {'page': self.kwargs['page']}) | |
55 | 58 | |
56 | 59 | def form_invalid(self, form): |
57 | 60 | return self.render_to_response(self.get_context_data(form=form)) |
... | ... | @@ -75,6 +78,7 @@ class AmadeusSettings(LoginRequiredMixin, HasRoleMixin, generic.CreateView): |
75 | 78 | |
76 | 79 | def get_context_data(self, **kwargs): |
77 | 80 | context = super(AmadeusSettings, self).get_context_data(**kwargs) |
81 | + context['page'] = self.kwargs.get('page') | |
78 | 82 | if not self.request.method == 'POST': |
79 | 83 | try: |
80 | 84 | setting = EmailBackend.objects.latest('id') | ... | ... |
courses/templates/subject/form_view_teacher.html
... | ... | @@ -103,6 +103,7 @@ |
103 | 103 | <li><a href="javascript:createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans 'Create Forum' %}</a></li> |
104 | 104 | <li><a href="javascript:modal.get('{% url 'course:poll:create_poll' topic.slug%}','#poll','#requisicoes_ajax');">{% trans 'Create Poll' %}</a></li> |
105 | 105 | <li><a href="javascript:modal.get('{% url 'course:exercise:create_exercise' topic.slug %}', '#createExercisesModal','#requisicoes_ajax')">{% trans 'Delivery Material' %}</a></li> |
106 | + <li><a href="javascript:modal.get('{% url 'course:exam:create_exam' topic.slug%}','#exam','#requisicoes_ajax');">{% trans 'Create exam' %}</a></li> | |
106 | 107 | </ul> |
107 | 108 | </div> |
108 | 109 | </div> | ... | ... |
... | ... | @@ -0,0 +1,147 @@ |
1 | + | |
2 | +//Insert Create select with question type | |
3 | + var idQuestionType = 1; | |
4 | + $("#addQuestion").on("click", function(event){ | |
5 | + var element = | |
6 | + '<div class="row form-group" id="questionType_' + idQuestionType +'">' + | |
7 | + '<label for="questionType" class="col-md-2 control-label">' + | |
8 | + '{% trans "Question Type" %}</label>' + '<div class="col-md-10">' + | |
9 | + '<select id="questionType'+ idQuestionType +'" class="form-control" name="option_question" onchange="showDiv (this, '+ idQuestionType +')">' + | |
10 | + '<option selected disabled>{% trans "Question Type" %}</option>' + | |
11 | + '<option value="0">{% trans "Multiple Choice" %}</option>' + | |
12 | + '<option value="1">{% trans "True or False" %}</option>' + | |
13 | + '<option value="2">{% trans "Gap Filling" %}</option>' + | |
14 | + '<option value="3">{% trans "Discursive Question" %}</option>' + | |
15 | + '</select>' + | |
16 | + '</div>' + | |
17 | + '</div>' + '<hr id="hr_'+idQuestionType+'">' | |
18 | + ; | |
19 | + if (idQuestionType == 1){ | |
20 | + $(element).insertAfter('#buttonAddQuestion'); | |
21 | + }else{ | |
22 | + var idhr = '#hr_'+(idQuestionType-1); | |
23 | + $(element).insertAfter(idhr); | |
24 | + } | |
25 | + idQuestionType++; | |
26 | + }) | |
27 | + | |
28 | + //Insert question choice | |
29 | + function showDiv (elem, questionType_id) { | |
30 | + if (elem.value == 0) { | |
31 | + var questionChoice = | |
32 | + '<div id="questionChoice_'+questionType_id+'">' + | |
33 | + '<div class="row form-group">'+ | |
34 | + '<label for="question-name" class="col-md-2 control-label">Question</label>'+ | |
35 | + '<div class="col-md-10">'+ | |
36 | + '<textarea class="form-control" rows="1" id="question-name" placeholder="Wording"></textarea>'+ | |
37 | + '</div>'+ | |
38 | + '</div>'+ | |
39 | + '<div class="row form-group">'+ | |
40 | + '<label for="alternatives" class="col-md-2 control-label">Alternatives</label>'+ | |
41 | + '<div class="col-md-10" id="radios_'+questionType_id+'">'+ | |
42 | + '<div class="radio radio-primary form-group">'+ | |
43 | + '<label>'+ | |
44 | + '<input checked type="radio" name="multiple-choice" id="alternative1" value="1">'+ | |
45 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | |
46 | + '</label>'+ | |
47 | + '</div>'+ | |
48 | + '<div class="radio radio-primary form-group">'+ | |
49 | + '<label>'+ | |
50 | + '<input type="radio" name="multiple-choice" id="alternative2" value="2">'+ | |
51 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | |
52 | + '</label>'+ | |
53 | + '</div>'+ | |
54 | + '</div>'+ | |
55 | + '</div>'+ | |
56 | + '<div class="form-group">'+ | |
57 | + '<button type="button" class="btn btn-raised btn-primary" id="newAlternative_'+questionType_id+'" onclick="functionNewAlternative(radios_'+questionType_id+')">New Alternative</button>'+ | |
58 | + '</div>'+ | |
59 | + '</div>'; | |
60 | + } else if (elem.value == 1) { | |
61 | + var questionChoice = | |
62 | + '<div id="questionChoice_'+questionType_id+'">'+ | |
63 | + '<div class="row form-group">'+ | |
64 | + '<label for="question-name" class="col-md-2 control-label">Question True or False</label>'+ | |
65 | + '<div class="col-md-10">'+ | |
66 | + '<textarea class="form-control" rows="1" id="question-name" placeholder="Wording"></textarea>'+ | |
67 | + '</div>'+ | |
68 | + '</div>'+ | |
69 | + '<div class="row form-group">'+ | |
70 | + '<label for="alternative" class="col-md-2 control-label">Alternatives: T/F</label>'+ | |
71 | + '<div class="col-md-10" id="radiosTF_'+questionType_id+'">'+ | |
72 | + '<div class="radio form-group" value="1">'+ | |
73 | + '<div class="radio">'+ | |
74 | + '<label>'+ | |
75 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | |
76 | + '</label>'+ | |
77 | + '<label>'+ | |
78 | + '<input type="radio" name="true-or-false-1" value="T">'+ | |
79 | + '</label>'+ | |
80 | + '<label>'+ | |
81 | + '<input type="radio" name="true-or-false-1" value="F">'+ | |
82 | + '</label>'+ | |
83 | + '</div>'+ | |
84 | + '</div>'+ | |
85 | + '<div class="radio form-group" value="2">'+ | |
86 | + '<label>'+ | |
87 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | |
88 | + '</label>'+ | |
89 | + '<label>'+ | |
90 | + '<input type="radio" name="true-or-false-2" value="T">'+ | |
91 | + '</label>'+ | |
92 | + '<label>'+ | |
93 | + '<input type="radio" name="true-or-false-2" value="F">'+ | |
94 | + '</label>'+ | |
95 | + '</div>'+ | |
96 | + '</div>'+ | |
97 | + '</div>'+ | |
98 | + '<div class="form-group">'+ | |
99 | + '<button type="button" class="btn btn-raised btn-primary" id="newAlternative_'+questionType_id+'" onclick="functionNewAlternativeTF(radiosTF_'+questionType_id+')">New Alternative</button>'+ | |
100 | + '</div>'+ | |
101 | + '</div>'; | |
102 | + } else if (elem.value == 3) { | |
103 | + var questionChoice = | |
104 | + '<div id="questionChoice_'+questionType_id+'">'+ | |
105 | + '<div class="row form-group">'+ | |
106 | + '<label for="question-name" class="col-md-2 control-label">Name Question discursive</label>'+ | |
107 | + '<div class="col-md-10">'+ | |
108 | + '<textarea class="form-control" rows="2" id="question" placeholder="Wording"></textarea>'+ | |
109 | + '</div>'+ | |
110 | + '</div>'+ | |
111 | + '</div>'; | |
112 | + } | |
113 | + if(document.getElementById('questionChoice_'+ questionType_id)){ | |
114 | + $('#questionChoice_'+ questionType_id).detach(); | |
115 | + } | |
116 | + $(questionChoice).insertBefore('#hr_'+questionType_id); | |
117 | + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | |
118 | + } | |
119 | +//Bug quando criamos sem ser na ordem | |
120 | +function functionNewAlternative(Question_Id){ | |
121 | + var alternative = parseInt($("div input").last().val()) + 1; | |
122 | + var element = '<div class="radio radio-primary form-group">' + | |
123 | + '<label>' + | |
124 | + '<input type="radio" name="alternatives" id="alternative_'+alternative+'_'+Question_Id+'"' + 'value="'+alternative+'">' + | |
125 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | |
126 | + '</label>'+ | |
127 | + '</div>'; | |
128 | + $(Question_Id).append(element); | |
129 | + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | |
130 | +} | |
131 | +function functionNewAlternativeTF(Question_Id){ | |
132 | + var alternative = parseInt($("div").last().val()) + 1; | |
133 | + var element = | |
134 | + '<div class="radio form-group">'+ | |
135 | + '<label>'+ | |
136 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | |
137 | + '</label>'+ | |
138 | + '<label>'+ | |
139 | + '<input type="radio" name="true-or-false-2" value="T">'+ | |
140 | + '</label>'+ | |
141 | + '<label>'+ | |
142 | + '<input type="radio" name="true-or-false-2" value="F">'+ | |
143 | + '</label>'+ | |
144 | + '</div>'; | |
145 | + $(Question_Id).append(element); | |
146 | + $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | |
147 | +} | |
0 | 148 | \ No newline at end of file | ... | ... |
exam/templates/exam/create.html
1 | -{% extends "home.html" %} | |
2 | 1 | |
3 | 2 | {% load i18n widget_tweaks dict_access static%} |
4 | 3 | |
5 | 4 | {# {% block style %} #} |
6 | 5 | <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> |
7 | - <script src="{% static 'js/modal_exam.js' %}"></script> | |
8 | - | |
6 | + <script src="{% static 'js/modalExam.js' %}"></script> | |
7 | + <!-- Init material Bootstrap --> | |
8 | + <script type="text/javascript">$.material.init()</script><!-- O botao radio volta a funcionar quando coloco essa função--> | |
9 | 9 | {# {% endblock %} #} |
10 | 10 | |
11 | -{# {% block content %} #} | |
11 | +{% block content %} | |
12 | 12 | <!-- Modal (remember to change the ids!!!) --> |
13 | 13 | <div class="modal fade" id="exam" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> |
14 | 14 | <div class="modal-dialog" role="document"> |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | |
20 | 20 | {% block title_exam %} |
21 | 21 | <!-- Put your title here!!! --> |
22 | - <h4 class="modal-title" id="myModalLabel">{% trans "Create a Exam" %}</h4> | |
22 | + <h4 class="modal-title" id="myModalLabel">{% trans "Create a Exam" %}</h4> | |
23 | 23 | {% endblock title_exam %} |
24 | 24 | </div> |
25 | 25 | <!-- Modal Body --> |
... | ... | @@ -50,31 +50,20 @@ |
50 | 50 | <div class="col-md-10"> |
51 | 51 | <div class="checkbox"> |
52 | 52 | <label> |
53 | - <input type="checkbox" name="checkbox"><span class="checkbox-material"><span class="check"></span></span> {% trans "Allow submissions after deadline?" %} | |
53 | + <input type="checkbox" name="checkbox"><span class="checkbox-material"></span> {% trans "Allow submissions after deadline?" %} | |
54 | 54 | </label> |
55 | 55 | </div> |
56 | 56 | </div> |
57 | 57 | </div> |
58 | - <div class="row form-group" id="questions"> | |
59 | - | |
60 | - </div> | |
61 | - <div class="row form-group"> | |
62 | - <label for="questionType" class="col-md-2 control-label">{% trans "Question Type" %}</label> | |
58 | + <div class="row form-group" id="buttonAddQuestion"> | |
63 | 59 | <div class="col-md-10"> |
64 | - <select id="questionType" class="form-control" name="option_question" onchange="showDiv (this)"> | |
65 | - <option selected disabled>{% trans "Question Type" %}</option> | |
66 | - <option value="0">{% trans "Multiple Choice" %}</option> | |
67 | - <option value="1">{% trans "True or False" %}</option> | |
68 | - <option value="2">{% trans "Gap Filling" %}</option> | |
69 | - <option value="3">{% trans "Discursive Question" %}</option> | |
70 | - </select> | |
60 | + <button id="addQuestion" type="button" class="btn btn-raised btn-default">Add new question buton</button> | |
71 | 61 | </div> |
72 | 62 | </div> |
73 | 63 | <!-- Modal Footer --> |
74 | 64 | <div class="modal-footer"> |
75 | - | |
76 | 65 | <!-- Don't remove that!!! --> |
77 | - <button type="button" class="btn btn-danger btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
66 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
78 | 67 | {% block button_save %} |
79 | 68 | <!-- Put curtom buttons here!!! --> |
80 | 69 | <button type="submite" id="button" form="form" class="btn btn-primary btn-raised">{% trans "Create" %}</button> |
... | ... | @@ -88,50 +77,4 @@ |
88 | 77 | </div> |
89 | 78 | </div> |
90 | 79 | |
91 | -<script type="text/javascript"> | |
92 | - | |
93 | -var id = 1; | |
94 | -$("#add_question").click(function(){ | |
95 | - $.get("{% url 'course:exam:true_or_false_question' %}", function(data){ | |
96 | - | |
97 | - $("#questions").append(data); | |
98 | - | |
99 | - $("#0").attr("id","true_" + id++); | |
100 | - }); | |
101 | -}); | |
102 | -var alternativeValue = 3; | |
103 | -$('#newAlternative').click(function () { | |
104 | - var element = '<div class="radio radio-primary">' + | |
105 | - '<label>' + | |
106 | - '<input type="radio" name="alternatives" id="alternative4"' + 'value="' +alternativeValue + '">' + | |
107 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | |
108 | - '</label>' + | |
109 | - '</div>'; | |
110 | - $('#radios').append(element); | |
111 | - alternativeValue++; | |
112 | -}); | |
113 | -var tfAlternativeValue = 3; | |
114 | -$('#tfAlternative').click(function () { | |
115 | - var element = '<div class="radio radio-primary">' + | |
116 | - '<label>' + | |
117 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | |
118 | - '</label>' + | |
119 | - '<label>' + | |
120 | - '<input type="radio" name="alternative' + tfAlternativeValue +'" value="T">' + | |
121 | - '</label>' + | |
122 | - '<label>' + | |
123 | - '<input type="radio" name="alternative2" value="F">' + | |
124 | - '</label>' + | |
125 | - '</div>'; | |
126 | - $('#radiosTF').append(element); | |
127 | - tfAlternativeValue++; | |
128 | -}); | |
129 | -$(function() { | |
130 | - $( "#begin_date,#end_date" ).datepicker(); | |
131 | -}); | |
132 | - | |
133 | -</script> | |
134 | - | |
135 | - | |
136 | - | |
137 | 80 | {% endblock content %} | ... | ... |