-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from m3dev/feat/quiz-branch
トリあえずクイズ機能実装
- Loading branch information
Showing
12 changed files
with
196 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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
Binary file not shown.
This file contains 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 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 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 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,71 @@ | ||
package core | ||
|
||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.MutableState | ||
import data.AnswerOption | ||
import data.Question | ||
|
||
class ComposeQuiz : Quiz { | ||
// TODO: Load file | ||
private val questions: List<Question> = listOf( | ||
Question( | ||
id = 0, | ||
questionText = "quiz0", | ||
answerOptions = listOf( | ||
AnswerOption("1", 1, false), | ||
AnswerOption("2", 2, false), | ||
AnswerOption("3", 3, false), | ||
), | ||
), | ||
Question( | ||
id = 1, | ||
questionText = "quiz1", | ||
answerOptions = listOf( | ||
AnswerOption("0", 0, false), | ||
AnswerOption("2", 2, false), | ||
AnswerOption("3", 3, false), | ||
), | ||
), | ||
Question( | ||
id = 2, | ||
questionText = "quiz2", | ||
answerOptions = listOf( | ||
AnswerOption("0", 0, false), | ||
AnswerOption("1", 1, false), | ||
AnswerOption("3", 3, false), | ||
), | ||
), | ||
Question( | ||
id = 3, | ||
questionText = "quiz3", | ||
answerOptions = listOf( | ||
AnswerOption("0", 0, false), | ||
AnswerOption("1", 1, false), | ||
AnswerOption("2", 2, true), // finish example | ||
), | ||
), | ||
) | ||
override val currentQuizId: MutableState<Int> = mutableStateOf(0) | ||
override val currentQuizNumber: MutableState<Int> = mutableStateOf(1) | ||
|
||
override fun onClickNext(answerOption: AnswerOption, onClickFinish: (nextId: Int) -> Unit) { | ||
if (answerOption.isFinish) { | ||
onClickFinish(answerOption.nextId) | ||
} | ||
currentQuizNumber.value += 1 | ||
currentQuizId.value = answerOption.nextId | ||
} | ||
|
||
override fun getAnswerOptions(): List<AnswerOption> { | ||
return questions[currentQuizId.value].answerOptions | ||
} | ||
|
||
override fun getQuestionText(): String { | ||
return questions[currentQuizId.value].questionText | ||
} | ||
|
||
override fun reset() { | ||
currentQuizId.value = 0 | ||
currentQuizNumber.value = 0 | ||
} | ||
} |
This file contains 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,41 @@ | ||
package core | ||
|
||
import data.Diagnosis | ||
|
||
class ComposeResult() : Result { | ||
// TODO: Load file | ||
private val diagnosisList: List<Diagnosis> = listOf( | ||
Diagnosis( | ||
typeText = "診断結果0です", | ||
srcImg = "./images/penguin.png", | ||
preText = "どんなインシデントでも冷静", | ||
mainText = "タイプ\n\n狙った獲物が、現れるまで、数時間も動きを止めることができるトリで、その動じない姿はまさに頼れるシニアなエンジニア。関東では、上野動物園、千葉市動物公園で見ることができます。", | ||
postText = "動じないエンジニア大募集!", | ||
), | ||
Diagnosis( | ||
typeText = "診断結果1です", | ||
srcImg = "./images/penguin.png", | ||
preText = "どんなインシデントでも冷静", | ||
mainText = "タイプ\n\n狙った獲物が、現れるまで、数時間も動きを止めることができるトリで、その動じない姿はまさに頼れるシニアなエンジニア。関東では、上野動物園、千葉市動物公園で見ることができます。", | ||
postText = "動じないエンジニア大募集!", | ||
), | ||
Diagnosis( | ||
typeText = "診断結果2です", | ||
srcImg = "./images/penguin.png", | ||
preText = "どんなインシデントでも冷静", | ||
mainText = "タイプ\n\n狙った獲物が、現れるまで、数時間も動きを止めることができるトリで、その動じない姿はまさに頼れるシニアなエンジニア。関東では、上野動物園、千葉市動物公園で見ることができます。", | ||
postText = "動じないエンジニア大募集!", | ||
), | ||
Diagnosis( | ||
typeText = "診断結果3です", | ||
srcImg = "./images/penguin.png", | ||
preText = "どんなインシデントでも冷静", | ||
mainText = "タイプ\n\n狙った獲物が、現れるまで、数時間も動きを止めることができるトリで、その動じない姿はまさに頼れるシニアなエンジニア。関東では、上野動物園、千葉市動物公園で見ることができます。", | ||
postText = "動じないエンジニア大募集!", | ||
), | ||
) | ||
|
||
override fun getDiagnosis(resultId: Int): Diagnosis { | ||
return diagnosisList[resultId] | ||
} | ||
} |
This file contains 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 core | ||
|
||
import androidx.compose.runtime.MutableState | ||
|
||
import data.AnswerOption | ||
|
||
interface Quiz { | ||
val currentQuizId: MutableState<Int> | ||
val currentQuizNumber: MutableState<Int> | ||
fun onClickNext(answerOption: AnswerOption, onClickFinish: (nextId: Int) -> Unit) | ||
fun getAnswerOptions(): List<AnswerOption> | ||
fun getQuestionText(): String | ||
fun reset() | ||
} |
This file contains 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 core | ||
|
||
import data.Diagnosis | ||
|
||
interface Result { | ||
fun getDiagnosis(resultId: Int): Diagnosis | ||
} |
This file contains 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 data | ||
|
||
data class AnswerOption( | ||
val text: String, | ||
val nextId: Int, | ||
val isFinish: Boolean | ||
) |
This file contains 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,9 @@ | ||
package data | ||
|
||
data class Diagnosis( | ||
val typeText: String, | ||
val srcImg: String, | ||
val preText: String, | ||
val mainText: String, | ||
val postText: String, | ||
) |
This file contains 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 data | ||
|
||
data class Question( | ||
val id: Int, | ||
val questionText: String, | ||
val answerOptions: List<AnswerOption>, | ||
) |