Cleanup
This commit is contained in:
parent
ec4da1b265
commit
91940ab711
|
|
@ -25,3 +25,20 @@ class AssignmentCompletionAdmin(admin.ModelAdmin):
|
||||||
"course_session",
|
"course_session",
|
||||||
]
|
]
|
||||||
search_fields = ["assignment_user__email"]
|
search_fields = ["assignment_user__email"]
|
||||||
|
readonly_fields = [
|
||||||
|
"assignment_user",
|
||||||
|
"assignment",
|
||||||
|
"completion_data",
|
||||||
|
"course_session",
|
||||||
|
"learning_content_page",
|
||||||
|
"evaluation_points",
|
||||||
|
"submitted_at",
|
||||||
|
"evaluation_user",
|
||||||
|
"evaluation_submitted_at",
|
||||||
|
"evaluation_points_deducted_user",
|
||||||
|
]
|
||||||
|
|
||||||
|
def save_model(self, request, obj, form, change):
|
||||||
|
if change and "evaluation_points_deducted" in form.changed_data:
|
||||||
|
obj.evaluation_points_deducted_user = request.user
|
||||||
|
super().save_model(request, obj, form, change)
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,10 @@ class AssignmentCompletion(models.Model):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def evaluation_points_final(self):
|
def evaluation_points_final(self):
|
||||||
|
"""
|
||||||
|
Das ist das relevante Feld für die Punkteberechnung, es berücksichtigt
|
||||||
|
den Punkteabzug aus `evaluation_points_deducted`
|
||||||
|
"""
|
||||||
if self.evaluation_points is None:
|
if self.evaluation_points is None:
|
||||||
return None
|
return None
|
||||||
return self.evaluation_points - self.evaluation_points_deducted
|
return self.evaluation_points - self.evaluation_points_deducted
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,13 @@ def request_assignment_completion_status(request, assignment_id, course_session_
|
||||||
# Convert the learning_content_page_id to a string
|
# Convert the learning_content_page_id to a string
|
||||||
data = list(qs) # Evaluate the queryset
|
data = list(qs) # Evaluate the queryset
|
||||||
for item in data:
|
for item in data:
|
||||||
# only `evaluation_points_final` is relevant for the frontend
|
if item["evaluation_points"] is not None:
|
||||||
item["evaluation_points_final"] = (
|
# only `evaluation_points_final` is relevant for the frontend
|
||||||
item["evaluation_points"] - item["evaluation_points_deducted"]
|
item["evaluation_points_final"] = (
|
||||||
)
|
item["evaluation_points"] - item["evaluation_points_deducted"]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
item["evaluation_points_final"] = None
|
||||||
item["learning_content_page_id"] = str(item["learning_content_page_id"])
|
item["learning_content_page_id"] = str(item["learning_content_page_id"])
|
||||||
|
|
||||||
return Response(status=200, data=data)
|
return Response(status=200, data=data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue