fix: mikrORM fix voor questions

This commit is contained in:
Timo De Meyst 2025-05-13 10:12:32 +02:00
parent 50cfcb69a6
commit c8d1112db2
2 changed files with 11 additions and 7 deletions

View file

@ -18,13 +18,14 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
content: question.content, content: question.content,
timestamp: new Date(), timestamp: new Date(),
}); });
await this.insert(questionEntity);
questionEntity.learningObjectHruid = question.loId.hruid; questionEntity.learningObjectHruid = question.loId.hruid;
questionEntity.learningObjectLanguage = question.loId.language; questionEntity.learningObjectLanguage = question.loId.language;
questionEntity.learningObjectVersion = question.loId.version; questionEntity.learningObjectVersion = question.loId.version;
questionEntity.author = question.author; questionEntity.author = question.author;
questionEntity.inGroup = question.inGroup; questionEntity.inGroup = question.inGroup;
questionEntity.content = question.content; questionEntity.content = question.content;
return await this.insert(questionEntity); return questionEntity;
} }
public async findAllQuestionsAboutLearningObject(loId: LearningObjectIdentifier): Promise<Question[]> { public async findAllQuestionsAboutLearningObject(loId: LearningObjectIdentifier): Promise<Question[]> {
return this.findAll({ return this.findAll({

View file

@ -139,12 +139,15 @@
(assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language,
); );
}); });
const loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => {
const loID: LearningObjectIdentifierDTO = { return {
hruid: props.learningObjectHruid as string, hruid: props.learningObjectHruid as string,
language: props.language, language: props.language,
version: currentNode.value?.version
}; };
const createQuestionMutation = useCreateQuestionMutation(loID); });
const createQuestionMutation = useCreateQuestionMutation(loID.value);
const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username); const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username);
const questionInput = ref(""); const questionInput = ref("");
@ -159,7 +162,7 @@
const questionData: QuestionData = { const questionData: QuestionData = {
author: authService.authState.user?.profile.preferred_username, author: authService.authState.user?.profile.preferred_username,
content: questionInput.value, content: questionInput.value,
inGroup: group, //TODO: POST response zegt dat dit null is??? inGroup: group,
}; };
if (questionInput.value !== "") { if (questionInput.value !== "") {
createQuestionMutation.mutate(questionData, { createQuestionMutation.mutate(questionData, {