added more example data
This commit is contained in:
parent
229cf816e3
commit
5c2928597c
4 changed files with 116 additions and 43 deletions
|
@ -74,46 +74,97 @@ fun populateTaskDatabaseTest(database: TaskDatabase) {
|
|||
taskA1Id,
|
||||
taskA2Id,
|
||||
taskA3Id,
|
||||
taskB1Id,
|
||||
taskB2Id,
|
||||
taskA4Id,
|
||||
taskA5Id,
|
||||
) = database.taskDao().insert(
|
||||
// Subject A
|
||||
TaskEntity(
|
||||
title = "Commencer A",
|
||||
description = "Description 1",
|
||||
title = "Installation Debian",
|
||||
description = "Installer la dernière version de Debian sur les Raspberry Pi.",
|
||||
order = 1,
|
||||
subjectId = subjectA.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Continuer A",
|
||||
description = "Description 2",
|
||||
title = "Connection de LEDs",
|
||||
description =
|
||||
"Utiliser les broches GPIO du Raspberry Pi pour brancher vos LEDs.\n" +
|
||||
"N'oublier pas les résistances !",
|
||||
order = 2,
|
||||
subjectId = subjectA.id
|
||||
subjectId = subjectA.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Finir A",
|
||||
description = "Description 3",
|
||||
title = "IDLE Python",
|
||||
description = "Installer l'éditeur basique Python avec 'apt install idle-python3.11'.",
|
||||
order = 3,
|
||||
subjectId = subjectA.id
|
||||
subjectId = subjectA.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Commencer B",
|
||||
description = "Description 1",
|
||||
title = "Clignotement de LEDs",
|
||||
description = "Faite clignoter les différentes LEDs.",
|
||||
order = 4,
|
||||
subjectId = subjectA.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Feu Tricolore",
|
||||
description = "Simuler un feu de circulation à l'aide de vos components.",
|
||||
order = 5,
|
||||
subjectId = subjectA.id,
|
||||
),
|
||||
)
|
||||
|
||||
val (
|
||||
taskB1Id,
|
||||
taskB2Id,
|
||||
taskB3Id,
|
||||
taskB4Id,
|
||||
taskB5Id,
|
||||
) = database.taskDao().insert(
|
||||
// Subject B
|
||||
TaskEntity(
|
||||
title = "Préparation Arduino",
|
||||
description = "Préparer votre Arduino et assurer vous qu'il soit reconnu par votre ordinateur.",
|
||||
order = 1,
|
||||
subjectId = subjectB.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Finir B",
|
||||
description = "Description 2",
|
||||
title = "Connection de LEDs",
|
||||
description =
|
||||
"Utiliser les broches de votre Arduino pour brancher vos LEDs.\n" +
|
||||
"N'oublier pas les résistances !",
|
||||
order = 2,
|
||||
subjectId = subjectB.id,
|
||||
)
|
||||
),
|
||||
TaskEntity(
|
||||
title = "IDE Arduino",
|
||||
description = "Installer l'éditeur de code 'Arduino IDE'.",
|
||||
order = 3,
|
||||
subjectId = subjectB.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Clignotement de LEDs",
|
||||
description = "Faite clignoter les différentes LEDs.",
|
||||
order = 4,
|
||||
subjectId = subjectB.id,
|
||||
),
|
||||
TaskEntity(
|
||||
title = "Feu Tricolore",
|
||||
description = "Simuler un feu de circulation à l'aide de vos components.",
|
||||
order = 5,
|
||||
subjectId = subjectB.id,
|
||||
),
|
||||
)
|
||||
|
||||
val taskA1 = database.taskDao().getById(taskA1Id)!!
|
||||
val taskA2 = database.taskDao().getById(taskA2Id)!!
|
||||
val taskA3 = database.taskDao().getById(taskA3Id)!!
|
||||
val taskA4 = database.taskDao().getById(taskA4Id)!!
|
||||
val taskA5 = database.taskDao().getById(taskA5Id)!!
|
||||
|
||||
val taskB1 = database.taskDao().getById(taskB1Id)!!
|
||||
val taskB2 = database.taskDao().getById(taskB2Id)!!
|
||||
val taskB3 = database.taskDao().getById(taskB3Id)!!
|
||||
val taskB4 = database.taskDao().getById(taskB4Id)!!
|
||||
val taskB5 = database.taskDao().getById(taskB5Id)!!
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.faraphel.tasks_valider.connectivity.task.TaskClient
|
||||
import com.faraphel.tasks_valider.connectivity.task.session.TaskSession
|
||||
import com.faraphel.tasks_valider.ui.screen.communication.authentication.AuthenticationClientScreen
|
||||
|
@ -27,16 +30,21 @@ import com.faraphel.tasks_valider.ui.screen.task.TaskSessionController
|
|||
|
||||
@Composable
|
||||
fun CommunicationInternetClientScreen(activity: Activity) {
|
||||
val controller = rememberNavController()
|
||||
|
||||
val client = remember { mutableStateOf<TaskClient?>(null) }
|
||||
val session = remember { mutableStateOf<TaskSession?>(null) }
|
||||
|
||||
// if the client is not connected, show the connection screen
|
||||
if (client.value == null)
|
||||
return CommunicationInternetClientContent(client)
|
||||
// if the user is not authenticated, show the authentication screen
|
||||
if (session.value == null)
|
||||
return AuthenticationClientScreen(activity, client.value!!, session)
|
||||
|
||||
NavHost(controller, startDestination = "communication") {
|
||||
composable("communication") {
|
||||
CommunicationInternetClientContent(client)
|
||||
if (client.value != null) controller.navigate("authentication")
|
||||
}
|
||||
composable("authentication") {
|
||||
AuthenticationClientScreen(activity, client.value!!, session)
|
||||
if (session.value != null) controller.navigate("session")
|
||||
}
|
||||
composable("session") {
|
||||
// show the main screen
|
||||
TaskSessionController(
|
||||
activity,
|
||||
|
@ -44,6 +52,8 @@ fun CommunicationInternetClientScreen(activity: Activity) {
|
|||
session.value!!.person,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
|
|
|
@ -6,27 +6,36 @@ import android.net.wifi.p2p.WifiP2pDevice
|
|||
import android.widget.Toast
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import com.faraphel.tasks_valider.connectivity.bwd.BwdManager
|
||||
import com.faraphel.tasks_valider.connectivity.task.TaskClient
|
||||
import com.faraphel.tasks_valider.connectivity.task.session.TaskSession
|
||||
import com.faraphel.tasks_valider.ui.screen.communication.DEFAULT_SERVER_PORT
|
||||
import com.faraphel.tasks_valider.ui.screen.communication.authentication.AuthenticationClientScreen
|
||||
import com.faraphel.tasks_valider.ui.screen.communication.connection.internet.role.CommunicationInternetClientContent
|
||||
import com.faraphel.tasks_valider.ui.screen.task.TaskSessionController
|
||||
import com.faraphel.tasks_valider.ui.widgets.connectivity.WifiP2pDeviceListWidget
|
||||
|
||||
|
||||
@Composable
|
||||
fun CommunicationWifiP2pClientScreen(activity: Activity, bwdManager: BwdManager) {
|
||||
val controller = rememberNavController()
|
||||
|
||||
val client = remember { mutableStateOf<TaskClient?>(null) }
|
||||
val session = remember { mutableStateOf<TaskSession?>(null) }
|
||||
|
||||
// if the client is not connected, show the connection screen
|
||||
if (client.value == null)
|
||||
return CommunicationWifiP2pClientContent(activity, client, bwdManager)
|
||||
// if the user is not authenticated, show the authentication screen
|
||||
if (session.value == null)
|
||||
return AuthenticationClientScreen(activity, client.value!!, session)
|
||||
|
||||
NavHost(controller, startDestination = "communication") {
|
||||
composable("communication") {
|
||||
CommunicationWifiP2pClientContent(activity, client, bwdManager)
|
||||
if (client.value != null) controller.navigate("authentication")
|
||||
}
|
||||
composable("authentication") {
|
||||
AuthenticationClientScreen(activity, client.value!!, session)
|
||||
if (session.value != null) controller.navigate("session")
|
||||
}
|
||||
composable("session") {
|
||||
// show the main screen
|
||||
TaskSessionController(
|
||||
activity,
|
||||
|
@ -34,6 +43,8 @@ fun CommunicationWifiP2pClientScreen(activity: Activity, bwdManager: BwdManager)
|
|||
session.value!!.person,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.faraphel.tasks_valider.connectivity.task.TaskClient
|
||||
|
@ -43,7 +44,7 @@ fun TaskStudentScreen(
|
|||
client,
|
||||
student,
|
||||
tasks,
|
||||
validations
|
||||
validations,
|
||||
)
|
||||
}.start()
|
||||
|
||||
|
@ -105,7 +106,7 @@ fun TaskStudentScreen(
|
|||
client,
|
||||
student,
|
||||
tasks,
|
||||
validations
|
||||
validations,
|
||||
)
|
||||
}.start()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue