fix assignment status in 'Coming Up' sidebar. fixes #6783
submitted assignments weren't having their status consistently updated because the partial depended on the @current_user_submissions variable that wasn't being set in every view. fixed this by adding an extra conditional to the view (eek!). also included a fix to ensure that the correct context is always used when checking permissions (the page context isn't always the context of the 'Coming Up' item). test plan: * create a course with an assignment due tomorrow; * as student of that course, log in and submit the assignment; * verify that the assignment shows as submitted on both the user dashboard and the course home page. * click around the app and ensure that the sidebar works as expected. Change-Id: If1b955cd4e49c3c83cae9c92a0f3c515e8d3c2d3 Reviewed-on: https://gerrit.instructure.com/8633 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Ryan Florence <ryanf@instructure.com>
This commit is contained in:
parent
cf82013c41
commit
6695c4e935
|
@ -29,6 +29,11 @@ module CoursesHelper
|
|||
return
|
||||
end
|
||||
|
||||
# because this happens in a sidebar, the context may be wrong. check and fix
|
||||
# it if that's the case.
|
||||
context = context.class == recent_event.class && context.id == recent_event.context_id ?
|
||||
context : recent_event.context
|
||||
|
||||
icon_data = [nil, 'icon-grading-gray']
|
||||
if can_do(context, current_user, :participate_as_student)
|
||||
icon_data = submission && submission.submitted_or_graded? ? [submission.readable_state, 'icon-grading'] : [t('#courses.recent_event.not_submitted', 'not submitted'), "icon-grading-gray"]
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<%
|
||||
show_context ||= false; upcoming ||= false
|
||||
submissions ||= @current_user_submissions || []
|
||||
submission = nil
|
||||
submission = submissions.detect{|s| s.assignment_id == recent_event.id} if recent_event.is_a?(Assignment)
|
||||
|
||||
if recent_event.is_a?(Assignment)
|
||||
submission = @current_user_submissions.nil? ?
|
||||
@current_user.submissions.scoped(:select => 'id, assignment_id, score, workflow_state', :conditions => { :assignment_id => recent_event.id }).first :
|
||||
@current_user_submissions.detect { |s| s.assignment_id == recent_event.id }
|
||||
end
|
||||
|
||||
cache(['recent_event_render', submission || 'no_submission', recent_event || 'blank_event', Time.zone.utc_offset, recent_event.cached_context_grants_right?(@current_user, nil, :manage_grades), recent_event.cached_context_grants_right?(@current_user, nil, :participate_as_student)].cache_key) do
|
||||
set_icon_data(:context => @context, :contexts => @contexts, :current_user => @current_user, :recent_event => recent_event, :submission => submission)
|
||||
%>
|
||||
|
|
|
@ -44,8 +44,7 @@ describe "/courses/_recent_event" do
|
|||
@quiz_submission.grade_submission
|
||||
|
||||
@submission = @quiz_submission.submission
|
||||
@submission.score = 1234567890987654400 # long magic number that should be distinct in the partial for the test
|
||||
@submission.save
|
||||
Submission.any_instance.stubs(:score).returns(1234567890987654400)
|
||||
end
|
||||
|
||||
it "should show the score for a non-muted assignment" do
|
||||
|
@ -61,4 +60,4 @@ describe "/courses/_recent_event" do
|
|||
end
|
||||
end
|
||||
|
||||
# Sidebar content
|
||||
# Sidebar content
|
||||
|
|
Loading…
Reference in New Issue