remove student visibility of comments when assignment is muted

Previously, when an assignment was muted, teacher comments
were hidden from the student inconsistenly in a few pages.
The commments were hidden in the submission details page,
but not from the student grades page or the assignment
show page sidebar. Added logic to to the erb templates
so that the muted status of the assignment is being
checked first before displaying comments.

fixes CNVS-20047

Test Plan:
1. create an assignment and mute it
2. as the instructor add a submission comment in speedgrader
3. unmute the assignment
4. go back in and re-mute the assignment
5. As a student, go to the assignment show page
(/courses/x/assignments/y) and verify no comments
are visible in the sidebar, but rather, there is a
message about "You may not see all comments...."
6. Also go to the 'Grades' page (/courses/x/grades)
and verify no comments are visible for the muted assignment.
7. Also go to the submission details page (click on the name
of the assignmet in the 'Grades' page to go there) and
verify no comments are visible. Rather, there is a message
about "You may not see all comments...."
8. Unmute the assignment and make sure that the comments
show up in the pages from steps 5 - 7.
9. Click the 'Show All Details' button and make sure that
comments/rubrics for muted assignments do not show up.

Change-Id: Iba22ced513bdd6ba5aa3a1b939675c90b45fcb7c
Reviewed-on: https://gerrit.instructure.com/68210
Reviewed-by: Spencer Olson <solson@instructure.com>
Tested-by: Jenkins
QA-Review: Jason Carter <jcarter@instructure.com>
Product-Review: Christi Wruck
This commit is contained in:
Amber Taniuchi 2015-12-02 15:31:42 -07:00
parent cd181be362
commit 8c33ee4caa
5 changed files with 102 additions and 24 deletions

View File

@ -87,27 +87,31 @@
<% end %>
<div class="comments module">
<h4><%= t 'titles.comments', "Comments:" %> </h4>
<% if @assignment.muted? %>
<p><%= t 'You may not see all comments right now because the assignment is currently being graded.' %></p>
<% else %>
<h4><%= t 'titles.comments', "Comments:" %> </h4>
<% visible_comments = @current_user_submission.visible_submission_comments -%>
<%= t('messages.no_comments', "No Comments") if visible_comments.empty? %>
<% visible_comments.each do |comment| %>
<div id="comment-<%= comment.id %>" class="comment">
<%= comment.comment %>
<div class="comment_attachments">
<% comment.attachments.each do |attachment| %>
<div class="comment_attachment">
<a href="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, @current_user_submission.user_id, :comment_id => comment.id, :download => attachment.id) %>" class="comment_attachment_link <%= attachment.mime_class %>"><%= attachment.display_name %></a>
</div>
<% end %>
<% visible_comments = @current_user_submission.visible_submission_comments -%>
<%= t('messages.no_comments', "No Comments") if visible_comments.empty? %>
<% visible_comments.each do |comment| %>
<div id="comment-<%= comment.id %>" class="comment">
<%= comment.comment %>
<div class="comment_attachments">
<% comment.attachments.each do |attachment| %>
<div class="comment_attachment">
<a href="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, @current_user_submission.user_id, :comment_id => comment.id, :download => attachment.id) %>" class="comment_attachment_link <%= attachment.mime_class %>"><%= attachment.display_name %></a>
</div>
<% end %>
</div>
<div class="signature" style="font-size: 0.8em; text-align: right; color: #888;">
<%= t :comment_signature, "%{author}, %{created_at}", {
:author => comment_author_name_for(comment),
:created_at => datetime_string(comment.created_at)
} %>
</div>
</div>
<div class="signature" style="font-size: 0.8em; text-align: right; color: #888;">
<%= t :comment_signature, "%{author}, %{created_at}", {
:author => comment_author_name_for(comment),
:created_at => datetime_string(comment.created_at)
} %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>

View File

@ -233,7 +233,7 @@
<td class="possible points_possible" <%= "colspan='2'".html_safe if assignment.special_class %>><%= assignment.points_possible %></td>
<% if !assignment.special_class %>
<td class="details">
<a href="#" class="toggle_comments_link tooltip" aria-label="<%= t(:comment_count_screenreader, 'Read comments') %>" <% if assignment_presenter.has_comments? %>aria-expanded="false" aria-controls="comments_thread_<%= assignment.id %>"<% else %>aria-hidden='true' role='presentation' tabindex='-1'<% end %> style="<%= 'visibility: hidden;' unless assignment_presenter.has_comments? %>">
<a href="#" class="toggle_comments_link tooltip" aria-label="<%= t(:comment_count_screenreader, 'Read comments') %>" <% if assignment_presenter.has_comments? && !assignment_presenter.assignment.muted? %>aria-expanded="false" aria-controls="comments_thread_<%= assignment.id %>"<% else %>aria-hidden='true' role='presentation' tabindex='-1'<% end %> style="<%= 'visibility: hidden;' unless assignment_presenter.has_comments? && !assignment_presenter.assignment.muted? %>">
<span class="tooltip_wrap right">
<span class="tooltip_text"><%= t(:comment_count, "comment", :count => (submission.visible_submission_comments.size rescue 0)) %></span>
</span>

View File

@ -352,15 +352,21 @@ define([
if ($button.hasClass('showAll')) {
$button.text(I18n.t('hide_all_details_button', 'Hide All Details'));
$("tr.rubric_assessments").show();
$("tr.comments").show();
$("tr.student_assignment.editable").each(function(assignment) {
var assignmentId = $(this).getTemplateValue('assignment_id');
var muted = $(this).data('muted');
if (!muted) {
$('#comments_thread_' + assignmentId).show();
$('#rubric_' + assignmentId).show();
$('#grade_info_' + assignmentId).show();
}
});
} else {
$button.text(I18n.t('show_all_details_button', 'Show All Details'));
$("tr.rubric_assessments").hide();
$("tr.comments").hide();
}
});
});
function updateScoreForAssignment(assignmentId, score) {

View File

@ -56,7 +56,7 @@ describe "assignments" do
get "/courses/#{@course.id}/assignments/#{assignment.id}"
details = f(".details")
expect(details).to include_text('comment before muting')
expect(details).not_to include_text('comment before muting')
expect(details).not_to include_text('comment after muting')
end

View File

@ -135,5 +135,73 @@ describe 'Student Gradebook' do
f('#only_consider_graded_assignments').click
expect(f('.final_grade .grade').text).to eq '66.67%'
end
context 'Comments' do
# create a course, publish and enroll teacher and student
let(:test_course) { course() }
let(:teacher) { user(active_all: true) }
let(:student) { user(active_all: true) }
let!(:published_course) do
test_course.workflow_state = 'available'
test_course.save!
test_course
end
let!(:enroll_teacher_and_students) do
published_course.enroll_teacher(teacher).accept!
published_course.enroll_student(student, enrollment_state: 'active')
end
# create an assignment and submit as a student
let(:assignment) do
published_course.assignments.create!(
title: 'Assignment Yay',
grading_type: 'points',
points_possible: 10,
submission_types: 'online_upload'
)
end
let(:file_attachment) { attachment_model(:content_type => 'application/pdf', :context => student) }
let!(:student_submission) do
assignment.submit_homework(
student,
submission_type: 'online_upload',
attachments: [file_attachment]
)
end
# leave a comment as a teacher
let!(:teacher_comment) { student_submission.submission_comments.create!(comment: 'good job')}
it 'should display comments from a teacher on student grades page', priority: "1", test_id: 537621 do
user_session(student)
get "/courses/#{published_course.id}/grades"
fj('.toggle_comments_link .icon-discussion:first').click
expect(fj('.score_details_table span:first')).to include_text('good job')
end
it 'should not display comments from a teacher on student grades page if assignment is muted', priority: "1", test_id: 537620 do
assignment.muted = true
assignment.save!
user_session(student)
get "/courses/#{published_course.id}/grades"
expect(fj('.score_details_table span:first')).not_to include_text('good job')
end
it 'should display comments from a teacher on assignment show page if assignment is muted', priority: "1", test_id: 537868 do
user_session(student)
get "/courses/#{published_course.id}/assignments/#{assignment.id}"
expect(fj('.comments.module .comment:first')).to include_text('good job')
end
it 'should not display comments from a teacher on assignment show page if assignment is muted', priority: "1", test_id: 537867 do
assignment.muted = true
assignment.save!
user_session(student)
get "/courses/#{published_course.id}/assignments/#{assignment.id}"
expect(fj('.comments.module p')).to include_text('You may not see all comments right now because the assignment is currently being graded.')
end
end
end