New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New state structure. #5007
New state structure. #5007
Conversation
Hi @DubeySandeep, please note merge conflicts. Also, might be worth making a note of what remaining work is needed on this PR in the form of a checklist? This helps the reviewer understand what the current status is, so they don't comment on stuff you are planning to do anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @DubeySandeep ! I left some comments, I think it looks pretty good overall, but it's pretty clear this needs some tests.
I also tried running it and it errors out. It seems like a circular dependency has been introduced by the id services. Could you take a look at that? Thanks!
core/domain/exp_domain.py
Outdated
"""Initializes a SubtitledHtml domain object. | ||
|
||
Args: | ||
content_id: str. An id for the object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description is extremely vague. Perhaps something more like "A unique id referring to the audio translations for this content."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
core/domain/exp_domain.py
Outdated
@@ -934,7 +910,7 @@ def __init__(self, hint_content): | |||
"""Constructs a Hint domain object. | |||
|
|||
Args: | |||
hint_content: SubtitledHtml. The hint text and audio translations. | |||
hint_content: SubtitledHtml. The hint text and content_id. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "The hint text and ID referring to the audio translations for this content."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
core/domain/exp_domain.py
Outdated
@@ -504,23 +506,20 @@ class SubtitledHtml(object): | |||
"""Value object representing subtitled HTML.""" | |||
|
|||
DEFAULT_SUBTITLED_HTML_DICT = { | |||
'html': '', | |||
'audio_translations': {} | |||
'content_id': feconf.DEFAULT_OUTCOME_CONTENT_ID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this DEFAULT_OUTCOME_CONTENT_ID specifically?
@@ -987,8 +963,8 @@ def __init__( | |||
False if is one of possible answer. | |||
correct_answer: str. The correct answer; this answer enables the | |||
learner to progress to the next card. | |||
explanation: SubtitledHtml. Contains text and audio translations for | |||
the solution's explanation. | |||
explanation: SubtitledHtml. Contains text and text id to link audio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this comment similar/consistent with the other ones, such as hint_content in hint
if default_outcome: | ||
default_outcome.feedback.audio_translations = {} | ||
for content_id in state.content_ids_to_audio_translations: | ||
state.content_ids_to_audio_translations[content_id] = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it matter that the content_id is still present within the different components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't understand this one. Can you please explain a bit more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah nevermind, realized this shouldn't matter, I think
@@ -221,6 +221,7 @@ | |||
<script src="{{TEMPLATE_DIR_PREFIX}}/services/CodeNormalizerService.js"></script> | |||
<script src="{{TEMPLATE_DIR_PREFIX}}/services/ComputeGraphService.js"></script> | |||
<script src="{{TEMPLATE_DIR_PREFIX}}/services/EditabilityService.js"></script> | |||
<script src="{{TEMPLATE_DIR_PREFIX}}/services/GenerateContendIdService.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ContentIdService*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I have also misspelled the filename.
Done!
function(stateContentIdsToAudioTranslationsService) { | ||
var generateRandomString = function() { | ||
randomString = ''; | ||
while (randomStringlength != 6){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is randomStringLength defined?
Also capitalize the l in length
} | ||
}; | ||
var _generateUniqueId = function() { | ||
var ContentIdList = Object.keys( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentIdList (camel case)
while (ContentIdList.indexOf(uniqueId) >= 0) { | ||
uniqueId = generateRandomString(); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this function return something?
utils.py
Outdated
old_ids. | ||
""" | ||
new_id = generate_random_string(6) | ||
while(new_id in old_id): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
old_ids?**
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -54,7 +54,8 @@ | |||
|
|||
<div ng-if="stateHintsService.savedMemento[getIndexPlusOne() - 1] && !stateHintsService.savedMemento[getIndexPlusOne() - 1].isEmpty()"> | |||
<audio-translations-editor component-name="<[COMPONENT_NAME_HINT]>" | |||
subtitled-html="stateHintsService.displayed[getIndexPlusOne() - 1].hintContent" | |||
content-ids-to-audio-translations="stateContentIdsToAudioTranslationsService.displayed" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanlip, Can we remove this (also on-change) as this will be same in all other places?
@@ -54,7 +54,8 @@ | |||
|
|||
<div ng-if="stateHintsService.savedMemento[getIndexPlusOne() - 1] && !stateHintsService.savedMemento[getIndexPlusOne() - 1].isEmpty()"> | |||
<audio-translations-editor component-name="<[COMPONENT_NAME_HINT]>" | |||
subtitled-html="stateHintsService.displayed[getIndexPlusOne() - 1].hintContent" | |||
content-ids-to-audio-translations="stateContentIdsToAudioTranslationsService.displayed" | |||
conten-id="stateHintsService.displayed[getIndexPlusOne() - 1].hintContent.getContentId()" | |||
on-start-edit="onAudioTranslationsStartEditAction" | |||
on-change="onAudioTranslationsEdited"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanlip, onAudioTranslationsEdited
we'll have to save the changes in stateContentIdsToAudioTranslationsService.saveDisplayedValue();
everywhere.
$scope.cancel = function() { | ||
$uibModalInstance.dismiss('cancel'); | ||
AlertsService.clearWarnings(); | ||
}; | ||
} | ||
] | ||
}).result.then(function() { | ||
// TODO(SD): Clean Hints and Responses to resolve #4634. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seanlip, is this an expected behavior?
We don't clean the stateHintsService while deleting an interaction? (I'll have to do the same thing for the audio part)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Hm, looks like my comment showed up in the main thread. I'll reply inline.)
Yep I think it is expected. Scenario: creator wants to ask exactly the same question, but using a different interaction (eg number with units instead of just a number).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create an exploration add textInput interaction.
- Add hint.
- Delete Interaction
- Add end exploration interaction.
- Preview
- Hint appears in "End exploration" card.
Is this expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good point. I didn't think of that scenario. It makes sense for hints not to appear when the state does not have an interaction to which answers are submittable in the first place.
Could you please file a bug for this? I am open to fixing it in this PR or fixing it in a separate PR, and I think the latter might be better since this PR is getting large, but your call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! (I have created an issue for now #5063 I'll fix this in another PR)
@tjiang11, can you PTAL? I'll be modifying/writing tests after this. |
Yep I think it is expected. Scenario: creator wants to ask exactly the same
question, but using a different interaction (eg number with units instead
of just a number).
… |
Codecov Report
@@ Coverage Diff @@
## develop #5007 +/- ##
===========================================
+ Coverage 45.2% 45.22% +0.02%
===========================================
Files 409 411 +2
Lines 23891 23993 +102
Branches 3861 3858 -3
===========================================
+ Hits 10800 10851 +51
- Misses 13091 13142 +51
Continue to review full report at Codecov.
|
if not set(content_id_list) <= set(available_content_ids): | ||
raise utils.ValidationError( | ||
'Expected state content_ids_to_audio_translations to have all ' | ||
'of the listed content ids %s' % content_id_list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth making a test to test this case? Same with the duplicate content ids case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -203,7 +239,10 @@ describe('States object factory', function() { | |||
customization_args: {}, | |||
default_outcome: { | |||
dest: 'new state', | |||
feedback: [], | |||
feedback: { | |||
contnet_id: 'default_outcome', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in about 20 other places, content*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -29,9 +29,9 @@ oppia.directive('hintEditor', [ | |||
'/components/hint_editor_directive.html'), | |||
controller: [ | |||
'$scope', '$uibModal', 'EditabilityService', 'stateHintsService', | |||
'COMPONENT_NAME_HINT', | |||
'stateContentIdsToAudioTranslationsService', 'COMPONENT_NAME_HINT', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still planning on renaming to AudioAssets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I didn't find any other name, as these are not the audio assets these are just the metadata for audio files and their status. So maybe we can leave it as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sgtm
return new Outcome( | ||
dest, | ||
SubtitledHtmlObjectFactory.createDefault(feedbackText), | ||
SubtitledHtmlObjectFactory.createDefault(feedbackText, feedbacktextId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feedbackTextId (camel case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
@@ -115,10 +117,13 @@ oppia.controller('StateHints', [ | |||
$scope.hintIndex = stateHintsService.displayed.length + 1; | |||
|
|||
$scope.saveHint = function() { | |||
var contentId = GenerateContentIdService.generateUniqueId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of generateUniqueId, we should call it something more like getNextId? Unique Id makes it sound like it's a random string. Up to you though I'm ultimately okay with either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
* Changes in exp_domain for new state structure * Made changes in exp_services * changes made in SubtitledHtmlObjectFactory * changes made in SubtitledHtmlObjectFactory * Made changes in backend exp_domain for state validation and conversion * Added new GenerateContendIdService * Added domain object for contentIdsToAudioTranslations * Added changes to support exploration player for new changes * Fixed lint issues andmade few changes. * Exploration editor and player started working * Minor changes to make AudioTranslationBar double binded. * Added review changes. * Change branch * exp_services_test fix * Fixed other backend test from core.domain * Fixed frontend tests * Lint fix * Fixed e2e test(1) * Fixed backend tests * Added Spec files for ContentIdsToAudioTranslationsObjectFactory * Added Spec file for GenerateContentIdService * Added validators for citat in sate.validator and fixed tests * Removed DEFAULT_OUTCOME_CONTENT_ID * minor changes * Added e2e review comments changes * Changed all contnet to content * Added review changes * resolved lint errors for docsting
Explanation
This PR changes the state structure.
(Doc can be found here)
CheckList: