-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Introduce first pass interface for ExplorationProgressController. * Fill in the stubbed logic for ExplorationProgressController. Still no tests to verify correctness. Also, added a method to facilitate notifying of DataProvider changes on the UI thread. * Fix lateinit issue in ExplorationProgressController due to wrongly ordered initialization. * Fix a variaty of issues in the exp progress controller, properly hook it up to the data controller, and start adding tests. * Created a separate ExplorationRetriever, hooked up AnswerClassificationController, and attempted to make ExplorationProgressController thread-safe. The thread-safety led to significant interface changes in the progress controller, and led to discovering some issues with the mediator live data approach to interop coroutines and LiveData. This locking mechanism will need to change since the optimal solution requires resolving #90. * Change the locking mechanism for ExplorationProgressController to work with the current MediatorLiveData implementation (see #90 for more context). Fix existing progress controller tests and add a few more. All current progress controller tests are passing. * Finish tests for ExplorationProgressController and add test classification support for the second test exploration (about_oppia). * First iteration at implementing real answer classification for the Oppia prototype. This uses a Dagger-powered solution to make it straightforward to add new rule types and interactions in a way that automatically hooks into the classifier. This only adds TextInput support, so existing tests do not pass. Tests and the app do build. * Bind all text input rules, add numeric input rules, and add support for two bound input values. * Add numbers with units classification support. * Add multiple choice input classification support. Fix some of the exploration progress controller tests for numeric input. * Add item selection classification support. Clean up all rule classifier comments to point to their corresponding Oppia web versions. * Add fractions input classification support. * Add Continue module. Resolve some TODOs, add TODOs to test classifiers, and fix ExplorationProgressController tests (which also included fixing one bug in the TextInput FuzzyEquals and the progress controller's fallback routing logic). * Add thorough tests for AnswerClassificationController. * Consolidate generic rule classifiers into a single class.
- Loading branch information
1 parent
7af4c1b
commit a501b23
Showing
56 changed files
with
2,169 additions
and
141 deletions.
There are no files selected for viewing
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
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
14 changes: 14 additions & 0 deletions
14
domain/src/main/java/org/oppia/domain/classify/GenericInteractionClassifier.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.oppia.domain.classify | ||
|
||
/** A general-purpose [InteractionClassifier] that utilizes a Dagger-bound [RuleClassifier] map. */ | ||
internal class GenericInteractionClassifier( | ||
private val ruleClassifiers: Map<String, RuleClassifier> | ||
): InteractionClassifier { | ||
override fun getRuleTypes(): Set<String> { | ||
return ruleClassifiers.keys | ||
} | ||
|
||
override fun getRuleClassifier(ruleType: String): RuleClassifier? { | ||
return ruleClassifiers[ruleType] | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
domain/src/main/java/org/oppia/domain/classify/InteractionClassifier.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.oppia.domain.classify | ||
|
||
/** | ||
* An answer classifier for a specific interaction type. Instances of this classifier should be bound to a map of | ||
* interaction IDs to classifier instances so that they can be used by the [AnswerClassificationController]. | ||
*/ | ||
interface InteractionClassifier { | ||
/** Returns a set of rule types that this interaction supports classifying. */ | ||
fun getRuleTypes(): Set<String> | ||
|
||
/** Returns the [RuleClassifier] corresponding to the specified rule type. */ | ||
fun getRuleClassifier(ruleType: String): RuleClassifier? | ||
} |
80 changes: 80 additions & 0 deletions
80
domain/src/main/java/org/oppia/domain/classify/InteractionsModule.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.oppia.domain.classify | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.multibindings.IntoMap | ||
import dagger.multibindings.StringKey | ||
import org.oppia.domain.classify.rules.ContinueRules | ||
import org.oppia.domain.classify.rules.FractionInputRules | ||
import org.oppia.domain.classify.rules.ItemSelectionInputRules | ||
import org.oppia.domain.classify.rules.MultipleChoiceInputRules | ||
import org.oppia.domain.classify.rules.NumberWithUnitsRules | ||
import org.oppia.domain.classify.rules.NumericInputRules | ||
import org.oppia.domain.classify.rules.TextInputRules | ||
|
||
/** Module that provides a map of [InteractionClassifier]s. */ | ||
@Module | ||
class InteractionsModule { | ||
@Provides | ||
@IntoMap | ||
@StringKey("Continue") | ||
fun provideContinueInteractionClassifier( | ||
@ContinueRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("FractionInput") | ||
fun provideFractionInputInteractionClassifier( | ||
@FractionInputRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("ItemSelectionInput") | ||
fun provideItemSelectionInputInteractionClassifier( | ||
@ItemSelectionInputRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("MultipleChoiceInput") | ||
fun provideMultipleChoiceInputInteractionClassifier( | ||
@MultipleChoiceInputRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("NumberWithUnits") | ||
fun provideNumberWithUnitsInteractionClassifier( | ||
@NumberWithUnitsRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("NumericInput") | ||
fun provideNumericInputInteractionClassifier( | ||
@NumericInputRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
|
||
@Provides | ||
@IntoMap | ||
@StringKey("TextInput") | ||
fun provideTextInputInteractionClassifier( | ||
@TextInputRules ruleClassifiers: Map<String, @JvmSuppressWildcards RuleClassifier> | ||
): InteractionClassifier { | ||
return GenericInteractionClassifier(ruleClassifiers) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
domain/src/main/java/org/oppia/domain/classify/RuleClassifier.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.oppia.domain.classify | ||
|
||
import org.oppia.app.model.InteractionObject | ||
|
||
/** An answer classifier for a specific interaction rule. */ | ||
interface RuleClassifier { | ||
/** | ||
* Returns whether the specified answer matches the rule's parameter inputs per this rule's classification strategy. | ||
*/ | ||
fun matches(answer: InteractionObject, inputs: Map<String, InteractionObject>): Boolean | ||
} |
Oops, something went wrong.