Skip to content

Commit

Permalink
Address the renames suggested in #217.
Browse files Browse the repository at this point in the history
  • Loading branch information
BenHenning committed Oct 9, 2019
1 parent 6ee7aec commit 848f172
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import javax.inject.Singleton

/** Controller for retrieving an exploration. */
@Singleton
class QuestionProgressController @Inject constructor(
class QuestionAssessmentProgressController @Inject constructor(
) {
fun beginQuestionTrainingSession(questionsList: List<Question>) {
}

fun finishQuestionTrainingSession() {

}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.oppia.domain.question

import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import org.oppia.app.model.Question
Expand All @@ -15,8 +14,8 @@ private const val QUESTION_DATA_PROVIDER_ID = "QuestionDataProvider"

/** Controller for retrieving an exploration. */
@Singleton
class QuestionDataController @Inject constructor(
private val questionProgressController: QuestionProgressController,
class QuestionTrainingController @Inject constructor(
private val questionAssessmentProgressController: QuestionAssessmentProgressController,
private val dataProviders: DataProviders
) {

Expand All @@ -32,8 +31,8 @@ class QuestionDataController @Inject constructor(

/**
* Begins a question training session given a list of questions. This method is not expected to fail.
* [QuestionProgressController] should be used to manage the play state, and monitor the load success/failure of
* the training session.
* [QuestionAssessmentProgressController] should be used to manage the play state, and monitor the load
* success/failure of the training session.
*
* Questions will be shuffled and then the training session will begin.
*
Expand All @@ -42,7 +41,7 @@ class QuestionDataController @Inject constructor(
*/
fun startQuestionTrainingSession(questionsList: List<Question>): LiveData<AsyncResult<Any?>> {
return try {
questionProgressController.beginQuestionTrainingSession(questionsList.shuffled())
questionAssessmentProgressController.beginQuestionTrainingSession(questionsList.shuffled())
MutableLiveData(AsyncResult.success<Any?>(null))
} catch (e: Exception) {
MutableLiveData(AsyncResult.failed(e))
Expand All @@ -56,7 +55,7 @@ class QuestionDataController @Inject constructor(
*/
fun stopQuestionTrainingSession(): LiveData<AsyncResult<Any?>> {
return try {
questionProgressController.finishQuestionTrainingSession()
questionAssessmentProgressController.finishQuestionTrainingSession()
MutableLiveData(AsyncResult.success<Any?>(null))
} catch (e: Exception) {
MutableLiveData(AsyncResult.failed(e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import kotlin.coroutines.EmptyCoroutineContext

const val TEST_TOPIC_ID_0 = "test_topic_id_0"

/** Tests for [QuestionDataController]. */
/** Tests for [QuestionTrainingController]. */
@RunWith(AndroidJUnit4::class)
@Config(manifest = Config.NONE)
class QuestionDataControllerTest {
Expand All @@ -61,7 +61,7 @@ class QuestionDataControllerTest {
val executorRule = InstantTaskExecutorRule()

@Inject
lateinit var questionDataController: QuestionDataController
lateinit var questionTrainingController: QuestionTrainingController

@Mock
lateinit var mockQuestionListObserver: Observer<AsyncResult<List<Question>>>
Expand Down Expand Up @@ -107,7 +107,7 @@ class QuestionDataControllerTest {
@Test
@ExperimentalCoroutinesApi
fun testController_providesInitialLiveDataForTopicId0() = runBlockingTest(coroutineContext) {
val questionListLiveData = questionDataController.getQuestionsForTopic(TEST_TOPIC_ID_0)
val questionListLiveData = questionTrainingController.getQuestionsForTopic(TEST_TOPIC_ID_0)
advanceUntilIdle()
questionListLiveData.observeForever(mockQuestionListObserver)

Expand All @@ -121,7 +121,7 @@ class QuestionDataControllerTest {
@Test
@ExperimentalCoroutinesApi
fun testController_returnsFailureForNonExistentTopic() = runBlockingTest(coroutineContext) {
val questionListLiveData = questionDataController.getQuestionsForTopic("NON_EXISTENT_TOPIC")
val questionListLiveData = questionTrainingController.getQuestionsForTopic("NON_EXISTENT_TOPIC")
advanceUntilIdle()
questionListLiveData.observeForever(mockQuestionListObserver)
verify(mockQuestionListObserver, atLeastOnce()).onChanged(questionListResultCaptor.capture())
Expand Down

0 comments on commit 848f172

Please sign in to comment.