don't send "needs grading" notification for graded surveys
test plan: - As a teacher, create a graded survey with an essay question. - As a student, take the graded survey. - As the teacher: - You should not receive a notification that the submission needs grading - You should not see the survey in your todos list on the course home page. - When you view the quiz submission in speedgrader, you should see the full points possible for that question in the input on the question header box, instead of '--'. fixes CNVS-1786 Change-Id: I658c0bc94d54be8449830412fd2da28884e98b4c Reviewed-on: https://gerrit.instructure.com/25593 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Ahmad Amireh <ahmad@instructure.com> QA-Review: Myller de Araujo <myller@instructure.com> Reviewed-by: Derek DeVries <ddevries@instructure.com> Product-Review: Stanley Stuart <stanley@instructure.com>
This commit is contained in:
parent
335afba106
commit
38f6fdb9de
|
@ -565,4 +565,15 @@ module QuizzesHelper
|
|||
!quiz.grants_right?(user, nil, :grade)
|
||||
end
|
||||
end
|
||||
|
||||
def point_value_for_input(user_answer, question)
|
||||
return user_answer[:points] unless user_answer[:correct] == 'undefined'
|
||||
|
||||
if ["assignment", "practice_quiz"].include?(@quiz.quiz_type)
|
||||
"--"
|
||||
else
|
||||
question[:points_possible] || 0
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -19,7 +19,9 @@ module BroadcastPolicies
|
|||
end
|
||||
|
||||
def should_dispatch_submission_needs_grading?
|
||||
quiz_is_accepting_messages? && quiz_submission.pending_review?
|
||||
!quiz.survey? &&
|
||||
quiz_is_accepting_messages? &&
|
||||
quiz_submission.pending_review?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -487,7 +487,9 @@ class QuizSubmission < ActiveRecord::Base
|
|||
self.submission_data = @user_answers
|
||||
self.workflow_state = "complete"
|
||||
@user_answers.each do |answer|
|
||||
self.workflow_state = "pending_review" if answer[:correct] == "undefined"
|
||||
if answer[:correct] == "undefined" && !quiz.survey?
|
||||
self.workflow_state = 'pending_review'
|
||||
end
|
||||
end
|
||||
self.score_before_regrade = nil
|
||||
self.finished_at = Time.now
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<% if user_answer && display_correct_answers %>
|
||||
<div class="user_points" <%= hidden(true) if (assessing || assessment_results) && question_type && question_type.entry_type == "none" %>>
|
||||
<% if editable %>
|
||||
<input type="text" class="question_input" name="question_score_<%= hash_get(question, :id) %>" value="<%= hash_get(user_answer, :correct) == "undefined" ? "--" : hash_get(user_answer, :points) %>" autocomplete='off'/>
|
||||
<input type="text" class="question_input" name="question_score_<%= hash_get(question, :id) %>" value="<%= point_value_for_input(user_answer, question) %>" autocomplete='off'/>
|
||||
<% else %>
|
||||
<% if hash_get(user_answer, :correct) == "undefined" %>
|
||||
<%= t(:not_yet_graded, 'Not yet graded') %>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<tr style="<%= hidden if @quiz.quiz_type == 'survey' %>">
|
||||
<td colspan="2" class="footnote">
|
||||
*
|
||||
<% if can_do(@quiz, @current_user, :grade) %>
|
||||
<% if can_do(@quiz, @current_user, :grade) && !@quiz.survey? %>
|
||||
<%= link_to t(:questions_not_graded, 'Some questions not yet graded'), context_url(@context, :context_quiz_history_url, @quiz, :version => @submission.version_number, :user_id => @submission.user_id) %>
|
||||
<% else %>
|
||||
<%= t(:questions_not_graded, 'Some questions not yet graded') %>
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
<% if (@current_submission || @submission).try(:pending_review?) %>
|
||||
*
|
||||
<div class='question-not-graded-text'>
|
||||
<% if can_do(@quiz, @current_user, :grade) %>
|
||||
<% if can_do(@quiz, @current_user, :grade) && !@quiz.survey? %>
|
||||
<%= link_to t(:questions_not_graded, 'Some questions not yet graded'), context_url(@context, :context_quiz_history_url, @quiz, :version => @submission.version_number, :user_id => @submission.user_id) %>
|
||||
<% else %>
|
||||
<% elsif !@quiz.survey? %>
|
||||
<%= t(:questions_not_graded, 'Some questions not yet graded') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -87,9 +87,9 @@
|
|||
<% if @submission.pending_review? %>
|
||||
<div class='question-not-graded-text'>
|
||||
*
|
||||
<% if can_do(@quiz, @current_user, :grade) %>
|
||||
<% if can_do(@quiz, @current_user, :grade) && !@quiz.survey? %>
|
||||
<%= link_to t(:questions_not_graded, 'Some questions not yet graded'), context_url(@context, :context_quiz_history_url, @quiz, :version => @submission.version_number, :user_id => @submission.user_id) %>
|
||||
<% else %>
|
||||
<% elsif !@quiz.survey? %>
|
||||
<%= t(:questions_not_graded, 'Some questions not yet graded') %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
require 'lib/data_fixup/change_graded_survey_submissions_to_not_need_grading'
|
||||
class ChangeGradedSurveySubmissionsToNotNeedGrading < ActiveRecord::Migration
|
||||
tag :postdeploy
|
||||
def self.up
|
||||
DataFixup::ChangeGradedSurveySubmissionsToNotNeedGrading.
|
||||
send_later_if_production(:run)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,17 @@
|
|||
module DataFixup
|
||||
class ChangeGradedSurveySubmissionsToNotNeedGrading
|
||||
|
||||
def self.run
|
||||
Quiz.where("quizzes.quiz_type NOT IN ('practice_quiz', 'assignment')").active.find_ids_in_ranges do |first_id, last_id|
|
||||
subs = QuizSubmission.where(quiz_id: first_id..last_id).
|
||||
where(workflow_state: 'pending_review')
|
||||
|
||||
subs.update_all(workflow_state: 'complete')
|
||||
Submission.where(quiz_submission_id: subs,
|
||||
workflow_state: 'pending_review').
|
||||
update_all(workflow_state: 'graded')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -259,4 +259,37 @@ describe QuizzesHelper do
|
|||
message.should =~ /are available until/
|
||||
end
|
||||
end
|
||||
|
||||
context "#point_value_for_input" do
|
||||
let(:user_answer) { @user_answer }
|
||||
let(:question) { { points_possible: 5 } }
|
||||
let(:quiz) { @quiz }
|
||||
|
||||
before do
|
||||
@quiz = stub(quiz_type: 'graded_survey')
|
||||
@user_answer = { correct: 'undefined', points: 5 }
|
||||
end
|
||||
|
||||
it "returns user_answer[:points] if correct is true/false" do
|
||||
[true, false].each do |bool|
|
||||
user_answer[:correct] = bool
|
||||
point_value_for_input(user_answer, question).should == user_answer[:points]
|
||||
end
|
||||
end
|
||||
|
||||
it "returns -- if quiz is practice quiz or assignment" do
|
||||
['assignment', 'practice_quiz'].each do |quiz_type|
|
||||
@quiz.expects(:quiz_type).returns quiz_type
|
||||
point_value_for_input(user_answer, question).should == "--"
|
||||
end
|
||||
end
|
||||
|
||||
it "returns points possible for the question if (un)graded survey" do
|
||||
['survey', 'graded_survey'].each do |quiz_type|
|
||||
@quiz.expects(:quiz_type).returns quiz_type
|
||||
point_value_for_input(user_answer, question).should ==
|
||||
question[:points_possible]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
require 'spec_helper'
|
||||
require File.expand_path(File.dirname(__FILE__) +
|
||||
'/../../../lib/data_fixup/change_graded_survey_submissions_to_not_need_grading')
|
||||
|
||||
describe DataFixup::ChangeGradedSurveySubmissionsToNotNeedGrading do
|
||||
|
||||
subject do
|
||||
DataFixup::ChangeGradedSurveySubmissionsToNotNeedGrading
|
||||
end
|
||||
|
||||
it "changes graded survey submissions to complete workflow_state" do
|
||||
course_with_student(active_all: true)
|
||||
course_quiz(course: @course)
|
||||
|
||||
@quiz.quiz_type = 'graded_survey'
|
||||
@quiz.publish!
|
||||
|
||||
submission = @quiz.generate_submission(@student)
|
||||
submission.submission = submission.assignment.find_or_create_submission(@student.id)
|
||||
submission.grade_submission(grade: 15)
|
||||
submission.workflow_state = 'pending_review'
|
||||
submission.score = 10
|
||||
submission.save!
|
||||
|
||||
subject.run
|
||||
|
||||
submission.reload.should be_completed
|
||||
submission.submission.should be_graded
|
||||
|
||||
teacher_in_course(course: @course, active_all: true)
|
||||
@teacher.assignments_needing_grading.should_not include @quiz.assignment
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -18,6 +18,7 @@ module BroadcastPolicies
|
|||
q.stubs(:muted?).returns(false)
|
||||
q.stubs(:context).returns(course)
|
||||
q.stubs(:assignment).returns(assignment)
|
||||
q.stubs(:survey?).returns(false)
|
||||
end
|
||||
end
|
||||
let(:submission) do
|
||||
|
@ -85,6 +86,7 @@ module BroadcastPolicies
|
|||
policy.should_dispatch_submission_needs_grading?.should == true
|
||||
end
|
||||
specify { wont_send_when { quiz.stubs(:assignment).returns nil } }
|
||||
specify { wont_send_when { quiz.stubs(:survey?).returns true} }
|
||||
specify { wont_send_when { quiz.stubs(:muted?).returns true } }
|
||||
specify { wont_send_when { course.stubs(:available?).returns false} }
|
||||
specify { wont_send_when { quiz.stubs(:deleted?).returns true } }
|
||||
|
|
|
@ -1655,6 +1655,20 @@ describe QuizSubmission do
|
|||
|
||||
end
|
||||
|
||||
it "does not put a graded survey submission in teacher's todos" do
|
||||
questions = [
|
||||
{ question_data: { name: 'question 1', question_type: 'essay_question' } }
|
||||
]
|
||||
submission_data = { 'question_1' => 'Hello' }
|
||||
survey_with_submission(questions) { submission_data }
|
||||
teacher_in_course(course: @course, active_all: true)
|
||||
@quiz.update_attributes(points_possible: 15, quiz_type: 'graded_survey')
|
||||
@quiz_submission.reload.grade_submission
|
||||
|
||||
@quiz_submission.should be_completed
|
||||
@quiz_submission.submission.should be_graded
|
||||
@teacher.assignments_needing_grading.should_not include @quiz.assignment
|
||||
end
|
||||
|
||||
describe 'broadcast policy' do
|
||||
before do
|
||||
|
@ -1705,4 +1719,5 @@ describe QuizSubmission do
|
|||
@submission.reload.messages_sent.keys.should_not include 'Submission Needs Grading'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue