From 50d8985a278c6ffb3b6954e4fcf7eec07c6e950e Mon Sep 17 00:00:00 2001 From: Evans Dianga Date: Mon, 18 Nov 2024 08:41:34 +0300 Subject: [PATCH] fix(scoring): Fix for regular scoring to use actual maxValueAnswer Part of #3720 Refs Tangerine-Community/Tangerine#3415 Refs Tangerine-Community/Tangerine#3416 --- .../src/app/class/_services/dashboard.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/client/src/app/class/_services/dashboard.service.ts b/client/src/app/class/_services/dashboard.service.ts index 1c78f9008..387ce1c54 100644 --- a/client/src/app/class/_services/dashboard.service.ts +++ b/client/src/app/class/_services/dashboard.service.ts @@ -242,7 +242,7 @@ export class DashboardService { if (item) { itemCount = item.inputs.length; - customScore = !isNaN(item.customScore)? item.customScore: null + customScore = item.customScore? item.customScore: null const metadata = item.metadata; if (metadata) { lastModified = metadata['lastModified']; @@ -388,8 +388,8 @@ export class DashboardService { maxValueAnswer = maxValueAnswer + max; } score = totalCorrect; - scorePercentageCorrect = !isNaN(customScore) ? customScore : this.classUtils.round(totalCorrect / maxValueAnswer * 100, 2); - if (!isNaN(customScore)) { + scorePercentageCorrect = customScore ? customScore : this.classUtils.round(totalCorrect / maxValueAnswer * 100, 2); + if (customScore) { maxValueAnswer = 100 } } @@ -430,7 +430,7 @@ export class DashboardService { totalIncorrect: totalIncorrect, maxValueAnswer: maxValueAnswer, totalCorrect: totalCorrect, - scorePercentageCorrect: !isNaN(customScore) ? customScore : scorePercentageCorrect, + scorePercentageCorrect: customScore ? customScore : scorePercentageCorrect, duration: duration, customScore: customScore }; @@ -503,15 +503,15 @@ export class DashboardService { studentResults.score = score; // console.log("student: " + studentResults["name"] + " form item: " + studentResults["response"]["formTitle"] + " score: " + score) } - const max = !isNaN(studentResponse.customScore)? 100: studentResponse.max; + const max = studentResponse.customScore? 100: studentResponse.max; if (max) { studentResults.max = max; classGroupReportMax = max; } - const totalCorrect = !isNaN(studentResponse.customScore) ? studentResponse.customScore : studentResponse.totalCorrect; - const scorePercentageCorrect = !isNaN(studentResponse.customScore) ? studentResponse.customScore : studentResponse.scorePercentageCorrect; + const totalCorrect = studentResponse.customScore ? studentResponse.customScore : studentResponse.totalCorrect; + const scorePercentageCorrect = studentResponse.customScore ? studentResponse.customScore : studentResponse.scorePercentageCorrect; studentResults.scorePercentageCorrect = scorePercentageCorrect; - const maxValueAnswer = !isNaN(studentResponse.customScore) ? 100: studentResponse.maxValueAnswer; + const maxValueAnswer = studentResponse.customScore ? 100: studentResponse.maxValueAnswer; studentResults.maxValueAnswer = maxValueAnswer; studentResults.customScore = studentResponse.customScore duration = studentResponse.duration;