can edit survey questions after reload fixes #6157
test plan: 1. create a quiz 2. change it to a graded survey 3. save settings 4. create and save a question 5. refresh the page 6. edit the question 7. change an answer 8. save the question 9. observe no "you need to pick a correct answer" error bubble Change-Id: I09a49185b94823acd0003eb956dd56b1880eeb59 Reviewed-on: https://gerrit.instructure.com/8984 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Ryan Florence <ryanf@instructure.com>
This commit is contained in:
parent
143cb3f665
commit
8c61132bef
|
@ -1940,7 +1940,9 @@ define([
|
|||
error_text = I18n.t('errors.no_correct_answer', "Please choose a correct answer");
|
||||
}
|
||||
}
|
||||
if (error_text) {
|
||||
|
||||
var isNotSurvey = !$('#quiz_assignment_id').val().match(/survey/i);
|
||||
if (isNotSurvey && error_text) {
|
||||
$form.find(".answers_header").errorBox(error_text, true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -712,6 +712,10 @@ shared_examples_for "all selenium tests" do
|
|||
driver.execute_script "$('#{selector}').simulate('drag', { dx: #{x}, dy: #{y} })"
|
||||
end
|
||||
|
||||
def error_displayed?
|
||||
f('.error_text:visible') != nil
|
||||
end
|
||||
|
||||
self.use_transactional_fixtures = false
|
||||
|
||||
append_after(:each) do
|
||||
|
|
|
@ -79,7 +79,7 @@ shared_examples_for "quizzes selenium tests" do
|
|||
b = AssessmentQuestion.create!
|
||||
bank.assessment_questions << a
|
||||
bank.assessment_questions << b
|
||||
answers = {'answer_0' => {'id' => 1}, 'answer_1' => {'id' => 2}}
|
||||
answers = {'answer_0' => {'id' => 1}, 'answer_1' => {'id' => 2}, 'answer_2' => {'id' => 3}}
|
||||
@quest1 = @q.quiz_questions.create!(:question_data => {:name => "first question", 'question_type' => 'multiple_choice_question', 'answers' => answers, :points_possible => 1}, :assessment_question => a)
|
||||
@quest2 = @q.quiz_questions.create!(:question_data => {:name => "second question", 'question_type' => 'multiple_choice_question', 'answers' => answers, :points_possible => 1}, :assessment_question => b)
|
||||
|
||||
|
@ -105,11 +105,47 @@ shared_examples_for "quizzes selenium tests" do
|
|||
el.find_element(:css, "textarea").send_keys(text)
|
||||
end
|
||||
|
||||
def edit_first_question
|
||||
question = driver.find_element :css, '.display_question'
|
||||
def hover_first_question
|
||||
question = f '.display_question'
|
||||
driver.action.move_to(question).perform
|
||||
driver.find_element(:css, '.edit_question_link').click
|
||||
end
|
||||
|
||||
def edit_first_question
|
||||
hover_first_question
|
||||
f('.edit_question_link').click
|
||||
wait_for_animations
|
||||
end
|
||||
|
||||
def save_question
|
||||
f('.question_form:visible').submit
|
||||
wait_for_ajax_requests
|
||||
end
|
||||
|
||||
def change_quiz_type_to(option_text)
|
||||
click_option '#quiz_assignment_id', option_text
|
||||
end
|
||||
|
||||
def save_settings
|
||||
f('.save_quiz_button').click
|
||||
wait_for_ajax_requests
|
||||
end
|
||||
|
||||
def edit_first_multiple_choice_answer(text)
|
||||
element = f 'input[name=answer_text]:visible'
|
||||
element.click
|
||||
element.send_keys text
|
||||
end
|
||||
|
||||
def edit_and_save_first_multiple_choice_answer(text)
|
||||
edit_first_question
|
||||
edit_first_multiple_choice_answer text
|
||||
save_question
|
||||
end
|
||||
|
||||
def delete_first_multiple_choice_answer
|
||||
driver.execute_script "$('.answer').addClass('hover');"
|
||||
f('.delete_answer_link:visible').click
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -324,14 +324,14 @@ describe "quizzes question creation" do
|
|||
skip_if_ie 'Out of memory'
|
||||
quiz_with_new_questions
|
||||
edit_first_html_answer
|
||||
type_in_tiny '.answer:eq(2) textarea', 'HTML'
|
||||
type_in_tiny '.answer:eq(3) textarea', 'HTML'
|
||||
close_first_html_answer
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
find_with_jquery('.question_form:visible').submit
|
||||
refresh_page
|
||||
edit_first_question
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
end
|
||||
|
||||
|
@ -339,14 +339,14 @@ describe "quizzes question creation" do
|
|||
skip_if_ie 'Out of memory'
|
||||
quiz_with_new_questions
|
||||
edit_first_html_answer 'Multiple Answers'
|
||||
type_in_tiny '.answer:eq(2) textarea', 'HTML'
|
||||
type_in_tiny '.answer:eq(3) textarea', 'HTML'
|
||||
close_first_html_answer
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
find_with_jquery('.question_form:visible').submit
|
||||
refresh_page
|
||||
edit_first_question
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
end
|
||||
|
||||
|
@ -371,12 +371,12 @@ describe "quizzes question creation" do
|
|||
it "should restore normal input when html answer is empty" do
|
||||
quiz_with_new_questions
|
||||
edit_first_html_answer
|
||||
type_in_tiny '.answer:eq(2) textarea', 'HTML'
|
||||
type_in_tiny '.answer:eq(3) textarea', 'HTML'
|
||||
|
||||
# clear tiny
|
||||
driver.execute_script "$('.answer:eq(2) textarea')._setContentCode('')"
|
||||
driver.execute_script "$('.answer:eq(3) textarea')._setContentCode('')"
|
||||
close_first_html_answer
|
||||
input_length = driver.execute_script "return $('.answer:eq(2) input[name=answer_text]:visible').length"
|
||||
input_length = driver.execute_script "return $('.answer:eq(3) input[name=answer_text]:visible').length"
|
||||
input_length.should == 1
|
||||
end
|
||||
|
||||
|
@ -393,11 +393,11 @@ describe "quizzes question creation" do
|
|||
|
||||
# open it up in the editor, make sure the text matches the input
|
||||
edit_first_html_answer
|
||||
content = driver.execute_script "return $('.answer:eq(2) textarea')._justGetCode()"
|
||||
content = driver.execute_script "return $('.answer:eq(3) textarea')._justGetCode()"
|
||||
content.should == '<p>ohai</p>'
|
||||
|
||||
# clear it out, make sure the original input is empty also
|
||||
driver.execute_script "$('.answer:eq(2) textarea')._setContentCode('')"
|
||||
driver.execute_script "$('.answer:eq(3) textarea')._setContentCode('')"
|
||||
close_first_html_answer
|
||||
value = driver.execute_script "return $('input[name=answer_text]:visible')[0].value"
|
||||
value.should == ''
|
||||
|
@ -406,24 +406,52 @@ describe "quizzes question creation" do
|
|||
it "should save open html answers when the question is submitted for multiple choice" do
|
||||
quiz_with_new_questions
|
||||
edit_first_html_answer
|
||||
type_in_tiny '.answer:eq(2) textarea', 'HTML'
|
||||
type_in_tiny '.answer:eq(3) textarea', 'HTML'
|
||||
find_with_jquery('.question_form:visible').submit
|
||||
refresh_page
|
||||
edit_first_question
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
end
|
||||
|
||||
it "should save open html answers when the question is submitted for multiple answers" do
|
||||
quiz_with_new_questions
|
||||
edit_first_html_answer 'Multiple Answers'
|
||||
type_in_tiny '.answer:eq(2) textarea', 'HTML'
|
||||
type_in_tiny '.answer:eq(3) textarea', 'HTML'
|
||||
find_with_jquery('.question_form:visible').submit
|
||||
refresh_page
|
||||
edit_first_question
|
||||
html = driver.execute_script "return $('.answer:eq(2) .answer_html').html()"
|
||||
html = driver.execute_script "return $('.answer:eq(3) .answer_html').html()"
|
||||
html.should == '<p>HTML</p>'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "should show errors for graded quizzes but not surveys" do
|
||||
quiz_with_new_questions
|
||||
change_quiz_type_to 'Graded Survey'
|
||||
save_settings
|
||||
|
||||
edit_and_save_first_multiple_choice_answer 'instructure!'
|
||||
error_displayed?.should be_false
|
||||
|
||||
refresh_page
|
||||
edit_and_save_first_multiple_choice_answer 'yog!'
|
||||
error_displayed?.should be_false
|
||||
|
||||
change_quiz_type_to 'Graded Quiz'
|
||||
save_settings
|
||||
|
||||
edit_first_question
|
||||
delete_first_multiple_choice_answer
|
||||
save_question
|
||||
error_displayed?.should be_true
|
||||
|
||||
refresh_page
|
||||
edit_first_question
|
||||
delete_first_multiple_choice_answer
|
||||
save_question
|
||||
error_displayed?.should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue