-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat: handle optional blocks in verticals #279
Conversation
Thanks for the pull request, @DanielVZ96! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. This is currently a draft pull request. When it is ready for our review and all tests are green, click "Ready for Review", or remove "WIP" from the title, as appropriate. |
b857473
to
4f66c25
Compare
4f66c25
to
51c5c24
Compare
completion/services.py
Outdated
child_locations = [ | ||
child.scope_ids.usage_id for child in self.get_completable_children(item) | ||
# for non-optional verticals, only include non-optional children | ||
if optional_vertical or not getattr(child, "optional_content", 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.
@DanielVZ96, shouldn't this be something like not optional_vertical and not getattr(child, "optional_content", False)
? We should add a test for this. We could also use a variable like required_completion = getattr(item, "optional_content", False)
to avoid too many negations that make this condition hard to read.
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.
There are only four combinations:
- Optional Vertical and Optional Child -> Include Child
- Optional Vertical and Required Child -> Include Child (shouldn't happen but this is how we can handle it gracefully)
- Required Vertical and Required Child -> Include Child
- Required Vertical and Optional Child -> Exclude Child
This means that the only case in which we want to exclude the child
is when the parent is required and the child isn't.
This can be achieved with either of the following logic (nots turns ors into ands)
a) optional_vertical or required_child # can be read as "if it's an optional vertical include all, if it's a required vertical only accept required children"
b) not (required_vertical and optional_child) # can be read as "exclude the 4th case"
Your's (not optional_vertical and not getattr(child, "optional_content", False)
) can be paraphrased as required_vertical and required_child
, and would only return true (thus include) the third case.
I'm refactoring the code to include this explanation and make it easier to test, since the vertical_is_complete is really hard to test without having edx-platform code available.
@DanielVZ96, please convert this PR to draft - since this should be merged with the upstream PR to |
2d35ae3
to
1f3b3c6
Compare
1f3b3c6
to
a1d90c6
Compare
@staticmethod | ||
def matches_vertical_optional_completion(optional_vertical, optional_child): | ||
""" | ||
Checks if child should count towards a vertical's completion. |
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.
Could we expand this docstring a bit to explain the concept of "optional" XBlocks?
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
completion/tests/test_services.py
Outdated
for optional_vertical, optional_child, should_include_child in ( | ||
(True, True, True), | ||
(True, False, True), | ||
(False, False, True), | ||
(False, True, False), # do not count optional children for non-optional verticals | ||
): |
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.
Nit: we should use @ddt.data
for this.
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
Hi @DanielVZ96 @Agrendalath are you planning to finish this PR? @pkulkark and I are CCs on this repo, so one of us can help with reviewing and merging. |
@pomegranited It depends on this PR i'm working on open-craft/edx-platform#638 It's been a bit slow because I can't run js browser tests locally in palm. |
No worries @DanielVZ96 , thanks for the update! |
@DanielVZ96, I need help understanding this PR's context. A course consists of the following components:
This PR handles counting the optional children of a vertical, which are mentioned in the last point above. We can override XBlock fields through the Django shell, but how can we create such optional XBlocks in Studio? Also, should we mark the parent as completed in case the optional children are incomplete? In this case, users would get the completion checkmarks for these sections. It would be impossible for them to find the incomplete items if they want to increase their optional completion. I suppose we could introduce some new completion checkmark type (e.g., partial completion), but this will require more investigation and is out of scope here. |
@Agrendalath you are completely right. i may have confused the terminology when working on this. there's no way of setting a single xblock as optional in studio for now. |
@DanielVZ96 Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future. |
Note: Not sure how to increase coverage since there's no testing in place for
Description: handles not counting optional children for non-optional verticals
Dependencies:
open-craft/edx-platform#638
Testing instructions:
Reviewers:
Merge checklist:
Post merge:
finished.
Private-ref: BB-8586