Links, mainly...
Some checks failed
/ Run system tests (push) Waiting to run
/ Build, push and deploy image (push) Blocked by required conditions
/ Run tests (push) Has been cancelled
/ Checkout (push) Successful in 8m9s

This commit is contained in:
david 2024-07-26 00:59:00 +02:00
parent fd42a3f173
commit 21ab02d647
69 changed files with 2258 additions and 155 deletions

View file

@ -7,4 +7,27 @@ class Element < ApplicationRecord
has_many :success_criteria, dependent: :destroy
validates :path, :title, presence: true
# Calculate actual conformity level:
# - if a success_criterion has result :failed -> the confirmity_level
# of that success_criterion is not reached.
# - the resulting level is the highest readched level
# abeying rule above.
def level
return nil
return nil unless success_criteria.all(&:result)
min_failed = success_criteria.select(&:failed?).map(&:level).min
possible_levels = success_criteria.select(&:passed?).map(&:level).uniq
return nil if possible_levels.empty?
puts possible_levels.inspect
puts min_failed
possible_levels[possible_levels.find_index(min_failed) - 1]
end
def max_level
@max_level ||= success_criteria.reject(&:not_applicable?).max(&:level)
end
end