forked from tom.biard/ScienceQuest
RepositoryAndroid
commit
cdd8a72b18
@ -1,6 +1,6 @@
|
|||||||
package fr.iut.sciencequest.model.dto
|
package fr.iut.sciencequest.model.dto
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable;
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class DifficulteDTO (
|
data class DifficulteDTO (
|
@ -1,7 +1,7 @@
|
|||||||
package fr.iut.sciencequest.model.dto
|
package fr.iut.sciencequest.model.dto
|
||||||
|
|
||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable;
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ScientifiqueDTO (
|
data class ScientifiqueDTO (
|
@ -1,6 +1,6 @@
|
|||||||
package fr.iut.sciencequest.model.dto
|
package fr.iut.sciencequest.model.dto
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable;
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class ThematiqueDTO (
|
data class ThematiqueDTO (
|
@ -0,0 +1,11 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.question
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseDTO
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class QuestionDTO (
|
||||||
|
val id: Int,
|
||||||
|
val question: String,
|
||||||
|
val reponses: List<ReponseDTO>
|
||||||
|
)
|
@ -0,0 +1,11 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.question
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
open class QuestionWithSimpleResponseDTO(
|
||||||
|
val id: Int,
|
||||||
|
val question: String,
|
||||||
|
val reponses: List<ReponseSimpleDTO>
|
||||||
|
)
|
@ -0,0 +1,13 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.reponse
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionDTO
|
||||||
|
import fr.iut.sciencequest.model.dto.ScientifiqueDTO
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class ReponseDTO (
|
||||||
|
val id: Int,
|
||||||
|
val reponse: String,
|
||||||
|
val question: QuestionDTO,
|
||||||
|
val scientifique: ScientifiqueDTO
|
||||||
|
)
|
@ -0,0 +1,9 @@
|
|||||||
|
package fr.iut.sciencequest.model.dto.reponse
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
class ReponseSimpleDTO(
|
||||||
|
val id: Int,
|
||||||
|
val reponse: String,
|
||||||
|
)
|
@ -0,0 +1,7 @@
|
|||||||
|
package fr.iut.sciencequest.model.metier
|
||||||
|
class Question(
|
||||||
|
val id: Int,
|
||||||
|
val question: String,
|
||||||
|
val reponses: List<Reponse>
|
||||||
|
) {}
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package fr.iut.sciencequest.model.metier
|
||||||
|
|
||||||
|
class Reponse (
|
||||||
|
val id: Int,
|
||||||
|
val reponse: String,
|
||||||
|
val question: Question,
|
||||||
|
val scientifique: Scientifique
|
||||||
|
) {}
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
package fr.iut.sciencequest.stub
|
||||||
|
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
||||||
|
|
||||||
|
object StubQuestionWithReponses: QuestionWithSimpleResponseDTO(
|
||||||
|
id = 0,
|
||||||
|
question = "Ceci est une question ?",
|
||||||
|
reponses = listOf<ReponseSimpleDTO>(
|
||||||
|
ReponseSimpleDTO(id=0, "Reponse 1"),
|
||||||
|
ReponseSimpleDTO(id=1, "Reponse 2"),
|
||||||
|
ReponseSimpleDTO(id=1, "Reponse 3"),
|
||||||
|
ReponseSimpleDTO(id=1, "Reponse 4"),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{}
|
@ -0,0 +1,63 @@
|
|||||||
|
package fr.iut.sciencequest.view.games
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.lazy.grid.GridCells
|
||||||
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import fr.iut.sciencequest.R
|
||||||
|
import fr.iut.sciencequest.model.dto.question.QuestionWithSimpleResponseDTO
|
||||||
|
import fr.iut.sciencequest.model.dto.reponse.ReponseSimpleDTO
|
||||||
|
import fr.iut.sciencequest.stub.StubQuestionWithReponses
|
||||||
|
import fr.iut.sciencequest.view.TopBar
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun KahootScreen(goToAccount: () -> Unit, goToHome: () -> Unit, question: QuestionWithSimpleResponseDTO) {
|
||||||
|
Column(modifier = Modifier.fillMaxWidth()) {
|
||||||
|
TopBar(goToAccount, goToHome, stringResource(id = R.string.kahoot))
|
||||||
|
KahootPlayer(question)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun KahootScreenPreview(){
|
||||||
|
KahootScreen(goToAccount = {}, goToHome = {}, StubQuestionWithReponses)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun KahootPlayerPreview(){
|
||||||
|
KahootPlayer(question = StubQuestionWithReponses)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun KahootPlayer(question: QuestionWithSimpleResponseDTO){
|
||||||
|
Column {
|
||||||
|
KahootQuestion(question = question.question)
|
||||||
|
KahootReponses(reponses = question.reponses)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun KahootReponses(reponses : List<ReponseSimpleDTO>) {
|
||||||
|
LazyVerticalGrid(columns = GridCells.Fixed(2)) {
|
||||||
|
reponses.forEach {
|
||||||
|
item() {
|
||||||
|
Text(it.reponse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun KahootQuestion(question: String){
|
||||||
|
Text(question)
|
||||||
|
}
|
Loading…
Reference in new issue