Skip to content

Commit

Permalink
Upadte getRows
Browse files Browse the repository at this point in the history
Set the id of the array of questions the id of each question
  • Loading branch information
agraciakuvut committed Sep 12, 2017
1 parent edb9f94 commit bdb9855
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/typeform/Typeform.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ protected function getHeaders()
foreach ($this->getQuestions() as $id => $question) {
$headers[$id] = $question;
}
$headers[] = 'score';
$headers['score'] = 'score';

return array_map('utf8_decode', $headers);
}
Expand All @@ -544,24 +544,19 @@ protected function getRows()
$rows = [];
foreach ($this->getResponses() as $response) {

$hash = '';
$fields = [];
foreach ($this->getQuestions() as $question_id => $question_name) {
$rr = '';
if (isset($response['answers'][$question_id])) {
$rr = $response['answers'][$question_id];
} elseif (isset($response['hidden'][$question_name])) {
$rr = $response['hidden'][$question_name];
if ($question_name == 'hash') {
$hash = $rr;
}

}
$fields[] = $rr;

$fields[$question_id] = $rr;
}

$fields[] = isset($response['answers']['score']) ? $response['answers']['score'] : 0;
$fields[] = $hash;
$fields['score'] = isset($response['answers']['score']) ? $response['answers']['score'] : 0;
//$rows[] = array_map('utf8_decode', $fields);
$rows[] = $fields;
}
Expand Down

0 comments on commit bdb9855

Please sign in to comment.