Calculate A Score

Link to Calculate A Score copied to clipboard
Free Trial

axe DevTools Mobile provides data in the result object that can help track your accessibility progress over time. Below we'll highlight how to calculate an accessibility score from a scan in iOS and Android. This score will provide a metric of how accessibility is going in your application. Or, use these data points to develop a health metric that works for your team!

The Algorithm

At the core, we recommend using the same algorithm you may have seen in some of our other products but with a mobile spin (we don't use the term pages). We encourage your team to modify the below algorithm to work for you!

Scan results are filtered by impact: Critical, Serious, Moderate, or Minor. Note: if working with legacy data, you may also see the deprecated 'Blocker' impact.

Utilize the result object to grab the following data points:

  • p2 = number of Critical and Serious issues
  • p1 = number of Moderate issues
  • p0 = number of Minor issues
  • total = number of total issues

( 0.4 * p2 + 0.8 * p1 + p0 ) / total

In other words, 40% is given for issues that are Critical or Serious, 80% is given for Moderate issues, and 100% for any Minor issues.

You may also choose to weight the score as shown in the mobile dashboard by: 500 + (score * 500.0)

iOS

From the result object, here's some sample code for pulling out the counts of each impact level:

let critical = result.failures.filter { $0.impact == .CRITICAL }.count
let serious = result.failures.filter { $0.impact == .SERIOUS }.count
let moderate = result.failures.filter { $0.impact == .MODERATE }.count
let minor = result.failures.filter { $0.impact == .MINOR }.count

Android

From the result object, here's some sample code for pulling out the counts of each impact level:

val minorImpactCount = AtomicInteger(0)
val blockerCount = AtomicInteger(0)
val criticalCount = AtomicInteger(0)
val moderateCount = AtomicInteger(0)
val serious = AtomicInteger(0)

result?.axeResult?.axeRuleResults?.forEach {
    when (it.impact) {
        AxeImpact.MINOR.value -> minorImpactCount.incrementAndGet()
        AxeImpact.BLOCKER.value -> blockerCount.incrementAndGet()
        AxeImpact.CRITICAL.value -> criticalCount.incrementAndGet()
        AxeImpact.MODERATE.value -> moderateCount.incrementAndGet()
        AxeImpact.SERIOUS.value -> serious.incrementAndGet()
        else -> {}
    }
}