How to programmatically reset students attempt for all problems in a given course?

Dear all,

I’d like to programmatically reset a students attempt (or even the entire progress if possible) for a given course. It is possible to unenroll a student from a course, but that does not delete this students progress. If he/she re-enrolls, the progress is still there.

So the question is - How to programmatically reset students attempt for all problems in a given course?

Thanks!
Daniel

The closest thing that I know of in edx-platform today is the instructor dashboard triggered ability to reset student state for a single problem:

So you could make your own management command in a plugin that copies much of this logic and applies it to all of a student’s problems in a course. A word of warning there: the indexes for StudentModule aren’t built properly to grab all of a student’s state for a given course (an oversight that’s hard to fix now because of potential locking issues given how big this table is in various installs now). So I believe doing a query on (student_id, course_id) will try to do the intersection of the rows that are returned by the index on each of those columns, instead of using a composite index–meaning that it might be slower and more expensive than you might expect.

If you want to add this functionality to the instructor dashboard, that might require a product conversation (FYI @jmakowski), since this would be a very dangerous button to press.

Good luck!

1 Like