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) {