Merge remote-tracking branch 'origin/refactor/common' into feat/user-routes
# Conflicts: # backend/src/controllers/students.ts # backend/src/controllers/teachers.ts # backend/src/interfaces/question.ts # backend/src/services/classes.ts # backend/src/services/students.ts # backend/src/services/teachers.ts
This commit is contained in:
		
						commit
						7d8a0fcbb2
					
				
					 96 changed files with 205 additions and 153 deletions
				
			
		|  | @ -1,13 +1,12 @@ | |||
| FROM node:22 | ||||
| FROM node:22 AS build-stage | ||||
| 
 | ||||
| WORKDIR /app/dwengo | ||||
| 
 | ||||
| COPY ./backend/i18n ./i18n | ||||
| 
 | ||||
| # Install dependencies | ||||
| 
 | ||||
| COPY package*.json ./ | ||||
| COPY backend/package.json ./backend/ | ||||
| # Backend depends on common | ||||
| COPY common/package.json ./common/ | ||||
| 
 | ||||
| RUN npm install --silent | ||||
|  | @ -15,14 +14,37 @@ RUN npm install --silent | |||
| # Build the backend | ||||
| 
 | ||||
| # Root tsconfig.json | ||||
| COPY tsconfig.json ./ | ||||
| COPY tsconfig.json tsconfig.build.json ./ | ||||
| 
 | ||||
| COPY backend ./backend | ||||
| COPY common ./common | ||||
| COPY docs ./docs | ||||
| 
 | ||||
| RUN npm run build --workspace=common | ||||
| RUN npm run build --workspace=backend | ||||
| RUN npm run build | ||||
| 
 | ||||
| FROM node:22 AS production-stage | ||||
| 
 | ||||
| WORKDIR /app/dwengo | ||||
| 
 | ||||
| # Copy static files | ||||
| 
 | ||||
| COPY ./backend/i18n ./i18n | ||||
| 
 | ||||
| # Copy built files | ||||
| 
 | ||||
| COPY --from=build-stage /app/dwengo/common/dist ./common/dist | ||||
| COPY --from=build-stage /app/dwengo/backend/dist ./backend/dist | ||||
| 
 | ||||
| COPY package*.json ./ | ||||
| COPY backend/package.json ./backend/ | ||||
| # Backend depends on common | ||||
| COPY common/package.json ./common/ | ||||
| 
 | ||||
| RUN npm install --silent --only=production | ||||
| 
 | ||||
| COPY ./docs ./docs | ||||
| COPY ./backend/i18n ./backend/i18n | ||||
| COPY ./backend/.env ./backend/.env | ||||
| 
 | ||||
| EXPOSE 3000 | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +0,0 @@ | |||
| // Can be placed in dotenv but found it redundant
 | ||||
| // Import dotenv from "dotenv";
 | ||||
| // Load .env file
 | ||||
| // Dotenv.config();
 | ||||
| export const DWENGO_API_BASE = 'https://dwengo.org/backend/api'; | ||||
| export const FALLBACK_LANG = 'nl'; | ||||
| export const FALLBACK_SEQ_NUM = 1; | ||||
|  | @ -1,11 +1,12 @@ | |||
| { | ||||
|     "name": "dwengo-1-backend", | ||||
|     "name": "@dwengo-1/backend", | ||||
|     "version": "0.1.1", | ||||
|     "description": "Backend for Dwengo-1", | ||||
|     "private": true, | ||||
|     "type": "module", | ||||
|     "main": "dist/app.js", | ||||
|     "scripts": { | ||||
|         "build": "cross-env NODE_ENV=production tsc --project tsconfig.json", | ||||
|         "build": "cross-env NODE_ENV=production tsc --build", | ||||
|         "dev": "cross-env NODE_ENV=development tsx watch --env-file=.env.development.local src/app.ts", | ||||
|         "start": "cross-env NODE_ENV=production node --env-file=.env dist/app.js", | ||||
|         "format": "prettier --write src/", | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmissions } from '../services/assignments.js'; | ||||
| 
 | ||||
| import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| 
 | ||||
| // Typescript is annoying with parameter forwarding from class.ts
 | ||||
| interface AssignmentParams { | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { createClass, getAllClasses, getClass, getClassStudents, getClassStudentsIds, getClassTeacherInvitations } from '../services/classes.js'; | ||||
| 
 | ||||
| import { ClassDTO } from 'dwengo-1-common/src/interfaces/class'; | ||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| 
 | ||||
| export async function getAllClassesHandler(req: Request, res: Response): Promise<void> { | ||||
|     const full = req.query.full === 'true'; | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { createGroup, getAllGroups, getGroup, getGroupSubmissions } from '../services/groups.js'; | ||||
| 
 | ||||
| import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; | ||||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| 
 | ||||
| // Typescript is annoywith with parameter forwarding from class.ts
 | ||||
| interface GroupParams { | ||||
|  |  | |||
|  | @ -2,11 +2,11 @@ import { Request, Response } from 'express'; | |||
| import { FALLBACK_LANG } from '../config.js'; | ||||
| import learningObjectService from '../services/learning-objects/learning-object-service.js'; | ||||
| import { envVars, getEnvVar } from '../util/envVars.js'; | ||||
| import { Language } from '../entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import attachmentService from '../services/learning-objects/attachment-service.js'; | ||||
| import { NotFoundError } from '@mikro-orm/core'; | ||||
| import { BadRequestException } from '../exceptions/bad-request-exception.js'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| function getLearningObjectIdentifierFromRequest(req: Request): LearningObjectIdentifier { | ||||
|     if (!req.params.hruid) { | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { Request, Response } from 'express'; | |||
| import { themes } from '../data/themes.js'; | ||||
| import { FALLBACK_LANG } from '../config.js'; | ||||
| import learningPathService from '../services/learning-paths/learning-path-service.js'; | ||||
| import { Language } from '../entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { | ||||
|     PersonalizationTarget, | ||||
|     personalizedForGroup, | ||||
|  |  | |||
|  | @ -2,8 +2,8 @@ import { Request, Response } from 'express'; | |||
| import { createQuestion, deleteQuestion, getAllQuestions, getAnswersByQuestion, getQuestion } from '../services/questions.js'; | ||||
| import { FALLBACK_LANG, FALLBACK_SEQ_NUM } from '../config.js'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; | ||||
| import { Language } from '../entities/content/language.js'; | ||||
| import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| function getObjectId(req: Request, res: Response): LearningObjectIdentifier | null { | ||||
|     const { hruid, version } = req.params; | ||||
|  |  | |||
|  | @ -1,8 +1,7 @@ | |||
| import { Request, Response } from 'express'; | ||||
| import { createSubmission, deleteSubmission, getSubmission } from '../services/submissions.js'; | ||||
| import { Language, languageMap } from '../entities/content/language.js'; | ||||
| 
 | ||||
| import { SubmissionDTO } from 'dwengo-1-common/src/interfaces/submission'; | ||||
| import { SubmissionDTO } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { Language, languageMap } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| interface SubmissionParams { | ||||
|     hruid: string; | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | ||||
| import { Attachment } from '../../entities/content/attachment.entity.js'; | ||||
| import { Language } from '../../entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier'; | ||||
| 
 | ||||
| export class AttachmentRepository extends DwengoEntityRepository<Attachment> { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | ||||
| import { LearningObject } from '../../entities/content/learning-object.entity.js'; | ||||
| import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; | ||||
| import { Language } from '../../entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Teacher } from '../../entities/users/teacher.entity.js'; | ||||
| 
 | ||||
| export class LearningObjectRepository extends DwengoEntityRepository<LearningObject> { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; | ||||
| import { LearningPath } from '../../entities/content/learning-path.entity.js'; | ||||
| import { Language } from '../../entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| export class LearningPathRepository extends DwengoEntityRepository<LearningPath> { | ||||
|     public async findByHruidAndLanguage(hruid: string, language: Language): Promise<LearningPath | null> { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; | ||||
| import { Class } from '../classes/class.entity.js'; | ||||
| import { Group } from './group.entity.js'; | ||||
| import { Language } from '../content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; | ||||
| 
 | ||||
| @Entity({ | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { Student } from '../users/student.entity.js'; | ||||
| import { Group } from './group.entity.js'; | ||||
| import { Entity, Enum, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; | ||||
| import { Language } from '../content/language.js'; | ||||
| import { SubmissionRepository } from '../../data/assignments/submission-repository.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| @Entity({ repository: () => SubmissionRepository }) | ||||
| export class Submission { | ||||
|  |  | |||
|  | @ -2,12 +2,7 @@ import { Entity, Enum, ManyToOne } from '@mikro-orm/core'; | |||
| import { Student } from '../users/student.entity.js'; | ||||
| import { Class } from './class.entity.js'; | ||||
| import { ClassJoinRequestRepository } from '../../data/classes/class-join-request-repository.js'; | ||||
| 
 | ||||
| export enum ClassJoinRequestStatus { | ||||
|     Open = 'open', | ||||
|     Accepted = 'accepted', | ||||
|     Declined = 'declined', | ||||
| } | ||||
| import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| @Entity({ | ||||
|     repository: () => ClassJoinRequestRepository, | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { Language } from './language.js'; | ||||
| import { Language } from "@dwengo-1/common/util/language"; | ||||
| 
 | ||||
| export class LearningObjectIdentifier { | ||||
|     constructor( | ||||
|  |  | |||
|  | @ -5,8 +5,8 @@ import { DwengoContentType } from '../../services/learning-objects/processing/co | |||
| import { v4 } from 'uuid'; | ||||
| import { LearningObjectRepository } from '../../data/content/learning-object-repository.js'; | ||||
| import { EducationalGoal } from './educational-goal.entity.js'; | ||||
| import { Language } from './language.js'; | ||||
| import { ReturnValue } from './return-value.entity.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| @Entity({ repository: () => LearningObjectRepository }) | ||||
| export class LearningObject { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property, Rel } from '@mikro-orm/core'; | ||||
| import { Language } from './language.js'; | ||||
| import { LearningPath } from './learning-path.entity.js'; | ||||
| import { LearningPathTransition } from './learning-path-transition.entity.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| @Entity() | ||||
| export class LearningPathNode { | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { Entity, Enum, ManyToMany, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; | ||||
| import { Language } from './language.js'; | ||||
| import { Teacher } from '../users/teacher.entity.js'; | ||||
| import { LearningPathRepository } from '../../data/content/learning-path-repository.js'; | ||||
| import { LearningPathNode } from './learning-path-node.entity.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| @Entity({ repository: () => LearningPathRepository }) | ||||
| export class LearningPath { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Entity, Enum, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'; | ||||
| import { Language } from '../content/language.js'; | ||||
| import { Student } from '../users/student.entity.js'; | ||||
| import { QuestionRepository } from '../../data/questions/question-repository.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| @Entity({ repository: () => QuestionRepository }) | ||||
| export class Question { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { mapToUserDTO } from './user.js'; | ||||
| import { mapToQuestionDTO, mapToQuestionDTOId } from './question.js'; | ||||
| import { Answer } from '../entities/questions/answer.entity.js'; | ||||
| import { AnswerDTO, AnswerId } from 'dwengo-1-common/src/interfaces/answer'; | ||||
| import { AnswerDTO, AnswerId } from '@dwengo-1/common/interfaces/answer'; | ||||
| 
 | ||||
| /** | ||||
|  * Convert a Question entity to a DTO format. | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import { languageMap } from '@dwengo-1/common/util/language'; | ||||
| import { FALLBACK_LANG } from '../config.js'; | ||||
| import { Assignment } from '../entities/assignments/assignment.entity.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { languageMap } from '../entities/content/language.js'; | ||||
| import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| 
 | ||||
| export function mapToAssignmentDTOId(assignment: Assignment): AssignmentDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { Collection } from '@mikro-orm/core'; | |||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { ClassDTO } from 'dwengo-1-common/src/interfaces/class'; | ||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| 
 | ||||
| export function mapToClassDTO(cls: Class): ClassDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| import { mapToAssignmentDTO } from './assignment.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; | ||||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| 
 | ||||
| export function mapToGroupDTO(group: Group): GroupDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { Question } from '../entities/questions/question.entity.js'; | ||||
| import { mapToStudentDTO } from './student.js'; | ||||
| import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| 
 | ||||
| function getLearningObjectIdentifier(question: Question): LearningObjectIdentifier { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { Student } from '../entities/users/student.entity.js'; | ||||
| import { getStudentRepository } from '../data/repositories.js'; | ||||
| import { StudentDTO } from 'dwengo-1-common/src/interfaces/student'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| 
 | ||||
| export function mapToStudentDTO(student: Student): StudentDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { Submission } from '../entities/assignments/submission.entity.js'; | ||||
| import { mapToGroupDTO } from './group.js'; | ||||
| import { mapToStudent, mapToStudentDTO } from './student.js'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from 'dwengo-1-common/src/interfaces/submission'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| 
 | ||||
| export function mapToSubmissionDTO(submission: Submission): SubmissionDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { TeacherInvitation } from '../entities/classes/teacher-invitation.entity.js'; | ||||
| import { mapToClassDTO } from './class.js'; | ||||
| import { mapToUserDTO } from './user.js'; | ||||
| import { TeacherInvitationDTO } from 'dwengo-1-common/src/interfaces/teacher-invitation'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| 
 | ||||
| export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): TeacherInvitationDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { Teacher } from '../entities/users/teacher.entity.js'; | ||||
| import { getTeacherRepository } from '../data/repositories.js'; | ||||
| import { TeacherDTO } from 'dwengo-1-common/src/interfaces/teacher'; | ||||
| import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||
| 
 | ||||
| export function mapToTeacherDTO(teacher: Teacher): TeacherDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { User } from '../entities/users/user.entity.js'; | ||||
| import { UserDTO } from 'dwengo-1-common/src/interfaces/user'; | ||||
| import { UserDTO } from '@dwengo-1/common/interfaces/user'; | ||||
| 
 | ||||
| export function mapToUserDTO(user: User): UserDTO { | ||||
|     return { | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { getAssignmentRepository, getClassRepository, getGroupRepository, getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { mapToAssignment, mapToAssignmentDTO, mapToAssignmentDTOId } from '../interfaces/assignment.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from 'dwengo-1-common/src/interfaces/submission'; | ||||
| import { AssignmentDTO } from '@dwengo-1/common/interfaces/assignment'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| 
 | ||||
| export async function getAllAssignments(classid: string, full: boolean): Promise<AssignmentDTO[]> { | ||||
|  |  | |||
|  | @ -5,9 +5,9 @@ import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds } from '../inte | |||
| import { getLogger } from '../logging/initalize.js'; | ||||
| import { NotFoundException } from '../exceptions/not-found-exception.js'; | ||||
| import { Class } from '../entities/classes/class.entity.js'; | ||||
| import { ClassDTO } from 'dwengo-1-common/src/interfaces/class'; | ||||
| import { TeacherInvitationDTO } from 'dwengo-1-common/src/interfaces/teacher-invitation'; | ||||
| import { StudentDTO } from 'dwengo-1-common/src/interfaces/student'; | ||||
| import { ClassDTO } from '@dwengo-1/common/interfaces/class'; | ||||
| import { TeacherInvitationDTO } from '@dwengo-1/common/interfaces/teacher-invitation'; | ||||
| import { StudentDTO } from '@dwengo-1/common/interfaces/student'; | ||||
| 
 | ||||
| const logger = getLogger(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -8,8 +8,8 @@ import { | |||
| import { Group } from '../entities/assignments/group.entity.js'; | ||||
| import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; | ||||
| import { mapToSubmissionDTO, mapToSubmissionDTOId } from '../interfaces/submission.js'; | ||||
| import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from 'dwengo-1-common/src/interfaces/submission'; | ||||
| import { GroupDTO } from '@dwengo-1/common/interfaces/group'; | ||||
| import { SubmissionDTO, SubmissionDTOId } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| 
 | ||||
| export async function getGroup(classId: string, assignmentNumber: number, groupNumber: number, full: boolean): Promise<GroupDTO | null> { | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import { | |||
|     LearningObjectMetadata, | ||||
|     LearningObjectNode, | ||||
|     LearningPathResponse, | ||||
| } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { getLogger } from '../logging/initalize.js'; | ||||
| 
 | ||||
| function filterData(data: LearningObjectMetadata, htmlUrl: string): FilteredLearningObject { | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { getAttachmentRepository } from '../../data/repositories.js'; | ||||
| import { Attachment } from '../../entities/content/attachment.entity.js'; | ||||
| 
 | ||||
| import { LearningObjectIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| const attachmentService = { | ||||
|     async getAttachment(learningObjectId: LearningObjectIdentifier, attachmentName: string): Promise<Attachment | null> { | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ import processingService from './processing/processing-service.js'; | |||
| import { NotFoundError } from '@mikro-orm/core'; | ||||
| import learningObjectService from './learning-object-service.js'; | ||||
| import { getLogger, Logger } from '../../logging/initalize.js'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,7 +10,7 @@ import { | |||
|     LearningObjectNode, | ||||
|     LearningPathIdentifier, | ||||
|     LearningPathResponse, | ||||
| } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
|  | @ -66,12 +66,13 @@ async function fetchLearningObjects(learningPathId: LearningPathIdentifier, full | |||
|         } | ||||
| 
 | ||||
|         const objects = await Promise.all( | ||||
|             nodes.map(async (node) => | ||||
|                 dwengoApiLearningObjectProvider.getLearningObjectById({ | ||||
|             nodes.map(async (node) => { | ||||
|                 const learningObjectId: LearningObjectIdentifier = { | ||||
|                     hruid: node.learningobject_hruid, | ||||
|                     language: learningPathId.language, | ||||
|                     language: learningPathId.language | ||||
|                 }; | ||||
|                 return dwengoApiLearningObjectProvider.getLearningObjectById(learningObjectId); | ||||
|             }) | ||||
|             ) | ||||
|         ); | ||||
|         return objects.filter((obj): obj is FilteredLearningObject => obj !== null); | ||||
|     } catch (error) { | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| export interface LearningObjectProvider { | ||||
|     /** | ||||
|  |  | |||
|  | @ -2,7 +2,11 @@ import dwengoApiLearningObjectProvider from './dwengo-api-learning-object-provid | |||
| import { LearningObjectProvider } from './learning-object-provider.js'; | ||||
| import { envVars, getEnvVar } from '../../util/envVars.js'; | ||||
| import databaseLearningObjectProvider from './database-learning-object-provider.js'; | ||||
| import { FilteredLearningObject, LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { | ||||
|     FilteredLearningObject, | ||||
|     LearningObjectIdentifier, | ||||
|     LearningPathIdentifier, | ||||
| } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| function getProvider(id: LearningObjectIdentifier): LearningObjectProvider { | ||||
|     if (id.hruid.startsWith(getEnvVar(envVars.UserContentPrefix))) { | ||||
|  |  | |||
|  | @ -8,13 +8,12 @@ import InlineImageProcessor from '../image/inline-image-processor.js'; | |||
| import * as marked from 'marked'; | ||||
| import { getUrlStringForLearningObjectHTML, isValidHttpUrl } from '../../../../util/links.js'; | ||||
| import { ProcessingError } from '../processing-error.js'; | ||||
| import { Language } from '../../../../entities/content/language.js'; | ||||
| 
 | ||||
| import Image = marked.Tokens.Image; | ||||
| import Heading = marked.Tokens.Heading; | ||||
| import Link = marked.Tokens.Link; | ||||
| import RendererObject = marked.RendererObject; | ||||
| import { LearningObjectIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const prefixes = { | ||||
|     learningObject: '@learning-object', | ||||
|  |  | |||
|  | @ -13,9 +13,9 @@ import GiftProcessor from './gift/gift-processor.js'; | |||
| import { LearningObject } from '../../../entities/content/learning-object.entity.js'; | ||||
| import Processor from './processor.js'; | ||||
| import { DwengoContentType } from './content-type.js'; | ||||
| import { Language } from '../../../entities/content/language.js'; | ||||
| import { replaceAsync } from '../../../util/async.js'; | ||||
| import { LearningObjectIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const EMBEDDED_LEARNING_OBJECT_PLACEHOLDER = /<learning-object hruid="([^"]+)" language="([^"]+)" version="([^"]+)"\/>/g; | ||||
| const LEARNING_OBJECT_DOES_NOT_EXIST = "<div class='non-existing-learning-object' />"; | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| import { LearningPathProvider } from './learning-path-provider.js'; | ||||
| import { LearningPath as LearningPathEntity } from '../../entities/content/learning-path.entity.js'; | ||||
| import { getLearningPathRepository } from '../../data/repositories.js'; | ||||
| import { Language } from '../../entities/content/language.js'; | ||||
| import learningObjectService from '../learning-objects/learning-object-service.js'; | ||||
| import { LearningPathNode } from '../../entities/content/learning-path-node.entity.js'; | ||||
| import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity.js'; | ||||
|  | @ -12,7 +11,8 @@ import { | |||
|     LearningPath, | ||||
|     LearningPathResponse, | ||||
|     Transition, | ||||
| } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| /** | ||||
|  * Fetches the corresponding learning object for each of the nodes and creates a map that maps each node to its | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { fetchWithLogging } from '../../util/api-helper.js'; | |||
| import { DWENGO_API_BASE } from '../../config.js'; | ||||
| import { LearningPathProvider } from './learning-path-provider.js'; | ||||
| import { getLogger, Logger } from '../../logging/initalize.js'; | ||||
| import { LearningPath, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningPath, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| const logger: Logger = getLogger(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { Language } from '../../entities/content/language.js'; | ||||
| import { LearningPath, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { PersonalizationTarget } from './learning-path-personalization-util.js'; | ||||
| import { LearningPath, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| /** | ||||
|  * Generic interface for a service which provides access to learning paths from a data source. | ||||
|  |  | |||
|  | @ -1,9 +1,9 @@ | |||
| import dwengoApiLearningPathProvider from './dwengo-api-learning-path-provider.js'; | ||||
| import databaseLearningPathProvider from './database-learning-path-provider.js'; | ||||
| import { envVars, getEnvVar } from '../../util/envVars.js'; | ||||
| import { Language } from '../../entities/content/language.js'; | ||||
| import { PersonalizationTarget } from './learning-path-personalization-util.js'; | ||||
| import { LearningPath, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningPath, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const userContentPrefix = getEnvVar(envVars.UserContentPrefix); | ||||
| const allProviders = [dwengoApiLearningPathProvider, databaseLearningPathProvider]; | ||||
|  |  | |||
|  | @ -6,8 +6,8 @@ import { mapToAnswerDTO, mapToAnswerDTOId } from '../interfaces/answer.js'; | |||
| import { QuestionRepository } from '../data/questions/question-repository.js'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; | ||||
| import { mapToStudent } from '../interfaces/student.js'; | ||||
| import { QuestionDTO, QuestionId } from 'dwengo-1-common/src/interfaces/question'; | ||||
| import { AnswerDTO, AnswerId } from 'dwengo-1-common/src/interfaces/answer'; | ||||
| import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; | ||||
| import { AnswerDTO, AnswerId } from '@dwengo-1/common/interfaces/answer'; | ||||
| 
 | ||||
| export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise<QuestionDTO[] | QuestionId[]> { | ||||
|     const questionRepository: QuestionRepository = getQuestionRepository(); | ||||
|  | @ -71,9 +71,14 @@ export async function createQuestion(questionDTO: QuestionDTO): Promise<Question | |||
| 
 | ||||
|     const author = mapToStudent(questionDTO.author); | ||||
| 
 | ||||
|     const loId: LearningObjectIdentifier = { | ||||
|         ...questionDTO.learningObjectIdentifier, | ||||
|         version: questionDTO.learningObjectIdentifier.version ?? 1, | ||||
|     } | ||||
| 
 | ||||
|     try { | ||||
|         await questionRepository.createQuestion({ | ||||
|             loId: questionDTO.learningObjectIdentifier, | ||||
|             loId, | ||||
|             author, | ||||
|             content: questionDTO.content, | ||||
|         }); | ||||
|  | @ -93,8 +98,13 @@ export async function deleteQuestion(questionId: QuestionId): Promise<QuestionDT | |||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     const loId : LearningObjectIdentifier = { | ||||
|         ...questionId.learningObjectIdentifier, | ||||
|         version: questionId.learningObjectIdentifier.version ?? 1 | ||||
|     } | ||||
| 
 | ||||
|     try { | ||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(questionId.learningObjectIdentifier, questionId.sequenceNumber); | ||||
|         await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(loId, questionId.sequenceNumber); | ||||
|     } catch (_) { | ||||
|         return null; | ||||
|     } | ||||
|  |  | |||
|  | @ -1,8 +1,8 @@ | |||
| import { getSubmissionRepository } from '../data/repositories.js'; | ||||
| import { Language } from '../entities/content/language.js'; | ||||
| import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js'; | ||||
| import { mapToSubmission, mapToSubmissionDTO } from '../interfaces/submission.js'; | ||||
| import { SubmissionDTO } from 'dwengo-1-common/src/interfaces/submission'; | ||||
| import { SubmissionDTO } from '@dwengo-1/common/interfaces/submission'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| export async function getSubmission( | ||||
|     learningObjectHruid: string, | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { LearningObjectIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier } from "@dwengo-1/common/interfaces/learning-content"; | ||||
| 
 | ||||
| export function isValidHttpUrl(url: string): boolean { | ||||
|     try { | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ import { | |||
|     getSubmissionRepository, | ||||
| } from '../../../src/data/repositories'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| 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'; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { getAttachmentRepository, getLearningObjectRepository } from '../../../s | |||
| 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'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('AttachmentRepository', () => { | ||||
|     let attachmentRepository: AttachmentRepository; | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ import { LearningObjectRepository } from '../../../src/data/content/learning-obj | |||
| import { getLearningObjectRepository } from '../../../src/data/repositories'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('LearningObjectRepository', () => { | ||||
|     let learningObjectRepository: LearningObjectRepository; | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ import { LearningPathRepository } from '../../../src/data/content/learning-path- | |||
| import example from '../../test-assets/learning-paths/pn-werking-example.js'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity.js'; | ||||
| import { expectToBeCorrectEntity } from '../../test-utils/expectations.js'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| function expectToHaveFoundPrecisely(expected: LearningPath, result: LearningPath[]): void { | ||||
|     expect(result).toHaveProperty('length'); | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; | |||
| import { getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import { LearningPathRepository } from '../../../src/data/content/learning-path-repository'; | ||||
| import { setupTestApp } from '../../setup-tests'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('LearningPathRepository', () => { | ||||
|     let learningPathRepository: LearningPathRepository; | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { AnswerRepository } from '../../../src/data/questions/answer-repository' | |||
| 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'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { TeacherRepository } from '../../../src/data/users/teacher-repository'; | ||||
| 
 | ||||
| describe('AnswerRepository', () => { | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import { QuestionRepository } from '../../../src/data/questions/question-reposit | |||
| import { getQuestionRepository, 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 '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| describe('QuestionRepository', () => { | ||||
|     let questionRepository: QuestionRepository; | ||||
|  |  | |||
|  | @ -5,11 +5,11 @@ import example from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-w | |||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import databaseLearningObjectProvider from '../../../src/services/learning-objects/database-learning-object-provider'; | ||||
| import { expectToBeCorrectFilteredLearningObject } from '../../test-utils/expectations'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { FilteredLearningObject } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  | @ -37,7 +37,7 @@ describe('DatabaseLearningObjectProvider', () => { | |||
|         it('should return the learning object when it is queried by its id', async () => { | ||||
|             const result: FilteredLearningObject | null = await databaseLearningObjectProvider.getLearningObjectById(exampleLearningObject); | ||||
|             expect(result).toBeTruthy(); | ||||
|             expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject); | ||||
|             expectToBeCorrectFilteredLearningObject(result, exampleLearningObject); | ||||
|         }); | ||||
| 
 | ||||
|         it('should return the learning object when it is queried by only hruid and language (but not version)', async () => { | ||||
|  | @ -46,7 +46,7 @@ describe('DatabaseLearningObjectProvider', () => { | |||
|                 language: exampleLearningObject.language, | ||||
|             }); | ||||
|             expect(result).toBeTruthy(); | ||||
|             expectToBeCorrectFilteredLearningObject(result!, exampleLearningObject); | ||||
|             expectToBeCorrectFilteredLearningObject(result, exampleLearningObject); | ||||
|         }); | ||||
| 
 | ||||
|         it('should return null when queried with an id that does not exist', async () => { | ||||
|  |  | |||
|  | @ -4,11 +4,11 @@ import { LearningObject } from '../../../src/entities/content/learning-object.en | |||
| import { getLearningObjectRepository, getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| import { LearningObjectIdentifier, LearningPathIdentifier } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectIdentifier, LearningPathIdentifier } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const EXPECTED_DWENGO_LEARNING_OBJECT_TITLE = 'Werken met notebooks'; | ||||
| const DWENGO_TEST_LEARNING_OBJECT_ID: LearningObjectIdentifier = { | ||||
|  |  | |||
|  | @ -13,14 +13,14 @@ import learningPathExample from '../../test-assets/learning-paths/pn-werking-exa | |||
| import databaseLearningPathProvider from '../../../src/services/learning-paths/database-learning-path-provider.js'; | ||||
| import { expectToBeCorrectLearningPath } from '../../test-utils/expectations.js'; | ||||
| import learningObjectService from '../../../src/services/learning-objects/learning-object-service.js'; | ||||
| import { Language } from '../../../src/entities/content/language.js'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { | ||||
|     ConditionTestLearningPathAndLearningObjects, | ||||
|     createConditionTestLearningPathAndLearningObjects, | ||||
| } from '../../test-assets/learning-paths/test-conditions-example.js'; | ||||
| import { Student } from '../../../src/entities/users/student.entity.js'; | ||||
| 
 | ||||
| import { LearningObjectNode, LearningPathResponse } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { LearningObjectNode, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  |  | |||
|  | @ -5,8 +5,8 @@ import { LearningPath } from '../../../src/entities/content/learning-path.entity | |||
| import { getLearningObjectRepository, getLearningPathRepository } from '../../../src/data/repositories'; | ||||
| import learningObjectExample from '../../test-assets/learning-objects/pn-werkingnotebooks/pn-werkingnotebooks-example'; | ||||
| import learningPathExample from '../../test-assets/learning-paths/pn-werking-example'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import learningPathService from '../../../src/services/learning-paths/learning-path-service'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| async function initExampleData(): Promise<{ learningObject: LearningObject; learningPath: LearningPath }> { | ||||
|     const learningObjectRepo = getLearningObjectRepository(); | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningObjectExample } from '../learning-object-example'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { LearningObjectExample } from '../learning-object-example'; | |||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|  |  | |||
|  | @ -2,8 +2,8 @@ import { LearningObjectExample } from '../learning-object-example'; | |||
| import { LearningObject } from '../../../../src/entities/content/learning-object.entity'; | ||||
| import { loadTestAsset } from '../../../test-utils/load-test-asset'; | ||||
| import { envVars, getEnvVar } from '../../../../src/util/envVars'; | ||||
| import { Language } from '../../../../src/entities/content/language'; | ||||
| import { DwengoContentType } from '../../../../src/services/learning-objects/processing/content-type'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| const example: LearningObjectExample = { | ||||
|     createLearningObject: () => { | ||||
|  |  | |||
|  | @ -1,4 +1,4 @@ | |||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { envVars, getEnvVar } from '../../../src/util/envVars'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import testMultipleChoiceExample from '../learning-objects/test-multiple-choice/test-multiple-choice-example'; | ||||
| import { dummyLearningObject } from '../learning-objects/dummy/dummy-learning-object-example'; | ||||
| import { createLearningPathNode, createLearningPathTransition } from './learning-path-utils'; | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ import { AssertionError } from 'node:assert'; | |||
| import { LearningObject } from '../../src/entities/content/learning-object.entity'; | ||||
| import { LearningPath as LearningPathEntity } from '../../src/entities/content/learning-path.entity'; | ||||
| import { expect } from 'vitest'; | ||||
| import { FilteredLearningObject, LearningPath } from 'dwengo-1-common/src/interfaces/learning-content'; | ||||
| import { FilteredLearningObject, LearningPath } from '@dwengo-1/common/interfaces/learning-content'; | ||||
| 
 | ||||
| // Ignored properties because they belang for example to the class, not to the entity itself.
 | ||||
| const IGNORE_PROPERTIES = ['parent']; | ||||
|  |  | |||
|  | @ -1,7 +1,7 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Assignment } from '../../../src/entities/assignments/assignment.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| 
 | ||||
| export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] { | ||||
|     const assignment01 = em.create(Assignment, { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Submission } from '../../../src/entities/assignments/submission.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Group } from '../../../src/entities/assignments/group.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,7 +1,8 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { ClassJoinRequest, ClassJoinRequestStatus } from '../../../src/entities/classes/class-join-request.entity'; | ||||
| import { ClassJoinRequest } from '../../../src/entities/classes/class-join-request.entity'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| import { Class } from '../../../src/entities/classes/class.entity'; | ||||
| import { ClassJoinRequestStatus } from '@dwengo-1/common/util/class-join-request'; | ||||
| 
 | ||||
| export function makeTestClassJoinRequests(em: EntityManager, students: Student[], classes: Class[]): ClassJoinRequest[] { | ||||
|     const classJoinRequest01 = em.create(ClassJoinRequest, { | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { DwengoContentType } from '../../../src/services/learning-objects/processing/content-type'; | ||||
| import { ReturnValue } from '../../../src/entities/content/return-value.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { LearningPath } from '../../../src/entities/content/learning-path.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { LearningPathTransition } from '../../../src/entities/content/learning-path-transition.entity'; | ||||
| import { LearningPathNode } from '../../../src/entities/content/learning-path-node.entity'; | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,6 +1,6 @@ | |||
| import { EntityManager } from '@mikro-orm/core'; | ||||
| import { Question } from '../../../src/entities/questions/question.entity'; | ||||
| import { Language } from '../../../src/entities/content/language'; | ||||
| import { Language } from '@dwengo-1/common/util/language'; | ||||
| import { Student } from '../../../src/entities/users/student.entity'; | ||||
| 
 | ||||
| export function makeTestQuestions(em: EntityManager, students: Student[]): Question[] { | ||||
|  |  | |||
|  | @ -4,8 +4,10 @@ | |||
|     "compilerOptions": { | ||||
|         "rootDir": "./src", | ||||
|         "outDir": "./dist", | ||||
|         "resolveJsonModule": true, | ||||
|         "sourceMap": true, | ||||
|         "composite": true | ||||
|     }, | ||||
|     "references": [ | ||||
|         { | ||||
|             "path": "../common" | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|  |  | |||
|  | @ -1,16 +1,19 @@ | |||
| { | ||||
|     "name": "dwengo-1-common", | ||||
|     "name": "@dwengo-1/common", | ||||
|     "version": "0.1.1", | ||||
|     "description": "Common types and utilities for Dwengo-1", | ||||
|     "private": true, | ||||
|     "type": "module", | ||||
|     "files": [ "./dist" ], | ||||
|     "scripts": { | ||||
|         "build": "tsc --project tsconfig.json", | ||||
|         "build": "tsc --build", | ||||
|         "clean": "tsc --build --clean", | ||||
|         "watch": "tsc --build --watch", | ||||
|         "format": "prettier --write src/", | ||||
|         "format-check": "prettier --check src/", | ||||
|         "lint": "eslint . --fix" | ||||
|     }, | ||||
|     "exports": { | ||||
|         "./src/*": "./dist/*" | ||||
|         "./*": "./dist/*.js" | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| import { UserDTO } from './user'; | ||||
| import { QuestionDTO } from './question'; | ||||
| import { QuestionDTO, QuestionId } from './question'; | ||||
| 
 | ||||
| export interface AnswerDTO { | ||||
|     author: UserDTO; | ||||
|  | @ -1,4 +1,5 @@ | |||
| import { AssignmentDTO } from './assignment'; | ||||
| import { StudentDTO } from './student'; | ||||
| 
 | ||||
| export interface GroupDTO { | ||||
|     assignment: number | AssignmentDTO; | ||||
|  | @ -1,4 +1,4 @@ | |||
| import { Language } from 'dwengo-1-backend/src/entities/content/language.js'; | ||||
| import { Language } from "../util/language"; | ||||
| 
 | ||||
| export interface Transition { | ||||
|     default: boolean; | ||||
|  | @ -1,3 +1,4 @@ | |||
| import { LearningObjectIdentifier } from './learning-content'; | ||||
| import { StudentDTO } from './student'; | ||||
| 
 | ||||
| export interface QuestionDTO { | ||||
|  | @ -1,4 +1,7 @@ | |||
| import { GroupDTO } from './group'; | ||||
| import { LearningObjectIdentifier } from './learning-content'; | ||||
| import { StudentDTO } from './student'; | ||||
| import { Language } from '../util/language'; | ||||
| 
 | ||||
| export interface SubmissionDTO { | ||||
|     learningObjectIdentifier: LearningObjectIdentifier; | ||||
							
								
								
									
										5
									
								
								common/src/util/class-join-request.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								common/src/util/class-join-request.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | |||
| export enum ClassJoinRequestStatus { | ||||
|     Open = 'open', | ||||
|     Accepted = 'accepted', | ||||
|     Declined = 'declined', | ||||
| } | ||||
|  | @ -3,9 +3,6 @@ | |||
|     "include": ["src/**/*.ts"], | ||||
|     "compilerOptions": { | ||||
|         "rootDir": "./src", | ||||
|         "outDir": "./dist", | ||||
|         "resolveJsonModule": true, | ||||
|         "sourceMap": true, | ||||
|         "composite": true | ||||
|         "outDir": "./dist" | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ | |||
|         "type-check": "vue-tsc --build", | ||||
|         "format": "prettier --write src/", | ||||
|         "format-check": "prettier --check src/", | ||||
|         "lint": "eslint . --fix", | ||||
|         "lint": "eslint ./{src,tests} --fix", | ||||
|         "test:unit": "vitest --run", | ||||
|         "test:e2e": "playwright test" | ||||
|     }, | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ | |||
|         } | ||||
|     ], | ||||
|     "compilerOptions": { | ||||
|         "composite": true, | ||||
|         "resolveJsonModule": true | ||||
|     } | ||||
| } | ||||
|  |  | |||
							
								
								
									
										16
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										16
									
								
								package-lock.json
									
										
									
										generated
									
									
									
								
							|  | @ -28,7 +28,7 @@ | |||
|             } | ||||
|         }, | ||||
|         "backend": { | ||||
|             "name": "dwengo-1-backend", | ||||
|             "name": "@dwengo-1/backend", | ||||
|             "version": "0.1.1", | ||||
|             "dependencies": { | ||||
|                 "@mikro-orm/core": "6.4.9", | ||||
|  | @ -86,7 +86,7 @@ | |||
|             } | ||||
|         }, | ||||
|         "common": { | ||||
|             "name": "dwengo-1-common", | ||||
|             "name": "@dwengo-1/common", | ||||
|             "version": "0.1.1" | ||||
|         }, | ||||
|         "docs": { | ||||
|  | @ -849,6 +849,14 @@ | |||
|                 "kuler": "^2.0.0" | ||||
|             } | ||||
|         }, | ||||
|         "node_modules/@dwengo-1/backend": { | ||||
|             "resolved": "backend", | ||||
|             "link": true | ||||
|         }, | ||||
|         "node_modules/@dwengo-1/common": { | ||||
|             "resolved": "common", | ||||
|             "link": true | ||||
|         }, | ||||
|         "node_modules/@esbuild/aix-ppc64": { | ||||
|             "version": "0.25.2", | ||||
|             "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.2.tgz", | ||||
|  | @ -4921,10 +4929,6 @@ | |||
|                 "node": ">= 0.4" | ||||
|             } | ||||
|         }, | ||||
|         "node_modules/dwengo-1-backend": { | ||||
|             "resolved": "backend", | ||||
|             "link": true | ||||
|         }, | ||||
|         "node_modules/dwengo-1-common": { | ||||
|             "resolved": "common", | ||||
|             "link": true | ||||
|  |  | |||
|  | @ -1,11 +1,14 @@ | |||
| { | ||||
|     "name": "dwengo-1-monorepo", | ||||
|     "name": "dwengo-1", | ||||
|     "version": "0.1.1", | ||||
|     "description": "Monorepo for Dwengo-1", | ||||
|     "private": true, | ||||
|     "type": "module", | ||||
|     "scripts": { | ||||
|         "build": "npm run build --workspaces --if-present", | ||||
|         "prebuild": "npm run clean", | ||||
|         "build": "tsc --build tsconfig.build.json", | ||||
|         "clean": "tsc --build tsconfig.build.json --clean", | ||||
|         "watch": "tsc --build tsconfig.build.json --watch", | ||||
|         "format": "npm run format --workspace=backend --workspace=common --workspace=frontend", | ||||
|         "format-check": "npm run format-check --workspace=backend --workspace=common --workspace=frontend", | ||||
|         "lint": "npm run lint --workspace=backend --workspace=common --workspace=frontend", | ||||
|  |  | |||
							
								
								
									
										11
									
								
								tsconfig.build.json
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								tsconfig.build.json
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| { | ||||
|     "files": [], | ||||
|     "references": [ | ||||
|         { | ||||
|             "path": "./common" | ||||
|         }, | ||||
|         { | ||||
|             "path": "./backend" | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|  | @ -4,7 +4,7 @@ | |||
| 
 | ||||
|         /* Projects */ | ||||
|         // "incremental": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ | ||||
|         // "composite": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */ | ||||
|         "composite": true,                                   /* Enable constraints that allow a TypeScript project to be used with project references. */ | ||||
|         // "tsBuildInfoFile": "./.tsbuildinfo",              /* Specify the path to .tsbuildinfo incremental compilation file. */ | ||||
|         // "disableSourceOfProjectReferenceRedirect": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */ | ||||
|         // "disableSolutionSearching": true,                 /* Opt a project out of multi-project reference checking when editing. */ | ||||
|  | @ -25,7 +25,7 @@ | |||
|         // "reactNamespace": "",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ | ||||
|         // "noLib": true,                                    /* Disable including any library files, including the default lib.d.ts. */ | ||||
|         // "useDefineForClassFields": true,                  /* Emit ECMAScript-standard-compliant class fields. */ | ||||
|         "moduleDetection": "force", | ||||
|         // "moduleDetection": "force", | ||||
|         /* Control what method is used to detect module-format JS files. */ | ||||
| 
 | ||||
|         /* Modules */ | ||||
|  | @ -33,7 +33,7 @@ | |||
|         /* Specify what module code is generated. */ | ||||
|         // "rootDir": "./src", | ||||
|         /* Specify the root folder within your source files. */ | ||||
|         "moduleResolution": "node", | ||||
|         "moduleResolution": "bundler", | ||||
|         /* Specify how TypeScript looks up a file from a given module specifier. */ | ||||
|         // "baseUrl": "./",                                  /* Specify the base directory to resolve non-relative module names. */ | ||||
|         // "paths": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */ | ||||
|  | @ -53,16 +53,16 @@ | |||
|         // "noResolve": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */ | ||||
| 
 | ||||
|         /* JavaScript Support */ | ||||
|         "allowJs": true, | ||||
|         // "allowJs": true, | ||||
|         /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ | ||||
|         // "checkJs": true,                                  /* Enable error reporting in type-checked JavaScript files. */ | ||||
|         // "maxNodeModuleJsDepth": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ | ||||
| 
 | ||||
|         /* Emit */ | ||||
|         // "declaration": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ | ||||
|         // "declarationMap": true,                           /* Create sourcemaps for d.ts files. */ | ||||
|         "declaration": true,                                 /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ | ||||
|         "declarationMap": true,                              /* Create sourcemaps for d.ts files. */ | ||||
|         // "emitDeclarationOnly": true,                      /* Only output d.ts files and not JavaScript files. */ | ||||
|         // "sourceMap": true,                                /* Create source map files for emitted JavaScript files. */ | ||||
|         "sourceMap": true,                                   /* Create source map files for emitted JavaScript files. */ | ||||
|         // "inlineSourceMap": true,                          /* Include sourcemap files inside the emitted JavaScript. */ | ||||
|         // "noEmit": true,                                   /* Disable emitting files from a compilation. */ | ||||
|         // "outFile": "./",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ | ||||
|  |  | |||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl