Skip to content

Commit

Permalink
fix: made model class format consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-arshad-dev committed Nov 7, 2023
1 parent 9ab3473 commit 9709ea8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 22 deletions.
30 changes: 20 additions & 10 deletions core/src/main/java/org/openedx/core/data/model/CourseDateBlock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ import com.google.gson.annotations.SerializedName
import java.util.*

data class CourseDateBlock(
@SerializedName("complete") val complete: Boolean = false,
@SerializedName("date") val date: String = "", // ISO 8601 compliant format
@SerializedName("assignment_type") val assignmentType: String? = "",
@SerializedName("date_type") val dateType: DateType = DateType.NONE,
@SerializedName("description") val description: String = "",
@SerializedName("learner_has_access") val learnerHasAccess: Boolean = false,
@SerializedName("link") val link: String = "",
@SerializedName("link_text") val linkText: String = "",
@SerializedName("title") val title: String = "",
@SerializedName("complete")
val complete: Boolean = false,
@SerializedName("date")
val date: String = "", // ISO 8601 compliant format
@SerializedName("assignment_type")
val assignmentType: String? = "",
@SerializedName("date_type")
val dateType: DateType = DateType.NONE,
@SerializedName("description")
val description: String = "",
@SerializedName("learner_has_access")
val learnerHasAccess: Boolean = false,
@SerializedName("link")
val link: String = "",
@SerializedName("link_text")
val linkText: String = "",
@SerializedName("title")
val title: String = "",
// component blockId in-case of navigating inside the app for component available in mobile
@SerializedName("first_component_block_id") val blockId: String = ""
@SerializedName("first_component_block_id")
val blockId: String = "",
)
21 changes: 14 additions & 7 deletions core/src/main/java/org/openedx/core/data/model/CourseDates.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ import java.util.Date
import org.openedx.core.domain.model.CourseDateBlock as DomainCourseDateBlock

data class CourseDates(
@SerializedName("dates_banner_info") val datesBannerInfo: CourseDatesBannerInfo?,
@SerializedName("course_date_blocks") val courseDateBlocks: List<CourseDateBlock>,
@SerializedName("missed_deadlines") val missedDeadlines: Boolean = false,
@SerializedName("missed_gated_content") val missedGatedContent: Boolean = false,
@SerializedName("learner_is_full_access") val learnerIsFullAccess: Boolean = false,
@SerializedName("user_timezone") val userTimezone: String? = "",
@SerializedName("verified_upgrade_link") val verifiedUpgradeLink: String? = "",
@SerializedName("dates_banner_info")
val datesBannerInfo: CourseDatesBannerInfo?,
@SerializedName("course_date_blocks")
val courseDateBlocks: List<CourseDateBlock>,
@SerializedName("missed_deadlines")
val missedDeadlines: Boolean = false,
@SerializedName("missed_gated_content")
val missedGatedContent: Boolean = false,
@SerializedName("learner_is_full_access")
val learnerIsFullAccess: Boolean = false,
@SerializedName("user_timezone")
val userTimezone: String? = "",
@SerializedName("verified_upgrade_link")
val verifiedUpgradeLink: String? = "",
) {
fun mapToDomain(): LinkedHashMap<String, ArrayList<DomainCourseDateBlock>> {
var courseDatesDomain = organiseCourseDatesInBlock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ package org.openedx.core.data.model
import com.google.gson.annotations.SerializedName

data class CourseDatesBannerInfo(
@SerializedName("missed_deadlines") val missedDeadlines: Boolean = false,
@SerializedName("missed_gated_content") val missedGatedContent: Boolean = false,
@SerializedName("verified_upgrade_link") val verifiedUpgradeLink: String = "",
@SerializedName("content_type_gating_enabled") val contentTypeGatingEnabled: Boolean = false
@SerializedName("missed_deadlines")
val missedDeadlines: Boolean = false,
@SerializedName("missed_gated_content")
val missedGatedContent: Boolean = false,
@SerializedName("verified_upgrade_link")
val verifiedUpgradeLink: String = "",
@SerializedName("content_type_gating_enabled")
val contentTypeGatingEnabled: Boolean = false,
) {
fun getCourseBannerType(): CourseBannerType = when {
upgradeToGraded() -> CourseBannerType.UPGRADE_TO_GRADED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ class CourseContainerFragment : Fragment(R.layout.fragment_course_container) {

private fun initViewPager() {
binding.viewPager.orientation = ViewPager2.ORIENTATION_HORIZONTAL
binding.viewPager.offscreenPageLimit = 4
adapter = CourseContainerAdapter(this).apply {
addFragment(CourseOutlineFragment.newInstance(viewModel.courseId, courseTitle))
addFragment(CourseVideosFragment.newInstance(viewModel.courseId, courseTitle))
addFragment(DiscussionTopicsFragment.newInstance(viewModel.courseId, courseTitle))
addFragment(CourseDatesFragment.newInstance(viewModel.courseId, courseTitle))
addFragment(HandoutsFragment.newInstance(viewModel.courseId))
}
binding.viewPager.offscreenPageLimit = adapter?.itemCount ?: 1
binding.viewPager.adapter = adapter
binding.viewPager.isUserInputEnabled = false
}
Expand Down

0 comments on commit 9709ea8

Please sign in to comment.