Fix typecheck errors
This commit is contained in:
parent
e688cf2fc8
commit
313417dfd6
|
|
@ -4,7 +4,11 @@ import EvaluationContainer from "@/pages/cockpit/assignmentEvaluationPage/Evalua
|
|||
import AssignmentSubmissionResponses from "@/pages/learningPath/learningContentPage/assignment/AssignmentSubmissionResponses.vue";
|
||||
import { useAssignmentStore } from "@/stores/assignmentStore";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import { Assignment, CourseSessionAssignmentDetails, CourseSessionUser } from "@/types";
|
||||
import type {
|
||||
Assignment,
|
||||
CourseSessionAssignmentDetails,
|
||||
CourseSessionUser,
|
||||
} from "@/types";
|
||||
import log from "loglevel";
|
||||
import { computed, onMounted, reactive } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
|
|
@ -17,7 +21,7 @@ const props = defineProps<{
|
|||
|
||||
log.debug("AssignmentEvaluationPage created", props.assignmentId, props.userId);
|
||||
|
||||
export interface StateInterface {
|
||||
interface StateInterface {
|
||||
assignment: Assignment | undefined;
|
||||
courseSessionAssignmentDetails: CourseSessionAssignmentDetails | undefined;
|
||||
assignmentUser: CourseSessionUser | undefined;
|
||||
|
|
@ -38,7 +42,7 @@ onMounted(async () => {
|
|||
|
||||
if (courseSessionStore.currentCourseSession) {
|
||||
state.assignmentUser = courseSessionStore.currentCourseSession.users.find(
|
||||
(user) => user.user_id == props.userId
|
||||
(user) => user.user_id === Number(props.userId)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -46,7 +50,7 @@ onMounted(async () => {
|
|||
state.assignment = await assignmentStore.loadAssignment(props.assignmentId);
|
||||
await assignmentStore.loadAssignmentCompletion(
|
||||
props.assignmentId,
|
||||
courseSessionStore.currentCourseSession.id,
|
||||
courseSessionStore.currentCourseSession!.id,
|
||||
props.userId
|
||||
);
|
||||
} catch (error) {
|
||||
|
|
@ -65,7 +69,10 @@ const assignmentCompletion = computed(() => assignmentStore.assignmentCompletion
|
|||
|
||||
<template>
|
||||
<div class="absolute bottom-0 top-0 z-10 w-full bg-white">
|
||||
<div v-if="state.assignment && assignmentCompletion" class="relative">
|
||||
<div
|
||||
v-if="state.assignment && state.assignmentUser && assignmentCompletion"
|
||||
class="relative"
|
||||
>
|
||||
<header
|
||||
class="relative flex h-12 w-full items-center justify-between border-b border-b-gray-400 bg-white px-4 lg:h-16 lg:px-8"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ function findAssignmentDetail() {
|
|||
const userStore = useUserStore();
|
||||
// TODO: filter by selected circle
|
||||
if (!courseSessionStore.currentCourseSession) {
|
||||
return [];
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const learningContents = calcAssignmentLearningContents(
|
||||
|
|
@ -87,7 +87,7 @@ function findAssignmentDetail() {
|
|||
(lc) => lc.assignmentId === props.assignment.id
|
||||
);
|
||||
|
||||
return courseSessionStore.findAssignmentDetails(learningContent.id);
|
||||
return courseSessionStore.findAssignmentDetails(learningContent?.id);
|
||||
}
|
||||
|
||||
const assignmentDetail = computed(() => findAssignmentDetail());
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
import { useAssignmentStore } from "@/stores/assignmentStore";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import type { Assignment, CourseSessionUser } from "@/types";
|
||||
import { AssignmentCompletion } from "@/types";
|
||||
import type { Assignment, AssignmentCompletion, CourseSessionUser } from "@/types";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import * as log from "loglevel";
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@ import {
|
|||
} from "@/services/assignmentService";
|
||||
import { useAssignmentStore } from "@/stores/assignmentStore";
|
||||
import { useCourseSessionsStore } from "@/stores/courseSessions";
|
||||
import type { Assignment, AssignmentEvaluationTask, CourseSessionUser } from "@/types";
|
||||
import { AssignmentCompletion } from "@/types";
|
||||
import type {
|
||||
Assignment,
|
||||
AssignmentCompletion,
|
||||
AssignmentEvaluationTask,
|
||||
CourseSessionUser,
|
||||
} from "@/types";
|
||||
import dayjs, { Dayjs } from "dayjs";
|
||||
import * as log from "loglevel";
|
||||
import { computed, reactive } from "vue";
|
||||
|
|
@ -132,11 +136,13 @@ const grade = computed(() => pointsToGrade(userPoints.value, maxPoints.value));
|
|||
|
||||
<section class="mb-4">
|
||||
<div
|
||||
v-html="subTaskByPoints(task, evaluationForTask(task).points).title"
|
||||
v-html="subTaskByPoints(task, evaluationForTask(task).points)?.title"
|
||||
></div>
|
||||
<p
|
||||
class="default-wagtail-rich-text"
|
||||
v-html="subTaskByPoints(task, evaluationForTask(task).points).description"
|
||||
v-html="
|
||||
subTaskByPoints(task, evaluationForTask(task).points)?.description
|
||||
"
|
||||
></p>
|
||||
<div class="text-sm text-gray-800">
|
||||
{{ evaluationForTask(task).points }} Punkte
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<script setup lang="ts">
|
||||
import type { AssignmentCompletionData, AssignmentTask, UserDataText } from "@/types";
|
||||
import { Assignment } from "@/types";
|
||||
import type {
|
||||
Assignment,
|
||||
AssignmentCompletionData,
|
||||
AssignmentTask,
|
||||
UserDataText,
|
||||
} from "@/types";
|
||||
|
||||
const props = defineProps<{
|
||||
assignment: Assignment;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import type {
|
|||
AssignmentCompletionStatus,
|
||||
CourseSessionUser,
|
||||
LearningContent,
|
||||
UserAssignmentCompletionStatus,
|
||||
} from "@/types";
|
||||
import { sum } from "d3";
|
||||
import pick from "lodash/pick";
|
||||
|
|
@ -16,8 +17,10 @@ export interface AssignmentLearningContent extends LearningContent {
|
|||
assignmentId: number;
|
||||
}
|
||||
|
||||
export function calcAssignmentLearningContents(learningPath: LearningPath) {
|
||||
export function calcAssignmentLearningContents(learningPath?: LearningPath) {
|
||||
// TODO: filter by circle
|
||||
if (!learningPath) return [];
|
||||
|
||||
return learningPath.circles.flatMap((circle) => {
|
||||
const learningContents = circle.flatLearningContents.filter(
|
||||
(lc) => lc.contents[0].type === "assignment"
|
||||
|
|
@ -38,9 +41,9 @@ export async function loadAssignmentCompletionStatusData(
|
|||
) {
|
||||
const cockpitStore = useCockpitStore();
|
||||
|
||||
const assignmentCompletionData = await itGet(
|
||||
const assignmentCompletionData = (await itGet(
|
||||
`/api/assignment/${assignmentId}/${courseSessionId}/status/`
|
||||
);
|
||||
)) as UserAssignmentCompletionStatus[];
|
||||
|
||||
const courseSessionUsers = await cockpitStore.loadCourseSessionUsers(courseSessionId);
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ export async function loadAssignmentCompletionStatusData(
|
|||
|
||||
export function calcUserAssignmentCompletionStatus(
|
||||
courseSessionUsers: CourseSessionUser[],
|
||||
assignmentCompletionStatusData: any
|
||||
assignmentCompletionStatusData: UserAssignmentCompletionStatus[]
|
||||
) {
|
||||
return courseSessionUsers.map((u) => {
|
||||
let userStatus = "unknown" as AssignmentCompletionStatus;
|
||||
|
|
|
|||
|
|
@ -233,9 +233,9 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
|
|||
}
|
||||
|
||||
function findAssignmentDetails(
|
||||
contentId: number
|
||||
contentId?: number
|
||||
): CourseSessionAssignmentDetails | undefined {
|
||||
if (currentCourseSession.value) {
|
||||
if (contentId && currentCourseSession.value) {
|
||||
return currentCourseSession.value.assignment_details_list.find(
|
||||
(assignmentDetails) => assignmentDetails.learningContentId === contentId
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,3 +561,9 @@ export type EvaluationCompletionData = UpsertUserAssignmentCompletion & {
|
|||
evaluation_grade?: number;
|
||||
evaluation_points?: number;
|
||||
};
|
||||
|
||||
export interface UserAssignmentCompletionStatus {
|
||||
id: number;
|
||||
assignment_user_id: number;
|
||||
completion_status: AssignmentCompletionStatus;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue