Skip to content

Commit 05fc280

Browse files
feat: changes according demo feedback
1 parent 36e49ac commit 05fc280

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

core/src/main/java/org/openedx/core/domain/model/CourseProgress.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ data class CourseProgress(
6868
return if (notCompletedPercent < 0.0) 0f else notCompletedPercent.toFloat()
6969
}
7070

71+
fun getNotEmptyGradingPolicies() = gradingPolicy?.assignmentPolicies?.mapNotNull {
72+
if (getPossibleAssignmentProblems(it) > 0) {
73+
it
74+
} else {
75+
null
76+
}
77+
}
78+
7179
data class CertificateData(
7280
val certStatus: String,
7381
val certWebViewUrl: String,

course/src/main/java/org/openedx/course/presentation/home/AssignmentsHomePagerCardContent.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ private const val MILLISECONDS_PER_DAY =
5050
fun AssignmentsHomePagerCardContent(
5151
uiState: CourseHomeUIState.CourseData,
5252
onAssignmentClick: (Block) -> Unit,
53-
onViewAllAssignmentsClick: () -> Unit
53+
onViewAllAssignmentsClick: () -> Unit,
54+
getBlockParent: (blockId: String) -> Block?,
5455
) {
5556
if (uiState.courseAssignments.isEmpty()) {
5657
CourseContentAssignmentEmptyState(
@@ -126,6 +127,7 @@ fun AssignmentsHomePagerCardContent(
126127
if (firstIncompleteAssignment != null) {
127128
AssignmentCard(
128129
assignment = firstIncompleteAssignment,
130+
sectionName = getBlockParent(firstIncompleteAssignment.id)?.displayName ?: "",
129131
onAssignmentClick = onAssignmentClick
130132
)
131133
} else {
@@ -147,6 +149,7 @@ fun AssignmentsHomePagerCardContent(
147149
@Composable
148150
private fun AssignmentCard(
149151
assignment: Block,
152+
sectionName: String,
150153
onAssignmentClick: (Block) -> Unit
151154
) {
152155
val isDuePast = assignment.due != null && assignment.due!! < Date()
@@ -247,14 +250,14 @@ private fun AssignmentCard(
247250

248251
// Assignment and section name
249252
Text(
250-
text = assignment.assignmentProgress?.assignmentType ?: "",
253+
text = assignment.displayName,
251254
style = MaterialTheme.appTypography.titleSmall,
252255
color = MaterialTheme.appColors.textPrimary,
253256
fontWeight = FontWeight.Bold
254257
)
255258
Spacer(modifier = Modifier.height(4.dp))
256259
Text(
257-
text = assignment.displayName,
260+
text = sectionName,
258261
style = MaterialTheme.appTypography.labelSmall,
259262
color = MaterialTheme.appColors.textPrimaryVariant,
260263
)

course/src/main/java/org/openedx/course/presentation/home/CourseHomeScreen.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ fun CourseHomeScreen(
168168
viewModel.logAssignmentClick(assignmentBlock.id)
169169
},
170170
onNavigateToContent = onNavigateToContent,
171-
onNavigateToProgress = onNavigateToProgress
171+
onNavigateToProgress = onNavigateToProgress,
172+
getBlockParent = viewModel::getBlockParent
172173
)
173174
}
174175

@@ -187,6 +188,7 @@ private fun CourseHomeUI(
187188
onAssignmentClick: (Block) -> Unit,
188189
onNavigateToContent: (CourseContentTab) -> Unit,
189190
onNavigateToProgress: () -> Unit,
191+
getBlockParent: (blockId: String) -> Block?,
190192
) {
191193
val scaffoldState = rememberScaffoldState()
192194

@@ -318,6 +320,7 @@ private fun CourseHomeUI(
318320
AssignmentsHomePagerCardContent(
319321
uiState = uiState,
320322
onAssignmentClick = onAssignmentClick,
323+
getBlockParent = getBlockParent,
321324
onViewAllAssignmentsClick = {
322325
onNavigateToContent(CourseContentTab.ASSIGNMENTS)
323326
}
@@ -453,7 +456,8 @@ private fun CourseHomeScreenPreview() {
453456
onVideoClick = {},
454457
onAssignmentClick = {},
455458
onNavigateToContent = { _ -> },
456-
onNavigateToProgress = {}
459+
onNavigateToProgress = {},
460+
getBlockParent = { null },
457461
)
458462
}
459463
}
@@ -502,6 +506,7 @@ private fun CourseHomeScreenTabletPreview() {
502506
onAssignmentClick = {},
503507
onNavigateToContent = { _ -> },
504508
onNavigateToProgress = { },
509+
getBlockParent = { null },
505510
)
506511
}
507512
}

course/src/main/java/org/openedx/course/presentation/home/GradesHomePagerCardContent.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ fun GradesHomePagerCardContent(
4242
) {
4343
val courseProgress = uiState.courseProgress
4444
val gradingPolicy = courseProgress?.gradingPolicy
45+
val assignmentPolicies = courseProgress?.getNotEmptyGradingPolicies()
4546

46-
if (courseProgress == null || gradingPolicy == null || gradingPolicy.assignmentPolicies.isEmpty()) {
47+
if (courseProgress == null || gradingPolicy == null || assignmentPolicies.isNullOrEmpty()) {
4748
CourseHomeGradesEmptyState()
4849
return
4950
}

course/src/main/java/org/openedx/course/presentation/progress/CourseProgressScreen.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ private fun CourseProgressContent(
134134
)
135135
}
136136
if (gradingPolicy == null) return@LazyColumn
137-
if (gradingPolicy.assignmentPolicies.isNotEmpty()) {
137+
val assignmentPolicies = uiState.progress.getNotEmptyGradingPolicies()
138+
if (!assignmentPolicies.isNullOrEmpty()) {
138139
item {
139140
OverallGradeView(
140141
progress = uiState.progress,
@@ -143,7 +144,7 @@ private fun CourseProgressContent(
143144
item {
144145
GradeDetailsHeaderView()
145146
}
146-
itemsIndexed(gradingPolicy.assignmentPolicies) { index, policy ->
147+
itemsIndexed(assignmentPolicies) { index, policy ->
147148
AssignmentTypeRow(
148149
progress = uiState.progress,
149150
policy = policy,

0 commit comments

Comments
 (0)