Skip to content

Commit 876baac

Browse files
committed
fix
1 parent 9ed61d5 commit 876baac

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

routes/api/quiz/controller.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class QuizController extends BaseController {
2323
const questionsToAdd = R.difference(questions, oldQuestions)
2424
const questionToRemove = R.difference(oldQuestions, questions)
2525

26-
await quiz.addQuestions(questionsToAdd, {
26+
const addQuestions = quiz.addQuestions(questionsToAdd, {
2727
through: {
2828
updatedById: req.user.id
2929
}
3030
})
3131

32-
await DB.quizQuestions.destroy({
32+
const removeQuestions = DB.quizQuestions.destroy({
3333
where:{
3434
quizId: quiz.id,
3535
questionId: {
@@ -38,7 +38,16 @@ class QuizController extends BaseController {
3838
}
3939
})
4040

41-
super.handleUpdateById(...arguments)
41+
const setUpdatedBy = DB.quizQuestions.update({
42+
updatedById: req.user.id
43+
}, {
44+
where: {
45+
quizId: quiz.id
46+
}
47+
})
48+
49+
await Promise.all([addQuestions, removeQuestions, setUpdatedBy])
50+
return super.handleUpdateById(...arguments)
4251
}
4352

4453
// body : {

0 commit comments

Comments
 (0)