
Tags can be added to exercises in the edit view. Tags can monitored under /tags. Added the concept of ProxyExercises which are a collection of Exercises. They can be found under /proxy_exercises Added Interventions as prework to show interventions later to the user. Added exercise/[:id]/working_time to return the working time of the user in this exercise and the average working time of all users in this exercise
31 lines
721 B
Ruby
31 lines
721 B
Ruby
module User
|
|
extend ActiveSupport::Concern
|
|
|
|
ROLES = %w(admin teacher)
|
|
|
|
included do
|
|
belongs_to :consumer
|
|
has_many :exercises, as: :user
|
|
has_many :file_types, as: :user
|
|
has_many :submissions, as: :user
|
|
has_many :user_proxy_exercise_exercises, as: :user
|
|
has_many :user_exercise_interventions, as: :user
|
|
has_many :interventions, through: :user_exercise_interventions
|
|
|
|
|
|
scope :with_submissions, -> { where('id IN (SELECT user_id FROM submissions)') }
|
|
end
|
|
|
|
ROLES.each do |role|
|
|
define_method("#{role}?") { try(:role) == role }
|
|
end
|
|
|
|
[ExternalUser, InternalUser].each do |klass|
|
|
define_method("#{klass.name.underscore}?") { is_a?(klass) }
|
|
end
|
|
|
|
def to_s
|
|
name
|
|
end
|
|
end
|