diff --git a/amadeus/settings.py b/amadeus/settings.py index ab3230f..342a0a6 100644 --- a/amadeus/settings.py +++ b/amadeus/settings.py @@ -56,7 +56,6 @@ INSTALLED_APPS = [ 'app', 'courses', 'forum', - 'exam', 'poll', 'links', 'files', diff --git a/courses/templates/subject/exam_item_actions.html b/courses/templates/subject/exam_item_actions.html deleted file mode 100644 index 626934e..0000000 --- a/courses/templates/subject/exam_item_actions.html +++ /dev/null @@ -1,20 +0,0 @@ -{% load static i18n permission_tags professor_access %} - - - - -{% for exam in exams %} - {% professor_subject exam.topic.subject request.user as permission%} - {% if permission %} -
  • {% trans 'exam' %} {{ exam.name }}
  • - {% else %} -
  • {% trans 'exam' %} {{ exam.name }}
  • - {% endif %} - {% endfor %} -{# #} - diff --git a/courses/templates/topic/topic_card.html b/courses/templates/topic/topic_card.html index c0f39d2..b3353ea 100644 --- a/courses/templates/topic/topic_card.html +++ b/courses/templates/topic/topic_card.html @@ -19,7 +19,6 @@ diff --git a/courses/urls.py b/courses/urls.py index cd9e21b..3cdc6e8 100644 --- a/courses/urls.py +++ b/courses/urls.py @@ -28,7 +28,6 @@ urlpatterns = [ url(r'^subjects/categories$',views.IndexSubjectCategoryView.as_view(), name='subject_category_index'), url(r'^forum/', include('forum.urls', namespace = 'forum')), url(r'^poll/', include('poll.urls', namespace = 'poll')), - url(r'^exam/', include('exam.urls', namespace = 'exam')), url(r'^files/', include('files.urls', namespace = 'file')), url(r'^upload-material/$', views.UploadMaterialView.as_view(), name='upload_material'), url(r'^subjects/file-material-view/(?P[\w_-]+)/$', views.FileMaterialView.as_view(), name='file_material_view'), diff --git a/exam/__init__.py b/exam/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/exam/__init__.py +++ /dev/null diff --git a/exam/admin.py b/exam/admin.py deleted file mode 100644 index 004f01e..0000000 --- a/exam/admin.py +++ /dev/null @@ -1,21 +0,0 @@ -from django.contrib import admin - -from .models import Exam, Answer, AnswersStudent, Question, Alternative - -class ExamAdmin(admin.ModelAdmin): - list_display = ['name', 'slug','begin_date','limit_date'] - search_fields = ['name','slug'] - -class AnswerAdmin(admin.ModelAdmin): - list_display = ['answer','order'] - search_fields = ['answer'] - -class AnswersStudentAdmin(admin.ModelAdmin): - list_display = ['student','exam','answered_in'] - search_fields = ['student','exam'] - -admin.site.register(Exam, ExamAdmin) -admin.site.register(Answer, AnswerAdmin) -admin.site.register(AnswersStudent, AnswersStudentAdmin) -admin.site.register(Question) -admin.site.register(Alternative) diff --git a/exam/apps.py b/exam/apps.py deleted file mode 100644 index 9649087..0000000 --- a/exam/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class ExamConfig(AppConfig): - name = 'exam' diff --git a/exam/forms.py b/exam/forms.py deleted file mode 100644 index 60b98ad..0000000 --- a/exam/forms.py +++ /dev/null @@ -1,37 +0,0 @@ -from django import forms -from django.utils.translation import ugettext_lazy as _ -from users.models import User -from .models import Exam - -class ExamForm(forms.ModelForm): - - def __init__(self, *args, **kwargs): - super(ExamForm, self).__init__(*args, **kwargs) - self.fields["all_students"].required = False - self.fields["all_students"].initial = False - self.fields["students"].required = False - - def clean_all_students(self): - if('all_students' not in self.data): - if('students' in self.data): - return False - raise forms.ValidationError(_('It is required one these fields.')) - else: - all_students = self.data['all_students'] - if(not all_students): - raise forms.ValidationError(_('It is required one these fields.')) - return True - - - class Meta: - model = Exam - fields = ['name','begin_date','limit_date','students','all_students', 'begin_exam', 'end_exam'] - - widgets = { - 'name': forms.TextInput(attrs={'placeholder': 'Exam?'}), - 'begin_date': forms.DateTimeInput( - attrs={'placeholder': _('Start date to resolve the exam')}), - 'limit_date': forms.DateTimeInput( - attrs={'placeholder': _('Maximum date permited to resolve the exam')}), - 'student': forms.Select(), - } diff --git a/exam/locale/pt_BR/LC_MESSAGES/django.po b/exam/locale/pt_BR/LC_MESSAGES/django.po deleted file mode 100644 index c2a297c..0000000 --- a/exam/locale/pt_BR/LC_MESSAGES/django.po +++ /dev/null @@ -1,190 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-11-23 23:58-0300\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" - -#: .\forms.py:18 .\forms.py:22 -msgid "It is required one these fields." -msgstr "É requerido um destes campos." - -#: .\forms.py:33 -msgid "Start date to resolve the exam" -msgstr "Data de início para resolver o exame" - -#: .\forms.py:35 -msgid "Maximum date permited to resolve the exam" -msgstr "Data máxima permitida para resolver o exame" - -#: .\models.py:9 -msgid "Begin of Course Date" -msgstr "Data de início do curso" - -#: .\models.py:10 -msgid "Exibe?" -msgstr "Exibir?" - -#: .\models.py:13 .\models.py:35 -msgid "Exam" -msgstr "Exame" - -#: .\models.py:14 -msgid "Exams" -msgstr "Exames" - -#: .\models.py:21 .\models.py:27 .\templates\exam\view.html:26 -msgid "Answer" -msgstr "Resposta" - -#: .\models.py:22 -msgid "Order" -msgstr "Ordem" - -#: .\models.py:23 .\models.py:28 -msgid "Answers" -msgstr "Respostas" - -#: .\models.py:34 -msgid "Answered" -msgstr "Respondida" - -#: .\models.py:36 -msgid "Answers Students" -msgstr "Resposta dos estudantes" - -#: .\models.py:37 -msgid "Student" -msgstr "Estudante" - -#: .\models.py:38 -msgid "Answered Date" -msgstr "Data da resposta" - -#: .\models.py:41 -msgid "Answer Stundent" -msgstr "Resposta do estudante" - -#: .\models.py:42 -msgid "Answers Student" -msgstr "Respostas dos estudantes" - -#: .\templates\exam\create.html:13 -msgid "Create a Exam" -msgstr "Criar um Exame" - -#: .\templates\exam\create.html:17 .\templates\exam\create.html:19 -msgid "Exam Name" -msgstr "Nome do exame" - -#: .\templates\exam\create.html:23 -msgid "Exam's begin date" -msgstr "Data de início do exame" - -#: .\templates\exam\create.html:25 -msgid "Begin Date" -msgstr "Data de início" - -#: .\templates\exam\create.html:27 -msgid "Exam's end date" -msgstr "Data final do exame" - -#: .\templates\exam\create.html:29 -msgid "End Date" -msgstr "Data final" - -#: .\templates\exam\create.html:36 -msgid "Allow submissions after deadline?" -msgstr "Permitir submissões após o prazo?" - -#: .\templates\exam\create.html:48 -msgid "Close" -msgstr "Fechar" - -#: .\templates\exam\create.html:51 -msgid "Create" -msgstr "Criar" - -#: .\templates\exam\questions\discursive_question.html:2 -#: .\templates\exam\questions\discursive_question.html:4 -#: .\templates\exam\questions\multiple_choice_question.html:5 -#: .\templates\exam\questions\true_or_false_question.html:20 -#: .\templates\exam\questions\true_or_false_question.html:25 -msgid "Question" -msgstr "Questão" - -#: .\templates\exam\questions\gap_filling_question.html:2 -msgid "Gap Filling Question" -msgstr "Questão de preenchimento de lacunas" - -#: .\templates\exam\questions\multiple_choice_question.html:15 -msgid "Alternatives" -msgstr "Alternativas" - -#: .\templates\exam\questions\multiple_choice_question.html:34 -#: .\templates\exam\questions\true_or_false_question.html:45 -msgid "New Alternative" -msgstr "Nova alternativa" - -#: .\templates\exam\questions\true_or_false_answer.html:9 -msgid "Write your alternative" -msgstr "Escreva sua alternativa" - -#: .\templates\exam\questions\true_or_false_question.html:37 -msgid "Alternatives: T/F" -msgstr "Alternativas: V/F" - -#: .\templates\exam\remove.html:7 -msgid "Delete Exam" -msgstr "Apagar exame" - -#: .\templates\exam\remove.html:15 -msgid "Are you sure you want to delete the subject" -msgstr "Você tem certeza que deseja apagar o assunto?" - -#: .\templates\exam\remove.html:20 -msgid "Delete" -msgstr "Apagar" - -#: .\templates\exam\update.html:7 -msgid "Update a Exam" -msgstr "Atualizar um Exame" - -#: .\templates\exam\update.html:12 -msgid "Update" -msgstr "Atualizar" - -#: .\templates\exam\view.html:17 -msgid "Limit date:" -msgstr "Data limite:" - -#~ msgid "Question Type" -#~ msgstr "Tipo de questão" - -#~ msgid "Multiple Choice" -#~ msgstr "Múltipla escolha" - -#~ msgid "True or False" -#~ msgstr "Verdadeiro ou falso" - -#~ msgid "Gap Filling" -#~ msgstr "Preenchimento de lacunas" - -#~ msgid "Discursive Question" -#~ msgstr "Questão discursiva" - -#~ msgid "add question" -#~ msgstr "Adicionar questão" diff --git a/exam/migrations/0001_initial.py b/exam/migrations/0001_initial.py deleted file mode 100644 index 326f03c..0000000 --- a/exam/migrations/0001_initial.py +++ /dev/null @@ -1,62 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-24 15:17 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ('courses', '0001_initial'), - ] - - operations = [ - migrations.CreateModel( - name='Answer', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('answer', models.CharField(max_length=300, verbose_name='Answer')), - ('order', models.PositiveSmallIntegerField(verbose_name='Order')), - ], - options={ - 'verbose_name': 'Answer', - 'verbose_name_plural': 'Answers', - 'ordering': ('order',), - }, - ), - migrations.CreateModel( - name='AnswersStudent', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('status', models.BooleanField(default=False, verbose_name='Answered')), - ('answered_in', models.DateTimeField(auto_now=True, verbose_name='Answered Date')), - ('answer', models.ManyToManyField(related_name='student_answer', to='exam.Answer', verbose_name='Answers Students')), - ], - options={ - 'verbose_name': 'Answer Stundent', - 'verbose_name_plural': 'Answers Student', - }, - ), - migrations.CreateModel( - name='Exam', - fields=[ - ('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')), - ('begin_date', models.DateField(blank=True, verbose_name='Begin of Course Date')), - ('exibe', models.BooleanField(default=False, verbose_name='Exibe?')), - ], - options={ - 'verbose_name': 'Exam', - 'verbose_name_plural': 'Exams', - }, - bases=('courses.activity',), - ), - migrations.AddField( - model_name='answersstudent', - name='exam', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student_exam', to='exam.Exam', verbose_name='Exam'), - ), - ] diff --git a/exam/migrations/0002_auto_20161124_1217.py b/exam/migrations/0002_auto_20161124_1217.py deleted file mode 100644 index cea13f9..0000000 --- a/exam/migrations/0002_auto_20161124_1217.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-24 15:17 -from __future__ import unicode_literals - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('exam', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='answersstudent', - name='student', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student', to=settings.AUTH_USER_MODEL, verbose_name='Student'), - ), - migrations.AddField( - model_name='answer', - name='exam', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='exam.Exam', verbose_name='Answers'), - ), - ] diff --git a/exam/migrations/0003_auto_20161125_0808.py b/exam/migrations/0003_auto_20161125_0808.py deleted file mode 100644 index 71f5378..0000000 --- a/exam/migrations/0003_auto_20161125_0808.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.10 on 2016-11-25 11:08 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ('exam', '0002_auto_20161124_1217'), - ] - - operations = [ - migrations.AddField( - model_name='exam', - name='begin_exam', - field=models.DateField(blank=True, default=django.utils.timezone.now, verbose_name='Begin of Exam'), - preserve_default=False, - ), - migrations.AddField( - model_name='exam', - name='end_exam', - field=models.DateField(blank=True, default=django.utils.timezone.now, verbose_name='End of Exam'), - preserve_default=False, - ), - ] diff --git a/exam/migrations/__init__.py b/exam/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/exam/migrations/__init__.py +++ /dev/null diff --git a/exam/models.py b/exam/models.py deleted file mode 100644 index ccde810..0000000 --- a/exam/models.py +++ /dev/null @@ -1,56 +0,0 @@ -from django.utils.translation import ugettext_lazy as _ -from django.db import models -from autoslug.fields import AutoSlugField -from users.models import User -from core.models import Resource -from courses.models import Activity - -class Exam(Activity): - begin_date = models.DateField(_('Begin of Course Date'), blank=True) - begin_exam = models.DateField(_('Begin of Exam'), blank = True) - end_exam = models.DateField(_('End of Exam'), blank = True) - exibe = models.BooleanField(_('Exibe?'), default=False) - - class Meta: - verbose_name = _('Exam') - verbose_name_plural = _('Exams') - - def __str__(self): - return str(self.name) + str("/") + str(self.topic) - - -class Answer(models.Model): - answer = models.CharField(_("Answer"), max_length = 300) - order = models.PositiveSmallIntegerField(_("Order")) - exam = models.ForeignKey(Exam, verbose_name = _('Answers'), related_name='answers') - - class Meta: - ordering = ('order',) - verbose_name = _('Answer') - verbose_name_plural = _('Answers') - - def __str__(self): - return str(self.answer) + str("/") + str(self.exam) - -class AnswersStudent(models.Model): - status = models.BooleanField(_("Answered"), default=False) - exam = models.ForeignKey(Exam, verbose_name = _('Exam'), related_name='student_exam') - answer = models.ManyToManyField(Answer,verbose_name = _('Answers Students'), related_name='student_answer') - student = models.ForeignKey(User, verbose_name = _('Student'), related_name='student') - answered_in = models.DateTimeField(_("Answered Date"),auto_now=True) - - class Meta: - verbose_name = _('Answer Stundent') - verbose_name_plural = _('Answers Student') - - def __str__(self): - return str(self.student) + str("/") + str(self.exam) - -class Question(models.Model): - exam = models.ForeignKey(Exam, verbose_name=_('Exam'), related_name='question_exam') - statement = models.TextField(_("Statement"), blank=False) - -class Alternative(models.Model): - question = models.ForeignKey(Question, verbose_name=_("Question"), related_name="alternative_question") - statement = models.TextField(_("Statement"), blank=False) - answer = models.BooleanField(_("answer"), default=False) \ No newline at end of file diff --git a/exam/permissions.py b/exam/permissions.py deleted file mode 100644 index 5da1d28..0000000 --- a/exam/permissions.py +++ /dev/null @@ -1,22 +0,0 @@ -from rolepermissions.permissions import register_object_checker -from amadeus.roles import SystemAdmin - -@register_object_checker() -def edit_exam(role, user, exam): - if (role == SystemAdmin): - return True - - if (user in exam.topic.subject.professors.all()): - return True - - return False - -@register_object_checker() -def delete_exam(role, user, exam): - if (role == SystemAdmin): - return True - - if (user in exam.topic.subject.professors.all()): - return True - - return False diff --git a/exam/static/css/exam.css b/exam/static/css/exam.css deleted file mode 100644 index 97331da..0000000 --- a/exam/static/css/exam.css +++ /dev/null @@ -1,4 +0,0 @@ -.primary-label-TF{ - padding-left: 0px; -} -.title-questions-exam{padding-left:1.5%;} \ No newline at end of file diff --git a/exam/static/js/Exam.js b/exam/static/js/Exam.js deleted file mode 100644 index bcee08d..0000000 --- a/exam/static/js/Exam.js +++ /dev/null @@ -1,130 +0,0 @@ - - //Insert question choice - function showDiv (elem, questionType_id) { - if (elem.value == 0) { - var questionChoice = - '
    ' + - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '; - } else if (elem.value == 1) { - var questionChoice = - '
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - ''+ - ''+ - ''+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '; - } else if (elem.value == 3) { - var questionChoice = - '
    '+ - '
    '+ - ''+ - '
    '+ - ''+ - '
    '+ - '
    '+ - '
    '; - } - if(document.getElementById('questionChoice_'+ questionType_id)){ - $('#questionChoice_'+ questionType_id).detach(); - } - $(questionChoice).insertBefore('#hr_'+questionType_id); - $('.primary-label-TF').css('padding-left', '0px'); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. - } -//Bug quando criamos sem ser na ordem -function functionNewAlternative(Question_Id){ - var alternative = parseInt($(Question_Id).find("input:last").val()) + 1; - var element = '
    ' + - ''+ - '
    '; - $(Question_Id).append(element); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. -} -function functionNewAlternativeTF(Question_Id){ - var alternative = parseInt($('#radiosTF_1').find('div:last').attr('value')) + 1; - var element = - '
    '+ - ''+ - ''+ - ''+ - '
    '; - $(Question_Id).append(element); - $('.primary-label-TF').css('padding-left', '0px'); - $.material.init() //O material deve ser iniciado aqui para funcionar os botoes de radio. -} -var locale = navigator.language || navigator.userLanguage; - - $('.date-picker').datepicker({ - language: locale, - }); \ No newline at end of file diff --git a/exam/templates/exam/create.html b/exam/templates/exam/create.html deleted file mode 100644 index 7652af3..0000000 --- a/exam/templates/exam/create.html +++ /dev/null @@ -1,112 +0,0 @@ -{% extends 'subject/index.html' %} - -{% load i18n widget_tweaks static django_bootstrap_breadcrumbs %} - -{% block style %} - -{% endblock %} - -{% block breadcrumbs %} - {{ block.super }} - {% breadcrumb 'Create exam' 'course:create_exam' %} -{% endblock breadcrumbs %} - -{% block content %} -
    -
    -

    {% trans "Create a Exam" %}

    -
    -
    - {% csrf_token %} - {% for field in form %} - {% 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' %} -
    - {% if field.field.required %} - - {% else %} - - {% endif %} -
    - {% if field.auto_id == 'id_all_students' %} - {% render_field field class='form-control input-sm' %} - {% else %} - {% render_field field class='form-control input-sm' %} - {% endif %} -
    -
    - {% endif %} - {% endfor %} -
    - {% for field in form %} - {% if field.auto_id == 'id_begin_date' or field.auto_id == 'id_limit_date' %} - {% if field.field.required %} - - {% else %} - - {% endif %} -
    - {% render_field field class='form-control date-picker' %} -
    - {% endif %} - {% endfor %} -
    - -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    - -{% block javascript %} - - - - -{% endblock %} -{% endblock content %} diff --git a/exam/templates/exam/questions/discursive_question.html b/exam/templates/exam/questions/discursive_question.html deleted file mode 100644 index c810344..0000000 --- a/exam/templates/exam/questions/discursive_question.html +++ /dev/null @@ -1,6 +0,0 @@ -
    - -
    - -
    -
    diff --git a/exam/templates/exam/questions/gap_filling_answer.html b/exam/templates/exam/questions/gap_filling_answer.html deleted file mode 100644 index e69de29..0000000 --- a/exam/templates/exam/questions/gap_filling_answer.html +++ /dev/null diff --git a/exam/templates/exam/questions/gap_filling_question.html b/exam/templates/exam/questions/gap_filling_question.html deleted file mode 100644 index 2c76175..0000000 --- a/exam/templates/exam/questions/gap_filling_question.html +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/exam/templates/exam/questions/multiple_choice_answer.html b/exam/templates/exam/questions/multiple_choice_answer.html deleted file mode 100644 index e69de29..0000000 --- a/exam/templates/exam/questions/multiple_choice_answer.html +++ /dev/null diff --git a/exam/templates/exam/questions/multiple_choice_question.html b/exam/templates/exam/questions/multiple_choice_question.html deleted file mode 100644 index 3567064..0000000 --- a/exam/templates/exam/questions/multiple_choice_question.html +++ /dev/null @@ -1,42 +0,0 @@ -{% load i18n %} - -
    - - - - -
    - -
    - - -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - - -
    -
    diff --git a/exam/templates/exam/questions/true_or_false_answer.html b/exam/templates/exam/questions/true_or_false_answer.html deleted file mode 100644 index e79b34d..0000000 --- a/exam/templates/exam/questions/true_or_false_answer.html +++ /dev/null @@ -1,15 +0,0 @@ -{% load i18n %} - -
    -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    diff --git a/exam/templates/exam/questions/true_or_false_question.html b/exam/templates/exam/questions/true_or_false_question.html deleted file mode 100644 index 1cc6594..0000000 --- a/exam/templates/exam/questions/true_or_false_question.html +++ /dev/null @@ -1,67 +0,0 @@ -{# {% extends "base.html" %} #} - -{% load i18n %} -{# {% block content %} #} - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - {% include "exam/true_or_false_answer.html" %} -
    -
    -
    -
    - -
    -
    -
    - -{# {% endblock content %} #} diff --git a/exam/templates/exam/remove.html b/exam/templates/exam/remove.html deleted file mode 100644 index a09504c..0000000 --- a/exam/templates/exam/remove.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends "exam/create.html" %} - -{% load i18n static%} - -{% block title_exam %} - - -{% endblock title_exam %} - -{% block content_exam %} - - -
    - {% csrf_token %} -

    {% trans 'Are you sure you want to delete the subject' %} "{{exam.name}}"?

    -
    -{% endblock content_exam %} - -{% block button_save %} - - -{% endblock button_save %} diff --git a/exam/templates/exam/update.html b/exam/templates/exam/update.html deleted file mode 100644 index 14d7de8..0000000 --- a/exam/templates/exam/update.html +++ /dev/null @@ -1,32 +0,0 @@ -{% extends "exam/create.html" %} - -{% load i18n dict_access static%} - -{% block title_exam %} - - -{% endblock title_exam %} - -{% block button_save %} - - -{% endblock button_save %} - -{% block script_exam %} - -{% endblock script_exam %} diff --git a/exam/templates/exam/view.html b/exam/templates/exam/view.html deleted file mode 100644 index 3ae1c95..0000000 --- a/exam/templates/exam/view.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "exam/create.html" %} - -{% load i18n dict_access static%} - -{% block style %} -{% endblock %} - -{% block title_exam %} - - -{% endblock title_exam %} - -{% block content_exam %} - -
    -
    -

    {% trans "Limit date:" %} {{exam.limit_date|date:'d/m/y'}}

    -
    - -
    -{% endblock content_exam %} - -{% block button_save %} - -{% if not status %} - -{% endif %} -{% endblock button_save %} diff --git a/exam/templatetags/__init__.py b/exam/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/exam/templatetags/__init__.py +++ /dev/null diff --git a/exam/templatetags/dict_access.py b/exam/templatetags/dict_access.py deleted file mode 100644 index bb671a6..0000000 --- a/exam/templatetags/dict_access.py +++ /dev/null @@ -1,13 +0,0 @@ -from django import template - -from forum.models import Forum - -register = template.Library() - -""" - Template tag to load all the foruns of a post -""" - -@register.filter -def value(dictionary, key): - return dictionary[key] diff --git a/exam/tests.py b/exam/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/exam/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/exam/urls.py b/exam/urls.py deleted file mode 100644 index 480ace1..0000000 --- a/exam/urls.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.conf.urls import url - -from . import views - -urlpatterns = [ - url(r'^create/(?P[\w\-_]+)/$', views.CreateExam.as_view(), name='create_exam'), # exam slug - url(r'^update/(?P[\w\-_]+)/$', views.UpdateExam.as_view(), name='update_exam'), # topic slug - url(r'^view/(?P[\w\-_]+)/$', views.ViewExam.as_view(), name='view_exam'), # exam slug - url(r'^delete/(?P[\w\-_]+)/$', views.DeleteExam.as_view(), name='delete_exam'), # exam - url(r'^answer/$', views.AnswerExam.as_view(), name='answer_exam'), # exam - url(r'^answer-exam/(?P[\w\-_]+)/$', views.AnswerStudentExam.as_view(), name='answer_student_exam'), # exam slug - url(r'^discursive-question/$',views.DiscursiveQuestion.as_view(), name="discursive_question"), - url(r'^gap-filling-question/$',views.GapFillingQuestion.as_view(), name="gap_filling_question"), - url(r'^gap-filling-answer/$',views.GapFillingAnswer.as_view(), name="gap_filling_answer"), - url(r'^multiple-choice-question/$',views.MultipleChoiceQuestion.as_view(), name="multiple_choice_question"), - url(r'^multiple-choice-answer/$',views.MultipleChoiceAnswer.as_view(), name="multiple_choice_answer"), - url(r'^true-or-false-question/$',views.TrueOrFalseQuestion.as_view(), name="true_or_false_question"), - url(r'^true-or-false-answer/$',views.TrueOrFalseAnswer.as_view(), name="true_or_false_answer"), -] diff --git a/exam/views.py b/exam/views.py deleted file mode 100644 index 5273936..0000000 --- a/exam/views.py +++ /dev/null @@ -1,380 +0,0 @@ -from django.shortcuts import render, get_object_or_404, redirect -from django.views import generic -from django.contrib.auth.decorators import login_required -from django.core.paginator import Paginator, EmptyPage -from django.contrib.auth.mixins import LoginRequiredMixin -from rolepermissions.mixins import HasRoleMixin -from django.core.urlresolvers import reverse_lazy -from django.utils.translation import ugettext_lazy as _ -from rolepermissions.verifications import has_role -from rolepermissions.verifications import has_object_permission -from django.db.models import Q -from datetime import datetime -import time -# from django.views.generic.edit import FormMixin - -from .forms import ExamForm -from .models import Exam, Answer, AnswersStudent -from core.mixins import LogMixin, NotificationMixin -from core.models import Log -from users.models import User -from courses.models import Course, Topic - -class ViewExam(LoginRequiredMixin, LogMixin, generic.DetailView): - log_component = 'exam' - log_resource = 'exam' - log_action = 'viewed' - log_context = {} - - model = Exam - context_object_name = 'exam' - template_name = 'exam/view.html' - - def get_object(self, queryset=None): - return get_object_or_404(Topic, slug = self.kwargs.get('slug')) - - def get_context_data(self, **kwargs): - context = super(ViewExam, self).get_context_data(**kwargs) - exam = self.object - context["topic"] = exam.topic - context['course'] = exam.topic.subject.course - context['subject'] = exam.topic.subject - context['subjects'] = exam.topic.subject.course.subjects.all() - - answered = AnswersStudent.objects.filter(exam = exam, student=self.request.user) - print (answered) - if answered.count()<1: - context['status'] = False - else: - context['status'] = answered[0].status - - self.log_context['exam_id'] = exam.id - self.log_context['topic_id'] = exam.topic.id - self.log_context['topic_name'] = exam.topic.name - self.log_context['topic_slug'] = exam.topic.slug - self.log_context['subject_id'] = exam.topic.subject.id - self.log_context['subject_name'] = exam.topic.subject.name - self.log_context['subject_slug'] = exam.topic.subject.slug - self.log_context['course_id'] = exam.topic.subject.course.id - self.log_context['course_name'] = exam.topic.subject.course.name - self.log_context['course_slug'] = exam.topic.subject.course.slug - self.log_context['course_category_id'] = exam.topic.subject.course.category.id - self.log_context['course_category_name'] = exam.topic.subject.course.category.name - self.request.session['time_spent'] = str(int(time.time())) - - super(ViewExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - - self.request.session['log_id'] = Log.objects.latest('id').id - - return context - - - -class CreateExam(LoginRequiredMixin,HasRoleMixin, LogMixin, NotificationMixin, generic.CreateView): - log_component = 'exam' - log_resource = 'exam' - log_action = 'create' - log_context = {} - - allowed_roles = ['professor', 'system_admin'] - login_url = reverse_lazy("core:home") - redirect_field_name = 'next' - model = Exam - form_class = ExamForm - context_object_name = 'exam' - template_name = 'exam/create.html' - - def form_invalid(self, form,**kwargs): - context = super(CreateExam, self).form_invalid(form) - answers = {} - for key in self.request.POST: - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): - answers[key] = self.request.POST[key] - - keys = sorted(answers) - context.context_data['answers'] = answers - context.context_data['keys'] = keys - context.context_data['form'] = form - context.status_code = 400 - return context - - def form_valid(self, form): - self.object = form.save(commit = False) - topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) - self.object.topic = topic - self.object.name = str(self.object) - self.object.save() - - super(CreateExam, self).createNotification(message="created an Exam "+ self.object.name, actor=self.request.user, - resource_name=self.object.name, resource_link= reverse('course:exam:view_exam', args=[self.object.slug]), - users=self.object.topic.subject.students.all()) - for key in self.request.POST: - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key != 'all_students' and key != 'students'): - answer = Answer(answer=self.request.POST[key],order=key,exam=self.object) - answer.save() - - self.log_context['exam_id'] = self.object.id - self.log_context['topic_id'] = self.object.topic.id - self.log_context['topic_name'] = self.object.topic.name - self.log_context['topic_slug'] = self.object.topic.slug - self.log_context['subject_id'] = self.object.topic.subject.id - self.log_context['subject_name'] = self.object.topic.subject.name - self.log_context['subject_slug'] = self.object.topic.subject.slug - self.log_context['course_id'] = self.object.topic.subject.course.id - self.log_context['course_name'] = self.object.topic.subject.course.name - self.log_context['course_slug'] = self.object.topic.subject.course.slug - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name - - super(CreateExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - - return self.render_to_response(self.get_context_data(form = form), status = 200) - - def get_context_data(self, **kwargs): - context = super(CreateExam, self).get_context_data(**kwargs) - topic = get_object_or_404(Topic, slug = self.kwargs.get('slug')) - context['course'] = topic.subject.course - context['subject'] = topic.subject - context['subjects'] = topic.subject.course.subjects.all() - return context - -class UpdateExam(LoginRequiredMixin,HasRoleMixin, LogMixin, generic.UpdateView): - log_component = 'exam' - log_resource = 'exam' - log_action = 'update' - log_context = {} - - allowed_roles = ['professor', 'system_admin'] - login_url = reverse_lazy("core:home") - redirect_field_name = 'next' - model = Exam - form_class = ExamForm - context_object_name = 'exam' - template_name = 'exam/update.html' - success_url = reverse_lazy('core:home') - - def dispatch(self, *args, **kwargs): - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) - if(not has_object_permission('edit_exam', self.request.user, exam)): - return self.handle_no_permission() - return super(UpdateExam, self).dispatch(*args, **kwargs) - - def get_object(self, queryset=None): - return get_object_or_404(Exam, slug = self.kwargs.get('slug')) - - def form_invalid(self, form,**kwargs): - context = super(UpdateExam, self).form_invalid(form) - answers = {} - for key in self.request.POST: - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): - answers[key] = self.request.POST[key] - - keys = sorted(answers) - context.context_data['answers'] = answers - context.context_data['keys'] = keys - context.context_data['form'] = form - context.status_code = 400 - return context - - def form_valid(self, form): - exam = self.object - exam = form.save(commit = False) - exam.answers.all().delete() - exam.save() - - - for key in self.request.POST: - if(key != 'csrfmiddlewaretoken' and key != 'name' and key != 'begin_date' and key != 'limit_date' and key!= 'exibe' and key != 'all_students' and key != 'students'): - answer = Answer(answer=self.request.POST[key],order=key,exam=exam) - answer.save() - - self.log_context['exam_id'] = self.object.id - self.log_context['topic_id'] = self.object.topic.id - self.log_context['topic_name'] = self.object.topic.name - self.log_context['topic_slug'] = self.object.topic.slug - self.log_context['subject_id'] = self.object.topic.subject.id - self.log_context['subject_name'] = self.object.topic.subject.name - self.log_context['subject_slug'] = self.object.topic.subject.slug - self.log_context['course_id'] = self.object.topic.subject.course.id - self.log_context['course_name'] = self.object.topic.subject.course.name - self.log_context['course_slug'] = self.object.topic.subject.course.slug - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name - - super(UpdateExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - - return super(UpdateExam, self).form_valid(form) - - def get_context_data(self, **kwargs): - context = super(UpdateExam, self).get_context_data(**kwargs) - exam = self.object - context['course'] = exam.topic.subject.course - context['subject'] = exam.topic.subject - context['subjects'] = exam.topic.subject.course.subjects.all() - - answers = {} - for answer in exam.answers.all(): - answers[answer.order] = answer.answer - - keys = sorted(answers) - context['answers'] = answers - context['keys'] = keys - - return context - -class DeleteExam(LoginRequiredMixin, HasRoleMixin, LogMixin, generic.DeleteView): - log_component = 'exam' - log_resource = 'exam' - log_action = 'delete' - log_context = {} - - allowed_roles = ['professor', 'system_admin'] - login_url = reverse_lazy("core:home") - redirect_field_name = 'next' - model = Exam - template_name = 'exam/remove.html' - - def dispatch(self, *args, **kwargs): - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) - if(not has_object_permission('delete_exam', self.request.user, exam)): - return self.handle_no_permission() - return super(DeleteExam, self).dispatch(*args, **kwargs) - - - def get_context_data(self, **kwargs): - context = super(DeleteExam, self).get_context_data(**kwargs) - context['course'] = self.object.topic.subject.course - context['subject'] = self.object.topic.subject - context['exam'] = self.object - context['subjects'] = self.object.topic.subject.course.subjects.filter(Q(visible=True) | Q(professors__in=[self.request.user])) - if (has_role(self.request.user,'system_admin')): - context['subjects'] = self.object.topic.subject.course.subjects.all() - return context - - def get_success_url(self): - self.log_context['exam_id'] = self.object.id - self.log_context['topic_id'] = self.object.topic.id - self.log_context['topic_name'] = self.object.topic.name - self.log_context['topic_slug'] = self.object.topic.slug - self.log_context['subject_id'] = self.object.topic.subject.id - self.log_context['subject_name'] = self.object.topic.subject.name - self.log_context['subject_slug'] = self.object.topic.subject.slug - self.log_context['course_id'] = self.object.topic.subject.course.id - self.log_context['course_name'] = self.object.topic.subject.course.name - self.log_context['course_slug'] = self.object.topic.subject.course.slug - self.log_context['course_category_id'] = self.object.topic.subject.course.category.id - self.log_context['course_category_name'] = self.object.topic.subject.course.category.name - - super(DeleteExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - - return reverse_lazy('course:view_topic', kwargs={'slug' : self.object.topic.slug}) - -class AnswerExam(generic.TemplateView): - template_name = 'exam/answer.html' - -class AnswerStudentExam(LoginRequiredMixin, LogMixin, generic.CreateView): - log_component = 'exam' - log_resource = 'exam' - log_action = 'answer' - log_context = {} - - model = AnswersStudent - fields = ['status'] - context_object_name = 'answer' - template_name = 'exam/answer_student.html' - - def form_valid(self, form): - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) - answers = AnswersStudent( - status = True, - exam = exam, - student = self.request.user, - ) - answers.save() - - for key in self.request.POST: - if(key != 'csrfmiddlewaretoken'): - answers.answer.add(exam.answers.all().filter(order=key)[0]) - - self.log_context['exam_id'] = exam.id - self.log_context['topic_id'] = exam.topic.id - self.log_context['topic_name'] = exam.topic.name - self.log_context['topic_slug'] = exam.topic.slug - self.log_context['subject_id'] = exam.topic.subject.id - self.log_context['subject_name'] = exam.topic.subject.name - self.log_context['subject_slug'] = exam.topic.subject.slug - self.log_context['course_id'] = exam.topic.subject.course.id - self.log_context['course_name'] = exam.topic.subject.course.name - self.log_context['course_slug'] = exam.topic.subject.course.slug - self.log_context['course_category_id'] = exam.topic.subject.course.category.id - self.log_context['course_category_name'] = exam.topic.subject.course.category.name - - date_time_click = datetime.strptime(self.request.session.get('time_spent'), "%Y-%m-%d %H:%M:%S.%f") - _now = datetime.now() - - time_spent = _now - date_time_click - - secs = time_spent.total_seconds() - hours = int(secs / 3600) - minutes = int(secs / 60) % 60 - secs = secs % 60 - - self.log_context['timestamp_end'] = str(int(time.time())) - self.log_context['time_spent'] = {} - self.log_context['time_spent']['hours'] = hours - self.log_context['time_spent']['minutes'] = minutes - self.log_context['time_spent']['seconds'] = secs - - super(AnswerStudentExam, self).createLog(self.request.user, self.log_component, self.log_action, self.log_resource, self.log_context) - - return self.render_to_response(self.get_context_data(form = form), status = 200) - - def get_context_data(self, **kwargs): - context = super(AnswerStudentExam, self).get_context_data(**kwargs) - print (self.kwargs.get('slug')) - exam = get_object_or_404(Exam, slug = self.kwargs.get('slug')) - context['exam'] = exam - context['topic'] = exam.topic - context['course'] = exam.topic.subject.course - context['subject'] = exam.topic.subject - context['subjects'] = exam.topic.subject.course.subjects.all() - - print (self.request.method) - answers = {} - for answer in exam.answers.all(): - answers[answer.order] = answer.answer - - keys = sorted(answers) - context['answers'] = answers - context['keys'] = keys - - self.log_context['timestamp_start'] = str(int(time.time())) - self.request.session['time_spent'] = str(datetime.now()) - - return context - -class MultipleChoiceQuestion(generic.TemplateView): - template_name = 'exam/multiple_choice_question.html' - - -class MultipleChoiceAnswer(generic.TemplateView): - template_name = 'exam/multiple_choice_answer.html' - - -class DiscursiveQuestion(generic.TemplateView): - template_name = 'exam/discursive_question.html' - - -class TrueOrFalseQuestion(generic.TemplateView): - template_name = 'exam/true_or_false_question.html' - - -class TrueOrFalseAnswer(generic.TemplateView): - template_name = 'exam/true_or_false_answer.html' - - -class GapFillingQuestion(generic.TemplateView): - template_name = 'exam/gap_filling_question.html' - -class GapFillingAnswer(generic.TemplateView): - template_name = 'exam/gap_filling_answer.html' diff --git a/users/templates/users/search.html b/users/templates/users/search.html index 6243c6b..5167377 100644 --- a/users/templates/users/search.html +++ b/users/templates/users/search.html @@ -94,26 +94,7 @@ {% endif %} -{% if exam_list %} -
    -
    -
    -

    - Exam -

    -
    -
    -
    - {% for exam in exam_list %} - {{exam.name}} - {% endfor %} -
    - -
    -
    -
    -{% endif %} {% if poll_list %}
    diff --git a/users/views.py b/users/views.py index ffb147a..c236f47 100644 --- a/users/views.py +++ b/users/views.py @@ -17,7 +17,7 @@ from links.models import Link from poll.models import * from forum.models import * from files.models import * -from exam.models import * + from courses.models import * #API IMPORTS @@ -224,7 +224,6 @@ class SearchView(LoginRequiredMixin, generic.ListView): link_list = [] file_list = [] poll_list = [] - exam_list = [] forum_list = [] qtd = 0 @@ -233,39 +232,35 @@ class SearchView(LoginRequiredMixin, generic.ListView): link_list = Link.objects.filter( Q(name__icontains=search)).order_by('name') file_list = TopicFile.objects.filter(Q(name__icontains=search)).order_by('name') poll_list = Poll.objects.filter(Q(name__icontains=search)).order_by('name') - exam_list = Exam.objects.filter(Q(name__icontains=search)).order_by('name') forum_list = Forum.objects.filter(Q(name__icontains=search)).order_by('name') - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) elif has_role(self.request.user,'professor'): topics = Topic.objects.filter(owner = self.request.user) links = Link.objects.all() files = TopicFile.objects.all() polls = Poll.objects.all() - exams = Exam.objects.all() + forums = Forum.objects.all() if search != '': 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) - 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) 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) 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) 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) - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) elif has_role(self.request.user, 'student'): if search != '': link_list = Link.objects.filter( Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') file_list = TopicFile.objects.filter(Q(name__icontains=search) and Q(students__name = self.request.user.name)).order_by('name') poll_list = Poll.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') - exam_list = Exam.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') forum_list = Forum.objects.filter(Q(name__icontains=search)and Q(students__name = self.request.user.name)).order_by('name') - qtd = len(link_list) + len(file_list) + len(poll_list) + len(exam_list) + len(forum_list) + qtd = len(link_list) + len(file_list) + len(poll_list) + len(forum_list) translated = _('You searched for... ') context['link_list'] = link_list context['file_list'] = file_list context['poll_list'] = poll_list - context['exam_list'] = exam_list context['forum_list'] = forum_list context['qtd'] = qtd context['search'] = translated + search -- libgit2 0.21.2