Skip to content

Commit

Permalink
fix: show multiView enabled xBlocks on mobile only
Browse files Browse the repository at this point in the history
- Update conditions for components to show only enabled multiview xBlocks on mobile

fix: LEARNER-9699
  • Loading branch information
omerhabib26 committed Dec 11, 2023
1 parent db65070 commit 1393a28
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
8 changes: 8 additions & 0 deletions core/src/main/java/org/openedx/core/domain/model/Block.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ data class Block(

fun isDownloaded() = downloadModel?.downloadedState == DownloadedState.DOWNLOADED

val isVideoBlock get() = type == BlockType.VIDEO
val isDiscussionBlock get() = type == BlockType.DISCUSSION
val isHTMLBlock get() = type == BlockType.HTML
val isProblemBlock get() = type == BlockType.PROBLEM
val isOpenAssessmentBlock get() = type == BlockType.OPENASSESSMENT
val isDragAndDropBlock get() = type == BlockType.DRAG_AND_DROP_V2
val isWordCloudBlock get() = type == BlockType.WORD_CLOUD
val isLTIConsumerBlock get() = type == BlockType.LTI_CONSUMER
}

data class StudentViewData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package org.openedx.course.presentation.unit.container

import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import org.openedx.core.BlockType
import org.openedx.core.FragmentViewType
import org.openedx.core.domain.model.Block
import org.openedx.course.presentation.unit.NotSupportedUnitFragment
Expand All @@ -23,18 +22,8 @@ class CourseUnitContainerAdapter(
override fun createFragment(position: Int): Fragment = unitBlockFragment(blocks[position])

private fun unitBlockFragment(block: Block): Fragment {
return when (block.type) {
BlockType.HTML,
BlockType.PROBLEM,
BlockType.OPENASSESSMENT,
BlockType.DRAG_AND_DROP_V2,
BlockType.WORD_CLOUD,
BlockType.LTI_CONSUMER,
-> {
HtmlUnitFragment.newInstance(block.id, block.studentViewUrl)
}

BlockType.VIDEO -> {
return when {
block.isVideoBlock -> {
val encodedVideos = block.studentViewData!!.encodedVideos!!
val transcripts = block.studentViewData!!.transcripts
with(encodedVideos) {
Expand Down Expand Up @@ -76,7 +65,7 @@ class CourseUnitContainerAdapter(
}
}

BlockType.DISCUSSION -> {
block.isDiscussionBlock -> {
DiscussionThreadsFragment.newInstance(
DiscussionTopicsFragment.TOPIC,
viewModel.courseId,
Expand All @@ -87,6 +76,22 @@ class CourseUnitContainerAdapter(
)
}

block.studentViewMultiDevice.not() -> {
NotSupportedUnitFragment.newInstance(
block.id,
block.lmsWebUrl
)
}

block.isHTMLBlock ||
block.isProblemBlock ||
block.isOpenAssessmentBlock ||
block.isDragAndDropBlock ||
block.isWordCloudBlock ||
block.isLTIConsumerBlock -> {
HtmlUnitFragment.newInstance(block.id, block.studentViewUrl)
}

else -> {
NotSupportedUnitFragment.newInstance(
block.id,
Expand All @@ -95,4 +100,4 @@ class CourseUnitContainerAdapter(
}
}
}
}
}

0 comments on commit 1393a28

Please sign in to comment.