fix rendering of multiple dropdowns question in rails 3
refs CNVS-13790 test plan: * create a quiz with a multiple drop downs question * preview it * it should render correctly Change-Id: I8a37e0e7b8eee545252343927f8697b659726de0 Reviewed-on: https://gerrit.instructure.com/37193 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Ahmad Amireh <ahmad@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
ff6fc8364b
commit
dce3460382
|
@ -441,7 +441,7 @@ module QuizzesHelper
|
|||
answer_list = hash_get(options, :answer_list)
|
||||
res = user_content hash_get(question, :question_text)
|
||||
index = 0
|
||||
res.gsub %r{<select.*?name=['"](question_.*?)['"].*?>.*?</select>} do |match|
|
||||
res.to_str.gsub %r{<select.*?name=['"](question_.*?)['"].*?>.*?</select>} do |match|
|
||||
if answer_list && !answer_list.empty?
|
||||
a = answer_list[index]
|
||||
index += 1
|
||||
|
@ -449,7 +449,7 @@ module QuizzesHelper
|
|||
a = hash_get(answers, $1)
|
||||
end
|
||||
match.sub(%r{(<option.*?value=['"]#{ERB::Util.h(a)}['"])}, '\\1 selected')
|
||||
end
|
||||
end.html_safe
|
||||
end
|
||||
|
||||
def duration_in_minutes(duration_seconds)
|
||||
|
|
|
@ -247,6 +247,19 @@ describe QuizzesHelper do
|
|||
end
|
||||
end
|
||||
|
||||
context "multiple_dropdowns_question" do
|
||||
before do
|
||||
def user_content(stuff); stuff; end # mock #user_content
|
||||
end
|
||||
|
||||
it "should select the user's answer" do
|
||||
html = multiple_dropdowns_question(question: { question_text: "some <select name='question_4'><option value='val'>val</option></select>"},
|
||||
answer_list: ['val'])
|
||||
html.should == "some <select name='question_4'><option value='val' selected>val</option></select>"
|
||||
html.should be_html_safe
|
||||
end
|
||||
end
|
||||
|
||||
describe "#quiz_edit_text" do
|
||||
|
||||
it "returns correct string for survey" do
|
||||
|
|
Loading…
Reference in New Issue