Refactor LTI parameters and add study group

* This change also requires that submissions in our test need to have a valid study group.
This commit is contained in:
Sebastian Serth
2023-08-19 11:28:57 +02:00
committed by Sebastian Serth
parent e2baa2ee55
commit e3603758ef
18 changed files with 114 additions and 54 deletions

View File

@@ -2,6 +2,7 @@
class ExternalUser < User
validates :external_id, presence: true
has_many :lti_parameters, dependent: :destroy
def displayname
name.presence || "User #{id}"

View File

@@ -1,9 +1,12 @@
# frozen_string_literal: true
class LtiParameter < ApplicationRecord
belongs_to :consumer, foreign_key: 'consumers_id'
belongs_to :exercise, foreign_key: 'exercises_id'
belongs_to :external_user, foreign_key: 'external_users_id'
belongs_to :exercise
belongs_to :external_user
belongs_to :study_group, optional: true
delegate :consumer, to: :external_user
validates :external_user_id, uniqueness: {scope: %i[study_group_id exercise_id]}
scope :lis_outcome_service_url?, lambda {
where("lti_parameters.lti_parameters ? 'lis_outcome_service_url'")

View File

@@ -8,6 +8,7 @@ class StudyGroup < ApplicationRecord
has_many :remote_evaluation_mappings, dependent: :nullify
has_many :subscriptions, dependent: :nullify
has_many :authentication_tokens, dependent: :nullify
has_many :lti_parameters, dependent: :delete_all
belongs_to :consumer
def users