Add linking to `evaluate_url` for learning unit
This commit is contained in:
parent
ebfeec4184
commit
3c386f31ca
|
|
@ -37,7 +37,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|||
</div>
|
||||
</div>
|
||||
<span class="whitespace-nowrap">
|
||||
<a class="link" :href="criteria.learning_unit.frontend_url">
|
||||
<a class="link" :href="criteria.learning_unit.evaluate_url">
|
||||
Sich nochmals einschätzen
|
||||
</a>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ export const useCircleStore = defineStore({
|
|||
},
|
||||
openSelfEvaluation(learningUnit: LearningUnit) {
|
||||
this.router.push({
|
||||
path: learningUnit.frontend_url,
|
||||
path: learningUnit.evaluate_url,
|
||||
});
|
||||
},
|
||||
closeSelfEvaluation(learningUnit: LearningUnit) {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ export interface LearningUnitPerformanceCriteria extends CourseWagtailPage {
|
|||
export interface LearningUnit extends CourseWagtailPage {
|
||||
type: "learnpath.LearningUnit";
|
||||
learningContents: LearningContent[];
|
||||
evaluate_url: string;
|
||||
minutes: number;
|
||||
parentLearningSequence?: LearningSequence;
|
||||
parentCircle?: Circle;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ from rest_framework import serializers
|
|||
|
||||
from vbv_lernwelt.competence.models import PerformanceCriteria
|
||||
from vbv_lernwelt.course.serializers import CourseCategorySerializer
|
||||
from vbv_lernwelt.learnpath.models import LearningUnit
|
||||
from vbv_lernwelt.learnpath.serializer_helpers import get_it_serializer_class
|
||||
|
||||
|
||||
|
|
@ -27,17 +26,11 @@ class PerformanceCriteriaSerializer(
|
|||
course_category = serializers.SerializerMethodField()
|
||||
|
||||
def get_learning_unit(self, obj):
|
||||
learning_unit_serializer = get_it_serializer_class(
|
||||
LearningUnit,
|
||||
[
|
||||
"id",
|
||||
"title",
|
||||
"slug",
|
||||
"type",
|
||||
"translation_key",
|
||||
],
|
||||
from vbv_lernwelt.learnpath.serializers import (
|
||||
LearningUnitPerformanceCriteriaSerializer,
|
||||
)
|
||||
return learning_unit_serializer(obj.learning_unit).data
|
||||
|
||||
return LearningUnitPerformanceCriteriaSerializer(obj.learning_unit).data
|
||||
|
||||
def get_circle(self, obj):
|
||||
return obj.learning_unit.get_parent().specific.title
|
||||
|
|
|
|||
|
|
@ -250,6 +250,10 @@ class LearningUnit(Page):
|
|||
super(LearningUnit, self).full_clean(*args, **kwargs)
|
||||
|
||||
def get_frontend_url(self):
|
||||
short_slug = self.slug.replace(f"{self.get_parent().slug}-lu-", "")
|
||||
return f"{self.get_parent().specific.get_frontend_url()}#lu-{short_slug}"
|
||||
|
||||
def get_evaluate_url(self):
|
||||
short_slug = self.slug.replace(f"{self.get_parent().slug}-lu-", "")
|
||||
return f"{self.get_parent().specific.get_frontend_url()}/evaluate/{short_slug}"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from rest_framework.fields import SerializerMethodField
|
||||
|
||||
from vbv_lernwelt.competence.serializers import (
|
||||
PerformanceCriteriaLearningPathSerializer,
|
||||
)
|
||||
|
|
@ -9,13 +11,34 @@ class LearningUnitSerializer(
|
|||
get_it_serializer_class(
|
||||
LearningUnit,
|
||||
[
|
||||
"evaluate_url",
|
||||
"course_category",
|
||||
"children",
|
||||
],
|
||||
)
|
||||
):
|
||||
evaluate_url = SerializerMethodField()
|
||||
|
||||
def get_children(self, obj):
|
||||
return [
|
||||
PerformanceCriteriaLearningPathSerializer(child).data
|
||||
for child in obj.performancecriteria_set.all()
|
||||
]
|
||||
|
||||
def get_evaluate_url(self, obj):
|
||||
return obj.get_evaluate_url()
|
||||
|
||||
|
||||
class LearningUnitPerformanceCriteriaSerializer(
|
||||
get_it_serializer_class(
|
||||
LearningUnit,
|
||||
[
|
||||
"evaluate_url",
|
||||
"course_category",
|
||||
],
|
||||
)
|
||||
):
|
||||
evaluate_url = SerializerMethodField()
|
||||
|
||||
def get_evaluate_url(self, obj):
|
||||
return obj.get_evaluate_url()
|
||||
|
|
|
|||
Loading…
Reference in New Issue