Functional Weave
Code in TypeScript

education.attendance-rate@1.0.1

vectors.json

4,449 bytes · view raw

[
 {
  "name": "38 of 380 sessions missed is exactly 10%: persistently absent",
  "args": [
   380,
   38,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 9000,
   "absenceBasisPoints": 1000,
   "persistentlyAbsent": true,
   "severelyAbsent": false
  }
 },
 {
  "name": "37 of 380 is 9.74%: not persistently absent",
  "args": [
   380,
   37,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 9026,
   "absenceBasisPoints": 974,
   "persistentlyAbsent": false,
   "severelyAbsent": false
  }
 },
 {
  "name": "250 of 2,501 rounds to 10.00% but is under 10%: not persistently absent",
  "args": [
   2501,
   250,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 9000,
   "absenceBasisPoints": 1000,
   "persistentlyAbsent": false,
   "severelyAbsent": false
  }
 },
 {
  "name": "190 of 380 is exactly half: severely absent",
  "args": [
   380,
   190,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 5000,
   "absenceBasisPoints": 5000,
   "persistentlyAbsent": true,
   "severelyAbsent": true
  }
 },
 {
  "name": "189 of 380 is just under half",
  "args": [
   380,
   189,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 5026,
   "absenceBasisPoints": 4974,
   "persistentlyAbsent": true,
   "severelyAbsent": false
  }
 },
 {
  "name": "no sessions missed",
  "args": [
   380,
   0,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 10000,
   "absenceBasisPoints": 0,
   "persistentlyAbsent": false,
   "severelyAbsent": false
  }
 },
 {
  "name": "every session missed",
  "args": [
   380,
   380,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 0,
   "absenceBasisPoints": 10000,
   "persistentlyAbsent": true,
   "severelyAbsent": true
  }
 },
 {
  "name": "a half basis point rounds absence up and attendance is what is left, so they sum to 100%",
  "args": [
   20000,
   1,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 9999,
   "absenceBasisPoints": 1,
   "persistentlyAbsent": false,
   "severelyAbsent": false
  }
 },
 {
  "name": "a single possible session, attended",
  "args": [
   1,
   0,
   "2025-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 10000,
   "absenceBasisPoints": 0,
   "persistentlyAbsent": false,
   "severelyAbsent": false
  }
 },
 {
  "name": "2016/17, before severe absence was published: severe is null",
  "args": [
   380,
   190,
   "2016-10-01"
  ],
  "expect": {
   "attendanceBasisPoints": 5000,
   "absenceBasisPoints": 5000,
   "persistentlyAbsent": true,
   "severelyAbsent": null
  }
 },
 {
  "name": "the last day before severe absence data",
  "args": [
   380,
   190,
   "2018-08-31"
  ],
  "expect": {
   "attendanceBasisPoints": 5000,
   "absenceBasisPoints": 5000,
   "persistentlyAbsent": true,
   "severelyAbsent": null
  }
 },
 {
  "name": "the first day of 2018/19",
  "args": [
   380,
   190,
   "2018-09-01"
  ],
  "expect": {
   "attendanceBasisPoints": 5000,
   "absenceBasisPoints": 5000,
   "persistentlyAbsent": true,
   "severelyAbsent": true
  }
 },
 {
  "name": "the first day of the 10% definition",
  "args": [
   380,
   38,
   "2015-09-01"
  ],
  "expect": {
   "attendanceBasisPoints": 9000,
   "absenceBasisPoints": 1000,
   "persistentlyAbsent": true,
   "severelyAbsent": null
  }
 },
 {
  "name": "before 2015/16 there is no per-pupil 10% definition",
  "args": [
   380,
   38,
   "2015-08-31"
  ],
  "expectError": "no persistent absence definition on 2015-08-31"
 },
 {
  "name": "more sessions missed than possible is an error",
  "args": [
   380,
   381,
   "2025-10-01"
  ],
  "expectError": "missedSessions must be a whole number from 0 to possibleSessions (380), received 381"
 },
 {
  "name": "negative missed sessions is an error",
  "args": [
   380,
   -1,
   "2025-10-01"
  ],
  "expectError": "missedSessions must be a whole number from 0 to possibleSessions (380), received -1"
 },
 {
  "name": "half a session is an error",
  "args": [
   380,
   1.5,
   "2025-10-01"
  ],
  "expectError": "missedSessions must be a whole number from 0 to possibleSessions (380), received 1.5"
 },
 {
  "name": "no possible sessions is an error",
  "args": [
   0,
   0,
   "2025-10-01"
  ],
  "expectError": "possibleSessions must be a whole number of 1 or more, received 0"
 },
 {
  "name": "an impossible date is an error",
  "args": [
   380,
   38,
   "2025-02-30"
  ],
  "expectError": "\"2025-02-30\" is not a real calendar date"
 }
]