bump question_data size, limit possible combinations. fixes #4953

Change-Id: Ic716425680c2c50a0c960d391104fc5502d4fafd
Reviewed-on: https://gerrit.instructure.com/5282
Reviewed-by: Jacob Fugal <jacob@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
This commit is contained in:
Jon Jensen 2011-08-25 16:32:35 -06:00
parent 59c15dc864
commit 432283d3e7
4 changed files with 86 additions and 15 deletions

View File

@ -1,4 +1,11 @@
<% question_bank_id ||= "" %>
<% max_combinations = 200 %>
<% js_block do %>
<script>
var maxCombinations = <%= raw max_combinations %>;
</script>
<% end %>
<form id="question_form_template" class="question_form" style="display: none;">
<div class="question">
<div class="header" style="background-color: transparent;">
@ -138,7 +145,7 @@
</div>
</div>
<div class="equation_content variables_specified formulas_specified">
<%= t(:offer_combinations, "Offer %{how_many} possible value combinations", :how_many => raw('<input type="text" class="combination_count combinations_option" style="width: 30px;"/>')) %><br/>
<%= t(:offer_combinations, "Offer %{how_many} possible value combinations (max %{max_combinations})", :how_many => raw('<input type="text" class="combination_count combinations_option" style="width: 30px;"/>'), :max_combinations => max_combinations) %><br/>
<%= t(:allow_tolerance, "allow an error margin of +/- %{tolerance}", :tolerance => raw('<input type="text" class="combination_answer_tolerance float_value" style="width: 30px;" value="0"/>')) %>
<button type="button" class="compute_combinations combinations_option"><%= t('buttons.generate', "Generate") %></button>
</div>

View File

@ -0,0 +1,13 @@
class QuestionDataLength < ActiveRecord::Migration
def self.up
return unless adapter_name =~ /mysql/i # postgres/sqlite have no limit
change_column :quiz_questions, :question_data, :text, :limit => 2**20
change_column :assessment_questions, :question_data, :text, :limit => 2**20
end
def self.down
return unless adapter_name =~ /mysql/i
change_column :quiz_questions, :question_data, :text
change_column :assessment_questions, :question_data, :text
end
end

View File

@ -21,6 +21,7 @@ var wikiSidebar;
// take a little bit of work. I just wrapped it in a closure for now
// to not pollute the global namespace, but it could use more.
var quiz = {};
var maxCombinations;
I18n.scoped('quizzes', function(I18n) {
quiz = {
uniqueLocalIDStore: {},
@ -2425,6 +2426,12 @@ I18n.scoped('quizzes', function(I18n) {
$table.find("thead tr").append($th);
$table.find("tbody").empty();
var cnt = parseInt($question.find(".combination_count").val(), 10) || 10;
if (cnt < 0) {
cnt = 10;
} else if (cnt > maxCombinations) {
cnt = maxCombinations;
}
$question.find(".combination_count").val(cnt);
var succeeded = 0;
var existingCombinations = {};
var mod = 0;

View File

@ -71,11 +71,12 @@ shared_examples_for "quiz selenium tests" do
end
#### Multiple Choice Question
question_count = 1
points_total = 1
new_question_link.click
questions = find_all_with_jquery(".question_holder:visible")
questions.length.should eql(1)
questions.length.should eql(question_count)
question = questions[0]
question.
find_element(:css, 'select.question_type').
@ -100,10 +101,10 @@ shared_examples_for "quiz selenium tests" do
set_feedback_content(question.find_element(:css, "div.text .question_neutral_comment"), "Pass or fail, you're a winner!")
save_question_and_wait(question)
driver.find_element(:css, "#right-side .points_possible").text.should eql("1")
driver.find_element(:css, "#right-side .points_possible").text.should eql(points_total.to_s)
quiz.reload
quiz.quiz_questions.length.should == 1
quiz.quiz_questions.length.should == question_count
question_data = quiz.quiz_questions[0].question_data
question_data[:answers].length.should == 4
question_data[:answers][0][:text].should == "Correct Answer"
@ -123,15 +124,17 @@ shared_examples_for "quiz selenium tests" do
#### True False Question
new_question_link.click
question_count += 1
points_total += (points = 2)
questions = find_all_with_jquery(".question_holder:visible")
questions.length.should eql(2)
question = questions[1]
questions.length.should eql(question_count)
question = questions.last
question.
find_element(:css, 'select.question_type').
find_element(:css, 'option[value="true_false_question"]').click
replace_content(question.find_element(:css, "input[name='question_points']"), "2")
replace_content(question.find_element(:css, "input[name='question_points']"), points.to_s)
tiny_frame = wait_for_tiny(question.find_element(:css, 'textarea.question_content'))
in_frame tiny_frame["id"] do
@ -145,24 +148,26 @@ shared_examples_for "quiz selenium tests" do
answers[1].find_element(:css, ".answer_comments textarea").send_keys("Good job!")
save_question_and_wait(question)
driver.find_element(:css, "#right-side .points_possible").text.should eql("3")
driver.find_element(:css, "#right-side .points_possible").text.should eql(points_total.to_s)
quiz.reload
quiz.quiz_questions.length.should == 2
quiz.quiz_questions.length.should == question_count
#### Fill in the Blank Question
new_question_link.click
question_count += 1
points_total += (points = 1)
questions = find_all_with_jquery(".question_holder:visible")
questions.length.should eql(3)
question = questions[2]
questions.length.should eql(question_count)
question = questions.last
question.
find_element(:css, 'select.question_type').
find_element(:css, 'option[value="short_answer_question"]').click
replace_content(question.find_element(:css, "input[name='question_points']"), "1")
replace_content(question.find_element(:css, "input[name='question_points']"), points.to_s)
tiny_frame = wait_for_tiny(question.find_element(:css, 'textarea.question_content'))
in_frame tiny_frame["id"] do
@ -183,10 +188,10 @@ shared_examples_for "quiz selenium tests" do
replace_content(answers[1].find_element(:css, ".short_answer input"), "Blank")
save_question_and_wait(question)
driver.find_element(:css, "#right-side .points_possible").text.should eql("4")
driver.find_element(:css, "#right-side .points_possible").text.should eql(points_total.to_s)
quiz.reload
quiz.quiz_questions.length.should == 3
quiz.quiz_questions.length.should == question_count
#### Fill in Multiple Blanks
@ -201,6 +206,45 @@ shared_examples_for "quiz selenium tests" do
#### Formula Question
new_question_link.click
question_count += 1
points_total += (points = 1)
questions = find_all_with_jquery(".question_holder:visible")
questions.length.should eql(question_count)
question = questions.last
question.
find_element(:css, 'select.question_type').
find_element(:css, 'option[value="calculated_question"]').click
replace_content(question.find_element(:css, "input[name='question_points']"), points.to_s)
tiny_frame = wait_for_tiny(question.find_element(:css, 'textarea.question_content'))
in_frame tiny_frame["id"] do
driver.find_element(:id, 'tinymce').send_keys('If [x] + [y] is a whole number, then this is a formula question.')
end
find_with_jquery('button.recompute_variables').click
find_with_jquery('.supercalc:visible').send_keys('x + y')
find_with_jquery('button.save_formula_button').click
# normally it's capped at 200 (to keep the yaml from getting crazy big)...
# since selenium tests take forever, let's make the limit much lower
driver.execute_script("window.maxCombinations = 10")
find_with_jquery('.combination_count:visible').send_keys('20') # over the limit
button = find_with_jquery('button.compute_combinations:visible')
button.click
find_with_jquery('.combination_count:visible').attribute(:value).should eql "10"
keep_trying_until {
button.text == 'Generate'
}
find_all_with_jquery('table.combinations:visible tr').size.should eql 11 # plus header row
save_question_and_wait(question)
driver.find_element(:css, "#right-side .points_possible").text.should eql(points_total.to_s)
quiz.reload
quiz.quiz_questions.length.should == question_count
#### Missing Word
#### Essay Question