Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/src/main/java/org/openedx/app/di/ScreenModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.openedx.course.presentation.container.CourseContainerViewModel
import org.openedx.course.presentation.contenttab.ContentTabViewModel
import org.openedx.course.presentation.dates.CourseDatesViewModel
import org.openedx.course.presentation.handouts.HandoutsViewModel
import org.openedx.course.presentation.home.CourseHomeViewModel
import org.openedx.course.presentation.offline.CourseOfflineViewModel
import org.openedx.course.presentation.outline.CourseContentAllViewModel
import org.openedx.course.presentation.progress.CourseProgressViewModel
Expand Down Expand Up @@ -309,6 +310,27 @@ val screenModule = module {
get(),
)
}
viewModel { (courseId: String, courseTitle: String) ->
CourseHomeViewModel(
courseId,
courseTitle,
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get(),
get()
)
}
viewModel { (courseId: String) ->
CourseSectionViewModel(
courseId,
Expand Down
263 changes: 263 additions & 0 deletions core/src/main/java/org/openedx/core/Mock.kt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case we will use this file for tests only, probably we can move it to core/src/test or to debug/testFixtures?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not only tests. Also preview functions

Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
package org.openedx.core

import org.openedx.core.data.model.room.VideoProgressEntity
import org.openedx.core.domain.model.AssignmentProgress
import org.openedx.core.domain.model.Block
import org.openedx.core.domain.model.BlockCounts
import org.openedx.core.domain.model.CourseComponentStatus
import org.openedx.core.domain.model.CourseDatesBannerInfo
import org.openedx.core.domain.model.CourseDatesResult
import org.openedx.core.domain.model.CourseProgress
import org.openedx.core.domain.model.CourseStructure
import org.openedx.core.domain.model.CoursewareAccess
import org.openedx.core.domain.model.EncodedVideos
import org.openedx.core.domain.model.OfflineDownload
import org.openedx.core.domain.model.Progress
import org.openedx.core.domain.model.ResetCourseDates
import org.openedx.core.domain.model.StudentViewData
import org.openedx.core.domain.model.VideoInfo
import org.openedx.core.module.db.DownloadModel
import org.openedx.core.module.db.DownloadedState
import org.openedx.core.module.db.FileType
import java.util.Date

object Mock {
private val mockAssignmentProgress = AssignmentProgress(
assignmentType = "Home",
numPointsEarned = 1f,
numPointsPossible = 3f,
shortLabel = "HM1"
)
val mockChapterBlock = Block(
id = "id",
blockId = "blockId",
lmsWebUrl = "lmsWebUrl",
legacyWebUrl = "legacyWebUrl",
studentViewUrl = "studentViewUrl",
type = BlockType.CHAPTER,
displayName = "Chapter",
graded = false,
studentViewData = null,
studentViewMultiDevice = false,
blockCounts = BlockCounts(1),
descendants = emptyList(),
descendantsType = BlockType.CHAPTER,
completion = 0.0,
containsGatedContent = false,
assignmentProgress = mockAssignmentProgress,
due = Date(),
offlineDownload = null
)
private val mockSequentialBlock = Block(
id = "id",
blockId = "blockId",
lmsWebUrl = "lmsWebUrl",
legacyWebUrl = "legacyWebUrl",
studentViewUrl = "studentViewUrl",
type = BlockType.SEQUENTIAL,
displayName = "Sequential",
graded = false,
studentViewData = null,
studentViewMultiDevice = false,
blockCounts = BlockCounts(1),
descendants = emptyList(),
descendantsType = BlockType.CHAPTER,
completion = 0.0,
containsGatedContent = false,
assignmentProgress = mockAssignmentProgress,
due = Date(),
offlineDownload = OfflineDownload("fileUrl", "", 1),
)

val mockCourseStructure = CourseStructure(
root = "",
blockData = listOf(mockSequentialBlock, mockSequentialBlock),
id = "id",
name = "Course name",
number = "",
org = "Org",
start = Date(),
startDisplay = "",
startType = "",
end = Date(),
coursewareAccess = CoursewareAccess(
true,
"",
"",
"",
"",
""
),
media = null,
certificate = null,
isSelfPaced = false,
progress = Progress(1, 3),
)

val mockCourseComponentStatus = CourseComponentStatus(
lastVisitedBlockId = "video1"
)

val mockCourseDatesBannerInfo = CourseDatesBannerInfo(
missedDeadlines = false,
missedGatedContent = false,
contentTypeGatingEnabled = false,
verifiedUpgradeLink = "",
hasEnded = false
)

val mockCourseDatesResult = CourseDatesResult(
datesSection = linkedMapOf(),
courseBanner = mockCourseDatesBannerInfo
)

val mockCourseProgress = CourseProgress(
verifiedMode = "audit",
accessExpiration = "",
certificateData = null,
completionSummary = null,
courseGrade = null,
creditCourseRequirements = "",
end = "",
enrollmentMode = "audit",
gradingPolicy = null,
hasScheduledContent = false,
sectionScores = emptyList(),
studioUrl = "",
username = "testuser",
userHasPassingGrade = false,
verificationData = null,
disableProgressGraph = false
)

val mockVideoProgress = VideoProgressEntity(
blockId = "video1",
videoUrl = "test-video-url",
videoTime = 1000L,
duration = 5000L
)

val mockResetCourseDates = ResetCourseDates(
message = "Dates reset successfully",
body = "Your course dates have been reset",
header = "Success",
link = "",
linkText = ""
)

val mockDownloadModel = DownloadModel(
id = "video1",
title = "Video 1",
courseId = "test-course-id",
size = 1000L,
path = "/test/path/video1",
url = "test-url",
type = FileType.VIDEO,
downloadedState = DownloadedState.NOT_DOWNLOADED,
lastModified = null
)

val mockVideoBlock = Block(
id = "video1",
blockId = "video1",
lmsWebUrl = "lmsWebUrl",
legacyWebUrl = "legacyWebUrl",
studentViewUrl = "studentViewUrl",
type = BlockType.VIDEO,
displayName = "Video 1",
graded = false,
studentViewData = StudentViewData(
onlyOnWeb = false,
duration = "",
transcripts = null,
encodedVideos = EncodedVideos(
youtube = null,
hls = null,
fallback = null,
desktopMp4 = null,
mobileHigh = null,
mobileLow = VideoInfo(
url = "test-url",
fileSize = 1000L
)
),
topicId = ""
),
studentViewMultiDevice = false,
blockCounts = BlockCounts(0),
descendants = emptyList(),
descendantsType = BlockType.VIDEO,
completion = 0.0,
containsGatedContent = false,
assignmentProgress = null,
due = null,
offlineDownload = null,
)

val mockSequentialBlockForDownload = Block(
id = "sequential1",
blockId = "sequential1",
lmsWebUrl = "lmsWebUrl",
legacyWebUrl = "legacyWebUrl",
studentViewUrl = "studentViewUrl",
type = BlockType.SEQUENTIAL,
displayName = "Sequential 1",
graded = false,
studentViewData = null,
studentViewMultiDevice = false,
blockCounts = BlockCounts(0),
descendants = listOf("vertical1"),
descendantsType = BlockType.VERTICAL,
completion = 0.0,
containsGatedContent = false,
assignmentProgress = null,
due = null,
offlineDownload = null,
)

val mockVerticalBlock = Block(
id = "vertical1",
blockId = "vertical1",
lmsWebUrl = "lmsWebUrl",
legacyWebUrl = "legacyWebUrl",
studentViewUrl = "studentViewUrl",
type = BlockType.VERTICAL,
displayName = "Vertical 1",
graded = false,
studentViewData = null,
studentViewMultiDevice = false,
blockCounts = BlockCounts(0),
descendants = listOf("video1"),
descendantsType = BlockType.VIDEO,
completion = 0.0,
containsGatedContent = false,
assignmentProgress = null,
due = null,
offlineDownload = null,
)

val mockCourseStructureForDownload = CourseStructure(
root = "sequential1",
blockData = listOf(mockSequentialBlockForDownload, mockVerticalBlock, mockVideoBlock),
id = "test-course-id",
name = "Test Course",
number = "CS101",
org = "TestOrg",
start = Date(),
startDisplay = "2024-01-01",
startType = "timestamped",
end = Date(),
coursewareAccess = CoursewareAccess(
true,
"",
"",
"",
"",
""
),
media = null,
certificate = null,
isSelfPaced = false,
progress = null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ data class CourseProgress(
return if (notCompletedPercent < 0.0) 0f else notCompletedPercent.toFloat()
}

fun getNotEmptyGradingPolicies() = gradingPolicy?.assignmentPolicies?.mapNotNull {
if (getPossibleAssignmentProblems(it) > 0) {
it
} else {
null
}
}

data class CertificateData(
val certStatus: String,
val certWebViewUrl: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ class CourseNotifier {
suspend fun send(event: RefreshDates) = channel.emit(event)
suspend fun send(event: RefreshDiscussions) = channel.emit(event)
suspend fun send(event: RefreshProgress) = channel.emit(event)
suspend fun send(event: CourseProgressLoaded) = channel.emit(event)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.openedx.core.system.notifier

object CourseProgressLoaded : CourseEvent
Loading
Loading