Reduce usage of @current_user (use helper instead)
This commit is contained in:
@ -108,7 +108,7 @@ module Lti
|
||||
@exercise = if proxy_exercise.nil?
|
||||
Exercise.find_by(token: params[:custom_token])
|
||||
else
|
||||
proxy_exercise.get_matching_exercise(@current_user)
|
||||
proxy_exercise.get_matching_exercise(current_user)
|
||||
end
|
||||
session[:lti_exercise_id] = @exercise.id if @exercise
|
||||
refuse_lti_launch(message: t('sessions.oauth.invalid_exercise_token')) unless @exercise
|
||||
@ -181,7 +181,7 @@ module Lti
|
||||
|
||||
def set_current_user
|
||||
@current_user = ExternalUser.find_or_create_by(consumer_id: @consumer.id, external_id: @provider.user_id)
|
||||
@current_user.update(email: external_user_email(@provider), name: external_user_name(@provider))
|
||||
current_user.update(email: external_user_email(@provider), name: external_user_name(@provider))
|
||||
end
|
||||
|
||||
private :set_current_user
|
||||
@ -196,7 +196,7 @@ module Lti
|
||||
StudyGroup.find_or_create_by(external_id: @provider.resource_link_id, consumer: @consumer)
|
||||
end
|
||||
|
||||
study_group_membership = StudyGroupMembership.find_or_create_by(study_group: group, user: @current_user)
|
||||
study_group_membership = StudyGroupMembership.find_or_create_by(study_group: group, user: current_user)
|
||||
study_group_membership.update(role: external_user_role(@provider))
|
||||
session[:study_group_id] = group.id
|
||||
end
|
||||
@ -228,14 +228,14 @@ module Lti
|
||||
|
||||
def store_lti_session_data(options = {})
|
||||
lti_parameters = LtiParameter.find_or_create_by(consumers_id: options[:consumer].id,
|
||||
external_users_id: @current_user.id,
|
||||
external_users_id: current_user.id,
|
||||
exercises_id: @exercise.id)
|
||||
|
||||
lti_parameters.lti_parameters = options[:parameters].slice(*SESSION_PARAMETERS).permit!.to_h
|
||||
lti_parameters.save!
|
||||
@lti_parameters = lti_parameters
|
||||
|
||||
session[:external_user_id] = @current_user.id
|
||||
session[:external_user_id] = current_user.id
|
||||
session[:lti_parameters_id] = lti_parameters.id
|
||||
end
|
||||
|
||||
|
@ -22,7 +22,7 @@ class SessionsController < ApplicationController
|
||||
redirect_to(URI.parse(params[:custom_redirect_target].to_s).path)
|
||||
else
|
||||
redirect_to(implement_exercise_path(@exercise),
|
||||
notice: t("sessions.create_through_lti.session_#{lti_outcome_service?(@exercise.id, @current_user.id) ? 'with' : 'without'}_outcome",
|
||||
notice: t("sessions.create_through_lti.session_#{lti_outcome_service?(@exercise.id, current_user.id) ? 'with' : 'without'}_outcome",
|
||||
consumer: @consumer))
|
||||
end
|
||||
end
|
||||
|
@ -6,9 +6,9 @@
|
||||
- if object
|
||||
- current_element = object
|
||||
- else
|
||||
- root_element = link_to_if(@current_user && policy(model).index?, model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
||||
- root_element = link_to_if(current_user && policy(model).index?, model.model_name.human(count: 2), send(:"#{model.model_name.collection}_path"))
|
||||
- if object
|
||||
- current_element = link_to_if(@current_user && policy(object).show?, object, send(:"#{model.model_name.singular}_path", object))
|
||||
- current_element = link_to_if(current_user && policy(object).show?, object, send(:"#{model.model_name.singular}_path", object))
|
||||
- if I18n.translation_present?("shared.#{params[:action]}")
|
||||
- active_action = t("shared.#{params[:action]}", model: model&.model_name&.human)
|
||||
- else
|
||||
|
@ -1,12 +1,13 @@
|
||||
- external_user_external_id = @current_user.respond_to?(:external_id) ? @current_user.external_id : ''
|
||||
- external_user_id = @current_user.respond_to?(:external_id) ? @current_user.id : ''
|
||||
- consumer_id = @current_user.respond_to?(:external_id) ? @current_user.consumer_id : ''
|
||||
- external_user_external_id = current_user.respond_to?(:external_id) ? current_user.external_id : ''
|
||||
- external_user_id = current_user.respond_to?(:external_id) ? current_user.id : ''
|
||||
- consumer_id = current_user.respond_to?(:external_id) ? current_user.consumer_id : ''
|
||||
- show_break_interventions = @show_break_interventions || "false"
|
||||
- show_rfc_interventions = @show_rfc_interventions || "false"
|
||||
- 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)
|
||||
= current_user
|
||||
#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)
|
||||
- unless @embed_options[:hide_sidebar]
|
||||
- additional_classes = 'sidebar-col'
|
||||
- if @tips.blank?
|
||||
|
@ -52,7 +52,7 @@ div.d-grid id='output_sidebar_uncollapsed' class='d-none col-sm-12 enforce-botto
|
||||
| 0
|
||||
= row(label: 'exercises.implement.feedback')
|
||||
= row(label: 'exercises.implement.messages')
|
||||
#score data-maximum-score=@exercise.maximum_score data-score=@exercise.final_submission(@current_user).try(:score)
|
||||
#score data-maximum-score=@exercise.maximum_score data-score=@exercise.final_submission(current_user).try(:score)
|
||||
h4
|
||||
span == "#{t('activerecord.attributes.submission.score')}: "
|
||||
span.score
|
||||
|
@ -26,13 +26,13 @@ html lang="#{I18n.locale || I18n.default_locale}"
|
||||
| release: "#{SentryJavascript.release}",
|
||||
| environment: "#{SentryJavascript.environment}",
|
||||
| });
|
||||
- if @current_user
|
||||
- if current_user
|
||||
| Sentry.configureScope(function(scope) {
|
||||
| scope.setUser({
|
||||
| "id": "#{@current_user.id}",
|
||||
| "type": "#{@current_user.class.name}",
|
||||
| "username": "#{@current_user.displayname}",
|
||||
| "consumer": "#{@current_user.consumer.name}"
|
||||
| "id": "#{current_user.id}",
|
||||
| "type": "#{current_user.class.name}",
|
||||
| "username": "#{current_user.displayname}",
|
||||
| "consumer": "#{current_user.consumer.name}"
|
||||
| });
|
||||
| });
|
||||
body
|
||||
|
@ -41,7 +41,7 @@
|
||||
pre= testrun.log or t('request_for_comments.no_output')
|
||||
|
||||
- assess_runs = testruns.select {|run| run.cause == 'assess' }
|
||||
- unless @current_user.admin?
|
||||
- unless current_user.admin?
|
||||
- assess_runs = assess_runs.select {|run| run.file.present? ? run.file.teacher_defined_test? : true }
|
||||
- if assess_runs.size > 0
|
||||
h5.mt-4= t('request_for_comments.test_results')
|
||||
@ -53,7 +53,7 @@
|
||||
span.fa-solid.fa-chevron-down.collapse-button
|
||||
pre= testrun.log or t('request_for_comments.no_output')
|
||||
|
||||
- if @current_user.admin? && user.is_a?(ExternalUser)
|
||||
- if current_user.admin? && user.is_a?(ExternalUser)
|
||||
= render('admin_menu')
|
||||
|
||||
hr
|
||||
|
@ -8,7 +8,7 @@ describe 'exercises/implement.html.slim' do
|
||||
let(:non_binary_files) { files.reject {|file| file.file_type.binary? } }
|
||||
|
||||
before do
|
||||
assign(:current_user, create(:admin))
|
||||
allow(view).to receive(:current_user).and_return(create(:admin))
|
||||
assign(:exercise, exercise)
|
||||
assign(:files, files)
|
||||
assign(:paths, [])
|
||||
|
Reference in New Issue
Block a user