Skip to content

Commit 8de8a4d

Browse files
feat: [FC-0092] Course content tabs (#450)
* feat: all content tab * feat: video content tab * feat: video tab progress * fix: video progress caching * fix: changes according demo feedback * fix: assignment tab UI * fix: connected data to assignment tab UI * feat: color coding, detekt fixes * feat: resume video * fix: changes according review * feat: changes according PR feedback * feat: empty state view * fix: changes according PR review feedback * fix: changes according QA review feedback * feat: analytics * fix: changes according QA review * feat: db automigration
1 parent 12f3d75 commit 8de8a4d

File tree

70 files changed

+4258
-1403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4258
-1403
lines changed

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

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

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

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import org.openedx.core.presentation.settings.video.VideoQualityViewModel
1818
import org.openedx.core.repository.CalendarRepository
1919
import org.openedx.course.data.repository.CourseRepository
2020
import org.openedx.course.domain.interactor.CourseInteractor
21+
import org.openedx.course.presentation.assignments.CourseAssignmentViewModel
2122
import org.openedx.course.presentation.container.CourseContainerViewModel
23+
import org.openedx.course.presentation.contenttab.ContentTabViewModel
2224
import org.openedx.course.presentation.dates.CourseDatesViewModel
2325
import org.openedx.course.presentation.handouts.HandoutsViewModel
2426
import org.openedx.course.presentation.offline.CourseOfflineViewModel
25-
import org.openedx.course.presentation.outline.CourseOutlineViewModel
27+
import org.openedx.course.presentation.outline.CourseContentAllViewModel
2628
import org.openedx.course.presentation.progress.CourseProgressViewModel
2729
import org.openedx.course.presentation.section.CourseSectionViewModel
2830
import org.openedx.course.presentation.unit.container.CourseUnitContainerViewModel
@@ -281,7 +283,7 @@ val screenModule = module {
281283
)
282284
}
283285
viewModel { (courseId: String, courseTitle: String) ->
284-
CourseOutlineViewModel(
286+
CourseContentAllViewModel(
285287
courseId,
286288
courseTitle,
287289
get(),
@@ -300,6 +302,13 @@ val screenModule = module {
300302
get(),
301303
)
302304
}
305+
viewModel { (courseId: String, courseTitle: String) ->
306+
ContentTabViewModel(
307+
courseId,
308+
courseTitle,
309+
get(),
310+
)
311+
}
303312
viewModel { (courseId: String) ->
304313
CourseSectionViewModel(
305314
courseId,
@@ -320,10 +329,9 @@ val screenModule = module {
320329
get(),
321330
)
322331
}
323-
viewModel { (courseId: String, courseTitle: String) ->
332+
viewModel { (courseId: String) ->
324333
CourseVideoViewModel(
325334
courseId,
326-
courseTitle,
327335
get(),
328336
get(),
329337
get(),
@@ -343,19 +351,22 @@ val screenModule = module {
343351
}
344352
viewModel { (courseId: String) -> BaseVideoViewModel(courseId, get()) }
345353
viewModel { (courseId: String) -> VideoViewModel(courseId, get(), get(), get(), get()) }
346-
viewModel { (courseId: String) ->
354+
viewModel { (courseId: String, videoUrl: String, blockId: String) ->
347355
VideoUnitViewModel(
348356
courseId,
357+
videoUrl,
358+
blockId,
349359
get(),
350360
get(),
351361
get(),
352362
get(),
353363
get()
354364
)
355365
}
356-
viewModel { (courseId: String, blockId: String) ->
366+
viewModel { (courseId: String, videoUrl: String, blockId: String) ->
357367
EncodedVideoUnitViewModel(
358368
courseId,
369+
videoUrl,
359370
blockId,
360371
get(),
361372
get(),
@@ -538,4 +549,13 @@ val screenModule = module {
538549
router = get()
539550
)
540551
}
552+
viewModel { (courseId: String) ->
553+
CourseAssignmentViewModel(
554+
courseId = courseId,
555+
interactor = get(),
556+
courseRouter = get(),
557+
courseNotifier = get(),
558+
analytics = get()
559+
)
560+
}
541561
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.openedx.core.data.model.room.CourseProgressEntity
1111
import org.openedx.core.data.model.room.CourseStructureEntity
1212
import org.openedx.core.data.model.room.DownloadCoursePreview
1313
import org.openedx.core.data.model.room.OfflineXBlockProgress
14+
import org.openedx.core.data.model.room.VideoProgressEntity
1415
import org.openedx.core.data.model.room.discovery.EnrolledCourseEntity
1516
import org.openedx.core.data.storage.CourseDao
1617
import org.openedx.core.module.db.CalendarDao
@@ -22,9 +23,10 @@ import org.openedx.discovery.data.converter.DiscoveryConverter
2223
import org.openedx.discovery.data.model.room.CourseEntity
2324
import org.openedx.discovery.data.storage.DiscoveryDao
2425

25-
const val DATABASE_VERSION = 3
26+
const val DATABASE_VERSION = 4
2627
const val DATABASE_NAME = "OpenEdX_db"
2728

29+
@Suppress("MagicNumber")
2830
@Database(
2931
entities = [
3032
CourseEntity::class,
@@ -36,11 +38,13 @@ const val DATABASE_NAME = "OpenEdX_db"
3638
CourseCalendarStateEntity::class,
3739
DownloadCoursePreview::class,
3840
CourseEnrollmentDetailsEntity::class,
41+
VideoProgressEntity::class,
3942
CourseProgressEntity::class,
4043
],
4144
autoMigrations = [
4245
AutoMigration(1, 2),
43-
AutoMigration(2, DATABASE_VERSION),
46+
AutoMigration(2, 3),
47+
AutoMigration(3, DATABASE_VERSION),
4448
],
4549
version = DATABASE_VERSION
4650
)

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/NoContentScreenType.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ enum class NoContentScreenType(
1616
iconResId = R.drawable.core_ic_no_content,
1717
messageResId = R.string.core_no_dates
1818
),
19+
COURSE_ASSIGNMENT(
20+
iconResId = R.drawable.core_ic_no_content,
21+
messageResId = R.string.core_no_assignments
22+
),
1923
COURSE_DISCUSSIONS(
2024
iconResId = R.drawable.core_ic_no_content,
2125
messageResId = R.string.core_no_discussion

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,29 @@ import com.google.gson.annotations.SerializedName
44
import org.openedx.core.data.model.room.AssignmentProgressDb
55
import org.openedx.core.domain.model.AssignmentProgress
66

7+
private const val DEFAULT_LABEL_LENGTH = 5
8+
79
data class AssignmentProgress(
810
@SerializedName("assignment_type")
911
val assignmentType: String?,
1012
@SerializedName("num_points_earned")
1113
val numPointsEarned: Float?,
1214
@SerializedName("num_points_possible")
1315
val numPointsPossible: Float?,
16+
@SerializedName("short_label")
17+
val shortLabel: String?
1418
) {
15-
fun mapToDomain() = AssignmentProgress(
16-
assignmentType = assignmentType ?: "",
19+
fun mapToDomain(displayName: String) = AssignmentProgress(
20+
assignmentType = assignmentType,
1721
numPointsEarned = numPointsEarned ?: 0f,
18-
numPointsPossible = numPointsPossible ?: 0f
22+
numPointsPossible = numPointsPossible ?: 0f,
23+
shortLabel = shortLabel ?: displayName.take(DEFAULT_LABEL_LENGTH)
1924
)
2025

2126
fun mapToRoomEntity() = AssignmentProgressDb(
2227
assignmentType = assignmentType,
2328
numPointsEarned = numPointsEarned,
24-
numPointsPossible = numPointsPossible
29+
numPointsPossible = numPointsPossible,
30+
shortLabel = shortLabel
2531
)
2632
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ data class Block(
6565
blockCounts = blockCounts?.mapToDomain()!!,
6666
completion = completion ?: 0.0,
6767
containsGatedContent = containsGatedContent ?: false,
68-
assignmentProgress = assignmentProgress?.mapToDomain(),
68+
assignmentProgress = assignmentProgress?.mapToDomain(displayName.orEmpty()),
6969
due = TimeUtils.iso8601ToDate(due.orEmpty()),
7070
offlineDownload = offlineDownload?.mapToDomain()
7171
)
@@ -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/CourseProgressResponse.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ data class CourseProgressResponse(
157157
displayName = displayName ?: "",
158158
subsections = subsections?.map { it.mapToDomain() } ?: emptyList()
159159
)
160+
160161
data class Subsection(
161162
@SerializedName("assignment_type") val assignmentType: String?,
162163
@SerializedName("block_key") val blockKey: String?,
@@ -203,6 +204,7 @@ data class CourseProgressResponse(
203204
showGrades = showGrades ?: false,
204205
url = url ?: ""
205206
)
207+
206208
data class ProblemScore(
207209
@SerializedName("earned") val earned: Double?,
208210
@SerializedName("possible") val possible: Double?

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ data class Progress(
1111
val totalAssignmentsCount: Int?,
1212
) {
1313
fun mapToDomain() = Progress(
14-
assignmentsCompleted = assignmentsCompleted ?: 0,
15-
totalAssignmentsCount = totalAssignmentsCount ?: 0
14+
completed = assignmentsCompleted ?: 0,
15+
total = totalAssignmentsCount ?: 0
1616
)
1717

1818
fun mapToRoomEntity() = ProgressDb(

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

Lines changed: 7 additions & 3 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
}
@@ -230,11 +232,13 @@ data class AssignmentProgressDb(
230232
val numPointsEarned: Float?,
231233
@ColumnInfo("num_points_possible")
232234
val numPointsPossible: Float?,
235+
val shortLabel: String?
233236
) {
234237
fun mapToDomain() = DomainAssignmentProgress(
235-
assignmentType = assignmentType ?: "",
238+
assignmentType = assignmentType,
236239
numPointsEarned = numPointsEarned ?: 0f,
237-
numPointsPossible = numPointsPossible ?: 0f
240+
numPointsPossible = numPointsPossible ?: 0f,
241+
shortLabel = shortLabel ?: ""
238242
)
239243
}
240244

0 commit comments

Comments
 (0)