Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedThanks for reporting this bug. Here the change you need to do
in quiz.module file, line number 1369
Fix has been committed to 3.x branch.
Comment #2
d-b CreditAttribution: d-b commentedHello 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
and line number 1651
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
Comment #3
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedProblem exists with token !total *not* with !count. Please compare the function theme_quiz_take_summary and quiz_mail you will understand.
Comment #4
d-b CreditAttribution: d-b commentedsivaji,
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.
Comment #5
Sivaji_Ganesh_Jojodae CreditAttribution: Sivaji_Ganesh_Jojodae commentedI would like to see this fixed in 7.x-4.x
Comment #6
lejon CreditAttribution: lejon commentedHi,
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.
Comment #7
djdevin