Skip to content

Commit

Permalink
fix: show multiView enabled xBlocks on mobile only (#158)
Browse files Browse the repository at this point in the history
* fix: show multiView enabled xBlocks on mobile only

- Update conditions for components to show only enabled multiview xBlocks on mobile

fix: LEARNER-9699

* fix: handle studentViewData for video and discussion blocks

- Add checks to show appropriate view in case studentViewData is NullOrEmpty
  • Loading branch information
omerhabib26 authored Dec 12, 2023
1 parent 73ed462 commit 7265f38
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 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,19 +22,9 @@ 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 -> {
val encodedVideos = block.studentViewData!!.encodedVideos!!
return when {
(block.isVideoBlock && block.studentViewData?.encodedVideos != null) -> {
val encodedVideos = block.studentViewData?.encodedVideos!!
val transcripts = block.studentViewData!!.transcripts
with(encodedVideos) {
var isDownloaded = false
Expand Down Expand Up @@ -76,7 +65,7 @@ class CourseUnitContainerAdapter(
}
}

BlockType.DISCUSSION -> {
(block.isDiscussionBlock && block.studentViewData?.topicId.isNullOrEmpty().not()) -> {
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 7265f38

Please sign in to comment.