Hi All,
We use this module in our current project and it works quite good. But unfortunately calculation of progress doesn't work well.
I'm working on integration of this module with Views and I found that when several quizzes are linked to certificate, the process is always 0, except the situation when all quizzes are passed. I found that the issue is in this code:
// Quiz calculations
foreach ($certificates as &$cert) {
$cert->gotpoints = 0; // Points the user actually got
$cert->gotpoints_capped = 0; // Points the user actually got, capped to points needed for each condition
$cert->needpoints = 0; // Ponts the user neede to pass
$cert->totalpoints = 0; // Total points available
foreach ($cert->quizzes as $quizvid => &$quiz) {
$cert->gotpoints += $quiz->score->achieved_score;
$cert->needpoints += $quiz->score->pass_score;
$cert->gotpoints_capped = $quiz->score->achieved_score > $quiz->score->pass_score ? $quiz->score->pass_score : $quiz->score->achieved_score;
$cert->totalpoints += $quiz->score->max_score;
}
}
Calculation works well with this quick fix (I added "+=" instead of "="):
$cert->gotpoints_capped += $quiz->score->achieved_score > $quiz->score->pass_score ? $quiz->score->pass_score : $quiz->score->achieved_score;
Comments
Comment #1
fuzzy76 commentedThanks for spotting this! This is the bug that I couldn't quite find (we mostly use 1 quiz per certificate) that caused me to recommend 2.0beta instead of 1.1 of certify. It has been rewritten, and doesn't have this bug.
I will do a bugfix release on monday with your code. :)
Comment #2
fuzzy76 commented