From bb98e8ad03c5105fee64623701686f6b3377f094 Mon Sep 17 00:00:00 2001 From: mfaber Date: Sun, 13 Oct 2013 16:35:40 +0200 Subject: [PATCH] Fixed issue #8160: queXML export: ambigous variable names in text/number/dual matrix question Dev: Variable names are now built as: Dev: [questioncode]_[y-scale code]_[x-scale code]. Dev: Varnames are thus compatible with VV-export, Dev: Stata-XML and so on and so forth, which facilitates Dev: easy merging of data collected with quexf and LS --- application/helpers/export_helper.php | 4 ++-- application/libraries/admin/quexmlpdf.php | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/helpers/export_helper.php b/application/helpers/export_helper.php index b1bbff04d14..2c8d0824e21 100644 --- a/application/helpers/export_helper.php +++ b/application/helpers/export_helper.php @@ -1039,7 +1039,7 @@ function quexml_create_multi(&$question,$qid,$varname,$scale_id = false,$free = else $response->appendChild(QueXMLCreateFree($free['f'],$free['len'],$Row['question'])); - $response->setAttribute("varName",$varname . QueXMLCleanup($Row['title'])); + $response->setAttribute("varName",QueXMLCleanup($Row['title'])); $question->appendChild($response); } @@ -1105,7 +1105,7 @@ function quexml_create_subQuestions(&$question,$qid,$varname,$use_answers = fals $subQuestion = $dom->createElement("subQuestion"); $text = $dom->createElement("text",QueXMLCleanup($Row['question'],'')); $subQuestion->appendChild($text); - $subQuestion->setAttribute("varName",$varname . QueXMLCleanup($Row['title'])); + $subQuestion->setAttribute("varName",$varname .'_'. QueXMLCleanup($Row['title'])); $question->appendChild($subQuestion); } diff --git a/application/libraries/admin/quexmlpdf.php b/application/libraries/admin/quexmlpdf.php index 26d1640a6e0..c2e5aa17473 100644 --- a/application/libraries/admin/quexmlpdf.php +++ b/application/libraries/admin/quexmlpdf.php @@ -1695,6 +1695,17 @@ protected function createQuestion($question) $bgtype = 3; //box group type temp set to 3 (text) + // question with > 1 responses and >1 subquestions --> matrix question --> need to come up with unique variable names + if (count($question['responses'])>1) + { + foreach ($subquestions as $index=>$sv) + { + $subquestions[$index]['varname']=$subquestions[$index]['varname'].'_'.$varname; + } + } + $debugoutput=$subquestions; +file_put_contents('/debugdata.txt', print_r($debugoutput, true), FILE_APPEND); + switch ($type) { case 'fixed':