Commit 36d375c3a559418d0ab86a2521a6ffb0e7912e6b
1 parent
209713f8
Exists in
master
and in
5 other branches
view delivery exercise #148
Showing
7 changed files
with
89 additions
and
68 deletions
Show diff stats
courses/templates/subject/form_view_teacher.html
@@ -123,6 +123,19 @@ | @@ -123,6 +123,19 @@ | ||
123 | </ul> | 123 | </ul> |
124 | </div> | 124 | </div> |
125 | </div> | 125 | </div> |
126 | + <div class="resource_inline"> | ||
127 | + <h4>{% trans 'Exercises' %}</h4> | ||
128 | + </div> | ||
129 | + <div class="resource_inline"> | ||
130 | + {# dropdown de create exercício #} | ||
131 | + <div class="dropdown"> | ||
132 | + <a href="#" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus-circle fa-lg" aria-hidden="true"></i></a> | ||
133 | + <ul class="dropdown-menu" aria-labelledby="dLabel"> | ||
134 | + <li><a href="javascript:modal.get('{% url 'course:exercise:create_exercise' topic.slug %}', '#createExercisesModal','#requisicoes_ajax')">{% trans 'Create a general exercise' %}</a></li> | ||
135 | + </ul> | ||
136 | + </div> | ||
137 | + </div> | ||
138 | + {% include "exercise/create_exercise.html" %} | ||
126 | </div> | 139 | </div> |
127 | 140 | ||
128 | {# opções de cancelar e editar no modo de edição #} | 141 | {# opções de cancelar e editar no modo de edição #} |
courses/templates/topic/index.html
@@ -120,7 +120,7 @@ | @@ -120,7 +120,7 @@ | ||
120 | </div> | 120 | </div> |
121 | </div> | 121 | </div> |
122 | <div class="col-md-6"> | 122 | <div class="col-md-6"> |
123 | - <h3>{% trans 'Students - Especific Exercises' %}</h3> | 123 | + <h3>{% trans 'Students - Specific Exercises' %}</h3> |
124 | <br/> | 124 | <br/> |
125 | </div> | 125 | </div> |
126 | {# mostra a lista de usuários caso seja um professor ou admin #} | 126 | {# mostra a lista de usuários caso seja um professor ou admin #} |
@@ -128,8 +128,9 @@ | @@ -128,8 +128,9 @@ | ||
128 | {% for user in users %} | 128 | {% for user in users %} |
129 | {% include "exercise/card_list_user.html" %} | 129 | {% include "exercise/card_list_user.html" %} |
130 | {% endfor %} | 130 | {% endfor %} |
131 | + {% endif %} | ||
131 | {# caso seja um estudante, mostra a lista de exercícios proposta a ele #} | 132 | {# caso seja um estudante, mostra a lista de exercícios proposta a ele #} |
132 | - {% elif user|has_role:'student'%} | 133 | + {% if user|has_role:'student'%} |
133 | {% for exercise in exercises %} | 134 | {% for exercise in exercises %} |
134 | {% include "exercise/card_topic_exercises.html" %} | 135 | {% include "exercise/card_topic_exercises.html" %} |
135 | {% endfor %} | 136 | {% endfor %} |
courses/views.py
@@ -16,7 +16,7 @@ from django.shortcuts import get_object_or_404 | @@ -16,7 +16,7 @@ from django.shortcuts import get_object_or_404 | ||
16 | from django.urls import reverse | 16 | from django.urls import reverse |
17 | from django.utils.translation import ugettext_lazy as _ | 17 | from django.utils.translation import ugettext_lazy as _ |
18 | from django.views import generic | 18 | from django.views import generic |
19 | -from exercise.models import Exercise | 19 | +from exercise.models import Exercise, File |
20 | from files.forms import FileForm | 20 | from files.forms import FileForm |
21 | from files.models import TopicFile | 21 | from files.models import TopicFile |
22 | from functools import reduce | 22 | from functools import reduce |
@@ -622,12 +622,13 @@ class TopicsView(LoginRequiredMixin, LogMixin, generic.ListView): | @@ -622,12 +622,13 @@ class TopicsView(LoginRequiredMixin, LogMixin, generic.ListView): | ||
622 | activitys = Activity.objects.filter(topic__name = topic.name) | 622 | activitys = Activity.objects.filter(topic__name = topic.name) |
623 | students_activit = User.objects.filter(activities__in = Activity.objects.all()) | 623 | students_activit = User.objects.filter(activities__in = Activity.objects.all()) |
624 | materials = Material.objects.filter(topic = topic) | 624 | materials = Material.objects.filter(topic = topic) |
625 | - if has_role(self.request.user, 'professor'): | ||
626 | - users = User.objects.filter(subject_student__in = Subject.objects.all()) | ||
627 | - context['users'] = users | ||
628 | - elif has_role(self.request.user, 'student'): | ||
629 | - exercises = Exercise.objects.all().filter(students=self.request.user) | ||
630 | - context['exercises'] = exercises | 625 | + |
626 | + users = User.objects.filter(subject_student__in = Subject.objects.all()) | ||
627 | + context['users'] = users | ||
628 | + exercises = Exercise.objects.filter(Q(students=self.request.user)|Q(professors=self.request.user)) | ||
629 | + context['exercises'] = exercises | ||
630 | + files = File.objects.all() | ||
631 | + context['files'] = files | ||
631 | 632 | ||
632 | context['topic'] = topic | 633 | context['topic'] = topic |
633 | context['subject'] = topic.subject | 634 | context['subject'] = topic.subject |
exercise/migrations/0001_initial.py
1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
2 | -# Generated by Django 1.10 on 2016-11-17 03:09 | 2 | +# Generated by Django 1.10 on 2016-11-17 04:25 |
3 | from __future__ import unicode_literals | 3 | from __future__ import unicode_literals |
4 | 4 | ||
5 | from decimal import Decimal | 5 | from decimal import Decimal |
6 | +from django.conf import settings | ||
6 | from django.db import migrations, models | 7 | from django.db import migrations, models |
7 | import django.db.models.deletion | 8 | import django.db.models.deletion |
8 | 9 | ||
@@ -12,6 +13,9 @@ class Migration(migrations.Migration): | @@ -12,6 +13,9 @@ class Migration(migrations.Migration): | ||
12 | initial = True | 13 | initial = True |
13 | 14 | ||
14 | dependencies = [ | 15 | dependencies = [ |
16 | + migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
17 | + ('courses', '0002_auto_20161117_0009'), | ||
18 | + ('core', '0002_auto_20161117_0009'), | ||
15 | ] | 19 | ] |
16 | 20 | ||
17 | operations = [ | 21 | operations = [ |
@@ -24,6 +28,9 @@ class Migration(migrations.Migration): | @@ -24,6 +28,9 @@ class Migration(migrations.Migration): | ||
24 | ('end_date', models.DateField(verbose_name='End of Subject Date')), | 28 | ('end_date', models.DateField(verbose_name='End of Subject Date')), |
25 | ('grade', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=20, null=True)), | 29 | ('grade', models.DecimalField(decimal_places=2, default=Decimal('0.00'), max_digits=20, null=True)), |
26 | ('name', models.CharField(max_length=100)), | 30 | ('name', models.CharField(max_length=100)), |
31 | + ('professors', models.ManyToManyField(blank=True, related_name='professors_exercise', to=settings.AUTH_USER_MODEL, verbose_name='Professors')), | ||
32 | + ('students', models.ManyToManyField(blank=True, related_name='subject_exercise', to=settings.AUTH_USER_MODEL, verbose_name='Students')), | ||
33 | + ('topic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exercises', to='courses.Topic', verbose_name='Topic')), | ||
27 | ], | 34 | ], |
28 | ), | 35 | ), |
29 | migrations.CreateModel( | 36 | migrations.CreateModel( |
@@ -33,6 +40,7 @@ class Migration(migrations.Migration): | @@ -33,6 +40,7 @@ class Migration(migrations.Migration): | ||
33 | ('name', models.CharField(max_length=100)), | 40 | ('name', models.CharField(max_length=100)), |
34 | ('file', models.FileField(upload_to='uploads/%Y/%m/%d')), | 41 | ('file', models.FileField(upload_to='uploads/%Y/%m/%d')), |
35 | ('exercise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='file', to='exercise.Exercise')), | 42 | ('exercise', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='file', to='exercise.Exercise')), |
43 | + ('file_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='file_files', to='core.MimeType', verbose_name='Type file')), | ||
36 | ], | 44 | ], |
37 | ), | 45 | ), |
38 | ] | 46 | ] |
exercise/migrations/0002_auto_20161117_0009.py
@@ -1,36 +0,0 @@ | @@ -1,36 +0,0 @@ | ||
1 | -# -*- coding: utf-8 -*- | ||
2 | -# Generated by Django 1.10 on 2016-11-17 03:09 | ||
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 | - ('exercise', '0001_initial'), | ||
17 | - ('courses', '0002_auto_20161117_0009'), | ||
18 | - ] | ||
19 | - | ||
20 | - operations = [ | ||
21 | - migrations.AddField( | ||
22 | - model_name='exercise', | ||
23 | - name='professors', | ||
24 | - field=models.ManyToManyField(blank=True, related_name='professors_exercise', to=settings.AUTH_USER_MODEL, verbose_name='Professors'), | ||
25 | - ), | ||
26 | - migrations.AddField( | ||
27 | - model_name='exercise', | ||
28 | - name='students', | ||
29 | - field=models.ManyToManyField(blank=True, related_name='subject_exercise', to=settings.AUTH_USER_MODEL, verbose_name='Students'), | ||
30 | - ), | ||
31 | - migrations.AddField( | ||
32 | - model_name='exercise', | ||
33 | - name='topic', | ||
34 | - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exercises', to='courses.Topic', verbose_name='Topic'), | ||
35 | - ), | ||
36 | - ] |
exercise/models.py
@@ -3,6 +3,7 @@ from decimal import Decimal | @@ -3,6 +3,7 @@ from decimal import Decimal | ||
3 | from django.db import models | 3 | from django.db import models |
4 | from django.utils.translation import ugettext_lazy as _ | 4 | from django.utils.translation import ugettext_lazy as _ |
5 | from users.models import User | 5 | from users.models import User |
6 | +from core.models import MimeType | ||
6 | 7 | ||
7 | """ | 8 | """ |
8 | Function to return the path where the file should be saved | 9 | Function to return the path where the file should be saved |
@@ -35,6 +36,7 @@ class File(models.Model): | @@ -35,6 +36,7 @@ class File(models.Model): | ||
35 | name = models.CharField(max_length=100) | 36 | name = models.CharField(max_length=100) |
36 | file = models.FileField(upload_to='uploads/%Y/%m/%d') | 37 | file = models.FileField(upload_to='uploads/%Y/%m/%d') |
37 | exercise = models.ForeignKey(Exercise, related_name='file') | 38 | exercise = models.ForeignKey(Exercise, related_name='file') |
38 | - | 39 | + file_type = models.ForeignKey(MimeType, verbose_name=_('Type file'), related_name='file_files') |
40 | + | ||
39 | def __str__(self): | 41 | def __str__(self): |
40 | return self.name | 42 | return self.name |
41 | \ No newline at end of file | 43 | \ No newline at end of file |
exercise/templates/exercise/card_list_user.html
1 | {% load static i18n list_topic_foruns permission_tags widget_tweaks professor_access list_topic_exercises %} | 1 | {% load static i18n list_topic_foruns permission_tags widget_tweaks professor_access list_topic_exercises %} |
2 | 2 | ||
3 | - <div class="col-md-12 col-sm-12 col-lg-12"> | ||
4 | - <div class="panel-group accordion ui-accordion ui-widget ui-helper-reset ui-sortable" role="tablist" aria-multiselectable="false"> | ||
5 | - <div class="group"><div class="panel panel-default"> | ||
6 | - <div class="panel-heading topic ui-sortable-handle" role="tab"> | 3 | +<div class="col-md-12 col-sm-12 col-lg-12"> |
4 | + <div class="panel-group accordion ui-accordion ui-widget ui-helper-reset ui-sortable" role="tablist" aria-multiselectable="false"> | ||
5 | + <div class="group"><div class="panel panel-default"> | ||
6 | + <div class="panel-heading topic ui-sortable-handle" role="tab"> | ||
7 | + <div class="row"> | ||
8 | + <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#accordion-{{user.id}}" href=".collapseTopic-{{user.id}}" aria-expanded="false" aria-controls="collapseTopic-{{user.id}}"> | ||
9 | + <button class="btn btn-default btn-sm caret-square"><i class="fa fa-caret-square-o-down fa-2x" aria-hidden="true"></i></button> | ||
10 | + </div> | ||
11 | + <div class="col-xs-9 col-md-9 titleTopic"> | ||
12 | + <a href="" role="button"> | ||
13 | + <h4>{{user|capfirst}}</h4> | ||
14 | + </a> | ||
15 | + </div> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + <div class="panel-collapse collapseTopic-{{user.id}} collapse in" role="tabpanel" aria-labelledby="heading_{{user.id}}" aria-expanded="true" aria-hidden="false"> | ||
19 | + <div class="panel-body"> | ||
7 | <div class="row"> | 20 | <div class="row"> |
8 | - <div class="col-md-1 moreAccordion" data-toggle="collapse" data-parent="#accordion-{{user.id}}" href=".collapseTopic-{{user.id}}" aria-expanded="false" aria-controls="collapseTopic-{{user.id}}"> | ||
9 | - <button class="btn btn-default btn-sm caret-square"><i class="fa fa-caret-square-o-down fa-2x" aria-hidden="true"></i></button> | 21 | + <div class="col-md-4"> |
22 | + <div class="resource_inline"> | ||
23 | + <h4>{% trans 'Grade' %}</h4> | ||
24 | + </div> | ||
25 | + <div class="resource_inline"> | ||
26 | + {# dropdown de create exercício #} | ||
27 | + <div class="dropdown"> | ||
28 | + <a href="#" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus-circle fa-lg" aria-hidden="true"></i></a> | ||
29 | + <ul class="dropdown-menu" aria-labelledby="dLabel"> | ||
30 | + <li><a href="javascript:modal.get('{% url 'course:exercise:create_exercise' topic.slug %}', '#createExercisesModal','#requisicoes_ajax')">{% trans 'Give a grade' %}</a></li> | ||
31 | + </ul> | ||
32 | + </div> | ||
33 | + </div> | ||
10 | </div> | 34 | </div> |
11 | - <div class="col-xs-9 col-md-9 titleTopic"> | ||
12 | - <a href="" role="button"> | ||
13 | - <h4>{{user|capfirst}}</h4> | ||
14 | - </a> | 35 | + <div class="col-md-4"> |
36 | + <div class="resource_inline"> | ||
37 | + <h4>{% trans 'Delivery' %}</h4> | ||
38 | + </div> | ||
39 | + {% for file in files %} | ||
40 | + <li>{{file.exercise}}: <a href="{{file.file.url}}" target="_blank">{{file.name}}</a></li> | ||
41 | + {% endfor %} | ||
42 | + | ||
15 | </div> | 43 | </div> |
16 | - </div> | ||
17 | - </div> | ||
18 | - <div class="panel-collapse collapseTopic-{{user.id}} collapse in" role="tabpanel" aria-labelledby="heading_{{user.id}}" aria-expanded="true" aria-hidden="false"> | ||
19 | - <div class="panel-body"> | ||
20 | - <div class="presentation"> | ||
21 | - <p> | ||
22 | - <i> | ||
23 | - | ||
24 | - </i> | ||
25 | - </p> | ||
26 | - | 44 | + <div class="col-md-4"> |
45 | + <div class="resource_inline"> | ||
46 | + <h4>{% trans 'Create' %}</h4> | ||
47 | + </div> | ||
48 | + <div class="resource_inline"> | ||
49 | + {# dropdown de create exercício #} | ||
50 | + <div class="dropdown"> | ||
51 | + <a href="#" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-plus-circle fa-lg" aria-hidden="true"></i></a> | ||
52 | + <ul class="dropdown-menu" aria-labelledby="dLabel"> | ||
53 | + <li><a href="javascript:modal.get('{% url 'course:exercise:create_exercise' topic.slug %}', '#createExercisesModal','#requisicoes_ajax')">{% trans 'Create a specific exercise' %}</a></li> | ||
54 | + </ul> | ||
55 | + </div> | ||
56 | + </div> | ||
57 | + {% include "exercise/create_exercise.html" %} | ||
27 | </div> | 58 | </div> |
28 | </div> | 59 | </div> |
29 | </div> | 60 | </div> |
30 | </div> | 61 | </div> |
31 | </div> | 62 | </div> |
32 | </div> | 63 | </div> |
64 | +</div> | ||
33 | </div> | 65 | </div> |
34 | \ No newline at end of file | 66 | \ No newline at end of file |