This commit is contained in:
lingdocs 2022-08-29 19:53:01 +04:00
parent a3219230bc
commit 21072755c1
1 changed files with 17 additions and 10 deletions

View File

@ -103,6 +103,8 @@ function getPercentageComplete(
tests: undefined | AT.TestResult[],
): "not logged in" | number {
if (!tests) return "not logged in";
console.log({ tests, chapter });
try {
const chapterTestIds = chapter.items.map(gr => gr.id);
const userCompletedIds = tests.map(t => t.id);
const required = chapterTestIds.length;
@ -113,6 +115,11 @@ function getPercentageComplete(
return Math.round(
(completed / (required + 1)) * 100
);
} catch (e) {
console.error("error getting per");
console.error(e);
return 0;
}
}
export default GamesBrowser;