Update the stamp each time a question is edited. This is the outcome of a long Skype discussion with Eloy on 15/02/06. A planned improvement for the future is to set the stamp to a md5 hash of the questiondata to ensure that identical questions will have identical stamps. Currently it is possible to obtain some duplication during question restore if between backup and restore the teacher clicks on the Save button on the editing page without acutally making any changes. Admittedly not a very likely scenario and hence the current system is good enough for now.

This commit is contained in:
gustav_delius
2006-02-16 10:20:27 +00:00
parent 84f037e086
commit 92c781cab3
+6 -1
View File
@@ -74,13 +74,18 @@ class quiz_default_questiontype {
$question->defaultgrade = $form->defaultgrade;
}
// Set the unique code
// TODO: set the stamp to a hash of the questiondata so that identical
// questions will get the same stamp. That will elliminate possible
// duplication during backup when questions get changed without changes
$question->stamp = make_unique_id_code();
if (!empty($question->id)) { // Question already exists
$question->version ++; // Update version number of question
if (!update_record("quiz_questions", $question)) {
error("Could not update question!");
}
} else { // Question is a new one
$question->stamp = make_unique_id_code(); // Set the unique code (not to be changed)
$question->version = 1;
if (!$question->id = insert_record("quiz_questions", $question)) {
error("Could not insert new question!");