Add ProgrammingGroup & ProgrammingGroupMembership

* User can create programming group with other users for exercise
* Submission is shared in a group
* Also adjust specs
This commit is contained in:
kiragrammel
2023-08-10 17:07:04 +02:00
committed by Sebastian Serth
parent 0234414bae
commit 319c3ab3b4
42 changed files with 715 additions and 276 deletions

View File

@ -24,6 +24,9 @@ class Submission < ApplicationRecord
belongs_to :internal_users, lambda {
where(submissions: {contributor_type: 'InternalUser'}).includes(:submissions)
}, foreign_key: :contributor_id, class_name: 'InternalUser', optional: true
belongs_to :programming_groups, lambda {
where(submissions: {contributor_type: 'ProgrammingGroup'}).includes(:submissions)
}, foreign_key: :contributor_id, class_name: 'ProgrammingGroup', optional: true
delegate :execution_environment, to: :exercise
scope :final, -> { where(cause: %w[submit remoteSubmit]) }
@ -49,12 +52,6 @@ class Submission < ApplicationRecord
# after_save :trigger_working_times_action_cable
def build_files_hash(files, attribute)
files.map(&attribute.to_proc).zip(files).to_h
end
private :build_files_hash
def collect_files
@collect_files ||= begin
ancestors = build_files_hash(exercise.files.includes(:file_type), :id)
@ -202,8 +199,16 @@ class Submission < ApplicationRecord
%w[study_group_id exercise_id cause]
end
def users
contributor.try(:users) || [contributor]
end
private
def build_files_hash(files, attribute)
files.map(&attribute.to_proc).zip(files).to_h
end
def prepared_runner
request_time = Time.zone.now
begin