Skip to content

Instantly share code, notes, and snippets.

@veena14cs
Created October 16, 2019 17:37
Show Gist options
  • Save veena14cs/ca22ef5f73a8598219e1ae3d51381580 to your computer and use it in GitHub Desktop.
Save veena14cs/ca22ef5f73a8598219e1ae3d51381580 to your computer and use it in GitHub Desktop.
private fun subscribeToCurrentState() {
ephemeralStateLiveData.observe(fragment, Observer<EphemeralState> { result ->
logger.d(STATE_LOG, "getCurrentState: ${result}")
entityType = "exploration"
val customizationArgsMap: Map<String, InteractionObject> = result.state.interaction.customizationArgsMap
val allKeys: Set<String> = customizationArgsMap.keys
for (key in allKeys) {
logger.d(TAG_STATE_FRAGMENT, key)
}
if (customizationArgsMap.contains("choices")) {
val customizationArgs: InteractionObject? = customizationArgsMap.get("choices")
val stringList: StringList = customizationArgs!!.setOfHtmlString
logger.d(TAG_STATE_FRAGMENT, "value: ${stringList}")
}
})
}
*****************
Output for state STATE_LOG
******************
state {
content {
html: "<p>Hi, welcome to Oppia! <oppia-noninteractive-link text-with-value=\"&quot;Oppia&quot;\" url-with-value=\"&quot;https://oppia.github.io&quot;\"></oppia-noninteractive-link> is a tool that helps you create interactive learning activities that can be continually improved over time.<br><br>Incidentally, do you know where the name \'Oppia\' comes from?<br></p>"
}
interaction {
answer_groups {
outcome {
dest_state_name: "What language"
feedback {
html: "Yes!"
}
}
rule_specs {
rule_type: "Equals"
}
}
answer_groups {
outcome {
dest_state_name: "Welcome!"
feedback {
html: "Actually, I don\'t know of any such characters, so I must confess to making that choice up. Have another go?"
}
}
rule_specs {
rule_type: "Equals"
}
}
default_outcome {
dest_state_name: "What language"
feedback {
html: "Hm, it certainly looks like it! But it\'s actually a word from a different language."
}
}
id: "MultipleChoiceInput"
}
name: "Welcome!"
}
@veena14cs
Copy link
Author

Actual Json

"Welcome!": {
"classifier_model_id": null,
"content": {
"audio_translations": {},
"html": "

Hi, welcome to Oppia! <oppia-noninteractive-link text-with-value=""Oppia"" url-with-value=""https://oppia.github.io&quot;\"> is a tool that helps you create interactive learning activities that can be continually improved over time.

Incidentally, do you know where the name 'Oppia' comes from?

"
},
"interaction": {
"answer_groups": [
{
"outcome": {
"dest": "What language",
"feedback": "Yes!",
"labelled_as_correct": false,
"param_changes": []
},
"rule_specs": [
{
"inputs": {
"x": 0
},
"rule_type": "Equals"
}
]
},
{
"outcome": {
"dest": "Welcome!",
"feedback": "Actually, I don't know of any such characters, so I must confess to making that choice up. Have another go?",
"labelled_as_correct": false,
"param_changes": []
},
"rule_specs": [
{
"inputs": {
"x": 2
},
"rule_type": "Equals"
}
]
}
],
"confirmed_unclassified_answers": [],
"customization_args": {
"choices": {
"value": [
"It's translated from a different language.",
"It's a nonsense word that someone made up.",
"It's the name of a popular cartoon character."
]
}
},
"default_outcome": {
"dest": "What language",
"feedback": "Hm, it certainly looks like it! But it's actually a word from a different language.",
"param_changes": [],
"labelled_as_correct": false
},
"hints": [],
"id": "MultipleChoiceInput",
"solution": null
},
"param_changes": []
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment