From a04cb3d4a7e42e1310659fdc6689e18fe0655eea Mon Sep 17 00:00:00 2001 From: SaipradeepR <53404427+SaipradeepR@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:55:20 +0530 Subject: [PATCH] KB-5745 | If user submits the test without selecting any answer options, then the system is considering the assessment as unattempted (#640) (#643) * KB-5745 | If user submits the test without selecting any answer options, then the system is considering the assessment as unattempted 1. If NaN value is there for double while convert the object to Json using mapper class its throwing error. Fixed by checking the value is greater than 0 * KB-5883 | The popup should be shown when user clicks on Retake button immediately after maximum attempt attended 1. If the retakeAttemptconsumed if less than 0 then consider it to be 0 Co-authored-by: tarentomaheshvakkund <139739142+tarentomaheshvakkund@users.noreply.github.com> --- .../service/AssessmentServiceV5Impl.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java index efe199840..150a34bef 100644 --- a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java +++ b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java @@ -83,7 +83,9 @@ public SBApiResponse retakeAssessment(String assessmentIdentifier, String token, // if (serverProperties.isAssessmentRetakeCountVerificationEnabled()) { retakeAttemptsConsumed = calculateAssessmentRetakeCount(userId, assessmentIdentifier); - retakeAttemptsConsumed=retakeAttemptsConsumed-1; + if(retakeAttemptsConsumed>0){ + retakeAttemptsConsumed=retakeAttemptsConsumed-1; + } //} } catch (Exception e) { errMsg = String.format("Error while calculating retake assessment. Exception: %s", e.getMessage()); @@ -820,7 +822,11 @@ private Map calculateSectionFinalResults(List 0 && inCorrect>0) { + res.put(Constants.OVERALL_RESULT, ((double) correct / (double) (correct + inCorrect)) * 100); + }else{ + res.put(Constants.OVERALL_RESULT,0.0); + } res.put(Constants.BLANK, blank); res.put(Constants.CORRECT, correct); res.put(Constants.INCORRECT, inCorrect); @@ -828,8 +834,12 @@ private Map calculateSectionFinalResults(List0.0 && totalMarks>0) { + double totalPercentage = (totalSectionMarks / (double) totalMarks) * 100; + res.put(Constants.TOTAL_PERCENTAGE, totalPercentage); + }else{ + res.put(Constants.TOTAL_PERCENTAGE,0.0); + } res.put(Constants.TOTAL_SECTION_MARKS, totalSectionMarks); res.put(Constants.TOTAL_MARKS, totalMarks); } catch (Exception e) {