Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide view writeup button when no writeup exists #1615

Merged
merged 5 commits into from
Sep 29, 2022
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
2 changes: 1 addition & 1 deletion app/controllers/assessment/handout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ def handout
return
end

flash[:error] = "There is no handout for this assessment."
flash.now[:error] = "There is no handout for this assessment."
end
end
3 changes: 2 additions & 1 deletion app/controllers/assessments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ def withdrawAllGrades
action_auth_level :writeup, :student

def writeup
# If the logic here changes, do update assessment#has_writeup?
if @assessment.writeup_is_url?
redirect_to @assessment.writeup
return
Expand All @@ -768,7 +769,7 @@ def writeup
return
end

@output = "There is no writeup for this assessment."
flash.now[:error] = "There is no writeup for this assessment."
end

# uninstall - uninstalls an assessment
Expand Down
4 changes: 4 additions & 0 deletions app/models/assessment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ def has_scoreboard?
scoreboard != nil
end

def has_writeup?
writeup_is_url? || writeup_is_file?
end

def groups
Group.joins(:assessment_user_data).where(assessment_user_data: { assessment_id: id }).distinct
end
Expand Down
8 changes: 6 additions & 2 deletions app/views/assessments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@
<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 writeup", {:action => 'writeup'}, {:title=> "View the assessment writeup", :class=>""}%> </li>

<% if @assessment.has_writeup? %>
<li><%= link_to "View writeup", {:action => 'writeup'}, {:title=> "View the assessment writeup", :class=>""}%> </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 %>
Expand All @@ -134,7 +138,7 @@
<% end %>
<% end %>
<% if @assessment.has_scoreboard? %>
<li><%= link_to "View scoreboard", [@course, @assessment, :scoreboard], title: "View the assessment scoreboard" %></li>
<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| %>
Expand Down