Skip to content

Commit c00fe0a

Browse files
author
Frederic Sadrieh
committed
Better datechecker
1 parent 072c693 commit c00fe0a

File tree

2 files changed

+9
-28
lines changed

2 files changed

+9
-28
lines changed

evap/staff/templates/staff_semester_view.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,9 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
377377
</div>
378378
</div>
379379

380-
{% for evaluation in evaluations %}
381-
<form id="exam_creation_form_{{ evaluation.id }}" reload-on-success method="post" action="{% url 'staff:create_exam_evaluation' %}">
382-
{% csrf_token %}
383-
</form>
384-
{% endfor %}
380+
<form id="exam_creation_form" reload-on-success method="post" action="{% url 'staff:create_exam_evaluation' %}">
381+
{% csrf_token %}
382+
</form>
385383

386384
<form id="evaluation-deletion-form" custom-success method="POST" action="{% url 'staff:evaluation_delete' %}">
387385
{% csrf_token %}

evap/staff/templates/staff_semester_view_evaluation.html

+6-23
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
<span class="fas fa-copy"></span>
190190
</a>
191191
{% if not evaluation.has_exam %}
192-
<confirmation-modal type="submit" id="exam_creation_modal" name="evaluation_id" value="{{ evaluation.id }}" confirm-button-class="btn-primary" form="exam_creation_form_{{ evaluation.id }}">
192+
<confirmation-modal type="submit" name="evaluation_id" value="{{ evaluation.id }}" confirm-button-class="btn-primary" form="exam_creation_form">
193193
<span slot="title">{% translate 'Create exam evaluation' %}</span>
194194
<span slot="action-text" id="submit_button">{% translate 'Create exam evaluation' %}</span>
195195
<span slot="question">
@@ -198,16 +198,18 @@
198198
{% endblocktranslate %}
199199
</span>
200200
<div slot="extra-inputs">
201-
<label for="exam_date">{% translate 'Exam Date:' %}</label>
202-
<input type="date" id="exam_date" name="exam_date" data-must-before="{{ evaluation.vote_start_datetime }}" class="form-control" required form="exam_creation_form_{{ evaluation.id }}"/>
201+
<label>
202+
{% translate 'Exam Date:' %}
203+
<input type="date" name="exam_date" evaluationDate="{{ evaluation.vote_start_datetime }}" class="form-control" required form="exam_creation_form"/>
204+
</label>
203205
</div>
204206

205207
<button slot="show-button" type="button" class="btn btn-sm btn-light" title="{% translate 'Create exam evaluation' %}" data-bs-placement="top" data-bs-toggle="tooltip"><span class="fas fa-file-pen fa-fw"></span></button>
206208

207209
<script type="text/javascript">
208210
document.getElementById('submit_button').addEventListener('click', function(event) {
209211
var inputDate = new Date(document.getElementById('exam_date').value);
210-
var evaluationDate = new Date(document.getElementById('exam_date').dataset.mustBefore);
212+
var evaluationDate = new Date(document.getElementById('exam_date').dataset.evaluationDate);
211213

212214
if (inputDate <= evaluationDate) {
213215
document.getElementById('exam_date').setCustomValidity("{% translate 'The exam date is before the start date of the main evaluation.' %}");
@@ -217,25 +219,6 @@
217219
});
218220
</script>
219221

220-
<!-- <script type="text/javascript">
221-
var examModal = document.currentScript.closest("confirmation-modal");
222-
223-
examModal.querySelectorAll("[data-evaluation-date]").forEach(element => {
224-
element.addEventListener("click", () => {
225-
var inputDate = new Date(element.value);
226-
var evaluationDate = new Date(element.dataset.evaluationDate);
227-
if (inputDate <= evaluationDate) {
228-
element.setCustomValidity("{% translate 'The exam date is before the start date of the main evaluation.' %}");
229-
} else {
230-
element.setCustomValidity("");
231-
}
232-
233-
element.reportValidity();
234-
});
235-
element.dispatchEvent(new Event("change"));
236-
});
237-
</script> -->
238-
239222
</confirmation-modal>
240223
{% endif %}
241224
{% endif %}

0 commit comments

Comments
 (0)