-
-
Save rt4914/9ca5798836e783ec29215dead870bc5b to your computer and use it in GitHub Desktop.
Alpha Dummy Progress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.oppia.domain.topic | |
import org.oppia.app.model.ProfileId | |
import java.util.Date | |
import javax.inject.Inject | |
private const val EIGHT_DAYS_IN_MS = 8 * 24 * 60 * 60 * 1000 | |
/** This helper allows tests to easily create dummy progress per profile-basis. */ | |
class StoryProgressTestHelper @Inject constructor( | |
private val storyProgressController: StoryProgressController | |
) { | |
private fun getCurrentTimestamp(): Long { | |
return Date().time | |
} | |
// Returns a timestamp which is atleast a week old than current. | |
private fun getOldTimestamp(): Long { | |
return Date().time - EIGHT_DAYS_IN_MS | |
} | |
/** Creates a partial story progress for a particular profile. */ | |
fun markAlphaDummyProgress(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"iX9kYCjnouWN", | |
"RRVMHsZ5Mobh", | |
"K645IfRNzpKy", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"iX9kYCjnouWN", | |
"RRVMHsZ5Mobh", | |
"Knvx24p24qPO", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"iX9kYCjnouWN", | |
"RRVMHsZ5Mobh", | |
"aAkDKVDR53cG", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"iX9kYCjnouWN", | |
"RRVMHsZ5Mobh", | |
"avwshGklKLJE", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"R7WpsSfmDQPV", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"zIBYaqfDJrJC", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"1904tpP0CYwY", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"cQDibOXQbpi7", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"MRJeVrKafW6G", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"hNOP3TwRJhsz", | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
"C4fqwrvqWpRm", | |
"vfJDB3JAdwIx", | |
"zTg2hzTz37jP", | |
timestamp | |
) | |
} | |
/** Creates a partial story progress for a particular profile. */ | |
fun markPartialStoryProgressForFractions(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
} | |
/** Creates a partial topic progress for a particular profile. */ | |
fun markPartialTopicProgressForFractions(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
} | |
/** Marks full story progress for a particular profile. */ | |
fun markFullStoryProgressForFractions(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_1, | |
timestamp | |
) | |
} | |
/** Marks full topic progress for a particular profile. */ | |
fun markFullTopicProgressForFractions(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_1, | |
timestamp | |
) | |
} | |
/** Marks one story progress full in ratios exploration for a particular profile. */ | |
fun markFullStoryPartialTopicProgressForRatios( | |
profileId: ProfileId, | |
timestampOlderThanAWeek: Boolean | |
) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_1, | |
timestamp | |
) | |
} | |
/** Marks two partial story progress in ratios exploration for a particular profile. */ | |
fun markTwoPartialStoryProgressForRatios(profileId: ProfileId, timestampOlderThanAWeek: Boolean) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordCompletedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_1, | |
RATIOS_EXPLORATION_ID_2, | |
timestamp | |
) | |
} | |
/** Marks exploration [FRACTIONS_EXPLORATION_ID_0] as recently played for a particular profile. */ | |
fun markRecentlyPlayedForFractionsStory0Exploration0( | |
profileId: ProfileId, | |
timestampOlderThanAWeek: Boolean | |
) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
} | |
/** Marks exploration [RATIOS_EXPLORATION_ID_0] as recently played for a particular profile. */ | |
fun markRecentlyPlayedForRatiosStory0Exploration0( | |
profileId: ProfileId, | |
timestampOlderThanAWeek: Boolean | |
) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_0, | |
timestamp | |
) | |
} | |
/** Marks first exploration in both stories of Ratios as recently played for a particular profile. */ | |
fun markRecentlyPlayedForRatiosStory0Exploration0AndStory1Exploration2( | |
profileId: ProfileId, | |
timestampOlderThanAWeek: Boolean | |
) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_1, | |
RATIOS_EXPLORATION_ID_2, | |
timestamp | |
) | |
} | |
/** Marks first exploration in all stories of Ratios & Fractions as recently played for a particular profile. */ | |
fun markRecentlyPlayedForFirstExplorationInAllStoriesInFractionsAndRatios( | |
profileId: ProfileId, | |
timestampOlderThanAWeek: Boolean | |
) { | |
val timestamp = if (!timestampOlderThanAWeek) { | |
getCurrentTimestamp() | |
} else { | |
getOldTimestamp() | |
} | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
FRACTIONS_TOPIC_ID, | |
FRACTIONS_STORY_ID_0, | |
FRACTIONS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_0, | |
RATIOS_EXPLORATION_ID_0, | |
timestamp | |
) | |
storyProgressController.recordRecentlyPlayedChapter( | |
profileId, | |
RATIOS_TOPIC_ID, | |
RATIOS_STORY_ID_1, | |
RATIOS_EXPLORATION_ID_2, | |
timestamp | |
) | |
} | |
} |
That's actually much clean. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative that let's you monitor the records finishing (which lets you block the HomeFragment until the record is completed):