Skip to content

Commit

Permalink
Use confirmation modals now correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
FSadrieh committed Apr 22, 2024
1 parent 5aea609 commit e4614c1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 35 deletions.
3 changes: 3 additions & 0 deletions deployment/localsettings.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@

# Make apache work when DEBUG == False
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]

# Questionnaires automatically added to exam evaluations
EXAM_QUESTIONNAIRE_IDS = [83]
2 changes: 1 addition & 1 deletion evap/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def make_exam_evaluation(self, exam_date: date, participants, eval_contributions
self.participants.set(participants)
for contribution in eval_contributions:
self.contributions.create(contributor=contribution.contributor)
self.general_contribution.questionnaires.set(settings.EXAM_QUESTIONNAIRES)
self.general_contribution.questionnaires.set(settings.EXAM_QUESTIONNAIRE_IDS)

class TextAnswerReviewState(Enum):
do_not_call_in_templates = True # pylint: disable=invalid-name
Expand Down
2 changes: 1 addition & 1 deletion evap/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
EVALUATION_END_WARNING_PERIOD = 5

# Questionnaires automatically added to exam evaluations
EXAM_QUESTIONNAIRES = [83]
EXAM_QUESTIONNAIRE_IDS = []

### Installation specific settings

Expand Down
25 changes: 6 additions & 19 deletions evap/staff/templates/staff_semester_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
</div>
</div>

{% for evaluation in evaluations %}
<form id="exam_creation_form_{{ evaluation.id }}" reload-on-success method="post" action="{% url 'staff:create_exam_evaluation' %}">
{% csrf_token %}
</form>
{% endfor %}

<form id="evaluation-deletion-form" custom-success method="POST" action="{% url 'staff:evaluation_delete' %}">
{% csrf_token %}
</form>
Expand All @@ -387,25 +393,6 @@ <h3 class="m-0 me-1">{{ semester.name }}</h3>
});
</script>

<form reload-on-success method="post" action="{% url 'staff:create_exam_evaluation' %}">
{% csrf_token %}
<confirmation-modal type="submit" id="exam_creation_modal" name="evaluation_id" value="{{ evaluation.id }}" confirm-button-class="btn-primary" title="{% translate 'Create exam evaluations' %}">
<span slot="title">{% translate 'Create exam evaluations' %}</span>
<span slot="action-text">{% translate 'Create exam evaluation' %}</span>
<span slot="question">
{% blocktranslate %}
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.
{% endblocktranslate %}
</span>
<span slot="extra-inputs">
<label for="exam_date">{% translate 'Exam Date:' %}</label>
<input type="date" id="exam_date" name="exam_date" required>
</span>

<button slot="show-button" type="button" class="btn btn-sm btn-light"><span class="fas fa-file-pen fa-fw"></span></button>
</confirmation-modal>
</form>

<form id="evaluation_operation_form" class="table-responsive" method="GET" action="{% url 'staff:evaluation_operation' semester.pk %}">
{% if num_evaluations > 0 %}
<table id="evaluation-table" class="table table-striped table-narrow table-vertically-aligned">
Expand Down
29 changes: 15 additions & 14 deletions evap/staff/templates/staff_semester_view_evaluation.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,21 @@
<span class="fas fa-copy"></span>
</a>
{% if not evaluation.has_exam %}
<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>
<confirmation-modal type="submit" id="exam_creation_modal" name="evaluation_id" value="{{ evaluation.id }}" confirm-button-class="btn-primary" title="{% translate 'Create exam evaluations' %}" form="exam_creation_form_{{ evaluation.id }}">
<span slot="title">{% translate 'Create exam evaluations' %}</span>
<span slot="action-text">{% translate 'Create exam evaluation' %}</span>
<span slot="question">
{% blocktranslate %}
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.
{% endblocktranslate %}
</span>
<span slot="extra-inputs">
<label for="exam_date">{% translate 'Exam Date:' %}</label>
<input type="date" id="exam_date" name="exam_date" required form="exam_creation_form_{{ evaluation.id }}">
</span>

<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>
</confirmation-modal>
{% endif %}
{% endif %}
{% if request.user.is_manager %}
Expand Down Expand Up @@ -228,17 +242,4 @@
{% endif %}
</td>

<script>
var exam_creation_modal = document.getElementById("exam_creation_modal");
var btn = document.querySelectorAll('button[evaluation_id="{{ evaluation.id }}"]')[0];
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal
btn.onclick = function() {
var modalForm = exam_creation_modal.querySelector("form");
exam_creation_modal.setAttribute("value", this.getAttribute("evaluation_id"));
exam_creation_modal.dialog.showModal();
}
</script>

{% endwith %}

0 comments on commit e4614c1

Please sign in to comment.