Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alter multiple choice questions to include "select XX answers" #711

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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