Please sign in to comment.
MDL-38538 question auto-save back end.
1. Autosave works in some ways just like a normal save. We ultimately call $behaviour->process_save() to do the work, and create a new step to hold the data. 2. However, we come in through a completely different route through the API, starting with separate auto-save methods. This keeps the auto-save changes mostly separate, and so reduced the chance of breaking existing working code. 3. When the time comes to store the auto-save step in the database, we save it using a negative sequence number. This is a clever trick that not only distinguises these steps, but also avoids unique key errors when an auto-save and a real action happen simultaneously. (There are unit tests for these tricky edge cases.) 4. When we load the data back from the database, most of the time the auto-save steps are loaded back as if they were a real save, and so the auto-saved data is used when the question is then rendered. 5. However, before we process another action, we remove the auto-saved step, so it does not appear in the final history.
- Loading branch information...
Showing with 886 additions and 23 deletions.
- +36 −0 question/behaviour/behaviourbase.php
- +2 −4 question/engine/datalib.php
- +6 −4 question/engine/lib.php
- +87 −6 question/engine/questionattempt.php
- +56 −9 question/engine/questionusage.php
- +112 −0 question/engine/tests/questionattempt_db_test.php
- +562 −0 question/engine/tests/questionusage_autosave_test.php
- +25 −0 question/tests/generator/lib.php
Oops, something went wrong.