import { Entity } from "../../../core/entity/model/entity" ; import { DatabaseField } from "../../../core/entity/database-field.decorator" ; import { DatabaseEntity } from "../../../core/entity/database-entity.decorator" ; import { ConfigurableEnumConfig , ConfigurableEnumValue , } from "../../../core/configurable-enum/configurable-enum.interface" ; import { MathLevel , mathLevels } from "./mathLevels" ; import { ReadingLevel , readingLevels } from "./readingLevels" ; import { WarningLevel } from "../../../core/entity/model/warning-level" ; @ DatabaseEntity ( "Aser" ) export class Aser extends Entity { static isReadingPassedOrNA ( level ) { return this . isHighestLevelOrNA ( level , readingLevels ) ; } static isMathPassedOrNA ( level ) { return this . isHighestLevelOrNA ( level , mathLevels ) ; } static isHighestLevelOrNA ( level , source ) { if ( ! level || level . id === "" ) { return true ; } const index = source . findIndex ( ( cEnumValue ) => cEnumValue . id === level . id ) ; return index === source . length - 1 ; } @ DatabaseField ( ) child : string ; @ DatabaseField ( { label : $localize `:Label for date of the ASER results:Date` , } ) date : Date = new Date ( ) ; @ DatabaseField ( { label : $localize `:Label of the Hindi ASER result:Hindi` , dataType : "configurable-enum" , innerDataType : "reading-levels" , } ) hindi : ReadingLevel ; @ DatabaseField ( { label : $localize `:Label of the Bengali ASER result:Bengali` , dataType : "configurable-enum" , innerDataType : "reading-levels" , } ) bengali : ReadingLevel ; @ DatabaseField ( { label : $localize `:Label of the English ASER result:English` , dataType : "configurable-enum" , innerDataType : "reading-levels" , } ) english : ReadingLevel ; @ DatabaseField ( { label : $localize `:Label of the Math ASER result:Math` , dataType : "configurable-enum" , innerDataType : "math-levels" , } ) math : MathLevel ; @ DatabaseField ( { label : $localize `:Label for the remarks of a ASER result:Remarks` , } ) remarks : string = "" ; getWarningLevel ( ) { if ( Aser . isReadingPassedOrNA ( this . english ) && Aser . isReadingPassedOrNA ( this . hindi ) && Aser . isReadingPassedOrNA ( this . bengali ) && Aser . isMathPassedOrNA ( this . math ) ) { return WarningLevel . OK ; } else { return WarningLevel . WARNING ; } } }