Make AssignmentList work for Berufsbildner
This commit is contained in:
parent
40ff65ad2d
commit
89152ce729
|
|
@ -439,28 +439,6 @@ export function useCourseDataWithCompletion(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCourseStatistics() {
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
|
|
||||||
const statistics = computed(() => {
|
|
||||||
return dashboardStore.currentDashBoardData as CourseStatisticsType;
|
|
||||||
});
|
|
||||||
|
|
||||||
const courseSessionName = (courseSessionId: string) => {
|
|
||||||
return statistics.value.course_session_properties.sessions.find(
|
|
||||||
(session) => session.id === courseSessionId
|
|
||||||
)?.name;
|
|
||||||
};
|
|
||||||
|
|
||||||
const circleMeta = (circleId: string) => {
|
|
||||||
return statistics.value.course_session_properties.circles.find(
|
|
||||||
(circle) => circle.id === circleId
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return { courseSessionName, circleMeta };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function useFileUpload() {
|
export function useFileUpload() {
|
||||||
const error = ref(false);
|
const error = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
|
||||||
|
|
@ -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 competence_certificate_title\n competence_certificate_id\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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 competence_certificate_title\n competence_certificate_id\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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!, $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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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 course_session_properties {\n _id\n sessions {\n id\n name\n }\n generations\n circles {\n id\n name\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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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!, $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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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 course_session_properties {\n _id\n sessions {\n id\n name\n }\n generations\n circles {\n id\n name\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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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 course_session_properties {\n _id\n sessions {\n id\n name\n }\n generations\n circles {\n id\n name\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 competence_certificate_id\n competence_certificate_title\n details_url\n deadline\n metrics {\n _id\n passed_count\n failed_count\n unranked_count\n ranking_completed\n average_evaluation_percent\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
|
|
@ -515,6 +515,18 @@ export const DASHBOARD_MENTOR_COMPETENCE_SUMMARY = graphql(`
|
||||||
course_slug
|
course_slug
|
||||||
course_session_selection_ids
|
course_session_selection_ids
|
||||||
user_selection_ids
|
user_selection_ids
|
||||||
|
course_session_properties {
|
||||||
|
_id
|
||||||
|
sessions {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
generations
|
||||||
|
circles {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
}
|
||||||
|
}
|
||||||
assignments {
|
assignments {
|
||||||
_id
|
_id
|
||||||
summary {
|
summary {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export function useExpertCockpitPageData(courseSlug: string) {
|
||||||
);
|
);
|
||||||
|
|
||||||
const userDataPromises = courseSessionDetailResult.filterMembers().map((m) => {
|
const userDataPromises = courseSessionDetailResult.filterMembers().map((m) => {
|
||||||
const completionData = useCourseDataWithCompletion(courseSlug, m.id);
|
const completionData = useCourseDataWithCompletion(courseSlug, m.user_id);
|
||||||
return completionData.resultPromise;
|
return completionData.resultPromise;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,61 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import log from "loglevel";
|
||||||
|
import { onMounted, ref } from "vue";
|
||||||
|
import {
|
||||||
|
courseIdForCourseSlug,
|
||||||
|
fetchMentorCompetenceSummary,
|
||||||
|
} from "@/services/dashboard";
|
||||||
|
import type { BaseStatisticsType } from "@/gql/graphql";
|
||||||
|
import { useDashboardStore } from "@/stores/dashboard";
|
||||||
import LoadingSpinner from "@/components/ui/LoadingSpinner.vue";
|
import LoadingSpinner from "@/components/ui/LoadingSpinner.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
import courseStatistics from "@/components/dashboard/CourseStatistics.vue";
|
||||||
|
import AssignmentList from "@/pages/dashboard/statistic/AssignmentList.vue";
|
||||||
|
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
agentRole: string;
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
log.debug("AgentStatisticParentPage created", props);
|
||||||
useCourseStatisticsv2(props.courseSlug);
|
|
||||||
|
const loading = ref(true);
|
||||||
|
const courseId = ref<string | undefined>(undefined);
|
||||||
|
const agentAssignmentData = ref<BaseStatisticsType | null>(null);
|
||||||
|
|
||||||
|
const courseSessionName = (courseSessionId: string) => {
|
||||||
|
return agentAssignmentData.value?.course_session_properties?.sessions.find(
|
||||||
|
(session) => session.id === courseSessionId
|
||||||
|
)?.name;
|
||||||
|
};
|
||||||
|
|
||||||
|
const circleMeta = (circleId: string) => {
|
||||||
|
return agentAssignmentData.value?.course_session_properties.circles.find(
|
||||||
|
(circle) => circle.id === circleId
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await dashboardStore.loadDashboardDetails();
|
||||||
|
courseId.value = courseIdForCourseSlug(
|
||||||
|
dashboardStore.dashboardConfigsv2,
|
||||||
|
props.courseSlug
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!courseId.value) {
|
||||||
|
log.error("CourseId not found for courseSlug", props.courseSlug);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("courseId", courseId.value);
|
||||||
|
agentAssignmentData.value = await fetchMentorCompetenceSummary(
|
||||||
|
courseId.value,
|
||||||
|
props.agentRole
|
||||||
|
);
|
||||||
|
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -20,11 +68,12 @@ const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
<it-icon-arrow-left />
|
<it-icon-arrow-left />
|
||||||
<span>{{ $t("general.back") }}</span>
|
<span>{{ $t("general.back") }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<router-view
|
<AssignmentList
|
||||||
:course-statistics="courseStatistics"
|
v-if="agentAssignmentData"
|
||||||
|
:course-statistics="agentAssignmentData"
|
||||||
:course-session-name="courseSessionName"
|
:course-session-name="courseSessionName"
|
||||||
:circle-meta="circleMeta"
|
:circle-meta="circleMeta"
|
||||||
></router-view>
|
></AssignmentList>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import type {
|
import type {
|
||||||
AssignmentCompletionMetricsType,
|
AssignmentCompletionMetricsType,
|
||||||
AssignmentStatisticsRecordType,
|
AssignmentStatisticsRecordType,
|
||||||
CourseStatisticsType,
|
BaseStatisticsType,
|
||||||
StatisticsCircleDataType,
|
StatisticsCircleDataType,
|
||||||
} from "@/gql/graphql";
|
} from "@/gql/graphql";
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
|
|
@ -16,7 +16,7 @@ import { useUserStore } from "@/stores/user";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseStatistics: CourseStatisticsType;
|
courseStatistics: BaseStatisticsType;
|
||||||
courseSessionName: (sessionId: string) => string;
|
courseSessionName: (sessionId: string) => string;
|
||||||
circleMeta: (circleId: string) => StatisticsCircleDataType;
|
circleMeta: (circleId: string) => StatisticsCircleDataType;
|
||||||
}>();
|
}>();
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,19 @@ const router = createRouter({
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/statistic/:agentRole/:courseSlug",
|
||||||
|
props: true,
|
||||||
|
component: () =>
|
||||||
|
import("@/pages/dashboard/statistic/AgentStatisticParentPage.vue"),
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "assignment",
|
||||||
|
props: true,
|
||||||
|
component: () => import("@/pages/dashboard/statistic/AssignmentList.vue"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/shop",
|
path: "/shop",
|
||||||
component: () => import("@/pages/ShopPage.vue"),
|
component: () => import("@/pages/ShopPage.vue"),
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,11 @@ import {
|
||||||
|
|
||||||
import { itGetCached, itPost } from "@/fetchHelpers";
|
import { itGetCached, itPost } from "@/fetchHelpers";
|
||||||
import type {
|
import type {
|
||||||
AssignmentsStatisticsType, BaseStatisticsType,
|
AssignmentsStatisticsType,
|
||||||
|
BaseStatisticsType,
|
||||||
CourseProgressType,
|
CourseProgressType,
|
||||||
CourseStatisticsType,
|
CourseStatisticsType,
|
||||||
DashboardConfigType
|
DashboardConfigType,
|
||||||
} from "@/gql/graphql";
|
} from "@/gql/graphql";
|
||||||
import type {
|
import type {
|
||||||
DashboardPersonsPageMode,
|
DashboardPersonsPageMode,
|
||||||
|
|
@ -152,12 +153,14 @@ export const fetchDashboardConfig = async (): Promise<DashboardConfigType[] | nu
|
||||||
|
|
||||||
export const fetchMentorCompetenceSummary = async (
|
export const fetchMentorCompetenceSummary = async (
|
||||||
courseId: string,
|
courseId: string,
|
||||||
roleKey: DashboardRoleKeyType
|
roleKey: string,
|
||||||
): Promise<BaseStatisticsType | null> => {
|
): Promise<BaseStatisticsType | null> => {
|
||||||
let agentRole = "";
|
let agentRole = "";
|
||||||
if (["MentorUK", "MentorVV"].includes(roleKey)) {
|
if (
|
||||||
|
["MentorUK".toLowerCase(), "MentorVV".toLowerCase()].includes(roleKey.toLowerCase())
|
||||||
|
) {
|
||||||
agentRole = "LEARNING_MENTOR";
|
agentRole = "LEARNING_MENTOR";
|
||||||
} else if (roleKey === "Berufsbildner") {
|
} else if (roleKey.toLowerCase() === "Berufsbildner".toLowerCase()) {
|
||||||
agentRole = "BERUFSBILDNER";
|
agentRole = "BERUFSBILDNER";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,9 @@ 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, agent_role: str): # noqa
|
def resolve_mentor_course_statistics(
|
||||||
|
root, info, course_id: str, agent_role: str
|
||||||
|
): # noqa
|
||||||
user = info.context.user
|
user = info.context.user
|
||||||
|
|
||||||
return _agent_course_statistics(user, course_id, role=agent_role)
|
return _agent_course_statistics(user, course_id, role=agent_role)
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,7 @@ class CourseStatisticsType(BaseStatisticsType):
|
||||||
records, success_total, fail_total = competences(
|
records, success_total, fail_total = competences(
|
||||||
course_slug=str(root.course_slug),
|
course_slug=str(root.course_slug),
|
||||||
course_session_selection_ids=[
|
course_session_selection_ids=[
|
||||||
str(cs)
|
str(cs) for cs in root.course_session_selection_ids # noqa
|
||||||
for cs in root.course_session_selection_ids # noqa
|
|
||||||
],
|
],
|
||||||
user_selection_ids=user_selection_ids, # noqa
|
user_selection_ids=user_selection_ids, # noqa
|
||||||
circle_ids=root.get_circle_ids(info), # noqa
|
circle_ids=root.get_circle_ids(info), # noqa
|
||||||
|
|
|
||||||
|
|
@ -515,7 +515,9 @@ def get_mentor_open_tasks_count(request, course_id: str):
|
||||||
return Response(
|
return Response(
|
||||||
status=200,
|
status=200,
|
||||||
data={
|
data={
|
||||||
"open_task_count": _get_mentor_open_tasks_count(course_id, request.user) # noqa
|
"open_task_count": _get_mentor_open_tasks_count(
|
||||||
|
course_id, request.user
|
||||||
|
) # noqa
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
except PermissionDenied as e:
|
except PermissionDenied as e:
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,11 @@ def is_course_session_learning_mentor(mentor: User, course_session_id: int):
|
||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
|
|
||||||
def is_learning_mentor_for_user(
|
def is_agent_for_user(
|
||||||
mentor: User, participant_user_id: str, course_session_id: int
|
agent: User,
|
||||||
|
participant_user_id: str,
|
||||||
|
course_session_id: int,
|
||||||
|
roles: list[str] = None,
|
||||||
):
|
):
|
||||||
csu = CourseSessionUser.objects.filter(
|
csu = CourseSessionUser.objects.filter(
|
||||||
course_session_id=course_session_id, user_id=participant_user_id
|
course_session_id=course_session_id, user_id=participant_user_id
|
||||||
|
|
@ -91,12 +94,30 @@ def is_learning_mentor_for_user(
|
||||||
if csu is None:
|
if csu is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return AgentParticipantRelation.objects.filter(
|
qs = AgentParticipantRelation.objects.filter(
|
||||||
agent=mentor,
|
agent=agent,
|
||||||
participant=csu,
|
participant=csu,
|
||||||
role=AgentParticipantRoleType.LEARNING_MENTOR.value,
|
role=AgentParticipantRoleType.LEARNING_MENTOR.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if roles and len(roles) > 0:
|
||||||
|
qs = qs.filter(role__in=roles)
|
||||||
|
|
||||||
|
return qs.exists()
|
||||||
|
|
||||||
|
|
||||||
|
def is_learning_mentor_for_user(
|
||||||
|
mentor: User, participant_user_id: str, course_session_id: int
|
||||||
|
):
|
||||||
|
return is_agent_for_user(
|
||||||
|
agent=mentor,
|
||||||
|
participant_user_id=participant_user_id,
|
||||||
|
course_session_id=course_session_id,
|
||||||
|
roles=[
|
||||||
|
AgentParticipantRoleType.LEARNING_MENTOR.value,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def is_course_session_supervisor(user, course_session_id: int):
|
def is_course_session_supervisor(user, course_session_id: int):
|
||||||
if user.is_superuser:
|
if user.is_superuser:
|
||||||
|
|
@ -268,8 +289,8 @@ def can_view_profile(user: User, profile_user: CourseSessionUser) -> bool:
|
||||||
|
|
||||||
if is_course_session_expert(
|
if is_course_session_expert(
|
||||||
user, profile_user.course_session.id
|
user, profile_user.course_session.id
|
||||||
) or is_learning_mentor_for_user(
|
) or is_agent_for_user(
|
||||||
mentor=user,
|
agent=user,
|
||||||
participant_user_id=profile_user.user.id,
|
participant_user_id=profile_user.user.id,
|
||||||
course_session_id=profile_user.course_session.id,
|
course_session_id=profile_user.course_session.id,
|
||||||
):
|
):
|
||||||
|
|
@ -284,8 +305,8 @@ def can_view_course_completions(
|
||||||
return (
|
return (
|
||||||
str(user.id) == target_user_id
|
str(user.id) == target_user_id
|
||||||
or is_course_session_expert(user=user, course_session_id=course_session_id)
|
or is_course_session_expert(user=user, course_session_id=course_session_id)
|
||||||
or is_learning_mentor_for_user(
|
or is_agent_for_user(
|
||||||
mentor=user,
|
agent=user,
|
||||||
participant_user_id=target_user_id,
|
participant_user_id=target_user_id,
|
||||||
course_session_id=course_session_id,
|
course_session_id=course_session_id,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue