Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-29378 Fix regression in the Survey/COLLES P+A module

This basically reverts the commit 5196df5 that
I believe was a result of misunderstanding of how question type field is
(ab)used in the Survey module. As it took significant time to get familiar with
the overall logic of questions and their processing in the module, I left my
findings in added inline comments. The point is that it is $question->type that
matters. Types of questions listed as subquestions in the multi field is
irrelevant in that case (and all have it set to 1 IIRC).

This patch re-enables the "COLLES (Preferred and Actual)" survey type that did
not work at all due to regression.
  • Loading branch information...
commit 597f4acd892a04112631e919dbe59b3fe9eace91 1 parent 0bd9f00
@mudrd8mz mudrd8mz authored
Showing with 14 additions and 7 deletions.
  1. +14 −7 mod/survey/lib.php
View
21 mod/survey/lib.php
@@ -509,8 +509,22 @@ function survey_print_multi($question) {
$options = explode( ",", $question->options);
$numoptions = count($options);
+ // COLLES Actual (which is having questions of type 1) and COLLES Preferred (type 2)
+ // expect just one answer per question. COLLES Actual and Preferred (type 3) expects
+ // two answers per question. ATTLS (having a single question of type 1) expects one
+ // answer per question. CIQ is not using multiquestions (i.e. a question with subquestions).
+ // Note that the type of subquestions does not really matter, it's the type of the
+ // question itself that determines everything.
$oneanswer = ($question->type == 1 || $question->type == 2) ? true : false;
+ // COLLES Preferred (having questions of type 2) will use the radio elements with the name
+ // like qP1, qP2 etc. COLLES Actual and ATTLS have radios like q1, q2 etc.
+ if ($question->type == 2) {
+ $P = "P";
+ } else {
+ $P = "";
+ }
+
echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
echo "<th scope=\"col\" class=\"hresponse\">". get_string('notyetanswered', 'survey'). "</th>";
while (list ($key, $val) = each ($options)) {
@@ -533,13 +547,6 @@ function survey_print_multi($question) {
$q->text = get_string($q->text, "survey");
}
- $oneanswer = ($q->type == 1 || $q->type == 2) ? true : false;
- if ($q->type == 2) {
- $P = "P";
- } else {
- $P = "";
- }
-
echo "<tr class=\"$rowclass rblock\">";
if ($oneanswer) {
echo "<th scope=\"row\" class=\"optioncell\">";
Please sign in to comment.
Something went wrong with that request. Please try again.