refactor: Linting

This commit is contained in:
Tibo De Peuter 2025-04-24 21:33:14 +02:00
parent 18e17e0133
commit 9393898e06
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
5 changed files with 27 additions and 30 deletions

View file

@ -90,7 +90,8 @@ export async function createQuestion(loId: LearningObjectIdentifier, questionDat
let assignment; let assignment;
if (typeof questionData.inGroup.assignment === 'number' && typeof questionData.inGroup.class === 'string') { if (typeof questionData.inGroup.assignment === 'number' && typeof questionData.inGroup.class === 'string') {
assignment = await fetchAssignment(questionData.inGroup.class, questionData.inGroup.assignment); assignment = await fetchAssignment(questionData.inGroup.class,
questionData.inGroup.assignment);
} else { } else {
// TODO check if necessary and no conflicts to delete this if // TODO check if necessary and no conflicts to delete this if
const clazz = await getClassRepository().findById((questionData.inGroup.assignment as AssignmentDTO).within); const clazz = await getClassRepository().findById((questionData.inGroup.assignment as AssignmentDTO).within);

View file

@ -2,7 +2,6 @@ import { EntityManager } from '@mikro-orm/core';
import { Answer } from '../../../src/entities/questions/answer.entity'; import { Answer } from '../../../src/entities/questions/answer.entity';
import { Teacher } from '../../../src/entities/users/teacher.entity'; import { Teacher } from '../../../src/entities/users/teacher.entity';
import { Question } from '../../../src/entities/questions/question.entity'; import { Question } from '../../../src/entities/questions/question.entity';
import { getTestleerling1 } from '../users/students.testdata';
import { getTestleerkracht1 } from '../users/teachers.testdata'; import { getTestleerkracht1 } from '../users/teachers.testdata';
import { getQuestion07 } from './questions.testdata'; import { getQuestion07 } from './questions.testdata';

View file

@ -1,24 +1,21 @@
<script setup lang="ts"> <script setup lang="ts">
import type { LearningObject } from "@/data-objects/learning-objects/learning-object"; import type { LearningObject } from "@/data-objects/learning-objects/learning-object";
import { useQuestionsQuery } from "@/queries/questions"; import { useQuestionsQuery } from "@/queries/questions";
import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content";
import { languageMap } from "@dwengo-1/common/util/language"; import { computed } from 'vue';
import { computed, ref } from "vue";
const props = defineProps<{ const props = defineProps<{
node: LearningObject; node: LearningObject;
}>(); }>();
const loid = { const loid = {
hruid: props.node.key, hruid: props.node.key,
version: props.node.version, version: props.node.version,
language: props.node.language, language: props.node.language,} as LearningObjectIdentifierDTO;
} as LearningObjectIdentifierDTO; const { data } = useQuestionsQuery(loid);
const { data, isLoading, error } = useQuestionsQuery(loid);
const hasQuestions = computed(() => (data.value?.questions.length ?? 0) > 0);
const hasQuestions = computed(() => {
return (data.value?.questions.length ?? 0) > 0;
});
</script> </script>
<template v-if="!isLoading & !error"> <template v-if="!isLoading & !error">
<v-icon <v-icon

View file

@ -13,13 +13,13 @@
const expanded = ref(false); const expanded = ref(false);
const toggle = () => { function toggle (): void {
expanded.value = !expanded.value; expanded.value = !expanded.value;
}; }
const formatDate = (timestamp: string | Date): string => { function formatDate (timestamp: string | Date): string {
return new Date(timestamp).toLocaleString(); return new Date(timestamp).toLocaleString();
}; }
const answersQuery = useAnswersQuery( const answersQuery = useAnswersQuery(
computed( computed(
@ -39,16 +39,16 @@
const answer = ref(""); const answer = ref("");
function submitAnswer() { function submitAnswer(): void {
const answerData: AnswerData = { const answerData: AnswerData = {
author: authService.authState.user?.profile.preferred_username as string, author: authService.authState.user?.profile.preferred_username as string,
content: answer.value, content: answer.value,
}; };
if (answer.value != "") { if (answer.value !== "") {
createAnswerMutation.mutate(answerData, { createAnswerMutation.mutate(answerData, {
onSuccess: () => { onSuccess: async () => {
answer.value = ""; answer.value = "";
answersQuery.refetch(); await answersQuery.refetch();
}, },
}); });
} else { } else {

View file

@ -165,7 +165,7 @@
const questionInput = ref(""); const questionInput = ref("");
function submitQuestion() { function submitQuestion(): void {
const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[]; const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[];
const assignment = assignments.find( const assignment = assignments.find(
(assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language,
@ -176,16 +176,16 @@
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, //TODO: POST response zegt dat dit null is???
}; }
console.log(questionData); if (questionInput.value !== "") {
if (questionInput.value != "") {
createQuestionMutation.mutate(questionData, { createQuestionMutation.mutate(questionData, {
onSuccess: () => { onSuccess: async () => {
questionInput.value = ""; // Clear the input field after submission questionInput.value = ""; // Clear the input field after submission
getQuestionsQuery.refetch(); // Reload the questions await getQuestionsQuery.refetch(); // Reload the questions
}, },
onError: (e) => { onError: (_) => {
console.error(e); // TODO Handle error
// - console.error(e);
}, },
}); });
} else { } else {