Skip to content
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

Fix #6322: Add IsProperSubsetOf to item-selection interaction #6350

Merged
merged 85 commits into from Mar 27, 2019
Merged

Fix #6322: Add IsProperSubsetOf to item-selection interaction #6350

merged 85 commits into from Mar 27, 2019

Conversation

amey-kudari
Copy link
Contributor

@amey-kudari amey-kudari commented Feb 28, 2019

Explanation

Fixes #6322 by adding an extra option to allow exploration creator provide feedback to user for answers that are a proper superset.

What I did:

1. Added option, is proper subset of, into Item selection, and updated all related files

2. Added tests for same

Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • The PR explanation includes the words "Fixes #bugnum: ..." (or "Fixes part of #bugnum" if the PR only partially fixes an issue).
  • The linter/Karma presubmit checks have passed.
    • These should run automatically, but if not, you can manually trigger them locally using python scripts/pre_commit_linter.py and bash scripts/run_frontend_tests.sh.
  • The PR is made from a branch that's not called "develop".
  • The PR follows the style guide.
  • The PR is assigned to an appropriate reviewer.
    • If you're a new contributor, please ask on Gitter for someone to assign a reviewer.
    • If you're not sure who the appropriate reviewer is, please assign to the issue's "owner" -- see the "talk-to" label on the issue.

Buahahahah and others added 30 commits February 23, 2019 19:40
… page from showing up before angular gets loaded
This reverts commit 9935d05.

got back base.html
undid previous pull request
remove changes
* add issue template for server errors

* improve about section

* review changes

* minor nits
… page from showing up before angular gets loaded
…ate module. (#6305)

* Add a script for updating indexes. Move gcloud functions into a separate file.

* Further changes needed to use gcloud for deployment.

* Remove unused code.

* Add ability to specify custom versions.

* Do not switch to new version after uploading.

* Update fileoverview docstring.
This reverts commit 9935d05.

got back base.html
Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @amey-kudari, if you want the PR to be merged, it is really important to ensure that what you are writing is logically correct, otherwise we will keep going back and forth on reviews. PTAL at the inline comments and make sure to carefully read and analyze what your code is doing, otherwise you run the risk of breaking the production code. It's really important to reason through the resulting code and make sure that it's doing what it's supposed to.

rules.forEach(function(rule, ruleIndex) {
var ruleInputs = rule.inputs.x;
ruleInputs.forEach(function(ruleInput) {
var choiceIndex = answerChoiceToIndex[ruleInput];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't answerChoiceToIndex empty? It seems to be declared on line 148 as an empty dict and then never populated. So wouldn't this end up being undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this code here by mistake, I will added it back and checked, (I will probably remove that case now, (#6350 (comment)).

149         seenChoices.forEach(function(seenChoice, choiceIndex) {
150           answerChoiceToIndex[seenChoice] = choiceIndex;
151         });

});
});
});
areAllChoicesCovered = handledAnswers.every(function(handledAnswer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the logic here. In the maxAllowedCount > 1 case, handledAnswers is initialized here, the entire block from lines 111-147 is skipped (since maxAllowedCount > 1), and then it seems to me like all rule types apart from IsProperSubsetOf are being ignored.

So, why do you say that "areAllChoicesCovered will only be true if all choices have been checked by some rule"? There are other rules besides isProperSubsetOf. I recommend that you do not try to extend that check beyond the == 1 case in this PR.

@amey-kudari
Copy link
Contributor Author

@seanlip ,
I was thinking about this, #6350 (comment), but yeah It is getting very confusing and I am not very sure about this, So Ill probably do this,
Add IsProperSubsetOf inside the if condition (we know case ===1 is handled, and make an else condition and verify this isProperSubsetOf without extending that part of code) . This way I am sure I know what is happening.

@amey-kudari
Copy link
Contributor Author

Hi @seanlip ,

And I added another else condition, and made sure I do not modify areAllOptionsCovered, and I rechecked my code. Can you please take a look.

And this was a messy PR, I did not know what I was doing initially as this was my first major PR to any big org. I will plan my code and PR, and make sure I know what every change in any PR is doing before pushing it from now.

Thanks!

expect(isirs.IsProperSubsetOf(
['a', 'b', 'c', 'd'], RULE_INPUT)).toBe(false);
expect(isirs.IsProperSubsetOf(
['b', 'c', 'd', 'e'], RULE_INPUT)).toBe(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amey-kudari did you miss this comment?

areAllChoicesCovered = handledAnswers.every(function(handledAnswer) {
return handledAnswer;
} else {
answerGroups.forEach(function(answerGroup, answerIndex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this check only apply for maxAllowedCount > 1? Does it not apply generally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed that (I put it inside both, the if and the else condition. I will add it right now.

Copy link
Member

@seanlip seanlip Mar 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we should not be duplicating code. Why not run it as a separate check, outside both clauses? This seems like a separate check altogether from areAllChoicesCovered.

In other words, keep the "handledAnswers" stuff inside the existing "maxAllowedCount == 1" clause, but pull out the ">= 2 options" check into its own separate check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah @seanlip , I agree, I will do it. I should have done this, it will make #6418 easier.
Thanks!

@@ -165,4 +176,22 @@ describe('ItemSelectionInputValidationService', function() {
message: 'Please ensure the choices are unique.'
}]);
});

it(
'should expect more that 1 element to be in the rule input, if the ' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop extra space between "be" and "in".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, changed it, will push now

'"proper subset" rule is used.',
function() {
// Modify values of customization arguments to get warning.
customizationArguments.minAllowableSelectionCount.value = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the proper subset check depend on minAllowableSelectionCount? I thought the check was for the validity of the rule, not the student's answer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not needed (I kept it before, did not remove it (I thought it will trigger other tests before, removed it now).

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there!

}
answerGroups.forEach(function(answerGroup, answerIndex) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put this after the "areAllChoicesCovered" bit. That bit relates to the computation that was previously done. So currently it looks like you are doing check A, then switching midway to check B, then going back to check A again (conceptually).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree, pushed that part of code down.
Thanks!

}
areAllChoicesCovered = handledAnswers.every(function(handledAnswer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this moved from inside the { ... } to outside? (Look at the diff in the "files changed" tab.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I took it out when I was trying to extend it for isProperSubset, (including all cases of maxAllowedCount). Shall I put it back in?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the correct thing to do? Please analyze.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not going to extend it later, (I thought of doing it for all functions in the other issue, but I saw there isnt much use of that, and it would make the code more messy)
I will add it back inside the brackets. I will do it now
Thanks!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I have no further comments. Thanks @amey-kudari!

@seanlip
Copy link
Member

seanlip commented Mar 17, 2019

@kevinlee12 @bansalnitish This requires your review as code-owners.

Copy link
Contributor

@kevinlee12 kevinlee12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks @amey-kudari!

@amey-kudari
Copy link
Contributor Author

Thank you so much!
@seanlip @kevinlee12

@apb7
Copy link
Contributor

apb7 commented Mar 21, 2019

Hi @amey-kudari, please bring your branch up-to-date with develop. Also, @bansalnitish, can you please take another pass here? Thanks!

update branch with develop
@amey-kudari
Copy link
Contributor Author

Hi @amey-kudari, please bring your branch up-to-date with develop. Also, @bansalnitish, can you please take another pass here? Thanks!

done, @apb7

Copy link
Contributor

@nithusha21 nithusha21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standin approval for the changes to the interaction project (Kevin is away for a while).

@vibhor98
Copy link
Contributor

Hi @bansalnitish, can you also take a look at this PR? Thanks!

Copy link
Contributor

@bansalnitish bansalnitish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @amey-kudari

@bansalnitish bansalnitish merged commit 11c73a7 into oppia:develop Mar 27, 2019
@amey-kudari
Copy link
Contributor Author

Thank you so much
@bansalnitish for merging it!
And all reviewers for helping me through this PR!

@amey-kudari amey-kudari deleted the fix6322 branch March 27, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Item-selection interaction should have a "proper subset" type of rule
10 participants