quiz_get_score_data only returns the last result because it keys the returned array using vid. This makes the returned data useless.

If we don't use num_questions this can be fixed by changing line 1449 of quiz.module from:

$to_return[$res_o->vid] = $res_o;

to

$to_return[] = $res_o;

Unfortunately, this breaks the num_questions calculation (because it uses the array keys to track where to store the number). So it probably needs a more elaborate fix.

CommentFileSizeAuthor
#4 quiz-939130.patch1.33 KBfuzzy76

Comments

fuzzy76’s picture

Or I guess you could have the function return best score only by changing:

$to_return[$res_o->vid] = $res_o;

to:

if (isset($to_return[$res_o->vid])) {
if ($res_o->percent_score > $to_return[$res_o->vid]->percent_score) {
$to_return[$res_o->vid] = $res_o;
}
}
else {
$to_return[$res_o->vid] = $res_o;
}

falcon’s picture

Priority: Major » Normal

I think you told me that you had a patch for this one?

falcon’s picture

Status: Active » Postponed (maintainer needs more info)
fuzzy76’s picture

StatusFileSize
new1.33 KB

Sorry about forgetting it! :) Here you go. I opted for only returning the highest score. Since I think that was the use case that function were meant for initially.

fuzzy76’s picture

Status: Postponed (maintainer needs more info) » Needs review
falcon’s picture

Status: Needs review » Fixed

Thanks! Patch has been committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.