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
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue