From 18e17e0133b2cfd003257b25328a91f030beadd3 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Thu, 24 Apr 2025 19:28:16 +0000 Subject: [PATCH] style: fix linting issues met Prettier --- .../src/data/questions/answer-repository.ts | 2 +- backend/src/services/questions.ts | 9 +- .../test_assets/questions/answers.testdata.ts | 4 +- .../questions/questions.testdata.ts | 6 +- frontend/src/components/QandA.vue | 4 +- .../src/components/QuestionNotification.vue | 38 +++-- frontend/src/components/SingleQuestion.vue | 125 ++++++++------- frontend/src/controllers/answers.ts | 6 +- .../views/learning-paths/LearningPathPage.vue | 150 ++++++++++-------- 9 files changed, 184 insertions(+), 160 deletions(-) diff --git a/backend/src/data/questions/answer-repository.ts b/backend/src/data/questions/answer-repository.ts index ae59a56c..4ef30bbe 100644 --- a/backend/src/data/questions/answer-repository.ts +++ b/backend/src/data/questions/answer-repository.ts @@ -15,7 +15,7 @@ export class AnswerRepository extends DwengoEntityRepository { await this.insert(answerEntity); answerEntity.toQuestion = answer.toQuestion; answerEntity.author = answer.author; - answerEntity.content = answer.content; + answerEntity.content = answer.content; return answerEntity; } public async findAllAnswersToQuestion(question: Question): Promise { diff --git a/backend/src/services/questions.ts b/backend/src/services/questions.ts index d80fffac..09643cd2 100644 --- a/backend/src/services/questions.ts +++ b/backend/src/services/questions.ts @@ -89,9 +89,8 @@ export async function createQuestion(loId: LearningObjectIdentifier, questionDat let assignment; - if ((typeof questionData.inGroup.assignment === "number") && (typeof questionData.inGroup.class === "string")) { - assignment = await fetchAssignment(questionData.inGroup.class, - questionData.inGroup.assignment); + if (typeof questionData.inGroup.assignment === 'number' && typeof questionData.inGroup.class === 'string') { + assignment = await fetchAssignment(questionData.inGroup.class, questionData.inGroup.assignment); } else { // TODO check if necessary and no conflicts to delete this if const clazz = await getClassRepository().findById((questionData.inGroup.assignment as AssignmentDTO).within); @@ -99,14 +98,14 @@ export async function createQuestion(loId: LearningObjectIdentifier, questionDat } const inGroup = await getGroupRepository().findByAssignmentAndGroupNumber(assignment, questionData.inGroup.groupNumber); - + const question = await questionRepository.createQuestion({ loId, author, inGroup: inGroup!, content, }); - + return mapToQuestionDTO(question); } diff --git a/backend/tests/test_assets/questions/answers.testdata.ts b/backend/tests/test_assets/questions/answers.testdata.ts index 44724604..443f523d 100644 --- a/backend/tests/test_assets/questions/answers.testdata.ts +++ b/backend/tests/test_assets/questions/answers.testdata.ts @@ -36,7 +36,7 @@ export function makeTestAnswers(em: EntityManager, teachers: Teacher[], question toQuestion: getQuestion07(), sequenceNumber: 1, timestamp: new Date(), - content: "this is a test answer" + content: 'this is a test answer', }); const answer05 = em.create(Answer, { @@ -44,7 +44,7 @@ export function makeTestAnswers(em: EntityManager, teachers: Teacher[], question toQuestion: getQuestion07(), sequenceNumber: 2, timestamp: new Date(), - content: "this is a test answer" + content: 'this is a test answer', }); return [answer01, answer02, answer03, answer04, answer05]; diff --git a/backend/tests/test_assets/questions/questions.testdata.ts b/backend/tests/test_assets/questions/questions.testdata.ts index 5e50d7d7..9e8d6df3 100644 --- a/backend/tests/test_assets/questions/questions.testdata.ts +++ b/backend/tests/test_assets/questions/questions.testdata.ts @@ -73,7 +73,7 @@ export function makeTestQuestions(em: EntityManager, students: Student[], groups timestamp: new Date(), content: 'question', }); - + question07 = em.create(Question, { learningObjectLanguage: Language.English, learningObjectVersion: 1, @@ -93,7 +93,7 @@ export function makeTestQuestions(em: EntityManager, students: Student[], groups author: getTestleerling1(), inGroup: getGroup1ConditionalLearningPath(), timestamp: new Date(), - content: 'this is a second test question' + content: 'this is a second test question', }); return [question01, question02, question03, question04, question05, question06, question07, question08]; @@ -108,4 +108,4 @@ export function getQuestion07(): Question { export function getQuestion08(): Question { return question08; -} \ No newline at end of file +} diff --git a/frontend/src/components/QandA.vue b/frontend/src/components/QandA.vue index 3d7bae39..f9b15362 100644 --- a/frontend/src/components/QandA.vue +++ b/frontend/src/components/QandA.vue @@ -9,13 +9,11 @@ diff --git a/frontend/src/components/QuestionNotification.vue b/frontend/src/components/QuestionNotification.vue index 21801fea..30d73e00 100644 --- a/frontend/src/components/QuestionNotification.vue +++ b/frontend/src/components/QuestionNotification.vue @@ -1,23 +1,31 @@ diff --git a/frontend/src/components/SingleQuestion.vue b/frontend/src/components/SingleQuestion.vue index 13553290..fdf48bd3 100644 --- a/frontend/src/components/SingleQuestion.vue +++ b/frontend/src/components/SingleQuestion.vue @@ -5,7 +5,7 @@ import UsingQueryResult from "./UsingQueryResult.vue"; import type { AnswersResponse } from "@/controllers/answers"; import type { AnswerData, AnswerDTO } from "@dwengo-1/common/interfaces/answer"; -import authService from "@/services/auth/auth-service"; + import authService from "@/services/auth/auth-service"; const props = defineProps<{ question: QuestionDTO; @@ -30,31 +30,30 @@ import authService from "@/services/auth/auth-service"; }) as QuestionId, ), ); - - const questionId : QuestionId = { + + const questionId: QuestionId = { learningObjectIdentifier: props.question.learningObjectIdentifier, - sequenceNumber: props.question.sequenceNumber as number + sequenceNumber: props.question.sequenceNumber as number, }; const createAnswerMutation = useCreateAnswerMutation(questionId); - const answer = ref(''); + const answer = ref(""); function submitAnswer() { const answerData: AnswerData = { author: authService.authState.user?.profile.preferred_username as string, - content: answer.value + content: answer.value, }; if (answer.value != "") { createAnswerMutation.mutate(answerData, { onSuccess: () => { answer.value = ""; answersQuery.refetch(); - } + }, }); } else { - alert("Please type an answer before submitting") //TODO: i18n + alert("Please type an answer before submitting"); //TODO: i18n } - } diff --git a/frontend/src/controllers/answers.ts b/frontend/src/controllers/answers.ts index 3a378a96..57407b19 100644 --- a/frontend/src/controllers/answers.ts +++ b/frontend/src/controllers/answers.ts @@ -12,13 +12,13 @@ export interface AnswerResponse { } export class AnswerController extends BaseController { - loId: LearningObjectIdentifierDTO; sequenceNumber: number; - constructor(questionId: QuestionId) { - super(`learningObject/${questionId.learningObjectIdentifier.hruid}/:${questionId.learningObjectIdentifier.version}/questions/${questionId.sequenceNumber}/answers`); + super( + `learningObject/${questionId.learningObjectIdentifier.hruid}/:${questionId.learningObjectIdentifier.version}/questions/${questionId.sequenceNumber}/answers`, + ); this.loId = questionId.learningObjectIdentifier; this.sequenceNumber = questionId.sequenceNumber; } diff --git a/frontend/src/views/learning-paths/LearningPathPage.vue b/frontend/src/views/learning-paths/LearningPathPage.vue index 8f97379a..e0199cfe 100644 --- a/frontend/src/views/learning-paths/LearningPathPage.vue +++ b/frontend/src/views/learning-paths/LearningPathPage.vue @@ -18,10 +18,10 @@ import type { LearningObjectIdentifierDTO } from "@dwengo-1/common/interfaces/learning-content"; import QandA from "@/components/QandA.vue"; import type { QuestionData, QuestionDTO } from "@dwengo-1/common/interfaces/question"; - import {useStudentAssignmentsQuery, useStudentGroupsQuery} from "@/queries/students" + import { useStudentAssignmentsQuery, useStudentGroupsQuery } from "@/queries/students"; import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; -import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; -import QuestionNotification from "@/components/QuestionNotification.vue"; + import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; + import QuestionNotification from "@/components/QuestionNotification.vue"; const router = useRouter(); const route = useRoute(); @@ -146,40 +146,38 @@ import QuestionNotification from "@/components/QuestionNotification.vue"; }); } - const studentAssignmentsQueryResult = useStudentAssignmentsQuery(authService.authState.user?.profile.preferred_username); + const studentAssignmentsQueryResult = useStudentAssignmentsQuery( + authService.authState.user?.profile.preferred_username, + ); const pathIsAssignment = computed(() => { - const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[] || []; + const assignments = (studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[]) || []; return assignments.some( - (assignment) => - assignment.learningPath === props.hruid && - assignment.language === props.language + (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, ); }); - const loID:LearningObjectIdentifierDTO = { - hruid: props.learningObjectHruid as string, - language: props.language - } - const createQuestionMutation = useCreateQuestionMutation(loID) - const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username) + const loID: LearningObjectIdentifierDTO = { + hruid: props.learningObjectHruid as string, + language: props.language, + }; + const createQuestionMutation = useCreateQuestionMutation(loID); + const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username); const questionInput = ref(""); function submitQuestion() { - const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[] + const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[]; const assignment = assignments.find( - (assignment) => - assignment.learningPath === props.hruid && - assignment.language === props.language - ) - const groups = groupsQueryResult.data.value?.groups as GroupDTO[] - const group = groups?.find(group => group.assignment === assignment?.id) as GroupDTO - const questionData:QuestionData = { + (assignment) => assignment.learningPath === props.hruid && assignment.language === props.language, + ); + const groups = groupsQueryResult.data.value?.groups as GroupDTO[]; + const group = groups?.find((group) => group.assignment === assignment?.id) as GroupDTO; + const questionData: QuestionData = { author: authService.authState.user?.profile.preferred_username, content: questionInput.value, - inGroup: group //TODO: POST response zegt dat dit null is??? - } - console.log(questionData) + inGroup: group, //TODO: POST response zegt dat dit null is??? + }; + console.log(questionData); if (questionInput.value != "") { createQuestionMutation.mutate(questionData, { onSuccess: () => { @@ -187,14 +185,13 @@ import QuestionNotification from "@/components/QuestionNotification.vue"; getQuestionsQuery.refetch(); // Reload the questions }, onError: (e) => { - console.error(e) + console.error(e); }, - }) + }); } else { - alert("Please type a question before submitting.") // TODO: i18n + alert("Please type a question before submitting."); // TODO: i18n } } - + - @@ -292,7 +295,10 @@ import QuestionNotification from "@/components/QuestionNotification.vue"; -
+
{{ t("assignmentIndicator") }}
@@ -318,17 +324,25 @@ import QuestionNotification from "@/components/QuestionNotification.vue"; v-if="currentNode" >
-
+
- - + +
-
+