Skip to content

Conversation

@jcdyer
Copy link
Contributor

@jcdyer jcdyer commented Oct 6, 2017

This contains the completion logic for scorable xblocks. When a block is scored, it should be marked complete (completion = 1.0). If an instructor resets the state of the xblock, it should also reset the completion of the xblock to 0.0.

JIRA tickets: N/A

Discussions: Architecture discussed extensively on the wiki and in meetings, then the revised proposal was presented to the Arch Council on Oct. 21 and given thumbs up.

Dependencies: None

Screenshots: N/A

Sandbox URL: TBD

Merge deadline: None

Testing instructions:

You will be going back and forth between the django shell and interacting with the devstack through the browser, so log into the devstack twice, and run paver devstack lms in one of the sessions. Then:

  1. Log in as an admin user.
  2. In the admin, at http://localhost:18000/admin/grades/persistentgradesenabledflag/add/ select both "enable" and "enable for all courses."
  3. Log in as a course staff user.
  4. Find a scorable block that the user hasn't answered yet. Get the block key for that user in the staff debug section.
  5. In the django shell (./manage.py lms --settings=devstack shell in the other window), ensure that there is no completion object for that block, or if it does exist, ensure the completion value is set to zero.
  6. Answer the problem.
  7. Refetch the completion object for the block. If you already have a copy, I think you should be able to do completion_object.refresh_from_db(). Otherwise completion_object = BlockCompletion.objects.get(pk=completion_object.pk) will work. Ensure the completion value is set to 1.0.
  8. In the instructor control panel, reset student state for the given problem and the logged in user.
  9. Refetch the completion object again, Ensure the completion value is set to 0.0.

Reviewers:

Author notes and concerns: N/A

Settings: N/A

@openedx-webhooks
Copy link

Thanks for the pull request, @jcdyer! It looks like you're a member of a company that does contract work for edX. If you're doing this work as part of a paid contract with edX, you should talk to edX about who will review this pull request. If this work is not part of a paid contract with edX, then you should ensure that there is an OSPR issue to track this work in JIRA, so that we don't lose track of your pull request.

Create an OSPR issue for this pull request.

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch 3 times, most recently from 24979ef to 2b9e9c5 Compare October 12, 2017 14:30
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

@jcdyer Whoops, I started reviewing this and thought I was reviewing "Create a completion emitter for default (non-scorable) blocks" since that WIP code is showing up in this PR. Could you please move the newer commits into a separate branch+PR?

I'll then give just the "complete scored" blocks part of this PR a final spin tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to remove these console.logs :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: inconsistent indentation here. Also, you can use trailing commas on the last element in JS arrays/objects, just like in python.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put completable into a constant, e.g. from lms.djangoapps.completion import CompletionMethod, then CompletionMethod.completable ?

Copy link
Contributor

Choose a reason for hiding this comment

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

"the default method" is pretty vague - perhaps we should say "the default method (marking it as completed once it has been viewed)" or something ?

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't an accurate description anymore - this is the set of descendent blocks that this vertical should mark as complete once the user views them. (i.e. it excludes completable blocks that are complete, and it excludes completable blocks that get marked complete via some other mechanism).

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Or six.text_type if you're changing this anyways?

Copy link
Contributor

Choose a reason for hiding this comment

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

How about calling this watch_completables or something to distinguish it from a list of children which are completable? See past comment about this list not being simply a list of completable descendants.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also check that this block is in the set returned by get_completables_for_user ? Or do we not care if spurious completion events or premature ones are emitted (e.g. user calling this directly to mark a gradable item as completed, instead of completing the graded activity).

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 it doesn't matter if it's in the set of get_completables_for_user. The main purpose of the specific user check is to reduce network traffic, and at this point, the request is already in the VPC (and will not even hit the DB if it doesn't change the value).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm. But it might be worth the looser check of whether it uses the default completion method. I'll think about that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I'm not a fan of this string "True" comparison. How about putting the data-completable attribute (with no value) on the element if and only if it should be marked as completed on view (or perhaps call it data-complete-on-view?), and then change this check here to use hasAttribute?

i.e. https://stackoverflow.com/questions/16864999/can-i-use-html5-data-attributes-as-boolean-attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I don't love "stringly" typed data either. I'll do it that way.

I suppose another option would be to make the values "JSON like" (so data-bool='true' data-null='null' data-num='1' data-string='"string"' data-object='{"tweedle": "dee"}'), but you'd need to make that a site-wide policy to be worth doing anyway. (just musing out loud).

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch 4 times, most recently from 7c2efd9 to 6eb6b0d Compare October 13, 2017 14:54
@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 13, 2017

Wow. I got my git branches in a muddled state. I think everything's back in shape now.

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch from 6eb6b0d to c10d304 Compare October 13, 2017 21:03
Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

@jcdyer I think you have an unnecessary test, but otherwise this looks great and works well :)

  • I tested this: Followed testing instructions with a problem block - it nicely created a BlockCompletion entry (with completion=1), then when I deleted the student state completion went to 0. Re-answering set the completion back to 1.
  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation: n/a

One potential issue though: I think we should we check for has_custom_completion and then not update the completion in that case. Right? Because the idea is that some XBlocks may wish to control their grade and their completion status separately. An example could be a block like ORA2 that wishes to emit an interim grade after the user has completed part of the requirements but not be considered complete until the user has finished everything.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test doesn't seem to be doing what it says (test_handler_resets_completion_on_score_delete) and it seems redundant given the ddt variants of the test_handler_submits_completion test above. Is this just a remnant from before a ddt refactor?

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. The DDT was a late addition, and I think I did it half way through copy-pasting this test (before revising it to match the name.

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Oct 13, 2017

If you want to spin the has_custom_completion nuances out into a separate story, in the interest of merging and cleaning up, however, I'd be fine with that. (Given that there aren't any XBlocks currently using that.)

@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 16, 2017

@bradenmacdonald You're absolutely right about checking for has_custom_completion. I've created a new ticket (OC-3247), and added it to the epic. I also removed the duplicate test.

Ready for another review.

Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

@jcdyer: Code looks good. Thanks.
A couple of questions:

  1. In the future, would it be possible to base the branch and PR off the other WIP branch before it merges, so the PR just has the changes meant to be reviewed? Are there issues with this?
  2. I see we are leaving the check for has_custom_completion until later. We'll also need to check completion_method=EXCLUDED right? I may be missing something obvious, but is there anything blocking data from being written once this is merged? What is the plan for merging or delaying merges such that functionality is more complete before writing data (for example, including default completion for viewable blocks)?

@bradenmacdonald
Copy link
Contributor

@robrap

In the future, would it be possible to base the branch and PR off the other WIP branch before it merges, so the PR just has the changes meant to be reviewed?

That would be really nice, yep - especially since GitHub allows changing the target branch before merging a PR, so it can change from the previous PR to master before merging. However, I don't think @jcdyer has push access to this repo, and it would be too inefficient for you or I to keep pushing his changes from the open-craft fork to here. If he could be given push access for at least the duration of this project, it would make the PRs much more manageable :)

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this: Followed testing instructions with a problem block - it nicely created a BlockCompletion entry (with completion=1), then when I deleted the student state completion went to 0. Re-answering set the completion back to 1.
  • I read through the code
  • I checked for accessibility issues: n/a
  • Includes documentation: n/a

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch 2 times, most recently from 90b3756 to f0d536e Compare October 18, 2017 10:45
@robrap
Copy link
Contributor

robrap commented Oct 18, 2017

@jcdyer @bradenmacdonald: Regarding my earlier comment, I submitted a ticket to get @jcdyer push access. I'll let you know when I hear back. Point 2 is still open and waiting for a response.
Thanks.

@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 18, 2017

Good point, @robrap. Nothing is going to stop the block completions from being written. I was planning on allowing the BlockCompletions to be written, and then using COMPLETION_START_DATE to prevent using early BlockCompletions from affecting AggregateCompletions (once those are implemented, but it probably makes sense to have basic completion rendering in place, and relatively complete, so the aggregate code doesn't have to be quite as defensive. I'll introduce a waffle flag in #16112.

@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 18, 2017

Thanks for looking into getting me push access. Additionally, I'm hoping once these first two commits land (model and event handler), I won't need to stack PRs as much.

@robrap
Copy link
Contributor

robrap commented Oct 18, 2017

@jcdyer: I still haven't thought this through, but I imagine it would be simpler if for any user, the timestamp of any completion data is the point at which that user has full completion data (e.g. default visibility completion, etc.). I guess we could truncate the table if and when we really wanted to achieve the same, but if the waffle flag were a part of this PR, we wouldn't get any data until this were turned on.

Also, maybe this is a non-issue, but do we have any known scored blocks that will not track completion once the custom completion and exemption code is done? In other words, will we be writing bad data in certain cases with this PR?

Lastly, it sounds like push access will be coming soon, but not certain until you have it. :)

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch 2 times, most recently from a507dc5 to 2f55112 Compare October 20, 2017 19:35
@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 20, 2017

jenkins run lettuce

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch from 2f55112 to 8412e9f Compare October 20, 2017 20:29
@robrap
Copy link
Contributor

robrap commented Oct 23, 2017

@jcdyer: You now have push access. A couple of thoughts:

  1. I will try not to hold up any PRs, but please try to avoid merging until both @bradenmacdonald and I have approved.
  2. I see that I haven't approved this ticket yet, but also see it includes issues that were written/updated on another ticket (I think), and I'm confused about what is needed on this one. Are you able to clean up the PR, basing it on another branch, and/or reminding me to review this one after the dependent changes are approved or merged and updated or removed from this PR?
    Thanks.

@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 23, 2017

@robrap

  1. I will try not to hold up any PRs, but please try to avoid merging until both @bradenmacdonald and I have approved.

Of course.

  1. I see that I haven't approved this ticket yet, but also see it includes issues that were written/updated on another ticket (I think), and I'm confused about what is needed on this one. Are you able to clean up the PR, basing it on another branch, and/or reminding me to review this one after the dependent changes are approved or merged and updated or removed from this PR?

Thanks.

This one depends on the changes in cliff/handle-block-completion (#16112). It was getting time consuming to keep rebasing this and #16234 whenever I added a commit to that PR, so it may be a little out of data ATM. Once that gets merged, I'll update this to match it, ensure all outstanding review issues are addressed, and ask for another review.

@robrap
Copy link
Contributor

robrap commented Oct 24, 2017

Great. I'll wait for your prompt on this one. Thanks.

@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch 3 times, most recently from 16e51d1 to 12b6e66 Compare October 25, 2017 15:47
* Add a handler to mark a block complete when a problem is scored.
* Also handle marking incomplete when user problem state is deleted.
* Add score_deleted to published providing_args for PROBLEM_{RAW,WEIGHTED}_SCORE_CHANGED

OC-3089
@jcdyer jcdyer force-pushed the cliff/complete-scored-blocks branch from 12b6e66 to 69271d0 Compare October 25, 2017 15:50
@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 25, 2017

@robrap @bradenmacdonald This has been rebased against the master branch. Can I get a fresh review on it? I had to expand the waffle flag handling a bit to prevent breaking grading, and I accidentally did it during the rebase cleanup, so it's all still one commit.

@jcdyer jcdyer closed this Oct 25, 2017
@jcdyer jcdyer reopened this Oct 25, 2017
@jcdyer jcdyer closed this Oct 25, 2017
@jcdyer jcdyer reopened this Oct 25, 2017
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

I wasn't too careful this pass. Just reviewing waffle. If you have any concerns, please point the way. Thanks!

@robrap
Copy link
Contributor

robrap commented Oct 25, 2017

@jcdyer: I can't find your earlier comment from one of these PR's with a "Xsoon" joke, but I appreciated it.

@jcdyer
Copy link
Contributor Author

jcdyer commented Oct 26, 2017

@robrap Glad to hear it. I don't have any particular concerns on the latest implementation. I'll get this squashed and merged.

@jcdyer jcdyer merged commit 2cadbba into openedx:master Oct 27, 2017
@jcdyer jcdyer deleted the cliff/complete-scored-blocks branch October 27, 2017 14:32
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production on Monday, October 30, 2017.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

5 participants