Skip to content
Snippets Groups Projects
Commit 6a931070 authored by PASQUIER-TROIANO AZZO's avatar PASQUIER-TROIANO AZZO
Browse files

:twisted_rightwards_arrows: merge feature: endpoint restart added

Merge branch 'feature/26-restart-quiz-route' into 'develop'
parents bb72aeee 17984e80
2 merge requests!38feat: V1,!36feature: endpoint restart added
Pipeline #304042 failed with stages
in 42 seconds
......@@ -107,6 +107,12 @@ export class QuizController {
return quiz;
}
@Patch('restart')
async restart(@Body() body: { id: string }) {
const { id } = body;
await this.quizService.restartQuiz(id);
}
@Get('all')
findAll() {
return this.quizService.findAll();
......
......@@ -218,6 +218,12 @@ export class QuizService {
return quiz;
}
async restartQuiz(codeQuiz: string) {
await this.quizRepository.restartQuiz(codeQuiz);
const success = 'the quiz has been restarted';
return success;
}
async updateQuestion(
quizId: string,
questionId: number,
......
......@@ -210,4 +210,11 @@ export class QuizRepositoryOnDb implements QuizRepository {
},
});
}
async restartQuiz(id: string): Promise<void> {
await this.prisma.quiz.update({
where: { id },
data: { questionIndex: 1, score: 0 },
});
}
}
......@@ -33,4 +33,5 @@ export abstract class QuizRepository {
answers: { text: string; isCorrect: boolean }[];
},
): Promise<void>;
abstract restartQuiz(id: string): Promise<void>; //permet de redémarrer un quiz
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment