Commit fa76f97b7ec3f6b6d23e387cb757ec7203fe853d
1 parent
3c790105
Exists in
pdf_file_html
and in
1 other branch
successfully removed exam app from project
Showing
37 changed files
with
6 additions
and
1386 deletions
Show diff stats
amadeus/settings.py
courses/templates/subject/exam_item_actions.html
@@ -1,20 +0,0 @@ | @@ -1,20 +0,0 @@ | ||
1 | -{% load static i18n permission_tags professor_access %} | ||
2 | - | ||
3 | -<script src="{% static 'js/modals_requisitions.js'%}"></script> | ||
4 | -<script src="{% static 'js/modal_exam.js'%}"></script> | ||
5 | - | ||
6 | -{% for exam in exams %} | ||
7 | - {% professor_subject exam.topic.subject request.user as permission%} | ||
8 | - {% if permission %} | ||
9 | - <li id="exam_{{exam.slug}}"><i class="material-icons">{% trans 'exam' %}</i> <a href="javascript:modal.get('{% url 'course:exam:update_exam' exam.slug %}','#exam','#modal_exam');">{{ exam.name }}</a><a href="javascript:modal.get('{% url 'course:exam:delete_exam' exam.slug %}','#exam','#modal_exam');"><span class="glyphicon glyphicon-remove"></span></a></li> | ||
10 | - {% else %} | ||
11 | - <li id="exam_{{exam.slug}}"><i class="material-icons">{% trans 'exam' %}</i> <a href="javascript:modal.get('{% url 'course:exam:view_exam' exam.slug %}','#exam','#modal_exam');">{{ exam.name }}</a></li> | ||
12 | - {% endif %} | ||
13 | - {% endfor %} | ||
14 | -{# <button class="btn btn-primary btn-raised" onclick="javascript:modal.get('{% url 'course:exam:create_exam' topic.slug%}','#exam','#modal_exam');">{% trans '+ Create Exam' %}</button> #} | ||
15 | -<div class="row" id="modal_exam"> | ||
16 | - | ||
17 | - | ||
18 | - | ||
19 | - | ||
20 | -</div> |
courses/templates/topic/topic_card.html
@@ -19,7 +19,6 @@ | @@ -19,7 +19,6 @@ | ||
19 | </div> | 19 | </div> |
20 | <ul> | 20 | <ul> |
21 | <div class="foruns_list"> | 21 | <div class="foruns_list"> |
22 | - {# {% list_topic_exam request topic %} #} | ||
23 | {% list_topic_poll request topic %} | 22 | {% list_topic_poll request topic %} |
24 | {% list_topic_foruns request topic %} | 23 | {% list_topic_foruns request topic %} |
25 | </div> | 24 | </div> |
courses/templates/topic/update.html
@@ -84,7 +84,6 @@ | @@ -84,7 +84,6 @@ | ||
84 | <ul class="dropdown-menu" aria-labelledby="dLabel"> | 84 | <ul class="dropdown-menu" aria-labelledby="dLabel"> |
85 | <li><a href="javascript:createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans 'Create Forum' %}</a></li> | 85 | <li><a href="javascript:createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans 'Create Forum' %}</a></li> |
86 | <li><a href="javascript:modal.get('{% url 'course:poll:create_poll' topic.slug%}','#poll','#requisicoes_ajax');">{% trans 'Create Poll' %}</a></li> | 86 | <li><a href="javascript:modal.get('{% url 'course:poll:create_poll' topic.slug%}','#poll','#requisicoes_ajax');">{% trans 'Create Poll' %}</a></li> |
87 | - <li><a href="{% url 'course:exam:create_exam' topic.slug %}">{% trans 'Create exam' %}</a></li> | ||
88 | </ul> | 87 | </ul> |
89 | </div> | 88 | </div> |
90 | </div> | 89 | </div> |
courses/templates/topic/view.html
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | <li><a href="javascript:createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans 'Create Forum' %}</a></li> | 52 | <li><a href="javascript:createForum('{% url 'course:forum:create' %}', '{{ topic.id }}')">{% trans 'Create Forum' %}</a></li> |
53 | <li><a href="javascript:modal.get('{% url 'course:poll:create_poll' topic.slug%}','#poll','#requisicoes_ajax');">{% trans 'Create Poll' %}</a></li> | 53 | <li><a href="javascript:modal.get('{% url 'course:poll:create_poll' topic.slug%}','#poll','#requisicoes_ajax');">{% trans 'Create Poll' %}</a></li> |
54 | 54 | ||
55 | - <li><a href="{% url 'course:exam:create_exam' topic.slug %}">{% trans 'Create exam' %}</a></li> | 55 | + |
56 | </ul> | 56 | </ul> |
57 | </div> | 57 | </div> |
58 | </div> | 58 | </div> |
courses/urls.py
@@ -28,7 +28,6 @@ urlpatterns = [ | @@ -28,7 +28,6 @@ urlpatterns = [ | ||
28 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), | 28 | url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), |
29 | url(r'^forum/', include('forum.urls', namespace = 'forum')), | 29 | url(r'^forum/', include('forum.urls', namespace = 'forum')), |
30 | url(r'^poll/', include('poll.urls', namespace = 'poll')), | 30 | url(r'^poll/', include('poll.urls', namespace = 'poll')), |
31 | - url(r'^exam/', include('exam.urls', namespace = 'exam')), | ||
32 | url(r'^files/', include('files.urls', namespace = 'file')), | 31 | url(r'^files/', include('files.urls', namespace = 'file')), |
33 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), | 32 | url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), |
34 | url(r'^subjects/file-material-view/(?P<slug>[\w_-]+)/$', views.FileMaterialView.as_view(), name='file_material_view'), | 33 | url(r'^subjects/file-material-view/(?P<slug>[\w_-]+)/$', views.FileMaterialView.as_view(), name='file_material_view'), |
exam/__init__.py
exam/admin.py
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -from django.contrib import admin | ||
2 | - | ||
3 | -from .models import Exam, Answer, AnswersStudent, Question, Alternative | ||
4 | - | ||
5 | -class ExamAdmin(admin.ModelAdmin): | ||
6 | - list_display = ['name', 'slug','begin_date','limit_date'] | ||
7 | - search_fields = ['name','slug'] | ||
8 | - | ||
9 | -class AnswerAdmin(admin.ModelAdmin): | ||
10 | - list_display = ['answer','order'] | ||
11 | - search_fields = ['answer'] | ||
12 | - | ||
13 | -class AnswersStudentAdmin(admin.ModelAdmin): | ||
14 | - list_display = ['student','exam','answered_in'] | ||
15 | - search_fields = ['student','exam'] | ||
16 | - | ||
17 | -admin.site.register(Exam, ExamAdmin) | ||
18 | -admin.site.register(Answer, AnswerAdmin) | ||
19 | -admin.site.register(AnswersStudent, AnswersStudentAdmin) | ||
20 | -admin.site.register(Question) | ||
21 | -admin.site.register(Alternative) |
exam/apps.py
exam/forms.py
@@ -1,37 +0,0 @@ | @@ -1,37 +0,0 @@ | ||
1 | -from django import forms | ||
2 | -from django.utils.translation import ugettext_lazy as _ | ||
3 | -from users.models import User | ||
4 | -from .models import Exam | ||
5 | - | ||
6 | -class ExamForm(forms.ModelForm): | ||
7 | - | ||
8 | - def __init__(self, *args, **kwargs): | ||
9 | - super(ExamForm, self).__init__(*args, **kwargs) | ||
10 | - self.fields["all_students"].required = False | ||
11 | - self.fields["all_students"].initial = False | ||
12 | - self.fields["students"].required = False | ||
13 | - | ||
14 | - def clean_all_students(self): | ||
15 | - if('all_students' not in self.data): | ||
16 | - if('students' in self.data): | ||
17 | - return False | ||
18 | - raise forms.ValidationError(_('It is required one these fields.')) | ||
19 | - else: | ||
20 | - all_students = self.data['all_students'] | ||
21 | - if(not all_students): | ||
22 | - raise forms.ValidationError(_('It is required one these fields.')) | ||
23 | - return True | ||
24 | - | ||
25 | - | ||
26 | - class Meta: | ||
27 | - model = Exam | ||
28 | - fields = ['name','begin_date','limit_date','students','all_students', 'begin_exam', 'end_exam'] | ||
29 | - | ||
30 | - widgets = { | ||
31 | - 'name': forms.TextInput(attrs={'placeholder': 'Exam?'}), | ||
32 | - 'begin_date': forms.DateTimeInput( | ||
33 | - attrs={'placeholder': _('Start date to resolve the exam')}), | ||
34 | - 'limit_date': forms.DateTimeInput( | ||
35 | - attrs={'placeholder': _('Maximum date permited to resolve the exam')}), | ||
36 | - 'student': forms.Select(), | ||
37 | - } |
exam/locale/pt_BR/LC_MESSAGES/django.po
@@ -1,190 +0,0 @@ | @@ -1,190 +0,0 @@ | ||
1 | -# SOME DESCRIPTIVE TITLE. | ||
2 | -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER | ||
3 | -# This file is distributed under the same license as the PACKAGE package. | ||
4 | -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
5 | -# | ||
6 | -#, fuzzy | ||
7 | -msgid "" | ||
8 | -msgstr "" | ||
9 | -"Project-Id-Version: PACKAGE VERSION\n" | ||
10 | -"Report-Msgid-Bugs-To: \n" | ||
11 | -"POT-Creation-Date: 2016-11-23 23:58-0300\n" | ||
12 | -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
13 | -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
14 | -"Language-Team: LANGUAGE <LL@li.org>\n" | ||
15 | -"Language: \n" | ||
16 | -"MIME-Version: 1.0\n" | ||
17 | -"Content-Type: text/plain; charset=UTF-8\n" | ||
18 | -"Content-Transfer-Encoding: 8bit\n" | ||
19 | -"Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
20 | - | ||
21 | -#: .\forms.py:18 .\forms.py:22 | ||
22 | -msgid "It is required one these fields." | ||
23 | -msgstr "É requerido um destes campos." | ||
24 | - | ||
25 | -#: .\forms.py:33 | ||
26 | -msgid "Start date to resolve the exam" | ||
27 | -msgstr "Data de início para resolver o exame" | ||
28 | - | ||
29 | -#: .\forms.py:35 | ||
30 | -msgid "Maximum date permited to resolve the exam" | ||
31 | -msgstr "Data máxima permitida para resolver o exame" | ||
32 | - | ||
33 | -#: .\models.py:9 | ||
34 | -msgid "Begin of Course Date" | ||
35 | -msgstr "Data de início do curso" | ||
36 | - | ||
37 | -#: .\models.py:10 | ||
38 | -msgid "Exibe?" | ||
39 | -msgstr "Exibir?" | ||
40 | - | ||
41 | -#: .\models.py:13 .\models.py:35 | ||
42 | -msgid "Exam" | ||
43 | -msgstr "Exame" | ||
44 | - | ||
45 | -#: .\models.py:14 | ||
46 | -msgid "Exams" | ||
47 | -msgstr "Exames" | ||
48 | - | ||
49 | -#: .\models.py:21 .\models.py:27 .\templates\exam\view.html:26 | ||
50 | -msgid "Answer" | ||
51 | -msgstr "Resposta" | ||
52 | - | ||
53 | -#: .\models.py:22 | ||
54 | -msgid "Order" | ||
55 | -msgstr "Ordem" | ||
56 | - | ||
57 | -#: .\models.py:23 .\models.py:28 | ||
58 | -msgid "Answers" | ||
59 | -msgstr "Respostas" | ||
60 | - | ||
61 | -#: .\models.py:34 | ||
62 | -msgid "Answered" | ||
63 | -msgstr "Respondida" | ||
64 | - | ||
65 | -#: .\models.py:36 | ||
66 | -msgid "Answers Students" | ||
67 | -msgstr "Resposta dos estudantes" | ||
68 | - | ||
69 | -#: .\models.py:37 | ||
70 | -msgid "Student" | ||
71 | -msgstr "Estudante" | ||
72 | - | ||
73 | -#: .\models.py:38 | ||
74 | -msgid "Answered Date" | ||
75 | -msgstr "Data da resposta" | ||
76 | - | ||
77 | -#: .\models.py:41 | ||
78 | -msgid "Answer Stundent" | ||
79 | -msgstr "Resposta do estudante" | ||
80 | - | ||
81 | -#: .\models.py:42 | ||
82 | -msgid "Answers Student" | ||
83 | -msgstr "Respostas dos estudantes" | ||
84 | - | ||
85 | -#: .\templates\exam\create.html:13 | ||
86 | -msgid "Create a Exam" | ||
87 | -msgstr "Criar um Exame" | ||
88 | - | ||
89 | -#: .\templates\exam\create.html:17 .\templates\exam\create.html:19 | ||
90 | -msgid "Exam Name" | ||
91 | -msgstr "Nome do exame" | ||
92 | - | ||
93 | -#: .\templates\exam\create.html:23 | ||
94 | -msgid "Exam's begin date" | ||
95 | -msgstr "Data de início do exame" | ||
96 | - | ||
97 | -#: .\templates\exam\create.html:25 | ||
98 | -msgid "Begin Date" | ||
99 | -msgstr "Data de início" | ||
100 | - | ||
101 | -#: .\templates\exam\create.html:27 | ||
102 | -msgid "Exam's end date" | ||
103 | -msgstr "Data final do exame" | ||
104 | - | ||
105 | -#: .\templates\exam\create.html:29 | ||
106 | -msgid "End Date" | ||
107 | -msgstr "Data final" | ||
108 | - | ||
109 | -#: .\templates\exam\create.html:36 | ||
110 | -msgid "Allow submissions after deadline?" | ||
111 | -msgstr "Permitir submissões após o prazo?" | ||
112 | - | ||
113 | -#: .\templates\exam\create.html:48 | ||
114 | -msgid "Close" | ||
115 | -msgstr "Fechar" | ||
116 | - | ||
117 | -#: .\templates\exam\create.html:51 | ||
118 | -msgid "Create" | ||
119 | -msgstr "Criar" | ||
120 | - | ||
121 | -#: .\templates\exam\questions\discursive_question.html:2 | ||
122 | -#: .\templates\exam\questions\discursive_question.html:4 | ||
123 | -#: .\templates\exam\questions\multiple_choice_question.html:5 | ||
124 | -#: .\templates\exam\questions\true_or_false_question.html:20 | ||
125 | -#: .\templates\exam\questions\true_or_false_question.html:25 | ||
126 | -msgid "Question" | ||
127 | -msgstr "Questão" | ||
128 | - | ||
129 | -#: .\templates\exam\questions\gap_filling_question.html:2 | ||
130 | -msgid "Gap Filling Question" | ||
131 | -msgstr "Questão de preenchimento de lacunas" | ||
132 | - | ||
133 | -#: .\templates\exam\questions\multiple_choice_question.html:15 | ||
134 | -msgid "Alternatives" | ||
135 | -msgstr "Alternativas" | ||
136 | - | ||
137 | -#: .\templates\exam\questions\multiple_choice_question.html:34 | ||
138 | -#: .\templates\exam\questions\true_or_false_question.html:45 | ||
139 | -msgid "New Alternative" | ||
140 | -msgstr "Nova alternativa" | ||
141 | - | ||
142 | -#: .\templates\exam\questions\true_or_false_answer.html:9 | ||
143 | -msgid "Write your alternative" | ||
144 | -msgstr "Escreva sua alternativa" | ||
145 | - | ||
146 | -#: .\templates\exam\questions\true_or_false_question.html:37 | ||
147 | -msgid "Alternatives: T/F" | ||
148 | -msgstr "Alternativas: V/F" | ||
149 | - | ||
150 | -#: .\templates\exam\remove.html:7 | ||
151 | -msgid "Delete Exam" | ||
152 | -msgstr "Apagar exame" | ||
153 | - | ||
154 | -#: .\templates\exam\remove.html:15 | ||
155 | -msgid "Are you sure you want to delete the subject" | ||
156 | -msgstr "Você tem certeza que deseja apagar o assunto?" | ||
157 | - | ||
158 | -#: .\templates\exam\remove.html:20 | ||
159 | -msgid "Delete" | ||
160 | -msgstr "Apagar" | ||
161 | - | ||
162 | -#: .\templates\exam\update.html:7 | ||
163 | -msgid "Update a Exam" | ||
164 | -msgstr "Atualizar um Exame" | ||
165 | - | ||
166 | -#: .\templates\exam\update.html:12 | ||
167 | -msgid "Update" | ||
168 | -msgstr "Atualizar" | ||
169 | - | ||
170 | -#: .\templates\exam\view.html:17 | ||
171 | -msgid "Limit date:" | ||
172 | -msgstr "Data limite:" | ||
173 | - | ||
174 | -#~ msgid "Question Type" | ||
175 | -#~ msgstr "Tipo de questão" | ||
176 | - | ||
177 | -#~ msgid "Multiple Choice" | ||
178 | -#~ msgstr "Múltipla escolha" | ||
179 | - | ||
180 | -#~ msgid "True or False" | ||
181 | -#~ msgstr "Verdadeiro ou falso" | ||
182 | - | ||
183 | -#~ msgid "Gap Filling" | ||
184 | -#~ msgstr "Preenchimento de lacunas" | ||
185 | - | ||
186 | -#~ msgid "Discursive Question" | ||
187 | -#~ msgstr "Questão discursiva" | ||
188 | - | ||
189 | -#~ msgid "add question" | ||
190 | -#~ msgstr "Adicionar questão" |
exam/migrations/0001_initial.py
@@ -1,62 +0,0 @@ | @@ -1,62 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | -# Generated by Django 1.10 on 2016-11-24 15:17 | ||
3 | -from __future__ import unicode_literals | ||
4 | - | ||
5 | -from django.db import migrations, models | ||
6 | -import django.db.models.deletion | ||
7 | - | ||
8 | - | ||
9 | -class Migration(migrations.Migration): | ||
10 | - | ||
11 | - initial = True | ||
12 | - | ||
13 | - dependencies = [ | ||
14 | - ('courses', '0001_initial'), | ||
15 | - ] | ||
16 | - | ||
17 | - operations = [ | ||
18 | - migrations.CreateModel( | ||
19 | - name='Answer', | ||
20 | - fields=[ | ||
21 | - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
22 | - ('answer', models.CharField(max_length=300, verbose_name='Answer')), | ||
23 | - ('order', models.PositiveSmallIntegerField(verbose_name='Order')), | ||
24 | - ], | ||
25 | - options={ | ||
26 | - 'verbose_name': 'Answer', | ||
27 | - 'verbose_name_plural': 'Answers', | ||
28 | - 'ordering': ('order',), | ||
29 | - }, | ||
30 | - ), | ||
31 | - migrations.CreateModel( | ||
32 | - name='AnswersStudent', | ||
33 | - fields=[ | ||
34 | - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
35 | - ('status', models.BooleanField(default=False, verbose_name='Answered')), | ||
36 | - ('answered_in', models.DateTimeField(auto_now=True, verbose_name='Answered Date')), | ||
37 | - ('answer', models.ManyToManyField(related_name='student_answer', to='exam.Answer', verbose_name='Answers Students')), | ||
38 | - ], | ||
39 | - options={ | ||
40 | - 'verbose_name': 'Answer Stundent', | ||
41 | - 'verbose_name_plural': 'Answers Student', | ||
42 | - }, | ||
43 | - ), | ||
44 | - migrations.CreateModel( | ||
45 | - name='Exam', | ||
46 | - fields=[ | ||
47 | - ('activity_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='courses.Activity')), | ||
48 | - ('begin_date', models.DateField(blank=True, verbose_name='Begin of Course Date')), | ||
49 | - ('exibe', models.BooleanField(default=False, verbose_name='Exibe?')), | ||
50 | - ], | ||
51 | - options={ | ||
52 | - 'verbose_name': 'Exam', | ||
53 | - 'verbose_name_plural': 'Exams', | ||
54 | - }, | ||
55 | - bases=('courses.activity',), | ||
56 | - ), | ||
57 | - migrations.AddField( | ||
58 | - model_name='answersstudent', | ||
59 | - name='exam', | ||
60 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student_exam', to='exam.Exam', verbose_name='Exam'), | ||
61 | - ), | ||
62 | - ] |
exam/migrations/0002_auto_20161124_1217.py
@@ -1,30 +0,0 @@ | @@ -1,30 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | -# Generated by Django 1.10 on 2016-11-24 15:17 | ||
3 | -from __future__ import unicode_literals | ||
4 | - | ||
5 | -from django.conf import settings | ||
6 | -from django.db import migrations, models | ||
7 | -import django.db.models.deletion | ||
8 | - | ||
9 | - | ||
10 | -class Migration(migrations.Migration): | ||
11 | - | ||
12 | - initial = True | ||
13 | - | ||
14 | - dependencies = [ | ||
15 | - migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
16 | - ('exam', '0001_initial'), | ||
17 | - ] | ||
18 | - | ||
19 | - operations = [ | ||
20 | - migrations.AddField( | ||
21 | - model_name='answersstudent', | ||
22 | - name='student', | ||
23 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student', to=settings.AUTH_USER_MODEL, verbose_name='Student'), | ||
24 | - ), | ||
25 | - migrations.AddField( | ||
26 | - model_name='answer', | ||
27 | - name='exam', | ||
28 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='exam.Exam', verbose_name='Answers'), | ||
29 | - ), | ||
30 | - ] |
exam/migrations/0003_auto_20161125_0808.py
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | -# Generated by Django 1.10 on 2016-11-25 11:08 | ||
3 | -from __future__ import unicode_literals | ||
4 | - | ||
5 | -from django.db import migrations, models | ||
6 | -import django.utils.timezone | ||
7 | - | ||
8 | - | ||
9 | -class Migration(migrations.Migration): | ||
10 | - | ||
11 | - dependencies = [ | ||
12 | - ('exam', '0002_auto_20161124_1217'), | ||
13 | - ] | ||
14 | - | ||
15 | - operations = [ | ||
16 | - migrations.AddField( | ||
17 | - model_name='exam', | ||
18 | - name='begin_exam', | ||
19 | - field=models.DateField(blank=True, default=django.utils.timezone.now, verbose_name='Begin of Exam'), | ||
20 | - preserve_default=False, | ||
21 | - ), | ||
22 | - migrations.AddField( | ||
23 | - model_name='exam', | ||
24 | - name='end_exam', | ||
25 | - field=models.DateField(blank=True, default=django.utils.timezone.now, verbose_name='End of Exam'), | ||
26 | - preserve_default=False, | ||
27 | - ), | ||
28 | - ] |
exam/migrations/__init__.py
exam/models.py
@@ -1,56 +0,0 @@ | @@ -1,56 +0,0 @@ | ||
1 | -from django.utils.translation import ugettext_lazy as _ | ||
2 | -from django.db import models | ||
3 | -from autoslug.fields import AutoSlugField | ||
4 | -from users.models import User | ||
5 | -from core.models import Resource | ||
6 | -from courses.models import Activity | ||
7 | - | ||
8 | -class Exam(Activity): | ||
9 | - begin_date = models.DateField(_('Begin of Course Date'), blank=True) | ||
10 | - begin_exam = models.DateField(_('Begin of Exam'), blank = True) | ||
11 | - end_exam = models.DateField(_('End of Exam'), blank = True) | ||
12 | - exibe = models.BooleanField(_('Exibe?'), default=False) | ||
13 | - | ||
14 | - class Meta: | ||
15 | - verbose_name = _('Exam') | ||
16 | - verbose_name_plural = _('Exams') | ||
17 | - | ||
18 | - def __str__(self): | ||
19 | - return str(self.name) + str("/") + str(self.topic) | ||
20 | - | ||
21 | - | ||
22 | -class Answer(models.Model): | ||
23 | - answer = models.CharField(_("Answer"), max_length = 300) | ||
24 | - order = models.PositiveSmallIntegerField(_("Order")) | ||
25 | - exam = models.ForeignKey(Exam, verbose_name = _('Answers'), related_name='answers') | ||
26 | - | ||
27 | - class Meta: | ||
28 | - ordering = ('order',) | ||
29 | - verbose_name = _('Answer') | ||
30 | - verbose_name_plural = _('Answers') | ||
31 | - | ||
32 | - def __str__(self): | ||
33 | - return str(self.answer) + str("/") + str(self.exam) | ||
34 | - | ||
35 | -class AnswersStudent(models.Model): | ||
36 | - status = models.BooleanField(_("Answered"), default=False) | ||
37 | - exam = models.ForeignKey(Exam, verbose_name = _('Exam'), related_name='student_exam') | ||
38 | - answer = models.ManyToManyField(Answer,verbose_name = _('Answers Students'), related_name='student_answer') | ||
39 | - student = models.ForeignKey(User, verbose_name = _('Student'), related_name='student') | ||
40 | - answered_in = models.DateTimeField(_("Answered Date"),auto_now=True) | ||
41 | - | ||
42 | - class Meta: | ||
43 | - verbose_name = _('Answer Stundent') | ||
44 | - verbose_name_plural = _('Answers Student') | ||
45 | - | ||
46 | - def __str__(self): | ||
47 | - return str(self.student) + str("/") + str(self.exam) | ||
48 | - | ||
49 | -class Question(models.Model): | ||
50 | - exam = models.ForeignKey(Exam, verbose_name=_('Exam'), related_name='question_exam') | ||
51 | - statement = models.TextField(_("Statement"), blank=False) | ||
52 | - | ||
53 | -class Alternative(models.Model): | ||
54 | - question = models.ForeignKey(Question, verbose_name=_("Question"), related_name="alternative_question") | ||
55 | - statement = models.TextField(_("Statement"), blank=False) | ||
56 | - answer = models.BooleanField(_("answer"), default=False) | ||
57 | \ No newline at end of file | 0 | \ No newline at end of file |
exam/permissions.py
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -from rolepermissions.permissions import register_object_checker | ||
2 | -from amadeus.roles import SystemAdmin | ||
3 | - | ||
4 | -@register_object_checker() | ||
5 | -def edit_exam(role, user, exam): | ||
6 | - if (role == SystemAdmin): | ||
7 | - return True | ||
8 | - | ||
9 | - if (user in exam.topic.subject.professors.all()): | ||
10 | - return True | ||
11 | - | ||
12 | - return False | ||
13 | - | ||
14 | -@register_object_checker() | ||
15 | -def delete_exam(role, user, exam): | ||
16 | - if (role == SystemAdmin): | ||
17 | - return True | ||
18 | - | ||
19 | - if (user in exam.topic.subject.professors.all()): | ||
20 | - return True | ||
21 | - | ||
22 | - return False |
exam/static/css/exam.css
exam/static/js/Exam.js
@@ -1,130 +0,0 @@ | @@ -1,130 +0,0 @@ | ||
1 | - | ||
2 | - //Insert question choice | ||
3 | - function showDiv (elem, questionType_id) { | ||
4 | - if (elem.value == 0) { | ||
5 | - var questionChoice = | ||
6 | - '<div id="questionChoice_'+questionType_id+'">' + | ||
7 | - '<div class="row form-group">'+ | ||
8 | - '<label for="question-name" class="col-md-2 control-label">Question</label>'+ | ||
9 | - '<div class="col-md-10">'+ | ||
10 | - '<textarea class="form-control" rows="1" id="question-name" placeholder="Wording"></textarea>'+ | ||
11 | - '</div>'+ | ||
12 | - '</div>'+ | ||
13 | - '<div class="row form-group">'+ | ||
14 | - '<label for="alternatives" class="col-md-2 control-label">Alternatives</label>'+ | ||
15 | - '<div class="col-md-10" id="radios_'+questionType_id+'">'+ | ||
16 | - '<div class="radio radio-primary form-group">'+ | ||
17 | - '<label>'+ | ||
18 | - '<input checked type="radio" name="multiple-choice" id="alternative1" value="1">'+ | ||
19 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | ||
20 | - '</label>'+ | ||
21 | - '</div>'+ | ||
22 | - '<div class="radio radio-primary form-group">'+ | ||
23 | - '<label>'+ | ||
24 | - '<input type="radio" name="multiple-choice" id="alternative2" value="2">'+ | ||
25 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | ||
26 | - '</label>'+ | ||
27 | - '</div>'+ | ||
28 | - '</div>'+ | ||
29 | - '</div>'+ | ||
30 | - '<div class="row form-group">'+ | ||
31 | - '<div class="col-md-8 col-md-offset-2">'+ | ||
32 | - '<button type="button" class="btn btn-raised btn-primary" id="newAlternative_'+questionType_id+'" onclick="functionNewAlternative(radios_'+questionType_id+')">New Alternative</button>'+ | ||
33 | - '</div>'+ | ||
34 | - '</div>'+ | ||
35 | - '</div>'; | ||
36 | - } else if (elem.value == 1) { | ||
37 | - var questionChoice = | ||
38 | - '<div id="questionChoice_'+questionType_id+'">'+ | ||
39 | - '<div class="row form-group">'+ | ||
40 | - '<label for="question-name" class="col-md-2 control-label">Question True or False</label>'+ | ||
41 | - '<div class="col-md-10">'+ | ||
42 | - '<textarea class="form-control" rows="1" id="question-name" placeholder="Wording"></textarea>'+ | ||
43 | - '</div>'+ | ||
44 | - '</div>'+ | ||
45 | - '<div class="row form-group">'+ | ||
46 | - '<label for="alternative" class="col-md-2 control-label">Alternatives: T/F</label>'+ | ||
47 | - '<div class="col-md-10" id="radiosTF_'+questionType_id+'">'+ | ||
48 | - '<div class="radio radio-primary form-group" value="1">'+ | ||
49 | - '<label class="primary-label-TF">'+ | ||
50 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | ||
51 | - '</label>'+ | ||
52 | - '<label>'+ | ||
53 | - '<input type="radio" name="true-or-false-1" value="T">'+ | ||
54 | - '</label>'+ | ||
55 | - '<label>'+ | ||
56 | - '<input type="radio" name="true-or-false-1" value="F">'+ | ||
57 | - '</label>'+ | ||
58 | - '</div>'+ | ||
59 | - '<div class="radio radio-primary form-group" value="2">'+ | ||
60 | - '<label class="primary-label-TF">'+ | ||
61 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | ||
62 | - '</label>'+ | ||
63 | - '<label>'+ | ||
64 | - '<input type="radio" name="true-or-false-2" value="T">'+ | ||
65 | - '</label>'+ | ||
66 | - '<label>'+ | ||
67 | - '<input type="radio" name="true-or-false-2" value="F">'+ | ||
68 | - '</label>'+ | ||
69 | - '</div>'+ | ||
70 | - '</div>'+ | ||
71 | - '</div>'+ | ||
72 | - '<div class="row form-group">'+ | ||
73 | - '<div class="col-md-8 col-md-offset-2">'+ | ||
74 | - '<button type="button" class="btn btn-raised btn-primary" id="newAlternative_'+questionType_id+'" onclick="functionNewAlternativeTF(radiosTF_'+questionType_id+')">New Alternative</button>'+ | ||
75 | - '</div>'+ | ||
76 | - '</div>'+ | ||
77 | - '</div>'; | ||
78 | - } else if (elem.value == 3) { | ||
79 | - var questionChoice = | ||
80 | - '<div id="questionChoice_'+questionType_id+'">'+ | ||
81 | - '<div class="row form-group">'+ | ||
82 | - '<label for="question-name" class="col-md-2 control-label">Name Question discursive</label>'+ | ||
83 | - '<div class="col-md-10">'+ | ||
84 | - '<textarea class="form-control" rows="2" id="question" placeholder="Wording"></textarea>'+ | ||
85 | - '</div>'+ | ||
86 | - '</div>'+ | ||
87 | - '</div>'; | ||
88 | - } | ||
89 | - if(document.getElementById('questionChoice_'+ questionType_id)){ | ||
90 | - $('#questionChoice_'+ questionType_id).detach(); | ||
91 | - } | ||
92 | - $(questionChoice).insertBefore('#hr_'+questionType_id); | ||
93 | - $('.primary-label-TF').css('padding-left', '0px'); | ||
94 | - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | ||
95 | - } | ||
96 | -//Bug quando criamos sem ser na ordem | ||
97 | -function functionNewAlternative(Question_Id){ | ||
98 | - var alternative = parseInt($(Question_Id).find("input:last").val()) + 1; | ||
99 | - var element = '<div class="radio radio-primary form-group">' + | ||
100 | - '<label>' + | ||
101 | - '<input type="radio" name="alternatives" id="alternative_'+alternative+'_'+Question_Id+'"' + 'value="'+alternative+'">' + | ||
102 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>' + | ||
103 | - '</label>'+ | ||
104 | - '</div>'; | ||
105 | - $(Question_Id).append(element); | ||
106 | - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | ||
107 | -} | ||
108 | -function functionNewAlternativeTF(Question_Id){ | ||
109 | - var alternative = parseInt($('#radiosTF_1').find('div:last').attr('value')) + 1; | ||
110 | - var element = | ||
111 | - '<div class="radio radio-primary form-group" value="'+alternative+'">'+ | ||
112 | - '<label class="primary-label-TF" >'+ | ||
113 | - '<textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea>'+ | ||
114 | - '</label>'+ | ||
115 | - '<label>'+ | ||
116 | - '<input type="radio" name="true-or-false-2" value="T">'+ | ||
117 | - '</label>'+ | ||
118 | - '<label>'+ | ||
119 | - '<input type="radio" name="true-or-false-2" value="F">'+ | ||
120 | - '</label>'+ | ||
121 | - '</div>'; | ||
122 | - $(Question_Id).append(element); | ||
123 | - $('.primary-label-TF').css('padding-left', '0px'); | ||
124 | - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. | ||
125 | -} | ||
126 | -var locale = navigator.language || navigator.userLanguage; | ||
127 | - | ||
128 | - $('.date-picker').datepicker({ | ||
129 | - language: locale, | ||
130 | - }); | ||
131 | \ No newline at end of file | 0 | \ No newline at end of file |
exam/templates/exam/create.html
@@ -1,112 +0,0 @@ | @@ -1,112 +0,0 @@ | ||
1 | -{% extends 'subject/index.html' %} | ||
2 | - | ||
3 | -{% load i18n widget_tweaks static django_bootstrap_breadcrumbs %} | ||
4 | - | ||
5 | -{% block style %} | ||
6 | - <link rel="stylesheet" type="text/css" href="{% static 'css/exam.css' %}"> | ||
7 | -{% endblock %} | ||
8 | - | ||
9 | -{% block breadcrumbs %} | ||
10 | - {{ block.super }} | ||
11 | - {% breadcrumb 'Create exam' 'course:create_exam' %} | ||
12 | -{% endblock breadcrumbs %} | ||
13 | - | ||
14 | -{% block content %} | ||
15 | -<div class="panel panel-primary"> | ||
16 | - <div class="panel-heading"> | ||
17 | - <h4 class="panel-title" id="exam-title">{% trans "Create a Exam" %}</h4> | ||
18 | - </div> | ||
19 | - <div class="panel-body"> | ||
20 | - {% csrf_token %} | ||
21 | - {% for field in form %} | ||
22 | - {% if field.auto_id != 'id_begin_exam' and field.auto_id != 'id_end_exam' and field.auto_id != 'id_begin_date' and field.auto_id != 'id_limit_date' %} | ||
23 | - <div class="row form-group"> | ||
24 | - {% if field.field.required %} | ||
25 | - <label for="{{ field.auto_id }}" class="col-md-2 control-label">{{ field.label }}</label> | ||
26 | - {% else %} | ||
27 | - <label for="{{ field.auto_id }}" class="col-md-2 control-label">{{ field.label }}</label> | ||
28 | - {% endif %} | ||
29 | - <div class="col-md-10"> | ||
30 | - {% if field.auto_id == 'id_all_students' %} | ||
31 | - {% render_field field class='form-control input-sm' %} | ||
32 | - {% else %} | ||
33 | - {% render_field field class='form-control input-sm' %} | ||
34 | - {% endif %} | ||
35 | - </div> | ||
36 | - </div> | ||
37 | - {% endif %} | ||
38 | - {% endfor %} | ||
39 | - <div class="row form-group"> | ||
40 | - {% for field in form %} | ||
41 | - {% if field.auto_id == 'id_begin_date' or field.auto_id == 'id_limit_date' %} | ||
42 | - {% if field.field.required %} | ||
43 | - <label for="{{ field.auto_id }}" class="col-md-2 control-label">{{ field.label }}</label> | ||
44 | - {% else %} | ||
45 | - <label for="{{ field.auto_id }}" class="col-md-2 control-label">{{ field.label }}</label> | ||
46 | - {% endif %} | ||
47 | - <div class="col-md-4"> | ||
48 | - {% render_field field class='form-control date-picker' %} | ||
49 | - </div> | ||
50 | - {% endif %} | ||
51 | - {% endfor %} | ||
52 | - </div> | ||
53 | - | ||
54 | - <div class="row form-group"> | ||
55 | - <div class="col-md-10"> | ||
56 | - <div class="checkbox"> | ||
57 | - <label> | ||
58 | - <input type="checkbox" name="checkbox"><span class="checkbox-material"></span> {% trans "Allow submissions after deadline?" %} | ||
59 | - </label> | ||
60 | - </div> | ||
61 | - </div> | ||
62 | - </div> | ||
63 | - <div class="row form-group" id="buttonAddQuestion"> | ||
64 | - <div class="col-md-10"> | ||
65 | - <button id="addQuestion" type="button" class="btn btn-raised btn-default">Add new question buton</button> | ||
66 | - </div> | ||
67 | - </div> | ||
68 | - </div> | ||
69 | - <div class="panel-footer"> | ||
70 | - <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | ||
71 | - {% block button_save %} | ||
72 | - <!-- Put curtom buttons here!!! --> | ||
73 | - <button type="submite" id="button" form="form" class="btn btn-primary btn-raised">{% trans "Create" %}</button> | ||
74 | - {% endblock button_save %} | ||
75 | - </div> | ||
76 | -</div> | ||
77 | - | ||
78 | -{% block javascript %} | ||
79 | - <script type="text/javascript"> | ||
80 | - //Insert Create select with question type | ||
81 | - var idQuestionType = 1; | ||
82 | - $("#addQuestion").on("click", function(event){ | ||
83 | - var title = '<h3 class="title-questions-exam">Choice your questions:</h3><br/>'; | ||
84 | - var element = | ||
85 | - '<div class="row form-group" id="questionType_' + idQuestionType +'">' + | ||
86 | - '<label for="questionType" class="col-md-2 control-label">' + | ||
87 | - '{% trans "Question Type" %}</label>' + '<div class="col-md-10">' + | ||
88 | - '<select id="questionType'+ idQuestionType +'" class="form-control" name="option_question" onchange="showDiv (this, '+ idQuestionType +')">' + | ||
89 | - '<option selected disabled>{% trans "Question Type" %}</option>' + | ||
90 | - '<option value="0">{% trans "Multiple Choice" %}</option>' + | ||
91 | - '<option value="1">{% trans "True or False" %}</option>' + | ||
92 | - '<option value="2">{% trans "Gap Filling" %}</option>' + | ||
93 | - '<option value="3">{% trans "Discursive Question" %}</option>' + | ||
94 | - '</select>' + | ||
95 | - '</div>' + | ||
96 | - '</div>' + '<hr id="hr_'+idQuestionType+'">' | ||
97 | - ; | ||
98 | - if (idQuestionType == 1){ | ||
99 | - $(title).insertBefore('#buttonAddQuestion'); | ||
100 | - $(element).insertBefore('#buttonAddQuestion'); | ||
101 | - }else{ | ||
102 | - var idhr = '#hr_'+(idQuestionType-1); | ||
103 | - $(element).insertAfter(idhr); | ||
104 | - } | ||
105 | - idQuestionType++; | ||
106 | - }) | ||
107 | - </script> | ||
108 | - <script src="{% static 'js/Exam.js' %}"></script> | ||
109 | - <!-- Init material Bootstrap --> | ||
110 | - <script type="text/javascript">$.material.init()</script><!-- O botao radio volta a funcionar quando coloco essa função--> | ||
111 | -{% endblock %} | ||
112 | -{% endblock content %} |
exam/templates/exam/questions/discursive_question.html
@@ -1,6 +0,0 @@ | @@ -1,6 +0,0 @@ | ||
1 | -<div class="form-group" id="discursiveQuestion"> | ||
2 | - <label for="question" class="col-md-2 control-label">{% trans "Question" %}</label> | ||
3 | - <div class="col-md-10"> | ||
4 | - <textarea class="form-control" rows="1" id="question" placeholder="{% trans 'Question' %}"></textarea> | ||
5 | - </div> | ||
6 | -</div> |
exam/templates/exam/questions/gap_filling_answer.html
exam/templates/exam/questions/gap_filling_question.html
exam/templates/exam/questions/multiple_choice_answer.html
exam/templates/exam/questions/multiple_choice_question.html
@@ -1,42 +0,0 @@ | @@ -1,42 +0,0 @@ | ||
1 | -{% load i18n %} | ||
2 | - | ||
3 | -<div class="form-group" id="multipleChoice"> | ||
4 | - | ||
5 | - <label for="questionName" class="col-md-2 control-label">{% trans 'Question' %}</label> | ||
6 | - | ||
7 | - | ||
8 | - <div class="col-md-10"> | ||
9 | - <textarea class="form-control" rows="1" id="questionName" placeholder="Wording"></textarea> | ||
10 | - </div> | ||
11 | - | ||
12 | - | ||
13 | -</div> | ||
14 | -<div class="form-group"> | ||
15 | - <label for="alternative" class="col-md-2 control-label">{% trans 'Alternatives' %}</label> | ||
16 | - <div class="col-md-10" id="radios"> | ||
17 | - <div class="radio radio-primary"> | ||
18 | - <label> | ||
19 | - <input checked type="radio" name="alternatives" id="alternative1" value="1"> | ||
20 | - <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | ||
21 | - </label> | ||
22 | - </div> | ||
23 | - <div class="radio radio-primary"> | ||
24 | - <label> | ||
25 | - <input type="radio" name="alternatives" id="alternative2" value="2"> | ||
26 | - <textarea class="form-control" rows="1" placeholder="Write your alternative"></textarea> | ||
27 | - </label> | ||
28 | - </div> | ||
29 | - </div> | ||
30 | -</div> | ||
31 | -<!-- new alternative button --> | ||
32 | -<div class="form-group"> | ||
33 | - <div class="col-md-12 col-md-offset-2"> | ||
34 | - <button type="button" class="btn btn-primary" id="newAlternative">{% trans 'New Alternative' %}</button> | ||
35 | - </div> | ||
36 | -</div> | ||
37 | -<div class="form-group"> | ||
38 | - <div class="col-md-12 col-md-offset-2"> | ||
39 | - <button type="submit" class="btn btn-primary">Save</button> | ||
40 | - <button type="cancel" class="btn btn-default">Cancel</button> | ||
41 | - </div> | ||
42 | -</div> |
exam/templates/exam/questions/true_or_false_answer.html
@@ -1,15 +0,0 @@ | @@ -1,15 +0,0 @@ | ||
1 | -{% load i18n %} | ||
2 | - | ||
3 | -<div class="row form-group" > | ||
4 | - <div class="col-md-1"> | ||
5 | - </br> | ||
6 | - <label><span class="glyphicon glyphicon-move"></span></label> | ||
7 | - </div> | ||
8 | - <div class="col-md-10"> | ||
9 | - <input class="form-control" placeholder='{% trans "Write your alternative" %}'></input> | ||
10 | - </div> | ||
11 | - <div class="col-md-1"> | ||
12 | - </br> | ||
13 | - <label><span class="glyphicon glyphicon-remove" onclick="this.parentNode.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode.parentNode);"></span></label> | ||
14 | - </div> | ||
15 | -</div> |
exam/templates/exam/questions/true_or_false_question.html
@@ -1,67 +0,0 @@ | @@ -1,67 +0,0 @@ | ||
1 | -{# {% extends "base.html" %} #} | ||
2 | - | ||
3 | -{% load i18n %} | ||
4 | -{# {% block content %} #} | ||
5 | -<style> | ||
6 | - .glyphicon-remove:hover { | ||
7 | - cursor: pointer; | ||
8 | - } | ||
9 | - .glyphicon-move:hover { | ||
10 | - cursor: move; | ||
11 | - } | ||
12 | -</style> | ||
13 | -<div class="" id="0"> | ||
14 | - <div class="row form-group"> | ||
15 | - <div class="col-md-1"> | ||
16 | - </br> | ||
17 | - <label><span class="glyphicon glyphicon-move"></span></label> | ||
18 | - </div> | ||
19 | - <div class="col-md-2"> | ||
20 | - <label for="questionName" class="control-label">{% trans "Question" %}</label> | ||
21 | - </div> | ||
22 | - <div class="col-md-9"> | ||
23 | - <div class="row"> | ||
24 | - <div class="col-md-11"> | ||
25 | - <input class="form-control" id="questionName" placeholder="{% trans 'Question' %}"></input> | ||
26 | - </div> | ||
27 | - <div class="col-md-1"> | ||
28 | - </br> | ||
29 | - <label><span class="glyphicon glyphicon-remove"></span></label> | ||
30 | - </div> | ||
31 | - </div> | ||
32 | - </div> | ||
33 | - | ||
34 | - </div> | ||
35 | - <div class="row"> | ||
36 | - <div class="col-md-offset-1 col-md-2"> | ||
37 | - <label class="control-label">{% trans "Alternatives: T/F" %}</label> | ||
38 | - </div> | ||
39 | - <div class="col-md-9" id="radiosTF"> | ||
40 | - {% include "exam/true_or_false_answer.html" %} | ||
41 | - </div> | ||
42 | - </div> | ||
43 | - <div class="form-group"> | ||
44 | - <div class="col-md-9 col-md-offset-3"> | ||
45 | - <button type="button" class="btn btn-primary btn-raised" id="new_alternative">{% trans "New Alternative" %}</button> | ||
46 | - </div> | ||
47 | - </div> | ||
48 | -</div> | ||
49 | -<script type="text/javascript"> | ||
50 | - $("#new_alternative").click(function(){ | ||
51 | - $.get("{% url 'course:exam:true_or_false_answer' %}", function(data){ | ||
52 | - $("#radiosTF").append(data); | ||
53 | - }); | ||
54 | - }); | ||
55 | - //deve ser importado apenas depois do html | ||
56 | - $( "#radiosTF" ).sortable({ // utilizado para fazer a re-organização das respostas | ||
57 | - delay: 100, | ||
58 | - distance: 5, | ||
59 | - update: function( event, ui ) { | ||
60 | - var cont = 1; | ||
61 | - $("#radiosTF div div input").each(function(){ | ||
62 | - $(this).attr('name',cont++); | ||
63 | - }); | ||
64 | - }, | ||
65 | - }); | ||
66 | -</script> | ||
67 | -{# {% endblock content %} #} |
exam/templates/exam/remove.html
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -{% extends "exam/create.html" %} | ||
2 | - | ||
3 | -{% load i18n static%} | ||
4 | - | ||
5 | -{% block title_exam %} | ||
6 | -<!-- Put your title here!!! --> | ||
7 | -<h4 class="modal-title" id="myModalLabel">{% trans "Delete Exam" %}</h4> | ||
8 | -{% endblock title_exam %} | ||
9 | - | ||
10 | -{% block content_exam %} | ||
11 | -<script src="{% static 'js/modal_exam.js' %}"></script> | ||
12 | -<!-- Put ONLY your content here!!! --> | ||
13 | -<form id="delete_form" action="" method="post"> | ||
14 | - {% csrf_token %} | ||
15 | - <p>{% trans 'Are you sure you want to delete the subject' %} "{{exam.name}}"?</p> | ||
16 | -</form> | ||
17 | -{% endblock content_exam %} | ||
18 | - | ||
19 | -{% block button_save %} | ||
20 | -<button type="submite" id="button" form="delete_form" class="btn btn-primary btn-raised">{% trans "Delete" %}</button> | ||
21 | -<script> | ||
22 | - $("#delete_form").submit(function(event) { | ||
23 | - Submite.remove("{% url 'course:exam:delete_exam' exam.slug %}",$(this).serialize(),"#exam_{{exam.slug}}"); | ||
24 | - event.preventDefault(); | ||
25 | - }); | ||
26 | -</script> | ||
27 | -{% endblock button_save %} |
exam/templates/exam/update.html
@@ -1,32 +0,0 @@ | @@ -1,32 +0,0 @@ | ||
1 | -{% extends "exam/create.html" %} | ||
2 | - | ||
3 | -{% load i18n dict_access static%} | ||
4 | - | ||
5 | -{% block title_exam %} | ||
6 | -<!-- Put your title here!!! --> | ||
7 | -<h4 class="modal-title" id="myModalLabel">{% trans "Update a Exam" %}</h4> | ||
8 | -{% endblock title_exam %} | ||
9 | - | ||
10 | -{% block button_save %} | ||
11 | -<!-- Put curtom buttons here!!! --> | ||
12 | -<button type="submite" id="button" form="form" class="btn btn-primary btn-raised">{% trans "Update" %}</button> | ||
13 | -{% endblock button_save %} | ||
14 | - | ||
15 | -{% block script_exam %} | ||
16 | -<script type="text/javascript"> | ||
17 | - var locale = navigator.language || navigator.userLanguage; | ||
18 | - | ||
19 | - $('.date-picker').datepicker({ | ||
20 | - language: locale, | ||
21 | - }); | ||
22 | -// Este js tem que ficar aqui se não o button add não vai funcionar | ||
23 | - $("#add").click(function (){ | ||
24 | - Answer.init('{% url "course:exam:answer_exam" %}'); | ||
25 | - }); | ||
26 | - | ||
27 | - $("#form").submit(function(event) { | ||
28 | - Submite.post("{% url 'course:exam:update_exam' exam.slug %}",$(this).serialize()); | ||
29 | - event.preventDefault(); | ||
30 | - }); | ||
31 | -</script> | ||
32 | -{% endblock script_exam %} |
exam/templates/exam/view.html
@@ -1,28 +0,0 @@ | @@ -1,28 +0,0 @@ | ||
1 | -{% extends "exam/create.html" %} | ||
2 | - | ||
3 | -{% load i18n dict_access static%} | ||
4 | - | ||
5 | -{% block style %} | ||
6 | -{% endblock %} | ||
7 | - | ||
8 | -{% block title_exam %} | ||
9 | -<!-- Put your title here!!! --> | ||
10 | -<h4 class="modal-title" id="myModalLabel">{{exam.name}}</h4> | ||
11 | -{% endblock title_exam %} | ||
12 | - | ||
13 | -{% block content_exam %} | ||
14 | -<!-- Put ONLY your content here!!! --> | ||
15 | -<div class="row"> | ||
16 | - <div class="col-md-10 col-md-offset-1"> | ||
17 | - <p>{% trans "Limit date:" %} {{exam.limit_date|date:'d/m/y'}}</p> | ||
18 | - </div> | ||
19 | - | ||
20 | -</div> | ||
21 | -{% endblock content_exam %} | ||
22 | - | ||
23 | -{% block button_save %} | ||
24 | -<!-- Put curtom buttons here!!! --> | ||
25 | -{% if not status %} | ||
26 | -<button type="button" onclick="javascript:modal.get('{% url 'course:exam:answer_student_exam' exam.slug%}','#exam','#modal_exam');$('div.modal-backdrop.fade.in').remove();" class="btn btn-primary btn-raised">{% trans "Answer" %}</button> | ||
27 | -{% endif %} | ||
28 | -{% endblock button_save %} |
exam/templatetags/__init__.py
exam/templatetags/dict_access.py
exam/tests.py
exam/urls.py
@@ -1,19 +0,0 @@ | @@ -1,19 +0,0 @@ | ||
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 | - url(r'^discursive-question/$',views.DiscursiveQuestion.as_view(), name="discursive_question"), | ||
13 | - url(r'^gap-filling-question/$',views.GapFillingQuestion.as_view(), name="gap_filling_question"), | ||
14 | - url(r'^gap-filling-answer/$',views.GapFillingAnswer.as_view(), name="gap_filling_answer"), | ||
15 | - url(r'^multiple-choice-question/$',views.MultipleChoiceQuestion.as_view(), name="multiple_choice_question"), | ||
16 | - url(r'^multiple-choice-answer/$',views.MultipleChoiceAnswer.as_view(), name="multiple_choice_answer"), | ||
17 | - url(r'^true-or-false-question/$',views.TrueOrFalseQuestion.as_view(), name="true_or_false_question"), | ||
18 | - url(r'^true-or-false-answer/$',views.TrueOrFalseAnswer.as_view(), name="true_or_false_answer"), | ||
19 | -] |
exam/views.py
@@ -1,380 +0,0 @@ | @@ -1,380 +0,0 @@ | ||
1 | -from django.shortcuts import render, get_object_or_404, redirect | ||
2 | -from django.views import generic | ||
3 | -from django.contrib.auth.decorators import login_required | ||
4 | -from django.core.paginator import Paginator, EmptyPage | ||
5 | -from django.contrib.auth.mixins import LoginRequiredMixin | ||
6 | -from rolepermissions.mixins import HasRoleMixin | ||
7 | -from django.core.urlresolvers import reverse_lazy | ||
8 | -from django.utils.translation import ugettext_lazy as _ | ||
9 | -from rolepermissions.verifications import has_role | ||
10 | -from rolepermissions.verifications import has_object_permission | ||
11 | -from django.db.models import Q | ||
12 | -from datetime import datetime | ||
13 | -import time | ||
14 | -# from django.views.generic.edit import FormMixin | ||
15 | - | ||
16 | -from .forms import ExamForm | ||
17 | -from .models import Exam, Answer, AnswersStudent | ||
18 | -from core.mixins import LogMixin, NotificationMixin | ||
19 | -from core.models import Log | ||
20 | -from users.models import User | ||
21 | -from courses.models import Course, Topic | ||
22 | - | ||
23 | -class ViewExam(LoginRequiredMixin, LogMixin, generic.DetailView): | ||
24 | - log_component = 'exam' | ||
25 | - log_resource = 'exam' | ||
26 | - log_action = 'viewed' | ||
27 | - log_context = {} | ||
28 | - | ||
29 | - model = Exam | ||
30 | - context_object_name = 'exam' | ||
31 | - template_name = 'exam/view.html' | ||
32 | - | ||
33 | - def get_object(self, queryset=None): | ||
34 | - return get_object_or_404(Topic, slug = self.kwargs.get('slug')) | ||
35 | - | ||
36 | - def get_context_data(self, **kwargs): | ||
37 | - context = super(ViewExam, self).get_context_data(**kwargs) | ||
38 | - exam = self.object | ||
39 | - context["topic"] = exam.topic | ||
40 | - context['course'] = exam.topic.subject.course | ||
41 | - context['subject'] = exam.topic.subject | ||
42 | - context['subjects'] = exam.topic.subject.course.subjects.all() | ||
43 | - | ||
44 | - answered = AnswersStudent.objects.filter(exam = exam, student=self.request.user) | ||
45 | - print (answered) | ||
46 | - if answered.count()<1: | ||
47 | - context['status'] = False | ||
48 | - else: | ||
49 | - context['status'] = answered[0].status | ||
50 | - | ||
51 | - self.log_context['exam_id'] = exam.id | ||
52 | - self.log_context['topic_id'] = exam.topic.id | ||
53 | - self.log_context['topic_name'] = exam.topic.name | ||
54 | - self.log_context['topic_slug'] = exam.topic.slug | ||
55 | - self.log_context['subject_id'] = exam.topic.subject.id | ||
56 | - self.log_context['subject_name'] = exam.topic.subject.name | ||
57 | - self.log_context['subject_slug'] = exam.topic.subject.slug | ||
58 | - self.log_context['course_id'] = exam.topic.subject.course.id | ||
59 | - self.log_context['course_name'] = exam.topic.subject.course.name | ||
60 | - self.log_context['course_slug'] = exam.topic.subject.course.slug | ||
61 | - self.log_context['course_category_id'] = exam.topic.subject.course.category.id | ||
62 | - self.log_context['course_category_name'] = exam.topic.subject.course.category.name | ||
63 | - self.request.session['time_spent'] = str(int(time.time())) | ||
64 | - | ||
65 | - super(ViewExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
66 | - | ||
67 | - self.request.session['log_id'] = Log.objects.latest('id').id | ||
68 | - | ||
69 | - return context | ||
70 | - | ||
71 | - | ||
72 | - | ||
73 | -class CreateExam(LoginRequiredMixin,HasRoleMixin, LogMixin, NotificationMixin, generic.CreateView): | ||
74 | - log_component = 'exam' | ||
75 | - log_resource = 'exam' | ||
76 | - log_action = 'create' | ||
77 | - log_context = {} | ||
78 | - | ||
79 | - allowed_roles = ['professor', 'system_admin'] | ||
80 | - login_url = reverse_lazy("core:home") | ||
81 | - redirect_field_name = 'next' | ||
82 | - model = Exam | ||
83 | - form_class = ExamForm | ||
84 | - context_object_name = 'exam' | ||
85 | - template_name = 'exam/create.html' | ||
86 | - | ||
87 | - def form_invalid(self, form,**kwargs): | ||
88 | - context = super(CreateExam, self).form_invalid(form) | ||
89 | - answers = {} | ||
90 | - for key in self.request.POST: | ||
91 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): | ||
92 | - answers[key] = self.request.POST[key] | ||
93 | - | ||
94 | - keys = sorted(answers) | ||
95 | - context.context_data['answers'] = answers | ||
96 | - context.context_data['keys'] = keys | ||
97 | - context.context_data['form'] = form | ||
98 | - context.status_code = 400 | ||
99 | - return context | ||
100 | - | ||
101 | - def form_valid(self, form): | ||
102 | - self.object = form.save(commit = False) | ||
103 | - topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) | ||
104 | - self.object.topic = topic | ||
105 | - self.object.name = str(self.object) | ||
106 | - self.object.save() | ||
107 | - | ||
108 | - super(CreateExam, self).createNotification(message="created an Exam "+ self.object.name, actor=self.request.user, | ||
109 | - resource_name=self.object.name, resource_link= reverse('course:exam:view_exam', args=[self.object.slug]), | ||
110 | - users=self.object.topic.subject.students.all()) | ||
111 | - for key in self.request.POST: | ||
112 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): | ||
113 | - answer = Answer(answer=self.request.POST[key],order=key,exam=self.object) | ||
114 | - answer.save() | ||
115 | - | ||
116 | - self.log_context['exam_id'] = self.object.id | ||
117 | - self.log_context['topic_id'] = self.object.topic.id | ||
118 | - self.log_context['topic_name'] = self.object.topic.name | ||
119 | - self.log_context['topic_slug'] = self.object.topic.slug | ||
120 | - self.log_context['subject_id'] = self.object.topic.subject.id | ||
121 | - self.log_context['subject_name'] = self.object.topic.subject.name | ||
122 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
123 | - self.log_context['course_id'] = self.object.topic.subject.course.id | ||
124 | - self.log_context['course_name'] = self.object.topic.subject.course.name | ||
125 | - self.log_context['course_slug'] = self.object.topic.subject.course.slug | ||
126 | - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id | ||
127 | - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name | ||
128 | - | ||
129 | - super(CreateExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
130 | - | ||
131 | - return self.render_to_response(self.get_context_data(form = form), status = 200) | ||
132 | - | ||
133 | - def get_context_data(self, **kwargs): | ||
134 | - context = super(CreateExam, self).get_context_data(**kwargs) | ||
135 | - topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) | ||
136 | - context['course'] = topic.subject.course | ||
137 | - context['subject'] = topic.subject | ||
138 | - context['subjects'] = topic.subject.course.subjects.all() | ||
139 | - return context | ||
140 | - | ||
141 | -class UpdateExam(LoginRequiredMixin,HasRoleMixin, LogMixin, generic.UpdateView): | ||
142 | - log_component = 'exam' | ||
143 | - log_resource = 'exam' | ||
144 | - log_action = 'update' | ||
145 | - log_context = {} | ||
146 | - | ||
147 | - allowed_roles = ['professor', 'system_admin'] | ||
148 | - login_url = reverse_lazy("core:home") | ||
149 | - redirect_field_name = 'next' | ||
150 | - model = Exam | ||
151 | - form_class = ExamForm | ||
152 | - context_object_name = 'exam' | ||
153 | - template_name = 'exam/update.html' | ||
154 | - success_url = reverse_lazy('core:home') | ||
155 | - | ||
156 | - def dispatch(self, *args, **kwargs): | ||
157 | - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) | ||
158 | - if(not has_object_permission('edit_exam', self.request.user, exam)): | ||
159 | - return self.handle_no_permission() | ||
160 | - return super(UpdateExam, self).dispatch(*args, **kwargs) | ||
161 | - | ||
162 | - def get_object(self, queryset=None): | ||
163 | - return get_object_or_404(Exam, slug = self.kwargs.get('slug')) | ||
164 | - | ||
165 | - def form_invalid(self, form,**kwargs): | ||
166 | - context = super(UpdateExam, self).form_invalid(form) | ||
167 | - answers = {} | ||
168 | - for key in self.request.POST: | ||
169 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): | ||
170 | - answers[key] = self.request.POST[key] | ||
171 | - | ||
172 | - keys = sorted(answers) | ||
173 | - context.context_data['answers'] = answers | ||
174 | - context.context_data['keys'] = keys | ||
175 | - context.context_data['form'] = form | ||
176 | - context.status_code = 400 | ||
177 | - return context | ||
178 | - | ||
179 | - def form_valid(self, form): | ||
180 | - exam = self.object | ||
181 | - exam = form.save(commit = False) | ||
182 | - exam.answers.all().delete() | ||
183 | - exam.save() | ||
184 | - | ||
185 | - | ||
186 | - for key in self.request.POST: | ||
187 | - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): | ||
188 | - answer = Answer(answer=self.request.POST[key],order=key,exam=exam) | ||
189 | - answer.save() | ||
190 | - | ||
191 | - self.log_context['exam_id'] = self.object.id | ||
192 | - self.log_context['topic_id'] = self.object.topic.id | ||
193 | - self.log_context['topic_name'] = self.object.topic.name | ||
194 | - self.log_context['topic_slug'] = self.object.topic.slug | ||
195 | - self.log_context['subject_id'] = self.object.topic.subject.id | ||
196 | - self.log_context['subject_name'] = self.object.topic.subject.name | ||
197 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
198 | - self.log_context['course_id'] = self.object.topic.subject.course.id | ||
199 | - self.log_context['course_name'] = self.object.topic.subject.course.name | ||
200 | - self.log_context['course_slug'] = self.object.topic.subject.course.slug | ||
201 | - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id | ||
202 | - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name | ||
203 | - | ||
204 | - super(UpdateExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
205 | - | ||
206 | - return super(UpdateExam, self).form_valid(form) | ||
207 | - | ||
208 | - def get_context_data(self, **kwargs): | ||
209 | - context = super(UpdateExam, self).get_context_data(**kwargs) | ||
210 | - exam = self.object | ||
211 | - context['course'] = exam.topic.subject.course | ||
212 | - context['subject'] = exam.topic.subject | ||
213 | - context['subjects'] = exam.topic.subject.course.subjects.all() | ||
214 | - | ||
215 | - answers = {} | ||
216 | - for answer in exam.answers.all(): | ||
217 | - answers[answer.order] = answer.answer | ||
218 | - | ||
219 | - keys = sorted(answers) | ||
220 | - context['answers'] = answers | ||
221 | - context['keys'] = keys | ||
222 | - | ||
223 | - return context | ||
224 | - | ||
225 | -class DeleteExam(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView): | ||
226 | - log_component = 'exam' | ||
227 | - log_resource = 'exam' | ||
228 | - log_action = 'delete' | ||
229 | - log_context = {} | ||
230 | - | ||
231 | - allowed_roles = ['professor', 'system_admin'] | ||
232 | - login_url = reverse_lazy("core:home") | ||
233 | - redirect_field_name = 'next' | ||
234 | - model = Exam | ||
235 | - template_name = 'exam/remove.html' | ||
236 | - | ||
237 | - def dispatch(self, *args, **kwargs): | ||
238 | - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) | ||
239 | - if(not has_object_permission('delete_exam', self.request.user, exam)): | ||
240 | - return self.handle_no_permission() | ||
241 | - return super(DeleteExam, self).dispatch(*args, **kwargs) | ||
242 | - | ||
243 | - | ||
244 | - def get_context_data(self, **kwargs): | ||
245 | - context = super(DeleteExam, self).get_context_data(**kwargs) | ||
246 | - context['course'] = self.object.topic.subject.course | ||
247 | - context['subject'] = self.object.topic.subject | ||
248 | - context['exam'] = self.object | ||
249 | - context['subjects'] = self.object.topic.subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) | ||
250 | - if (has_role(self.request.user,'system_admin')): | ||
251 | - context['subjects'] = self.object.topic.subject.course.subjects.all() | ||
252 | - return context | ||
253 | - | ||
254 | - def get_success_url(self): | ||
255 | - self.log_context['exam_id'] = self.object.id | ||
256 | - self.log_context['topic_id'] = self.object.topic.id | ||
257 | - self.log_context['topic_name'] = self.object.topic.name | ||
258 | - self.log_context['topic_slug'] = self.object.topic.slug | ||
259 | - self.log_context['subject_id'] = self.object.topic.subject.id | ||
260 | - self.log_context['subject_name'] = self.object.topic.subject.name | ||
261 | - self.log_context['subject_slug'] = self.object.topic.subject.slug | ||
262 | - self.log_context['course_id'] = self.object.topic.subject.course.id | ||
263 | - self.log_context['course_name'] = self.object.topic.subject.course.name | ||
264 | - self.log_context['course_slug'] = self.object.topic.subject.course.slug | ||
265 | - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id | ||
266 | - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name | ||
267 | - | ||
268 | - super(DeleteExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
269 | - | ||
270 | - return reverse_lazy('course:view_topic', kwargs={'slug' : self.object.topic.slug}) | ||
271 | - | ||
272 | -class AnswerExam(generic.TemplateView): | ||
273 | - template_name = 'exam/answer.html' | ||
274 | - | ||
275 | -class AnswerStudentExam(LoginRequiredMixin, LogMixin, generic.CreateView): | ||
276 | - log_component = 'exam' | ||
277 | - log_resource = 'exam' | ||
278 | - log_action = 'answer' | ||
279 | - log_context = {} | ||
280 | - | ||
281 | - model = AnswersStudent | ||
282 | - fields = ['status'] | ||
283 | - context_object_name = 'answer' | ||
284 | - template_name = 'exam/answer_student.html' | ||
285 | - | ||
286 | - def form_valid(self, form): | ||
287 | - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) | ||
288 | - answers = AnswersStudent( | ||
289 | - status = True, | ||
290 | - exam = exam, | ||
291 | - student = self.request.user, | ||
292 | - ) | ||
293 | - answers.save() | ||
294 | - | ||
295 | - for key in self.request.POST: | ||
296 | - if(key != 'csrfmiddlewaretoken'): | ||
297 | - answers.answer.add(exam.answers.all().filter(order=key)[0]) | ||
298 | - | ||
299 | - self.log_context['exam_id'] = exam.id | ||
300 | - self.log_context['topic_id'] = exam.topic.id | ||
301 | - self.log_context['topic_name'] = exam.topic.name | ||
302 | - self.log_context['topic_slug'] = exam.topic.slug | ||
303 | - self.log_context['subject_id'] = exam.topic.subject.id | ||
304 | - self.log_context['subject_name'] = exam.topic.subject.name | ||
305 | - self.log_context['subject_slug'] = exam.topic.subject.slug | ||
306 | - self.log_context['course_id'] = exam.topic.subject.course.id | ||
307 | - self.log_context['course_name'] = exam.topic.subject.course.name | ||
308 | - self.log_context['course_slug'] = exam.topic.subject.course.slug | ||
309 | - self.log_context['course_category_id'] = exam.topic.subject.course.category.id | ||
310 | - self.log_context['course_category_name'] = exam.topic.subject.course.category.name | ||
311 | - | ||
312 | - date_time_click = datetime.strptime(self.request.session.get('time_spent'), "%Y-%m-%d %H:%M:%S.%f") | ||
313 | - _now = datetime.now() | ||
314 | - | ||
315 | - time_spent = _now - date_time_click | ||
316 | - | ||
317 | - secs = time_spent.total_seconds() | ||
318 | - hours = int(secs / 3600) | ||
319 | - minutes = int(secs / 60) % 60 | ||
320 | - secs = secs % 60 | ||
321 | - | ||
322 | - self.log_context['timestamp_end'] = str(int(time.time())) | ||
323 | - self.log_context['time_spent'] = {} | ||
324 | - self.log_context['time_spent']['hours'] = hours | ||
325 | - self.log_context['time_spent']['minutes'] = minutes | ||
326 | - self.log_context['time_spent']['seconds'] = secs | ||
327 | - | ||
328 | - super(AnswerStudentExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) | ||
329 | - | ||
330 | - return self.render_to_response(self.get_context_data(form = form), status = 200) | ||
331 | - | ||
332 | - def get_context_data(self, **kwargs): | ||
333 | - context = super(AnswerStudentExam, self).get_context_data(**kwargs) | ||
334 | - print (self.kwargs.get('slug')) | ||
335 | - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) | ||
336 | - context['exam'] = exam | ||
337 | - context['topic'] = exam.topic | ||
338 | - context['course'] = exam.topic.subject.course | ||
339 | - context['subject'] = exam.topic.subject | ||
340 | - context['subjects'] = exam.topic.subject.course.subjects.all() | ||
341 | - | ||
342 | - print (self.request.method) | ||
343 | - answers = {} | ||
344 | - for answer in exam.answers.all(): | ||
345 | - answers[answer.order] = answer.answer | ||
346 | - | ||
347 | - keys = sorted(answers) | ||
348 | - context['answers'] = answers | ||
349 | - context['keys'] = keys | ||
350 | - | ||
351 | - self.log_context['timestamp_start'] = str(int(time.time())) | ||
352 | - self.request.session['time_spent'] = str(datetime.now()) | ||
353 | - | ||
354 | - return context | ||
355 | - | ||
356 | -class MultipleChoiceQuestion(generic.TemplateView): | ||
357 | - template_name = 'exam/multiple_choice_question.html' | ||
358 | - | ||
359 | - | ||
360 | -class MultipleChoiceAnswer(generic.TemplateView): | ||
361 | - template_name = 'exam/multiple_choice_answer.html' | ||
362 | - | ||
363 | - | ||
364 | -class DiscursiveQuestion(generic.TemplateView): | ||
365 | - template_name = 'exam/discursive_question.html' | ||
366 | - | ||
367 | - | ||
368 | -class TrueOrFalseQuestion(generic.TemplateView): | ||
369 | - template_name = 'exam/true_or_false_question.html' | ||
370 | - | ||
371 | - | ||
372 | -class TrueOrFalseAnswer(generic.TemplateView): | ||
373 | - template_name = 'exam/true_or_false_answer.html' | ||
374 | - | ||
375 | - | ||
376 | -class GapFillingQuestion(generic.TemplateView): | ||
377 | - template_name = 'exam/gap_filling_question.html' | ||
378 | - | ||
379 | -class GapFillingAnswer(generic.TemplateView): | ||
380 | - template_name = 'exam/gap_filling_answer.html' |
users/templates/users/search.html
@@ -94,26 +94,7 @@ | @@ -94,26 +94,7 @@ | ||
94 | </div> | 94 | </div> |
95 | {% endif %} | 95 | {% endif %} |
96 | 96 | ||
97 | -{% if exam_list %} | ||
98 | -<div class="panel-group"> | ||
99 | - <div class="panel panel-default"> | ||
100 | - <div class="panel-heading"> | ||
101 | - <h4 class="panel-title"> | ||
102 | - <a data-toggle="collapse" href="#Exam" id="bot3" style="color: black"> <i class="fa fa-caret-square-o-down" aria-hidden="true" id="down3"></i>Exam</a> | ||
103 | - </h4> | ||
104 | - </div> | ||
105 | - <div id="Exam" class="panel-collapse collapse"> | ||
106 | - <div class="panel-body"> | ||
107 | - {% for exam in exam_list %} | ||
108 | - {{exam.name}} | ||
109 | - {% endfor %} | ||
110 | 97 | ||
111 | - </div> | ||
112 | - | ||
113 | - </div> | ||
114 | - </div> | ||
115 | -</div> | ||
116 | -{% endif %} | ||
117 | 98 | ||
118 | {% if poll_list %} | 99 | {% if poll_list %} |
119 | <div class="panel-group"> | 100 | <div class="panel-group"> |
users/views.py
@@ -17,7 +17,7 @@ from links.models import Link | @@ -17,7 +17,7 @@ from links.models import Link | ||
17 | from poll.models import * | 17 | from poll.models import * |
18 | from forum.models import * | 18 | from forum.models import * |
19 | from files.models import * | 19 | from files.models import * |
20 | -from exam.models import * | 20 | + |
21 | from courses.models import * | 21 | from courses.models import * |
22 | 22 | ||
23 | #API IMPORTS | 23 | #API IMPORTS |
@@ -224,7 +224,6 @@ class SearchView(LoginRequiredMixin, generic.ListView): | @@ -224,7 +224,6 @@ class SearchView(LoginRequiredMixin, generic.ListView): | ||
224 | link_list = [] | 224 | link_list = [] |
225 | file_list = [] | 225 | file_list = [] |
226 | poll_list = [] | 226 | poll_list = [] |
227 | - exam_list = [] | ||
228 | forum_list = [] | 227 | forum_list = [] |
229 | qtd = 0 | 228 | qtd = 0 |
230 | 229 | ||
@@ -233,39 +232,35 @@ class SearchView(LoginRequiredMixin, generic.ListView): | @@ -233,39 +232,35 @@ class SearchView(LoginRequiredMixin, generic.ListView): | ||
233 | link_list = Link.objects.filter( Q(name__icontains=search)).order_by('name') | 232 | link_list = Link.objects.filter( Q(name__icontains=search)).order_by('name') |
234 | file_list = TopicFile.objects.filter(Q(name__icontains=search)).order_by('name') | 233 | file_list = TopicFile.objects.filter(Q(name__icontains=search)).order_by('name') |
235 | poll_list = Poll.objects.filter(Q(name__icontains=search)).order_by('name') | 234 | poll_list = Poll.objects.filter(Q(name__icontains=search)).order_by('name') |
236 | - exam_list = Exam.objects.filter(Q(name__icontains=search)).order_by('name') | ||
237 | forum_list = Forum.objects.filter(Q(name__icontains=search)).order_by('name') | 235 | forum_list = Forum.objects.filter(Q(name__icontains=search)).order_by('name') |
238 | - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) | 236 | + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) |
239 | 237 | ||
240 | elif has_role(self.request.user,'professor'): | 238 | elif has_role(self.request.user,'professor'): |
241 | topics = Topic.objects.filter(owner = self.request.user) | 239 | topics = Topic.objects.filter(owner = self.request.user) |
242 | links = Link.objects.all() | 240 | links = Link.objects.all() |
243 | files = TopicFile.objects.all() | 241 | files = TopicFile.objects.all() |
244 | polls = Poll.objects.all() | 242 | polls = Poll.objects.all() |
245 | - exams = Exam.objects.all() | 243 | + |
246 | forums = Forum.objects.all() | 244 | forums = Forum.objects.all() |
247 | if search != '': | 245 | if search != '': |
248 | link_list = sorted([link for link in links for topic in topics if (link.topic == topic) and ( search in link.name ) ],key = lambda x:x.name) | 246 | link_list = sorted([link for link in links for topic in topics if (link.topic == topic) and ( search in link.name ) ],key = lambda x:x.name) |
249 | - exam_list = sorted([exam for exam in exams for topic in topics if (exam.topic == topic) and ( search in exam.name ) ],key = lambda x:x.name) | ||
250 | file_list = sorted([arquivo for arquivo in files for topic in topics if (arquivo.topic == topic) and (search in arquivo.name ) ],key = lambda x:x.name) | 247 | file_list = sorted([arquivo for arquivo in files for topic in topics if (arquivo.topic == topic) and (search in arquivo.name ) ],key = lambda x:x.name) |
251 | poll_list = sorted([poll for poll in polls for topic in topics if (poll.topic == topic) and ( search in poll.name ) ],key = lambda x:x.name) | 248 | poll_list = sorted([poll for poll in polls for topic in topics if (poll.topic == topic) and ( search in poll.name ) ],key = lambda x:x.name) |
252 | forum_list = sorted([forum for forum in forums for topic in topics if (forum.topic == topic) and ( search in forum.name ) ],key = lambda x:x.name) | 249 | forum_list = sorted([forum for forum in forums for topic in topics if (forum.topic == topic) and ( search in forum.name ) ],key = lambda x:x.name) |
253 | - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) | 250 | + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) |
254 | 251 | ||
255 | elif has_role(self.request.user, 'student'): | 252 | elif has_role(self.request.user, 'student'): |
256 | if search != '': | 253 | if search != '': |
257 | link_list = Link.objects.filter( Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') | 254 | link_list = Link.objects.filter( Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') |
258 | file_list = TopicFile.objects.filter(Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') | 255 | file_list = TopicFile.objects.filter(Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') |
259 | poll_list = Poll.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') | 256 | poll_list = Poll.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') |
260 | - exam_list = Exam.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') | ||
261 | forum_list = Forum.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') | 257 | forum_list = Forum.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') |
262 | - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) | 258 | + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) |
263 | 259 | ||
264 | translated = _('You searched for... ') | 260 | translated = _('You searched for... ') |
265 | context['link_list'] = link_list | 261 | context['link_list'] = link_list |
266 | context['file_list'] = file_list | 262 | context['file_list'] = file_list |
267 | context['poll_list'] = poll_list | 263 | context['poll_list'] = poll_list |
268 | - context['exam_list'] = exam_list | ||
269 | context['forum_list'] = forum_list | 264 | context['forum_list'] = forum_list |
270 | context['qtd'] = qtd | 265 | context['qtd'] = qtd |
271 | context['search'] = translated + search | 266 | context['search'] = translated + search |