error messages with wrong question numbers

error messages with wrong question numbers

by Jac Gubbels -
Number of replies: 1
I noted that when mixing questions with labels (and page breaks) there is a problem with the numbers of the questions that are indicated as missing. Basically the labels (a kind of question) are counted as real questions when calculating the question numbers. This results in question numbers in the error message that are too high. I.e. You are missing required questions: #25. #26 in stead of the actual You are missing required questions: #23. #24.

Below a little hack that I would like the community to check for validity. It seems to work, but I am a very limited php programmer so do not copy paste this into you code without knowing what you are doing

In locallib.php find the line that says '// ---- RESPONSE LIBRARY' and add the foreach loop as indicated below to the 'response_check_format' function

function response_check_format($section, &$formdata, $qnum='') {
$missing = 0;
$strmissing = ''; // missing questions
$wrongformat = 0;
$strwrongformat = ''; // wrongly formatted questions (Numeric, 5:Check Boxes, Date)
$i = 1;
for($j = 2; $j<=$section; $j++) {
// ADDED A SIMPLE LOOP FOR MAKING SURE PAGE BREAKS (type 99) AND LABELS (type 100) ARE NOT ALLOWED
foreach ($this->questionsbysec[$j-1] as $sectionrecord) {
$tid = $sectionrecord->type_id;
if ($tid < 99) {
$i++;
}
}

// I REMOVED ONLY THE LINE DIRECTLY BELOW THIS ONE
// $i += count($this->questionsbysec[$j-1]);

}
$qnum = $i - 1;

...

Maybe the developers of this beautiful moodle plugin can react!?
Average of ratings: -
In reply to Jac Gubbels

Re: error messages with wrong question numbers

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Jac,
Thanks for reporting this bug... and for providing the fix. It would be nice if all reported bugs were accompanied by a working fix (even if this was a small bug easy to fix).wink
Joseph
PS.- See CONTRIB-978.