File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
quiz-service/quiz-domain/src/main/kotlin/com/grepp/quizy/quiz/domain/quizread Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.grepp.quizy.quiz.domain.quizread
22
33import com.grepp.quizy.quiz.domain.quiz.Answerable
44import com.grepp.quizy.quiz.domain.quiz.Quiz
5+ import com.grepp.quizy.quiz.domain.quiz.QuizOption
56
67data class GameQuizDetail (
78 val id : Long ,
@@ -17,12 +18,17 @@ data class GameQuizDetail(
1718 id = quiz.id.value,
1819 content = quiz.content.content,
1920 options = quiz.content.options.map { GameQuizOption (it.optionNumber, it.content) },
20- answer = GameQuizAnswer (quiz.getCorrectAnswer() , quiz.getAnswerExplanation() )
21+ answer = findAnswer (quiz.content.options , quiz)
2122 )
2223 }
24+
25+ private fun findAnswer (options : List <QuizOption >, quiz : Answerable ): GameQuizAnswer {
26+ val answerOption = options.first { it.optionNumber == quiz.getCorrectAnswer() }
27+ return GameQuizAnswer (answerOption.content, quiz.getAnswerExplanation())
28+ }
2329 }
2430}
2531
2632data class GameQuizOption (val no : Int , val content : String )
2733
28- data class GameQuizAnswer (val content : Int , val explanation : String )
34+ data class GameQuizAnswer (val content : String , val explanation : String )
You can’t perform that action at this time.
0 commit comments