Commit 7a47ecbb8192fe1fd3042b5721c6b10289d038d5
1 parent
ba2e1913
Exists in
master
and in
5 other branches
changing the delivery create exercise #95
Showing
4 changed files
with
122 additions
and
9 deletions
Show diff stats
courses/templates/subject/form_view_teacher.html
... | ... | @@ -123,13 +123,6 @@ |
123 | 123 | {% list_topic_foruns request topic %} |
124 | 124 | </ul> |
125 | 125 | </div> |
126 | - <div class="editation editation_{{topic.slug}}"> | |
127 | - | |
128 | - {# exercícios do tópico no modo de edição #} | |
129 | - <ul> | |
130 | - {% list_topic_exercise_edit request topic %} | |
131 | - </ul> | |
132 | - </div> | |
133 | 126 | </div> |
134 | 127 | </div> |
135 | 128 | ... | ... |
exercise/templates/exercise/exercise_edit.html
1 | 1 | {% load static i18n list_topic_foruns permission_tags %} |
2 | 2 | <div id="exercise-topic{{ topic.id }}-exercises-edit"> |
3 | 3 | {% for exercise in exercises %} |
4 | - <li class="icon_edit_remove" id = "exercise_edit_icon_{{ exercise.slug }}"> <a href="javascript:modal.get('', '#exercisesModalEdit', '#requisicoes_ajax')"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="javascript:modal.get('', '#exerciseDeleteModal', '#requisicoes_ajax')"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> | |
4 | + <li class="icon_edit_remove" id = "exercise_edit_icon_{{ exercise.slug }}"> <a href="javascript:modal.get('{% url 'course:exercise:update_exercise' exercise.slug %}', '#exercisesModalEdit', '#requisicoes_ajax')"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a> <a href="javascript:modal.get('', '#exerciseDeleteModal', '#requisicoes_ajax')"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a></li> | |
5 | 5 | <li id = "exercise_edit_{{ exercise.slug }}"><i class="fa fa-file" aria-hidden="true"></i> <a href="javascript:modal.get('', '#viewExerciseModal','#requisicoes_ajax')">{{exercise.name_exercise}}</a></li> |
6 | 6 | {% endfor %} |
7 | 7 | </div> | ... | ... |
... | ... | @@ -0,0 +1,120 @@ |
1 | +{% load static widget_tweaks i18n %} | |
2 | + | |
3 | +<!-- MODAL CREATE FILE --> | |
4 | +<link rel="stylesheet" type="text/css" href="{% static 'css/file.css' %}"> | |
5 | + | |
6 | +<div class="erro-update"> | |
7 | + <div class="modal fade" id="exercisesModalEdit" tabindex="-1" role="dialog" aria-labelledby="updateFileLabel" style="z-index: 10"> | |
8 | + <div class="modal-dialog" role="document"> | |
9 | + <div class="modal-content"> | |
10 | + <div class="modal-header"> | |
11 | + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | |
12 | + <h4 class="modal-title" id="updateFileLabel">{% trans 'Edit Material' %}</h4> | |
13 | + </div> | |
14 | + <div class="modal-body"> | |
15 | + <!-- Card --> | |
16 | + <form class="form-horizontal" method="post" id="form-update-exercise" enctype="multipart/form-data"> | |
17 | + {% csrf_token %} | |
18 | + {% if messages %} | |
19 | + {% for message in messages %} | |
20 | + <div class="alert alert-{{ message.tags }} alert-dismissible" role="alert"> | |
21 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
22 | + <span aria-hidden="true">×</span> | |
23 | + </button> | |
24 | + <p>{{ message }}</p> | |
25 | + </div> | |
26 | + {% endfor %} | |
27 | + {% endif %} | |
28 | + <fieldset> | |
29 | + {% for field in form %} | |
30 | + <div class="form-group is-empy{% if form.has_error %} has-error {% endif %} is-fileinput"> | |
31 | + <div class="col-md-12"> | |
32 | + {% if field.field.required %} | |
33 | + <label for="{{ field.auto_id }}" class="control-label">{{ field.label }}<span>*</span></label> | |
34 | + {% else %} | |
35 | + <label for="{{ field.auto_id }}" class=" control-label">{{ field.label }}</label> | |
36 | + {% endif %} | |
37 | + {% if field.auto_id == 'id_file' %} | |
38 | + <input class="form-control input-sm" id="id_file_url" name="file_url" type="file"> | |
39 | + <div class="input-group"> | |
40 | + <input type="text" readonly="" class="form-control" placeholder="{% trans 'Choose your file...' %}"> | |
41 | + <span class="input-group-btn input-group-sm"> | |
42 | + <button type="button" class="btn btn-fab btn-fab-mini"> | |
43 | + <i class="material-icons">attach_file</i> | |
44 | + </button> | |
45 | + </span> | |
46 | + </div> | |
47 | + <div class="crearfix"> | |
48 | + <a href="{{ file.file_url.url }}" target="_blank">{% trans "See current file" %}</a> | |
49 | + </div> | |
50 | + {% else %} | |
51 | + {% render_field field class='form-control input-sm' %} | |
52 | + <span id="helpBlock" class="help-block">{{ field.help_text }}</span> | |
53 | + {% endif %} | |
54 | + </div> | |
55 | + | |
56 | + {% if field.errors %} | |
57 | + <div class="alert alert-danger alert-dismissible clearfix" role="alert"> | |
58 | + <button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |
59 | + <span aria-hidden="true">×</span> | |
60 | + </button> | |
61 | + <ul> | |
62 | + {% for error in field.errors %} | |
63 | + <li>{{ error }}</li> | |
64 | + {% endfor %} | |
65 | + </ul> | |
66 | + </div> | |
67 | + {% endif %} | |
68 | + </div> | |
69 | + {% endfor %} | |
70 | + | |
71 | + <div class="form-group"> | |
72 | + <div class="col-md-12 text-center"> | |
73 | + <p><b>{% trans 'The file size shouldnt exceed 10MB' %}</b></p> | |
74 | + </div> | |
75 | + </div> | |
76 | + | |
77 | + <div class="form-group"> | |
78 | + <div class="col-md-12"> | |
79 | + <button type="button" class="btn btn-default btn-raised" data-dismiss="modal">{% trans "Close" %}</button> | |
80 | + <button class="btn btn-raised btn-primary" type="submit">{% trans 'Submit' %}</button> | |
81 | + </div> | |
82 | + </div> | |
83 | + </fieldset> | |
84 | + </form> | |
85 | + <!-- .end Card --> | |
86 | + </div> | |
87 | + </div> | |
88 | + </div> | |
89 | + </div> | |
90 | +</div> | |
91 | + | |
92 | +{% block script_file %} | |
93 | + | |
94 | + {# // <script src="{% static 'js/file.js' %}"></script> #} | |
95 | + <script type="text/javascript"> | |
96 | + $("#form-update-exercise").submit(function(event) { | |
97 | + var data = new FormData($('#form-update-exercise').get(0)); | |
98 | + $.ajax({ | |
99 | + url: "{% url 'course:exercise:update_exercise' exercise.slug %}", | |
100 | + type: $("#form-update-exercise").attr('method'), | |
101 | + data: data, | |
102 | + cache: false, | |
103 | + processData: false, | |
104 | + contentType: false, | |
105 | + success: function(data) { | |
106 | + $('#Carrinho').modal('hide'); | |
107 | + $('#file_edit_{{ exercise.slug }}').replaceWith(data); | |
108 | + $('#file_{{ exercise.slug }}').replaceWith(data); | |
109 | + }, | |
110 | + error: function(data){ | |
111 | + $('.erro-update').html(data.responseText); | |
112 | + $('.modal-backdrop').remove(); | |
113 | + $('#Carrinho').modal(); | |
114 | + } | |
115 | + }); | |
116 | + event.preventDefault(); | |
117 | + }); | |
118 | + </script> | |
119 | +{% endblock script_file %} | |
120 | +<!-- EndModal --> | |
0 | 121 | \ No newline at end of file | ... | ... |
exercise/templatetags/list_topic_exercises.py
... | ... | @@ -19,7 +19,7 @@ def list_topic_exercise_edit(request, topic): |
19 | 19 | context = { |
20 | 20 | 'request': request, |
21 | 21 | } |
22 | - context['exercises'] = Exercise.objects.filter(topic = topic) | |
22 | + context['exercises'] = Exercise.objects.filter(topic=topic) | |
23 | 23 | context['topic'] = topic |
24 | 24 | |
25 | 25 | return context | ... | ... |