Commit 006e2c014ac58c3d3a041696ec76ebbdd1ee39c4
1 parent
715f05d8
Exists in
master
and in
5 other branches
edição no model e views do exam #171
Showing
6 changed files
with
288 additions
and
16 deletions
Show diff stats
amadeus/settings.py
courses/urls.py
... | ... | @@ -27,7 +27,7 @@ urlpatterns = [ |
27 | 27 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), |
28 | 28 | url(r'^forum/', include('forum.urls', namespace = 'forum')), |
29 | 29 | url(r'^poll/', include('poll.urls', namespace = 'poll')), |
30 | - # url(r'^exam/', include('exam.urls', namespace = 'exam')), | |
30 | + url(r'^exam/', include('exam.urls', namespace = 'exam')), | |
31 | 31 | url(r'^files/', include('files.urls', namespace = 'file')), |
32 | 32 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), |
33 | 33 | url(r'^links/',include('links.urls',namespace = 'links')), | ... | ... |
exam/models.py
... | ... | @@ -7,6 +7,7 @@ from courses.models import Activity |
7 | 7 | |
8 | 8 | class Exam(Activity): |
9 | 9 | begin_date = models.DateField(_('Begin of Course Date'), blank=True) |
10 | + exibe = models.BooleanField(_('Exibe?'), default=False) | |
10 | 11 | |
11 | 12 | class Meta: |
12 | 13 | verbose_name = _('Exam') |
... | ... | @@ -33,7 +34,7 @@ class AnswersStudent(models.Model): |
33 | 34 | status = models.BooleanField(_("Answered"), default=False) |
34 | 35 | exam = models.ForeignKey(Exam, verbose_name = _('Exam'), related_name='answers_stundet') |
35 | 36 | answer = models.ManyToManyField(Answer,verbose_name = _('Answers Students'), related_name='answers_stundet') |
36 | - student = models.ForeignKey(User, verbose_name = _('Student'), related_name='answers_stundent') | |
37 | + student = models.ForeignKey(User, verbose_name = _('Student'), related_name='answers_stundent_exam') | |
37 | 38 | answered_in = models.DateTimeField(_("Answered Date"),auto_now=True) |
38 | 39 | |
39 | 40 | class Meta: | ... | ... |
exam/templates/exam/create.html
... | ... | @@ -0,0 +1,270 @@ |
1 | +ma {% extends "base.html" %} | |
2 | +{% block content %} | |
3 | +<div class="modal fade" id="poll" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> | |
4 | + <div class="modal-dialog" role="document"> | |
5 | + <div class="modal-content"> | |
6 | + | |
7 | + <!-- Modal Header --> | |
8 | + <div class="modal-header"> | |
9 | + | |
10 | + {% block title_poll %} | |
11 | + <!-- Put your title here!!! --> | |
12 | + <h4 class="modal-title" id="myModalLabel">{% trans "Create a Exam" %}</h4> | |
13 | + {% endblock title_poll %} | |
14 | + </div> | |
15 | + <!-- Modal Body --> | |
16 | + <div class="modal-body"> | |
17 | + | |
18 | + {# <form id="ac" class="form-horizontal"> #} | |
19 | + {# <fieldset> #} | |
20 | + | |
21 | + <div class="form-group"> | |
22 | + <label for="examName" class="col-md-2 control-label">Exam Name</label> | |
23 | + | |
24 | + <div class="col-md-10"> | |
25 | + <input type="text" class="form-control" id="examName" placeholder="Exam Name"> | |
26 | + </div> | |
27 | + | |
28 | + | |
29 | + </div> | |
30 | + <div class="form-group"> | |
31 | + <label for="Date" class="col-md-2 control-label">Exam Period</label> | |
32 | + <div class="col-md-5"> | |
33 | + <input type="date" class="form-control" id="beginDate" placeholder="Begin Date"> | |
34 | + </div> | |
35 | + <div class="col-md-5"> | |
36 | + <input type="text" class="form-control" id="datepicker" placeholder="End Date"> | |
37 | + | |
38 | + </div> | |
39 | + </div> | |
40 | + <div class="form-group"> | |
41 | + <label for="deadline" class="col-md-2 control-label">Allow submissions after deadline?</label> | |
42 | + <div class="col-md-10"> | |
43 | + <label> | |
44 | + <input type="checkbox"> | |
45 | + </label> | |
46 | + </div> | |
47 | + </div> | |
48 | + <div class="form-group"> | |
49 | + <label for="questionType" class="col-md-2 control-label">Question Type</label> | |
50 | + <div class="col-md-10"> | |
51 | + <select id="questionType" class="form-control" onchange="showDiv (this)"> | |
52 | + <option selected disabled>Question Type</option> | |
53 | + <option value="0">Multiple Choice</option> | |
54 | + <option value="1">True or False</option> | |
55 | + <option value="2">Gap Filling</option> | |
56 | + <option value="3">Discursive Question</option> | |
57 | + </select> | |
58 | + </div> | |
59 | + </div> | |
60 | + <div class="form-group" id="multipleChoice" style="display: none;"> | |
61 | + <form class="form-horizontal"> | |
62 | + <fieldset> | |
63 | + <div class="form-group" id="multipleChoice"> | |
64 | + | |
65 | + <label for="questionName" class="col-md-2 control-label">Question</label> | |
66 | + | |
67 | + | |
68 | + <div class="col-md-10"> | |
69 | + <textarea class="form-control" rows="1" id="questionName" placeholder="Wording"></textarea> | |
70 | + </div> | |
71 | + | |
72 | + | |
73 | + </div> | |
74 | + <div class="form-group"> | |
75 | + <label for="alternative" class="col-md-2 control-label">Alternatives</label> | |
76 | + <div class="col-md-10" id="radios"> | |
77 | + <div class="radio radio-primary"> | |
78 | + <label> | |
79 | + <input checked type="radio" name="alternatives" id="alternative1" value="1"> | |
80 | + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | |
81 | + </label> | |
82 | + </div> | |
83 | + <div class="radio radio-primary"> | |
84 | + <label> | |
85 | + <input type="radio" name="alternatives" id="alternative2" value="2"> | |
86 | + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | |
87 | + </label> | |
88 | + </div> | |
89 | + </div> | |
90 | + </div> | |
91 | + <!-- new alternative button --> | |
92 | + <div class="form-group"> | |
93 | + <div class="col-md-12 col-md-offset-2"> | |
94 | + <button type="button" class="btn btn-primary" id="newAlternative">New Alternative</button> | |
95 | + </div> | |
96 | + </div> | |
97 | + <div class="form-group"> | |
98 | + <div class="col-md-12 col-md-offset-2"> | |
99 | + <button type="submit" class="btn btn-primary">Save</button> | |
100 | + <button type="cancel" class="btn btn-default">Cancel</button> | |
101 | + </div> | |
102 | + </div> | |
103 | + | |
104 | + </fieldset> | |
105 | +</form> | |
106 | + | |
107 | +<script> | |
108 | + var alternativeValue = 3; | |
109 | + | |
110 | + $('#newAlternative').click(function () { | |
111 | + var element = '<div class="radio radio-primary">' + | |
112 | + '<label>' + | |
113 | + '<input type="radio" name="alternatives" id="alternative4"' + 'value="' +alternativeValue + '">' + | |
114 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | |
115 | + '</label>' + | |
116 | + '</div>'; | |
117 | + $('#radios').append(element); | |
118 | + | |
119 | + alternativeValue++; | |
120 | + }); | |
121 | +</script> | |
122 | + </div> | |
123 | + <div class="form-group" id="trueOrFalse" style="display: none;"> | |
124 | + <form class="form-horizontal" id="true-or-false"> | |
125 | + <fieldset> | |
126 | + <div class="form-group" id="trueOrFalse"> | |
127 | + | |
128 | + <label for="questionName" class="col-md-2 control-label">Question</label> | |
129 | + | |
130 | + | |
131 | + <div class="col-md-10"> | |
132 | + <textarea class="form-control" rows="1" id="questionName" placeholder="Wording"></textarea> | |
133 | + </div> | |
134 | + | |
135 | + | |
136 | + </div> | |
137 | + <div class="form-group"> | |
138 | + <label for="alternative" class="col-md-2 control-label">Alternatives: T/F</label> | |
139 | + <div class="col-md-10" id="radiosTF"> | |
140 | + <!-- alternative --> | |
141 | + <div class="radio radio-primary"> | |
142 | + <label> | |
143 | + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | |
144 | + </label> | |
145 | + <label> | |
146 | + <input type="radio" name="alternative1" value="T"> | |
147 | + </label> | |
148 | + <label> | |
149 | + <input type="radio" name="alternative1" value="F"> | |
150 | + </label> | |
151 | + </div> | |
152 | + <!-- alternative --> | |
153 | + <div class="radio radio-primary"> | |
154 | + <label> | |
155 | + <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | |
156 | + </label> | |
157 | + <label> | |
158 | + <input type="radio" name="alternative2" value="T"> | |
159 | + </label> | |
160 | + <label> | |
161 | + <input type="radio" name="alternative2" value="F"> | |
162 | + </label> | |
163 | + </div> | |
164 | + </div> | |
165 | + </div> | |
166 | + <div class="form-group"> | |
167 | + <div class="col-md-12 col-md-offset-2"> | |
168 | + <button type="button" class="btn btn-primary" id="tfAlternative">New Alternative</button> | |
169 | + </div> | |
170 | + </div> | |
171 | + <div class="form-group"> | |
172 | + <div class="col-md-12 col-md-offset-2"> | |
173 | + <button type="submit" class="btn btn-primary">Save</button> | |
174 | + <button type="cancel" class="btn btn-default">Cancel</button> | |
175 | + </div> | |
176 | + </div> | |
177 | + | |
178 | + </fieldset> | |
179 | +</form> | |
180 | + | |
181 | +<script> | |
182 | + var tfAlternativeValue = 3; | |
183 | + | |
184 | + $('#tfAlternative').click(function () { | |
185 | + var element = '<div class="radio radio-primary">' + | |
186 | + '<label>' + | |
187 | + '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | |
188 | + '</label>' + | |
189 | + '<label>' + | |
190 | + '<input type="radio" name="alternative' + tfAlternativeValue +'" value="T">' + | |
191 | + '</label>' + | |
192 | + '<label>' + | |
193 | + '<input type="radio" name="alternative2" value="F">' + | |
194 | + '</label>' + | |
195 | + '</div>'; | |
196 | + $('#radiosTF').append(element); | |
197 | + | |
198 | + tfAlternativeValue++; | |
199 | + }); | |
200 | +</script> | |
201 | + </div> | |
202 | + <div class="form-group" id="gapFilling" style="display: none;"> | |
203 | + <p>Gap Filling Question</p> | |
204 | + </div> | |
205 | + <div class="form-group" id="discursiveQuestion" style="display: none;"> | |
206 | + <form class="form-horizontal" id="discursive-question"> | |
207 | + <fieldset> | |
208 | + <div class="form-group" id="discursiveQuestion"> | |
209 | + | |
210 | + <label for="question" class="col-md-2 control-label">Question</label> | |
211 | + | |
212 | + | |
213 | + <div class="col-md-10"> | |
214 | + <textarea class="form-control" rows="1" id="question" placeholder="Wording"></textarea> | |
215 | + </div> | |
216 | + | |
217 | + | |
218 | + </div> | |
219 | + | |
220 | + <div class="form-group"> | |
221 | + <div class="col-md-10 col-md-offset-2"> | |
222 | + <button type="submit" class="btn btn-primary">Save</button> | |
223 | + <button type="cancel" class="btn btn-default">Cancel</button> | |
224 | + </div> | |
225 | + </div> | |
226 | + | |
227 | + </fieldset> | |
228 | +</form> | |
229 | + </div> | |
230 | + <div class="form-group"> | |
231 | + <div class="col-md-12 col-md-offset-2"> | |
232 | + <button type="submit" class="btn btn-primary">Save</button> | |
233 | + <button type="cancel" class="btn btn-default">Cancel</button> | |
234 | + </div> | |
235 | + </div> | |
236 | + </form> | |
237 | + </fieldset> | |
238 | + </div> | |
239 | +</div> | |
240 | + | |
241 | +<script> | |
242 | + function showDiv (elem) { | |
243 | + if (elem.value == 0) { | |
244 | + document.getElementById('multipleChoice').style.display = "block"; | |
245 | + document.getElementById('trueOrFalse').style.display = "none"; | |
246 | + document.getElementById('gapFilling').style.display = "none"; | |
247 | + document.getElementById('discursiveQuestion').style.display = "none"; | |
248 | + } else if (elem.value == 1) { | |
249 | + document.getElementById('trueOrFalse').style.display = "block"; | |
250 | + document.getElementById('multipleChoice').style.display = "none"; | |
251 | + document.getElementById('gapFilling').style.display = "none"; | |
252 | + document.getElementById('discursiveQuestion').style.display = "none"; | |
253 | + } else if (elem.value == 2) { | |
254 | + document.getElementById('gapFilling').style.display = "block"; | |
255 | + document.getElementById('multipleChoice').style.display = "none"; | |
256 | + document.getElementById('trueOrFalse').style.display = "none"; | |
257 | + document.getElementById('discursiveQuestion').style.display = "none"; | |
258 | + } else if (elem.value == 3) { | |
259 | + document.getElementById('discursiveQuestion').style.display = "block"; | |
260 | + document.getElementById('multipleChoice').style.display = "none"; | |
261 | + document.getElementById('trueOrFalse').style.display = "none"; | |
262 | + document.getElementById('gapFilling').style.display = "none"; | |
263 | + } | |
264 | + } | |
265 | + | |
266 | + $(function() { | |
267 | + $( "#datepicker" ).datepicker(); | |
268 | + }); | |
269 | +</script> | |
270 | +{% endblock content %} | ... | ... |
exam/urls.py
1 | -# from django.conf.urls import url | |
2 | -# | |
3 | -# from . import views | |
4 | -# | |
5 | -# urlpatterns = [ | |
6 | -# url(r'^create/(?P<slug>[\w\-_]+)/$', views.CreateExam.as_view(), name='create_exam'), # exam slug | |
7 | -# url(r'^update/(?P<slug>[\w\-_]+)/$', views.UpdateExam.as_view(), name='update_exam'), # topic slug | |
8 | -# url(r'^view/(?P<slug>[\w\-_]+)/$', views.ViewExam.as_view(), name='view_exam'), # exam slug | |
9 | -# url(r'^delete/(?P<slug>[\w\-_]+)/$', views.DeleteExam.as_view(), name='delete_exam'), # exam | |
10 | -# url(r'^answer/$', views.AnswerExam.as_view(), name='answer_exam'), # exam | |
11 | -# url(r'^answer-exam/(?P<slug>[\w\-_]+)/$', views.AnswerStudentExam.as_view(), name='answer_student_exam'), # exam slug | |
12 | -# ] | |
1 | +from django.conf.urls import url | |
2 | + | |
3 | +from . import views | |
4 | + | |
5 | +urlpatterns = [ | |
6 | + url(r'^create/(?P<slug>[\w\-_]+)/$', views.CreateExam.as_view(), name='create_exam'), # exam slug | |
7 | + url(r'^update/(?P<slug>[\w\-_]+)/$', views.UpdateExam.as_view(), name='update_exam'), # topic slug | |
8 | + url(r'^view/(?P<slug>[\w\-_]+)/$', views.ViewExam.as_view(), name='view_exam'), # exam slug | |
9 | + url(r'^delete/(?P<slug>[\w\-_]+)/$', views.DeleteExam.as_view(), name='delete_exam'), # exam | |
10 | + url(r'^answer/$', views.AnswerExam.as_view(), name='answer_exam'), # exam | |
11 | + url(r'^answer-exam/(?P<slug>[\w\-_]+)/$', views.AnswerStudentExam.as_view(), name='answer_student_exam'), # exam slug | |
12 | +] | ... | ... |
exam/views.py
... | ... | @@ -113,7 +113,7 @@ class UpdateExam(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): |
113 | 113 | context = super(UpdateExam, self).form_invalid(form) |
114 | 114 | answers = {} |
115 | 115 | for key in self.request.POST: |
116 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): | |
116 | + if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): | |
117 | 117 | answers[key] = self.request.POST[key] |
118 | 118 | |
119 | 119 | keys = sorted(answers) |
... | ... | @@ -131,7 +131,7 @@ class UpdateExam(LoginRequiredMixin,HasRoleMixin,generic.UpdateView): |
131 | 131 | |
132 | 132 | |
133 | 133 | for key in self.request.POST: |
134 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): | |
134 | + if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): | |
135 | 135 | answer = Answer(answer=self.request.POST[key],order=key,exam=exam) |
136 | 136 | answer.save() |
137 | 137 | ... | ... |