MDL-10799 - Question types do not accurately determine whether their state has changed or not. Merged from MOODLE_18_STABLE.

This commit is contained in:
tjhunt
2007-08-10 15:21:29 +00:00
parent 76317c73a2
commit ceeae340f9
2 changed files with 12 additions and 8 deletions
+10 -1
View File
@@ -1157,7 +1157,16 @@ class default_questiontype {
// Question types may wish to override this (eg. to ignore trailing
// white space or to make "7.0" and "7" compare equal).
return $state->responses === $teststate->responses;
// In php neither == nor === compare arrays the way you want. The following
// ensures that the arrays have the same keys, with the same values.
$result = false;
$diff1 = array_diff_assoc($state->responses, $teststate->responses);
if (empty($diff1)) {
$diff2 = array_diff_assoc($teststate->responses, $state->responses);
$result = empty($diff2);
}
return $result;
}
/**