From 0ec96a874d7dc6fd98c85849f715d4c7df9a64c3 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Tue, 5 Mar 2019 11:42:54 +0000 Subject: [PATCH] Simplified rating validity check --- .../co/neviyn/observationdatabase/Entity.kt | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt index 6406868..7171742 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Entity.kt @@ -122,7 +122,11 @@ data class RatingComponent( val rating: Int, val strengths: String = "", val improvements: String = "" -) +) { + fun ratingValid(): Boolean { + return rating in 1..5 + } +} @Entity data class Scenario( @@ -149,15 +153,14 @@ data class Scenario( ) { fun ratingsAllValid(): Boolean { - val limitation = 1..5 - return monitoring.rating in limitation && - controlProcedural.rating in limitation && - control.rating in limitation && - conservatism.rating in limitation && - teamworkCommunications.rating in limitation && - teamworkLeadership.rating in limitation && - teamworkWorkload.rating in limitation && - knowledge.rating in limitation + return monitoring.ratingValid() && + controlProcedural.ratingValid()&& + control.ratingValid() && + conservatism.ratingValid() && + teamworkCommunications.ratingValid() && + teamworkLeadership.ratingValid() && + teamworkWorkload.ratingValid() && + knowledge.ratingValid() } }