mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Simpler quiz domain object (no db logic)
This commit is contained in:
parent
b527aa9ade
commit
cd0c6a469b
1 changed files with 31 additions and 39 deletions
|
|
@ -1,58 +1,50 @@
|
||||||
import { ObjectId } from 'mongodb';
|
import { ObjectId } from 'mongodb';
|
||||||
import QuizRepository from '../repositories/quizRepository';
|
import { Folder } from './folder';
|
||||||
|
import { User } from './user';
|
||||||
|
|
||||||
export class Quiz {
|
export class Quiz {
|
||||||
private repository: QuizRepository;
|
public created_at: Date;
|
||||||
folderId: string;
|
public updated_at: Date;
|
||||||
userId: string;
|
|
||||||
title: string;
|
|
||||||
content: string;
|
|
||||||
created_at: Date;
|
|
||||||
updated_at: Date;
|
|
||||||
|
|
||||||
constructor(folderId: string, userId: string, title: string, content: string, repository?: QuizRepository) {
|
constructor(public folder: Folder, public user: User, public title: string, public content: string, public _id?: ObjectId) {
|
||||||
this.repository = repository || new QuizRepository();
|
this.folder = folder;
|
||||||
this.folderId = folderId;
|
this.user = user;
|
||||||
this.userId = userId;
|
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.content = content;
|
this.content = content;
|
||||||
this.created_at = new Date();
|
this.created_at = new Date();
|
||||||
this.updated_at = new Date();
|
this.updated_at = new Date();
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(): Promise<ObjectId | null> {
|
|
||||||
return await this.repository.createQuiz(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
async getOwner(quizId: string): Promise<string | null> {
|
// async getOwner(quizId: string): Promise<string | null> {
|
||||||
return await this.repository.getOwner(quizId);
|
// return await this.repository.getOwner(quizId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async getContent(quizId: string): Promise<string | null> {
|
// async getContent(quizId: string): Promise<string | null> {
|
||||||
return await this.repository.getContent(quizId);
|
// return await this.repository.getContent(quizId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async delete(quizId: string): Promise<boolean> {
|
// async delete(quizId: string): Promise<boolean> {
|
||||||
return await this.repository.delete(quizId);
|
// return await this.repository.delete(quizId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async deleteQuizzes(folderId: string): Promise<number> {
|
// async deleteQuizzes(folderId: string): Promise<number> {
|
||||||
return await this.repository.deleteQuizzes(folderId);
|
// return await this.repository.deleteQuizzes(folderId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async update(quizId: string, updateData: Partial<Quiz>): Promise<boolean> {
|
// async update(quizId: string, updateData: Partial<Quiz>): Promise<boolean> {
|
||||||
return await this.repository.update(quizId, updateData);
|
// return await this.repository.update(quizId, updateData);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async move(quizId: string, newFolderId: string): Promise<boolean> {
|
// async move(quizId: string, newFolderId: string): Promise<boolean> {
|
||||||
return await this.repository.move(quizId, newFolderId);
|
// return await this.repository.move(quizId, newFolderId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async duplicate(quizId: string): Promise<ObjectId | null> {
|
// async duplicate(quizId: string): Promise<ObjectId | null> {
|
||||||
return await this.repository.duplicate(quizId);
|
// return await this.repository.duplicate(quizId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
async quizExists(title: string, userId: string): Promise<boolean> {
|
// async quizExists(title: string, userId: string): Promise<boolean> {
|
||||||
return await this.repository.quizExists(title, userId);
|
// return await this.repository.quizExists(title, userId);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue