Closed (won't fix)
Project:
Quiz
Version:
6.x-3.x-dev
Component:
Code - Quiz core
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
1 Jun 2009 at 13:06 UTC
Updated:
7 Jun 2014 at 03:16 UTC
Jump to comment: Most recent
Comments
Comment #1
darktygur-1 commentedThis may or may not be an easy fix. In my opinion, leaving a long-answer question blank should be the same as not choosing an answer in the other question types. In that case, you would be skipping the question, which gets special treatment. If #488304: Allow admins to disable skipping of questions makes it in, skipping can be disabled from the UI, but until then, there is a way to disable it from the source code.
The quiz_take_quiz() function checks $_POST['tries'] to determine whether nothing was entered (and therefore whether the question is being skipped). The problem is that it does isset($_POST['tries']). For long-answer questions, that'll always be set (if they enter nothing, it's a zero-length string).
It looks like you can get away with changing this:
if (!isset($_POST['tries'])) {
... to this:
if (!isset($_POST['tries']) || $_POST['tries'] === '') {
The problem is that I'm not completely sure how this would affect the other question types. Offhand, I can't think of any case where a question would need to have a zero-length string as a valid answer. But I'm not familiar enough with them to say that with much accuracy.
Comment #2
mbutcher commentedYour proposed solution should work. The tricky part (that caused me to change it to isset()) is that some question types may return booleans (TRUE/FALSE).
I'm wondering if maybe something like this might be preferable:
if (!isset($_POST['tries']) || (is_string($_POST['tries'] && strlen(trim($_POST['tries'])) > 0)) {
That additional check will make the answer ' ' evaluate as empty.
What do you think?
Comment #3
darktygur-1 commentedHere, I fixed your proposed if statement so that it actually works:
if (!isset($_POST['tries']) || (is_string($_POST['tries']) && strlen(trim($_POST['tries'])) == 0)) {
Whether that's good depends on whether question types might want something like ' ' to be valid (which I doubt). So it sounds good to me.
I wonder if the best solution might be to just ask the question type whether the answer given is blank. But this is easier, and it looks like it'll work.
Comment #4
summit commentedHi,
Shouldn't it not also be possible to set an option on evert question-type whether the quiz-taker needs to select an answer.
I have exactly the same issue with the new scale type, in quiz 4, see: http://drupal.org/node/501886#comment-1813668
Hopefully a general solution is possible to select with every quiz-question whether an answer of the quiz-taker is required.
thanks for considering this!
Greetings,
Martijn
Comment #5
falcon commentedI think the maintainers are planning to add this feature for all(or selected) question types. I need it for my use-cases as well.
Comment #6
djdevin