Skip to content

Commit

Permalink
Hide download handout button if assessement has no handout (autolab#1951
Browse files Browse the repository at this point in the history
)

* Hide handout button if no handout defined

* Temporary fix for chromedriver issue

(cherry picked from commit 6bd7bc6)
  • Loading branch information
damianhxy authored and NicholasMy committed Jan 4, 2024
1 parent 3b3b3f2 commit ade353e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions app/controllers/assessment/handout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def mime_type_from_ext(ext)
end

def handout
# If the logic here changes, do update assessment#has_handout?
extend_config_module(@assessment, nil, @cud)

if @assessment.overwrites_method?(:handout)
Expand Down
4 changes: 4 additions & 0 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ def has_writeup?
writeup_is_url? || writeup_is_file?
end

def has_handout?
overwrites_method?(:handout) || handout_is_url? || handout_is_file?
end

def groups
Group.joins(:assessment_user_data).where(assessment_user_data: { assessment_id: id }).distinct
end
Expand Down
21 changes: 10 additions & 11 deletions app/views/assessments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@
<div class="collapsible-header active"><h5>Options</h5></div>
<div class="collapsible-body">
<ul class="options">
<li><%= link_to "View handin history", { :action => 'history' }, { :title => "View your submissions, scores, and feedback from the course staff" } %> </li>

<li><%= link_to "View handin history", {:action => 'history'}, {:title=> "View your submissions, scores, and feedback from the course staff" } %> </li>
<% if @assessment.has_writeup? %>
<li><%= link_to "View writeup", { :action => 'writeup' }, { :title => "View the assessment writeup", :class => "" } %> </li>
<li><%= link_to "View writeup", {:action => 'writeup'}, {:title=> "View the assessment writeup"} %> </li>
<% end %>
<% if @assessment.has_handout? %>
<li><%= link_to "Download handout", {:action => 'handout'}, {:title=> "Download handout materials and starter code" } %> </li>
<% end %>

<li><%= link_to "Download handout", { :action => 'handout' }, { :title => "Download handout materials and starter code" } %> </li>
<% if @assessment.has_groups? %>
<% if @aud.membership_status != AssessmentUserDatum::UNCONFIRMED then %>
<li><%= link_to "Group options", [@course, @assessment, @aud.group], title: "Check your group settings." %></li>
Expand All @@ -147,12 +147,11 @@
<% if @assessment.has_scoreboard? %>
<li><%= link_to "View scoreboard", [@course, @assessment, :scoreboard], title: "View the assessment scoreboard" %></li>
<% end %>
<% @list.sort { |a, b| a[1] <=> b[1] }.each { |key, value| %>
<% if value.size > 0 then %>
<li><%= link_to value, { :action => key }, { :title => (@list_title[key] || "") } %> </li>
<% end %>
<% } %>
<% @list.sort { |a,b| a[1] <=> b[1] }.each { |key, value| %>
<% if value.size > 0 then %>
<li><%= link_to value, {:action => key}, {:title=>(@list_title[key] || "")} %> </li>
<% end %>
<% } %>
</ul>
</div>
</li>
Expand Down
4 changes: 4 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

# Temporary fix for chromedriver version issue, until we can update Selenium
# https://github.com/titusfortner/webdrivers/issues/247
Webdrivers::Chromedriver.required_version = "114.0.5735.90"

Capybara.register_driver :headless_chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
'goog:chromeOptions': { args: %w[headless] }
Expand Down

0 comments on commit ade353e

Please sign in to comment.