Browse Source

odevzdavatko: políčko pro zpětnou vazbu řešiteli

Karel Balej 2 years ago
parent
commit
973d3fc8bf
  1. 2
      mamweb/static/css/mamweb.css
  2. 5
      odevzdavatko/forms.py
  3. 6
      odevzdavatko/templates/odevzdavatko/detail.html
  4. 3
      odevzdavatko/templates/odevzdavatko/detail_resitele.html
  5. 8
      odevzdavatko/views.py
  6. 18
      seminar/migrations/0108_hodnoceni_feedback.py
  7. 2
      seminar/models/odevzdavatko.py

2
mamweb/static/css/mamweb.css

@ -417,7 +417,7 @@ input[type="file"] {
display: block; display: block;
} }
input { input, textarea {
margin: 5px; margin: 5px;
} }

5
odevzdavatko/forms.py

@ -88,11 +88,12 @@ ReseniSPrilohamiFormSet = inlineformset_factory(m.Reseni,m.PrilohaReseni,
class JednoHodnoceniForm(forms.ModelForm): class JednoHodnoceniForm(forms.ModelForm):
class Meta: class Meta:
model = m.Hodnoceni model = m.Hodnoceni
fields = ('problem', 'body', 'deadline_body') fields = ('problem', 'body', 'deadline_body', 'feedback',)
widgets = { widgets = {
'problem': autocomplete.ModelSelect2( 'problem': autocomplete.ModelSelect2(
url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší? url='autocomplete_problem_odevzdatelny', # FIXME: Dovolit i starší?
) ),
'feedback': forms.Textarea(attrs={'rows': 1, 'cols': 30}),
} }
OhodnoceniReseniFormSet = formset_factory(JednoHodnoceniForm, OhodnoceniReseniFormSet = formset_factory(JednoHodnoceniForm,

6
odevzdavatko/templates/odevzdavatko/detail.html

@ -91,7 +91,7 @@ $(document).ready(function(){
<form method=post onsubmit="return zkontroluj_hodnoceni();"> <form method=post onsubmit="return zkontroluj_hodnoceni();">
{# Poznámka #} {# Poznámka #}
<h3>Poznámka:</h3> <h3>Neveřejná poznámka:</h3>
<p>{{ poznamka_form.poznamka }}</p> <p>{{ poznamka_form.poznamka }}</p>
{# Hodnocení: #} {# Hodnocení: #}
@ -101,13 +101,14 @@ $(document).ready(function(){
{{ form.management_form }} {{ form.management_form }}
</table> </table>
<table id="form_set"> <table id="form_set">
<tr><th>Problém</th><th>Body</th><th>Deadline pro body</th></tr> <tr><th>Problém</th><th>Body</th><th>Deadline pro body</th><th>Zpětná vazba pro řešitele</th></tr>
{% for subform in form %} {% for subform in form %}
<tbody> <tbody>
<tr class="hodnoceni"> <tr class="hodnoceni">
<td>{{ subform.problem }}</td> <td>{{ subform.problem }}</td>
<td>{{ subform.body }}</td> <td>{{ subform.body }}</td>
<td>{{ subform.deadline_body }}</td> <td>{{ subform.deadline_body }}</td>
<td>{{ subform.feedback }}</td>
<td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td> <td><a href="#" class="smazat_hodnoceni" id="id_{{subform.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
</tr> </tr>
</tbody> </tbody>
@ -123,6 +124,7 @@ $(document).ready(function(){
<td>{{ form.empty_form.problem }}</td> <td>{{ form.empty_form.problem }}</td>
<td>{{ form.empty_form.body }}</td> <td>{{ form.empty_form.body }}</td>
<td>{{ form.empty_form.deadline_body }}</td> <td>{{ form.empty_form.deadline_body }}</td>
<td>{{ form.empty_form.feedback }}</td>
<td><a href="#" class="smazat_hodnoceni" id="id_{{form.empty_form.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td> <td><a href="#" class="smazat_hodnoceni" id="id_{{form.empty_form.prefix}}-jsremove"><img src="{% static "odevzdavatko/cross.png" %}" alt="Smazat"></a></td>
</tr> </tr>
</table> </table>

3
odevzdavatko/templates/odevzdavatko/detail_resitele.html

@ -37,11 +37,12 @@
{# Hodnocení: #} {# Hodnocení: #}
<h3>Hodnocení:</h3> <h3>Hodnocení:</h3>
<table id="form_set" class="dosla_reseni"> <table id="form_set" class="dosla_reseni">
<tr><th>Problém</th><th>Body</th>{# <th>Deadline pro body</th> #}</tr> <tr><th>Problém</th><th>Body</th><th>Zpětná vazba od opravovatele</th>{# <th>Deadline pro body</th> #}</tr>
{% for h in hodnoceni %} {% for h in hodnoceni %}
<tr class="hodnoceni"> <tr class="hodnoceni">
<td>{{ h.problem }}</td> <td>{{ h.problem }}</td>
<td>{{ h.body }}</td> <td>{{ h.body }}</td>
<td>{{ h.feedback }}</td>
{# <td>{{ h.deadline_body }}</td>#} {# <td>{{ h.deadline_body }}</td>#}
</tr> </tr>
{% endfor %} {% endfor %}

8
odevzdavatko/views.py

@ -218,10 +218,11 @@ class DetailReseniView(DetailView):
self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk'])
result = [] # Slovníky s klíči problem, body, deadline_body -- initial data pro f.OhodnoceniReseniFormSet result = [] # Slovníky s klíči problem, body, deadline_body -- initial data pro f.OhodnoceniReseniFormSet
for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni): for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni):
result.append( result.append({
{"problem": hodn.problem, "problem": hodn.problem,
"body": hodn.body, "body": hodn.body,
"deadline_body": hodn.deadline_body, "deadline_body": hodn.deadline_body,
"feedback": hodn.feedback,
}) })
return result return result
@ -261,10 +262,12 @@ def hodnoceniReseniView(request, pk, *args, **kwargs):
problem = form.cleaned_data['problem'] problem = form.cleaned_data['problem']
body = form.cleaned_data['body'] body = form.cleaned_data['body']
deadline_body = form.cleaned_data['deadline_body'] deadline_body = form.cleaned_data['deadline_body']
feedback = form.cleaned_data['feedback']
hodnoceni = m.Hodnoceni( hodnoceni = m.Hodnoceni(
problem=problem, problem=problem,
body=body, body=body,
deadline_body=deadline_body, deadline_body=deadline_body,
feedback=feedback,
reseni=reseni, reseni=reseni,
) )
logger.info(f"Creating Hodnoceni: {hodnoceni}") logger.info(f"Creating Hodnoceni: {hodnoceni}")
@ -285,6 +288,7 @@ class ResitelReseniView(DetailView):
{ {
"problem": hodn.problem, "problem": hodn.problem,
"body": hodn.body, "body": hodn.body,
"feedback": hodn.feedback,
# "deadline_body": hodn.deadline_body, # "deadline_body": hodn.deadline_body,
} }
) )

18
seminar/migrations/0108_hodnoceni_feedback.py

@ -0,0 +1,18 @@
# Generated by Django 3.2.16 on 2022-11-14 19:30
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('seminar', '0107_zmrazenavysledkovka'),
]
operations = [
migrations.AddField(
model_name='hodnoceni',
name='feedback',
field=models.TextField(blank=True, default='', help_text='Zpětná vazba řešiteli (plain text)', verbose_name='zpětná vazba'),
),
]

2
seminar/models/odevzdavatko.py

@ -113,6 +113,8 @@ class Hodnoceni(bm.SeminarModelBase):
problem = models.ForeignKey(am.Problem, verbose_name='problém', problem = models.ForeignKey(am.Problem, verbose_name='problém',
related_name='hodnoceni', on_delete=models.PROTECT) related_name='hodnoceni', on_delete=models.PROTECT)
feedback = models.TextField('zpětná vazba', blank=True, default='', help_text='Zpětná vazba řešiteli (plain text)')
def __str__(self): def __str__(self):
return "{}, {}, {}".format(self.problem, self.reseni, self.body) return "{}, {}, {}".format(self.problem, self.reseni, self.body)

Loading…
Cancel
Save