review points

This commit is contained in:
Karol
2019-12-16 17:38:32 +01:00
parent 1ddd6e19f5
commit da8d31279c
5 changed files with 16 additions and 46 deletions

View File

@@ -13,7 +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_one :codeharbor_link
has_one :codeharbor_link, dependent: :destroy
accepts_nested_attributes_for :user_proxy_exercise_exercises

View File

@@ -8,11 +8,11 @@ class CodeharborLinkPolicy < ApplicationPolicy
end
def new?
teacher?
teacher? || admin?
end
def create?
teacher?
teacher? || admin?
end
def edit?

View File

@@ -28,13 +28,9 @@ module ProformaService
def base_exercise
exercise = Exercise.find_by(uuid: @task.uuid)
if exercise
return exercise if ExercisePolicy.new(@user, exercise).update?
return exercise if exercise && ExercisePolicy.new(@user, exercise).update?
return Exercise.new(uuid: SecureRandom.uuid, unpublished: true)
end
Exercise.new(uuid: @task.uuid || SecureRandom.uuid, unpublished: true)
Exercise.new(uuid: @task.uuid, unpublished: true)
end
def import_multi