don't count test users in speedgrader graded count
Returns a separate JSON element consisting solely of student with vanilla enrollments (not e.g. student_view_enrollments) so that any test students are excluded from grading counts. fixes CNVS-3471 Test plan: - Access an assignment whose class has a test student enrolled. - Go to SpeedGrader. - Note the values of the "x / y Graded" indicator at the upper right of the page. - Score the test user's assignment. - The "x / y Graded" values should not have changed. Change-Id: I244f4463023bcf385aa609ed04e5b387ede1def9 Reviewed-on: https://gerrit.instructure.com/33684 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Anna Koalenz <akoalenz@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
5091754e48
commit
83591f638e
|
@ -1193,6 +1193,8 @@ class Assignment < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
enrollments = context.enrollments_visible_to(user)
|
||||
|
||||
res[:context][:students] = students.map { |u|
|
||||
u.as_json(:include_root => false,
|
||||
:methods => avatar_methods,
|
||||
|
@ -1200,7 +1202,7 @@ class Assignment < ActiveRecord::Base
|
|||
}
|
||||
res[:context][:active_course_sections] = context.sections_visible_to(user).
|
||||
map{|s| s.as_json(:include_root => false, :only => [:id, :name]) }
|
||||
res[:context][:enrollments] = context.enrollments_visible_to(user).
|
||||
res[:context][:enrollments] = enrollments.
|
||||
map{|s| s.as_json(:include_root => false, :only => [:user_id, :course_section_id]) }
|
||||
res[:context][:quiz] = self.quiz.as_json(:include_root => false, :only => [:anonymous_submissions])
|
||||
|
||||
|
@ -1213,6 +1215,8 @@ class Assignment < ActiveRecord::Base
|
|||
res[:too_many_quiz_submissions] = too_many = too_many_qs_versions?(submissions)
|
||||
qs_versions = quiz_submission_versions(submissions, too_many)
|
||||
|
||||
enrollment_types_by_id = enrollments.inject({}){ |h, e| h[e.user_id] ||= e.type; h }
|
||||
|
||||
res[:submissions] = submissions.map do |sub|
|
||||
json = sub.as_json(:include_root => false,
|
||||
:include => {
|
||||
|
@ -1226,7 +1230,8 @@ class Assignment < ActiveRecord::Base
|
|||
},
|
||||
:methods => [:scribdable?, :scribd_doc, :submission_history, :late],
|
||||
:only => submission_fields
|
||||
)
|
||||
).merge("from_enrollment_type" => enrollment_types_by_id[sub.user_id])
|
||||
|
||||
json['submission_history'] = if json['submission_history'] && (quiz.nil? || too_many)
|
||||
json['submission_history'].map do |version|
|
||||
version.as_json(
|
||||
|
|
|
@ -1260,13 +1260,16 @@ define([
|
|||
})
|
||||
);
|
||||
|
||||
var gradedStudents = $.grep(jsonData.studentsWithSubmissions, function(s){
|
||||
return (s.submission && s.submission.workflow_state === 'graded');
|
||||
var gradedStudents = $.grep(jsonData.studentsWithSubmissions, function(s) {
|
||||
return (s.submission &&
|
||||
s.submission.workflow_state === 'graded' &&
|
||||
s.submission.from_enrollment_type === "StudentEnrollment"
|
||||
);
|
||||
});
|
||||
var scores = $.map(gradedStudents, function(s){
|
||||
|
||||
var scores = $.map(gradedStudents , function(s){
|
||||
return s.submission.score;
|
||||
});
|
||||
//scores shoud be an array that has all of the scores of the students that have submisisons
|
||||
|
||||
if (scores.length) { //if there are some submissions that have been graded.
|
||||
$average_score_wrapper.show();
|
||||
|
@ -1288,9 +1291,10 @@ define([
|
|||
else { //there are no submissions that have been graded.
|
||||
$average_score_wrapper.hide();
|
||||
}
|
||||
|
||||
$grded_so_far.html(
|
||||
I18n.t('portion_graded', '%{x} / %{y} Graded', {
|
||||
x: scores.length,
|
||||
x: gradedStudents.length,
|
||||
y: jsonData.context.students.length
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue