Remove clear_lti_session_data as it is no longer needed
* no lti session data anymore included in the function * decided not to delete the pg_id here as it is handled in create_through_lti and implement * the function is only called once without an exercise id so the values are now directly deleted there
This commit is contained in:

committed by
Sebastian Serth

parent
dddebcca67
commit
c2995c96f0
@ -19,24 +19,6 @@ module Lti
|
|||||||
|
|
||||||
private :build_tool_provider
|
private :build_tool_provider
|
||||||
|
|
||||||
# exercise_id.nil? ==> the user has logged out. All session data is to be destroyed
|
|
||||||
# exercise_id.exists? ==> the user has submitted the results of an exercise to the consumer.
|
|
||||||
# Only the assignment of the programming group is deleted.
|
|
||||||
def clear_lti_session_data(exercise_id = nil)
|
|
||||||
if exercise_id.nil?
|
|
||||||
session.delete(:external_user_id)
|
|
||||||
session.delete(:study_group_id)
|
|
||||||
session.delete(:embed_options)
|
|
||||||
end
|
|
||||||
session.delete(:pg_id)
|
|
||||||
|
|
||||||
# We allow reusing the LTI credentials and don't remove them on purpose.
|
|
||||||
# This allows users to jump between remote and web evaluation with the same behavior.
|
|
||||||
# Also it prevents the user from deleting the lti_parameters for their programming team members.
|
|
||||||
end
|
|
||||||
|
|
||||||
private :clear_lti_session_data
|
|
||||||
|
|
||||||
def consumer_return_url(provider, options = {})
|
def consumer_return_url(provider, options = {})
|
||||||
consumer_return_url = provider.try(:launch_presentation_return_url) || params[:launch_presentation_return_url]
|
consumer_return_url = provider.try(:launch_presentation_return_url) || params[:launch_presentation_return_url]
|
||||||
consumer_return_url += "?#{options.to_query}" if consumer_return_url && options.present?
|
consumer_return_url += "?#{options.to_query}" if consumer_return_url && options.present?
|
||||||
|
@ -16,7 +16,6 @@ module RedirectBehavior
|
|||||||
# redirect 10 percent pseudorandomly to the feedback page
|
# redirect 10 percent pseudorandomly to the feedback page
|
||||||
if current_user.respond_to? :external_id
|
if current_user.respond_to? :external_id
|
||||||
if @submission.redirect_to_feedback? && !@embed_options[:disable_redirect_to_feedback]
|
if @submission.redirect_to_feedback? && !@embed_options[:disable_redirect_to_feedback]
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
redirect_to_user_feedback
|
redirect_to_user_feedback
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -27,7 +26,6 @@ module RedirectBehavior
|
|||||||
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc')
|
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_own_rfc')
|
||||||
flash.keep(:notice)
|
flash.keep(:notice)
|
||||||
|
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(rfc) }
|
format.html { redirect_to(rfc) }
|
||||||
format.json { render(json: {redirect: url_for(rfc)}) }
|
format.json { render(json: {redirect: url_for(rfc)}) }
|
||||||
@ -45,7 +43,6 @@ module RedirectBehavior
|
|||||||
# increase counter 'times_featured' in rfc
|
# increase counter 'times_featured' in rfc
|
||||||
rfc.increment(:times_featured)
|
rfc.increment(:times_featured)
|
||||||
|
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(rfc) }
|
format.html { redirect_to(rfc) }
|
||||||
format.json { render(json: {redirect: url_for(rfc)}) }
|
format.json { render(json: {redirect: url_for(rfc)}) }
|
||||||
@ -56,7 +53,6 @@ module RedirectBehavior
|
|||||||
else
|
else
|
||||||
# redirect to feedback page if score is less than 100 percent
|
# redirect to feedback page if score is less than 100 percent
|
||||||
if @exercise.needs_more_feedback?(@submission) && !@embed_options[:disable_redirect_to_feedback]
|
if @exercise.needs_more_feedback?(@submission) && !@embed_options[:disable_redirect_to_feedback]
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
redirect_to_user_feedback
|
redirect_to_user_feedback
|
||||||
else
|
else
|
||||||
redirect_to_lti_return_path
|
redirect_to_lti_return_path
|
||||||
@ -128,7 +124,6 @@ module RedirectBehavior
|
|||||||
)
|
)
|
||||||
|
|
||||||
path = lti_return_path(submission_id: @submission.id)
|
path = lti_return_path(submission_id: @submission.id)
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(path) }
|
format.html { redirect_to(path) }
|
||||||
format.json { render(json: {redirect: path}) }
|
format.json { render(json: {redirect: path}) }
|
||||||
|
@ -47,13 +47,14 @@ class SessionsController < ApplicationController
|
|||||||
authorize(@submission, :show?)
|
authorize(@submission, :show?)
|
||||||
lti_parameter = current_user.lti_parameters.find_by(exercise: @submission.exercise, study_group_id: current_user.current_study_group_id)
|
lti_parameter = current_user.lti_parameters.find_by(exercise: @submission.exercise, study_group_id: current_user.current_study_group_id)
|
||||||
@url = consumer_return_url(build_tool_provider(consumer: current_user.consumer, parameters: lti_parameter&.lti_parameters))
|
@url = consumer_return_url(build_tool_provider(consumer: current_user.consumer, parameters: lti_parameter&.lti_parameters))
|
||||||
|
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if current_user&.external_user?
|
if current_user&.external_user?
|
||||||
clear_lti_session_data
|
session.delete(:external_user_id)
|
||||||
|
session.delete(:study_group_id)
|
||||||
|
session.delete(:embed_options)
|
||||||
|
session.delete(:pg_id)
|
||||||
|
|
||||||
# In case we have another session as an internal user, we set the study group for this one
|
# In case we have another session as an internal user, we set the study group for this one
|
||||||
internal_user = find_or_login_current_user
|
internal_user = find_or_login_current_user
|
||||||
|
@ -17,16 +17,6 @@ describe Lti do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#clear_lti_session_data' do
|
|
||||||
it 'clears the session' do
|
|
||||||
expect(controller.session).to receive(:delete).with(:external_user_id)
|
|
||||||
expect(controller.session).to receive(:delete).with(:study_group_id)
|
|
||||||
expect(controller.session).to receive(:delete).with(:embed_options)
|
|
||||||
expect(controller.session).to receive(:delete).with(:pg_id)
|
|
||||||
controller.send(:clear_lti_session_data)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#external_user_name' do
|
describe '#external_user_name' do
|
||||||
let(:first_name) { 'Jane' }
|
let(:first_name) { 'Jane' }
|
||||||
let(:last_name) { 'Doe' }
|
let(:last_name) { 'Doe' }
|
||||||
|
@ -190,7 +190,10 @@ describe SessionsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'clears the session' do
|
it 'clears the session' do
|
||||||
expect(controller).to receive(:clear_lti_session_data)
|
expect(controller.session).to receive(:delete).with(:external_user_id)
|
||||||
|
expect(controller.session).to receive(:delete).with(:study_group_id)
|
||||||
|
expect(controller.session).to receive(:delete).with(:embed_options)
|
||||||
|
expect(controller.session).to receive(:delete).with(:pg_id)
|
||||||
delete :destroy
|
delete :destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -210,11 +213,6 @@ describe SessionsController do
|
|||||||
perform_request.call
|
perform_request.call
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'clears the session' do
|
|
||||||
expect(controller).to receive(:clear_lti_session_data)
|
|
||||||
perform_request.call
|
|
||||||
end
|
|
||||||
|
|
||||||
expect_http_status(:ok)
|
expect_http_status(:ok)
|
||||||
expect_template(:destroy_through_lti)
|
expect_template(:destroy_through_lti)
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user