Refactor various ruby files
* Insights based on brakeman report
This commit is contained in:
@ -19,7 +19,7 @@ Metrics/ClassLength:
|
|||||||
Max: 600
|
Max: 600
|
||||||
|
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Max: 220
|
Max: 225
|
||||||
|
|
||||||
# It's a very complicated application...
|
# It's a very complicated application...
|
||||||
#
|
#
|
||||||
|
@ -41,7 +41,7 @@ module CodeOcean
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@file = CodeOcean::File.find(params[:id])
|
@file = CodeOcean::File.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
destroy_and_respond(object: @file, path: @file.context)
|
destroy_and_respond(object: @file, path: @file.context)
|
||||||
end
|
end
|
||||||
|
@ -43,8 +43,7 @@ class CodeharborLinksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_codeharbor_link
|
def set_codeharbor_link
|
||||||
@codeharbor_link = CodeharborLink.find(params[:id])
|
@codeharbor_link = CodeharborLink.find_by(id: params[:id])
|
||||||
@codeharbor_link.user = current_user
|
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
# GET /comments.json
|
# GET /comments.json
|
||||||
def index
|
def index
|
||||||
file = CodeOcean::File.find(params[:file_id])
|
file = CodeOcean::File.find_by(id: params[:file_id])
|
||||||
# there might be no submission yet, so dont use find
|
# there might be no submission yet, so dont use find
|
||||||
submission = Submission.find_by(id: file.context_id)
|
submission = Submission.find_by(id: file.context_id)
|
||||||
if submission
|
if submission
|
||||||
@ -38,7 +38,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
if @comment.save
|
if @comment.save
|
||||||
if comment_params[:request_id]
|
if comment_params[:request_id]
|
||||||
request_for_comment = RequestForComment.find(comment_params[:request_id])
|
request_for_comment = RequestForComment.find_by(id: comment_params[:request_id])
|
||||||
send_mail_to_author @comment, request_for_comment
|
send_mail_to_author @comment, request_for_comment
|
||||||
send_mail_to_subscribers @comment, request_for_comment
|
send_mail_to_subscribers @comment, request_for_comment
|
||||||
end
|
end
|
||||||
@ -71,7 +71,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_comment
|
def set_comment
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment_params_for_update
|
def comment_params_for_update
|
||||||
|
@ -90,11 +90,11 @@ class CommunitySolutionsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_community_solution
|
def set_community_solution
|
||||||
@community_solution = CommunitySolution.find(params[:id])
|
@community_solution = CommunitySolution.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_community_solution_lock
|
def set_community_solution_lock
|
||||||
@community_solution_lock = CommunitySolutionLock.find(params[:lock_id])
|
@community_solution_lock = CommunitySolutionLock.find_by(id: params[:lock_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_exercise_and_submission
|
def set_exercise_and_submission
|
||||||
|
@ -129,12 +129,7 @@ module RedirectBehavior
|
|||||||
lti_parameters_id: session[:lti_parameters_id]
|
lti_parameters_id: session[:lti_parameters_id]
|
||||||
)
|
)
|
||||||
|
|
||||||
lti_parameter = LtiParameter.where(external_users_id: @submission.user_id,
|
path = lti_return_path(submission_id: @submission.id)
|
||||||
exercises_id: @submission.exercise_id).last
|
|
||||||
|
|
||||||
path = lti_return_path(submission_id: @submission.id,
|
|
||||||
url: consumer_return_url(build_tool_provider(consumer: @submission.user.consumer,
|
|
||||||
parameters: lti_parameter&.lti_parameters)))
|
|
||||||
clear_lti_session_data(@submission.exercise_id, @submission.user_id)
|
clear_lti_session_data(@submission.exercise_id, @submission.user_id)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to(path) }
|
format.html { redirect_to(path) }
|
||||||
|
@ -38,7 +38,7 @@ class ConsumersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_consumer
|
def set_consumer
|
||||||
@consumer = Consumer.find(params[:id])
|
@consumer = Consumer.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_consumer
|
private :set_consumer
|
||||||
|
@ -86,7 +86,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_error_template_attribute
|
def set_error_template_attribute
|
||||||
@error_template_attribute = ErrorTemplateAttribute.find(params[:id])
|
@error_template_attribute = ErrorTemplateAttribute.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_template_attribute_params
|
def error_template_attribute_params
|
||||||
|
@ -77,7 +77,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
def add_attribute
|
def add_attribute
|
||||||
authorize!
|
authorize!
|
||||||
@error_template.error_template_attributes << ErrorTemplateAttribute.find(params['error_template_attribute_id'])
|
@error_template.error_template_attributes << ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @error_template }
|
format.html { redirect_to @error_template }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
@ -86,7 +86,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
def remove_attribute
|
def remove_attribute
|
||||||
authorize!
|
authorize!
|
||||||
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find(params['error_template_attribute_id']))
|
@error_template.error_template_attributes.delete(ErrorTemplateAttribute.find_by(id: params[:error_template_attribute_id]))
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to @error_template }
|
format.html { redirect_to @error_template }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
@ -97,7 +97,7 @@ class ErrorTemplatesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_error_template
|
def set_error_template
|
||||||
@error_template = ErrorTemplate.find(params[:id])
|
@error_template = ErrorTemplate.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def error_template_params
|
def error_template_params
|
||||||
|
@ -141,7 +141,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
private :set_docker_images
|
private :set_docker_images
|
||||||
|
|
||||||
def set_execution_environment
|
def set_execution_environment
|
||||||
@execution_environment = ExecutionEnvironment.find(params[:id])
|
@execution_environment = ExecutionEnvironment.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_execution_environment
|
private :set_execution_environment
|
||||||
@ -158,7 +158,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
|||||||
|
|
||||||
def show
|
def show
|
||||||
if @execution_environment.testing_framework?
|
if @execution_environment.testing_framework?
|
||||||
@testing_framework_adapter = Kernel.const_get(@execution_environment.testing_framework)
|
@testing_framework_adapter = TestingFrameworkAdapter.descendants.find {|klass| klass.name == @execution_environment.testing_framework }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class ExerciseCollectionsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def set_exercise_collection
|
def set_exercise_collection
|
||||||
@exercise_collection = ExerciseCollection.find(params[:id])
|
@exercise_collection = ExerciseCollection.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ class ExercisesController < ApplicationController
|
|||||||
def authorize!
|
def authorize!
|
||||||
authorize(@exercise || @exercises)
|
authorize(@exercise || @exercises)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :authorize!
|
private :authorize!
|
||||||
|
|
||||||
def max_intervention_count_per_day
|
def max_intervention_count_per_day
|
||||||
@ -39,7 +40,7 @@ class ExercisesController < ApplicationController
|
|||||||
@exercises = Exercise.all
|
@exercises = Exercise.all
|
||||||
authorize!
|
authorize!
|
||||||
@exercises = params[:exercises].values.map do |exercise_params|
|
@exercises = params[:exercises].values.map do |exercise_params|
|
||||||
exercise = Exercise.find(exercise_params.delete(:id))
|
exercise = Exercise.find_by(id: exercise_params.delete(:id))
|
||||||
exercise.update(exercise_params)
|
exercise.update(exercise_params)
|
||||||
exercise
|
exercise
|
||||||
end
|
end
|
||||||
@ -50,7 +51,7 @@ class ExercisesController < ApplicationController
|
|||||||
exercise = @exercise.duplicate(public: false, token: nil, user: current_user)
|
exercise = @exercise.duplicate(public: false, token: nil, user: current_user)
|
||||||
exercise.send(:generate_token)
|
exercise.send(:generate_token)
|
||||||
if exercise.save
|
if exercise.save
|
||||||
redirect_to(exercise, notice: t('shared.object_cloned', model: Exercise.model_name.human))
|
redirect_to(exercise_path(exercise), notice: t('shared.object_cloned', model: Exercise.model_name.human))
|
||||||
else
|
else
|
||||||
flash[:danger] = t('shared.message_failure')
|
flash[:danger] = t('shared.message_failure')
|
||||||
redirect_to(@exercise)
|
redirect_to(@exercise)
|
||||||
@ -66,6 +67,7 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
subpaths.flatten.uniq
|
subpaths.flatten.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
private :collect_paths
|
private :collect_paths
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@ -192,12 +194,14 @@ class ExercisesController < ApplicationController
|
|||||||
api_key = authorization_header&.split(' ')&.second
|
api_key = authorization_header&.split(' ')&.second
|
||||||
user_by_codeharbor_token(api_key)
|
user_by_codeharbor_token(api_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :user_from_api_key
|
private :user_from_api_key
|
||||||
|
|
||||||
def user_by_codeharbor_token(api_key)
|
def user_by_codeharbor_token(api_key)
|
||||||
link = CodeharborLink.find_by(api_key: api_key)
|
link = CodeharborLink.find_by(api_key: api_key)
|
||||||
link&.user
|
link&.user
|
||||||
end
|
end
|
||||||
|
|
||||||
private :user_by_codeharbor_token
|
private :user_by_codeharbor_token
|
||||||
|
|
||||||
def exercise_params
|
def exercise_params
|
||||||
@ -225,6 +229,7 @@ class ExercisesController < ApplicationController
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :exercise_params
|
private :exercise_params
|
||||||
|
|
||||||
def handle_file_uploads
|
def handle_file_uploads
|
||||||
@ -241,6 +246,7 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :handle_file_uploads
|
private :handle_file_uploads
|
||||||
|
|
||||||
def handle_exercise_tips
|
def handle_exercise_tips
|
||||||
@ -258,6 +264,7 @@ class ExercisesController < ApplicationController
|
|||||||
redirect_to(edit_exercise_path(@exercise))
|
redirect_to(edit_exercise_path(@exercise))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :handle_exercise_tips
|
private :handle_exercise_tips
|
||||||
|
|
||||||
def update_exercise_tips(exercise_tips, parent_exercise_tip_id, rank)
|
def update_exercise_tips(exercise_tips, parent_exercise_tip_id, rank)
|
||||||
@ -283,6 +290,7 @@ class ExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
private :update_exercise_tips
|
private :update_exercise_tips
|
||||||
|
|
||||||
def implement
|
def implement
|
||||||
@ -348,6 +356,7 @@ class ExercisesController < ApplicationController
|
|||||||
@course_token = '702cbd2a-c84c-4b37-923a-692d7d1532d0'
|
@course_token = '702cbd2a-c84c-4b37-923a-692d7d1532d0'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_course_token
|
private :set_course_token
|
||||||
|
|
||||||
def set_available_tips
|
def set_available_tips
|
||||||
@ -374,13 +383,14 @@ class ExercisesController < ApplicationController
|
|||||||
# Return an array with top-level tips
|
# Return an array with top-level tips
|
||||||
@tips = nested_tips.values.select {|tip| tip.parent_exercise_tip_id.nil? }
|
@tips = nested_tips.values.select {|tip| tip.parent_exercise_tip_id.nil? }
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_available_tips
|
private :set_available_tips
|
||||||
|
|
||||||
def working_times
|
def working_times
|
||||||
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user)
|
working_time_accumulated = @exercise.accumulated_working_time_for_only(current_user)
|
||||||
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
|
working_time_75_percentile = @exercise.get_quantiles([0.75]).first
|
||||||
render(json: {working_time_75_percentile: working_time_75_percentile,
|
render(json: {working_time_75_percentile: working_time_75_percentile,
|
||||||
working_time_accumulated: working_time_accumulated})
|
working_time_accumulated: working_time_accumulated})
|
||||||
end
|
end
|
||||||
|
|
||||||
def intervention
|
def intervention
|
||||||
@ -401,8 +411,9 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
search_text = params[:search_text]
|
search_text = params[:search_text]
|
||||||
search = Search.new(user: current_user, exercise: @exercise, search: search_text)
|
search = Search.new(user: current_user, exercise: @exercise, search: search_text)
|
||||||
|
|
||||||
begin search.save
|
begin
|
||||||
render(json: {success: 'true'})
|
search.save
|
||||||
|
render(json: {success: 'true'})
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
render(json: {success: 'false', error: "could not save search: #{$ERROR_INFO}"})
|
render(json: {success: 'false', error: "could not save search: #{$ERROR_INFO}"})
|
||||||
end
|
end
|
||||||
@ -424,25 +435,29 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
def set_execution_environments
|
def set_execution_environments
|
||||||
@execution_environments = ExecutionEnvironment.all.order(:name)
|
@execution_environments = ExecutionEnvironment.all.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_execution_environments
|
private :set_execution_environments
|
||||||
|
|
||||||
def set_exercise_and_authorize
|
def set_exercise_and_authorize
|
||||||
@exercise = Exercise.find(params[:id])
|
@exercise = Exercise.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_exercise_and_authorize
|
private :set_exercise_and_authorize
|
||||||
|
|
||||||
def set_external_user_and_authorize
|
def set_external_user_and_authorize
|
||||||
if params[:external_user_id]
|
if params[:external_user_id]
|
||||||
@external_user = ExternalUser.find(params[:external_user_id])
|
@external_user = ExternalUser.find_by(id: params[:external_user_id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_external_user_and_authorize
|
private :set_external_user_and_authorize
|
||||||
|
|
||||||
def set_file_types
|
def set_file_types
|
||||||
@file_types = FileType.all.order(:name)
|
@file_types = FileType.all.order(:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
private :set_file_types
|
private :set_file_types
|
||||||
|
|
||||||
def collect_set_and_unset_exercise_tags
|
def collect_set_and_unset_exercise_tags
|
||||||
@ -452,9 +467,10 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
checked_tags = checked_exercise_tags.collect(&:tag).to_set
|
checked_tags = checked_exercise_tags.collect(&:tag).to_set
|
||||||
unchecked_tags = Tag.all.to_set.subtract checked_tags
|
unchecked_tags = Tag.all.to_set.subtract checked_tags
|
||||||
@exercise_tags = checked_exercise_tags + unchecked_tags.collect do |tag|
|
@exercise_tags = checked_exercise_tags + unchecked_tags.collect do |tag|
|
||||||
ExerciseTag.new(exercise: @exercise, tag: tag)
|
ExerciseTag.new(exercise: @exercise, tag: tag)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :collect_set_and_unset_exercise_tags
|
private :collect_set_and_unset_exercise_tags
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@ -468,20 +484,24 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
def statistics
|
def statistics
|
||||||
# Show general statistic page for specific exercise
|
# Show general statistic page for specific exercise
|
||||||
user_statistics = {'InternalUser' => {}, 'ExternalUser' => {}}
|
user_statistics = {'InternalUser' => {}, 'ExternalUser' => {}}
|
||||||
additional_filter = if policy(@exercise).detailed_statistics?
|
|
||||||
''
|
query = Submission.select('user_id, user_type, MAX(score) AS maximum_score, COUNT(id) AS runs')
|
||||||
elsif !policy(@exercise).detailed_statistics? && current_user.study_groups.count.positive?
|
.where(exercise_id: @exercise.id)
|
||||||
"AND study_group_id IN (#{current_user.study_groups.pluck(:id).join(', ')}) AND cause = 'submit'"
|
.group('user_id, user_type')
|
||||||
else
|
|
||||||
# e.g. internal user without any study groups, show no submissions
|
query = if policy(@exercise).detailed_statistics?
|
||||||
'AND FALSE'
|
query
|
||||||
end
|
elsif !policy(@exercise).detailed_statistics? && current_user.study_groups.count.positive?
|
||||||
query = "SELECT user_id, user_type, MAX(score) AS maximum_score, COUNT(id) AS runs
|
query.where(study_groups: current_user.study_groups.pluck(:id), cause: 'submit')
|
||||||
FROM submissions WHERE exercise_id = #{@exercise.id} #{additional_filter}
|
else
|
||||||
GROUP BY user_id, user_type;"
|
# e.g. internal user without any study groups, show no submissions
|
||||||
ApplicationRecord.connection.execute(query).each do |tuple|
|
query.where('false')
|
||||||
|
end
|
||||||
|
|
||||||
|
query.each do |tuple|
|
||||||
user_statistics[tuple['user_type']][tuple['user_id'].to_i] = tuple
|
user_statistics[tuple['user_type']][tuple['user_id'].to_i] = tuple
|
||||||
end
|
end
|
||||||
|
|
||||||
render locals: {
|
render locals: {
|
||||||
user_statistics: user_statistics,
|
user_statistics: user_statistics,
|
||||||
}
|
}
|
||||||
@ -554,6 +574,7 @@ working_time_accumulated: working_time_accumulated})
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private :transmit_lti_score
|
private :transmit_lti_score
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@ -15,7 +15,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = ExternalUser.find(params[:id])
|
@user = ExternalUser.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def statistics
|
def statistics
|
||||||
@user = ExternalUser.find(params[:id])
|
@user = ExternalUser.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
statistics = {}
|
statistics = {}
|
||||||
@ -73,7 +73,7 @@ class ExternalUsersController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def tag_statistics
|
def tag_statistics
|
||||||
@user = ExternalUser.find(params[:id])
|
@user = ExternalUser.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
statistics = []
|
statistics = []
|
||||||
|
@ -87,7 +87,7 @@ class FileTemplatesController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_file_template
|
def set_file_template
|
||||||
@file_template = FileTemplate.find(params[:id])
|
@file_template = FileTemplate.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_template_params
|
def file_template_params
|
||||||
|
@ -51,7 +51,7 @@ class FileTypesController < ApplicationController
|
|||||||
private :set_editor_modes
|
private :set_editor_modes
|
||||||
|
|
||||||
def set_file_type
|
def set_file_type
|
||||||
@file_type = FileType.find(params[:id])
|
@file_type = FileType.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_file_type
|
private :set_file_type
|
||||||
|
@ -121,7 +121,7 @@ class InternalUsersController < ApplicationController
|
|||||||
private :set_up_password
|
private :set_up_password
|
||||||
|
|
||||||
def set_user
|
def set_user
|
||||||
@user = InternalUser.find(params[:id])
|
@user = InternalUser.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_user
|
private :set_user
|
||||||
|
@ -15,7 +15,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
user: current_user)
|
user: current_user)
|
||||||
proxy_exercise.send(:generate_token)
|
proxy_exercise.send(:generate_token)
|
||||||
if proxy_exercise.save
|
if proxy_exercise.save
|
||||||
redirect_to(proxy_exercise, notice: t('shared.object_cloned', model: ProxyExercise.model_name.human))
|
redirect_to(proxy_exercise_path(proxy_exercise), notice: t('shared.object_cloned', model: ProxyExercise.model_name.human))
|
||||||
else
|
else
|
||||||
flash[:danger] = t('shared.message_failure')
|
flash[:danger] = t('shared.message_failure')
|
||||||
redirect_to(@proxy_exercise)
|
redirect_to(@proxy_exercise)
|
||||||
@ -24,7 +24,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
myparams = proxy_exercise_params
|
myparams = proxy_exercise_params
|
||||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
||||||
@proxy_exercise = ProxyExercise.new(myparams)
|
@proxy_exercise = ProxyExercise.new(myparams)
|
||||||
authorize!
|
authorize!
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_exercise_and_authorize
|
def set_exercise_and_authorize
|
||||||
@proxy_exercise = ProxyExercise.find(params[:id])
|
@proxy_exercise = ProxyExercise.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_exercise_and_authorize
|
private :set_exercise_and_authorize
|
||||||
@ -78,7 +78,7 @@ class ProxyExercisesController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
myparams = proxy_exercise_params
|
myparams = proxy_exercise_params
|
||||||
myparams[:exercises] = Exercise.find(myparams[:exercise_ids].compact_blank)
|
myparams[:exercises] = Exercise.find_by(id: myparams[:exercise_ids].compact_blank)
|
||||||
update_and_respond(object: @proxy_exercise, params: myparams)
|
update_and_respond(object: @proxy_exercise, params: myparams)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -58,7 +58,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
|
|
||||||
# GET /exercises/:id/request_for_comments
|
# GET /exercises/:id/request_for_comments
|
||||||
def rfcs_for_exercise
|
def rfcs_for_exercise
|
||||||
exercise = Exercise.find(params[:exercise_id])
|
exercise = Exercise.find_by(id: params[:exercise_id])
|
||||||
@search = RequestForComment
|
@search = RequestForComment
|
||||||
.with_last_activity
|
.with_last_activity
|
||||||
.where(exercise_id: exercise.id)
|
.where(exercise_id: exercise.id)
|
||||||
@ -141,7 +141,7 @@ class RequestForCommentsController < ApplicationController
|
|||||||
|
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_request_for_comment
|
def set_request_for_comment
|
||||||
@request_for_comment = RequestForComment.find(params[:id])
|
@request_for_comment = RequestForComment.find_by(id: params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def request_for_comment_params
|
def request_for_comment_params
|
||||||
|
@ -24,7 +24,7 @@ class SessionsController < ApplicationController
|
|||||||
store_lti_session_data(consumer: @consumer, parameters: params)
|
store_lti_session_data(consumer: @consumer, parameters: params)
|
||||||
store_nonce(params[:oauth_nonce])
|
store_nonce(params[:oauth_nonce])
|
||||||
if params[:custom_redirect_target]
|
if params[:custom_redirect_target]
|
||||||
redirect_to(params[:custom_redirect_target])
|
redirect_to(URI.parse(params[:custom_redirect_target].to_s).path)
|
||||||
else
|
else
|
||||||
redirect_to(implement_exercise_path(@exercise),
|
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",
|
||||||
@ -42,7 +42,11 @@ class SessionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy_through_lti
|
def destroy_through_lti
|
||||||
@submission = Submission.find(params[:submission_id])
|
@submission = Submission.find_by(id: params[:submission_id])
|
||||||
|
authorize(@submission, :show?)
|
||||||
|
lti_parameter = LtiParameter.where(external_users_id: @submission.user_id, exercises_id: @submission.exercise_id).last
|
||||||
|
@url = consumer_return_url(build_tool_provider(consumer: @submission.user.consumer, parameters: lti_parameter&.lti_parameters))
|
||||||
|
|
||||||
clear_lti_session_data(@submission.exercise_id, @submission.user_id)
|
clear_lti_session_data(@submission.exercise_id, @submission.user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class StudyGroupsController < ApplicationController
|
|||||||
def update
|
def update
|
||||||
myparams = study_group_params
|
myparams = study_group_params
|
||||||
myparams[:external_users] =
|
myparams[:external_users] =
|
||||||
StudyGroupMembership.find(myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
StudyGroupMembership.find_by(id: myparams[:study_group_membership_ids].compact_blank).map(&:user)
|
||||||
myparams.delete(:study_group_membership_ids)
|
myparams.delete(:study_group_membership_ids)
|
||||||
update_and_respond(object: @study_group, params: myparams)
|
update_and_respond(object: @study_group, params: myparams)
|
||||||
end
|
end
|
||||||
@ -38,7 +38,7 @@ class StudyGroupsController < ApplicationController
|
|||||||
private :study_group_params
|
private :study_group_params
|
||||||
|
|
||||||
def set_group
|
def set_group
|
||||||
@study_group = StudyGroup.find(params[:id])
|
@study_group = StudyGroup.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_group
|
private :set_group
|
||||||
|
@ -373,7 +373,7 @@ class SubmissionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_submission
|
def set_submission
|
||||||
@submission = Submission.find(params[:id])
|
@submission = Submission.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class SubscriptionsController < ApplicationController
|
|||||||
# DELETE /subscriptions/1
|
# DELETE /subscriptions/1
|
||||||
# DELETE /subscriptions/1.json
|
# DELETE /subscriptions/1.json
|
||||||
def destroy
|
def destroy
|
||||||
@subscription = Subscription.find(params[:id])
|
@subscription = Subscription.find_by(id: params[:id])
|
||||||
rescue StandardError
|
rescue StandardError
|
||||||
skip_authorization
|
skip_authorization
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
@ -47,7 +47,7 @@ class SubscriptionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_subscription
|
def set_subscription
|
||||||
@subscription = Subscription.find(params[:id])
|
@subscription = Subscription.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_subscription
|
private :set_subscription
|
||||||
|
@ -38,7 +38,7 @@ class TagsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_tag
|
def set_tag
|
||||||
@tag = Tag.find(params[:id])
|
@tag = Tag.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_tag
|
private :set_tag
|
||||||
|
@ -44,7 +44,7 @@ class TipsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_tip
|
def set_tip
|
||||||
@tip = Tip.find(params[:id])
|
@tip = Tip.find_by(id: params[:id])
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
private :set_tip
|
private :set_tip
|
||||||
|
@ -25,7 +25,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
def create
|
def create
|
||||||
Sentry.set_extras(params: uef_params)
|
Sentry.set_extras(params: uef_params)
|
||||||
|
|
||||||
@exercise = Exercise.find(uef_params[:exercise_id])
|
@exercise = Exercise.find_by(id: uef_params[:exercise_id])
|
||||||
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
|
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user_id: current_user.id).first
|
||||||
submission = begin
|
submission = begin
|
||||||
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
current_user.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
|
||||||
@ -67,7 +67,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
else
|
else
|
||||||
params[:user_exercise_feedback][:exercise_id]
|
params[:user_exercise_feedback][:exercise_id]
|
||||||
end
|
end
|
||||||
@exercise = Exercise.find(exercise_id)
|
@exercise = Exercise.find_by(id: exercise_id)
|
||||||
@uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise)
|
@uef = UserExerciseFeedback.find_or_initialize_by(user: current_user, exercise: @exercise)
|
||||||
authorize!
|
authorize!
|
||||||
end
|
end
|
||||||
@ -105,7 +105,7 @@ class UserExerciseFeedbacksController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_user_exercise_feedback
|
def set_user_exercise_feedback
|
||||||
@uef = UserExerciseFeedback.find(params[:id])
|
@uef = UserExerciseFeedback.find_by(id: params[:id])
|
||||||
@exercise = @uef.exercise
|
@exercise = @uef.exercise
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
module StatisticsHelper
|
module StatisticsHelper
|
||||||
WORKING_TIME_DELTA_IN_SECONDS = 5.minutes
|
WORKING_TIME_DELTA_IN_SECONDS = 5.minutes
|
||||||
WORKING_TIME_DELTA_IN_SQL_INTERVAL = "'0:05:00'" # yes, a string with quotes
|
WORKING_TIME_DELTA_IN_SQL_INTERVAL = ActiveRecord::Base.sanitize_sql("'0:05:00'") # yes, a string with quotes
|
||||||
|
|
||||||
def statistics_data
|
def statistics_data
|
||||||
[
|
[
|
||||||
@ -174,6 +174,8 @@ module StatisticsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ranged_rfc_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)
|
def ranged_rfc_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)
|
||||||
|
interval = ActiveRecord::Base.sanitize_sql(interval)
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
key: 'rfcs',
|
key: 'rfcs',
|
||||||
@ -209,6 +211,8 @@ module StatisticsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def ranged_user_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)
|
def ranged_user_data(interval = 'year', from = DateTime.new(0), to = DateTime.now)
|
||||||
|
interval = ActiveRecord::Base.sanitize_sql(interval)
|
||||||
|
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
key: 'active',
|
key: 'active',
|
||||||
|
@ -103,7 +103,7 @@ class Exercise < ApplicationRecord
|
|||||||
(created_at - lag(created_at) over (PARTITION BY user_id, exercise_id
|
(created_at - lag(created_at) over (PARTITION BY user_id, exercise_id
|
||||||
ORDER BY created_at)) AS working_time
|
ORDER BY created_at)) AS working_time
|
||||||
FROM submissions
|
FROM submissions
|
||||||
WHERE exercise_id=#{id}) AS foo) AS bar
|
WHERE exercise_id=#{self.class.sanitize_sql(id)}) AS foo) AS bar
|
||||||
GROUP BY user_id, user_type
|
GROUP BY user_id, user_type
|
||||||
"
|
"
|
||||||
end
|
end
|
||||||
@ -118,7 +118,7 @@ class Exercise < ApplicationRecord
|
|||||||
(created_at - lag(created_at) over (PARTITION BY submissions.user_type, submissions.user_id, exercise_id
|
(created_at - lag(created_at) over (PARTITION BY submissions.user_type, submissions.user_id, exercise_id
|
||||||
ORDER BY created_at)) AS working_time
|
ORDER BY created_at)) AS working_time
|
||||||
FROM submissions
|
FROM submissions
|
||||||
WHERE exercise_id = #{exercise_id} AND study_group_id = #{study_group_id} #{additional_filter}),
|
WHERE exercise_id = #{self.class.sanitize_sql(exercise_id)} AND study_group_id = #{self.class.sanitize_sql(study_group_id)} #{self.class.sanitize_sql(additional_filter)}),
|
||||||
working_time_with_deltas_ignored AS (
|
working_time_with_deltas_ignored AS (
|
||||||
SELECT user_id,
|
SELECT user_id,
|
||||||
user_type,
|
user_type,
|
||||||
@ -251,7 +251,7 @@ class Exercise < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def get_quantiles(quantiles)
|
def get_quantiles(quantiles)
|
||||||
quantiles_str = "[#{quantiles.join(',')}]"
|
quantiles_str = self.class.sanitize_sql("[#{quantiles.join(',')}]")
|
||||||
result = ActiveRecord::Base.transaction do
|
result = ActiveRecord::Base.transaction do
|
||||||
self.class.connection.execute("
|
self.class.connection.execute("
|
||||||
SET LOCAL intervalstyle = 'iso_8601';
|
SET LOCAL intervalstyle = 'iso_8601';
|
||||||
@ -263,7 +263,7 @@ class Exercise < ApplicationRecord
|
|||||||
Max(score) AS max_score,
|
Max(score) AS max_score,
|
||||||
(created_at - Lag(created_at) OVER (partition BY user_id, exercise_id ORDER BY created_at)) AS working_time
|
(created_at - Lag(created_at) OVER (partition BY user_id, exercise_id ORDER BY created_at)) AS working_time
|
||||||
FROM submissions
|
FROM submissions
|
||||||
WHERE exercise_id = #{id}
|
WHERE exercise_id = #{self.class.sanitize_sql(id)}
|
||||||
AND user_type = 'ExternalUser'
|
AND user_type = 'ExternalUser'
|
||||||
GROUP BY user_id,
|
GROUP BY user_id,
|
||||||
id,
|
id,
|
||||||
@ -273,7 +273,7 @@ class Exercise < ApplicationRecord
|
|||||||
Sum(weight) AS max_points
|
Sum(weight) AS max_points
|
||||||
FROM files
|
FROM files
|
||||||
WHERE context_type = 'Exercise'
|
WHERE context_type = 'Exercise'
|
||||||
AND context_id = #{id}
|
AND context_id = #{self.class.sanitize_sql(id)}
|
||||||
AND role IN ('teacher_defined_test', 'teacher_defined_linter')
|
AND role IN ('teacher_defined_test', 'teacher_defined_linter')
|
||||||
GROUP BY context_id),
|
GROUP BY context_id),
|
||||||
-- filter for rows containing max points
|
-- filter for rows containing max points
|
||||||
@ -387,7 +387,7 @@ class Exercise < ApplicationRecord
|
|||||||
self.class.connection.execute("
|
self.class.connection.execute("
|
||||||
SELECT avg(working_time) as average_time
|
SELECT avg(working_time) as average_time
|
||||||
FROM
|
FROM
|
||||||
(#{user_working_time_query}) AS baz;
|
(#{self.class.sanitize_sql(user_working_time_query)}) AS baz;
|
||||||
").first['average_time']
|
").first['average_time']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,27 +22,6 @@ class RequestForComment < ApplicationRecord
|
|||||||
|
|
||||||
# after_save :trigger_rfc_action_cable
|
# after_save :trigger_rfc_action_cable
|
||||||
|
|
||||||
# not used right now, finds the last submission for the respective user and exercise.
|
|
||||||
# might be helpful to check whether the exercise has been solved in the meantime.
|
|
||||||
def last_submission
|
|
||||||
Submission.find_by_sql(" select * from submissions
|
|
||||||
where exercise_id = #{exercise_id} AND
|
|
||||||
user_id = #{user_id}
|
|
||||||
order by created_at desc
|
|
||||||
limit 1").first
|
|
||||||
end
|
|
||||||
|
|
||||||
# not used any longer, since we directly saved the submission_id now.
|
|
||||||
# Was used before that to determine the submission belonging to the request_for_comment.
|
|
||||||
def last_submission_before_creation
|
|
||||||
Submission.find_by_sql(" select * from submissions
|
|
||||||
where exercise_id = #{exercise_id} AND
|
|
||||||
user_id = #{user_id} AND
|
|
||||||
'#{created_at.localtime}' > created_at
|
|
||||||
order by created_at desc
|
|
||||||
limit 1").first
|
|
||||||
end
|
|
||||||
|
|
||||||
def comments_count
|
def comments_count
|
||||||
submission.files.sum {|file| file.comments.size }
|
submission.files.sum {|file| file.comments.size }
|
||||||
end
|
end
|
||||||
@ -89,7 +68,7 @@ class RequestForComment < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
def last_per_user(count = 5)
|
def last_per_user(count = 5)
|
||||||
from("(#{row_number_user_sql}) as request_for_comments")
|
from(row_number_user_sql, :request_for_comments)
|
||||||
.where('row_number <= ?', count)
|
.where('row_number <= ?', count)
|
||||||
.group('request_for_comments.id, request_for_comments.user_id, request_for_comments.user_type, ' \
|
.group('request_for_comments.id, request_for_comments.user_id, request_for_comments.user_type, ' \
|
||||||
'request_for_comments.exercise_id, request_for_comments.file_id, request_for_comments.question, ' \
|
'request_for_comments.exercise_id, request_for_comments.file_id, request_for_comments.question, ' \
|
||||||
@ -101,7 +80,7 @@ class RequestForComment < ApplicationRecord
|
|||||||
private
|
private
|
||||||
|
|
||||||
def row_number_user_sql
|
def row_number_user_sql
|
||||||
select('id, user_id, user_type, exercise_id, file_id, question, created_at, updated_at, solved, full_score_reached, submission_id, row_number() OVER (PARTITION BY user_id, user_type ORDER BY created_at DESC) as row_number').to_sql
|
select('id, user_id, user_type, exercise_id, file_id, question, created_at, updated_at, solved, full_score_reached, submission_id, row_number() OVER (PARTITION BY user_id, user_type ORDER BY created_at DESC) as row_number')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
- if model = Kernel.const_get(controller_path.classify) rescue nil
|
- model = controller_path.classify.constantize rescue nil
|
||||||
|
- if model
|
||||||
- object = model.find_by(id: params[:id])
|
- object = model.find_by(id: params[:id])
|
||||||
- if model.try(:nested_resource?)
|
- if model.try(:nested_resource?)
|
||||||
- root_element = model.model_name.human(count: 2)
|
- root_element = model.model_name.human(count: 2)
|
||||||
|
@ -4,4 +4,4 @@ li.nav-item.dropdown
|
|||||||
span.caret
|
span.caret
|
||||||
ul.dropdown-menu.p-0.mt-1 role='menu'
|
ul.dropdown-menu.p-0.mt-1 role='menu'
|
||||||
- I18n.available_locales.sort_by { |locale| t("locales.#{locale}") }.each do |locale|
|
- I18n.available_locales.sort_by { |locale| t("locales.#{locale}") }.each do |locale|
|
||||||
li = link_to(t("locales.#{locale}"), url_for(params.permit!.merge(locale: locale)), 'data-turbolinks' => "false", class: 'dropdown-item')
|
li = link_to(t("locales.#{locale}"), url_for(request.query_parameters.merge(locale: locale)), 'data-turbolinks' => "false", class: 'dropdown-item')
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
h1 = t('.headline')
|
h1 = t('.headline')
|
||||||
|
|
||||||
|
- consumer = @submission.user.consumer
|
||||||
|
|
||||||
p
|
p
|
||||||
== t(".success_#{params[:outcome] ? 'with' : 'without'}_outcome", consumer: @consumer)
|
= t(".success_#{consumer ? 'with' : 'without'}_outcome", consumer: consumer)
|
||||||
==< t(".finished_#{@consumer ? 'with' : 'without'}_consumer", consumer: @consumer, url: params[:url])
|
==< t(".finished_#{consumer ? 'with' : 'without'}_consumer", consumer: h(consumer.name), url: @url)
|
||||||
==< t(".do_not_use_backbutton", consumer: @consumer)
|
=< t(".do_not_use_backbutton")
|
||||||
|
|
||||||
h2 = t('shared.statistics')
|
h2 = t('shared.statistics')
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ Rails.application.configure do
|
|||||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||||
|
|
||||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
# config.force_ssl = true
|
config.force_ssl = true
|
||||||
|
|
||||||
# Include generic and useful information about system operation, but avoid logging too much
|
# Include generic and useful information about system operation, but avoid logging too much
|
||||||
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
# information to avoid inadvertent exposure of personally identifiable information (PII).
|
||||||
|
@ -60,7 +60,7 @@ Rails.application.configure do
|
|||||||
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
||||||
|
|
||||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||||
# config.force_ssl = true
|
config.force_ssl = true
|
||||||
|
|
||||||
# Set to :debug to see everything in the log.
|
# Set to :debug to see everything in the log.
|
||||||
config.log_level = :info
|
config.log_level = :info
|
||||||
|
@ -23,7 +23,7 @@ class Assessor
|
|||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
if options[:execution_environment].testing_framework?
|
if options[:execution_environment].testing_framework?
|
||||||
@testing_framework_adapter = Kernel.const_get(options[:execution_environment].testing_framework).new
|
@testing_framework_adapter = options[:execution_environment].testing_framework.constantize.new
|
||||||
else
|
else
|
||||||
raise Error.new('No testing framework adapter set!')
|
raise Error.new('No testing framework adapter set!')
|
||||||
end
|
end
|
||||||
|
@ -201,13 +201,14 @@ describe SessionsController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe 'GET #destroy_through_lti' do
|
describe 'GET #destroy_through_lti' do
|
||||||
let(:perform_request) { proc { get :destroy_through_lti, params: {consumer_id: consumer.id, submission_id: submission.id} } }
|
let(:perform_request) { proc { get :destroy_through_lti, params: {submission_id: submission.id} } }
|
||||||
let(:submission) { create(:submission, exercise: create(:dummy)) }
|
let(:submission) { create(:submission, exercise: create(:dummy)) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
# Todo replace session with lti_parameter
|
# Todo replace session with lti_parameter
|
||||||
# Todo create LtiParameter Object
|
# Todo create LtiParameter Object
|
||||||
# session[:lti_parameters] = {}
|
# session[:lti_parameters] = {}
|
||||||
|
allow(controller).to receive(:current_user).and_return(submission.user)
|
||||||
perform_request.call
|
perform_request.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user