Gracie had a friend who was interested in becoming a teacher. To get admitted into a teaching program at the local university, the friend needed to take an admissions test, to prove they were teaching material.

Said friend tried to retrieve their test results, and the page glitched out. Gracie, who was handy, offered to see if she could identify the problem- likely an ad-blocker extension or something was breaking a script. A few minutes in the browser debugging tools, however, showed that the script came pre-broken.

if (result == '0.9') {
alert("Your calculated average is : 49.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.0') {
alert("Your calculated average is : 50.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.1') {
alert("Your calculated average is : 52.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.2') {
alert("Your calculated average is : 54.7 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.3') {
alert("Your calculated average is : 57.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.4') {
alert("Your calculated average is : 57.8 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.5') {
alert("Your calculated average is : 58.5 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.6') {
alert("Your calculated average is : 59.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.7') {
alert("Your calculated average is : 60.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.8') {
alert("Your calculated average is : 61.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '1.9') {
alert("Your calculated average is : 62.7 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.0') {
alert("Your calculated average is : 63.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.1') {
alert("Your calculated average is : 64.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.2') {
alert("Your calculated average is : 65.7 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.3') {
alert("Your calculated average is : 67.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.4') {
alert("Your calculated average is : 67.8 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.5') {
alert("Your calculated average is : 68.5 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.6') {
alert("Your calculated average is : 69.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.7') {
alert("Your calculated average is : 70.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.8') {
alert("Your calculated average is : 71.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '2.9') {
alert("Your calculated average is : 72.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.0') {
alert("Your calculated average is : 73.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.1') {
alert("Your calculated average is : 74.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.2') {
alert("Your calculated average is : 75.7 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.3') {
alert("Your calculated average is : 77.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.4') {
alert("Your calculated average is : 77.8 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.5') {
alert("Your calculated average is : 78.5 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.6') {
alert("Your calculated average is : 79.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.7') {
alert("Your calculated average is : 80.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.8') {
alert("Your calculated average is : 82.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '3.9') {
alert("Your calculated average is : 83.3 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '4.0') {
alert("Your calculated average is : 85.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '4.1') {
alert("Your calculated average is : 90.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '4.2') {
alert("Your calculated average is : 95.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}
if (result == '4.3') {
alert("Your calculated average is : 100.0 %\n\nTo be eligible for admission to the Teacher Education programs, you must have a minimum average of 68.0 %");
}

The choice to use alert leaves me wondering "what year is this?"- what a terrible user experience choice. But the core logic itself seems to be the real problem. While the function that maps the results to percentages is clearly not strictly linear, there's clearly a relationship.

My suspicion, looking at this, is that this calculation started its life in a spreadsheet. Someone in the admissions office would plug test results into a spreadsheet, and use that to generate percentages. When the organization decided to put this on the web, they just handed the developer the spreadsheet and said "do this". So… they did.

In the developer's defense, however- what is this calculation doing? The relationship makes no real sense; the steps between each point in the result are almost random, with gaps as large as 2.4 and as small as 0.7.

And this leads me to my second suspicion: the mapping of result to "percentage" is utterly arbitrary. They know that a result of 2.5 is the cutoff point- anything higher gets you into the program, anything lower doesn't. So they call that 68.5%, set the bar at 68%, and everything else is just there to make the numbers look good.

So while this code could be much better, I'm not certain the code is as much a WTF as the business process in question.

Regardless, I hope they hire some teachers for their programmers.

[Advertisement] Continuously monitor your servers for configuration changes, and report when there's configuration drift. Get started with Otter today!