fix: Logica vragen stellen gecorrigeerd (WIP)

This commit is contained in:
Gerald Schmittinger 2025-05-20 13:26:39 +02:00
parent 1d9141bab7
commit 8edd4f0225
5 changed files with 17 additions and 21 deletions

View file

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

View file

@ -6,6 +6,9 @@ import { Group } from '../assignments/group.entity.js';
@Entity({ repository: () => QuestionRepository })
export class Question {
@PrimaryKey({ type: 'integer', autoincrement: true })
sequenceNumber?: number;
@PrimaryKey({ type: 'string' })
learningObjectHruid!: string;
@ -18,9 +21,6 @@ export class Question {
@PrimaryKey({ type: 'number' })
learningObjectVersion = 1;
@PrimaryKey({ type: 'integer', autoincrement: true })
sequenceNumber?: number;
@ManyToOne({ entity: () => Group })
inGroup!: Group;

View file

@ -1,6 +1,5 @@
<script setup lang="ts">
import authService from "@/services/auth/auth-service.ts";
import { Language } from "@/data-objects/language.ts";
import { computed, type ComputedRef, ref } from "vue";
import type { GroupDTOId } from "@dwengo-1/common/interfaces/group";
import type { QuestionData } from "@dwengo-1/common/interfaces/question";
@ -10,9 +9,9 @@
import { AccountType } from "@dwengo-1/common/util/account-types.ts";
const props = defineProps<{
hruid: string;
language: Language;
learningObjectHruid?: string;
learningObjectHruid: string;
learningObjectLanguage: string;
learningObjectVersion: number;
forGroup?: GroupDTOId | undefined;
withTitle?: boolean;
}>();
@ -25,7 +24,8 @@
const loID: ComputedRef<LearningObjectIdentifierDTO> = computed(() => ({
hruid: props.learningObjectHruid as string,
language: props.language,
language: props.learningObjectLanguage,
version: props.learningObjectVersion
}));
const createQuestionMutation = useCreateQuestionMutation(loID);
@ -56,6 +56,7 @@
<template>
<h3 v-if="props.withTitle && showQuestionBox">{{ t("askAQuestion") }}:</h3>
{{ props.forGroup }}
<div
class="question-box"
v-if="showQuestionBox"

View file

@ -14,7 +14,7 @@ export class QuestionController extends BaseController {
loId: LearningObjectIdentifierDTO;
constructor(loId: LearningObjectIdentifierDTO) {
super(`learningObject/${loId.hruid}/:${loId.version}/questions`);
super(`learningObject/${loId.hruid}/${loId.version}/questions`);
this.loId = loId;
}

View file

@ -339,7 +339,7 @@
</v-btn>
</div>
<using-query-result
v-if="forGroup"
v-if="currentNode && forGroup"
:query-result="getQuestionsQuery"
v-slot="questionsResponse: { data: QuestionsResponse }"
>
@ -354,10 +354,10 @@
</span>
</div>
<QuestionBox
:hruid="props.hruid"
:language="props.language"
:learningObjectHruid="props.learningObjectHruid"
:forGroup="forGroup"
:learningObjectHruid="currentNode.learningobjectHruid"
:learningObjectLanguage="currentNode.language"
:learningObjectVersion="currentNode.version"
:forGroup="{assignment: forGroup.assignmentNo, class: forGroup.classId, groupNumber: forGroup.forGroup}"
@updated="refetchQuestions"
/>
<QandA :questions="(questionsResponse.data.questions as QuestionDTO[]) ?? []" />