Fixed the destroy session logic.
1. an exercise_id is provided ==> only the LtiParameter object for the current user, consumer, and exercise is deleted. 2. no exercise_id is provided ==> external user and consumer are removed from the session, all LtiParameter objects for this user and consumer are deleted. This enables users to have several tabs with exercises open and submitting the results to the tool consumer. When an exercise has been submitted, the user cannot use the back button to get back to CodeOcean and work on the submitted or any other exercise. For now a warning has been added to the info text to tell users not to do this. (As the LtiParameters have been deleted, the points can no more be submitted to the consumer.) @TODO disable/redirect back button?
This commit is contained in:
@ -15,19 +15,20 @@ module Lti
|
|||||||
end
|
end
|
||||||
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 lti_parameters are deleted.
|
||||||
def clear_lti_session_data(exercise_id = nil)
|
def clear_lti_session_data(exercise_id = nil)
|
||||||
#Todo replace session with lti_parameter /done
|
#Todo replace session with lti_parameter /done
|
||||||
#TODO decide if we need to remove all LtiParameters for user/consumer
|
|
||||||
if (exercise_id.nil?)
|
if (exercise_id.nil?)
|
||||||
LtiParameter.destroy_all(consumers_id: session[:consumer_id], external_user_id: session[:external_user_external_id])
|
LtiParameter.destroy_all(consumers_id: session[:consumer_id], external_user_id: session[:external_user_external_id])
|
||||||
else #TODO: probably it does not make sense to keep the LtiParameters if the session is deleted
|
session.delete(:consumer_id)
|
||||||
|
session.delete(:external_user_id)
|
||||||
|
else
|
||||||
LtiParameter.destroy_all(consumers_id: session[:consumer_id],
|
LtiParameter.destroy_all(consumers_id: session[:consumer_id],
|
||||||
external_user_id: session[:external_user_external_id],
|
external_user_id: session[:external_user_external_id],
|
||||||
exercises_id: exercise_id)
|
exercises_id: exercise_id)
|
||||||
end
|
end
|
||||||
session.delete(:consumer_id)
|
|
||||||
session.delete(:external_user_id)
|
|
||||||
#session.delete(:lti_parameters)
|
|
||||||
end
|
end
|
||||||
private :clear_lti_session_data
|
private :clear_lti_session_data
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class SessionsController < ApplicationController
|
|||||||
def destroy_through_lti
|
def destroy_through_lti
|
||||||
@consumer = Consumer.find_by(id: params[:consumer_id])
|
@consumer = Consumer.find_by(id: params[:consumer_id])
|
||||||
@submission = Submission.find(params[:submission_id])
|
@submission = Submission.find(params[:submission_id])
|
||||||
#TODO decide if we need to remove all LtiParameters for user/consumer
|
|
||||||
clear_lti_session_data(@submission.exercise_id)
|
clear_lti_session_data(@submission.exercise_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ h1 = t('.headline')
|
|||||||
p
|
p
|
||||||
== t(".success_#{params[:outcome] ? 'with' : 'without'}_outcome", consumer: @consumer)
|
== t(".success_#{params[:outcome] ? 'with' : 'without'}_outcome", consumer: @consumer)
|
||||||
==< t(".finished_#{@consumer ? 'with' : 'without'}_consumer", consumer: @consumer, url: params[:url])
|
==< t(".finished_#{@consumer ? 'with' : 'without'}_consumer", consumer: @consumer, url: params[:url])
|
||||||
|
==< t(".do_not_use_backbutton", consumer: @consumer)
|
||||||
|
|
||||||
h2 = t('shared.statistics')
|
h2 = t('shared.statistics')
|
||||||
|
|
||||||
|
@ -386,6 +386,7 @@ de:
|
|||||||
score: Ihre Punktzahl
|
score: Ihre Punktzahl
|
||||||
success_with_outcome: 'Ihr Code wurde erfolgreich bewertet. Ihre Bewertung wurde an %{consumer} übermittelt.'
|
success_with_outcome: 'Ihr Code wurde erfolgreich bewertet. Ihre Bewertung wurde an %{consumer} übermittelt.'
|
||||||
success_without_outcome: Ihr Code wurde erfolgreich bewertet.
|
success_without_outcome: Ihr Code wurde erfolgreich bewertet.
|
||||||
|
do_not_use_backbutton: Benutzen Sie nicht den "Zurück" Button des Browsers, um zu CodeOcean zurück zu kehren. Übungen müssen immer aus dem %{consumer} Kontext gestartet werden.
|
||||||
new:
|
new:
|
||||||
forgot_password: Passwort vergessen?
|
forgot_password: Passwort vergessen?
|
||||||
headline: Anmelden
|
headline: Anmelden
|
||||||
|
@ -407,6 +407,7 @@ en:
|
|||||||
score: Your Score
|
score: Your Score
|
||||||
success_with_outcome: 'Your code has been successfully assessed. Your grade has been transmitted to %{consumer}.'
|
success_with_outcome: 'Your code has been successfully assessed. Your grade has been transmitted to %{consumer}.'
|
||||||
success_without_outcome: Your code has been successfully assessed.
|
success_without_outcome: Your code has been successfully assessed.
|
||||||
|
do_not_use_backbutton: Never use the browser's "Back" button to get back to CodeOcean. Always start an exercise from within %{consumer}.
|
||||||
new:
|
new:
|
||||||
forgot_password: Forgot password?
|
forgot_password: Forgot password?
|
||||||
headline: Sign In
|
headline: Sign In
|
||||||
|
Reference in New Issue
Block a user