Allow internal user to be part of an study group
This commit is contained in:
@ -202,7 +202,7 @@ module Lti
|
||||
else
|
||||
StudyGroup.find_or_create_by(external_id: @provider.resource_link_id, consumer: @consumer)
|
||||
end
|
||||
group.users << @current_user unless group.users.include? @current_user
|
||||
group.external_users << @current_user unless group.external_users.include? @current_user
|
||||
group.save
|
||||
session[:study_group_id] = group.id
|
||||
end
|
||||
|
@ -10,11 +10,11 @@ class StudyGroupsController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
@search = @study_group.users.ransack(params[:q])
|
||||
@search = @study_group.external_users.ransack(params[:q])
|
||||
end
|
||||
|
||||
def edit
|
||||
@search = @study_group.users.ransack(params[:q])
|
||||
@search = @study_group.external_users.ransack(params[:q])
|
||||
@members = StudyGroupMembership.where(user: @search.result, study_group: @study_group)
|
||||
end
|
||||
|
||||
|
@ -2,13 +2,15 @@
|
||||
|
||||
class StudyGroup < ApplicationRecord
|
||||
has_many :study_group_memberships, dependent: :destroy
|
||||
# Use `ExternalUser` as `source_type` for now.
|
||||
# Using `User` will lead ActiveRecord to access the inexistent table `users`.
|
||||
# Issue created: https://github.com/rails/rails/issues/34531
|
||||
has_many :users, through: :study_group_memberships, source_type: 'ExternalUser'
|
||||
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
|
||||
belongs_to :consumer
|
||||
|
||||
def users
|
||||
external_users + internal_users
|
||||
end
|
||||
|
||||
def to_s
|
||||
if name.blank?
|
||||
"StudyGroup " + id.to_s
|
||||
|
Reference in New Issue
Block a user