Show (wrong) competence dashboard widget for `BERUFSBILDNER`
This commit is contained in:
parent
b6590c0b86
commit
1f79693e59
|
|
@ -167,6 +167,7 @@ function hasActionButton(): boolean {
|
||||||
<MentorCompetenceSummary
|
<MentorCompetenceSummary
|
||||||
v-if="hasWidget('MentorCompetenceWidget')"
|
v-if="hasWidget('MentorCompetenceWidget')"
|
||||||
:course-id="courseConfig.course_id"
|
:course-id="courseConfig.course_id"
|
||||||
|
:agent-role="courseConfig.role_key"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,22 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import { onMounted, ref } from "vue";
|
import { onMounted, ref } from "vue";
|
||||||
import { fetchMentorCompetenceSummary } from "@/services/dashboard";
|
import {
|
||||||
|
type DashboardRoleKeyType,
|
||||||
|
fetchMentorCompetenceSummary,
|
||||||
|
} from "@/services/dashboard";
|
||||||
import type { AssignmentsStatisticsType } from "@/gql/graphql";
|
import type { AssignmentsStatisticsType } from "@/gql/graphql";
|
||||||
import BaseBox from "@/components/dashboard/BaseBox.vue";
|
import BaseBox from "@/components/dashboard/BaseBox.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseId: string;
|
courseId: string;
|
||||||
|
agentRole: DashboardRoleKeyType;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const summary: Ref<AssignmentsStatisticsType | null> = ref(null);
|
const summary: Ref<AssignmentsStatisticsType | null> = ref(null);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
summary.value = await fetchMentorCompetenceSummary(props.courseId);
|
summary.value = await fetchMentorCompetenceSummary(props.courseId, props.agentRole);
|
||||||
console.log(summary.value);
|
console.log(summary.value);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ const documents = {
|
||||||
"\n query dashboardProgress($courseId: ID!) {\n course_progress(course_id: $courseId) {\n _id\n course_id\n session_to_continue_id\n competence {\n _id\n total_count\n success_count\n fail_count\n }\n assignment {\n _id\n total_count\n points_max_count\n points_achieved_count\n }\n }\n }\n": types.DashboardProgressDocument,
|
"\n query dashboardProgress($courseId: ID!) {\n course_progress(course_id: $courseId) {\n _id\n course_id\n session_to_continue_id\n competence {\n _id\n total_count\n success_count\n fail_count\n }\n assignment {\n _id\n total_count\n points_max_count\n points_achieved_count\n }\n }\n }\n": types.DashboardProgressDocument,
|
||||||
"\n query dashboardCourseData($courseId: ID!) {\n course_progress(course_id: $courseId) {\n _id\n course_id\n session_to_continue_id\n }\n }\n": types.DashboardCourseDataDocument,
|
"\n query dashboardCourseData($courseId: ID!) {\n course_progress(course_id: $courseId) {\n _id\n course_id\n session_to_continue_id\n }\n }\n": types.DashboardCourseDataDocument,
|
||||||
"\n query courseStatistics($courseId: ID!) {\n course_statistics(course_id: $courseId) {\n _id\n course_id\n course_title\n course_slug\n course_session_properties {\n _id\n sessions {\n id\n name\n }\n generations\n circles {\n id\n name\n }\n }\n course_session_selection_ids\n course_session_selection_metrics {\n _id\n session_count\n participant_count\n expert_count\n }\n attendance_day_presences {\n _id\n records {\n _id\n course_session_id\n generation\n circle_id\n due_date\n participants_present\n participants_total\n details_url\n }\n summary {\n _id\n days_completed\n participants_present\n }\n }\n feedback_responses {\n _id\n records {\n _id\n course_session_id\n generation\n circle_id\n experts\n satisfaction_average\n satisfaction_max\n details_url\n }\n summary {\n _id\n satisfaction_average\n satisfaction_max\n total_responses\n }\n }\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n competences {\n _id\n summary {\n _id\n success_total\n fail_total\n }\n records {\n _id\n course_session_id\n generation\n circle_id\n title\n success_count\n fail_count\n details_url\n }\n }\n }\n }\n": types.CourseStatisticsDocument,
|
"\n query courseStatistics($courseId: ID!) {\n course_statistics(course_id: $courseId) {\n _id\n course_id\n course_title\n course_slug\n course_session_properties {\n _id\n sessions {\n id\n name\n }\n generations\n circles {\n id\n name\n }\n }\n course_session_selection_ids\n course_session_selection_metrics {\n _id\n session_count\n participant_count\n expert_count\n }\n attendance_day_presences {\n _id\n records {\n _id\n course_session_id\n generation\n circle_id\n due_date\n participants_present\n participants_total\n details_url\n }\n summary {\n _id\n days_completed\n participants_present\n }\n }\n feedback_responses {\n _id\n records {\n _id\n course_session_id\n generation\n circle_id\n experts\n satisfaction_average\n satisfaction_max\n details_url\n }\n summary {\n _id\n satisfaction_average\n satisfaction_max\n total_responses\n }\n }\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n competences {\n _id\n summary {\n _id\n success_total\n fail_total\n }\n records {\n _id\n course_session_id\n generation\n circle_id\n title\n success_count\n fail_count\n details_url\n }\n }\n }\n }\n": types.CourseStatisticsDocument,
|
||||||
"\n query mentorCourseStatistics($courseId: ID!) {\n mentor_course_statistics(course_id: $courseId) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n": types.MentorCourseStatisticsDocument,
|
"\n query mentorCourseStatistics($courseId: ID!, $agentRole: String!) {\n mentor_course_statistics(course_id: $courseId, agent_role: $agentRole) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n": types.MentorCourseStatisticsDocument,
|
||||||
"\n mutation SendFeedbackMutation(\n $courseSessionId: ID!\n $learningContentId: ID!\n $learningContentType: String!\n $data: GenericScalar!\n $submitted: Boolean\n ) {\n send_feedback(\n course_session_id: $courseSessionId\n learning_content_page_id: $learningContentId\n learning_content_type: $learningContentType\n data: $data\n submitted: $submitted\n ) {\n feedback_response {\n id\n data\n submitted\n }\n errors {\n field\n messages\n }\n }\n }\n": types.SendFeedbackMutationDocument,
|
"\n mutation SendFeedbackMutation(\n $courseSessionId: ID!\n $learningContentId: ID!\n $learningContentType: String!\n $data: GenericScalar!\n $submitted: Boolean\n ) {\n send_feedback(\n course_session_id: $courseSessionId\n learning_content_page_id: $learningContentId\n learning_content_type: $learningContentType\n data: $data\n submitted: $submitted\n ) {\n feedback_response {\n id\n data\n submitted\n }\n errors {\n field\n messages\n }\n }\n }\n": types.SendFeedbackMutationDocument,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ export function graphql(source: "\n query courseStatistics($courseId: ID!) {\n
|
||||||
/**
|
/**
|
||||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||||
*/
|
*/
|
||||||
export function graphql(source: "\n query mentorCourseStatistics($courseId: ID!) {\n mentor_course_statistics(course_id: $courseId) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query mentorCourseStatistics($courseId: ID!) {\n mentor_course_statistics(course_id: $courseId) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n"];
|
export function graphql(source: "\n query mentorCourseStatistics($courseId: ID!, $agentRole: String!) {\n mentor_course_statistics(course_id: $courseId, agent_role: $agentRole) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n"): (typeof documents)["\n query mentorCourseStatistics($courseId: ID!, $agentRole: String!) {\n mentor_course_statistics(course_id: $courseId, agent_role: $agentRole) {\n _id\n course_id\n course_title\n course_slug\n course_session_selection_ids\n user_selection_ids\n assignments {\n _id\n summary {\n _id\n completed_count\n average_passed\n total_passed\n total_failed\n }\n records {\n _id\n course_session_id\n course_session_assignment_id\n circle_id\n generation\n assignment_title\n assignment_type_translation_key\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_passed\n }\n }\n }\n }\n }\n"];
|
||||||
/**
|
/**
|
||||||
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -1,6 +1,6 @@
|
||||||
type Query {
|
type Query {
|
||||||
course_statistics(course_id: ID!): CourseStatisticsType
|
course_statistics(course_id: ID!): CourseStatisticsType
|
||||||
mentor_course_statistics(course_id: ID!): BaseStatisticsType
|
mentor_course_statistics(course_id: ID!, agent_role: String!): BaseStatisticsType
|
||||||
course_progress(course_id: ID!): CourseProgressType
|
course_progress(course_id: ID!): CourseProgressType
|
||||||
dashboard_config: [DashboardConfigType!]!
|
dashboard_config: [DashboardConfigType!]!
|
||||||
learning_path(id: ID, slug: String, course_id: ID, course_slug: String): LearningPathObjectType
|
learning_path(id: ID, slug: String, course_id: ID, course_slug: String): LearningPathObjectType
|
||||||
|
|
|
||||||
|
|
@ -504,8 +504,8 @@ export const DASHBOARD_COURSE_STATISTICS = graphql(`
|
||||||
`);
|
`);
|
||||||
|
|
||||||
export const DASHBOARD_MENTOR_COMPETENCE_SUMMARY = graphql(`
|
export const DASHBOARD_MENTOR_COMPETENCE_SUMMARY = graphql(`
|
||||||
query mentorCourseStatistics($courseId: ID!) {
|
query mentorCourseStatistics($courseId: ID!, $agentRole: String!) {
|
||||||
mentor_course_statistics(course_id: $courseId) {
|
mentor_course_statistics(course_id: $courseId, agent_role: $agentRole) {
|
||||||
_id
|
_id
|
||||||
course_id
|
course_id
|
||||||
course_title
|
course_title
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,8 @@ export type DashboardRoleKeyType =
|
||||||
| "Trainer"
|
| "Trainer"
|
||||||
| "Member"
|
| "Member"
|
||||||
| "MentorUK"
|
| "MentorUK"
|
||||||
| "MentorVV";
|
| "MentorVV"
|
||||||
|
| "Berufsbildner";
|
||||||
|
|
||||||
export type WidgetType =
|
export type WidgetType =
|
||||||
| "ProgressWidget"
|
| "ProgressWidget"
|
||||||
|
|
@ -149,11 +150,25 @@ export const fetchDashboardConfig = async (): Promise<DashboardConfigType[] | nu
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchMentorCompetenceSummary = async (
|
export const fetchMentorCompetenceSummary = async (
|
||||||
courseId: string
|
courseId: string,
|
||||||
|
roleKey: DashboardRoleKeyType
|
||||||
): Promise<AssignmentsStatisticsType | null> => {
|
): Promise<AssignmentsStatisticsType | null> => {
|
||||||
|
let agentRole = "";
|
||||||
|
if (["MentorUK", "MentorVV"].includes(roleKey)) {
|
||||||
|
agentRole = "LEARNING_MENTOR";
|
||||||
|
} else if (roleKey === "Berufsbildner") {
|
||||||
|
agentRole = "BERUFSBILDNER";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!agentRole) {
|
||||||
|
console.error(`Invalid role key for competence summary: ${roleKey}`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await graphqlClient.query(DASHBOARD_MENTOR_COMPETENCE_SUMMARY, {
|
const res = await graphqlClient.query(DASHBOARD_MENTOR_COMPETENCE_SUMMARY, {
|
||||||
courseId,
|
courseId,
|
||||||
|
agentRole,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
|
|
|
||||||
|
|
@ -32,13 +32,41 @@ from vbv_lernwelt.learning_mentor.models import (
|
||||||
from vbv_lernwelt.learnpath.models import Circle
|
from vbv_lernwelt.learnpath.models import Circle
|
||||||
|
|
||||||
|
|
||||||
|
def _agent_course_statistics(user, course_id: str, role: str):
|
||||||
|
course = Course.objects.get(id=course_id)
|
||||||
|
|
||||||
|
participant_ids = set()
|
||||||
|
course_session_ids = set()
|
||||||
|
|
||||||
|
relations_qs = AgentParticipantRelation.objects.filter(
|
||||||
|
agent=user,
|
||||||
|
role=role,
|
||||||
|
participant__course_session__course=course,
|
||||||
|
)
|
||||||
|
|
||||||
|
for relation in relations_qs:
|
||||||
|
participant_ids.add(relation.participant.user_id)
|
||||||
|
course_session_ids.add(relation.participant.course_session_id)
|
||||||
|
|
||||||
|
return CourseStatisticsType(
|
||||||
|
_id=f"{role}:{course.id}", # noqa
|
||||||
|
course_id=course.id, # noqa
|
||||||
|
course_title=course.title, # noqa
|
||||||
|
course_slug=course.slug, # noqa
|
||||||
|
course_session_selection_ids=list(course_session_ids), # noqa
|
||||||
|
user_selection_ids=list(participant_ids), # noqa
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class DashboardQuery(graphene.ObjectType):
|
class DashboardQuery(graphene.ObjectType):
|
||||||
course_statistics = graphene.Field(
|
course_statistics = graphene.Field(
|
||||||
CourseStatisticsType, course_id=graphene.ID(required=True)
|
CourseStatisticsType, course_id=graphene.ID(required=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
mentor_course_statistics = graphene.Field(
|
mentor_course_statistics = graphene.Field(
|
||||||
BaseStatisticsType, course_id=graphene.ID(required=True)
|
BaseStatisticsType,
|
||||||
|
course_id=graphene.ID(required=True),
|
||||||
|
agent_role=graphene.String(required=True),
|
||||||
)
|
)
|
||||||
|
|
||||||
course_progress = graphene.Field(
|
course_progress = graphene.Field(
|
||||||
|
|
@ -91,31 +119,10 @@ class DashboardQuery(graphene.ObjectType):
|
||||||
course_session_selection_ids=list(course_session_ids), # noqa
|
course_session_selection_ids=list(course_session_ids), # noqa
|
||||||
)
|
)
|
||||||
|
|
||||||
def resolve_mentor_course_statistics(root, info, course_id: str): # noqa
|
def resolve_mentor_course_statistics(root, info, course_id: str, agent_role: str): # noqa
|
||||||
user = info.context.user
|
user = info.context.user
|
||||||
course = Course.objects.get(id=course_id)
|
|
||||||
|
|
||||||
mentees_ids = set()
|
return _agent_course_statistics(user, course_id, role=agent_role)
|
||||||
course_session_ids = set()
|
|
||||||
|
|
||||||
relations_qs = AgentParticipantRelation.objects.filter(
|
|
||||||
agent=user,
|
|
||||||
role=AgentParticipantRoleType.LEARNING_MENTOR.value,
|
|
||||||
participant__course_session__course=course,
|
|
||||||
)
|
|
||||||
|
|
||||||
for relation in relations_qs:
|
|
||||||
mentees_ids.add(relation.participant.user_id)
|
|
||||||
course_session_ids.add(relation.participant.course_session_id)
|
|
||||||
|
|
||||||
return CourseStatisticsType(
|
|
||||||
_id=f"mentor:{course.id}", # noqa
|
|
||||||
course_id=course.id, # noqa
|
|
||||||
course_title=course.title, # noqa
|
|
||||||
course_slug=course.slug, # noqa
|
|
||||||
course_session_selection_ids=list(course_session_ids), # noqa
|
|
||||||
user_selection_ids=list(mentees_ids), # noqa
|
|
||||||
)
|
|
||||||
|
|
||||||
def resolve_dashboard_config(root, info): # noqa
|
def resolve_dashboard_config(root, info): # noqa
|
||||||
user = info.context.user
|
user = info.context.user
|
||||||
|
|
|
||||||
|
|
@ -378,6 +378,9 @@ def get_widgets_for_course(
|
||||||
if is_vv:
|
if is_vv:
|
||||||
widgets.append(WidgetType.MENTOR_TASKS_WIDGET.value)
|
widgets.append(WidgetType.MENTOR_TASKS_WIDGET.value)
|
||||||
|
|
||||||
|
if role_key in [RoleKeyType.BERUFSBILDNER]:
|
||||||
|
widgets.append(WidgetType.MENTOR_COMPETENCE_WIDGET.value)
|
||||||
|
|
||||||
return widgets
|
return widgets
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue