-
Notifications
You must be signed in to change notification settings - Fork 3
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
Enhancing FeedbackScreen with Performance Metrics #283
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
49b6f94
feat: add statistics to feedback screen for single conversation
baptisteghostine 6abdc33
Merge branch 'main' of https://github.com/SWENT-TEAM17/demo-repositor…
baptisteghostine 105f656
fix: remove variables fillerWords and pauseDurations because not used…
baptisteghostine d5a5b11
Merge branch 'main' of https://github.com/SWENT-TEAM17/demo-repositor…
baptisteghostine fbf7c54
feat: add tests to improve line coverage
baptisteghostine b350ff5
fix: ktmft Format to pass CI
baptisteghostine 0f05fad
fix: add description to function
baptisteghostine add6228
Merge branch 'main' of https://github.com/SWENT-TEAM17/demo-repositor…
baptisteghostine 579c78b
Merge branch 'main' of https://github.com/SWENT-TEAM17/demo-repositor…
baptisteghostine aa25c3a
fix: remove chatGPT starting message displaying on ChatScreen
baptisteghostine d5feeda
Merge branch 'main' of https://github.com/SWENT-TEAM17/demo-repositor…
ymarc11 c7a8c76
fix: replace talk time percentage by mean for feedback
ymarc11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -26,14 +26,6 @@ import com.github.se.orator.ui.network.Message | |
import com.github.se.orator.ui.theme.AppDimensions | ||
import com.github.se.orator.ui.theme.AppTypography | ||
|
||
/** | ||
* Composable function to display the feedback screen. | ||
* | ||
* @param chatViewModel The view model for chat interactions. | ||
* @param userProfileViewModel The view model for user profiles. | ||
* @param apiLinkViewModel The view model for API links. | ||
* @param navigationActions The actions used for navigation. | ||
*/ | ||
@OptIn(ExperimentalMaterial3Api::class) | ||
@Composable | ||
fun FeedbackScreen( | ||
|
@@ -42,14 +34,15 @@ fun FeedbackScreen( | |
apiLinkViewModel: ApiLinkViewModel, | ||
navigationActions: NavigationActions | ||
) { | ||
// State variables for feedback message, decision, loading status, and error message. | ||
var feedbackMessage by remember { mutableStateOf<String?>(null) } | ||
var decisionResult by remember { mutableStateOf<ChatViewModel.DecisionResult?>(null) } | ||
var isLoading by remember { mutableStateOf(true) } | ||
var errorMessage by remember { mutableStateOf<String?>(null) } | ||
|
||
val practiceContext by apiLinkViewModel.practiceContext.collectAsState() | ||
val userProfile by userProfileViewModel.userProfile.collectAsState() | ||
val talkTimePercentageMean = userProfile?.statistics?.talkTimePercMean | ||
val talkTimeSecondsMean = userProfile?.statistics?.talkTimeSecMean | ||
|
||
val sessionType = | ||
when (practiceContext) { | ||
|
@@ -59,7 +52,6 @@ fun FeedbackScreen( | |
else -> null | ||
} | ||
|
||
// Retrieve the number of successful sessions | ||
val successfulSessionsCount = | ||
sessionType?.let { userProfile?.statistics?.successfulSessions?.get(it.name) ?: 0 } ?: 0 | ||
|
||
|
@@ -68,8 +60,6 @@ fun FeedbackScreen( | |
feedbackMessage = chatViewModel.generateFeedback() | ||
feedbackMessage?.let { | ||
decisionResult = parseDecisionFromFeedback(it, sessionType) | ||
|
||
// Update user statistics based on the decision and session type | ||
if (decisionResult != null && sessionType != null) { | ||
userProfileViewModel.updateSessionResult( | ||
isSuccess = decisionResult!!.isSuccess, sessionType = sessionType) | ||
|
@@ -155,7 +145,6 @@ fun FeedbackScreen( | |
.weight(1f) | ||
.verticalScroll(rememberScrollState()) | ||
.testTag("feedbackMessage")) { | ||
// Display the decision prominently. | ||
decisionResult?.message?.let { decisionText -> | ||
Text( | ||
text = decisionText, | ||
|
@@ -170,29 +159,49 @@ fun FeedbackScreen( | |
Text( | ||
text = | ||
"You have successfully completed $successfulSessionsCount ${ | ||
when (sessionType) { | ||
SessionType.SPEECH -> "speeches" | ||
SessionType.INTERVIEW -> "interviews" | ||
SessionType.NEGOTIATION -> "negotiations" | ||
else -> "sessions" | ||
} | ||
} so far!", | ||
when (sessionType) { | ||
SessionType.SPEECH -> "speeches" | ||
SessionType.INTERVIEW -> "interviews" | ||
SessionType.NEGOTIATION -> "negotiations" | ||
else -> "sessions" | ||
} | ||
} so far!", | ||
style = AppTypography.bodyLargeStyle, | ||
modifier = | ||
Modifier.align(Alignment.CenterHorizontally) | ||
.padding(AppDimensions.paddingMedium) | ||
.testTag("successfulSessionsText"), | ||
color = MaterialTheme.colorScheme.tertiary) | ||
// Display the detailed feedback message. | ||
ChatMessageItem( | ||
message = Message(content = feedbackMessage!!, role = "assistant")) | ||
|
||
Text( | ||
text = "Your Performance Metrics:", | ||
style = AppTypography.mediumTitleStyle, | ||
modifier = | ||
Modifier.padding(AppDimensions.paddingMedium) | ||
.testTag("performanceMetricsTitle")) | ||
|
||
// Display Talk Time Seconds | ||
MetricDisplayItem( | ||
title = "Talk Time (Seconds)", | ||
value = talkTimeSecondsMean?.let { "%.2f".format(it) } ?: "No data", | ||
testTag = "talkTimeSeconds") | ||
|
||
// Display Talk Time Percentage | ||
MetricDisplayItem( | ||
title = "Talk Time (Percentage)", | ||
value = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could have added tests for the MetricDisplayItem. |
||
talkTimePercentageMean?.let { "%.2f%%".format(it) } ?: "No data", | ||
testTag = "talkTimePercentage") | ||
} | ||
} | ||
else -> { | ||
Text( | ||
text = "No feedback available.", | ||
style = AppTypography.bodyLargeStyle, | ||
color = MaterialTheme.colorScheme.secondary) | ||
color = MaterialTheme.colorScheme.secondary, | ||
modifier = Modifier.testTag("feedbackNoMessage")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good adaptation for the dark mode. Well done. |
||
} | ||
} | ||
|
||
|
@@ -224,10 +233,41 @@ fun FeedbackScreen( | |
} | ||
|
||
/** | ||
* Function to parse the decision from the feedback message. | ||
* A reusable composable function to display a performance metric. | ||
* | ||
* @param title The title of the metric, typically describing what the metric represents. Example: | ||
* "Talk Time (Seconds)" or "Talk Time (Percentage)". | ||
* @param value The value of the metric, formatted as a string for display. Example: "120.00" or | ||
* "75.50%". | ||
* @param testTag A test tag assigned to the composable for UI testing purposes. | ||
* | ||
* Functionality: | ||
* - Displays a metric with its title and value in a column layout. | ||
* - Applies consistent padding and styling to ensure visual alignment with other UI components. | ||
* - Includes a test tag for accessibility and testing frameworks. | ||
* | ||
* Usage: Call this function with appropriate parameters to render a performance metric anywhere in | ||
* the UI. | ||
*/ | ||
@Composable | ||
fun MetricDisplayItem(title: String, value: String, testTag: String) { | ||
Column(modifier = Modifier.fillMaxWidth().padding(AppDimensions.paddingSmall).testTag(testTag)) { | ||
Text( | ||
text = title, | ||
style = AppTypography.smallTitleStyle, | ||
modifier = Modifier.padding(bottom = AppDimensions.paddingSmall)) | ||
Text( | ||
text = value, | ||
style = AppTypography.smallTitleStyle, | ||
modifier = Modifier.padding(bottom = AppDimensions.paddingSmall)) | ||
} | ||
} | ||
|
||
/** | ||
* Parses the decision from the feedback message. | ||
* | ||
* @param feedback The feedback message. | ||
* @param sessionType The type of session. | ||
* @param sessionType The session type. | ||
* @return The decision result. | ||
*/ | ||
private fun parseDecisionFromFeedback( | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should replace the talk time percentage mean by the paceMean.