Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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?
@assessment.attachments
else
@assessment.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/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<% if @attachments.any? %>
<div class="section">
<h3 class="section-title"><span class="white">Attachments</span></h3>
<ul class="attachments">
<ul class="collection with-header attachments">
<%= render @attachments %>
</ul>
</div>
Expand Down
50 changes: 26 additions & 24 deletions app/views/assessments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -175,34 +175,36 @@
<% download_access = (@cud.instructor?) %>

<%# Display any attachments %>
<% if @assessment.attachments.length > 0 or @cud.instructor? %>
<h2>Handouts</h2>
<ul class="collection with-header attachments">
<%= render @assessment.attachments %>

<% # this code is temporarily "commented out" because Dan wants to preserve the logic for future changes to _attachment.html.erb %>
<% if false then %>
<% for a in @assessment.attachments do %>
<% if a.released? then %>
<% if (Time.now() > @assessment.start_at) or (@cud.instructor?) then %>
<li><%= link_to a.name, [@course, @assessment, a] %></li>
<% else %>
<li><%= a.name %></li>
<% if @attachments.any? or @cud.instructor? %>
<div class="section">
<h3 class="section-title"><span class="white">Attachments</span></h3>
<ul class="collection with-header 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 %>
<% for a in @assessment.attachments do %>
<% if a.released? then %>
<% if (Time.now() > @assessment.start_at) or (@cud.instructor?) then %>
<li><%= link_to a.name, [@course, @assessment, a] %></li>
<% else %>
<li><%= a.name %></li>
<% end %>
<% elsif @cud.instructor? then %>
<li><i><%= link_to a.name, [@course, @assessment, a] %>*</i></li>
<% end %>
<% elsif @cud.instructor? then %>
<li><i><%= link_to a.name, [@course, @assessment, a] %>*</i></li>
<% end %>
<% end %>
<% if @cud.instructor? then %>
<li class="collection-item add">
<%= link_to new_course_assessment_attachment_path(@course, @assessment) do %>
<i class="material-icons left">note_add</i>Add Attachment
<% end %>
<span class="secondary-content"></span>
</li>
<% end %>
<% if @cud.instructor? then %>
<li class="collection-item add">
<%= link_to new_course_assessment_attachment_path(@course, @assessment) do %>
<i class="material-icons left">note_add</i>Add Attachment
<% end %>
<span class="secondary-content"></span>
</li>
<% end %>
</ul>
</ul>
</div>
<hr>

<% end %>
Expand Down