Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/controllers/assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@ def show
else
@cud
end
@attachments = if @cud.instructor?
@course.attachments
Comment thread
damianhxy marked this conversation as resolved.
Outdated
else
@course.attachments.where(released: true)
end
@submissions = @assessment.submissions.where(course_user_datum_id: @effectiveCud.id)
.order("version DESC")
@extension = @assessment.extensions.find_by(course_user_datum_id: @effectiveCud.id)
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/attachments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@ def show
flash[:error] = "Error loading #{@attachment.name} from #{@attachment.filename}"
redirect_to([@course, :attachments]) && return
end
# Set to application/octet-stream to force download
send_file(filename, disposition: "inline",
type: "application/octet-stream", filename: @attachment.filename) && return
if @cud.instructor? || @attachment.released?
# Set to application/octet-stream to force download
send_file(filename, disposition: "inline",
type: "application/octet-stream",
filename: @attachment.filename) && return
end

flash[:error] = "You are unauthorized to view this attachment"
redirect_to([@course, @assessment])
end

action_auth_level :edit, :instructor
Expand Down
2 changes: 1 addition & 1 deletion app/views/assessments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<% if @assessment.attachments.length > 0 or @cud.instructor? %>
<h2>Handouts</h2>
<ul class="collection with-header attachments">
<%= render @assessment.attachments %>
<%= render @attachments %>

<% # this code is temporarily "commented out" because Dan wants to preserve the logic for future changes to _attachment.html.erb %>
<% if false then %>
Expand Down