Add user_type
to RemoteEvaluationMappings
This commit is contained in:
@ -15,14 +15,12 @@ class RemoteEvaluationController < ApplicationController
|
|||||||
|
|
||||||
# todo extra: validiere, ob files wirklich zur Übung gehören (wenn allowNewFiles-flag nicht gesetzt ist)
|
# todo extra: validiere, ob files wirklich zur Übung gehören (wenn allowNewFiles-flag nicht gesetzt ist)
|
||||||
if (remote_evaluation_mapping = RemoteEvaluationMapping.find_by(:validation_token => validation_token))
|
if (remote_evaluation_mapping = RemoteEvaluationMapping.find_by(:validation_token => validation_token))
|
||||||
puts remote_evaluation_mapping.exercise_id
|
|
||||||
puts remote_evaluation_mapping.user_id
|
|
||||||
|
|
||||||
_params = remote_evaluation_params.except(:validation_token)
|
_params = remote_evaluation_params.except(:validation_token)
|
||||||
_params[:exercise_id] = remote_evaluation_mapping.exercise_id
|
_params[:exercise_id] = remote_evaluation_mapping.exercise_id
|
||||||
_params[:user_id] = remote_evaluation_mapping.user_id
|
_params[:user_id] = remote_evaluation_mapping.user_id
|
||||||
_params[:cause] = "remoteAssess"
|
_params[:cause] = "remoteAssess"
|
||||||
_params[:user_type] = "ExternalUser"
|
_params[:user_type] = remote_evaluation_mapping.user_type
|
||||||
|
|
||||||
@submission = Submission.create(_params)
|
@submission = Submission.create(_params)
|
||||||
render json: score_submission(@submission)
|
render json: score_submission(@submission)
|
||||||
|
@ -398,13 +398,13 @@ class SubmissionsController < ApplicationController
|
|||||||
private :with_server_sent_events
|
private :with_server_sent_events
|
||||||
|
|
||||||
def create_remote_evaluation_mapping
|
def create_remote_evaluation_mapping
|
||||||
user_id = @submission.user_id
|
user = @submission.user
|
||||||
exercise_id = @submission.exercise_id
|
exercise_id = @submission.exercise_id
|
||||||
|
|
||||||
remote_evaluation_mapping = RemoteEvaluationMapping.create(:user_id => user_id, :exercise_id => exercise_id)
|
remote_evaluation_mapping = RemoteEvaluationMapping.create(user: user, exercise_id: exercise_id)
|
||||||
|
|
||||||
# create .co file
|
# create .co file
|
||||||
path = "tmp/" + user_id.to_s + ".co"
|
path = "tmp/" + user.id.to_s + ".co"
|
||||||
# parse validation token
|
# parse validation token
|
||||||
content = "#{remote_evaluation_mapping.validation_token}\n"
|
content = "#{remote_evaluation_mapping.validation_token}\n"
|
||||||
# parse remote request url
|
# parse remote request url
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
class RemoteEvaluationMapping < ApplicationRecord
|
class RemoteEvaluationMapping < ApplicationRecord
|
||||||
before_create :generate_token, unless: :validation_token?
|
before_create :generate_token, unless: :validation_token?
|
||||||
belongs_to :exercise
|
belongs_to :exercise
|
||||||
belongs_to :user, class_name: 'ExternalUser'
|
belongs_to :user, polymorphic: true
|
||||||
|
|
||||||
def generate_token
|
def generate_token
|
||||||
self.validation_token = SecureRandom.urlsafe_base64
|
self.validation_token = SecureRandom.urlsafe_base64
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
class AddUserTypeToRemoteEvaluationMappings < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
add_column :remote_evaluation_mappings, :user_type, :string
|
||||||
|
# Update all existing records and set user_type to `ExternalUser` (safe way to prevent any function loss).
|
||||||
|
# We are not using a default value here on intend to be in line with the other `user_type` columns
|
||||||
|
RemoteEvaluationMapping.update_all(user_type: 'ExternalUser')
|
||||||
|
end
|
||||||
|
end
|
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_09_04_115948) do
|
ActiveRecord::Schema.define(version: 2018_11_26_163428) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@ -290,6 +290,7 @@ ActiveRecord::Schema.define(version: 2018_09_04_115948) do
|
|||||||
t.string "validation_token", null: false
|
t.string "validation_token", null: false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "user_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "request_for_comments", force: :cascade do |t|
|
create_table "request_for_comments", force: :cascade do |t|
|
||||||
|
Reference in New Issue
Block a user