MDL-30484 question engine: don't lose response files when regrading.
authorTim Hunt <T.J.Hunt@open.ac.uk>
Mon, 16 Jan 2012 18:29:52 +0000 (18:29 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Mon, 30 Jan 2012 16:57:23 +0000 (16:57 +0000)
commit94815ccfa0895e27a2bb2c22e450c3e6074c623b
tree07e2259c1893237fc23830993abd1c0f8eb44f92
parent216f6d8e9d7e7473890ce0cb42332396e33740a0
MDL-30484 question engine: don't lose response files when regrading.

The problem was mostly that, in the past, we did not worry if
question_attempt_step.id changed during regrade (because we deleted the
old step row and inserted a new one). However, now that steps can have
associated files, we can't be that slack, becuase the step id is used as
the file itemid.

So, now, we have to update the existing rows during a regrade. We do
this by having the question engine tell the question_engine_unit_of_work
that the step has first been deleted, and then added back. Then we make
the unit-of-work spot that delete + add = update.

This also means that during regrading, we have to pass around some extra
ids so that new steps know the id of the step they are replacing.

Naturally, this requires some quite trickly logic, so I finally got
around to writing unit tests for question_engine_unit_of_work, which is
a good thing.

Along the way I also got around to renaming
question_attempt->set_number_in_usage, which got missed out when
everthing else was renamed to slot ages ago.

Finally, while working on this code, I noticed and fixed some PHPdoc
comments.
question/engine/datalib.php
question/engine/questionattempt.php
question/engine/questionattemptstep.php
question/engine/questionusage.php
question/engine/simpletest/testquestionattempt.php
question/engine/simpletest/testquestionusagebyactivity.php
question/engine/simpletest/testunitofwork.php [new file with mode: 0644]