Skip to content

Commit

Permalink
Feat : add a private method
Browse files Browse the repository at this point in the history
set a private method to map the answers and set the question for them so we can return that list and set them as answers  for that question.
  • Loading branch information
Mr-AXEL01 committed Nov 9, 2024
1 parent 1934fa8 commit 60eefb1
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ public QuestionResponseDTO create(QuestionRequestDTO dto) {
protected void updateEntity(Question question, QuestionRequestDTO dto) {
question.setQuestionType(dto.questionType())
.setText(dto.text())
.setChapter(chapter(dto.chapterId()));

question.getAnswers().clear();

Set<Answer> answers = mapAnswersRequestToEntity(dto.answers(), question);
question.setAnswers(answers);
.setChapter(chapter(dto.chapterId()))
.setAnswers(mapAnswersRequestToEntity(dto.answers(), question));
}

private Chapter chapter(UUID chapterId) {
Expand Down

0 comments on commit 60eefb1

Please sign in to comment.