I had to make a change to the submissions API to allow it to show final computed grades, including grades for muted assignments. I'd love to see this merged into the trunk. Thanks.
Add computed_final_score_with_muted field to submissions API
These changes don't work with the latest code, but I would still like to see this as a feature.
I think the change that broke your commit might also solve your problem (or hopefully get you most of the way there). The gradebook CSV now includes muted assignments (see https://github.com/instructure/canvas-lms/blob/stable/app/models/course.rb#L1439). You could just grab the csv or pass the :ignore_muted option to GradeCalculator. We don't currently save the ignore_muted value to the database.
Oh, one other note on the proposed API change: the grade including muted assignments should get filtered out for students (otherwise they would be able to infer the grade on the muted assignment the computed_final_score_with_muted grade change).
Thanks Cameron. Can you give me a sense of how I can filter this out for students?
If anyone else is interested, here are the changes I needed to make to get it working.
lib/grade_calculator.rb, line 63, just after def save_scores:
def final_score_with_muted(user_id, submissions)
@ignore_muted = false
group_sums = create_group_sums(submissions, false)
app/model/enrollment.rb, line 779, after computed_final_grade:
user_ids = [user_id]
submissions = course.submissions.for_user(user_id).to_a
calc = GradeCalculator.new(user_ids, course_id)
app/controllers/submissions_api_controller.rb, line 132, in def for_students:
if includes.include?('total_scores') && params[:grouped].present?
:computed_final_score => enrollment.computed_final_score,
:computed_final_score_with_muted => enrollment.computed_final_score_with_muted,
:computed_current_score => enrollment.computed_current_score)
Hey Christopher, our api_json stuff calls filter_attributes_for_user on the model if it is defined. See https://github.com/instructure/canvas-lms/blob/stable/app/models/submission.rb#L1130 for an example of how it is used.
In this case, the api change I made is in SubmissionsApiController#for_students, which seems to required permission to view / manage grades:
if authorized_action(@context, @current_user, [:manage_grades, :view_all_grades])
So student access to this shouldn't be a problem, right?
Sorry you're right Christopher. You shouldn't have any issues.