Display chosen profile on user profile page
This commit is contained in:
parent
d22a7c296f
commit
59c695b838
|
|
@ -267,7 +267,8 @@ type CourseObjectType {
|
||||||
learning_path: LearningPathObjectType!
|
learning_path: LearningPathObjectType!
|
||||||
action_competences: [ActionCompetenceObjectType!]!
|
action_competences: [ActionCompetenceObjectType!]!
|
||||||
profiles: [String]
|
profiles: [String]
|
||||||
course_session_users: [CourseSessionUserType]!
|
course_session_users(id: String): [CourseSessionUserType]!
|
||||||
|
chosen_profile(user: String!): String
|
||||||
}
|
}
|
||||||
|
|
||||||
type ActionCompetenceObjectType implements CoursePageInterface {
|
type ActionCompetenceObjectType implements CoursePageInterface {
|
||||||
|
|
|
||||||
|
|
@ -264,14 +264,14 @@ export const COURSE_SESSION_DETAIL_QUERY = graphql(`
|
||||||
`);
|
`);
|
||||||
|
|
||||||
export const COURSE_QUERY = graphql(`
|
export const COURSE_QUERY = graphql(`
|
||||||
query courseQuery($slug: String!) {
|
query courseQuery($slug: String!, $user: String) {
|
||||||
course(slug: $slug) {
|
course(slug: $slug) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
slug
|
slug
|
||||||
category_name
|
category_name
|
||||||
profiles
|
profiles
|
||||||
course_session_users {
|
course_session_users(id: $user) {
|
||||||
id
|
id
|
||||||
__typename
|
__typename
|
||||||
chosen_profile
|
chosen_profile
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import { useCourseDataWithCompletion } from "@/composables";
|
||||||
import UserProfileContent from "@/components/userProfile/UserProfileContent.vue";
|
import UserProfileContent from "@/components/userProfile/UserProfileContent.vue";
|
||||||
import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue";
|
import LearningPathCircle from "@/pages/learningPath/learningPathPage/LearningPathCircle.vue";
|
||||||
import LearningSequence from "@/pages/learningPath/circlePage/LearningSequence.vue";
|
import LearningSequence from "@/pages/learningPath/circlePage/LearningSequence.vue";
|
||||||
import { ref, watch } from "vue";
|
import { computed, ref, watch } from "vue";
|
||||||
import type { CircleType } from "@/types";
|
import type { CircleType } from "@/types";
|
||||||
|
import { COURSE_QUERY } from "@/graphql/queries";
|
||||||
|
import { useQuery } from "@urql/vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
userId: string;
|
userId: string;
|
||||||
|
|
@ -20,6 +22,23 @@ function selectCircle(circle: CircleType) {
|
||||||
selectedCircle.value = circle;
|
selectedCircle.value = circle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const courseReactiveResult = useQuery({
|
||||||
|
query: COURSE_QUERY,
|
||||||
|
variables: { slug: props.courseSlug, user: props.userId },
|
||||||
|
});
|
||||||
|
|
||||||
|
const courseReactive = computed(() => courseReactiveResult.data.value?.course);
|
||||||
|
const courseSessionUsers = computed(() => {
|
||||||
|
return courseReactive.value?.course_session_users;
|
||||||
|
});
|
||||||
|
|
||||||
|
const chosenProfile = computed(() => {
|
||||||
|
if (courseSessionUsers.value && courseSessionUsers.value.length > 0) {
|
||||||
|
return courseSessionUsers.value[0]?.chosen_profile;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
watch(lpQueryResult.learningPath, () => {
|
watch(lpQueryResult.learningPath, () => {
|
||||||
if (lpQueryResult.learningPath?.value?.topics?.length) {
|
if (lpQueryResult.learningPath?.value?.topics?.length) {
|
||||||
selectCircle(lpQueryResult.learningPath.value.topics[0].circles[0]);
|
selectCircle(lpQueryResult.learningPath.value.topics[0].circles[0]);
|
||||||
|
|
@ -30,6 +49,13 @@ watch(lpQueryResult.learningPath, () => {
|
||||||
<template>
|
<template>
|
||||||
<UserProfileContent>
|
<UserProfileContent>
|
||||||
<template #side>
|
<template #side>
|
||||||
|
<div v-if="chosenProfile">
|
||||||
|
<h3 class="mb-4 text-base font-bold">
|
||||||
|
Zulassungsprofil:
|
||||||
|
<br />
|
||||||
|
{{ $t(`profile.${chosenProfile}`) }}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="topic in lpQueryResult.learningPath?.value?.topics ?? []"
|
v-for="topic in lpQueryResult.learningPath?.value?.topics ?? []"
|
||||||
:key="topic.id"
|
:key="topic.id"
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ from graphql import GraphQLError
|
||||||
from rest_framework.exceptions import PermissionDenied
|
from rest_framework.exceptions import PermissionDenied
|
||||||
|
|
||||||
from vbv_lernwelt.competence.graphql.types import ActionCompetenceObjectType
|
from vbv_lernwelt.competence.graphql.types import ActionCompetenceObjectType
|
||||||
|
from vbv_lernwelt.core.models import User
|
||||||
from vbv_lernwelt.course.models import (
|
from vbv_lernwelt.course.models import (
|
||||||
CircleDocument,
|
CircleDocument,
|
||||||
Course,
|
Course,
|
||||||
|
|
@ -108,7 +109,9 @@ class CourseObjectType(DjangoObjectType):
|
||||||
configuration = graphene.Field(CourseConfigurationObjectType, required=True)
|
configuration = graphene.Field(CourseConfigurationObjectType, required=True)
|
||||||
profiles = graphene.List(graphene.String)
|
profiles = graphene.List(graphene.String)
|
||||||
course_session_users = graphene.List(
|
course_session_users = graphene.List(
|
||||||
"vbv_lernwelt.course.graphql.types.CourseSessionUserType", required=True
|
"vbv_lernwelt.course.graphql.types.CourseSessionUserType",
|
||||||
|
required=True,
|
||||||
|
id=graphene.String(),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
@ -134,8 +137,12 @@ class CourseObjectType(DjangoObjectType):
|
||||||
return CourseProfile.objects.all().values_list("code", flat=True)
|
return CourseProfile.objects.all().values_list("code", flat=True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_course_session_users(root: Course, info, **kwargs):
|
def resolve_course_session_users(root: Course, info, id=None, **kwargs):
|
||||||
user = info.context.user
|
# todo: restrict users that can be queried
|
||||||
|
if id is not None:
|
||||||
|
user = User.objects.get(id=id)
|
||||||
|
else:
|
||||||
|
user = info.context.user
|
||||||
users = CourseSessionUser.objects.filter(user=user, course_session__course=root)
|
users = CourseSessionUser.objects.filter(user=user, course_session__course=root)
|
||||||
return users
|
return users
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue