diff --git a/server/vbv_lernwelt/assignment/models.py b/server/vbv_lernwelt/assignment/models.py index e82e8def..c485aab7 100644 --- a/server/vbv_lernwelt/assignment/models.py +++ b/server/vbv_lernwelt/assignment/models.py @@ -127,6 +127,12 @@ class Assignment(CourseBasePage): "evaluation_tasks", ] + def get_admin_display_title(self): + circle_title = self.get_attached_circle_title() + if circle_title: + return f"{circle_title}: {self.title}" + return self.title + assignment_type = models.CharField( max_length=50, choices=[(tag.value, tag.value) for tag in AssignmentType], @@ -271,6 +277,16 @@ class Assignment(CourseBasePage): return lp.get_frontend_url() return "" + def get_attached_circle_title(self): + if self.learningcontentassignment_set.count() > 1: + # probably "Reflexion" which is attached to multiple circles + return "" + + lp = self.find_attached_learning_content() + if lp and lp.get_parent_circle(): + return lp.get_parent_circle().title + return "" + class AssignmentCompletionStatus(Enum): IN_PROGRESS = "IN_PROGRESS" diff --git a/server/vbv_lernwelt/learnpath/models.py b/server/vbv_lernwelt/learnpath/models.py index d6a77c50..b0a60b7c 100644 --- a/server/vbv_lernwelt/learnpath/models.py +++ b/server/vbv_lernwelt/learnpath/models.py @@ -277,6 +277,14 @@ class LearningContent(CourseBasePage): return "ERROR: could not parse slug" return f"/course/{m.group('coursePart')}/learn/{m.group('circlePart')}/{m.group('lcPart')}" + def get_parent_circle(self): + try: + return self.get_ancestors().exact_type(Circle).first() + except Exception: + # noop + pass + return None + def save(self, clean=True, user=None, log_action=False, **kwargs): self.slug = find_slug_with_parent_prefix(self, "lc") super().save(**kwargs)