Skip to content

Commit d8614c0

Browse files
fix: changes according QA review feedback
1 parent e5311f5 commit d8614c0

File tree

13 files changed

+44
-29
lines changed

13 files changed

+44
-29
lines changed

core/src/main/java/org/openedx/core/data/model/AssignmentProgress.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ data class AssignmentProgress(
1414
@SerializedName("num_points_possible")
1515
val numPointsPossible: Float?,
1616
@SerializedName("short_label")
17-
val label: String?
17+
val shortLabel: String?
1818
) {
1919
fun mapToDomain(displayName: String) = AssignmentProgress(
2020
assignmentType = assignmentType ?: "",
2121
numPointsEarned = numPointsEarned ?: 0f,
2222
numPointsPossible = numPointsPossible ?: 0f,
23-
label = label ?: displayName.take(DEFAULT_LABEL_LENGTH)
23+
shortLabel = shortLabel ?: displayName.take(DEFAULT_LABEL_LENGTH)
2424
)
2525

2626
fun mapToRoomEntity() = AssignmentProgressDb(
2727
assignmentType = assignmentType,
2828
numPointsEarned = numPointsEarned,
2929
numPointsPossible = numPointsPossible,
30-
label = label
30+
shortLabel = shortLabel
3131
)
3232
}

core/src/main/java/org/openedx/core/data/model/room/BlockDb.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ data class AssignmentProgressDb(
230230
val numPointsEarned: Float?,
231231
@ColumnInfo("num_points_possible")
232232
val numPointsPossible: Float?,
233-
val label: String?
233+
val shortLabel: String?
234234
) {
235235
fun mapToDomain() = DomainAssignmentProgress(
236236
assignmentType = assignmentType ?: "",
237237
numPointsEarned = numPointsEarned ?: 0f,
238238
numPointsPossible = numPointsPossible ?: 0f,
239-
label = label ?: ""
239+
shortLabel = shortLabel ?: ""
240240
)
241241
}
242242

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class AssignmentProgress(
1010
val assignmentType: String,
1111
val numPointsEarned: Float,
1212
val numPointsPossible: Float,
13-
val label: String
13+
val shortLabel: String
1414
) : Parcelable {
1515

1616
@IgnoredOnParcel
@@ -19,4 +19,9 @@ data class AssignmentProgress(
1919
override fun toString(): String {
2020
return "${numPointsEarned.toInt()}/${numPointsPossible.toInt()}"
2121
}
22+
23+
@IgnoredOnParcel
24+
val label = shortLabel
25+
.replace(" ", "")
26+
.replaceFirst(Regex("^(\\D+)(0*)(\\d+)$"), "$1$3")
2227
}

course/src/main/java/org/openedx/course/presentation/assignments/CourseAssignmentViewModel.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,16 @@ class CourseAssignmentViewModel(
6464
if (assignments.isEmpty()) {
6565
_uiState.value = CourseAssignmentUIState.Empty
6666
} else {
67-
val grouped = assignments
68-
.filter { assignments ->
69-
courseProgress.gradingPolicy?.assignmentPolicies?.map { it.type }
70-
?.contains(assignments.assignmentProgress?.assignmentType) == true
67+
val assignmentTypeOrder =
68+
courseProgress.gradingPolicy?.assignmentPolicies?.map { it.type } ?: emptyList()
69+
val filteredAssignments = assignments
70+
.filter { assignment ->
71+
assignmentTypeOrder.contains(assignment.assignmentProgress?.assignmentType)
7172
}
73+
.filter { it.graded }
74+
val grouped = filteredAssignments
7275
.groupBy { it.assignmentProgress?.assignmentType ?: "" }
76+
.toSortedMap(compareBy { assignmentTypeOrder.indexOf(it) })
7377
val completed = assignments.count { it.isCompleted() }
7478
val total = assignments.size
7579
val progress = Progress(completed, total)

course/src/main/java/org/openedx/course/presentation/assignments/CourseContentAssignmentScreen.kt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ private const val ASSIGNMENT_BUTTON_CARD_BACKGROUND_ALPHA = 0.5f
7979
private const val COMPLETED_ASSIGNMENTS_COUNT = 1
8080
private const val COMPLETED_ASSIGNMENTS_COUNT_TABLET = 2
8181
private const val TOTAL_ASSIGNMENTS_COUNT = 3
82-
private const val SHORT_LABEL_PREFIX_SIZE = 3
8382

8483
@Composable
8584
fun CourseContentAssignmentScreen(
@@ -139,15 +138,18 @@ private fun CourseContentAssignmentScreen(
139138
is CourseAssignmentUIState.CourseData -> {
140139
val gradingPolicy = uiState.courseProgress.gradingPolicy
141140
val defaultGradeColor = MaterialTheme.appColors.primary
142-
Box(modifier = screenWidth) {
141+
Box(
142+
modifier = Modifier.fillMaxSize(),
143+
contentAlignment = Alignment.TopCenter
144+
) {
143145
val progress = uiState.progress
144146
val description = stringResource(
145147
id = R.string.course_completed,
146148
progress.completed,
147149
progress.total
148150
)
149151
LazyColumn(
150-
modifier = Modifier.fillMaxSize(),
152+
modifier = screenWidth,
151153
contentPadding = PaddingValues(bottom = 16.dp)
152154
) {
153155
item {
@@ -308,9 +310,6 @@ private fun AssignmentGroupSection(
308310

309311
@Composable
310312
private fun AssignmentButton(assignment: Block, isSelected: Boolean, onClick: () -> Unit) {
311-
val label = assignment.assignmentProgress?.label?.split(" ").let {
312-
it?.first()?.take(SHORT_LABEL_PREFIX_SIZE) + it?.last()
313-
}
314313
val isDuePast = assignment.due != null && assignment.due!! < Date()
315314
val cardBorderColor = when {
316315
isSelected -> MaterialTheme.appColors.primary
@@ -368,7 +367,7 @@ private fun AssignmentButton(assignment: Block, isSelected: Boolean, onClick: ()
368367
) {
369368
Text(
370369
modifier = Modifier.align(Alignment.Center),
371-
text = label,
370+
text = assignment.assignmentProgress?.label ?: "",
372371
color = MaterialTheme.appColors.textDark,
373372
style = MaterialTheme.appTypography.bodyMedium,
374373
maxLines = 1,
@@ -412,11 +411,14 @@ private fun AssignmentDetails(
412411
onAssignmentClick: (Block) -> Unit,
413412
) {
414413
val dueDate =
415-
assignment.due?.let { TimeUtils.formatToDueInString(LocalContext.current, it) } ?: ""
414+
assignment.due?.let {
415+
TimeUtils.formatToDueInString(LocalContext.current, it)
416+
} ?: ""
417+
val isDuePast = assignment.due != null && assignment.due!! < Date()
416418
val progress = assignment.completion.toFloat()
417419
val color = when {
418420
assignment.isCompleted() -> MaterialTheme.appColors.successGreen
419-
assignment.due != null && assignment.due!! > Date() -> MaterialTheme.appColors.warning
421+
isDuePast -> MaterialTheme.appColors.warning
420422
else -> MaterialTheme.appColors.cardViewBorder
421423
}
422424
val label = assignment.assignmentProgress?.label
@@ -428,13 +430,17 @@ private fun AssignmentDetails(
428430
)
429431
}
430432

431-
assignment.due != null && assignment.due!! > Date() -> {
433+
isDuePast -> {
432434
"$label " + stringResource(
433435
R.string.course_past_due,
434436
assignment.assignmentProgress?.toString() ?: ""
435437
)
436438
}
437439

440+
assignment.due == null -> {
441+
"$label - ${assignment.assignmentProgress}"
442+
}
443+
438444
else -> {
439445
"$label $dueDate"
440446
}
@@ -637,7 +643,7 @@ private val mockAssignmentProgress = AssignmentProgress(
637643
assignmentType = "Home",
638644
numPointsEarned = 1f,
639645
numPointsPossible = 3f,
640-
label = "HM1"
646+
shortLabel = "HM1"
641647
)
642648

643649
private val mockChapterBlock = Block(

course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ fun CourseDashboard(
309309
) {
310310
IconText(
311311
text = stringResource(R.string.course_review_grading_policy),
312-
painter = painterResource(id = coreR.drawable.core_ic_assignment),
312+
painter = painterResource(id = coreR.drawable.core_ic_mountains),
313313
color = MaterialTheme.appColors.primary,
314314
textStyle = MaterialTheme.appTypography.labelLarge
315315
)

course/src/main/java/org/openedx/course/presentation/outline/CourseContentAllScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ private val mockAssignmentProgress = AssignmentProgress(
483483
assignmentType = "Home",
484484
numPointsEarned = 1f,
485485
numPointsPossible = 3f,
486-
label = "HM1"
486+
shortLabel = "HM1"
487487
)
488488
private val mockChapterBlock = Block(
489489
id = "id",

course/src/main/java/org/openedx/course/presentation/videos/CourseContentVideoScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private val mockAssignmentProgress = AssignmentProgress(
308308
assignmentType = "Home",
309309
numPointsEarned = 1f,
310310
numPointsPossible = 3f,
311-
label = "HM1"
311+
shortLabel = "HM1"
312312
)
313313

314314
private val mockChapterBlock = Block(

course/src/test/java/org/openedx/course/presentation/outline/CourseOutlineViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CourseOutlineViewModelTest {
9696
assignmentType = "Homework",
9797
numPointsEarned = 1f,
9898
numPointsPossible = 3f,
99-
label = "HW1",
99+
shortLabel = "HW1",
100100
)
101101

102102
private val blocks = listOf(

course/src/test/java/org/openedx/course/presentation/section/CourseSectionViewModelTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CourseSectionViewModelTest {
7474
assignmentType = "Homework",
7575
numPointsEarned = 1f,
7676
numPointsPossible = 3f,
77-
label = "HW1",
77+
shortLabel = "HW1",
7878
)
7979

8080
private val blocks = listOf(

0 commit comments

Comments
 (0)