fix issue with regrades changing displayed points of questions within a group
fixes CNVS-10533 test plan: - as a teacher - create a quiz with a question group that has Pick: 1, Points: 25 - create a question within the group that has Points: 1 - as a student - take the quiz, get the answer correct - as a teacher - change the answer for the question, choose first regrade option - save the quiz - as a student - view your quiz results - point values should continue to show 25/25 points - poke around with points within a quiz group when regrading - poke around with regrading stuff in general to try and break point scoring Change-Id: Id5cacf44012d967a812e2208df0404c3d532f2c5 Reviewed-on: https://gerrit.instructure.com/29002 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jason Madsen <jmadsen@instructure.com> QA-Review: Caleb Guanzon <cguanzon@instructure.com> Product-Review: Derek DeVries <ddevries@instructure.com>
This commit is contained in:
parent
be4f66b08b
commit
ac13d2faa5
|
@ -52,7 +52,16 @@ class QuizRegrader::Submission
|
|||
id = question[:id]
|
||||
if submitted_answer_ids.include?(id)
|
||||
question.keep_if {|k, v| %w{id position published_at}.include?(k) }
|
||||
question.merge(question_regrades[id].question_data.to_hash)
|
||||
|
||||
quiz_question = question_regrades[id].quiz_question
|
||||
data = quiz_question.question_data
|
||||
group = quiz_question.quiz_group
|
||||
|
||||
if group && group.pick_count
|
||||
data[:points_possible] = group.question_points
|
||||
end
|
||||
|
||||
question.merge(data.to_hash)
|
||||
else
|
||||
question
|
||||
end
|
||||
|
|
|
@ -8,9 +8,13 @@ describe QuizRegrader::AttemptVersion do
|
|||
{1 => 'no_regrade', 2 => 'full_credit', 3 => 'current_correct_only' }
|
||||
end
|
||||
|
||||
let(:question_group) do
|
||||
stub(:pick_count => 1, :question_points => 25)
|
||||
end
|
||||
|
||||
let(:question_regrades) do
|
||||
1.upto(3).each_with_object({}) do |i, hash|
|
||||
hash[i] = stub(:quiz_question => stub(:id => i, :question_data => {:id => i}),
|
||||
hash[i] = stub(:quiz_question => stub(:id => i, :question_data => {:id => i}, :quiz_group => question_group),
|
||||
:question_data => {:id => i},
|
||||
:regrade_option => regrade_options[i])
|
||||
end
|
||||
|
@ -25,10 +29,13 @@ describe QuizRegrader::AttemptVersion do
|
|||
end
|
||||
|
||||
let(:submission) do
|
||||
stub(:score => 0,
|
||||
:quiz_data => quiz_data,
|
||||
:submission_data => submission_data,
|
||||
:write_attribute => {})
|
||||
stub(:score => 0,
|
||||
:score_before_regrade => 1,
|
||||
:quiz_data => quiz_data,
|
||||
:score= => nil,
|
||||
:score_before_regrade= => nil,
|
||||
:submission_data => submission_data,
|
||||
:write_attribute => {})
|
||||
end
|
||||
|
||||
let(:version) do
|
||||
|
@ -66,7 +73,7 @@ describe QuizRegrader::AttemptVersion do
|
|||
submission.expects(:score=).with(3)
|
||||
submission.expects(:score_before_regrade).returns nil
|
||||
submission.expects(:score_before_regrade=).with(0)
|
||||
submission.expects(:quiz_data=).with(question_regrades.map { |id, q| q.question_data })
|
||||
submission.expects(:quiz_data=)
|
||||
|
||||
version.expects(:model=)
|
||||
version.expects(:save!)
|
||||
|
|
|
@ -8,9 +8,13 @@ describe QuizRegrader::Submission do
|
|||
{1 => 'no_regrade', 2 => 'full_credit', 3 => 'current_correct_only' }
|
||||
end
|
||||
|
||||
let(:question_group) do
|
||||
stub(:pick_count => 1, :question_points => 25)
|
||||
end
|
||||
|
||||
let(:question_regrades) do
|
||||
1.upto(3).each_with_object({}) do |i, hash|
|
||||
hash[i] = stub(:quiz_question => stub(:id => i, :question_data => {:id => i}),
|
||||
hash[i] = stub(:quiz_question => stub(:id => i, :question_data => {:id => i}, :quiz_group => question_group),
|
||||
:question_data => {:id => i},
|
||||
:regrade_option => regrade_options[i])
|
||||
end
|
||||
|
@ -25,10 +29,13 @@ describe QuizRegrader::Submission do
|
|||
end
|
||||
|
||||
let(:submission) do
|
||||
stub(:score => 0,
|
||||
:quiz_data => quiz_data,
|
||||
:submission_data => submission_data,
|
||||
:write_attribute => {})
|
||||
stub(:score => 0,
|
||||
:score_before_regrade => 1,
|
||||
:quiz_data => quiz_data,
|
||||
:score= => nil,
|
||||
:score_before_regrade= => nil,
|
||||
:submission_data => submission_data,
|
||||
:write_attribute => {})
|
||||
end
|
||||
|
||||
let(:wrapper) do
|
||||
|
@ -64,11 +71,28 @@ describe QuizRegrader::Submission do
|
|||
submission.expects(:score=).with(3)
|
||||
submission.expects(:score_before_regrade).returns nil
|
||||
submission.expects(:score_before_regrade=).with(0)
|
||||
submission.expects(:quiz_data=).with(question_regrades.map { |id, q| q.question_data })
|
||||
submission.expects(:quiz_data=)
|
||||
submission.expects(:attempts => stub(:last_versions => []))
|
||||
|
||||
wrapper.regrade!
|
||||
end
|
||||
end
|
||||
|
||||
describe "#rescored_submission" do
|
||||
it "scores the submission based on the regraded answers" do
|
||||
params = question_regrades.map do |key, qr|
|
||||
{:id => key, :points_possible => question_group.question_points}
|
||||
end
|
||||
|
||||
submission.expects(:quiz_data=).with(params)
|
||||
|
||||
regrade_submission = QuizRegrader::Submission.new(
|
||||
:submission => submission,
|
||||
:question_regrades => question_regrades)
|
||||
|
||||
regrade_submission.expects(:answers_to_grade).returns []
|
||||
regrade_submission.rescored_submission
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue