Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #8182: (quexf-pdf) labels for dual matrix question #129

Merged
merged 1 commit into from
Sep 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion application/helpers/export_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1399,10 +1399,22 @@ function quexml_export($surveyi, $quexmllan)
case "1": //Dualscale multi-flexi array
//select subQuestions from answers table where QID
quexml_create_subQuestions($question,$qid,$sgq);
//get the header of the first scale of the dual scale question
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND language='$quexmllang' AND attribute='dualscale_headerA'";
$QRE = Yii::app()->db->createCommand($Query)->query();
$QROW = $QRE->read();
$response = $dom->createElement("response");
if ($QROW['value'])
$response->setAttribute("varName",QueXMLCleanup($QROW['value']));
$response->appendChild(QueXMLCreateFixed($qid,false,false,0,$other,$sgq));

//get the header of the second scale of the dual scale question
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND language='$quexmllang' AND attribute='dualscale_headerB'";
$QRE = Yii::app()->db->createCommand($Query)->query();
$QROW = $QRE->read();
$response2 = $dom->createElement("response");
$response2->setAttribute("varName",QueXMLCleanup($sgq) . "_2");
if ($QROW['value'])
$response2->setAttribute("varName",QueXMLCleanup($QROW['value']));
$response2->appendChild(QueXMLCreateFixed($qid,false,false,1,$other,$sgq));
$question->appendChild($response);
$question->appendChild($response2);
Expand Down
30 changes: 21 additions & 9 deletions application/libraries/admin/quexmlpdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -1679,8 +1679,12 @@ protected function createQuestion($question)
if (isset($question['text'])) $text = $question['text'];

//Loop over response groups and produce questions of various types
if (isset($question['responses'])) { foreach($question['responses'] as $r)
{
if (isset($question['responses']))
{
//the number of response scales is needed later on to decide on labelling scales in fixed response questions
$iCountResponseScales=count($question['responses']);
foreach($question['responses'] as $r)
{
$varname = $r['varname'];

if (isset($r['subquestions']))
Expand Down Expand Up @@ -1742,10 +1746,10 @@ protected function createQuestion($question)
{
$this->commitTransaction();
}
/** End redo question title/text/help **/
// if there is more than one response scale, add a label to scales in the pdf
$this->drawSingleChoiceHorizontal($categories,$subquestions,$text,$iCountResponseScales >1? $varname : false);
}
/** End redo question title/text/help **/
$this->drawSingleChoiceHorizontal($categories,$subquestions,$text);

break;
case 'number':
$bgtype = 4;
Expand Down Expand Up @@ -2302,7 +2306,7 @@ protected function drawMatrixTextHorizontal($subquestions,$width,$parenttext = f
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2012-06-05
*/
protected function drawSingleChoiceHorizontalHead($categories)
protected function drawSingleChoiceHorizontalHead($categories, $responsegrouplabel=false)
{
$total = count($categories);
$currentY = $this->GetY();
Expand All @@ -2313,6 +2317,14 @@ protected function drawSingleChoiceHorizontalHead($categories)
$rwidth = $this->singleResponseVerticalAreaWidth;

$textwidth = ($this->getColumnWidth() - $this->skipColumnWidth) - ($rwidth * $total);

//Draw a label for a group of Questions/Responses (e.g. useful for dual scale matrix questions)
if ($responsegrouplabel!=false)
{
$this->setBackground('question');
$this->setDefaultFont();
$this->MultiCell($textwidth,$this->responseLabelHeight,$responsegrouplabel.':',0,'L',false,0,$this->getColumnX()+$this->questionTitleWidth,$this->GetY(),true,0,false,true,$this->responseLabelHeight,'B',true);
}


//First draw a background of height $this->responseLabelHeight
Expand Down Expand Up @@ -2353,7 +2365,7 @@ protected function drawSingleChoiceHorizontalHead($categories)
* @author Adam Zammit <adam.zammit@acspri.org.au>
* @since 2010-09-08
*/
protected function drawSingleChoiceHorizontal($categories, $subquestions = array(array('text' => '')),$parenttext = false)
protected function drawSingleChoiceHorizontal($categories, $subquestions = array(array('text' => '')),$parenttext = false, $responsegrouplabel=false)
{
$total = count($categories);
$currentY = $this->GetY();
Expand All @@ -2368,7 +2380,7 @@ protected function drawSingleChoiceHorizontal($categories, $subquestions = array
if ($this->allowSplittingSingleChoiceHorizontal) $this->startTransaction(); //start a transaction

//draw the header
$this->drawSingleChoiceHorizontalHead($categories);
$this->drawSingleChoiceHorizontalHead($categories, $responsegrouplabel);
$currentY += $this->responseLabelHeight;

for ($i = 0; $i < count($subquestions); $i++)
Expand Down Expand Up @@ -2427,7 +2439,7 @@ protected function drawSingleChoiceHorizontal($categories, $subquestions = array
$this->SetAutoPageBreak(false); //Temporarily set so we don't trigger a page break
$this->fillPageBackground();
$this->newPage();
$this->drawSingleChoiceHorizontalHead($categories);
$this->drawSingleChoiceHorizontalHead($categories, $responsegrouplabel);

//reset currentY
$currentY = $this->GetY() + $this->responseLabelHeight;
Expand Down