Skip to content

Commit ea8c616

Browse files
fix: Changes according QA review
1 parent 44f4f4e commit ea8c616

File tree

23 files changed

+151
-100
lines changed

23 files changed

+151
-100
lines changed

app/src/main/java/org/openedx/app/di/ScreenModule.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import org.openedx.course.presentation.dates.CourseDatesViewModel
2525
import org.openedx.course.presentation.handouts.HandoutsViewModel
2626
import org.openedx.course.presentation.offline.CourseOfflineViewModel
2727
import org.openedx.course.presentation.outline.CourseContentAllViewModel
28-
import org.openedx.course.presentation.outline.CourseOutlineViewModel
2928
import org.openedx.course.presentation.progress.CourseProgressViewModel
3029
import org.openedx.course.presentation.section.CourseSectionViewModel
3130
import org.openedx.course.presentation.unit.container.CourseUnitContainerViewModel

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.openedx.discovery.data.storage.DiscoveryDao
2626
const val DATABASE_VERSION = 4
2727
const val DATABASE_NAME = "OpenEdX_db"
2828

29+
@Suppress("MagicNumber")
2930
@Database(
3031
entities = [
3132
CourseEntity::class,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DatabaseManager(
1717
) : DatabaseManager {
1818
override fun clearTables() {
1919
CoroutineScope(Dispatchers.IO).launch {
20-
courseDao.clearCourseData()
20+
courseDao.clearCachedData()
2121
dashboardDao.clearCachedData()
2222
downloadDao.clearOfflineProgress()
2323
discoveryDao.clearCachedData()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ data class AssignmentProgress(
1717
val shortLabel: String?
1818
) {
1919
fun mapToDomain(displayName: String) = AssignmentProgress(
20-
assignmentType = assignmentType ?: "",
20+
assignmentType = assignmentType,
2121
numPointsEarned = numPointsEarned ?: 0f,
2222
numPointsPossible = numPointsPossible ?: 0f,
2323
shortLabel = shortLabel ?: displayName.take(DEFAULT_LABEL_LENGTH)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ data class VideoInfo(
136136
var fileSize: Long?
137137
) {
138138
fun mapToDomain() = DomainVideoInfo(
139-
url = url.orEmpty(),
139+
url = url
140+
.orEmpty()
141+
.trim(),
140142
fileSize = fileSize ?: 0
141143
)
142144
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ data class VideoInfoDb(
203203
fun createFrom(videoInfo: VideoInfo?): VideoInfoDb? {
204204
if (videoInfo == null) return null
205205
return VideoInfoDb(
206-
videoInfo.url ?: "",
206+
videoInfo.url
207+
.orEmpty()
208+
.trim(),
207209
videoInfo.fileSize ?: 0,
208210
)
209211
}
@@ -233,7 +235,7 @@ data class AssignmentProgressDb(
233235
val shortLabel: String?
234236
) {
235237
fun mapToDomain() = DomainAssignmentProgress(
236-
assignmentType = assignmentType ?: "",
238+
assignmentType = assignmentType,
237239
numPointsEarned = numPointsEarned ?: 0f,
238240
numPointsPossible = numPointsPossible ?: 0f,
239241
shortLabel = shortLabel ?: ""

core/src/main/java/org/openedx/core/data/storage/CourseDao.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@ interface CourseDao {
2020
suspend fun insertCourseStructureEntity(vararg courseStructureEntity: CourseStructureEntity)
2121

2222
@Transaction
23-
suspend fun clearCourseData() {
24-
clearCourseStructureData()
25-
clearCourseProgressData()
23+
suspend fun clearCachedData() {
24+
clearCourseStructure()
25+
clearVideoProgress()
2626
clearEnrollmentCachedData()
27+
clearCourseProgressData()
2728
}
2829

2930
@Query("DELETE FROM course_structure_table")
30-
suspend fun clearCourseStructureData()
31+
suspend fun clearCourseStructure()
3132

32-
@Query("DELETE FROM course_progress_table")
33-
suspend fun clearCourseProgressData()
33+
@Query("DELETE FROM video_progress_table")
34+
suspend fun clearVideoProgress()
3435

3536
@Query("DELETE FROM course_enrollment_details_table")
3637
suspend fun clearEnrollmentCachedData()
3738

39+
@Query("DELETE FROM course_progress_table")
40+
suspend fun clearCourseProgressData()
41+
3842
@Insert(onConflict = OnConflictStrategy.REPLACE)
3943
suspend fun insertCourseEnrollmentDetailsEntity(vararg courseEnrollmentDetailsEntity: CourseEnrollmentDetailsEntity)
4044

4145
@Query("SELECT * FROM course_enrollment_details_table WHERE id=:id")
4246
suspend fun getCourseEnrollmentDetailsById(id: String): CourseEnrollmentDetailsEntity?
4347

44-
45-
@Query("DELETE FROM course_progress_table")
46-
suspend fun clearCourseProgressData()
47-
4848
@Insert(onConflict = OnConflictStrategy.REPLACE)
4949
suspend fun insertVideoProgressEntity(vararg videoProgressEntity: VideoProgressEntity)
5050

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import org.openedx.core.extension.safeDivBy
77

88
@Parcelize
99
data class AssignmentProgress(
10-
val assignmentType: String,
10+
val assignmentType: String?,
1111
val numPointsEarned: Float,
1212
val numPointsPossible: Float,
1313
val shortLabel: String
@@ -16,8 +16,8 @@ data class AssignmentProgress(
1616
@IgnoredOnParcel
1717
val value: Float = numPointsEarned.safeDivBy(numPointsPossible)
1818

19-
override fun toString(): String {
20-
return "${numPointsEarned.toInt()}/${numPointsPossible.toInt()}"
19+
fun toPointString(separator: String = ""): String {
20+
return "${numPointsEarned.toInt()}$separator/$separator${numPointsPossible.toInt()}"
2121
}
2222

2323
@IgnoredOnParcel

core/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
<string name="core_no_videos">No videos available for this course.</string>
161161
<string name="core_no_dates">Course dates are currently not available.</string>
162162
<string name="core_no_progress">This course does not contain exams or graded assignments.</string>
163-
<string name="core_no_assignments">Course assignment are currently not available.</string>
164163
<string name="core_no_assignments">No assignments available for this course.</string>
165164
<string name="core_no_discussion">Unable to load discussions.\n Please try again later.</string>
166165
<string name="core_no_handouts">There are currently no handouts for this course.</string>
@@ -185,7 +184,6 @@
185184
<string name="core_delete_in_process_confirmation" formatted="false">Turning off the switch will stop downloading and delete all downloaded videos for \"%s\"?</string>
186185
<string name="core_delete_confirmation" formatted="false">Are you sure you want to delete all video(s) for \"%s\"?</string>
187186
<string name="core_delete_download_confirmation_text" formatted="false">Are you sure you want to delete video(s) for \"%s\"?</string>
188-
<string name="core_subsection_assignment_info" translatable="false">%1$s - %2$s - %3$d / %4$d</string>
189187
<string name="core_download_no_internet_dialog_description">Downloading this content requires an active internet connection. Please connect to the internet and try again.</string>
190188
<string name="core_wifi_required">Wi-Fi Required</string>
191189
<string name="core_download_wifi_required_dialog_description">Downloading this content requires an active WiFi connection. Please connect to a WiFi network and try again.</string>

course/src/main/java/org/openedx/course/data/repository/CourseRepository.kt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,19 +241,6 @@ class CourseRepository(
241241
}
242242
}
243243

244-
fun getCourseProgress(courseId: String, isRefresh: Boolean): Flow<CourseProgress> =
245-
channelFlowWithAwait {
246-
if (!isRefresh) {
247-
val cached = courseDao.getCourseProgressById(courseId)
248-
if (cached != null) {
249-
trySend(cached.mapToDomain())
250-
}
251-
}
252-
val response = api.getCourseProgress(courseId)
253-
courseDao.insertCourseProgressEntity(response.mapToRoomEntity(courseId))
254-
trySend(response.mapToDomain())
255-
}
256-
257244
suspend fun saveVideoProgress(
258245
blockId: String,
259246
videoUrl: String,

0 commit comments

Comments
 (0)