Skip to content
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

Added missing features & enhancements #42

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import de.tum.informatics.www1.artemis.native_app.core.data.service.network.Exer
import de.tum.informatics.www1.artemis.native_app.core.data.service.KtorProvider
import de.tum.informatics.www1.artemis.native_app.core.data.service.impl.JsonProvider
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.Exercise
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.statement.bodyAsText
import io.ktor.http.ContentType
import io.ktor.http.appendPathSegments
import io.ktor.http.contentType
import kotlinx.serialization.json.decodeFromJsonElement
import kotlinx.serialization.json.jsonObject

internal class ExerciseServiceImpl(
private val ktorProvider: KtorProvider,
Expand All @@ -23,14 +25,20 @@ internal class ExerciseServiceImpl(
authToken: String
): NetworkResponse<Exercise> {
return performNetworkCall {
ktorProvider.ktorClient.get(serverUrl) {
url {
appendPathSegments("api", "exercises", exerciseId.toString(), "details")
val response = ktorProvider.ktorClient.get(serverUrl) {
url {
appendPathSegments("api", "exercises", exerciseId.toString(), "details")
}

contentType(ContentType.Application.Json)
cookieAuth(authToken)
}

contentType(ContentType.Application.Json)
cookieAuth(authToken)
}.body()
val jsonElement = jsonProvider.applicationJsonConfiguration.parseToJsonElement(response.bodyAsText())
val exercise = jsonProvider.applicationJsonConfiguration
.decodeFromJsonElement<Exercise>(jsonElement.jsonObject["exercise"]!!)

exercise
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ sealed class Exercise {
abstract val mode: Mode
abstract val categories: List<Category>
abstract val visibleToStudents: Boolean?
abstract val secondCorrectionEnabled: Boolean?
abstract val presentationScoreEnabled: Boolean?
abstract val teamMode: Boolean
abstract val studentAssignedTeamId: Long?
abstract val studentAssignedTeamIdComputed: Boolean
abstract val problemStatement: String?
abstract val assessmentType: AssessmentType?
abstract val allowComplaintsForAutomaticAssessments: Boolean?
abstract val allowManualFeedbackRequests: Boolean?
abstract val allowFeedbackRequests: Boolean?
abstract val includedInOverallScore: IncludedInOverallScore
abstract val exampleSolutionPublicationDate: Instant?
abstract val studentParticipations: List<Participation>?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ data class FileUploadExercise(
override val assessmentDueDate: Instant? = null,
override val difficulty: Difficulty? = null,
override val mode: Mode = Mode.INDIVIDUAL,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val categories: List<Category> = emptyList(),
override val visibleToStudents: Boolean? = null,
override val teamMode: Boolean = false,
Expand All @@ -28,7 +30,7 @@ data class FileUploadExercise(
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ data class ModelingExercise(
override val teamMode: Boolean = false,
override val studentAssignedTeamId: Long? = null,
override val studentAssignedTeamIdComputed: Boolean = false,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ data class ProgrammingExercise(
override val visibleToStudents: Boolean? = null,
override val teamMode: Boolean = false,
override val studentAssignedTeamId: Long? = null,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val studentAssignedTeamIdComputed: Boolean = false,
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ data class QuizExercise(
override val visibleToStudents: Boolean? = null,
override val teamMode: Boolean = false,
override val studentAssignedTeamId: Long? = null,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val studentAssignedTeamIdComputed: Boolean = false,
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ data class TextExercise(
override val categories: List<Category> = emptyList(),
override val visibleToStudents: Boolean? = null,
override val teamMode: Boolean = false,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val studentAssignedTeamId: Long? = null,
override val studentAssignedTeamIdComputed: Boolean = false,
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ data class UnknownExercise(
override val problemStatement: String? = null,
override val assessmentType: AssessmentType? = null,
override val allowComplaintsForAutomaticAssessments: Boolean? = null,
override val allowManualFeedbackRequests: Boolean? = null,
override val allowFeedbackRequests: Boolean? = null,
override val secondCorrectionEnabled: Boolean = false,
override val presentationScoreEnabled: Boolean = false,
override val includedInOverallScore: IncludedInOverallScore = IncludedInOverallScore.INCLUDED_COMPLETELY,
override val exampleSolutionPublicationDate: Instant? = null,
override val attachments: List<Attachment> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.common

import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.runtime.Composable
Expand All @@ -11,8 +13,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.OffsetMapping
import androidx.compose.ui.text.input.TransformedText

Expand All @@ -27,7 +31,7 @@ fun BasicHintTextField(
hintStyle: TextStyle = LocalTextStyle.current
) {
var hasFocus by remember { mutableStateOf(false) }

val keyboardController = LocalSoftwareKeyboardController.current

val isValueDisplayed = value.isNotBlank() || (hasFocus && hideHintOnFocus)
val currentValue = if (isValueDisplayed) value else hint
Expand All @@ -48,6 +52,14 @@ fun BasicHintTextField(
AnnotatedString(text = currentValue, spanStyle = hintStyle.toSpanStyle()),
OffsetMapping.Identity
)
}
},
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Done
),
keyboardActions = KeyboardActions(
onDone = {
keyboardController?.hide()
}
)
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
package de.tum.informatics.www1.artemis.native_app.core.ui.exercise

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Info
import androidx.compose.material3.Button
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.Exercise
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.ProgrammingExercise
import de.tum.informatics.www1.artemis.native_app.core.model.exercise.QuizExercise
Expand Down Expand Up @@ -116,6 +129,10 @@ fun ExerciseActionButtons(
)
}
}
} else {
Row(modifier=Modifier.padding(top=2.dp, bottom = 2.dp)) {
InfoMessageCard()
}
}

if (templateStatus is ResultTemplateStatus.WithResult) {
Expand Down Expand Up @@ -187,4 +204,30 @@ class BoundExerciseActions(
onClickViewResult = { onClickViewResult(exerciseId) },
onClickViewQuizResults = { onClickViewQuizResults(exerciseId) }
)
}
}


@Composable
fun InfoMessageCard() {
Box(
modifier = Modifier
.border(width = 2.dp, color = Color.LightGray)
julian-wls marked this conversation as resolved.
Show resolved Hide resolved
.background(Color(0xFFB3E5FC)) // Light sky blue background
.padding(10.dp)
.fillMaxWidth()
) {
Row(verticalAlignment = Alignment.CenterVertically) {
Icon(
imageVector = Icons.Filled.Info,
contentDescription = "Information",
modifier = Modifier.padding(end = 8.dp),
tint = Color(0xFF0288D1)
)
Text(
text = stringResource(id = R.string.exercise_participation_not_possible),
fontSize = 16.sp,
color = Color.Black
)
}
}
}
2 changes: 2 additions & 0 deletions core/ui/src/main/res/values/exercise_strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

<!-- Exercise action buttons -->
<string name="exercise_actions_view_result_button">View result</string>
<string name="exercise_participation_not_possible">Participating this exercise is currently
not possible in the mobile app.</string>
<string name="exercise_actions_start_exercise_button">Start exercise</string>
<string name="exercise_actions_open_exercise_button">Open exercise</string>
<string name="exercise_actions_view_submission_button">View submission</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ fun `Metis - Conversation Overview`() {
): Flow<ConversationPreferenceService.Preferences> = flowOf(
ConversationPreferenceService.Preferences(
favouritesExpanded = true,
channelsExpanded = true,
generalsExpanded = true,
groupChatsExpanded = true,
personalConversationsExpanded = true,
hiddenExpanded = false
hiddenExpanded = false,
examsExpanded = true,
exercisesExpanded = true,
lecturesExpanded = true,
)
)

Expand Down Expand Up @@ -140,7 +143,9 @@ fun `Metis - Conversation Overview`() {
viewModel = viewModel,
onNavigateToConversation = {},
onRequestCreatePersonalConversation = {},
onRequestAddChannel = {}
onRequestAddChannel = {},
onRequestBrowseChannel = {},
canCreateChannel = false,
)
},
onNavigateBack = { },
Expand Down Expand Up @@ -249,7 +254,8 @@ fun `Metis - Conversation Channel`() {
onRequestReactWithEmoji = { _, _, _ -> CompletableDeferred() },
bottomItem = null,
onClickViewPost = {},
onRequestRetrySend = {}
onRequestRetrySend = {},
title = ""
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.webkit.WebSettings
import android.webkit.WebView
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -116,7 +117,7 @@ internal fun ArtemisWebView(

Box(modifier = modifier) {
WebView(
modifier = Modifier,
modifier = Modifier.fillMaxSize(),
client = remember(value) { ThemeClient(value) },
state = webViewState,
onCreated = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.tum.informatics.www1.artemis.native_app.feature.exerciseview

import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Create
import androidx.compose.material.icons.filled.HelpCenter
Expand Down Expand Up @@ -74,7 +72,6 @@ internal fun ExerciseScreenBody(
exerciseOverviewTab(
Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(horizontal = 8.dp)
)

Expand Down
Loading
Loading