Skip to content

Commit

Permalink
Alter multiple choice questions to include "select XX answers"
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrett committed Jul 11, 2023
1 parent 1d71c94 commit 31e4537
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/models/training/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ def answer
@answer ||= Answer.new(json: json)
end

# @return [Integer]
def correct_answer_count
answer.correct_answers.count
end

# @return [Hash{Symbol => nil, Integer}]
def pagination
return super if formative_question?
Expand Down Expand Up @@ -83,7 +88,7 @@ def heading
# @return [String]
def legend
if multi_select?
"#{body} (Select all answers that apply)"
"#{body} (Select #{correct_answer_count} answers)"
elsif true_false?
<<~LEGEND
True or false?
Expand Down
2 changes: 1 addition & 1 deletion spec/cms/models/training/question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
end

specify do
expect(question.legend).to end_with '(Select all answers that apply)'
expect(question.legend).to end_with '(Select 2 answers)'
end
end

Expand Down

0 comments on commit 31e4537

Please sign in to comment.