style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-03-13 14:30:15 +00:00
parent e58835aa17
commit e73d5c21c3
34 changed files with 103 additions and 296 deletions

View file

@ -62,7 +62,9 @@ De tech-stack bestaat uit:
Voor meer informatie over de keuze van deze tech-stack, zie [designkeuzes](https://github.com/SELab-2/Dwengo-1/wiki/Developer:-Design-keuzes).
## Testen
Voer volgende commando's uit om de <frontend/backend> te testen:
```
npm run test:unit
```

View file

@ -22,7 +22,9 @@ npm run start
```
### Tests
Voer volgend commando uit om de unit tests uit te voeren:
```
npm run test:unit
```

View file

@ -4,19 +4,13 @@ import { Question } from '../../entities/questions/question.entity.js';
import { Teacher } from '../../entities/users/teacher.entity.js';
export class AnswerRepository extends DwengoEntityRepository<Answer> {
public createAnswer(answer: {
toQuestion: Question;
author: Teacher;
content: string;
}): Promise<Answer> {
const answerEntity = this.create(
{
toQuestion: answer.toQuestion,
author: answer.author,
content: answer.content,
timestamp: new Date()
}
);
public createAnswer(answer: { toQuestion: Question; author: Teacher; content: string }): Promise<Answer> {
const answerEntity = this.create({
toQuestion: answer.toQuestion,
author: answer.author,
content: answer.content,
timestamp: new Date(),
});
return this.insert(answerEntity);
}
public findAllAnswersToQuestion(question: Question): Promise<Answer[]> {

View file

@ -11,7 +11,7 @@ export class QuestionRepository extends DwengoEntityRepository<Question> {
learningObjectVersion: question.loId.version,
author: question.author,
content: question.content,
timestamp: new Date()
timestamp: new Date(),
});
questionEntity.learningObjectHruid = question.loId.hruid;
questionEntity.learningObjectLanguage = question.loId.language;

View file

@ -24,7 +24,7 @@ import { LearningPath } from './entities/content/learning-path.entity.js';
import { Answer } from './entities/questions/answer.entity.js';
import { Question } from './entities/questions/question.entity.js';
import {SqliteAutoincrementSubscriber} from "./sqlite-autoincrement-workaround.js";
import { SqliteAutoincrementSubscriber } from './sqlite-autoincrement-workaround.js';
const entities = [
User,

View file

@ -1,4 +1,4 @@
import {EntityManager, MikroORM} from '@mikro-orm/core';
import { EntityManager, MikroORM } from '@mikro-orm/core';
import config from './mikro-orm.config.js';
import { EnvVars, getEnvVar } from './util/envvars.js';
import { getLogger, Logger } from './logging/initalize.js';

View file

@ -1,4 +1,4 @@
import {EntityProperty, EventArgs, EventSubscriber} from "@mikro-orm/core";
import { EntityProperty, EventArgs, EventSubscriber } from '@mikro-orm/core';
/**
* The tests are ran on an in-memory SQLite database. However, SQLite does not allow fields which are part of composite
@ -29,7 +29,7 @@ export class SqliteAutoincrementSubscriber implements EventSubscriber {
const property = prop as EntityProperty<T>;
if (property.primary && property.autoincrement && !(args.entity as Record<string, any>)[property.name]) {
// Obtain and increment sequence number of this entity.
const propertyKey = args.meta.class.name + "." + property.name;
const propertyKey = args.meta.class.name + '.' + property.name;
const nextSeqNumber = this.sequenceNumbersForEntityType.get(propertyKey) || 0;
this.sequenceNumbersForEntityType.set(propertyKey, nextSeqNumber + 1);

View file

@ -1,10 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import {
getAssignmentRepository,
getClassRepository,
} from '../../../src/data/repositories';
import { getAssignmentRepository, getClassRepository } from '../../../src/data/repositories';
import { ClassRepository } from '../../../src/data/classes/class-repository';
describe('AssignmentRepository', () => {
@ -19,10 +16,7 @@ describe('AssignmentRepository', () => {
it('should return the requested assignment', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 2);
expect(assignment).toBeTruthy();
expect(assignment!.title).toBe('tool');
@ -30,8 +24,7 @@ describe('AssignmentRepository', () => {
it('should return all assignments for a class', async () => {
const class_ = await classRepository.findById('id02');
const assignments =
await assignmentRepository.findAllAssignmentsInClass(class_!);
const assignments = await assignmentRepository.findAllAssignmentsInClass(class_!);
expect(assignments).toBeTruthy();
expect(assignments).toHaveLength(1);
@ -42,10 +35,7 @@ describe('AssignmentRepository', () => {
const class_ = await classRepository.findById('id01');
await assignmentRepository.deleteByClassAndId(class_!, 3);
const assignment = await assignmentRepository.findByClassAndId(
class_!,
3
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 3);
expect(assignment).toBeNull();
});

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { GroupRepository } from '../../../src/data/assignments/group-repository';
import {
getAssignmentRepository,
getClassRepository,
getGroupRepository,
} from '../../../src/data/repositories';
import { getAssignmentRepository, getClassRepository, getGroupRepository } from '../../../src/data/repositories';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
@ -23,29 +19,18 @@ describe('GroupRepository', () => {
it('should return the requested group', async () => {
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1);
expect(group).toBeTruthy();
});
it('should return all groups for assignment', async () => {
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 1);
const groups = await groupRepository.findAllGroupsForAssignment(
assignment!
);
const groups = await groupRepository.findAllGroupsForAssignment(assignment!);
expect(groups).toBeTruthy();
expect(groups).toHaveLength(3);
@ -53,17 +38,11 @@ describe('GroupRepository', () => {
it('should not find removed group', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 2);
await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1);
expect(group).toBeNull();
});

View file

@ -33,11 +33,7 @@ describe('SubmissionRepository', () => {
it('should find the requested submission', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1');
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1);
expect(submission).toBeTruthy();
expect(submission?.content).toBe('sub1');
@ -46,11 +42,7 @@ describe('SubmissionRepository', () => {
it('should find the most recent submission for a student', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1');
const student = await studentRepository.findByUsername('Noordkaap');
const submission =
await submissionRepository.findMostRecentSubmissionForStudent(
id,
student!
);
const submission = await submissionRepository.findMostRecentSubmissionForStudent(id, student!);
expect(submission).toBeTruthy();
expect(submission?.submissionTime.getDate()).toBe(25);
@ -59,19 +51,9 @@ describe('SubmissionRepository', () => {
it('should find the most recent submission for a group', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1');
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const submission =
await submissionRepository.findMostRecentSubmissionForGroup(
id,
group!
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1);
const submission = await submissionRepository.findMostRecentSubmissionForGroup(id, group!);
expect(submission).toBeTruthy();
expect(submission?.submissionTime.getDate()).toBe(25);
@ -79,16 +61,9 @@ describe('SubmissionRepository', () => {
it('should not find a deleted submission', async () => {
const id = new LearningObjectIdentifier('id01', Language.English, '1');
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(id, 1);
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1);
expect(submission).toBeNull();
});

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository';
import {
getClassJoinRequestRepository,
getClassRepository,
getStudentRepository,
} from '../../../src/data/repositories';
import { getClassJoinRequestRepository, getClassRepository, getStudentRepository } from '../../../src/data/repositories';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { Class } from '../../../src/entities/classes/class.entity';
import { ClassRepository } from '../../../src/data/classes/class-repository';
@ -25,9 +21,7 @@ describe('ClassJoinRequestRepository', () => {
it('should list all requests from student to join classes', async () => {
const student = await studentRepository.findByUsername('PinkFloyd');
const requests = await classJoinRequestRepository.findAllRequestsBy(
student!
);
const requests = await classJoinRequestRepository.findAllRequestsBy(student!);
expect(requests).toBeTruthy();
expect(requests).toHaveLength(2);
@ -35,23 +29,18 @@ describe('ClassJoinRequestRepository', () => {
it('should list all requests to a single class', async () => {
const class_ = await cassRepository.findById('id02');
const requests = await classJoinRequestRepository.findAllOpenRequestsTo(
class_!
);
const requests = await classJoinRequestRepository.findAllOpenRequestsTo(class_!);
expect(requests).toBeTruthy();
expect(requests).toHaveLength(2);
});
it('should not find a removed request', async () => {
const student =
await studentRepository.findByUsername('SmashingPumpkins');
const student = await studentRepository.findByUsername('SmashingPumpkins');
const class_ = await cassRepository.findById('id03');
await classJoinRequestRepository.deleteBy(student!, class_!);
const request = await classJoinRequestRepository.findAllRequestsBy(
student!
);
const request = await classJoinRequestRepository.findAllRequestsBy(student!);
expect(request).toHaveLength(0);
});

View file

@ -1,10 +1,6 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import {
getClassRepository,
getTeacherInvitationRepository,
getTeacherRepository,
} from '../../../src/data/repositories';
import { getClassRepository, getTeacherInvitationRepository, getTeacherRepository } from '../../../src/data/repositories';
import { TeacherInvitationRepository } from '../../../src/data/classes/teacher-invitation-repository';
import { TeacherRepository } from '../../../src/data/users/teacher-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
@ -23,8 +19,7 @@ describe('ClassRepository', () => {
it('should return all invitations from a teacher', async () => {
const teacher = await teacherRepository.findByUsername('LimpBizkit');
const invitations =
await teacherInvitationRepository.findAllInvitationsBy(teacher!);
const invitations = await teacherInvitationRepository.findAllInvitationsBy(teacher!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -32,8 +27,7 @@ describe('ClassRepository', () => {
it('should return all invitations for a teacher', async () => {
const teacher = await teacherRepository.findByUsername('FooFighters');
const invitations =
await teacherInvitationRepository.findAllInvitationsFor(teacher!);
const invitations = await teacherInvitationRepository.findAllInvitationsFor(teacher!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -41,10 +35,7 @@ describe('ClassRepository', () => {
it('should return all invitations for a class', async () => {
const class_ = await classRepository.findById('id02');
const invitations =
await teacherInvitationRepository.findAllInvitationsForClass(
class_!
);
const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -56,8 +47,7 @@ describe('ClassRepository', () => {
const receiver = await teacherRepository.findByUsername('LimpBizkit');
await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!);
const invitation =
await teacherInvitationRepository.findAllInvitationsBy(sender!);
const invitation = await teacherInvitationRepository.findAllInvitationsBy(sender!);
expect(invitation).toHaveLength(0);
});

View file

@ -1,9 +1,6 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests.js';
import {
getAttachmentRepository,
getLearningObjectRepository,
} from '../../../src/data/repositories.js';
import { getAttachmentRepository, getLearningObjectRepository } from '../../../src/data/repositories.js';
import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js';
import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository.js';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier.js';
@ -21,15 +18,13 @@ describe('AttachmentRepository', () => {
it('should return the requested attachment', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1');
const learningObject =
await learningObjectRepository.findByIdentifier(id);
const learningObject = await learningObjectRepository.findByIdentifier(id);
const attachment =
await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName(
learningObject!,
Language.English,
'attachment01'
);
const attachment = await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName(
learningObject!,
Language.English,
'attachment01'
);
expect(attachment).toBeTruthy();
});

View file

@ -17,8 +17,7 @@ describe('LearningObjectRepository', () => {
const id02 = new LearningObjectIdentifier('test_id', Language.English, '1');
it('should return the learning object that matches identifier 1', async () => {
const learningObject =
await learningObjectRepository.findByIdentifier(id01);
const learningObject = await learningObjectRepository.findByIdentifier(id01);
expect(learningObject).toBeTruthy();
expect(learningObject?.title).toBe('Undertow');
@ -26,8 +25,7 @@ describe('LearningObjectRepository', () => {
});
it('should return nothing because the identifier does not exist in the database', async () => {
const learningObject =
await learningObjectRepository.findByIdentifier(id02);
const learningObject = await learningObjectRepository.findByIdentifier(id02);
expect(learningObject).toBeNull();
});

View file

@ -13,21 +13,13 @@ describe('LearningPathRepository', () => {
});
it('should return nothing because no match for hruid and language', async () => {
const learningPath =
await learningPathRepository.findByHruidAndLanguage(
'test_id',
Language.Dutch
);
const learningPath = await learningPathRepository.findByHruidAndLanguage('test_id', Language.Dutch);
expect(learningPath).toBeNull();
});
it('should return requested learning path', async () => {
const learningPath =
await learningPathRepository.findByHruidAndLanguage(
'id01',
Language.English
);
const learningPath = await learningPathRepository.findByHruidAndLanguage('id01', Language.English);
expect(learningPath).toBeTruthy();
expect(learningPath?.title).toBe('repertoire Tool');

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { AnswerRepository } from '../../../src/data/questions/answer-repository';
import {
getAnswerRepository,
getQuestionRepository,
getTeacherRepository,
} from '../../../src/data/repositories';
import { getAnswerRepository, getQuestionRepository, getTeacherRepository } from '../../../src/data/repositories';
import { QuestionRepository } from '../../../src/data/questions/question-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '../../../src/entities/content/language';
@ -25,13 +21,11 @@ describe('AnswerRepository', () => {
it('should find all answers to a question', async () => {
const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = questions.filter((it) => it.sequenceNumber == 2)[0];
const answers =
await answerRepository.findAllAnswersToQuestion(question);
const answers = await answerRepository.findAllAnswersToQuestion(question);
expect(answers).toBeTruthy();
expect(answers).toHaveLength(2);
@ -42,8 +36,7 @@ describe('AnswerRepository', () => {
it('should create an answer to a question', async () => {
const teacher = await teacherRepository.findByUsername('FooFighters');
const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = questions[0];
@ -53,8 +46,7 @@ describe('AnswerRepository', () => {
content: 'created answer',
});
const answers =
await answerRepository.findAllAnswersToQuestion(question);
const answers = await answerRepository.findAllAnswersToQuestion(question);
expect(answers).toBeTruthy();
expect(answers).toHaveLength(1);
@ -63,17 +55,11 @@ describe('AnswerRepository', () => {
it('should not find a removed answer', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
await answerRepository.removeAnswerByQuestionAndSequenceNumber(
questions[0],
1
);
await answerRepository.removeAnswerByQuestionAndSequenceNumber(questions[0], 1);
const emptyList = await answerRepository.findAllAnswersToQuestion(
questions[0]
);
const emptyList = await answerRepository.findAllAnswersToQuestion(questions[0]);
expect(emptyList).toHaveLength(0);
});

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { QuestionRepository } from '../../../src/data/questions/question-repository';
import {
getLearningObjectRepository,
getQuestionRepository,
getStudentRepository,
} from '../../../src/data/repositories';
import { getLearningObjectRepository, getQuestionRepository, getStudentRepository } from '../../../src/data/repositories';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
@ -25,8 +21,7 @@ describe('QuestionRepository', () => {
it('should return all questions part of the given learning object', async () => {
const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(questions).toBeTruthy();
expect(questions).toHaveLength(2);
@ -40,8 +35,7 @@ describe('QuestionRepository', () => {
author: student!,
content: 'question?',
});
const question =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(question).toBeTruthy();
expect(question).toHaveLength(1);
@ -49,13 +43,9 @@ describe('QuestionRepository', () => {
it('should not find removed question', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1');
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(
id,
1
);
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(id, 1);
const question =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(question).toHaveLength(0);
});

View file

@ -30,12 +30,9 @@ describe('TeacherRepository', () => {
});
it('should return the queried teacher after he was added', async () => {
await teacherRepository.insert(
new Teacher(username, firstName, lastName)
);
await teacherRepository.insert(new Teacher(username, firstName, lastName));
const retrievedTeacher =
await teacherRepository.findByUsername(username);
const retrievedTeacher = await teacherRepository.findByUsername(username);
expect(retrievedTeacher).toBeTruthy();
expect(retrievedTeacher?.firstName).toBe(firstName);
expect(retrievedTeacher?.lastName).toBe(lastName);
@ -44,8 +41,7 @@ describe('TeacherRepository', () => {
it('should no longer return the queried teacher after he was removed again', async () => {
await teacherRepository.deleteByUsername('ZesdeMetaal');
const retrievedTeacher =
await teacherRepository.findByUsername('ZesdeMetaal');
const retrievedTeacher = await teacherRepository.findByUsername('ZesdeMetaal');
expect(retrievedTeacher).toBeNull();
});
});

View file

@ -31,11 +31,7 @@ export async function setupTestApp() {
assignments[0].groups = groups.slice(0, 3);
assignments[1].groups = groups.slice(3, 4);
const teacherInvitations = makeTestTeacherInvitations(
em,
teachers,
classes
);
const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes);
const classJoinRequests = makeTestClassJoinRequests(em, students, classes);
const attachments = makeTestAttachments(em, learningObjects);

View file

@ -3,10 +3,7 @@ import { Assignment } from '../../../src/entities/assignments/assignment.entity'
import { Class } from '../../../src/entities/classes/class.entity';
import { Language } from '../../../src/entities/content/language';
export function makeTestAssignemnts(
em: EntityManager<IDatabaseDriver<Connection>>,
classes: Array<Class>
): Array<Assignment> {
export function makeTestAssignemnts(em: EntityManager<IDatabaseDriver<Connection>>, classes: Array<Class>): Array<Assignment> {
const assignment01 = em.create(Assignment, {
within: classes[0],
id: 1,

View file

@ -61,11 +61,5 @@ export function makeTestSubmissions(
content: '',
});
return [
submission01,
submission02,
submission03,
submission04,
submission05,
];
return [submission01, submission02, submission03, submission04, submission05];
}

View file

@ -1,8 +1,5 @@
import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core';
import {
ClassJoinRequest,
ClassJoinRequestStatus,
} from '../../../src/entities/classes/class-join-request.entity';
import { ClassJoinRequest, ClassJoinRequestStatus } from '../../../src/entities/classes/class-join-request.entity';
import { Student } from '../../../src/entities/users/student.entity';
import { Class } from '../../../src/entities/classes/class.entity';
@ -35,10 +32,5 @@ export function makeTestClassJoinRequests(
status: ClassJoinRequestStatus.Open,
});
return [
classJoinRequest01,
classJoinRequest02,
classJoinRequest03,
classJoinRequest04,
];
return [classJoinRequest01, classJoinRequest02, classJoinRequest03, classJoinRequest04];
}

View file

@ -3,11 +3,7 @@ import { Class } from '../../../src/entities/classes/class.entity';
import { Student } from '../../../src/entities/users/student.entity';
import { Teacher } from '../../../src/entities/users/teacher.entity';
export function makeTestClasses(
em: EntityManager<IDatabaseDriver<Connection>>,
students: Array<Student>,
teachers: Array<Teacher>
): Array<Class> {
export function makeTestClasses(em: EntityManager<IDatabaseDriver<Connection>>, students: Array<Student>, teachers: Array<Teacher>): Array<Class> {
const studentsClass01 = students.slice(0, 7);
const teacherClass01: Array<Teacher> = teachers.slice(0, 1);
@ -18,9 +14,7 @@ export function makeTestClasses(
students: studentsClass01,
});
const studentsClass02: Array<Student> = students
.slice(0, 2)
.concat(students.slice(3, 4));
const studentsClass02: Array<Student> = students.slice(0, 2).concat(students.slice(3, 4));
const teacherClass02: Array<Teacher> = teachers.slice(1, 2);
const class02 = em.create(Class, {

View file

@ -32,10 +32,5 @@ export function makeTestTeacherInvitations(
class: classes[0],
});
return [
teacherInvitation01,
teacherInvitation02,
teacherInvitation03,
teacherInvitation04,
];
return [teacherInvitation01, teacherInvitation02, teacherInvitation03, teacherInvitation04];
}

View file

@ -2,10 +2,7 @@ import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core';
import { Attachment } from '../../../src/entities/content/attachment.entity';
import { LearningObject } from '../../../src/entities/content/learning-object.entity';
export function makeTestAttachments(
em: EntityManager<IDatabaseDriver<Connection>>,
learningObjects: Array<LearningObject>
): Array<Attachment> {
export function makeTestAttachments(em: EntityManager<IDatabaseDriver<Connection>>, learningObjects: Array<LearningObject>): Array<Attachment> {
const attachment01 = em.create(Attachment, {
learningObject: learningObjects[1],
name: 'attachment01',

View file

@ -3,9 +3,7 @@ import { LearningObject, ReturnValue } from '../../../src/entities/content/learn
import { Language } from '../../../src/entities/content/language';
import { DwengoContentType } from '../../../src/services/learning-objects/processing/content-type';
export function makeTestLearningObjects(
em: EntityManager<IDatabaseDriver<Connection>>
): Array<LearningObject> {
export function makeTestLearningObjects(em: EntityManager<IDatabaseDriver<Connection>>): Array<LearningObject> {
const returnValue: ReturnValue = new ReturnValue();
returnValue.callbackSchema = '';
returnValue.callbackUrl = '';
@ -29,9 +27,7 @@ export function makeTestLearningObjects(
available: true,
contentLocation: '',
attachments: [],
content: Buffer.from(
"there's a shadow just behind me, shrouding every step i take, making every promise empty pointing every finger at me"
)
content: Buffer.from("there's a shadow just behind me, shrouding every step i take, making every promise empty pointing every finger at me"),
});
const learningObject02 = em.create(LearningObject, {
@ -131,16 +127,8 @@ export function makeTestLearningObjects(
available: true,
contentLocation: '',
attachments: [],
content: Buffer.from(
'calling Elvis, is anybody home, calling elvis, I am here all alone'
),
content: Buffer.from('calling Elvis, is anybody home, calling elvis, I am here all alone'),
});
return [
learningObject01,
learningObject02,
learningObject03,
learningObject04,
learningObject05,
];
return [learningObject01, learningObject02, learningObject03, learningObject04, learningObject05];
}

View file

@ -1,14 +1,10 @@
import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core';
import {
LearningPath,
} from '../../../src/entities/content/learning-path.entity';
import { LearningPath } from '../../../src/entities/content/learning-path.entity';
import { Language } from '../../../src/entities/content/language';
import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity';
import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity';
export function makeTestLearningPaths(
em: EntityManager<IDatabaseDriver<Connection>>
): Array<LearningPath> {
export function makeTestLearningPaths(em: EntityManager<IDatabaseDriver<Connection>>): Array<LearningPath> {
const learningPathNode01: LearningPathNode = new LearningPathNode();
const learningPathNode02: LearningPathNode = new LearningPathNode();
const learningPathNode03: LearningPathNode = new LearningPathNode();

View file

@ -3,11 +3,7 @@ import { Answer } from '../../../src/entities/questions/answer.entity';
import { Teacher } from '../../../src/entities/users/teacher.entity';
import { Question } from '../../../src/entities/questions/question.entity';
export function makeTestAnswers(
em: EntityManager<IDatabaseDriver<Connection>>,
teachers: Array<Teacher>,
questions: Array<Question>
): Array<Answer> {
export function makeTestAnswers(em: EntityManager<IDatabaseDriver<Connection>>, teachers: Array<Teacher>, questions: Array<Question>): Array<Answer> {
const answer01 = em.create(Answer, {
author: teachers[0],
toQuestion: questions[1],

View file

@ -3,10 +3,7 @@ import { Question } from '../../../src/entities/questions/question.entity';
import { Language } from '../../../src/entities/content/language';
import { Student } from '../../../src/entities/users/student.entity';
export function makeTestQuestions(
em: EntityManager<IDatabaseDriver<Connection>>,
students: Array<Student>
): Array<Question> {
export function makeTestQuestions(em: EntityManager<IDatabaseDriver<Connection>>, students: Array<Student>): Array<Question> {
const question01 = em.create(Question, {
learningObjectLanguage: Language.English,
learningObjectVersion: '1',

View file

@ -1,9 +1,7 @@
import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core';
import { Student } from '../../../src/entities/users/student.entity';
export function makeTestStudents(
em: EntityManager<IDatabaseDriver<Connection>>
): Array<Student> {
export function makeTestStudents(em: EntityManager<IDatabaseDriver<Connection>>): Array<Student> {
const student01 = em.create(Student, {
username: 'Noordkaap',
firstName: 'Stijn',
@ -47,13 +45,5 @@ export function makeTestStudents(
lastName: 'Cobain',
});
return [
student01,
student02,
student03,
student04,
student05,
student06,
student07,
];
return [student01, student02, student03, student04, student05, student06, student07];
}

View file

@ -1,9 +1,7 @@
import { Teacher } from '../../../src/entities/users/teacher.entity';
import { Connection, EntityManager, IDatabaseDriver } from '@mikro-orm/core';
export function makeTestTeachers(
em: EntityManager<IDatabaseDriver<Connection>>
): Array<Teacher> {
export function makeTestTeachers(em: EntityManager<IDatabaseDriver<Connection>>): Array<Teacher> {
const teacher01 = em.create(Teacher, {
username: 'FooFighters',
firstName: 'Dave',

View file

@ -2,10 +2,10 @@
import { ref } from "vue";
import { useRoute } from "vue-router";
import dwengoLogo from "../../../assets/img/dwengo-groen-zwart.svg";
import {useI18n} from "vue-i18n";
import { useI18n } from "vue-i18n";
const route = useRoute();
const { t, locale } = useI18n()
const { t, locale } = useI18n();
// Instantiate variables to use in html to render right
// Links and content dependent on the role (student or teacher)
@ -30,7 +30,7 @@
// Logic to change the language of the website to the selected language
const changeLanguage = (langCode: string) => {
locale.value = langCode;
localStorage.setItem('user-lang', langCode);
localStorage.setItem("user-lang", langCode);
console.log(langCode);
};
</script>
@ -59,22 +59,22 @@
:to="`/${role}/${userId}/assignment`"
class="menu_item"
>
{{ t('assignments') }}
{{ t("assignments") }}
</router-link>
</li>
<li>
<router-link
:to="`/${role}/${userId}/class`"
class="menu_item"
>{{ t('classes') }}</router-link
>{{ t("classes") }}</router-link
>
</li>
<li>
<router-link
:to="`/${role}/${userId}/discussion`"
class="menu_item"
>{{ t('discussions') }} </router-link
>
>{{ t("discussions") }}
</router-link>
</li>
<li>
<v-menu open-on-hover>

View file

@ -1,4 +1,4 @@
import { createI18n } from 'vue-i18n';
import { createI18n } from "vue-i18n";
// Import translations
import en from "@/i18n/locale/en.json";
@ -6,11 +6,11 @@ import nl from "@/i18n/locale/nl.json";
import fr from "@/i18n/locale/fr.json";
import de from "@/i18n/locale/de.json";
const savedLocale = localStorage.getItem('user-lang') || 'en';
const savedLocale = localStorage.getItem("user-lang") || "en";
const i18n = createI18n({
locale: savedLocale,
fallbackLocale: 'en',
fallbackLocale: "en",
messages: {
en: en,
nl: nl,

View file

@ -1,8 +1,8 @@
import {createApp} from "vue";
import { createApp } from "vue";
// Vuetify
import "vuetify/styles";
import {createVuetify} from "vuetify";
import { createVuetify } from "vuetify";
import * as components from "vuetify/components";
import * as directives from "vuetify/directives";
import i18n from "./i18n/i18n.ts";
@ -11,7 +11,6 @@ import i18n from "./i18n/i18n.ts";
import App from "./App.vue";
import router from "./router";
const app = createApp(App);
app.use(router);