Add embed options to disable redirect to either rfcs or feedback

This commit is contained in:
Sebastian Serth
2020-01-15 14:38:52 +01:00
parent a551760965
commit 6d16dfe14d
2 changed files with 16 additions and 14 deletions

View File

@ -173,17 +173,19 @@ module Lti
def set_embedding_options def set_embedding_options
@embed_options = {} @embed_options = {}
[:hide_navbar, %i[hide_navbar
:hide_exercise_description, hide_exercise_description
:disable_run, disable_run
:disable_score, disable_score
:disable_rfc, disable_rfc
:disable_interventions, disable_redirect_to_rfcs
:hide_sidebar, disable_redirect_to_feedback
:read_only, disable_interventions
:hide_test_results, hide_sidebar
:disable_hints, read_only
:disable_download].each do |option| hide_test_results
disable_hints
disable_download].each do |option|
value = params["custom_embed_options_#{option}".to_sym] == 'true' value = params["custom_embed_options_#{option}".to_sym] == 'true'
# Optimize storage and save only those that are true, the session cookie is limited to 4KB # Optimize storage and save only those that are true, the session cookie is limited to 4KB
@embed_options[option] = value if value.present? @embed_options[option] = value if value.present?

View File

@ -466,7 +466,7 @@ class ExercisesController < ApplicationController
# otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.) # otherwise an internal user could be shown a false rfc here, since current_user.id is polymorphic, but only makes sense for external users when used with rfcs.)
# 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? if @submission.redirect_to_feedback? && !@embed_options[:disable_redirect_to_feedback]
redirect_to_user_feedback redirect_to_user_feedback
return return
end end
@ -486,7 +486,7 @@ class ExercisesController < ApplicationController
# else: show open rfc for same exercise if available # else: show open rfc for same exercise if available
rfc = @submission.unsolved_rfc rfc = @submission.unsolved_rfc
unless rfc.nil? unless rfc.nil? || @embed_options[:disable_redirect_to_rfcs] || @embed_options[:disable_rfc]
# set a message that informs the user that his score was perfect and help in RFC is greatly appreciated. # set a message that informs the user that his score was perfect and help in RFC is greatly appreciated.
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc') flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
flash.keep(:notice) flash.keep(:notice)
@ -503,7 +503,7 @@ class ExercisesController < ApplicationController
end end
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? if @exercise.needs_more_feedback? && !@embed_options[:disable_redirect_to_feedback]
redirect_to_user_feedback redirect_to_user_feedback
else else
redirect_to_lti_return_path redirect_to_lti_return_path