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
@embed_options = {}
[:hide_navbar,
:hide_exercise_description,
:disable_run,
:disable_score,
:disable_rfc,
:disable_interventions,
:hide_sidebar,
:read_only,
:hide_test_results,
:disable_hints,
:disable_download].each do |option|
%i[hide_navbar
hide_exercise_description
disable_run
disable_score
disable_rfc
disable_redirect_to_rfcs
disable_redirect_to_feedback
disable_interventions
hide_sidebar
read_only
hide_test_results
disable_hints
disable_download].each do |option|
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
@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.)
# redirect 10 percent pseudorandomly to the feedback page
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
return
end
@ -486,7 +486,7 @@ class ExercisesController < ApplicationController
# else: show open rfc for same exercise if available
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.
flash[:notice] = I18n.t('exercises.submit.full_score_redirect_to_rfc')
flash.keep(:notice)
@ -503,7 +503,7 @@ class ExercisesController < ApplicationController
end
else
# 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
else
redirect_to_lti_return_path