Skip to content

Commit

Permalink
Get answers dual scale (#1331)
Browse files Browse the repository at this point in the history
Fixed issue #13312: Get all answers for dualscale questions
Dev: Add additional property to retrieve all answer options of all scales
Fixed issue #13312: Get all answers for dualscale questions
Dev: add answeroptions_multiscale to list of possible properties in api documentation
  • Loading branch information
jakobwoegerbauer authored and LouisGac committed Oct 16, 2019
1 parent 93455a7 commit 4931bb6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion application/helpers/remotecontrol/remotecontrol_handle.php
Expand Up @@ -1471,7 +1471,7 @@ public function import_question($sSessionKey, $iSurveyID, $iGroupID, $sImportDat
* Get properties of a question in a survey.
*
* @see \Question for available properties.
* Some more properties are available_answers, subquestions, attributes, attributes_lang, answeroptions, defaultvalue
* Some more properties are available_answers, subquestions, attributes, attributes_lang, answeroptions, answeroptions_multiscale, defaultvalue
*
* @access public
* @param string $sSessionKey Auth credentials
Expand Down Expand Up @@ -1579,6 +1579,21 @@ public function get_question_properties($sSessionKey, $iQuestionID, $aQuestionSe
$aData[$oAttribute['code']]['order'] = $oAttribute['sortorder'];
}
$aResult['answeroptions'] = $aData;
} else {
$aResult['answeroptions'] = 'No available answer options';
}
} else if ($sPropertyName == 'answeroptions_multiscale') {
$oAttributes = Answer::model()->findAllByAttributes(array('qid' => $iQuestionID, 'language'=> $sLanguage), array('order'=>'sortorder'));
if (count($oAttributes) > 0) {
$aData = array();
foreach ($oAttributes as $oAttribute) {
$aData[$oAttribute['scale_id']][$oAttribute['code']]['code'] = $oAttribute['code'];
$aData[$oAttribute['scale_id']][$oAttribute['code']]['answer'] = $oAttribute['answer'];
$aData[$oAttribute['scale_id']][$oAttribute['code']]['assessment_value'] = $oAttribute['assessment_value'];
$aData[$oAttribute['scale_id']][$oAttribute['code']]['scale_id'] = $oAttribute['scale_id'];
$aData[$oAttribute['scale_id']][$oAttribute['code']]['order'] = $oAttribute['sortorder'];
}
$aResult['answeroptions'] = $aData;
} else {
$aResult['answeroptions'] = 'No available answer options';
}
Expand Down

0 comments on commit 4931bb6

Please sign in to comment.