app/models/exam_registration/authorization_criterion.rb in mumuki-domain-9.10.0 vs app/models/exam_registration/authorization_criterion.rb in mumuki-domain-9.11.0
- old
+ new
@@ -32,10 +32,14 @@
def self.parse_criterion_type(type, value)
"ExamRegistration::AuthorizationCriterion::#{type.camelize}".constantize.new(value)
rescue
raise "Invalid criterion type #{type}"
end
+
+ def meets_authorization_criteria?(authorization_request)
+ meets_criterion? authorization_request.user, authorization_request.organization
+ end
end
class ExamRegistration::AuthorizationCriterion::None < ExamRegistration::AuthorizationCriterion
def initialize(_)
@value = nil
@@ -43,19 +47,19 @@
def valid?
!value
end
- def meets_authorization_criteria?(_authorization_request)
+ def meets_criterion?(_user, _organization)
true
end
end
class ExamRegistration::AuthorizationCriterion::PassedExercises < ExamRegistration::AuthorizationCriterion
def valid?
value.positive?
end
- def meets_authorization_criteria?(authorization_request)
- authorization_request.user.passed_submissions_count_in(authorization_request.organization) >= value
+ def meets_criterion?(user, organization)
+ user.passed_submissions_count_in(organization) >= value
end
end