fix: deel van linting problemen gefixt
This commit is contained in:
parent
08d8dd924c
commit
b9e71de281
18 changed files with 22 additions and 39 deletions
|
@ -1,5 +1,4 @@
|
|||
import { EnvVars, getEnvVar } from './util/envvars.js';
|
||||
import { Language } from './entities/content/language.js';
|
||||
|
||||
// API
|
||||
export const DWENGO_API_BASE = getEnvVar(EnvVars.LearningContentRepoApiBaseUrl);
|
||||
|
|
|
@ -10,7 +10,6 @@ import {
|
|||
getStudentSubmissions,
|
||||
} from '../services/students.js';
|
||||
import { StudentDTO } from '../interfaces/student.js';
|
||||
import { getStudentRepository } from '../data/repositories.js';
|
||||
|
||||
// TODO: accept arguments (full, ...)
|
||||
// TODO: endpoints
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
getTeacher,
|
||||
} from '../services/teachers.js';
|
||||
import { TeacherDTO } from '../interfaces/teacher.js';
|
||||
import { getTeacherRepository } from '../data/repositories.js';
|
||||
|
||||
export async function getAllTeachersHandler(req: Request, res: Response): Promise<void> {
|
||||
const full = req.query.full === 'true';
|
||||
|
|
|
@ -2,8 +2,6 @@ import { AnyEntity, EntityManager, EntityName, EntityRepository } from '@mikro-o
|
|||
import { forkEntityManager } from '../orm.js';
|
||||
import { StudentRepository } from './users/student-repository.js';
|
||||
import { Student } from '../entities/users/student.entity.js';
|
||||
import { User } from '../entities/users/user.entity.js';
|
||||
import { UserRepository } from './users/user-repository.js';
|
||||
import { Teacher } from '../entities/users/teacher.entity.js';
|
||||
import { TeacherRepository } from './users/teacher-repository.js';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Student } from '../../entities/users/student.entity.js';
|
||||
import { User } from '../../entities/users/user.entity.js';
|
||||
import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
|
||||
// Import { UserRepository } from './user-repository.js';
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { Teacher } from '../../entities/users/teacher.entity.js';
|
||||
import { DwengoEntityRepository } from '../dwengo-entity-repository.js';
|
||||
import { UserRepository } from './user-repository.js';
|
||||
|
||||
export class TeacherRepository extends DwengoEntityRepository<Teacher> {
|
||||
public findByUsername(username: string): Promise<Teacher | null> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
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';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Collection, Entity, ManyToMany, ManyToOne, PrimaryKey } from '@mikro-orm/core';
|
||||
import { Entity, ManyToMany, ManyToOne, PrimaryKey } from '@mikro-orm/core';
|
||||
import { Assignment } from './assignment.entity.js';
|
||||
import { Student } from '../users/student.entity.js';
|
||||
import { GroupRepository } from '../../data/assignments/group-repository.js';
|
||||
|
|
|
@ -3,6 +3,12 @@ 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',
|
||||
}
|
||||
|
||||
@Entity({
|
||||
repository: () => ClassJoinRequestRepository,
|
||||
})
|
||||
|
@ -21,10 +27,4 @@ export class ClassJoinRequest {
|
|||
|
||||
@Enum(() => ClassJoinRequestStatus)
|
||||
status!: ClassJoinRequestStatus;
|
||||
}
|
||||
|
||||
export enum ClassJoinRequestStatus {
|
||||
Open = 'open',
|
||||
Accepted = 'accepted',
|
||||
Declined = 'declined',
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ import { FALLBACK_LANG } from '../config.js';
|
|||
import { Assignment } from '../entities/assignments/assignment.entity.js';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { languageMap } from '../entities/content/language.js';
|
||||
import { GroupDTO, mapToGroupDTO } from './group.js';
|
||||
import { GroupDTO } from './group.js';
|
||||
|
||||
export interface AssignmentDTO {
|
||||
id: number;
|
||||
|
@ -46,7 +46,5 @@ export function mapToAssignment(assignmentData: AssignmentDTO, cls: Class): Assi
|
|||
assignment.learningPathLanguage = languageMap[assignmentData.language] || FALLBACK_LANG;
|
||||
assignment.within = cls;
|
||||
|
||||
console.log(assignment);
|
||||
|
||||
return assignment;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import { Question } from '../entities/questions/question.entity.js';
|
||||
import { UserDTO } from './user.js';
|
||||
import { LearningObjectIdentifier } from '../entities/content/learning-object-identifier.js';
|
||||
import { mapToStudentDTO, StudentDTO } from './student.js';
|
||||
import { TeacherDTO } from './teacher.js';
|
||||
|
||||
export interface QuestionDTO {
|
||||
learningObjectIdentifier: LearningObjectIdentifier;
|
||||
|
|
|
@ -2,8 +2,6 @@ import { Submission } from '../entities/assignments/submission.entity.js';
|
|||
import { Language } from '../entities/content/language.js';
|
||||
import { GroupDTO, mapToGroupDTO } from './group.js';
|
||||
import { mapToStudent, mapToStudentDTO, StudentDTO } from './student.js';
|
||||
import { mapToUser } from './user';
|
||||
import { Student } from '../entities/users/student.entity';
|
||||
import { LearningObjectIdentifier } from './learning-content.js';
|
||||
|
||||
export interface SubmissionDTO {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { Response, Router } from 'express';
|
||||
import studentRouter from './students.js';
|
||||
import teacherRouter from './teachers.js';
|
||||
import groupRouter from './groups.js';
|
||||
import assignmentRouter from './assignments.js';
|
||||
import submissionRouter from './submissions.js';
|
||||
import classRouter from './classes.js';
|
||||
import questionRouter from './questions.js';
|
||||
import authRouter from './auth.js';
|
||||
import themeRoutes from './themes.js';
|
||||
import learningPathRoutes from './learning-paths.js';
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
getStudentHandler,
|
||||
getStudentSubmissionsHandler,
|
||||
} from '../controllers/students.js';
|
||||
import { getStudentGroups } from '../services/students.js';
|
||||
const router = express.Router();
|
||||
|
||||
// Root endpoint used to search objects
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { getAssignmentRepository, getClassRepository, getGroupRepository, getSubmissionRepository } from '../data/repositories.js';
|
||||
import { Assignment } from '../entities/assignments/assignment.entity.js';
|
||||
import { AssignmentDTO, mapToAssignment, mapToAssignmentDTO, mapToAssignmentDTOId } from '../interfaces/assignment.js';
|
||||
import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js';
|
||||
|
||||
|
@ -38,6 +37,7 @@ export async function createAssignment(classid: string, assignmentData: Assignme
|
|||
|
||||
return mapToAssignmentDTO(newAssignment);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { getClassRepository, getStudentRepository, getTeacherInvitationRepository, getTeacherRepository } from '../data/repositories.js';
|
||||
import { Class } from '../entities/classes/class.entity.js';
|
||||
import { ClassDTO, mapToClassDTO } from '../interfaces/class.js';
|
||||
import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js';
|
||||
import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js';
|
||||
|
@ -24,13 +23,11 @@ export async function getAllClasses(full: boolean): Promise<ClassDTO[] | string[
|
|||
export async function createClass(classData: ClassDTO): Promise<ClassDTO | null> {
|
||||
const teacherRepository = getTeacherRepository();
|
||||
const teacherUsernames = classData.teachers || [];
|
||||
const teachers = (await Promise.all(teacherUsernames.map((id) => teacherRepository.findByUsername(id)))).filter((teacher) => teacher != null);
|
||||
const teachers = (await Promise.all(teacherUsernames.map((id) => teacherRepository.findByUsername(id)))).filter((teacher) => teacher !== null);
|
||||
|
||||
const studentRepository = getStudentRepository();
|
||||
const studentUsernames = classData.students || [];
|
||||
const students = (await Promise.all(studentUsernames.map((id) => studentRepository.findByUsername(id)))).filter((student) => student != null);
|
||||
|
||||
//Const cls = mapToClass(classData, teachers, students);
|
||||
const students = (await Promise.all(studentUsernames.map((id) => studentRepository.findByUsername(id)))).filter((student) => student !== null);
|
||||
|
||||
const classRepository = getClassRepository();
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { GroupRepository } from '../data/assignments/group-repository.js';
|
||||
import {
|
||||
getAssignmentRepository,
|
||||
getClassRepository,
|
||||
|
@ -43,7 +42,7 @@ export async function createGroup(groupData: GroupDTO, classid: string, assignme
|
|||
const studentRepository = getStudentRepository();
|
||||
|
||||
const memberUsernames = (groupData.members as string[]) || []; // TODO check if groupdata.members is a list
|
||||
const members = (await Promise.all([...memberUsernames].map((id) => studentRepository.findByUsername(id)))).filter((student) => student != null);
|
||||
const members = (await Promise.all([...memberUsernames].map((id) => studentRepository.findByUsername(id)))).filter((student) => student !== null);
|
||||
|
||||
console.log(members);
|
||||
|
||||
|
|
|
@ -45,6 +45,13 @@ export async function getLearningObjectById(hruid: string, language: string): Pr
|
|||
return filterData(metadata, htmlUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function to fetch learning paths
|
||||
*/
|
||||
function fetchLearningPaths(arg0: string[], language: string, arg2: string): LearningPathResponse | PromiseLike<LearningPathResponse> {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic function to fetch learning objects (full data or just HRUIDs)
|
||||
*/
|
||||
|
@ -85,6 +92,4 @@ export async function getLearningObjectsFromPath(hruid: string, language: string
|
|||
export async function getLearningObjectIdsFromPath(hruid: string, language: string): Promise<string[]> {
|
||||
return (await fetchLearningObjects(hruid, false, language)) as string[];
|
||||
}
|
||||
function fetchLearningPaths(arg0: string[], language: string, arg2: string): LearningPathResponse | PromiseLike<LearningPathResponse> {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue