From 692d7c2ced43f686e7fdb7d696c60b6b684c79ea Mon Sep 17 00:00:00 2001 From: karthik-tarento Date: Thu, 24 Mar 2022 14:42:20 +0530 Subject: [PATCH] Fixes for type cast issue in assessment submit --- .../service/AssessmentUtilServiceV2Impl.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java index e17b1f113..e7384b23b 100644 --- a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java +++ b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java @@ -72,7 +72,7 @@ public Map validateQumlAssessment(List originalQuestionL case MCQ_MCA: for (Map option : options) { if ((boolean) option.get(SELECTED_ANSWER)) { - marked.add(Integer.toString((int) option.get(INDEX))); + marked.add((String) option.get(INDEX)); } } break; @@ -131,23 +131,25 @@ private Map getQumlAnswers(List questions) throws Except if (question.containsKey(QUESTION_TYPE)) { String questionType = ((String) question.get(QUESTION_TYPE)).toLowerCase(); Map editorStateObj = (Map) question.get(EDITOR_STATE); + List> options = (List>) editorStateObj.get(OPTIONS); switch (questionType) { case MTF: - for (Map options : (List>) editorStateObj.get(OPTIONS)) { - Map valueObj = (Map) options.get(VALUE); - correctOption - .add(valueObj.get(VALUE).toString() + "-" + valueObj.get(BODY).toString().toLowerCase() - + "-" + options.get(ANSWER).toString().toLowerCase()); + for (Map option : options) { + Map valueObj = (Map) option.get(VALUE); + correctOption.add( + valueObj.get(VALUE).toString() + "-" + option.get(ANSWER).toString().toLowerCase()); } break; case FTB: - correctOption.add((String) editorStateObj.get(ANSWER)); + for (Map option : options) { + correctOption.add((String) option.get(SELECTED_ANSWER)); + } break; case MCQ_SCA: case MCQ_MCA: - for (Map options : (List>) editorStateObj.get(OPTIONS)) { - if ((boolean) options.get(ANSWER)) { - Map valueObj = (Map) options.get(VALUE); + for (Map option : options) { + if ((boolean) option.get(ANSWER)) { + Map valueObj = (Map) option.get(VALUE); correctOption.add(valueObj.get(VALUE).toString()); } }