Change types to use UUID ids

This commit is contained in:
Daniel Egger 2023-07-14 14:55:45 +02:00
parent 5ed883e83b
commit f25602c84c
18 changed files with 42 additions and 57 deletions

View File

@ -19,9 +19,7 @@ onMounted(async () => {
}); });
const user = computed(() => { const user = computed(() => {
return cockpitStore.courseSessionUsers?.find( return cockpitStore.courseSessionUsers?.find((csu) => csu.user_id === props.userId);
(csu) => csu.user_id === Number(props.userId)
);
}); });
</script> </script>

View File

@ -28,9 +28,7 @@ const learningPath = computed(() => {
}); });
const user = computed(() => { const user = computed(() => {
return cockpitStore.courseSessionUsers?.find( return cockpitStore.courseSessionUsers?.find((csu) => csu.user_id === props.userId);
(csu) => csu.user_id === Number(props.userId)
);
}); });
function setActiveClasses(isActive: boolean) { function setActiveClasses(isActive: boolean) {

View File

@ -49,7 +49,7 @@ onMounted(async () => {
log.debug("AssignmentView mounted", props.assignmentId, props.userId); log.debug("AssignmentView mounted", props.assignmentId, props.userId);
state.assignmentUser = courseSession.value.users.find( state.assignmentUser = courseSession.value.users.find(
(user) => user.user_id === Number(props.userId) (user) => user.user_id === props.userId
); );
}); });

View File

@ -88,7 +88,7 @@ const grade = computed(() => {
const evaluationUser = computed(() => { const evaluationUser = computed(() => {
if (props.assignmentCompletion.evaluation_user) { if (props.assignmentCompletion.evaluation_user) {
return (courseSession.value.users ?? []).find( return (courseSession.value.users ?? []).find(
(user) => user.user_id === Number(props.assignmentCompletion.evaluation_user) (user) => user.user_id === props.assignmentCompletion.evaluation_user
) as CourseSessionUser; ) as CourseSessionUser;
} }

View File

@ -32,7 +32,7 @@ const state = reactive({
statusByUser: [] as { statusByUser: [] as {
userStatus: AssignmentCompletionStatus; userStatus: AssignmentCompletionStatus;
progressStatus: StatusCountKey; progressStatus: StatusCountKey;
userId: number; userId: string;
grade: number | null; grade: number | null;
}[], }[],
progressStatusCount: {} as StatusCount, progressStatusCount: {} as StatusCount,
@ -45,7 +45,7 @@ onMounted(async () => {
); );
}); });
function submissionStatusForUser(userId: number) { function submissionStatusForUser(userId: string) {
return state.statusByUser.find((s) => s.userId === userId); return state.statusByUser.find((s) => s.userId === userId);
} }

View File

@ -26,7 +26,7 @@ const state = reactive({
statusByUser: [] as { statusByUser: [] as {
userStatus: AssignmentCompletionStatus; userStatus: AssignmentCompletionStatus;
progressStatus: StatusCountKey; progressStatus: StatusCountKey;
userId: number; userId: string;
}[], }[],
progressStatusCount: {} as StatusCount, progressStatusCount: {} as StatusCount,
}); });

View File

@ -26,7 +26,7 @@ const competenceStore = useCompetenceStore();
const learningPathStore = useLearningPathStore(); const learningPathStore = useLearningPathStore();
const courseSession = useCurrentCourseSession(); const courseSession = useCurrentCourseSession();
function userCountStatusForCircle(userId: number, translationKey: string) { function userCountStatusForCircle(userId: string, translationKey: string) {
const criteria = competenceStore.flatPerformanceCriteria( const criteria = competenceStore.flatPerformanceCriteria(
userId, userId,
cockpitStore.selectedCircles cockpitStore.selectedCircles

View File

@ -188,7 +188,7 @@ const subTitle = computed(() => {
const assignmentUser = computed(() => { const assignmentUser = computed(() => {
return courseSession.value.users.find( return courseSession.value.users.find(
(user) => user.user_id === Number(userStore.id) (user) => user.user_id === userStore.id
) as CourseSessionUser; ) as CourseSessionUser;
}); });

View File

@ -98,6 +98,6 @@ export async function uploadCircleDocument(
return Promise.resolve(newDocument); return Promise.resolve(newDocument);
} }
export async function deleteCircleDocument(documentId: number) { export async function deleteCircleDocument(documentId: string) {
return itDelete(`/api/core/document/${documentId}/`); return itDelete(`/api/core/document/${documentId}/`);
} }

View File

@ -41,7 +41,7 @@ export class LearningPath implements WagtailLearningPath {
public static fromJson( public static fromJson(
json: WagtailLearningPath, json: WagtailLearningPath,
completionData: CourseCompletion[], completionData: CourseCompletion[],
userId: number | undefined userId: string | undefined
): LearningPath { ): LearningPath {
return new LearningPath( return new LearningPath(
json.id, json.id,
@ -64,7 +64,7 @@ export class LearningPath implements WagtailLearningPath {
public readonly frontend_url: string, public readonly frontend_url: string,
public readonly course: Course, public readonly course: Course,
public children: LearningPathChild[], public children: LearningPathChild[],
public userId: number | undefined, public userId: string | undefined,
completionData?: CourseCompletion[] completionData?: CourseCompletion[]
) { ) {
// parse children // parse children

View File

@ -41,7 +41,7 @@ export const useCircleStore = defineStore({
async loadCircle( async loadCircle(
courseSlug: string, courseSlug: string,
circleSlug: string, circleSlug: string,
userId: number | undefined = undefined userId: string | undefined = undefined
): Promise<Circle> { ): Promise<Circle> {
if (!userId) { if (!userId) {
const userStore = useUserStore(); const userStore = useUserStore();

View File

@ -14,7 +14,7 @@ import orderBy from "lodash/orderBy";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
export type CompetenceStoreState = { export type CompetenceStoreState = {
competenceProfilePages: Map<number, CompetenceProfilePage>; competenceProfilePages: Map<string, CompetenceProfilePage>;
selectedCircle: { id: string; name: string }; selectedCircle: { id: string; name: string };
availableCircles: { id: string; name: string }[]; availableCircles: { id: string; name: string }[];
@ -24,7 +24,7 @@ export const useCompetenceStore = defineStore({
id: "competence", id: "competence",
state: () => { state: () => {
return { return {
competenceProfilePages: new Map<number, CompetenceProfilePage>(), competenceProfilePages: new Map<string, CompetenceProfilePage>(),
selectedCircle: { id: "all", name: "Circle: Alle" }, selectedCircle: { id: "all", name: "Circle: Alle" },
availableCircles: [], availableCircles: [],
} as CompetenceStoreState; } as CompetenceStoreState;
@ -56,7 +56,7 @@ export const useCompetenceStore = defineStore({
return competence.children; return competence.children;
}); });
}, },
competenceProfilePage(userId: number | undefined = undefined) { competenceProfilePage(userId: string | undefined = undefined) {
if (!userId) { if (!userId) {
const userStore = useUserStore(); const userStore = useUserStore();
userId = userStore.id; userId = userStore.id;
@ -65,7 +65,7 @@ export const useCompetenceStore = defineStore({
return this.competenceProfilePages.get(userId); return this.competenceProfilePages.get(userId);
}, },
flatPerformanceCriteria( flatPerformanceCriteria(
userId: number | undefined = undefined, userId: string | undefined = undefined,
circleTranslationKeys: string[] | undefined = undefined circleTranslationKeys: string[] | undefined = undefined
) { ) {
if (!userId) { if (!userId) {
@ -102,7 +102,7 @@ export const useCompetenceStore = defineStore({
return []; return [];
}, },
competences(userId: number | undefined = undefined) { competences(userId: string | undefined = undefined) {
if (!userId) { if (!userId) {
const userStore = useUserStore(); const userStore = useUserStore();
userId = userStore.id; userId = userStore.id;
@ -128,7 +128,7 @@ export const useCompetenceStore = defineStore({
}, },
async loadCompetenceProfilePage( async loadCompetenceProfilePage(
slug: string, slug: string,
userId: number | undefined = undefined, userId: string | undefined = undefined,
reload = false reload = false
) { ) {
if (!userId) { if (!userId) {
@ -161,7 +161,7 @@ export const useCompetenceStore = defineStore({
return this.competenceProfilePages.get(userId); return this.competenceProfilePages.get(userId);
}, },
async parseCompletionData(userId: number) { async parseCompletionData(userId: string) {
const competenceProfilePage = this.competenceProfilePages.get(userId); const competenceProfilePage = this.competenceProfilePages.get(userId);
if (competenceProfilePage) { if (competenceProfilePage) {
const completionStore = useCompletionStore(); const completionStore = useCompletionStore();

View File

@ -13,7 +13,7 @@ export const useCompletionStore = defineStore({
actions: { actions: {
async loadCourseSessionCompletionData( async loadCourseSessionCompletionData(
courseSessionId: number, courseSessionId: number,
userId: number, userId: string,
reload = false reload = false
) { ) {
const userCompletionData = (await itGetCached( const userCompletionData = (await itGetCached(
@ -30,7 +30,7 @@ export const useCompletionStore = defineStore({
}, },
async markPage( async markPage(
page: BaseCourseWagtailPage, page: BaseCourseWagtailPage,
userId: number | undefined = undefined, userId: string | undefined = undefined,
courseSessionId: number | undefined = undefined courseSessionId: number | undefined = undefined
) { ) {
if (!courseSessionId) { if (!courseSessionId) {

View File

@ -213,7 +213,7 @@ export const useCourseSessionsStore = defineStore("courseSessions", () => {
}); });
} }
async function removeDocument(documentId: number) { async function removeDocument(documentId: string) {
await deleteCircleDocument(documentId); await deleteCircleDocument(documentId);
if (currentCourseSession.value === undefined) { if (currentCourseSession.value === undefined) {

View File

@ -43,7 +43,7 @@ export const useLearningPathStore = defineStore("learningPath", () => {
async function loadCourseSessionCompletionData( async function loadCourseSessionCompletionData(
courseSlug: string, courseSlug: string,
userId: number | undefined = undefined userId: string | undefined = undefined
) { ) {
// FIXME: should not be here anymore with VBV-305 // FIXME: should not be here anymore with VBV-305
const completionStore = useCompletionStore(); const completionStore = useCompletionStore();
@ -66,7 +66,7 @@ export const useLearningPathStore = defineStore("learningPath", () => {
async function loadLearningPath( async function loadLearningPath(
slug: string, slug: string,
userId: number | undefined = undefined, userId: string | undefined = undefined,
reload = false, reload = false,
fail = true fail = true
) { ) {

View File

@ -19,7 +19,7 @@ if (import.meta.env.VITE_OAUTH_API_BASE_URL) {
export type AvailableLanguages = "de" | "fr" | "it"; export type AvailableLanguages = "de" | "fr" | "it";
export type UserState = { export type UserState = {
id: number; id: string;
first_name: string; first_name: string;
last_name: string; last_name: string;
email: string; email: string;
@ -50,7 +50,7 @@ for (const language of languagesWithoutCountryCode) {
} }
const initialUserState: UserState = { const initialUserState: UserState = {
id: 0, id: "",
email: "", email: "",
first_name: "", first_name: "",
last_name: "", last_name: "",

View File

@ -170,7 +170,7 @@ export interface Topic extends BaseCourseWagtailPage {
export type LearningPathChild = Topic | WagtailCircle; export type LearningPathChild = Topic | WagtailCircle;
export interface CourseCompletion { export interface CourseCompletion {
readonly id: number; readonly id: string;
created_at: string; created_at: string;
updated_at: string; updated_at: string;
readonly user: number; readonly user: number;
@ -181,17 +181,6 @@ export interface CourseCompletion {
additional_json_data: unknown; additional_json_data: unknown;
} }
export interface CircleDiagramData {
index: number;
title: string;
icon: string;
startAngle: number;
endAngle: number;
arrowStartAngle: number;
arrowEndAngle: number;
done: boolean;
}
export interface Course { export interface Course {
id: number; id: number;
title: string; title: string;
@ -394,7 +383,7 @@ export interface DropdownSelectable {
} }
export interface CircleExpert { export interface CircleExpert {
user_id: number; user_id: string;
user_email: string; user_email: string;
user_first_name: string; user_first_name: string;
user_last_name: string; user_last_name: string;
@ -404,7 +393,7 @@ export interface CircleExpert {
} }
export interface CircleDocument { export interface CircleDocument {
id: number; id: string;
name: string; name: string;
file_name: string; file_name: string;
url: string; url: string;
@ -457,7 +446,7 @@ export type Role = "MEMBER" | "EXPERT" | "TUTOR";
export interface CourseSessionUser { export interface CourseSessionUser {
session_title: string; session_title: string;
user_id: number; user_id: string;
first_name: string; first_name: string;
last_name: string; last_name: string;
email: string; email: string;
@ -491,7 +480,7 @@ export type NotificationType = "USER_INTERACTION" | "PROGRESS" | "INFORMATION";
export interface Notification { export interface Notification {
// given by AbstractNotification model // given by AbstractNotification model
id: number; id: string;
timestamp: string; timestamp: string;
unread: boolean; unread: boolean;
actor: string | null; actor: string | null;
@ -532,16 +521,16 @@ export interface AssignmentCompletionData {
} }
export interface AssignmentCompletion { export interface AssignmentCompletion {
id: number; id: string;
created_at: string; created_at: string;
updated_at: string; updated_at: string;
submitted_at: string; submitted_at: string;
evaluation_submitted_at: string | null; evaluation_submitted_at: string | null;
assignment_user: number; assignment_user: string;
assignment: number; assignment: number;
course_session: number; course_session: number;
completion_status: AssignmentCompletionStatus; completion_status: AssignmentCompletionStatus;
evaluation_user: number | null; evaluation_user: string | null;
completion_data: AssignmentCompletionData; completion_data: AssignmentCompletionData;
evaluation_grade: number | null; evaluation_grade: number | null;
} }
@ -554,14 +543,14 @@ export type UpsertUserAssignmentCompletion = {
}; };
export type EvaluationCompletionData = UpsertUserAssignmentCompletion & { export type EvaluationCompletionData = UpsertUserAssignmentCompletion & {
assignment_user_id: number; assignment_user_id: string;
evaluation_grade?: number; evaluation_grade?: number;
evaluation_points?: number; evaluation_points?: number;
}; };
export interface UserAssignmentCompletionStatus { export interface UserAssignmentCompletionStatus {
id: number; id: string;
assignment_user_id: number; assignment_user_id: string;
completion_status: AssignmentCompletionStatus; completion_status: AssignmentCompletionStatus;
evaluation_grade: number | null; evaluation_grade: number | null;
} }

View File

@ -10,6 +10,9 @@ from django.views import defaults as default_views
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView from graphene_django.views import GraphQLView
from ratelimit.exceptions import Ratelimited from ratelimit.exceptions import Ratelimited
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
from vbv_lernwelt.assignment.views import request_assignment_completion_status from vbv_lernwelt.assignment.views import request_assignment_completion_status
from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt from vbv_lernwelt.core.middleware.auth import django_view_authentication_exempt
@ -42,9 +45,6 @@ from vbv_lernwelt.feedback.views import (
get_feedback_for_circle, get_feedback_for_circle,
) )
from vbv_lernwelt.notify.views import email_notification_settings from vbv_lernwelt.notify.views import email_notification_settings
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
class SignedIntConverter(IntConverter): class SignedIntConverter(IntConverter):
@ -109,7 +109,7 @@ urlpatterns = [
path(r"api/course/completion/<signed_int:course_session_id>/", path(r"api/course/completion/<signed_int:course_session_id>/",
request_course_completion, request_course_completion,
name="request_course_completion"), name="request_course_completion"),
path(r"api/course/completion/<signed_int:course_session_id>/<signed_int:user_id>/", path(r"api/course/completion/<signed_int:course_session_id>/<uuid:user_id>/",
request_course_completion_for_user, request_course_completion_for_user,
name="request_course_completion_for_user"), name="request_course_completion_for_user"),