Skip to content

Commit

Permalink
Fixed issue #8219: show printable_help on quexml-PDFs
Browse files Browse the repository at this point in the history
Dev: Can be switched on with
Dev: config variable 'quexmlshowprintablehelp'
Dev: Off by default to prevent user surprises
  • Loading branch information
mfaber committed Nov 22, 2013
1 parent 930a40a commit a3366bd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
3 changes: 3 additions & 0 deletions application/config/config-defaults.php
Expand Up @@ -359,6 +359,9 @@
$config['pdffontsize'] = 9; //Fontsize for normal text; Surveytitle is +4; grouptitle is +2
$config['pdforientation'] = 'P'; // Set L for Landscape or P for portrait format

// QueXML-PDF: If set to true, the printable_help attribute will be visible on the exported PDF questionnaires
// If used, the appearance (font size, justification, etc.) may be adjusted by editing td.questionHelpBefore and $helpBeforeBorderBottom of quexml.
$config['quexmlshowprintablehelp'] = false;

// CAS Settings
/**
Expand Down
27 changes: 24 additions & 3 deletions application/helpers/export_helper.php
Expand Up @@ -973,11 +973,14 @@ function QueXMLCreateFixed($qid,$rotate=false,$labels=true,$scale=0,$other=false
/**
* from export_structure_quexml.php
*/
function quexml_get_lengthth($qid,$attribute,$default)
function quexml_get_lengthth($qid,$attribute,$default, $quexmllang=false)
{
global $dom;

$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND attribute = '$attribute'";
if ($quexmllang!=false)
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND language='$quexmllang' AND attribute='$attribute'";
else
$Query = "SELECT value FROM {{question_attributes}} WHERE qid = $qid AND attribute='$attribute'";

//$QueryResult = mysql_query($Query) or die ("ERROR: $QueryResult<br />".mysql_error());
$QueryResult = Yii::app()->db->createCommand($Query)->query();

Expand Down Expand Up @@ -1272,6 +1275,24 @@ function quexml_export($surveyi, $quexmllan)

$question->appendChild($directive);
}

if (Yii::app()->getConfig('quexmlshowprintablehelp')==true)
{

$RowQ['printable_help']=quexml_get_lengthth($qid,"printable_help","", $quexmllang);

if (!empty($RowQ['printable_help']))
{
$directive = $dom->createElement("directive");
$position = $dom->createElement("position","before");
$text = $dom->createElement("text", '['.$qlang->gT('Only answer the following question if:')." ".QueXMLCleanup($RowQ['printable_help'])."]");
$administration = $dom->createElement("administration","self");
$directive->appendChild($position);
$directive->appendChild($text);
$directive->appendChild($administration);
$question->appendChild($directive);
}
}

$response = $dom->createElement("response");
$sgq = $RowQ['title'];
Expand Down

0 comments on commit a3366bd

Please sign in to comment.