added fail reason to result screen

This commit is contained in:
Jack 2021-06-29 19:03:45 +01:00
parent 87073a3700
commit f9d2f64a43
3 changed files with 22 additions and 14 deletions

View file

@ -287,7 +287,7 @@ function handleSpace(event, isEnter) {
if (Config.stopOnError != "off") {
if (Config.difficulty == "expert" || Config.difficulty == "master") {
//failed due to diff when pressing space
TestLogic.fail();
TestLogic.fail("difficulty");
return;
}
if (Config.stopOnError == "word") {
@ -311,7 +311,7 @@ function handleSpace(event, isEnter) {
TestStats.pushKeypressWord(TestLogic.words.currentIndex);
TestStats.updateLastKeypress();
if (Config.difficulty == "expert" || Config.difficulty == "master") {
TestLogic.fail();
TestLogic.fail("difficulty");
return;
} else if (TestLogic.words.currentIndex == TestLogic.words.length) {
//submitted last word that is incorrect
@ -329,7 +329,7 @@ function handleSpace(event, isEnter) {
(Config.minBurst === "fixed" && burst < Config.minBurstCustomSpeed) ||
(Config.minBurst === "flex" && burst < flex)
) {
TestLogic.fail();
TestLogic.fail("min burst");
return;
}
@ -684,7 +684,7 @@ function handleAlpha(event) {
}
if (!thisCharCorrect && Config.difficulty == "master") {
TestLogic.fail();
TestLogic.fail("difficulty");
return;
}

View file

@ -1350,7 +1350,7 @@ export function finish(difficultyFailed = false) {
}
if (difficultyFailed) {
Notifications.add("Test failed", 0, 1);
Notifications.add(`Test failed - ${failReason}`, 0, 1);
} else if (afkDetected) {
Notifications.add("Test invalid - AFK detected", 0);
} else if (isRepeated) {
@ -1831,7 +1831,7 @@ export function finish(difficultyFailed = false) {
// otherText += "<br>" + Config.layout;
// }
if (difficultyFailed) {
otherText += "<br>failed";
otherText += `<br>failed (${failReason})`;
}
if (afkDetected) {
otherText += "<br>afk detected";
@ -1949,7 +1949,9 @@ export function finish(difficultyFailed = false) {
);
}
export function fail() {
let failReason = "";
export function fail(reason) {
failReason = reason;
input.pushHistory();
corrected.pushHistory();
TestStats.pushKeypressesToHistory();

View file

@ -88,15 +88,21 @@ export function start() {
TestStats.pushKeypressesToHistory();
if (
(Config.minWpm === "custom" &&
wpmAndRaw.wpm < parseInt(Config.minWpmCustomSpeed) &&
TestLogic.words.currentIndex > 3) ||
(Config.minAcc === "custom" &&
acc < parseInt(Config.minAccCustom) &&
TestLogic.words.currentIndex > 3)
Config.minWpm === "custom" &&
wpmAndRaw.wpm < parseInt(Config.minWpmCustomSpeed) &&
TestLogic.words.currentIndex > 3
) {
clearTimeout(timer);
TestLogic.fail();
TestLogic.fail("min wpm");
return;
}
if (
Config.minAcc === "custom" &&
acc < parseInt(Config.minAccCustom) &&
TestLogic.words.currentIndex > 3
) {
clearTimeout(timer);
TestLogic.fail("min accuracy");
return;
}
if (