function quiz_calculate_score() return array contains element 'question_count' that includes 'instruction' nodes as well as question nodes. This throws off the !total substitution token.

Using the default mailer message one can get something like:

"You got 1 out of 3. Your percentage is 50"

from

"You got !correct out of !total. Your percentage is !percentage"

Comments

Sivaji_Ganesh_Jojodae’s picture

Status: Active » Fixed

Thanks for reporting this bug. Here the change you need to do

in quiz.module file, line number 1369

-    '!total' => $score['question_count'],
+    '!total' => $score['possible_score'],

Fix has been committed to 3.x branch.

d-b’s picture

Category: bug » feature
Status: Fixed » Needs review

Hello Sivaji,

Thanks for taking a look at this.

If you actually want to provide users with the ability to count non-instruction questions nodes, this might be a solution.

quiz.module (beta1) line number ~1363


+    '!count' =>$score['question_count'],

and line number 1651

-     count++;
+    if ($question->type != 'quiz_directions') {$count++;}

On a side note, this is the first collaborative project I've made code suggestions to, if there's a better way for me to do it or if I'm breaking convention and being an annoying n00b, please let me know.

Have a good one

Sivaji_Ganesh_Jojodae’s picture

Problem exists with token !total *not* with !count. Please compare the function theme_quiz_take_summary and quiz_mail you will understand.

d-b’s picture

sivaji,

I understand that changing !total to possible_score solves the problem of !total returning the count of questions instead of the possible score. Thank you for this.

There is a second issue here.

There is currently a property of the $score object called question_count. Despite it's name, does not contain the number of questions on a quiz. It instead contains the number of quiz nodes (questions & directions) in a given quiz. This is not really a relevant piece of information to include in this array since no one who wants to display the question count of a quiz will want to include direction nodes.

The change I suggested makes the question_count property of $score actually mean something. This is useful for the theme_summary type functions that pull directly from the $score object since they now have a correct question count to access for anyone that wants to display it.

It is also then useful to expose this correct question_count for use in the mail functions, thus the suggestion of a !count token.

e.g.

You scored 10 points of a possible 20 points. This represents a 50% achievement over 15 questions.

Sivaji_Ganesh_Jojodae’s picture

Title: $score['question_count'] counts directions as well as questions » Why do Quiz Directions count as Questions?
Version: 6.x-3.0-beta1 » 7.x-4.x-dev
Status: Needs review » Needs work

I would like to see this fixed in 7.x-4.x

lejon’s picture

Hi,

As mentioned elsewhere in the support issues, I am using Quiz for e-learning purposes. I don't know whether many other people are doing this.

Sivaji suggests "I am in favor of depreciating quiz directions from quiz questions in display. "

http://drupal.org/node/1120890#comment-4365288

Would this affect the listing of quiz directions in the "jumping" navigation function? Ideally this would be able to separate the two, with the option of showing the node title of the question/direction in the jumping menu and/or a separate navigation block.

djdevin’s picture

Component: Code - Quiz module » Code - Quiz core
Issue summary: View changes
Status: Needs work » Closed (outdated)