correctly show completion icons on peer review listings

Because of concerns with a potential race condition on using just the 
incomplete peer review count we've also added the total count of
assigned reviews to the cache key. These two additions still allow us
to take advantage of caching yielding a 90% performance improvement 
against a hot cache locally. These numbers may not translate perfectly
to production given that this page may have frequent cache misses. This
is something we should probably take a look at in the logs once this is
in beta/production.

fixes CNVS-7523

Test Plan:
- As an instructor build a class with at least 2 students
- Add an assignment to the class with peer review enabled
- Assign peer reviewers manually
  - These should start marked as incomplete with a yellow icon
- As the first student navigate to the assignment and submit it
- As the second student navigate to the assignment
  - In the sidebar this student should see that they have an incomplete
    review, indicated by the yellow icon
- Complete the review and view the assignment again
  - The review should indicate that it is complete with a green
    checkmark
- As the teacher view the peer assessments page
  - The review you previously completed should show as completed using
    the same green checkmark.

Change-Id: I8b71fd8f25c71b8031ab74b57d280c98add2c14e
Reviewed-on: https://gerrit.instructure.com/34420
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
Product-Review: Matt Fairbourn <mfairbourn@instructure.com>
This commit is contained in:
Tyler Pickett 2014-05-06 14:44:20 -05:00
parent 3956ceefb1
commit 01190e3e4a
3 changed files with 28 additions and 8 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (C) 2011 Instructure, Inc.
# Copyright (C) 2011 - 2014 Instructure, Inc.
#
# This file is part of Canvas.
#
@ -17,6 +17,17 @@
#
module AssignmentsHelper
PEER_REVIEW_LINK_OPTIONS = {
completed: {
class: 'pass',
title: I18n.t('tooltips.finished', 'finished'),
},
in_progress: {
class: 'warning',
title: I18n.t('tooltips.incomplete', 'incomplete'),
}
}
def multiple_due_dates(assignment)
# can use this method as the single source of rendering multiple due dates
# for now, just text, but eventually, a bubble/dialog/link/etc, rendering
@ -24,6 +35,11 @@ module AssignmentsHelper
I18n.t '#assignments.multiple_due_dates', 'Multiple Due Dates'
end
def student_peer_review_link_for(context, assignment, assessment)
link_options = assessment.completed? ? PEER_REVIEW_LINK_OPTIONS[:completed] : PEER_REVIEW_LINK_OPTIONS[:in_progress]
link_to assessment.asset_user_name, context_url(context, :context_assignment_submission_url, assignment.id, assessment.asset.user_id), link_options
end
def due_at(assignment, user, format='datetime')
if assignment.multiple_due_dates_apply_to?(user)
multiple_due_dates(assignment)

View File

@ -1,9 +1,9 @@
<% request = peer_review_assignment || nil %>
<li class="peer_review <%= request.try_rescue(:workflow_state) || 'assigned' %>" id="review_request_<%= request ? request.id : 'blank' %>" style="<%= hidden unless request %>">
<span style="float: left;">
<%= image_tag "pass.png", :alt => "finished", :title => "Finished" if request && request.completed? %>
<%= image_tag "warning_dim.png", :alt => "incomplete", :title => "Assessment not yet Completed" if request && !request.completed? %>
<%= image_tag "file.png" %>
<%= image_tag "pass.png", :alt => "finished", :title => "Finished" if request && request.completed? %>
<%= image_tag "warning_dim.png", :alt => "incomplete", :title => "Assessment not yet Completed" if (request && !request.completed?) || request.nil? %>
<%= image_tag "file.png" %>
<a href="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, request ? request.asset.user_id : '{{ user_id }}') %>">
<span class="asset_user_name"><%= request.try_rescue(:asset).try_rescue(:user).try_rescue(:last_name_first) || nbsp %></span>
</a>

View File

@ -1,4 +1,10 @@
<% cache(['submission_sidebar_render', @current_user_submission, Time.zone.utc_offset].cache_key) do %>
<% cache([
'submission_sidebar_render',
@current_user_submission,
Time.zone.utc_offset,
@current_user_submission.assigned_assessments.count,
@current_user_submission.assigned_assessments.incomplete.count
].cache_key) do %>
<div class="details">
<h3 style="margin: 0;"><%= t 'titles.submission', "Submission" %></h3>
<% if @assignment.expects_submission? %>
@ -45,9 +51,7 @@
<ul class="unstyled_list" style="margin: 5px 10px 10px;">
<li style="<%= hidden unless @current_user_submission.assigned_assessments.empty? %>"><%= t 'labels.none_assigned', "None Assigned" %></li>
<% @current_user_submission.assigned_assessments.each do |assessment| %>
<li><a <%= assessment.completed? ? "class='pass' title='#{h(t('tooltips.finished', "finished"))}'" : "class='warning' title='#{h(t('tooltips.incomplete', "incomplete"))}'" %> href="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, assessment.asset.user_id) %> ">
<%= assessment.asset_user_name %>
</a></li>
<li><%= student_peer_review_link_for @context, @assignment, assessment %></li>
<% end %>
</ul>
<% end %>