Jonas Havelka
2 years ago
17 changed files with 217 additions and 169 deletions
@ -0,0 +1,22 @@ |
|||||
|
// Kontrola, že org neposílá nějakou blbost v detail.html
|
||||
|
|
||||
|
function zkontroluj_hodnoceni() { |
||||
|
const pocet = $('.hodnoceni').length; |
||||
|
if (pocet === 1) { // vidím pouze plusko
|
||||
|
const vysledek = confirm("Odstranil jsi všechny problémy tohoto řešení. Nepůjde tedy dohledat přes problémy, co řeší, tj. například v došlých řešeních. Přesto odeslat?"); |
||||
|
if (!vysledek) { |
||||
|
event.preventDefault(); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function problem_is_empty(elem, index, array) {return elem.firstElementChild.children.length !== 1 && elem.firstElementChild.children[1].textContent === "";} |
||||
|
|
||||
|
if ($('.hodnoceni').toArray().some(problem_is_empty)) { |
||||
|
alert("Neuloženo! Nezadal jsi problém, ke kterému posíláš hodnocení. Pokud je toto hodnocení navíc, smaž ho prosím křížkem a znovu odešli.") |
||||
|
event.preventDefault() |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return true; |
||||
|
} |
@ -0,0 +1,56 @@ |
|||||
|
// FIXME: Necopypastovat! Tohle je zkopírované ze static/odevzdavatko/dynamic_formsets.js
|
||||
|
|
||||
|
|
||||
|
// Credit https://medium.com/all-about-django/adding-forms-dynamically-to-a-django-formset-375f1090c2b0
|
||||
|
function updateElementIndex(el, prefix, ndx) { |
||||
|
var id_regex = new RegExp('(' + prefix + '-\\d+)'); |
||||
|
var replacement = prefix + '-' + ndx; |
||||
|
if ($(el).attr("for")) { |
||||
|
$(el).attr("for", $(el).attr("for").replace(id_regex, replacement)); |
||||
|
} |
||||
|
if (el.id) { |
||||
|
el.id = el.id.replace(id_regex, replacement); |
||||
|
} |
||||
|
if (el.name) { |
||||
|
el.name = el.name.replace(id_regex, replacement); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Credit https://medium.com/all-about-django/adding-forms-dynamically-to-a-django-formset-375f1090c2b0
|
||||
|
function deleteForm(prefix, btn) { |
||||
|
var total = parseInt($('#id_' + prefix + '-TOTAL_FORMS').val()); |
||||
|
if (total >= 1){ |
||||
|
btn.closest('tr').remove(); |
||||
|
var forms = $('.hodnoceni'); |
||||
|
var formCount = forms.length - 1; // There is one extra such form hidden as template!
|
||||
|
$('#id_' + prefix + '-TOTAL_FORMS').val(formCount); |
||||
|
for (var i=0; i<formCount; i++) { |
||||
|
$(forms.get(i)).find(':input').each(function() { |
||||
|
updateElementIndex(this, prefix, i); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// Credit: https://simpleit.rocks/python/django/dynamic-add-form-with-add-button-in-django-modelformset-template/
|
||||
|
$(document).ready(function(){ |
||||
|
$('#pridat_hodnoceni').click(function() { |
||||
|
var form_idx = $('#id_form-TOTAL_FORMS').val(); |
||||
|
var new_form = $('#empty_form').html().replace(/__prefix__/g, form_idx); |
||||
|
$('#form_set').append(new_form); |
||||
|
// Newly created form has not the binding between remove button and remove function
|
||||
|
// We need to add it manually
|
||||
|
$('.smazat_hodnoceni').click(function(){ |
||||
|
deleteForm("form",this); |
||||
|
}); |
||||
|
// Copy deadline
|
||||
|
if (form_idx !== "0") { |
||||
|
$('#id_form-' + form_idx + '-deadline_body')[0].value = $('#id_form-' + (form_idx - 1) + '-deadline_body')[0].value |
||||
|
} |
||||
|
$('#id_form-TOTAL_FORMS').val(parseInt(form_idx) + 1); |
||||
|
}); |
||||
|
$('.smazat_hodnoceni').click(function(){ |
||||
|
deleteForm("form",this); |
||||
|
}); |
||||
|
}); |
@ -1,51 +0,0 @@ |
|||||
{% extends "base.html" %} |
|
||||
{% load static %} |
|
||||
{% load deadliny %} |
|
||||
|
|
||||
{% block content %} |
|
||||
|
|
||||
<p>Řešené problémy: {{ object.problem.all | join:", " }}</p> |
|
||||
|
|
||||
<p>Řešitelé: {% for r in object.resitele.all %} {{ r }} |
|
||||
{% if forloop.revcounter0 != 0 %}, {% endif %} {% endfor %}</p> |
|
||||
|
|
||||
{# https://docs.djangoproject.com/en/3.1/ref/models/instances/#django.db.models.Model.get_FOO_display #} |
|
||||
<p>Forma: {{ object.get_forma_display }}</p> |
|
||||
|
|
||||
<p>Doručeno {{ object.cas_doruceni }}, deadline: {{object.deadline_reseni | deadline_html }}</p> |
|
||||
|
|
||||
{# Soubory: #} |
|
||||
<h3>Přílohy:</h3> |
|
||||
{% if object.prilohy.all %} |
|
||||
<table class="dosla_reseni"> |
|
||||
<tr><th>Soubor</th><th>Řešitelova poznámka</th><th>Datum</th></tr> |
|
||||
{% for priloha in object.prilohy.all %} |
|
||||
<tr> |
|
||||
<td><a href="{{ priloha.soubor.url }}" download>{{ priloha.split | last }}</a></td> |
|
||||
<td>{{ priloha.res_poznamka }}</td> |
|
||||
<td>{{ priloha.vytvoreno }}</td></tr> |
|
||||
{# TODO: Orgo-poznámka, ideálně jako formulář #} |
|
||||
{% endfor %} |
|
||||
</table> |
|
||||
{% else %} |
|
||||
<p>Žádné přílohy</p> |
|
||||
{% endif %} |
|
||||
|
|
||||
{#<h3>Poznámka:</h3>#} |
|
||||
{#<p>{{ poznamka }}</p>#} |
|
||||
|
|
||||
{# Hodnocení: #} |
|
||||
<h3>Hodnocení:</h3> |
|
||||
<table id="form_set" class="dosla_reseni"> |
|
||||
<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 %} |
|
||||
<tr class="hodnoceni"> |
|
||||
<td>{{ h.problem }}</td> |
|
||||
<td>{{ h.body }}</td> |
|
||||
<td>{{ h.feedback }}</td> |
|
||||
{# <td>{{ h.deadline_body }}</td>#} |
|
||||
</tr> |
|
||||
{% endfor %} |
|
||||
</table> |
|
||||
|
|
||||
{% endblock %} |
|
@ -0,0 +1,18 @@ |
|||||
|
# Generated by Django 2.2.28 on 2022-11-21 22:07 |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('seminar', '0109_hodnoceni_feedback'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='resitel', |
||||
|
name='prezdivka_resitele', |
||||
|
field=models.CharField(blank=True, max_length=256, null=True, unique=True, verbose_name='přezdívka řešitele'), |
||||
|
), |
||||
|
] |
Loading…
Reference in new issue