diff --git a/app/src/main/java/org/openedx/app/di/ScreenModule.kt b/app/src/main/java/org/openedx/app/di/ScreenModule.kt index c74d007a5..a32c35c22 100644 --- a/app/src/main/java/org/openedx/app/di/ScreenModule.kt +++ b/app/src/main/java/org/openedx/app/di/ScreenModule.kt @@ -246,6 +246,7 @@ val screenModule = module { get(), get(), get(), + get(), ) } viewModel { (courseId: String, handoutsType: String) -> diff --git a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesFragment.kt b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesFragment.kt index 39a342634..4b0e175c1 100644 --- a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesFragment.kt @@ -156,16 +156,26 @@ class CourseDatesFragment : Fragment() { onItemClick = { blockId -> if (blockId.isNotEmpty()) { viewModel.getVerticalBlock(blockId)?.let { verticalBlock -> - viewModel.getSequentialBlock(verticalBlock.id) - ?.let { sequentialBlock -> - router.navigateToCourseSubsections( - fm = requireActivity().supportFragmentManager, - subSectionId = sequentialBlock.id, - courseId = viewModel.courseId, - unitId = verticalBlock.id, - mode = CourseViewMode.FULL - ) - } + if (viewModel.isCourseExpandableSectionsEnabled) { + router.navigateToCourseContainer( + fm = requireActivity().supportFragmentManager, + courseId = viewModel.courseId, + unitId = verticalBlock.id, + componentId = "", + mode = CourseViewMode.FULL + ) + } else { + viewModel.getSequentialBlock(verticalBlock.id) + ?.let { sequentialBlock -> + router.navigateToCourseSubsections( + fm = requireActivity().supportFragmentManager, + subSectionId = sequentialBlock.id, + courseId = viewModel.courseId, + unitId = verticalBlock.id, + mode = CourseViewMode.FULL + ) + } + } } } }, diff --git a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt index 2380dbab4..6313b599d 100644 --- a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.launch import org.openedx.core.BaseViewModel import org.openedx.core.SingleEventLiveData import org.openedx.core.UIMessage +import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Block import org.openedx.core.extension.getSequentialBlocks @@ -37,6 +38,7 @@ class CourseDatesViewModel( private val networkConnection: NetworkConnection, private val resourceManager: ResourceManager, private val corePreferences: CorePreferences, + private val config: Config, ) : BaseViewModel() { private val _uiState = MutableLiveData(DatesUIState.Loading) @@ -64,6 +66,8 @@ class CourseDatesViewModel( val hasInternetConnection: Boolean get() = networkConnection.isOnline() + val isCourseExpandableSectionsEnabled get() = config.isCourseNestedListEnabled() + init { getCourseDates() viewModelScope.launch { diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineFragment.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineFragment.kt index f00055fa9..86fa2314c 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineFragment.kt @@ -168,14 +168,24 @@ class CourseOutlineFragment : Fragment() { viewModel.resumeSectionBlock?.let { subSection -> viewModel.resumeCourseTappedEvent(subSection.id) viewModel.resumeVerticalBlock?.let { unit -> - router.navigateToCourseSubsections( - requireActivity().supportFragmentManager, - courseId = viewModel.courseId, - subSectionId = subSection.id, - mode = CourseViewMode.FULL, - unitId = unit.id, - componentId = componentId - ) + if (viewModel.isCourseExpandableSectionsEnabled) { + router.navigateToCourseContainer( + fm = requireActivity().supportFragmentManager, + courseId = viewModel.courseId, + unitId = unit.id, + componentId = componentId, + mode = CourseViewMode.FULL + ) + } else { + router.navigateToCourseSubsections( + requireActivity().supportFragmentManager, + courseId = viewModel.courseId, + subSectionId = subSection.id, + mode = CourseViewMode.FULL, + unitId = unit.id, + componentId = componentId + ) + } } } }, diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt index cf83fd041..0337f811b 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt @@ -73,6 +73,8 @@ class CourseOutlineViewModel( val hasInternetConnection: Boolean get() = networkConnection.isOnline() + val isCourseExpandableSectionsEnabled get() = config.isCourseNestedListEnabled() + private val courseSubSections = mutableMapOf>() private val subSectionsDownloadsCount = mutableMapOf() val courseSubSectionUnit = mutableMapOf() diff --git a/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt index df7becbc3..752ba30ba 100644 --- a/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt @@ -21,6 +21,7 @@ import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R import org.openedx.core.UIMessage +import org.openedx.core.config.Config import org.openedx.core.data.model.DateType import org.openedx.core.data.model.User import org.openedx.core.data.storage.CorePreferences @@ -54,6 +55,7 @@ class CourseDatesViewModelTest { private val calendarManager = mockk() private val networkConnection = mockk() private val corePreferences = mockk() + private val config = mockk() private val openEdx = "OpenEdx" private val calendarTitle = "OpenEdx - Abc" @@ -159,7 +161,8 @@ class CourseDatesViewModelTest { calendarManager, networkConnection, resourceManager, - corePreferences + corePreferences, + config ) every { networkConnection.isOnline() } returns true coEvery { interactor.getCourseDates(any()) } throws UnknownHostException() @@ -185,7 +188,8 @@ class CourseDatesViewModelTest { calendarManager, networkConnection, resourceManager, - corePreferences + corePreferences, + config ) every { networkConnection.isOnline() } returns true coEvery { interactor.getCourseDates(any()) } throws Exception() @@ -211,7 +215,8 @@ class CourseDatesViewModelTest { calendarManager, networkConnection, resourceManager, - corePreferences + corePreferences, + config ) every { networkConnection.isOnline() } returns true coEvery { interactor.getCourseDates(any()) } returns mockedCourseDatesResult @@ -236,7 +241,8 @@ class CourseDatesViewModelTest { calendarManager, networkConnection, resourceManager, - corePreferences + corePreferences, + config ) every { networkConnection.isOnline() } returns true coEvery { interactor.getCourseDates(any()) } returns CourseDatesResult(