Add StudyGroup to RemoteEvaluationMapping
This commit is contained in:
@@ -74,6 +74,7 @@ class RemoteEvaluationController < ApplicationController
|
||||
submission_params = remote_evaluation_params.except(:validation_token)
|
||||
submission_params[:exercise_id] = remote_evaluation_mapping.exercise_id
|
||||
submission_params[:user_id] = remote_evaluation_mapping.user_id
|
||||
submission_params[:study_group_id] = remote_evaluation_mapping.study_group_id
|
||||
submission_params[:cause] = cause
|
||||
submission_params[:user_type] = remote_evaluation_mapping.user_type
|
||||
submission_params[:files_attributes] = reject_illegal_file_attributes(remote_evaluation_mapping.exercise, files_attributes)
|
||||
|
@@ -450,7 +450,11 @@ class SubmissionsController < ApplicationController
|
||||
user = @submission.user
|
||||
exercise_id = @submission.exercise_id
|
||||
|
||||
remote_evaluation_mapping = RemoteEvaluationMapping.create(user: user, exercise_id: exercise_id)
|
||||
remote_evaluation_mapping = RemoteEvaluationMapping.create(
|
||||
user: user,
|
||||
exercise_id: exercise_id,
|
||||
study_group_id: session[:study_group_id]
|
||||
)
|
||||
|
||||
# create .co file
|
||||
path = "tmp/" + user.id.to_s + ".co"
|
||||
|
@@ -3,6 +3,7 @@ class RemoteEvaluationMapping < ApplicationRecord
|
||||
before_create :generate_token, unless: :validation_token?
|
||||
belongs_to :exercise
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :study_group, optional: true
|
||||
|
||||
def generate_token
|
||||
self.validation_token = SecureRandom.urlsafe_base64
|
||||
|
@@ -5,6 +5,7 @@ class StudyGroup < ApplicationRecord
|
||||
has_many :external_users, through: :study_group_memberships, source_type: 'ExternalUser', source: :user
|
||||
has_many :internal_users, through: :study_group_memberships, source_type: 'InternalUser', source: :user
|
||||
has_many :submissions, dependent: :nullify
|
||||
has_many :remote_evaluation_mappings, dependent: :nullify
|
||||
belongs_to :consumer
|
||||
|
||||
def users
|
||||
|
@@ -13,6 +13,7 @@ class User < ApplicationRecord
|
||||
has_many :user_proxy_exercise_exercises, as: :user
|
||||
has_many :user_exercise_interventions, as: :user
|
||||
has_many :interventions, through: :user_exercise_interventions
|
||||
has_many :remote_evaluation_mappings, as: :user
|
||||
has_one :codeharbor_link, dependent: :destroy
|
||||
accepts_nested_attributes_for :user_proxy_exercise_exercises
|
||||
|
||||
|
Reference in New Issue
Block a user