Skip to content
Snippets Groups Projects
Verified Commit ef983d7e authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Store possible not necessary WIP

parent 4c18e34b
1 merge request!18Draft: Resolve "Add mode to allow showing results before final time"
......@@ -43,7 +43,7 @@ class EvaluationPhaseForm(forms.ModelForm):
Row("evaluation_date_start", "evaluation_date_end"),
Row("results_date_start"),
),
Fieldset(_("Additional data"), Row("privacy_notice")),
Fieldset(_("Additional data"), Row("privacy_notice"), Row("show_results_before_results_phase")),
)
class Meta:
......@@ -57,6 +57,7 @@ class EvaluationPhaseForm(forms.ModelForm):
"evaluation_date_end",
"results_date_start",
"privacy_notice",
"show_results_before_results_phase",
]
widgets = {
"evaluated_group": ModelSelect2Widget(
......
# Generated by Django 3.2.16 on 2022-12-26 13:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('evalu', '0012_deletion'),
]
operations = [
migrations.AddField(
model_name='evaluationgroup',
name='closed',
field=models.BooleanField(default=False, verbose_name='Evaluation closed'),
),
migrations.AddField(
model_name='evaluationphase',
name='show_results_before_results_phase',
field=models.BooleanField(default=False, verbose_name='Show results before the results phase has started'),
),
]
......@@ -55,6 +55,12 @@ class EvaluationPhase(ExtensibleModel):
)
evaluation_date_end = models.DateField(verbose_name=_("Date when all evaluations stop"))
results_date_start = models.DateField(verbose_name=_("First date teachers can see results"))
show_results_before_results_phase = models.BooleanField(
default=False,
verbose_name=_(
"Show results before the results phase has started"
),
)
privacy_notice = RichTextField(verbose_name=_("Privacy notice which teachers have to agree"))
......@@ -428,10 +434,11 @@ class EvaluationGroup(ExtensibleModel):
)
group_name = models.CharField(max_length=255, verbose_name=_("Group name"))
unlocked = models.BooleanField(default=False, verbose_name=_("Evaluation unlocked"))
closed = models.BooleanField(default=False, verbose_name=_("Evaluation closed"))
@property
def is_unlocked(self):
return self.unlocked and self.registration.phase.status == "evaluation"
return self.unlocked and self.registration.phase.status == "evaluation" and not self.closed
def lock(self):
"""Lock the group for evaluations."""
......@@ -443,6 +450,11 @@ class EvaluationGroup(ExtensibleModel):
self.unlocked = True
self.save()
def close(self):
"""Close the group for evaluations."""
self.closed = True
self.save()
@property
def possible_comparison_groups(self):
return self.registration.phase.comparison_groups.filter(
......
......@@ -12,7 +12,7 @@ from aleksis.apps.evalu.util.predicates import (
is_member_of_evaluated_group,
is_participant_for_group,
is_registration_running,
is_unlocked,
is_unlocked, is_closing_possible,
)
from aleksis.core.util.predicates import has_global_perm, has_object_perm, has_person
......@@ -89,7 +89,7 @@ manage_evaluation_process_predicate = (
add_perm("evalu.manage_evaluation_process_rule", manage_evaluation_process_predicate)
view_evaluations_results_predicate = view_evaluationregistration_predicate & (
is_evaluation_status("results") | is_finished
is_evaluation_status("results") | is_finished | is_closing_possible
)
add_perm("evalu.view_evaluation_results_rule", view_evaluations_results_predicate)
......@@ -114,6 +114,17 @@ stop_evaluation_for_group_predicate = (
)
add_perm("evalu.stop_evaluation_for_group_rule", stop_evaluation_for_group_predicate)
close_evaluation_for_group_predicate = (
has_person
& is_evaluation_status_for_group("evaluation")
& ~is_finished
& is_unlocked
& is_closing_possible
& (is_evaluated_person_for_group | has_global_perm("evalu.edit_evaluationgroup"))
)
add_perm("evalu.close_evaluation_for_group_rule", close_evaluation_for_group_predicate)
view_evaluations_as_participant_predicate = has_person & has_any_evaluation_group
add_perm("evalu.view_evaluations_as_participant_rule", view_evaluations_as_participant_predicate)
......
......@@ -71,7 +71,7 @@
{% trans "Finish evaluation" %}
</a>
{% endif %}
{% if phase.registrations.all and phase.registrations.all.0.results_accessible %}
{% if phase.registrations.all and phase.registrations.all.0.results_accessible or phase.show_results_before_results_phase %}
<a class="btn waves-effect waves-light"
href="{% url "evaluation_results" phase.registrations.all.0.pk %}">
<i class="material-icons left">insights</i>
......
......@@ -50,12 +50,18 @@
<i class="material-icons left">stop</i>
{% trans "Stop evaluation" %}
</a>
{% else %}
{% elif not group.closed %}
<a class="btn waves-effect waves-light green" href="{% url "start_evaluation_for_group" group.pk %}">
<i class="material-icons left">play_arrow</i>
{% trans "Start evaluation" %}
</a>
{% endif %}
{% if not group.is_unlocked and not group.closed %}
<a class="btn waves-effect waves-light orange" href="{% url "close_evaluation_for_group" group.pk %}">
<i class="material-icons left">stop</i>
{% trans "Close evaluation and show results" %}
</a>
{% endif %}
{% endif %}
</td>
</tr>
......
......@@ -61,6 +61,11 @@ urlpatterns = [
views.StopEvaluationForGroupView.as_view(),
name="stop_evaluation_for_group",
),
path(
"evaluations/groups/<int:pk>/close/",
views.CloseEvaluationForGroupView.as_view(),
name="close_evaluation_for_group",
),
path(
"evaluations/registrations/<int:pk>/finish/",
views.FinishEvaluationView.as_view(),
......
......@@ -90,3 +90,7 @@ def is_finished(user, obj):
if hasattr(obj, "registration"):
return obj.registration.finished
return obj.finished
@predicate
def is_closing_possible(user, obj):
return obj.phase.show_results_before_results_phase
......@@ -311,6 +311,23 @@ class StopEvaluationForGroupView(PermissionRequiredMixin, SingleObjectMixin, Vie
)
return redirect("manage_evaluation_process", group.registration.pk)
@method_decorator(never_cache, name="dispatch")
class CloseEvaluationForGroupView(PermissionRequiredMixin, SingleObjectMixin, View):
permission_required = "evalu.close_evaluation_for_group_rule"
model = EvaluationGroup
def get(self, request, *args, **kwargs):
group = self.get_object()
group.close()
messages.success(
request,
_("The evaluation for the group {} has been successfully locked.").format(
group.group_name
),
)
return redirect("evaluation_results", group.registration.pk)
class EvaluationsAsParticipantListView(PermissionRequiredMixin, ListView):
permission_required = "evalu.view_evaluations_as_participant_rule"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment