Repository: e-valuation/EvaP

Issue:
Midterm evaluation message
Courses should get an option to be marked as midterm evaluations. For these courses on the student voting page a message will be shown to explain that the evaluation results will be published while the course is still running and before its exam grades are published.


Discussion:

Resolving patch:
diff --git a/evap/evaluation/migrations/0067_course_is_midterm_evaluation.py b/evap/evaluation/migrations/0067_course_is_midterm_evaluation.py
new file mode 100644
--- /dev/null
+++ b/evap/evaluation/migrations/0067_course_is_midterm_evaluation.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.0.4 on 2018-05-10 16:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('evaluation', '0066_rename_course_is_required_for_reward'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='course',
+            name='is_midterm_evaluation',
+            field=models.BooleanField(default=False, verbose_name='is midterm evaluation'),
+        ),
+    ]
diff --git a/evap/evaluation/models.py b/evap/evaluation/models.py
--- a/evap/evaluation/models.py
+++ b/evap/evaluation/models.py
@@ -251,6 +251,9 @@ class Course(models.Model, metaclass=LocalizeModelBase):
     # whether participants must vote to qualify for reward points
     is_rewarded = models.BooleanField(verbose_name=_("is rewarded"), default=True)
 
+    # whether the evaluation does take place during the semester, stating that evaluation results will be published while the course is still running
+    is_midterm_evaluation = models.BooleanField(verbose_name=_("is midterm evaluation"), default=False)
+
     # students that are allowed to vote
     participants = models.ManyToManyField(settings.AUTH_USER_MODEL, verbose_name=_("participants"), blank=True, related_name='courses_participating_in')
     _participant_count = models.IntegerField(verbose_name=_("participant count"), blank=True, null=True, default=None)
diff --git a/evap/staff/forms.py b/evap/staff/forms.py
--- a/evap/staff/forms.py
+++ b/evap/staff/forms.py
@@ -139,8 +139,9 @@ class CourseForm(forms.ModelForm):
 
     class Meta:
         model = Course
-        fields = ('name_de', 'name_en', 'type', 'degrees', 'is_graded', 'is_private', 'is_rewarded', 'vote_start_datetime',
-                  'vote_end_date', 'participants', 'general_questions', 'last_modified_time_2', 'last_modified_user_2', 'semester')
+        fields = ('name_de', 'name_en', 'type', 'degrees', 'is_graded', 'is_private', 'is_rewarded',
+                  'is_midterm_evaluation', 'vote_start_datetime', 'vote_end_date', 'participants', 'general_questions',
+                  'last_modified_time_2', 'last_modified_user_2', 'semester')
         localized_fields = ('vote_start_datetime', 'vote_end_date')
         field_classes = {
             'participants': UserModelMultipleChoiceField,


Test patch:
diff --git a/evap/student/tests/test_views.py b/evap/student/tests/test_views.py
--- a/evap/student/tests/test_views.py
+++ b/evap/student/tests/test_views.py
@@ -193,3 +193,14 @@ def test_user_logged_out(self):
         response = form.submit()
         self.assertEqual(response.status_code, 302)
         self.assertNotIn(SUCCESS_MAGIC_STRING, response)
+
+    def test_midterm_evaluation_warning(self):
+        evaluation_warning = "The results of this evaluation will be published while the course is still running."
+        page = self.get_assert_200(self.url, user=self.voting_user1.username)
+        self.assertNotIn(evaluation_warning, page)
+
+        self.course.is_midterm_evaluation = True
+        self.course.save()
+
+        page = self.get_assert_200(self.url, user=self.voting_user1.username)
+        self.assertIn(evaluation_warning, page)