Skip to content

Commit a2f36a3

Browse files
fix: changes according QA review feedback
1 parent b350dc8 commit a2f36a3

File tree

15 files changed

+1283
-31
lines changed

15 files changed

+1283
-31
lines changed

app/schemas/org.openedx.app.room.AppDatabase/3.json

Lines changed: 1236 additions & 0 deletions
Large diffs are not rendered by default.

app/src/main/java/org/openedx/app/room/AppDatabase.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.openedx.discovery.data.converter.DiscoveryConverter
2323
import org.openedx.discovery.data.model.room.CourseEntity
2424
import org.openedx.discovery.data.storage.DiscoveryDao
2525

26-
const val DATABASE_VERSION = 2
26+
const val DATABASE_VERSION = 3
2727
const val DATABASE_NAME = "OpenEdX_db"
2828

2929
@Database(
@@ -41,7 +41,8 @@ const val DATABASE_NAME = "OpenEdX_db"
4141
CourseProgressEntity::class,
4242
],
4343
autoMigrations = [
44-
AutoMigration(1, DATABASE_VERSION)
44+
AutoMigration(1, 2),
45+
AutoMigration(2, DATABASE_VERSION),
4546
],
4647
version = DATABASE_VERSION
4748
)

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
@@ -306,7 +306,7 @@ fun CourseDashboard(
306306
) {
307307
IconText(
308308
text = stringResource(R.string.course_review_grading_policy),
309-
painter = painterResource(id = coreR.drawable.core_ic_assignment),
309+
painter = painterResource(id = coreR.drawable.core_ic_mountains),
310310
color = MaterialTheme.appColors.primary,
311311
textStyle = MaterialTheme.appTypography.labelLarge
312312
)

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(

0 commit comments

Comments
 (0)