fix: merge + lint fixes
This commit is contained in:
parent
7f189188e8
commit
b556516359
12 changed files with 58 additions and 62 deletions
|
|
@ -1,8 +1,8 @@
|
|||
import { getAnswerRepository, getQuestionRepository } from '../data/repositories.js';
|
||||
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js';
|
||||
import {mapToQuestionDTO, mapToQuestionDTOId, QuestionDTO, QuestionId} from '../interfaces/question.js';
|
||||
import { Question } from '../entities/questions/question.entity.js';
|
||||
import { Answer } from '../entities/questions/answer.entity.js';
|
||||
import { AnswerDTO, AnswerId, mapToAnswerDTO, mapToAnswerId } from '../interfaces/answer.js';
|
||||
import { AnswerDTO, AnswerId, 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';
|
||||
|
|
@ -15,13 +15,11 @@ export async function getAllQuestions(id: LearningObjectIdentifier, full: boolea
|
|||
return [];
|
||||
}
|
||||
|
||||
const questionsDTO: QuestionDTO[] = questions.map(mapToQuestionDTO);
|
||||
|
||||
if (full) {
|
||||
return questionsDTO;
|
||||
return questions.map(mapToQuestionDTO);
|
||||
}
|
||||
|
||||
return questionsDTO.map(mapToQuestionId);
|
||||
return questions.map(mapToQuestionDTOId);
|
||||
}
|
||||
|
||||
async function fetchQuestion(questionId: QuestionId): Promise<Question | null> {
|
||||
|
|
@ -59,13 +57,11 @@ export async function getAnswersByQuestion(questionId: QuestionId, full: boolean
|
|||
return [];
|
||||
}
|
||||
|
||||
const answersDTO = answers.map(mapToAnswerDTO);
|
||||
|
||||
if (full) {
|
||||
return answersDTO;
|
||||
return answers.map(mapToAnswerDTO);
|
||||
}
|
||||
|
||||
return answersDTO.map(mapToAnswerId);
|
||||
return answers.map(mapToAnswerDTOId);
|
||||
}
|
||||
|
||||
export async function createQuestion(questionDTO: QuestionDTO): Promise<QuestionDTO | null> {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,13 @@ import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js
|
|||
import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
|
||||
import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js';
|
||||
import { getAllAssignments } from './assignments.js';
|
||||
import { mapToQuestionDTO, mapToQuestionId, QuestionDTO, QuestionId } from '../interfaces/question.js';
|
||||
import { mapToStudentRequest, mapToStudentRequestDTO } from '../interfaces/student-request.js';
|
||||
import {
|
||||
mapToQuestionDTO,
|
||||
mapToQuestionDTOId,
|
||||
QuestionDTO,
|
||||
QuestionId
|
||||
} from '../interfaces/question.js';
|
||||
import {mapToStudentRequest, mapToStudentRequestDTO, StudentRequestDTO} from '../interfaces/student-request.js';
|
||||
import { Student } from '../entities/users/student.entity.js';
|
||||
import { NotFoundException } from '../exceptions/not-found-exception.js';
|
||||
import { fetchClass } from './classes.js';
|
||||
|
|
@ -116,16 +121,14 @@ export async function getStudentQuestions(username: string, full: boolean): Prom
|
|||
const questionRepository = getQuestionRepository();
|
||||
const questions = await questionRepository.findAllByAuthor(student);
|
||||
|
||||
const questionsDTO = questions.map(mapToQuestionDTO);
|
||||
|
||||
if (full) {
|
||||
return questionsDTO;
|
||||
return questions.map(mapToQuestionDTO);
|
||||
}
|
||||
|
||||
return questionsDTO.map(mapToQuestionId);
|
||||
return questions.map(mapToQuestionDTOId);
|
||||
}
|
||||
|
||||
export async function createClassJoinRequest(username: string, classId: string) {
|
||||
export async function createClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> {
|
||||
const requestRepo = getClassJoinRequestRepository();
|
||||
|
||||
const student = await fetchStudent(username); // Throws error if student not found
|
||||
|
|
@ -136,7 +139,7 @@ export async function createClassJoinRequest(username: string, classId: string)
|
|||
return mapToStudentRequestDTO(request);
|
||||
}
|
||||
|
||||
export async function getJoinRequestsByStudent(username: string) {
|
||||
export async function getJoinRequestsByStudent(username: string): Promise<StudentRequestDTO[]> {
|
||||
const requestRepo = getClassJoinRequestRepository();
|
||||
|
||||
const student = await fetchStudent(username);
|
||||
|
|
@ -145,7 +148,7 @@ export async function getJoinRequestsByStudent(username: string) {
|
|||
return requests.map(mapToStudentRequestDTO);
|
||||
}
|
||||
|
||||
export async function getJoinRequestByStudentClass(username: string, classId: string){
|
||||
export async function getJoinRequestByStudentClass(username: string, classId: string): Promise<StudentRequestDTO>{
|
||||
const requestRepo = getClassJoinRequestRepository();
|
||||
|
||||
const student = await fetchStudent(username);
|
||||
|
|
@ -159,7 +162,7 @@ export async function getJoinRequestByStudentClass(username: string, classId: st
|
|||
return mapToStudentRequestDTO(request);
|
||||
}
|
||||
|
||||
export async function deleteClassJoinRequest(username: string, classId: string) {
|
||||
export async function deleteClassJoinRequest(username: string, classId: string): Promise<StudentRequestDTO> {
|
||||
const requestRepo = getClassJoinRequestRepository();
|
||||
|
||||
const student = await fetchStudent(username);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export async function getClassesByTeacher(username: string, full: boolean): Prom
|
|||
return classes.map((cls) => cls.id);
|
||||
}
|
||||
|
||||
export async function getStudentsByTeacher(username: string, full: boolean) {
|
||||
export async function getStudentsByTeacher(username: string, full: boolean): Promise<StudentDTO[] | string[]> {
|
||||
const classes: ClassDTO[] = await fetchClassesByTeacher(username);
|
||||
|
||||
if (!classes || classes.length === 0) {
|
||||
|
|
@ -141,7 +141,7 @@ export async function getJoinRequestsByClass(classId: string): Promise<StudentRe
|
|||
return requests.map(mapToStudentRequestDTO);
|
||||
}
|
||||
|
||||
export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted: boolean = true): Promise<StudentRequestDTO> {
|
||||
export async function updateClassJoinRequestStatus(studentUsername: string, classId: string, accepted = true): Promise<StudentRequestDTO> {
|
||||
const requestRepo: ClassJoinRequestRepository = getClassJoinRequestRepository();
|
||||
const classRepo: ClassRepository = getClassRepository();
|
||||
|
||||
|
|
|
|||
Reference in a new issue