|
|
|
@ -26,6 +26,8 @@ import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import com.example.what_the_fantasy.R
|
|
|
|
|
import com.example.what_the_fantasy.data.local.QuestionStub
|
|
|
|
|
import com.example.what_the_fantasy.data.local.QuizStub
|
|
|
|
|
import com.example.what_the_fantasy.ui.navigations.Destination
|
|
|
|
|
|
|
|
|
|
val gradient = Brush.linearGradient(
|
|
|
|
|
colors = listOf(Color(0xFF7B1FA2), Color(0xFF311B92)),
|
|
|
|
@ -34,7 +36,12 @@ val gradient = Brush.linearGradient(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) {
|
|
|
|
|
fun QuizEndPage(
|
|
|
|
|
idQuiz: Int,
|
|
|
|
|
points: Int,
|
|
|
|
|
navControllerQuizMenu: () -> Unit,
|
|
|
|
|
navControllerMenu: () -> Unit
|
|
|
|
|
) {
|
|
|
|
|
Column(
|
|
|
|
|
modifier = Modifier.fillMaxSize().background(Color(0xFF100C1B))
|
|
|
|
|
) {
|
|
|
|
@ -80,14 +87,13 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) {
|
|
|
|
|
horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
|
|
verticalArrangement = Arrangement.SpaceEvenly
|
|
|
|
|
) {
|
|
|
|
|
val quiz = QuizStub.getQuizById(idQuiz)
|
|
|
|
|
val nbQuestions = quiz?.questions?.size
|
|
|
|
|
Text (
|
|
|
|
|
text = "Quiz N°$idQuiz",
|
|
|
|
|
text = "${quiz?.name}",
|
|
|
|
|
color = Color.White,
|
|
|
|
|
style = TextStyle(fontSize = 25.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val nbQuestions = QuestionStub.allQuestions.size
|
|
|
|
|
|
|
|
|
|
Text (
|
|
|
|
|
text = "Nombres de Questions : $nbQuestions",
|
|
|
|
|
color = Color.White,
|
|
|
|
@ -99,13 +105,17 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) {
|
|
|
|
|
style = TextStyle(fontSize = 15.sp, fontWeight = FontWeight.Bold, textAlign = TextAlign.Center)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val pourcentage = (points.toDouble() / nbQuestions!!) * 100
|
|
|
|
|
|
|
|
|
|
val note = when {
|
|
|
|
|
points == 10 -> "S"
|
|
|
|
|
points >= 7 -> "A"
|
|
|
|
|
points >= 4 -> "B"
|
|
|
|
|
pourcentage == 100.0 -> "S"
|
|
|
|
|
pourcentage >= 70.0 -> "A"
|
|
|
|
|
pourcentage >= 40.0 -> "B"
|
|
|
|
|
else -> "C"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
println("Note obtenue : $note")
|
|
|
|
|
|
|
|
|
|
Box(
|
|
|
|
|
contentAlignment = Alignment.Center,
|
|
|
|
|
modifier = Modifier
|
|
|
|
@ -145,13 +155,15 @@ fun QuizEndPage(idQuiz: Int, points: Int, navControllerQuizMenu: () -> Unit) {
|
|
|
|
|
Image(
|
|
|
|
|
painter = painterResource(R.drawable.wf_logo),
|
|
|
|
|
contentDescription = "Menu Button",
|
|
|
|
|
Modifier.clickable { navControllerQuizMenu() }
|
|
|
|
|
Modifier.clickable { navControllerMenu() }
|
|
|
|
|
)
|
|
|
|
|
// Bouton Quiz
|
|
|
|
|
// Bouton Menu Quiz
|
|
|
|
|
Image(
|
|
|
|
|
painter = painterResource(id = R.drawable.quiz_icon),
|
|
|
|
|
contentDescription = "Bouton",
|
|
|
|
|
modifier = Modifier.size(50.dp)
|
|
|
|
|
modifier = Modifier
|
|
|
|
|
.size(50.dp)
|
|
|
|
|
.clickable { navControllerQuizMenu() }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|