Skip to content

Commit

Permalink
Fix annotation tool infant diseases (#606)
Browse files Browse the repository at this point in the history
* Don't assume that `lecture` variable is present

For example, when opening a worked example that is not attached
to a particular lecture, it will be `nil`. In this case,
we return the annotation status of the medium itself.

* Don't show emergency link if `lecture` is not present

* Fix wrong tooltip for annotation button
  • Loading branch information
Splines authored Apr 3, 2024
1 parent ac7808f commit e9fc650
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/models/medium.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def subscribed_users
# if "inherit from lecture" was selected (i.e. if the annotations status of
# this medium is -1).
def get_annotations_status # rubocop:todo Naming/AccessorMethodName
return lecture.annotations_status if annotations_status == -1
return lecture.annotations_status if annotations_status == -1 && lecture.present?

annotations_status
end
Expand Down
27 changes: 15 additions & 12 deletions app/views/annotations/_form_content_further_help.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<div id="emergency-link">
<% lecture = Medium.find_by_id(@medium_id).lecture %>
<% status = lecture.emergency_link_status_for_database %>
<% link = lecture.emergency_link %>
<% if status == Lecture.emergency_link_statuses[:lecture_link] %>
<% link_name = Lecture.find_by_id(link.tr("^[0-9]", "")).title %>
<% elsif status == Lecture.emergency_link_statuses[:direct_link] %>
<% link_name = link %>
<% if lecture %>
<% status = lecture.emergency_link_status_for_database %>
<% link = lecture.emergency_link %>
<% if status == Lecture.emergency_link_statuses[:lecture_link] %>
<% link_name = Lecture.find_by_id(link.tr("^[0-9]", "")).title %>
<% elsif status == Lecture.emergency_link_statuses[:direct_link] %>
<% link_name = link %>
<% end %>

<% unless link_name.blank? %>
<%= t('admin.annotation.further_help') %> <br>
<a href="<%= link %>" target="_blank" rel="noopener noreferrer">
<%= link_name %>
</a>
<% end %>
<% end %>
<% unless link_name.blank? %>
<%= t('admin.annotation.further_help') %> <br>
<a href="<%= link %>" target="_blank" rel="noopener noreferrer">
<%= link_name %>
</a>
<% end %>
</div>
3 changes: 2 additions & 1 deletion app/views/media/play.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@

<!--- ANNOTATION BUTTON -->
<% if user_signed_in? %>
<a id="annotation-button" class="btn" title="<%= t('admin.annotation.edit_annotation') %>">
<a id="annotation-button" class="btn"
title="<%= t('admin.annotation.annotation_modal_head_create_annotation') %>">
<i class="fas fa-sticky-note" aria-hidden="true"></i>
</a>
<% end %>
Expand Down

0 comments on commit e9fc650

Please sign in to comment.