-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature/#37] 단일 퀴즈 비즈니스 로직 구현 및 api를 연동합니다. #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e4cc3c7
chore: Orientation -> Persistence 네이밍 수정
wjdrjs00 13b31f0
feat: QuizCategory 도메인 모델 추가
wjdrjs00 56a3d15
feat: 지남력 퀴즈 요청 api 연동
wjdrjs00 e32134a
feat: 퀴즈 정답 확인 로직 변경
wjdrjs00 b49cc08
refactor: QuizCategory를 domain 모듈로 이동
wjdrjs00 c9a147f
feat: 퀴즈 카테고리 화면 비활성화 UI 및 비즈니스 로직 구현
wjdrjs00 c4b41fb
chore: 린트 수정
wjdrjs00 4ae23d1
feat: 리뷰사항 반영
wjdrjs00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
data/src/main/kotlin/com/moa/app/data/quiz/datasource/QuizDataSource.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.moa.app.data.quiz.datasource | ||
|
|
||
| import com.moa.app.data.quiz.model.response.PersistenceQuizResponse | ||
|
|
||
| interface QuizDataSource { | ||
| suspend fun fetchPersistenceQuizzes(type: String): Result<List<PersistenceQuizResponse>> | ||
| } |
17 changes: 17 additions & 0 deletions
17
data/src/main/kotlin/com/moa/app/data/quiz/datasourceImpl/QuizDataSourceImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.moa.app.data.quiz.datasourceImpl | ||
|
|
||
| import com.moa.app.data.quiz.datasource.QuizDataSource | ||
| import com.moa.app.data.quiz.model.response.PersistenceQuizResponse | ||
| import com.moa.app.data.quiz.model.response.toDomain | ||
| import com.moa.app.data.quiz.service.QuizService | ||
| import com.moa.app.network.extension.toResult | ||
| import com.moa.app.network.model.NetworkResult | ||
| import javax.inject.Inject | ||
|
|
||
| class QuizDataSourceImpl @Inject constructor( | ||
| private val quizService: QuizService | ||
| ) : QuizDataSource { | ||
| override suspend fun fetchPersistenceQuizzes(type: String): Result<List<PersistenceQuizResponse>> { | ||
| return quizService.fetchPersistenceQuizzes(type).toResult { it } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
data/src/main/kotlin/com/moa/app/data/quiz/model/response/PersistenceQuizResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package com.moa.app.data.quiz.model.response | ||
|
|
||
| import com.moa.app.domain.quiz.model.PersistenceQuiz | ||
| import com.moa.app.domain.quiz.model.QuizCategory | ||
| import kotlinx.collections.immutable.toImmutableList | ||
| import kotlinx.serialization.SerialName | ||
| import kotlinx.serialization.Serializable | ||
|
|
||
| @Serializable | ||
| data class PersistenceQuizResponse( | ||
| @SerialName("questionId") val questionId: Long, | ||
| @SerialName("quizType") val quizType: String, | ||
| @SerialName("questionFormat") val questionFormat: String, | ||
| @SerialName("questionContent") val questionContent: String, | ||
| @SerialName("answer") val answer: String, | ||
| @SerialName("answerOptions") val answerOptions: List<String> | ||
| ) | ||
|
|
||
| fun PersistenceQuizResponse.toDomain(): PersistenceQuiz { | ||
| return PersistenceQuiz( | ||
| id = this.questionId, | ||
| type = QuizCategory.fromString(this.quizType), | ||
| questionFormat = this.questionFormat, | ||
| questionContent = this.questionContent, | ||
| answer = this.answer, | ||
| answerOptions = this.answerOptions.toImmutableList() | ||
| ) | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
data/src/main/kotlin/com/moa/app/data/quiz/repositoryImpl/QuizRepositoryImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package com.moa.app.data.quiz.repositoryImpl | ||
|
|
||
| import com.moa.app.data.quiz.datasource.QuizDataSource | ||
| import com.moa.app.data.quiz.model.response.toDomain | ||
| import com.moa.app.domain.quiz.model.PersistenceQuiz | ||
| import com.moa.app.domain.quiz.model.QuizCategory | ||
| import com.moa.app.domain.quiz.repository.QuizRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class QuizRepositoryImpl @Inject constructor( | ||
| private val quizDataSource: QuizDataSource | ||
| ) : QuizRepository { | ||
| override suspend fun fetchPersistenceQuizzes(category: QuizCategory): Result<List<PersistenceQuiz>> { | ||
| return quizDataSource.fetchPersistenceQuizzes(category.toString()) | ||
| .mapCatching { response -> | ||
| response.map { it.toDomain() } | ||
| } | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
data/src/main/kotlin/com/moa/app/data/quiz/service/QuizService.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| package com.moa.app.data.quiz.service | ||
|
|
||
| import com.moa.app.data.quiz.model.response.PersistenceQuizResponse | ||
| import com.moa.app.network.model.NetworkResult | ||
| import retrofit2.http.GET | ||
| import retrofit2.http.Query | ||
|
|
||
| interface QuizService { | ||
|
|
||
| @GET("/api/v1/quiz/set") | ||
| suspend fun fetchPersistenceQuizzes( | ||
| @Query("type") type: String | ||
| ): NetworkResult<List<PersistenceQuizResponse>> | ||
|
|
||
| } |
16 changes: 16 additions & 0 deletions
16
domain/src/main/kotlin/com/moa/app/domain/quiz/model/PersistenceQuiz.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.moa.app.domain.quiz.model | ||
|
|
||
| import kotlinx.collections.immutable.ImmutableList | ||
|
|
||
| data class PersistenceQuiz( | ||
| val id: Long, | ||
| val type: QuizCategory, | ||
| val questionFormat: String, | ||
| val questionContent: String, | ||
| val answer: String, | ||
| val answerOptions: ImmutableList<String>, | ||
| ) { | ||
| fun getCurrentAnswerIndex(selectedAnswerIndex: Int): Boolean { | ||
| return selectedAnswerIndex == answerOptions.indexOf(answer) | ||
| } | ||
| } |
17 changes: 0 additions & 17 deletions
17
domain/src/main/kotlin/com/moa/app/domain/quiz/model/Quiz.kt
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
domain/src/main/kotlin/com/moa/app/domain/quiz/model/QuizCategory.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.moa.app.domain.quiz.model | ||
|
|
||
| /** | ||
| * MMSE 기반 퀴즈 카테고리 | ||
| * | ||
| * PERSISTENCE: 지남력 | ||
| * LINGUISTIC: 언어능력 | ||
| * MEMORY: 기억력 | ||
| * ATTENTION: 주의력 | ||
| * SPACETIME: 시공간 | ||
| */ | ||
| enum class QuizCategory { | ||
| PERSISTENCE, | ||
| LINGUISTIC, | ||
| MEMORY, | ||
| ATTENTION, | ||
| SPACETIME, | ||
|
|
||
| ; | ||
|
|
||
| companion object { | ||
| fun fromString(value: String): QuizCategory { | ||
| return when (value) { | ||
| "PERSISTENCE" -> PERSISTENCE | ||
| "LINGUISTIC" -> LINGUISTIC | ||
| "MEMORY" -> MEMORY | ||
| "ATTENTION" -> ATTENTION | ||
| "SPACETIME" -> SPACETIME | ||
| else -> throw IllegalArgumentException("Invalid QuizCategory value: $value") | ||
| } | ||
| } | ||
| } | ||
| } |
25 changes: 0 additions & 25 deletions
25
domain/src/main/kotlin/com/moa/app/domain/quiz/model/Quizzes.kt
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
domain/src/main/kotlin/com/moa/app/domain/quiz/repository/QuizRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package com.moa.app.domain.quiz.repository | ||
|
|
||
| import com.moa.app.domain.quiz.model.PersistenceQuiz | ||
| import com.moa.app.domain.quiz.model.QuizCategory | ||
|
|
||
| interface QuizRepository { | ||
| suspend fun fetchPersistenceQuizzes(category: QuizCategory): Result<List<PersistenceQuiz>> | ||
| } |
10 changes: 0 additions & 10 deletions
10
domain/src/main/kotlin/com/moa/app/domain/quiz/usecase/CheckAnswerUseCase.kt
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
domain/src/main/kotlin/com/moa/app/domain/quiz/usecase/FetchOrientationQuizUseCase.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
domain/src/main/kotlin/com/moa/app/domain/quiz/usecase/FetchPersistenceQuizUseCase.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.moa.app.domain.quiz.usecase | ||
|
|
||
| import com.moa.app.domain.quiz.model.PersistenceQuiz | ||
| import com.moa.app.domain.quiz.model.QuizCategory | ||
| import com.moa.app.domain.quiz.repository.QuizRepository | ||
| import javax.inject.Inject | ||
|
|
||
| class FetchPersistenceQuizUseCase @Inject constructor( | ||
| private val quizRepository: QuizRepository, | ||
| ) { | ||
| suspend operator fun invoke(category: QuizCategory): Result<List<PersistenceQuiz>> { | ||
| return quizRepository.fetchPersistenceQuizzes(category) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.