Skip to content

Commit

Permalink
Adding solicit_answer_details in the State class (oppia#6810)
Browse files Browse the repository at this point in the history
* First

* First

* Second

* Third

* Fourth

* Reset

* Added pl json

* Added ask_llearners_for_response

* exp_domain_test completed

* Edited exp_services.py

* editor_test and exp_services_test

* Fixed lint issues

* Updated feconf file

* Ignored package-lock.json

* edited .gitignore

* Made changes in question domain and zip

* Fixing backend tests failure

* Edited question_domain.py

* Fixed backend tests

* Fixed editor_test

* Edited summary for ask_learners_for_response

* Added more tests in exp_services_test

* Added test in state_domain_test.py

* Added more tests

* Added baseline verification

* Edited args docstrings

* Replaced ask_learners_for_response with solicit_answer_details

* Added more changes

* Fixed linting issues

* Sorted order YAML

* Debugging e2e tests

* Debug e2e test

* Removed pre push tests for debugging

* Removed ;

* Replaced earlier e2e test

* Debugging e2e tests

* Added ;

* Made frontend changes

* Added e2e tests

* Corrected a mistake

* Fixed history tab e2e test

* reverted back changes

* Added files

* Fixed branch

* Made some changes

* Changes made

* Added more tests

* Added CANNOT_SOLICIT_ANSWER_DETAILS

* Added changes

* Removed extra new line

* Changes made

* Removed default args

* Removed +
  • Loading branch information
anubhavsinha98 authored and brianrodri committed Jun 13, 2019
1 parent db7b49c commit 7074567
Show file tree
Hide file tree
Showing 38 changed files with 454 additions and 30 deletions.
1 change: 1 addition & 0 deletions assets/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ var constants = {
"default_outcome": {}
}
},
"solicit_answer_details": false,
"written_translations": {
"translations_mapping": {
"content": {},
Expand Down
4 changes: 4 additions & 0 deletions core/controllers/editor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class DownloadIntegrationTest(BaseEditorControllerTests):
voiceovers_mapping:
content: {}
default_outcome: {}
solicit_answer_details: false
written_translations:
translations_mapping:
content: {}
Expand Down Expand Up @@ -376,6 +377,7 @@ class DownloadIntegrationTest(BaseEditorControllerTests):
voiceovers_mapping:
content: {}
default_outcome: {}
solicit_answer_details: false
written_translations:
translations_mapping:
content: {}
Expand Down Expand Up @@ -410,6 +412,7 @@ class DownloadIntegrationTest(BaseEditorControllerTests):
voiceovers_mapping:
content: {}
default_outcome: {}
solicit_answer_details: false
written_translations:
translations_mapping:
content: {}
Expand Down Expand Up @@ -446,6 +449,7 @@ class DownloadIntegrationTest(BaseEditorControllerTests):
voiceovers_mapping:
content: {}
default_outcome: {}
solicit_answer_details: false
written_translations:
translations_mapping:
content: {}
Expand Down
52 changes: 51 additions & 1 deletion core/domain/exp_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
# 'answer_groups' and 'default_outcome'.
STATE_PROPERTY_PARAM_CHANGES = 'param_changes'
STATE_PROPERTY_CONTENT = 'content'
STATE_PROPERTY_SOLICIT_ANSWER_DETAILS = 'solicit_answer_details'
STATE_PROPERTY_RECORDED_VOICEOVERS = 'recorded_voiceovers'
STATE_PROPERTY_WRITTEN_TRANSLATIONS = 'written_translations'
STATE_PROPERTY_INTERACTION_ID = 'widget_id'
Expand Down Expand Up @@ -112,6 +113,7 @@ class ExplorationChange(object):
STATE_PROPERTIES = (
STATE_PROPERTY_PARAM_CHANGES,
STATE_PROPERTY_CONTENT,
STATE_PROPERTY_SOLICIT_ANSWER_DETAILS,
STATE_PROPERTY_RECORDED_VOICEOVERS,
STATE_PROPERTY_WRITTEN_TRANSLATIONS,
STATE_PROPERTY_INTERACTION_ID,
Expand Down Expand Up @@ -585,6 +587,8 @@ def from_dict(
state_domain.WrittenTranslations.from_dict(
sdict['written_translations']))

state.solicit_answer_details = sdict['solicit_answer_details']

exploration.states[state_name] = state

exploration.param_changes = [
Expand Down Expand Up @@ -2190,6 +2194,25 @@ def _convert_states_v27_dict_to_v28_dict(cls, states_dict):
}
return states_dict

@classmethod
def _convert_states_v28_dict_to_v29_dict(cls, states_dict):
"""Converts from version 28 to 29. Version 29 adds
solicit_answer_details boolean variable to the state, which
allows the creator to ask for answer details from the learner
about why they landed on a particular answer.
Args:
states_dict: dict. A dict where each key-value pair represents,
respectively, a state name and a dict used to initalize a
State domain object.
Returns:
dict. The converted states_dict.
"""
for state_dict in states_dict.itervalues():
state_dict['solicit_answer_details'] = False
return states_dict

@classmethod
def update_states_from_model(
cls, versioned_exploration_states, current_states_schema_version,
Expand Down Expand Up @@ -2225,7 +2248,7 @@ def update_states_from_model(
# incompatible changes are made to the exploration schema in the YAML
# definitions, this version number must be changed and a migration process
# put in place.
CURRENT_EXP_SCHEMA_VERSION = 33
CURRENT_EXP_SCHEMA_VERSION = 34
LAST_UNTITLED_SCHEMA_VERSION = 9

@classmethod
Expand Down Expand Up @@ -2817,6 +2840,28 @@ def _convert_v32_dict_to_v33_dict(cls, exploration_dict):

return exploration_dict

@classmethod
def _convert_v33_dict_to_v34_dict(cls, exploration_dict):
"""Converts a v33 exploration dict into a v34 exploration dict.
Adds solicit_answer_details in state to ask learners for the
answer details.
Args:
exploration_dict: dict. The dict representation of an exploration
with schema version v33.
Returns:
dict. The dict representation of the Exploration domain object,
following schema version v34.
"""
exploration_dict['schema_version'] = 34

exploration_dict['states'] = cls._convert_states_v28_dict_to_v29_dict(
exploration_dict['states'])
exploration_dict['states_schema_version'] = 29

return exploration_dict

@classmethod
def _migrate_to_latest_yaml_version(
cls, yaml_content, exp_id, title=None, category=None):
Expand Down Expand Up @@ -3015,6 +3060,11 @@ def _migrate_to_latest_yaml_version(
exploration_dict)
exploration_schema_version = 33

if exploration_schema_version == 33:
exploration_dict = cls._convert_v33_dict_to_v34_dict(
exploration_dict)
exploration_schema_version = 34

return (exploration_dict, initial_schema_version)

@classmethod
Expand Down
Loading

0 comments on commit 7074567

Please sign in to comment.