style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-04-08 08:56:50 +00:00
parent ba725f67b2
commit 8a55c0f003
22 changed files with 137 additions and 157 deletions

View file

@ -147,7 +147,6 @@ describe('Student controllers', () => {
const result = jsonMock.mock.lastCall?.[0];
expect(result.submissions).to.have.length.greaterThan(0);
});
it('Student questions', async () => {

View file

@ -32,10 +32,8 @@ describe('AssignmentRepository', () => {
});
it('should find all by username of the responsible teacher', async () => {
const result = await assignmentRepository.findAllByResponsibleTeacher("FooFighters")
const resultIds = result
.map(it => it.id)
.sort((a, b) => (a ?? 0) - (b ?? 0));
const result = await assignmentRepository.findAllByResponsibleTeacher('FooFighters');
const resultIds = result.map((it) => it.id).sort((a, b) => (a ?? 0) - (b ?? 0));
expect(resultIds).toEqual([1, 3, 4]);
});

View file

@ -1,6 +1,6 @@
import {beforeAll, describe, expect, it} from 'vitest';
import {setupTestApp} from '../../setup-tests';
import {SubmissionRepository} from '../../../src/data/assignments/submission-repository';
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { SubmissionRepository } from '../../../src/data/assignments/submission-repository';
import {
getAssignmentRepository,
getClassRepository,
@ -8,15 +8,15 @@ import {
getStudentRepository,
getSubmissionRepository,
} from '../../../src/data/repositories';
import {LearningObjectIdentifier} from '../../../src/entities/content/learning-object-identifier';
import {Language} from '@dwengo-1/common/util/language';
import {StudentRepository} from '../../../src/data/users/student-repository';
import {GroupRepository} from '../../../src/data/assignments/group-repository';
import {AssignmentRepository} from '../../../src/data/assignments/assignment-repository';
import {ClassRepository} from '../../../src/data/classes/class-repository';
import {Submission} from "../../../src/entities/assignments/submission.entity";
import {Class} from "../../../src/entities/classes/class.entity";
import {Assignment} from "../../../src/entities/assignments/assignment.entity";
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '@dwengo-1/common/util/language';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { GroupRepository } from '../../../src/data/assignments/group-repository';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
import { Submission } from '../../../src/entities/assignments/submission.entity';
import { Class } from '../../../src/entities/classes/class.entity';
import { Assignment } from '../../../src/entities/assignments/assignment.entity';
describe('SubmissionRepository', () => {
let submissionRepository: SubmissionRepository;
@ -69,9 +69,9 @@ describe('SubmissionRepository', () => {
clazz = await classRepository.findById('id01');
assignment = await assignmentRepository.findByClassAndId(clazz!, 1);
loId = {
hruid: "id02",
hruid: 'id02',
language: Language.English,
version: 1
version: 1,
};
const result = await submissionRepository.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment!);
sortSubmissions(result);
@ -92,8 +92,7 @@ describe('SubmissionRepository', () => {
});
it("should find only the submissions for a certain learning object and assignment made for the user's group", async () => {
const result =
await submissionRepository.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment!, "Tool");
const result = await submissionRepository.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment!, 'Tool');
// (student Tool is in group #2)
expect(result).toHaveLength(1);
@ -118,8 +117,12 @@ describe('SubmissionRepository', () => {
function sortSubmissions(submissions: Submission[]): void {
submissions.sort((a, b) => {
if (a.learningObjectHruid < b.learningObjectHruid) {return -1;}
if (a.learningObjectHruid > b.learningObjectHruid) {return 1;}
if (a.learningObjectHruid < b.learningObjectHruid) {
return -1;
}
if (a.learningObjectHruid > b.learningObjectHruid) {
return 1;
}
return a.submissionNumber! - b.submissionNumber!;
});
}

View file

@ -2,17 +2,18 @@ import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { QuestionRepository } from '../../../src/data/questions/question-repository';
import {
getAssignmentRepository, getClassRepository,
getAssignmentRepository,
getClassRepository,
getGroupRepository,
getQuestionRepository,
getStudentRepository
getStudentRepository,
} from '../../../src/data/repositories';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '@dwengo-1/common/util/language';
import {Question} from "../../../src/entities/questions/question.entity";
import {Class} from "../../../src/entities/classes/class.entity";
import {Assignment} from "../../../src/entities/assignments/assignment.entity";
import { Question } from '../../../src/entities/questions/question.entity';
import { Class } from '../../../src/entities/classes/class.entity';
import { Assignment } from '../../../src/entities/assignments/assignment.entity';
describe('QuestionRepository', () => {
let questionRepository: QuestionRepository;
@ -36,7 +37,7 @@ describe('QuestionRepository', () => {
const id = new LearningObjectIdentifier('id03', Language.English, 1);
const student = await studentRepository.findByUsername('Noordkaap');
const clazz = await getClassRepository().findById("id01");
const clazz = await getClassRepository().findById('id01');
const assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
const group = await getGroupRepository().findByAssignmentAndGroupNumber(assignment!, 1);
await questionRepository.createQuestion({
@ -58,9 +59,9 @@ describe('QuestionRepository', () => {
clazz = await getClassRepository().findById('id01');
assignment = await getAssignmentRepository().findByClassAndId(clazz!, 1);
loId = {
hruid: "id05",
hruid: 'id05',
language: Language.English,
version: 1
version: 1,
};
const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!);
sortQuestions(result);
@ -83,8 +84,7 @@ describe('QuestionRepository', () => {
});
it("should find only the questions for a certain learning object and assignment asked by the user's group", async () => {
const result =
await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!, "Tool");
const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!, 'Tool');
// (student Tool is in group #2)
expect(result).toHaveLength(1);
@ -110,8 +110,11 @@ describe('QuestionRepository', () => {
function sortQuestions(questions: Question[]): void {
questions.sort((a, b) => {
if (a.learningObjectHruid < b.learningObjectHruid) {return -1}
else if (a.learningObjectHruid > b.learningObjectHruid) {return 1}
return a.sequenceNumber! - b.sequenceNumber!
if (a.learningObjectHruid < b.learningObjectHruid) {
return -1;
} else if (a.learningObjectHruid > b.learningObjectHruid) {
return 1;
}
return a.sequenceNumber! - b.sequenceNumber!;
});
}

View file

@ -25,9 +25,9 @@ import { Student } from '../../../src/entities/users/student.entity.js';
import { LearningObjectNode, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content';
const STUDENT_A_USERNAME = "student_a";
const STUDENT_B_USERNAME = "student_b";
const CLASS_NAME = "test_class"
const STUDENT_A_USERNAME = 'student_a';
const STUDENT_B_USERNAME = 'student_b';
const CLASS_NAME = 'test_class';
async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> {
const learningObjectRepo = getLearningObjectRepository();
@ -44,7 +44,7 @@ async function initPersonalizationTestData(): Promise<{
studentA: Student;
studentB: Student;
}> {
const studentRepo = getStudentRepository()
const studentRepo = getStudentRepository();
const classRepo = getClassRepository();
const assignmentRepo = getAssignmentRepository();
const groupRepo = getGroupRepository();
@ -75,31 +75,31 @@ async function initPersonalizationTestData(): Promise<{
// Create class for students
const testClass = classRepo.create({
classId: CLASS_NAME,
displayName: "Test class"
displayName: 'Test class',
});
await classRepo.save(testClass);
// Create assignment for students and assign them to different groups
const assignment = assignmentRepo.create({
id: 0,
title: "Test assignment",
description: "Test description",
title: 'Test assignment',
description: 'Test description',
learningPathHruid: learningContent.learningPath.hruid,
learningPathLanguage: learningContent.learningPath.language,
within: testClass
})
within: testClass,
});
const groupA = groupRepo.create({
groupNumber: 0,
members: [studentA],
assignment
assignment,
});
await groupRepo.save(groupA);
const groupB = groupRepo.create({
groupNumber: 1,
members: [studentB],
assignment
assignment,
});
await groupRepo.save(groupB);

View file

@ -2,7 +2,7 @@ import { EntityManager } from '@mikro-orm/core';
import { Question } from '../../../src/entities/questions/question.entity';
import { Language } from '@dwengo-1/common/util/language';
import { Student } from '../../../src/entities/users/student.entity';
import {Group} from "../../../src/entities/assignments/group.entity";
import { Group } from '../../../src/entities/assignments/group.entity';
export function makeTestQuestions(em: EntityManager, students: Student[], groups: Group[]): Question[] {
const question01 = em.create(Question, {