Skip to content

Commit

Permalink
Fixed text output of multiple choice questions
Browse files Browse the repository at this point in the history
Fixed evaluation of conditional code in page introductions
  • Loading branch information
hschottm committed Feb 28, 2019
1 parent a9abf57 commit 48bb124
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
6 changes: 0 additions & 6 deletions src/Resources/contao/classes/SurveyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ public function evalConditionTags($strBuffer)
$strReturn = ob_get_contents();
ob_end_clean();

// Throw an exception if there is an eval() error
if ($blnEval == false)
{
throw new \Exception("Error eval() in Formdata::evalConditionTags ($strReturn)");
}

// Return the evaled code
return $strReturn;
}
Expand Down
36 changes: 20 additions & 16 deletions src/Resources/contao/classes/SurveyQuestionMultiplechoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,20 +456,24 @@ protected function exportDetailResults(&$exporter, $sheet, &$row, &$col, $partic
}

public function resultAsString($res)
{
$arrAnswer = deserialize($res, true);
if (is_array($arrAnswer['value']))
{
return implode (", ", $arrAnswer['value']);
}
else
{
$arrChoices = (strcmp($this->arrData['multiplechoice_subtype'], 'mc_dichotomous') != 0) ? deserialize($this->arrData['choices'], true) : array(0 => $GLOBALS['TL_LANG']['tl_survey_question']['yes'], 1 => $GLOBALS['TL_LANG']['tl_survey_question']['no']);
return $arrChoices[$arrAnswer['value']-1];
}
if (strlen($arrAnswer['other']))
{
return $arrAnswer['other'];
}
}
{
$arrAnswer = deserialize($res, true);
$arrChoices = (strcmp($this->arrData['multiplechoice_subtype'], 'mc_dichotomous') != 0) ? deserialize($this->arrData['choices'], true) : array(0 => $GLOBALS['TL_LANG']['tl_survey_question']['yes'], 1 => $GLOBALS['TL_LANG']['tl_survey_question']['no']);
if (is_array($arrAnswer['value']))
{
foreach ($arrAnswer['value'] as $key => $val)
{
$selections[] = $arrChoices[$val-1];
}
return implode (", ", $selections);
}
else
{
return $arrChoices[is_numeric($arrAnswer['value']) ? $arrAnswer['value']-1 : -1];
}
if (strlen($arrAnswer['other']))
{
return $arrAnswer['other'];
}
}
}

0 comments on commit 48bb124

Please sign in to comment.