Add transmitted score to remoteSubmit

This commit is contained in:
Sebastian Serth
2020-11-27 12:26:12 +01:00
parent cd9ab16c4d
commit a60510c97f

View File

@ -21,8 +21,11 @@ class RemoteEvaluationController < ApplicationController
def submit
result = create_and_score_submission("remoteSubmit")
status = 201
if @submission.present?
current_user = @submission.user
score_achieved_percentage = @submission.normalized_score * 100
if !current_user.nil? && lti_outcome_service?(@submission.exercise_id, current_user.id)
lti_response = send_score(@submission)
@ -36,14 +39,11 @@ class RemoteEvaluationController < ApplicationController
end
# ToDo: Delete LTI parameters?
else
result = {message: "Your submission was successfully scored with #{@submission.normalized_score * 100}%. However, your score could not be sent to the e-Learning platform. Please reopen the exercise through the e-Learning platform and try again.", status: 410}
end
result = {message: "Your submission was successfully scored with #{score_achieved_percentage}%. However, your score could not be sent to the e-Learning platform. Please reopen the exercise through the e-Learning platform and try again.", status: 410}
end
status = if result.is_a?(Hash) && result.has_key?(:status)
result[:status]
else
201
result.merge!({score: score_achieved_percentage})
status = result[:status]
end
render json: result, status: status