Skip to content

Commit

Permalink
fix: proper ordering of closed question answers in form responses (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellen-Wittingen authored May 20, 2022
1 parent bf50bdb commit fca9816
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/form/responses-table-totals.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{#if question.isOpenQuestion}}
<strong>{{question.sumOfAnswers}}</strong>
{{else}}
{{#each question.options as |opt|}}
{{#each question.sortedOptions as |opt|}}
<strong>{{opt.sumOfAnswers}}</strong>
{{opt.option}}<br />
{{/each}}
Expand Down
5 changes: 5 additions & 0 deletions app/models/form/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export default class Response extends DirtySaveModel {
await this.closedQuestionAnswers
).map((closedQuestionAnswer) => closedQuestionAnswer.option)
);
answers.sort((answer1, answer2) =>
answer1.option && answer2.option
? answer1.option.get('position') - answer2.option.get('position')
: 0
);
return answers;
})
.then(this.groupAnswers);
Expand Down

0 comments on commit fca9816

Please sign in to comment.