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
Conversation
… 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
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.
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]; |
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.
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?
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.
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) { |
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.
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.
@seanlip , |
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); |
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.
@amey-kudari did you miss this comment?
areAllChoicesCovered = handledAnswers.every(function(handledAnswer) { | ||
return handledAnswer; | ||
} else { | ||
answerGroups.forEach(function(answerGroup, answerIndex) { |
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 does this check only apply for maxAllowedCount > 1
? Does it not apply generally?
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 missed that (I put it inside both, the if and the else condition. I will add it right now.
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.
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.
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.
@@ -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 ' + |
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.
Drop extra space between "be" and "in".
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, changed it, will push now
'"proper subset" rule is used.', | ||
function() { | ||
// Modify values of customization arguments to get warning. | ||
customizationArguments.minAllowableSelectionCount.value = 0; |
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 does the proper subset check depend on minAllowableSelectionCount? I thought the check was for the validity of the rule, not the student's answer.
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.
It is not needed (I kept it before, did not remove it (I thought it will trigger other tests before, removed it now).
…set function, to remove duplicate code
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.
Almost there!
} | ||
answerGroups.forEach(function(answerGroup, answerIndex) { |
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.
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).
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, I agree, pushed that part of code down.
Thanks!
} | ||
areAllChoicesCovered = handledAnswers.every(function(handledAnswer) { |
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 has this moved from inside the { ... } to outside? (Look at the diff in the "files changed" tab.)
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.
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?
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.
What is the correct thing to do? Please analyze.
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.
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!
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.
Looks good, I have no further comments. Thanks @amey-kudari!
@kevinlee12 @bansalnitish This requires your review as code-owners. |
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.
lgtm, thanks @amey-kudari!
Thank you so much! |
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
done, @apb7 |
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.
Standin approval for the changes to the interaction project (Kevin is away for a while).
Hi @bansalnitish, can you also take a look at this PR? Thanks! |
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.
LGTM! Thanks @amey-kudari
Thank you so much |
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:
Checklist
python scripts/pre_commit_linter.py
andbash scripts/run_frontend_tests.sh
.