Permalink
Browse files

random question history MDL-20951: Two minor bugs in the fix for MDL-…

…20776.

Thanks to Oleg Sychev for noticing these problems.
  • Loading branch information...
1 parent 5929c00 commit 15b9c8e9c60d078d150043793445e09d0960e3e2 @timhunt timhunt committed Nov 24, 2009
Showing with 6 additions and 1 deletion.
  1. +6 −1 question/type/questiontype.php
@@ -950,8 +950,10 @@ function history($question, $state, $number, $cmoptions, $options) {
if (isset($question->randomquestionid)) {
$qid = $question->randomquestionid;
+ $randomprefix = 'random' . $question->id . '-';
} else {
$qid = $question->id;
+ $randomprefix = '';
}
if ($options->history == 'all') {
$eventtest = 'event > 0';
@@ -961,7 +963,7 @@ function history($question, $state, $number, $cmoptions, $options) {
$states = get_records_select('question_states',
'attempt = ' . $state->attempt . ' AND question = ' . $qid .
' AND ' . $eventtest, 'seq_number ASC');
- if (empty($states)) {
+ if (count($states) <= 1) {
return '';
}
@@ -980,6 +982,9 @@ function history($question, $state, $number, $cmoptions, $options) {
}
foreach ($states as $st) {
+ if ($randomprefix && strpos($st->answer, $randomprefix) === 0) {
+ $st->answer = substr($st->answer, strlen($randomprefix));
+ }
$st->responses[''] = $st->answer;
$this->restore_session_and_responses($question, $st);

0 comments on commit 15b9c8e

Please sign in to comment.