feat(backend): Vragen kunnen nu per leerobject, assignment en optioneel groepslid opgevraagd worden
This commit is contained in:
parent
64fd66a1de
commit
c863dc627f
7 changed files with 181 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
getAnswerRepository,
|
||||
getAnswerRepository, getAssignmentRepository,
|
||||
getClassRepository,
|
||||
getGroupRepository,
|
||||
getQuestionRepository
|
||||
|
@ -13,8 +13,27 @@ import { LearningObjectIdentifier } from '../entities/content/learning-object-id
|
|||
import { mapToStudent } from '../interfaces/student.js';
|
||||
import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question';
|
||||
import { AnswerDTO, AnswerId } from '@dwengo-1/common/interfaces/answer';
|
||||
import {AssignmentDTO} from "@dwengo-1/common/interfaces/assignment";
|
||||
import {mapToAssignment} from "../interfaces/assignment";
|
||||
import { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
|
||||
import { mapToAssignment } from "../interfaces/assignment";
|
||||
|
||||
export async function getQuestionsAboutLearningObjectInAssignment(
|
||||
loId: LearningObjectIdentifier,
|
||||
classId: string,
|
||||
assignmentId: number,
|
||||
full: boolean,
|
||||
studentUsername?: string
|
||||
): Promise<QuestionDTO[] | QuestionId[]> {
|
||||
const assignment = await getAssignmentRepository()
|
||||
.findByClassIdAndAssignmentId(classId, assignmentId);
|
||||
|
||||
const questions = await getQuestionRepository()
|
||||
.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!, studentUsername);
|
||||
|
||||
if (full)
|
||||
return questions.map(q => mapToQuestionDTO(q));
|
||||
else
|
||||
return questions.map(q => mapToQuestionDTOId(q));
|
||||
}
|
||||
|
||||
export async function getAllQuestions(id: LearningObjectIdentifier, full: boolean): Promise<QuestionDTO[] | QuestionId[]> {
|
||||
const questionRepository: QuestionRepository = getQuestionRepository();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getSubmissionRepository } from '../data/repositories.js';
|
||||
import {getAssignmentRepository, getSubmissionRepository} from '../data/repositories.js';
|
||||
import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js';
|
||||
import { mapToSubmission, mapToSubmissionDTO } from '../interfaces/submission.js';
|
||||
import { SubmissionDTO } from '@dwengo-1/common/interfaces/submission';
|
||||
|
@ -55,3 +55,24 @@ export async function deleteSubmission(
|
|||
|
||||
return submission;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the submissions made by on behalf of any group the given student is in.
|
||||
*/
|
||||
export async function getSubmissionsForLearningObjectAndAssignment(
|
||||
learningObjectHruid: string,
|
||||
language: Language,
|
||||
version: number,
|
||||
classId: string,
|
||||
assignmentId: number,
|
||||
studentUsername?: string
|
||||
): Promise<SubmissionDTO[]> {
|
||||
const loId = new LearningObjectIdentifier(learningObjectHruid, language, version);
|
||||
const assignment = await getAssignmentRepository()
|
||||
.findByClassIdAndAssignmentId(classId, assignmentId);
|
||||
|
||||
const submissions = await getSubmissionRepository()
|
||||
.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment!, studentUsername);
|
||||
|
||||
return submissions.map(s => mapToSubmissionDTO(s));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue