Cooper Test Calculator


Calculating predicted 12-minute running distance based on prior race performance


This application is not maintained as of November 2023

(the app might take a few seconds to wake up)

Cooper Test Calculator Documentation:

Overview

This Node.js application calculates and displays the results of a Cooper test based on the distance run in a specific time. The Cooper test is a fitness test used to measure an individual's aerobic capacity. When a user selects a race distance and enters their race time, they can submit the form to calculate their estimated distance for a 12-minute Cooper test. The application is mobile responsive.

Dependencies

- `path`: Used to construct paths to the views and public directories.

- `fastify`: A fast and low overhead web framework for Node.js.

- `@fastify/formbody`: A plugin to parse HTML form body content.

- `@fastify/static`: A plugin to serve static files such as CSS and images.

- `@fastify/view`: A plugin to render server-side templates using Handlebars.

- `handlebars`: A templating engine to create the HTML views.

Endpoints

- `GET /`: Renders the index page where the user can input the distance run and the time taken.

- `POST /calculate`: Accepts the form data from the index page, calculates the Cooper test results, and renders the results page with the calculated pace, distance in meters, and the number of laps.

Calculation

The application calculates the following:

- `speed`: The speed in meters per second based on the input distance and time.

- `cooperSpeedInSeconds`: The adjusted speed based on a conversion factor specific to the distance run.

- `cooperDistanceInMeters`: The distance covered in meters during a 12-minute Cooper test based on the adjusted speed.

- `cooperLaps`: The number of laps completed in a standard 400-meter track during the Cooper test.

- `cooperPace`: The pace in minutes and seconds per kilometer during the Cooper test.

Conversion Factors

The conversion factors used to adjust the speed based on the distance run are:

- Marathon: 1.15

- Half Marathon: 1.09

- 10k: 1.056

- 5k: 1.04

Views

The application uses Handlebars templates for rendering the HTML views:

- `index.hbs`: The form for inputting the distance run and the time taken.

- `results.hbs`: Displays the calculated Cooper test results.

Static Files & Logging

The application serves static files, such as CSS, from the `public` directory.

The application logs various intermediate values for debugging purposes, such as the input distance, time in seconds, conversion factor, speed, adjusted speed, laps, and pace.