Add profiles to courses

This commit is contained in:
Ramon Wenger 2024-07-08 14:30:06 +02:00 committed by Christian Cueni
parent 46ee6f9edd
commit 09570f18c2
4 changed files with 15 additions and 3 deletions

View File

@ -202,6 +202,7 @@ export interface Course {
title: string;
category_name: string;
slug: string;
filters: string[];
configuration: CourseConfiguration;
}

View File

@ -30,7 +30,7 @@ from vbv_lernwelt.course_session.models import (
from vbv_lernwelt.course_session_group.models import CourseSessionGroup
from vbv_lernwelt.iam.permissions import has_course_access
from vbv_lernwelt.learnpath.graphql.types import LearningPathObjectType
from vbv_lernwelt.learnpath.models import Circle
from vbv_lernwelt.learnpath.models import Circle, CourseProfile
logger = structlog.get_logger(__name__)
@ -106,6 +106,7 @@ class CourseObjectType(DjangoObjectType):
graphene.NonNull(ActionCompetenceObjectType), required=True
)
configuration = graphene.Field(CourseConfigurationObjectType, required=True)
filters = graphene.List(graphene.String)
class Meta:
model = Course
@ -125,6 +126,10 @@ class CourseObjectType(DjangoObjectType):
def resolve_action_competences(root: Course, info):
return root.get_action_competences()
@staticmethod
def resolve_filters(root: Course, info, **kwargs):
return CourseProfile.objects.all().values_list("code", flat=True)
class CourseSessionUserExpertCircleType(ObjectType):
id = graphene.ID(required=True)

View File

@ -8,6 +8,7 @@ from vbv_lernwelt.core.utils import find_first_index
from vbv_lernwelt.course.graphql.interfaces import CoursePageInterface
from vbv_lernwelt.learnpath.models import (
Circle,
CourseProfile,
LearningContentAssignment,
LearningContentAttendanceCourse,
LearningContentDocumentList,
@ -336,8 +337,9 @@ class CircleObjectType(DjangoObjectType):
]
def resolve_profiles(self, info, **kwargs):
choices = ["life", "nonlife", "sick"]
return [random.choice(choices)]
# choices = ["life", "nonlife", "sick"]
choices = CourseProfile.objects.all()
return [random.choice(choices).code]
class TopicObjectType(DjangoObjectType):

View File

@ -68,6 +68,10 @@ class Topic(CourseBasePage):
class CourseProfile(models.Model):
title = models.CharField(max_length=255)
code = models.CharField(max_length=255)
def __str__(self) -> str:
return self.title
class CourseProfileToCircle(models.Model):