Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions backend/src/api/controllers/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ async function calculateXp(
breakdown.base = baseXp;

let modifier = 1;

// check if charstats is undefined
const correctedEverything = charStats
.slice(1)
.every((charStat: number) => charStat === 0);
Expand All @@ -740,7 +740,6 @@ async function calculateXp(
modifier += 0.25;
breakdown["corrected"] = Math.round(baseXp * 0.25);
}

if (mode === "quote") {
// real sentences bonus
modifier += 0.5;
Expand Down
2 changes: 2 additions & 0 deletions backend/src/utils/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function buildDbResult(
isPb: boolean
): DBResult {
const ce = completedEvent;

const res: DBResult = {
_id: new ObjectId(),
uid: ce.uid,
Expand Down Expand Up @@ -51,6 +52,7 @@ export function buildDbResult(
bailedOut: ce.bailedOut,
blindMode: ce.blindMode,
name: userName,
detailedCharStats: ce.detailedCharStats,
};

//compress object by omitting default values. Frontend will add them back after reading
Expand Down
41 changes: 37 additions & 4 deletions frontend/src/html/pages/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
<i class="fas fa-search"></i>
</button>
</div>

<div class="zen">
<div
class="textButton"
Expand All @@ -83,9 +82,7 @@
margin-left: 0;
margin-right: 0;
"
>

</div>
></div>
</div>

<div class="customText">
Expand Down Expand Up @@ -326,6 +323,15 @@
</div>
<div class="bottom">-</div>
</div>

<div class="group charStats">
<div class="top">miss / nail</div>
<div class="bottom" aria-label="" data-balloon-pos="up">
<span id="hardestChar">-</span>
/
<span id="easiestChar">-</span>
</div>
</div>
</div>
<div class="chart">
<div class="chartLegend">
Expand Down Expand Up @@ -399,6 +405,24 @@
</div>
<div class="words"></div>
</div>
<div id="resultCharStats" class="hidden">
<div class="title">
<span>character statistics</span>
<button
id="copyCharStatsButton"
class="textButton"
aria-label="Copy character stats"
data-balloon-pos="up"
style="display: inline-block"
tabindex="-1"
>
<i class="fas fa-fw fa-copy"></i>
</button>
</div>
<div id="charStatsChartContainer">
<canvas id="charStatsChart"></canvas>
</div>
</div>
<div id="resultReplay" class="hidden">
<div class="title">
watch replay
Expand Down Expand Up @@ -459,6 +483,15 @@
>
<i class="fas fa-fw fa-align-left"></i>
</button>
<button
class="text"
id="showCharStatsButton"
aria-label="Toggle character statistics"
role="button"
data-balloon-pos="down"
>
<i class="fas fa-fw fa-chart-bar"></i>
</button>
<button
class="text"
id="watchReplayButton"
Expand Down
66 changes: 64 additions & 2 deletions frontend/src/styles/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,66 @@
position: relative;
}

#resultCharStats {
position: relative;

#charStatsChartContainer {
height: 300px;
margin: 1rem 0;
position: relative;
}

.charStatsList {
margin-top: 1rem;

.charStatsListContent {
display: flex;
flex-direction: column;
gap: 0.5rem;

.charStatsHeader {
display: grid;
grid-template-columns: 2fr 1fr 1fr;
gap: 1rem;
padding: 0.5rem;
border-bottom: 1px solid var(--sub-color);
font-weight: bold;
color: var(--main-color);
}

.charStatsItem {
display: grid;
grid-template-columns: 2fr 1fr 1fr;
gap: 1rem;
padding: 0.5rem;
border-bottom: 1px solid var(--sub-color);
opacity: 0.8;

&:hover {
opacity: 1;
background-color: var(--bg-color);
}

.charStatsChar {
font-family: var(--font);
font-size: 1.2rem;
color: var(--main-color);
}

.charStatsRate {
color: var(--error-color);
text-align: right;
}

.charStatsCount {
text-align: right;
color: var(--sub-color);
}
}
}
}
}

#words.noErrorBorder,
#resultWordsHistory.noErrorBorder {
.word.error {
Expand Down Expand Up @@ -685,7 +745,8 @@
}

#resultWordsHistory,
#resultReplay {
#resultReplay,
#resultCharStats {
// grid-area: wordsHistory;
color: var(--sub-color);
// grid-column: 1/3;
Expand All @@ -694,7 +755,8 @@
padding: 0 0.25em;
}
#copyWordsListButton,
#playpauseReplayButton {
#playpauseReplayButton,
#copyCharStatsButton {
margin-left: 0.5em;
}
.heatmapLegend {
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/ts/controllers/route-controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as PageController from "./page-controller";
import * as TestUI from "../test/test-ui";
import * as PageTransition from "../states/page-transition";
import { isAuthAvailable, isAuthenticated } from "../firebase";
import { isFunboxActive } from "../test/funbox/list";
Expand Down Expand Up @@ -170,14 +169,14 @@ export async function navigate(
if (
!options.force &&
(TestState.testRestarting ||
TestUI.resultCalculating ||
TestState.resultCalculating ||
PageTransition.get())
) {
console.debug(
`navigate: ${url} ignored, page is busy (testRestarting: ${
TestState.testRestarting
}, resultCalculating: ${
TestUI.resultCalculating
TestState.resultCalculating
}, pageTransition: ${PageTransition.get()})`
);
return;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/input/handlers/before-insert-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function onBeforeInsertText(data: string): boolean {
return true;
}

if (TestUI.resultCalculating) {
if (TestState.resultCalculating) {
return true;
}

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/ts/modals/last-signed-out-result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ function fillData(): void {
fillGroup("acc", r.acc + "%");
fillGroup("raw", r.rawWpm);
fillGroup("con", r.consistency + "%");
fillGroup("chardata", r.charStats.join("/"));

const [correct, missed, incorrect, extra] = r.charStats;

fillGroup("chardata", `${correct}/${missed}/${incorrect}/${extra}`);

let tt = r.mode + " " + r.mode2;

Expand Down
Loading