Skip to content

Commit

Permalink
KB-5130 | DEV| Assessment | BE | Enhancement in Consumption Logic for…
Browse files Browse the repository at this point in the history
… the QuestionWeightage Assessment Type (#615)

1. Score Calculation fix for practice assessment.
  • Loading branch information
tarentomaheshvakkund authored Jun 20, 2024
1 parent 28ca582 commit b274de9
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,13 @@ public SBApiResponse submitAssessmentAsync(Map<String, Object> submitRequest, St
}
}
if (Constants.SECTION_LEVEL_SCORE_CUTOFF.equalsIgnoreCase(scoreCutOffType)) {
boolean practiceAssessmentFlag = ((String) assessmentHierarchy.get(Constants.PRIMARY_CATEGORY)).equalsIgnoreCase(Constants.PRACTICE_QUESTION_SET);
long assessmentStartTime = 0;
if (existingAssessmentData.get(Constants.START_TIME)!=null) {
Date assessmentStart = (Date) existingAssessmentData.get(Constants.START_TIME);
assessmentStartTime = assessmentStart.getTime();
}
Map<String, Object> result = calculateSectionFinalResults(sectionLevelsResults,assessmentStartTime,assessmentCompletionTime,maxAssessmentRetakeAttempts,retakeAttemptsConsumed);
Map<String, Object> result = calculateSectionFinalResults(sectionLevelsResults,assessmentStartTime,assessmentCompletionTime,maxAssessmentRetakeAttempts,retakeAttemptsConsumed,practiceAssessmentFlag);
outgoingResponse.getResult().putAll(result);
outgoingResponse.getParams().setStatus(Constants.SUCCESS);
outgoingResponse.setResponseCode(HttpStatus.OK);
Expand Down Expand Up @@ -789,7 +790,7 @@ private void writeDataToDatabaseAndTriggerKafkaEvent(Map<String, Object> submitR
}
}

private Map<String, Object> calculateSectionFinalResults(List<Map<String, Object>> sectionLevelResults,long assessmentStartTime,long assessmentCompletionTime,int maxAssessmentRetakeAttempts,int retakeAttemptsConsumed) {
private Map<String, Object> calculateSectionFinalResults(List<Map<String, Object>> sectionLevelResults, long assessmentStartTime, long assessmentCompletionTime, int maxAssessmentRetakeAttempts, int retakeAttemptsConsumed, boolean practiceAssessmentFlag) {
Map<String, Object> res = new HashMap<>();
Double result;
Integer correct = 0;
Expand Down Expand Up @@ -819,7 +820,11 @@ private Map<String, Object> calculateSectionFinalResults(List<Map<String, Object
totalMarks += (Integer) sectionChildren.get(Constants.TOTAL_MARKS);
}
}
res.put(Constants.OVERALL_RESULT, totalResult / sectionLevelResults.size());
if(practiceAssessmentFlag){
res.put(Constants.OVERALL_RESULT, (correct / blank+correct+inCorrect) * 100);
}else{
res.put(Constants.OVERALL_RESULT, totalResult / sectionLevelResults.size());
}
res.put(Constants.BLANK, blank);
res.put(Constants.CORRECT, correct);
res.put(Constants.INCORRECT, inCorrect);
Expand Down

0 comments on commit b274de9

Please sign in to comment.