Element_OphCoTherapyapplication_PatientSuitability::calculateAnswers PHP Method

calculateAnswers() public method

traverse the given tree and answers to construct list of questions and answers.
public calculateAnswers ( $treeData, $answers, null $parent = null, array $textAnswers = [] ) : array
$treeData
$answers
$parent null
$textAnswers array
return array
    public function calculateAnswers($treeData, $answers, $parent = null, $textAnswers = array())
    {
        foreach ($treeData[$parent] as $node) {
            if (isset($answers[$node->id])) {
                $textAnswers[$node->question] = $node->response_type->getDisplayValueforResponse($answers[$node->id]);
            }
            if (isset($treeData[$node->id])) {
                $textAnswers = $this->calculateAnswers($treeData, $answers, $node->id, $textAnswers);
            }
        }
        return $textAnswers;
    }