Permalink
Browse files

MDL-26520 random tf questions that had not been answered were shown a…

…s answered on the summary page.

This was a regression from MDL-26236 thanks to some brain-dead PHP behaviour.
  • Loading branch information...
1 parent 48fe5c6 commit 231ec773234a45dc20b3625d01a46bfef2776e23 @timhunt timhunt committed Mar 5, 2011
Showing with 6 additions and 0 deletions.
  1. +6 −0 question/type/random/questiontype.php
@@ -260,6 +260,12 @@ function restore_session_and_responses(&$question, &$state) {
$wrappedquestion->qtype = 'missingtype';
}
$state->responses[''] = substr($state->responses[''], strlen('random' . $questionid . '-'));
+ if ($state->responses[''] === false) {
+ // In PHP, if $response === $prefix, then
+ // substr($response, strlen($prefix)) returns false, not '',
+ // which is stupid, and caused MDL-26520. Fix up that case here.
+ $state->responses[''] = '';
+ }
}
if (!$QTYPES[$wrappedquestion->qtype]

0 comments on commit 231ec77

Please sign in to comment.