disable multiple_dropdowns_question selects when not editable
fixes CNVS-14719 test plan: - Create a quiz with a multiple-dropdowns-question. - Navigate to take the quiz. - Observe that the dropdowns work as expected. - Complete the quiz with a student. - Observe the completed quiz screen. - Observe that there are no dropdowns in the question text. - Observe that the selected answers are just treated as plaintext when interacted with via VoiceOver, NVDA & JAWS. Change-Id: I9506f064417eae85c084a15c416974d4f00568ee Reviewed-on: https://gerrit.instructure.com/70156 Tested-by: Jenkins Reviewed-by: Matt Berns <mberns@instructure.com> QA-Review: Michael Hargiss <mhargiss@instructure.com> Product-Review: Nathan Rogowski <nathan@instructure.com>
This commit is contained in:
parent
f245e74ba6
commit
ee15911543
|
@ -451,6 +451,7 @@ module QuizzesHelper
|
|||
question = hash_get(options, :question)
|
||||
answers = hash_get(options, :answers)
|
||||
answer_list = hash_get(options, :answer_list)
|
||||
editable = hash_get(options, :editable)
|
||||
res = user_content hash_get(question, :question_text)
|
||||
index = 0
|
||||
doc = Nokogiri::HTML.fragment(res)
|
||||
|
@ -464,9 +465,18 @@ module QuizzesHelper
|
|||
a = hash_get(answers, question_id)
|
||||
end
|
||||
|
||||
# If existing answer is one of the options, select it
|
||||
if opt_tag = s.children.css("option[value='#{a}']").first
|
||||
opt_tag["selected"] = "selected"
|
||||
if editable
|
||||
# If existing answer is one of the options, select it
|
||||
if (opt_tag = s.children.css("option[value='#{a}']").first)
|
||||
opt_tag["selected"] = "selected"
|
||||
end
|
||||
else
|
||||
# If existing answer is one of the options, replace it with a span
|
||||
if (opt_tag = s.children.css("option[value='#{a}']").first)
|
||||
s.replace(<<-HTML)
|
||||
<span>#{opt_tag.content}</span>
|
||||
HTML
|
||||
end
|
||||
end
|
||||
end
|
||||
doc.to_s.html_safe
|
||||
|
|
|
@ -153,7 +153,9 @@
|
|||
variables.each {|var| answer_list << hash_get(user_answer, "answer_id_for_#{var}") }
|
||||
end
|
||||
%>
|
||||
<%= multiple_dropdowns_question :question => question, :answers => @stored_params, :answer_list => answer_list %>
|
||||
<%= multiple_dropdowns_question({
|
||||
:question => question, :answers => @stored_params, :answer_list => answer_list, :editable => assessing
|
||||
}) %>
|
||||
<% else %>
|
||||
<%= user_content(hash_get(question, :question_text)) %>
|
||||
<% end %>
|
||||
|
|
|
@ -253,18 +253,42 @@ describe QuizzesHelper do
|
|||
end
|
||||
|
||||
it "should select the user's answer" do
|
||||
html = multiple_dropdowns_question(question: { question_text: 'some <select class="question_input" name="question_4"><option value="val">val</option></select>'},
|
||||
answer_list: ['val'])
|
||||
html = multiple_dropdowns_question({
|
||||
question: {
|
||||
question_text: 'some <select class="question_input" name="question_4"><option value="val">val</option></select>'
|
||||
},
|
||||
answer_list: ['val'],
|
||||
editable: true
|
||||
})
|
||||
expect(html).to eq 'some <select class="question_input" name="question_4"><option value="val" selected>val</option></select>'
|
||||
expect(html).to be_html_safe
|
||||
end
|
||||
|
||||
it "should not blow up if the user's answer isn't there" do
|
||||
html = multiple_dropdowns_question(question: { question_text: 'some <select class="question_input" name="question_4"><option value="other_val">val</option></select>'},
|
||||
answer_list: ['val'])
|
||||
html = multiple_dropdowns_question({
|
||||
question: {
|
||||
question_text: 'some <select class="question_input" name="question_4"><option value="other_val">val</option></select>'
|
||||
},
|
||||
answer_list: ['val'],
|
||||
editable: true
|
||||
})
|
||||
expect(html).to eq 'some <select class="question_input" name="question_4"><option value="other_val">val</option></select>'
|
||||
expect(html).to be_html_safe
|
||||
end
|
||||
|
||||
it "should disable select boxes that are not editable" do
|
||||
html_string = multiple_dropdowns_question({
|
||||
question: {
|
||||
question_text: 'some <select class="question_input" name="question_4"><option value="val">val</option></select>'
|
||||
},
|
||||
answer_list: ['val'],
|
||||
editable: false
|
||||
})
|
||||
html = Nokogiri::HTML.fragment(html_string)
|
||||
span_html = html.css('span').first
|
||||
expect(span_html).not_to be_nil
|
||||
expect(html_string).to be_html_safe
|
||||
end
|
||||
end
|
||||
|
||||
describe "#quiz_edit_text" do
|
||||
|
|
Loading…
Reference in New Issue