diff --git a/mod/quiz/doc/versioning.html b/mod/quiz/doc/versioning.html
index cc76bced279..78720592c5c 100644
--- a/mod/quiz/doc/versioning.html
+++ b/mod/quiz/doc/versioning.html
@@ -31,8 +31,23 @@ The first goal, namely keeping around old questions, is easily achieved. They
are just not deleted any more. However, this is not enough; it is also necessary
to store which questions are versions of others. To achieve this goal, there is
an additional table, which stores the versioning information:
-quiz_question_versions. Finally, there is a cosmetic issue. If all
-old versions of questions are kept around this would horribly clutter the
+quiz_question_versions.
+
+
+
+When a question is replaced for which there are already student attempts then
+all the attempt data gets associated to the new version of the question and is
+re-graded. This requires the question ids in the quiz_attempts,
+quiz_states and quiz_newest_states tables to be
+replaced by the new id. However we do also want to be able to reconstruct
+the quiz the way the student saw it when he gave his answers. For that purpose
+the id of the original question is always preserved in the 'originalquestion'
+field of the quiz_states table.
+
+
+
+If all
+old versions of questions are kept around this could horribly clutter the
editing interface. Therefore a field called hidden was added to the
quiz_questions table and all old versions of edited questions are
automatically hidden. When this flag is set to 1 the question is not displayed
@@ -71,10 +86,12 @@ checked for that quiz as well.
-The changes to the database structure are limited to an added field
-(hidden) in the quiz_questions table and an additional
-table called quiz_question_versions. However, dealing with the
-quiz_questions table has become slightly more complicated.
+The changes to the database structure are limited to an
+added field (hidden) in the
+quiz_questions table and an additional table called
+quiz_question_versions. However, dealing with the
+quiz_questions table has become slightly more
+complicated.
@@ -104,15 +121,15 @@ the order shown below (compare with question.php):
quiz_question_states
- table for each affected quiz (i.e. each quiz in which the questin was
+ First a new record is inserted into the quiz_question_versions
+ table for each affected quiz (i.e. each quiz in which the question was
replaced).
question field is updated
- with a comma separated list of question ids, where the old question id is
- replaced with the new one.
+ Then, for each affected quiz, the comma separated list of question ids in the
+ question field is updated by replacing the old question id with
+ the new one.
originalquestion field in the
- quiz_states table (this is determined by the
- originalquestion field beeing set to '0').
+ In all attempts belonging to the old question the comma-separated list of
+ question ids in the layout field are changed by replacing the
+ old id by the new one.
- Question for Gustav:
- Should we also update the attempt->layout field at this point? Or do we use
- that to determine how the student's attempt actually looked when they took
- the quiz?
-
- That's what is causing bug #3311: the attempts->layout field is not updated,
- so there are question ids in attempts->layout, which don't have
- instances associated with them. However, we need information from the
- quiz_question_instances table (grade, which
- becomes question->maxgrade and less importantly, I think, the
- instance id, which becomes question->instance).
-
- In the remaining text I assume that we don't change
- attempt->layout.
-
originalquestion field.
+
+ questionid field in
+ quiz_newest_states.