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

Remove emergency link #625

Merged
merged 2 commits into from
Apr 24, 2024
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
24 changes: 0 additions & 24 deletions app/assets/javascripts/lectures.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -202,30 +202,6 @@ $(document).on 'turbolinks:load', ->
userModalContent.dataset.filled = 'true'
return

# Dynamically render content for entering emergency links.
updateEmergencyLink = (value) ->
if value == "no_link"
$('#direct-link-field').hide()
$('#lecture-link-field').hide()
if value == "lecture_link"
$('#direct-link-field').hide()
$('#lecture-link-field').show()
if value == "direct_link"
$('#lecture-link-field').hide()
$('#direct-link-field').show()
return

emergencyLinkRadios = document.getElementById('emergency-link-status-radios')

if (emergencyLinkRadios != null)
$('#emergency-link-status-radios input:radio:checked').each ->
updateEmergencyLink(this.value)
return
emergencyLinkRadios.addEventListener 'click', (evt) ->
if evt.target && event.target.matches("input[type='radio']")
updateEmergencyLink(evt.target.value)
return

# on small mobile display, use shortened tag badges and
# shortened course titles
mobileDisplay = ->
Expand Down
4 changes: 0 additions & 4 deletions app/assets/stylesheets/annotations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@
}
}

#emergency-link {
text-align: center;
}

.annotation-marker {
position: relative;
top: -12px;
Expand Down
25 changes: 1 addition & 24 deletions app/controllers/lectures_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ def edit
Time.zone.parse(ENV.fetch("RAILS_CACHE_ID", nil))].max)
eager_load_stuff
end

# emergency link -> prefill form
status = @lecture.emergency_link_status_for_database
link = @lecture.emergency_link
if status == Lecture.emergency_link_statuses[:lecture_link]
@linked_lecture = Lecture.find_by(id: link.tr("^[0-9]", ""))
elsif status == Lecture.emergency_link_statuses[:direct_link]
@direct_link = link
end
end

def create
Expand Down Expand Up @@ -121,19 +112,6 @@ def update
end
end

# emergency link update
status = params[:lecture][:emergency_link_status] # string
status = Lecture.emergency_link_statuses[status]
if status == Lecture.emergency_link_statuses[:lecture_link]
params[:lecture][:emergency_link] = params[:lecture][:lecture_link]
elsif status == Lecture.emergency_link_statuses[:direct_link]
link = params[:lecture][:direct_link]
# Prepend "https://" to link if not present to make it an absolute URL
# instead of a relative one. E.g. "example.com" -> "https://example.com".
link = "https://#{link}" unless link.start_with?("http")
params[:lecture][:emergency_link] = link
end

@lecture.update(lecture_params)
if structure_params.present?
structure_ids = structure_params.select { |_k, v| v.to_i == 1 }.keys
Expand Down Expand Up @@ -345,8 +323,7 @@ def lecture_params
:organizational_on_top, :disable_teacher_display,
:content_mode, :passphrase, :sort, :comments_disabled,
:submission_max_team_size, :submission_grace_period,
:annotations_status, :emergency_link,
:emergency_link_status]
:annotations_status]
if action_name == "update" && current_user.can_update_personell?(@lecture)
allowed_params.push(:teacher_id, { editor_ids: [] })
end
Expand Down
4 changes: 0 additions & 4 deletions app/models/lecture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ class Lecture < ApplicationRecord
# in the erdbeere database
serialize :structure_ids, Array

# if the annotation button is enabled, one can add different types of links
# that e.g. bring students to the helpdesk
enum emergency_link_status: { no_link: 0, lecture_link: 1, direct_link: 2 }

# we do not allow that a teacher gives a certain lecture in a given term
# of the same sort twice
# rubocop:todo Rails/UniqueValidationWithoutIndex
Expand Down
19 changes: 0 additions & 19 deletions app/views/annotations/_form_content_further_help.html.erb

This file was deleted.

19 changes: 0 additions & 19 deletions app/views/annotations/edit.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -116,27 +116,8 @@ function content() {
contentCategoryRadios.addEventListener("click", function (evt) {
if (evt.target && event.target.matches("input[type='radio']")) {
submitButton.disabled = false;

// Show further help
// (right now, the same help is display for all the different categories)
switch (evt.target.value) {
case Subcategory.DEFINITION.name:
showFurtherHelp();
break;
case Subcategory.ARGUMENT.name:
showFurtherHelp();
break;
case Subcategory.STRATEGY.name:
showFurtherHelp();
break;
}
}
});

function showFurtherHelp() {
$("#content-specific").empty()
.append("<%= j render partial: "annotations/form_content_further_help"%>");
}
}

function mistake() {
Expand Down
49 changes: 0 additions & 49 deletions app/views/lectures/edit/_preferences.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -158,55 +158,6 @@
</div>
</div>
<% end %>
<!--- ANNOTATION BUTTON -->
<% if lecture.annotations_status == 1 %>
<div class="form-group">
<%= t('admin.lecture.emergency_link') %>
<div class="form-row ml-2", id="emergency-link-status-radios">
<div class="form-check form-check-inline">
<%= f.radio_button :emergency_link_status,
:no_link,
class: 'form-check-input' %>
<%= f.label :emergency_link_status,
t('admin.lecture.emergency_link_no_link'),
value: :no_link,
class: 'form-check-label' %>
</div>
<div class="form-check form-check-inline">
<%= f.radio_button :emergency_link_status,
:lecture_link,
class: 'form-check-input' %>
<%= f.label :emergency_link_status,
t('admin.lecture.emergency_link_lecture_link'),
value: :lecture_link,
class: 'form-check-label' %>
</div>
<div class="form-check form-check-inline">
<%= f.radio_button :emergency_link_status,
:direct_link,
class: 'form-check-input' %>
<%= f.label :emergency_link_status,
t('admin.lecture.emergency_link_direct_link'),
value: :direct_link,
class: 'form-check-label' %>
</div>
</div>
</div>
<div id="lecture-link-field">
<%= t('admin.lecture.select_helpdesk') %>
<%= f.select :lecture_link,
options_for_select(Lecture.all.map { |l| [l.title, l.lecture_path] },
[@linked_lecture&.title, @linked_lecture&.lecture_path]) %>
</div>
<div class="form-row", id="direct-link-field">
<div class="col-auto form-group">
<%= t('admin.lecture.enter_emergency_link') %>
<%= f.text_field :direct_link,
{ size: 50,
value: @direct_link } %>
</div>
</div>
<% end %>
<div class="row">
<div class="col-12 text-center">
<div id="lecture-preferences-warning">
Expand Down
6 changes: 0 additions & 6 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,6 @@ de:
script_based: >
unter Verwendung eines Veranstaltungsskriptes, das mit dem MaMpf
LaTeX-Paket erstellt wurde
emergency_link: 'Link für den Emergency-Button'
emergency_link_no_link: 'kein Link'
emergency_link_lecture_link: 'Vorlesungslink'
emergency_link_direct_link: 'direkter Link'
enter_emergency_link: 'Emergency-Link eingeben:'
select_helpdesk: 'Helpdesk auswählen:'
no_chapters: 'Es sind noch keine Kapitel vorhanden.'
no_talks: Es sind noch keine Vorträge vorhanden.
orphaned_lessons: 'Verwaiste Sitzungen'
Expand Down
6 changes: 0 additions & 6 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,6 @@ en:
content_mode: 'Content determination'
video_based: 'media based'
script_based: 'using a manuscript generated by the MaMpf LaTeX package'
emergency_link: 'Link for the emergency button'
emergency_link_no_link: 'no link'
emergency_link_lecture_link: 'lecture link'
emergency_link_direct_link: 'direct link'
enter_emergency_link: 'Enter emergency link:'
select_helpdesk: 'Select helpdesk:'
no_chapters: 'There are no chapters yet.'
no_talks: 'There are no talks yet.'
orphaned_lessons: 'Orphaned Sessions'
Expand Down
10 changes: 10 additions & 0 deletions db/migrate/20240422200000_remove_emergency_link_from_lecture.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class RemoveEmergencyLinkFromLecture < ActiveRecord::Migration[7.0]
def up
remove_column :lectures, :emergency_link_status, :integer
remove_column :lectures, :emergency_link, :text
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
4 changes: 1 addition & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_03_29_230010) do
ActiveRecord::Schema[7.0].define(version: 2024_04_22_200000) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -299,8 +299,6 @@
t.integer "submission_grace_period", default: 15
t.boolean "legacy_seminar", default: false
t.integer "annotations_status", default: 1, null: false
t.integer "emergency_link_status", default: 0, null: false
t.text "emergency_link"
t.index ["teacher_id"], name: "index_lectures_on_teacher_id"
t.index ["term_id"], name: "index_lectures_on_term_id"
end
Expand Down