Skip to content

Clear state option - #34

Closed
efischer19 wants to merge 4 commits into
masterfrom
efischer/clear_state
Closed

Clear state option#34
efischer19 wants to merge 4 commits into
masterfrom
efischer/clear_state

Conversation

@efischer19

Copy link
Copy Markdown
Contributor

To fix the buggy behavior reported in TNL-3880, we need to ensure
that the submission we're dropping is unlinked from the student_item
used to find it. This prevents code (say, an ORA staff tool) from
constructing a student item with an id, a course, and a problem, and
using that to find a "cleared" submission.

TNL-3880
Sibling changes:

To fix the buggy behavior reported in TNL-3880, we need to ensure
that the submission we're dropping is unlinked from the student_item
used to find it. This prevents code (say, an ORA staff tool) from
constructing a student item with an id, a course, and a problem, and
using that to find a "cleared" submission.
@openedx-webhooks

Copy link
Copy Markdown

PR Checklist

Sandbox

  • not yet prepared

Testing

  • determine what, if any tests are needed here
  • implement them

Reviewers

If you've been tagged for review, please check your corresponding box once you've given the 👍.

Post-review

  • Squash commits

Eric Fischer added 2 commits February 4, 2016 10:08
Turns out you have to let the database know that a value can be None,
who knew? Migration included.
@efischer19

Copy link
Copy Markdown
Contributor Author

@dianakhuang @cahrens This simpler fix is ready for an initial review (not final, still some open questions to answer).

What I misunderstood originally was that we aren't actually deleting anything, we're just orphaning submissions by having a student's module state forget the submission_uuid. However, staff can construct a perfectly valid lookup triplet of (student, course, problem), use that to query the submissions API, and get a (supposedly "orphaned") submission_uuid back.

This fix will now eliminate the key that made such lookups possible, which prevents staff from seeing the individual submission even if they do construct the lookup triplet again. This solves the problem of staff being able to see deleted items with the Manage Individual Learners tool.

What this does not address is the aggregate data in the View Assignment Statistics tool. This is looking up data (in an ORA database) keyed on (course, problem). Since ORA was never informed of the 'reset state' request, it has no way of knowing that these 'deleted' values should be removed. I have several ideas of how to fix this, but I also wonder if it's worthwhile. How do others feel? To fix it would require informing ORA of "cleared" submissions, either by the LMS at time of deletion, or by submissions at lookup time.

@efischer19

Copy link
Copy Markdown
Contributor Author

@maxrothman what's the devops impact of an AlterField migration? We're just removing a NOT NULL constraint from a column here.

@efischer19

Copy link
Copy Markdown
Contributor Author

To go along with the View Assignment Statistics issue mentioned above - ORA also stores references to the should-have-been-deleted submission_uuid in various workflow items, meaning that peers (and I assume staff, have yet to check) can be given previously "cleared" submissions for grading.

So it looks like we will need to inform ORA of the removal somehow, so it can clear out any items that refer to the cleared submission. I'll keep working on that.

name='student_item',
field=models.ForeignKey(to='submissions.StudentItem', null=True),
),
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One potential issue I've discovered during dev testing - trying to reverse this migration after NULL values have been added results in an error, so I'll have to figure that out, at least.

django.db.utils.OperationalError: (1138, 'Invalid use of NULL value').

@efischer19

Copy link
Copy Markdown
Contributor Author

I've updated this PR and it's siblings to inform openassessment of the clear operation, and it looks like it's working.

@dianakhuang and/or @cahrens, could we start going over this in a bit more detail when we get a chance? I've installed all of this code on https://efischer19.sandbox.edx.org/ if you want to test it out.

field=models.ForeignKey(to='submissions.StudentItem', null=True, default=1),
preserve_default=False
),
]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@maxrothman Here's some data from running this migration on my devstack with ~1400 rows of data, the read-replica indicates ~670,000 on production

https://gist.github.com/efischer19/b56b9d14768de28cf612

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@efischer19 Do you feel those results are representative enough to indicate lack of an issue with ~100x rows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think so. The two longest lines seem to be these, what else should we be considering when extrapolating?

DEBUG:django.db.backends:(0.114) ALTER TABLE `submissions_submission` MODIFY `student_item_id` integer NULL; args=[]
DEBUG:django.db.backends:(0.130) ALTER TABLE `submissions_submission` ADD CONSTRAINT `su_student_item_id_d3801ff833d05b1_fk_submissions_studentitem_id` FOREIGN KEY (`student_item_id`) REFERENCES `submissions_studentitem` (`id`); args=[]

There's also now a possibility of avoiding migrations entirely if the approach in #35 wins out as our best option.

@efischer19 efischer19 closed this Feb 18, 2016
@nsprenkle
nsprenkle deleted the efischer/clear_state branch November 12, 2021 20:13
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.

4 participants