diff --git a/deployment/localsettings.template.py b/deployment/localsettings.template.py
index a55f0ca5d..71e27dd76 100644
--- a/deployment/localsettings.template.py
+++ b/deployment/localsettings.template.py
@@ -53,3 +53,5 @@
"de": mark_safe("Deine Teilnahme am Evaluationsprojekt wird helfen. Evaluiere also jetzt!"),
"en": mark_safe("Your participation in the evaluation helps, so evaluate now!"),
}
+# Questionnaires automatically added to exam evaluations
+EXAM_QUESTIONNAIRE_IDS = [111]
diff --git a/evap/development/fixtures/test_data.json b/evap/development/fixtures/test_data.json
index 0203e18e6..6af5c5b40 100644
--- a/evap/development/fixtures/test_data.json
+++ b/evap/development/fixtures/test_data.json
@@ -656,6 +656,24 @@
"is_locked": false
}
},
+{
+ "model": "evaluation.questionnaire",
+ "pk": 111,
+ "fields": {
+ "type": 10,
+ "name_de": "Klausur",
+ "name_en": "Exam",
+ "description_de": "",
+ "description_en": "",
+ "public_name_de": "Klausur",
+ "public_name_en": "Exam",
+ "teaser_de": "",
+ "teaser_en": "",
+ "order": 62,
+ "visibility": 1,
+ "is_locked": false
+ }
+},
{
"model": "evaluation.program",
"pk": 1,
@@ -21784,6 +21802,18 @@
"type": 10
}
},
+{
+ "model": "evaluation.question",
+ "pk": 478,
+ "fields": {
+ "order": 1,
+ "questionnaire": 111,
+ "text_de": "Wie fandest du die Klausur?",
+ "text_en": "How did you like the exam?",
+ "allows_additional_textanswers": true,
+ "type": 6
+ }
+},
{
"model": "evaluation.ratinganswercounter",
"pk": "0009be0e-4a00-4f89-82b7-9733ff0fe35f",
diff --git a/evap/evaluation/models.py b/evap/evaluation/models.py
index c7e4881fd..6bd54928a 100644
--- a/evap/evaluation/models.py
+++ b/evap/evaluation/models.py
@@ -4,7 +4,7 @@
from collections import defaultdict
from collections.abc import Collection, Container, Iterable, Sequence
from dataclasses import dataclass
-from datetime import date, datetime, timedelta
+from datetime import date, datetime, time, timedelta
from enum import Enum, auto
from functools import partial
from numbers import Real
@@ -470,6 +470,30 @@ class State(models.IntegerChoices):
verbose_name=_("wait for grade upload before publishing"), default=True
)
+ @property
+ def has_exam_evaluation(self):
+ return self.course.evaluations.filter(name_de="Klausur", name_en="Exam").exists()
+
+ @property
+ def earliest_possible_exam_date(self):
+ return self.vote_start_datetime.date() + timedelta(days=1)
+
+ @transaction.atomic
+ def create_exam_evaluation(self, exam_date: date):
+ self.weight = 9
+ self.vote_end_date = exam_date - timedelta(days=1)
+ self.save()
+ exam_evaluation = Evaluation(course=self.course, name_de="Klausur", name_en="Exam", weight=1, is_rewarded=False)
+ exam_evaluation.vote_start_datetime = datetime.combine(exam_date + timedelta(days=1), time(8, 0))
+ exam_evaluation.vote_end_date = exam_date + timedelta(days=3)
+ exam_evaluation.save()
+
+ exam_evaluation.participants.set(self.participants.all())
+ for contribution in self.contributions.exclude(contributor=None):
+ exam_evaluation.contributions.create(contributor=contribution.contributor)
+ exam_evaluation.general_contribution.questionnaires.set(settings.EXAM_QUESTIONNAIRE_IDS)
+ exam_evaluation.save()
+
class TextAnswerReviewState(Enum):
do_not_call_in_templates = True # pylint: disable=invalid-name
NO_TEXTANSWERS = auto()
diff --git a/evap/evaluation/templates/base.html b/evap/evaluation/templates/base.html
index 9cc581b22..d48debe48 100644
--- a/evap/evaluation/templates/base.html
+++ b/evap/evaluation/templates/base.html
@@ -211,5 +211,18 @@
{% block additional_javascript %}{% endblock %}
+
+