From bf662ecb8171ff5d4e8e913a2f3677b1566f8f77 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Fri, 28 Jul 2023 08:45:05 +0200 Subject: [PATCH] Remove legacy forum search and search buttons --- app/assets/javascripts/editor/editor.js.erb | 22 ------------------- app/controllers/exercises_controller.rb | 21 ------------------ app/views/exercises/_editor.html.slim | 2 +- .../exercises/_editor_file_tree.html.slim | 11 ---------- 4 files changed, 1 insertion(+), 55 deletions(-) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 6246ecdc..6c6420ae 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -1010,27 +1010,6 @@ var CodeOceanEditor = { } }, - initializeSearchButton: function () { - $('#btn-search-col').button().click(function () { - var search = $('#search-input-text').val(); - var course_token = $('#editor').data('course_token') - var save_search_url = $('#editor').data('search-save-url') - window.open("https://open.hpi.de/courses/" + course_token + "/pinboard?query=" + search, '_blank'); - // save search - $.ajax({ - data: { - search_text: search - }, - dataType: 'json', - type: 'POST', - url: save_search_url - }); - }) - - $('#sidebar-search-collapsed').on('click', this.handleSideBarToggle.bind(this)); - }, - - initializeEverything: function () { CodeOceanEditor.editors = []; this.initializeRegexes(); @@ -1044,7 +1023,6 @@ var CodeOceanEditor = { this.initializeDescriptionToggle(); this.initializeSideBarTooltips(); this.initializeInterventionTimer(); - this.initializeSearchButton(); this.initPrompt(); this.renderScore(); this.showFirstFile(); diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d31ca30c..7e807103 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -16,7 +16,6 @@ class ExercisesController < ApplicationController before_action :collect_set_and_unset_exercise_tags, only: MEMBER_ACTIONS before_action :set_external_user_and_authorize, only: [:external_user_statistics] before_action :set_file_types, only: %i[create edit new update] - before_action :set_course_token, only: [:implement] before_action :set_available_tips, only: %i[implement show new edit] skip_before_action :verify_authenticity_token, only: %i[import_task import_uuid_check] @@ -344,26 +343,6 @@ class ExercisesController < ApplicationController end end - def set_course_token - lti_parameters = LtiParameter.where(external_users_id: current_user.id, - exercises_id: @exercise.id).last - if lti_parameters - lti_json = lti_parameters.lti_parameters['launch_presentation_return_url'] - - @course_token = - if lti_json.present? && (match = lti_json.match(%r{^.*courses/([a-z0-9-]+)/sections})) - match.captures.first - else - '' - end - else - # no consumer, therefore implementation with internal user - @course_token = '702cbd2a-c84c-4b37-923a-692d7d1532d0' - end - end - - private :set_course_token - def set_available_tips # Order of elements is important and will be kept available_tips = ExerciseTip.where(exercise: @exercise).order(rank: :asc).includes(:tip) diff --git a/app/views/exercises/_editor.html.slim b/app/views/exercises/_editor.html.slim index cdc1da8c..1cb89297 100644 --- a/app/views/exercises/_editor.html.slim +++ b/app/views/exercises/_editor.html.slim @@ -6,7 +6,7 @@ - show_tips_interventions = @show_tips_interventions || "false" - hide_rfc_button = @hide_rfc_button || false -#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-user-id=current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions data-course_token=@course_token data-search-save-url=search_exercise_path(@exercise) +#editor.row data-exercise-id=@exercise.id data-message-depleted=t('exercises.editor.depleted') data-message-timeout=t('exercises.editor.timeout', permitted_execution_time: @exercise.execution_environment.permitted_execution_time) data-message-out-of-memory=t('exercises.editor.out_of_memory', memory_limit: @exercise.execution_environment.memory_limit) data-submissions-url=submissions_path data-user-id=current_user.id data-user-external-id=external_user_external_id data-working-times-url=working_times_exercise_path(@exercise) data-intervention-save-url=intervention_exercise_path(@exercise) data-rfc-interventions=show_rfc_interventions data-break-interventions=show_break_interventions data-tips-interventions=show_tips_interventions data-search-save-url=search_exercise_path(@exercise) - unless @embed_options[:hide_sidebar] - additional_classes = 'sidebar-col' - if @tips.blank? diff --git a/app/views/exercises/_editor_file_tree.html.slim b/app/views/exercises/_editor_file_tree.html.slim index 9e3a78bd..f9d83300 100644 --- a/app/views/exercises/_editor_file_tree.html.slim +++ b/app/views/exercises/_editor_file_tree.html.slim @@ -4,9 +4,6 @@ div.d-grid.gap-2 id='sidebar-collapsed' class=(@exercise.hide_file_tree && @tips - unless @embed_options[:disable_hints] or @tips.blank? = render('editor_button', classes: 'btn-secondary btn mb-4', data: {:'data-bs-toggle' => 'tooltip', :'data-bs-placement' => 'right'}, icon: 'fa-solid fa-lightbulb', id: 'tips-collapsed', label:'', title: t('exercises.form.tips')) - //- if !@course_token.blank? - = render('editor_button', classes: 'btn-primary btn enforce-top-margin', data: {:'data-bs-toggle' => 'tooltip', :'data-bs-placement' => 'right'}, icon: 'fa-solid fa-magnifying-glass', id: 'sidebar-search-collapsed', label: '', title: t('search.search_in_forum')) - div.d-grid.enforce-bottom-margin id='sidebar-uncollapsed' class=(@exercise.hide_file_tree && @tips.blank? ? 'd-none' : '') = render('editor_button', classes: 'btn-outline-dark overflow-hidden mb-2', icon: 'fa-solid fa-square-minus', id: 'sidebar-collapse', label: t('exercises.editor.collapse_action_sidebar')) #content-left-sidebar.overflow-scroll @@ -32,13 +29,5 @@ div.d-grid.enforce-bottom-margin id='sidebar-uncollapsed' class=(@exercise.hide_ - unless @embed_options[:disable_hints] or @tips.blank? = render(partial: 'tips_content') - //- if !@course_token.blank? - .input-group.enforce-top-margin - .enforce-right-margin - = text_field_tag 'search-input-text', nil, placeholder: t('search.search_in_forum'), class: 'form-control' - .input-group-btn - = button_tag(class: 'btn btn-primary', id: 'btn-search-col') do - i.fa-solid.fa-magnifying-glass - - if @exercise.allow_file_creation? = render('shared/modal', id: 'modal-file', template: 'code_ocean/files/_form', title: t('exercises.editor.create_file'))