Skip to content

Commit 6597968

Browse files
author
FSadrieh
committed
Update exam modals to new modals
1 parent 3682b74 commit 6597968

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

evap/staff/templates/staff_semester_view.html

+15-20
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,20 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
387387
});
388388
</script>
389389

390+
<form reload-on-success method="post" action="{% url 'staff:create_exam_evaluation' %}">
391+
{% csrf_token %}
392+
<confirmation-modal type="submit" id="exam_creation_modal" name="evaluation_id" value="{{ evaluation.id }}" confirm-button-class="btn-primary" title="{% translate 'Create exam evaluations' %}">
393+
<span slot="title">{% translate 'Create exam evaluations' %}</span>
394+
<span slot="action-text">{% translate 'Create exam evaluation' %}</span>
395+
<span slot="question">
396+
{% blocktranslate %}
397+
Create an exam evaluation based on this evaluation. This will copy all the participants and contributors from the original evaluation. It will set the weight of the original evaluation to 9 and its end date will be set to the day before the exam.
398+
{% endblocktranslate %}
399+
</span>
400+
<button slot="show-button" type="button" class="btn btn-sm btn-light"><span class="fas fa-file-pen fa-fw"></span></button>
401+
</confirmation-modal>
402+
</form>
403+
390404
<form id="evaluation_operation_form" class="table-responsive" method="GET" action="{% url 'staff:evaluation_operation' semester.pk %}">
391405
{% if num_evaluations > 0 %}
392406
<table id="evaluation-table" class="table table-striped table-narrow table-vertically-aligned">
@@ -475,6 +489,7 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
475489
{% endif %}
476490
</form>
477491
</div>
492+
478493
<div class="tab-pane" id="courses" role="tabpanel">
479494
<div class="row align-items-center mb-3">
480495
<div class="col-9">
@@ -589,26 +604,6 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
589604
</div>
590605
{% endblock %}
591606

592-
{% block modals %}
593-
{{ block.super }}
594-
{% trans 'Create exam evaluation' as title %}
595-
{% blocktrans asvar question %}Create an exam evaluation based on this evaluation. This will copy all the participants and contributors from the original evaluation. It will set the weight of the original evaluation to 9 and its end date will be set to the day before the exam. {% endblocktrans %}
596-
{% trans 'Create exam evaluation' as action_text %}
597-
{% include 'confirmation_modal.html' with modal_id='createExamEvaluation' title=title question=question action_text=action_text btn_type='primary' %}
598-
<script type="text/javascript">
599-
function createExamEvaluationAction(dataId) {
600-
fetch("{% url 'staff:create_exam_evaluation' %}", {
601-
body: new URLSearchParams({evaluation_id: dataId}),
602-
headers: CSRF_HEADERS,
603-
method: "POST",
604-
}).then(response => {
605-
assert(response.ok);
606-
location.reload();
607-
}).catch(error => {window.alert("{% trans 'The server is not responding.' %}");});
608-
};
609-
</script>
610-
{% endblock %}
611-
612607
{% block additional_javascript %}
613608
<script type="text/javascript">
614609
var overviewCard = document.getElementById('overviewCard');

evap/staff/templates/staff_semester_view_evaluation.html

+15-6
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,8 @@
188188
<a href="{% url 'staff:evaluation_copy' evaluation.id %}" class="btn btn-sm btn-light" data-bs-toggle="tooltip" title="{% translate "Copy" %}">
189189
<span class="fas fa-copy"></span>
190190
</a>
191-
{% if not evaluation.has_exam%}
192-
<a class="btn btn-sm btn-dark" data-bs-toggle="tooltip"
193-
onclick="createExamEvaluationShow({{ evaluation.id }}, '{{ course.name|escapejs }}');"
194-
title="{% trans 'Create exam evaluation' %}">
195-
<span class="fas fa-file-pen fa-fw"></span>
196-
</a>
191+
{% if not evaluation.has_exam %}
192+
<button id="openModalBtn" type="button" class="btn btn-sm btn-light" evaluation_id="{{ evaluation.id }}"><span class="fas fa-file-pen fa-fw"></span></button>
197193
{% endif %}
198194
{% endif %}
199195
{% if request.user.is_manager %}
@@ -232,4 +228,17 @@
232228
{% endif %}
233229
</td>
234230

231+
<script>
232+
var exam_creation_modal = document.getElementById("exam_creation_modal");
233+
var btn = document.querySelectorAll('button[evaluation_id="{{ evaluation.id }}"]')[0];
234+
var span = document.getElementsByClassName("close")[0];
235+
236+
// When the user clicks the button, open the modal
237+
btn.onclick = function() {
238+
var modalForm = exam_creation_modal.querySelector("form");
239+
exam_creation_modal.setAttribute("value", this.getAttribute("evaluation_id"));
240+
exam_creation_modal.dialog.showModal();
241+
}
242+
</script>
243+
235244
{% endwith %}

0 commit comments

Comments
 (0)