diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java index efe199840..bf9cf764b 100644 --- a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java +++ b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV5Impl.java @@ -238,7 +238,7 @@ public SBApiResponse readQuestionList(Map requestBody, String au String assessmentIdFromRequest = (String) requestBody.get(Constants.ASSESSMENT_ID_KEY); Map questionsMap = assessUtilServ.readQListfromCache(identifierList,assessmentIdFromRequest,editMode,authUserToken); for (String questionId : identifierList) { - questionList.add(assessUtilServ.filterQuestionMapDetail((Map) questionsMap.get(questionId), + questionList.add(assessUtilServ.filterQuestionMapDetailV2((Map) questionsMap.get(questionId), result.get(Constants.PRIMARY_CATEGORY))); } if (errMsg.isEmpty() && identifierList.size() == questionList.size()) { diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2.java b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2.java index 3de59dd36..4b09e0f09 100644 --- a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2.java +++ b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2.java @@ -37,4 +37,6 @@ public Map validateQumlAssessment(List originalQuestionL */ public Map validateQumlAssessmentV2(Map questionSetDetailsMap, List originalQuestionList, List> userQuestionList, Map questionMap); + + Map filterQuestionMapDetailV2(Map questionMapResponse, String primaryCategory); } diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java index 600f55675..6c85faee7 100644 --- a/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java +++ b/src/main/java/org/sunbird/assessment/service/AssessmentUtilServiceV2Impl.java @@ -796,4 +796,41 @@ public static List> shuffleOptions(List> Collections.shuffle(shuffledList); return shuffledList; } + + @Override + public Map filterQuestionMapDetailV2(Map questionMapResponse, + String primaryCategory) { + List questionParams = serverProperties.getAssessmentQuestionParams(); + Map updatedQuestionMap = new HashMap<>(); + for (String questionParam : questionParams) { + if (questionMapResponse.containsKey(questionParam)) { + updatedQuestionMap.put(questionParam, questionMapResponse.get(questionParam)); + } + } + if (questionMapResponse.containsKey(Constants.EDITOR_STATE) + && primaryCategory.equalsIgnoreCase(Constants.PRACTICE_QUESTION_SET)) { + Map editorState = (Map) questionMapResponse.get(Constants.EDITOR_STATE); + updatedQuestionMap.put(Constants.EDITOR_STATE, editorState); + } + if (questionMapResponse.containsKey(Constants.CHOICES) + && updatedQuestionMap.containsKey(Constants.PRIMARY_CATEGORY)) { + Map choicesObj = (Map) questionMapResponse.get(Constants.CHOICES); + Map updatedChoicesMap = new HashMap<>(); + if (choicesObj.containsKey(Constants.OPTIONS)) { + List> optionsMapList = (List>) choicesObj + .get(Constants.OPTIONS); + updatedChoicesMap.put(Constants.OPTIONS, shuffleOptions(optionsMapList)); + } + updatedQuestionMap.put(Constants.CHOICES, updatedChoicesMap); + } + if (questionMapResponse.containsKey(Constants.RHS_CHOICES) + && updatedQuestionMap.containsKey(Constants.PRIMARY_CATEGORY) && updatedQuestionMap + .get(Constants.PRIMARY_CATEGORY).toString().equalsIgnoreCase(Constants.MTF_QUESTION)) { + List rhsChoicesObj = (List) questionMapResponse.get(Constants.RHS_CHOICES); + Collections.shuffle(rhsChoicesObj); + updatedQuestionMap.put(Constants.RHS_CHOICES, rhsChoicesObj); + } + + return updatedQuestionMap; + } } \ No newline at end of file diff --git a/src/main/java/org/sunbird/halloffame/controller/HallOfFameController.java b/src/main/java/org/sunbird/halloffame/controller/HallOfFameController.java index 40c74000b..8410e5f81 100644 --- a/src/main/java/org/sunbird/halloffame/controller/HallOfFameController.java +++ b/src/main/java/org/sunbird/halloffame/controller/HallOfFameController.java @@ -3,10 +3,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.sunbird.common.model.SBApiResponse; import org.sunbird.common.util.Constants; import org.sunbird.halloffame.service.HallOfFameService; @@ -35,11 +32,11 @@ public ResponseEntity> fetchHallOfFameData() { return new ResponseEntity<>(response, response.getResponseCode()); } - @GetMapping("/v1/top/learners") + @GetMapping("/v1/top/learners/{ministryOrgId}") public ResponseEntity fetchingTopLearners (@RequestHeader(Constants.X_AUTH_TOKEN) String authToken, - @RequestHeader(Constants.X_AUTH_USER_ORG_ID) String rootOrgId) throws Exception { - SBApiResponse response = hallOfFameService.fetchingTop10Learners(rootOrgId, authToken); + @PathVariable String ministryOrgId) throws Exception { + SBApiResponse response = hallOfFameService.fetchingTop10Learners(ministryOrgId, authToken); return new ResponseEntity<>(response, response.getResponseCode()); } } diff --git a/src/main/java/org/sunbird/halloffame/service/HallOfFameService.java b/src/main/java/org/sunbird/halloffame/service/HallOfFameService.java index cb372fd70..4acc51ad1 100644 --- a/src/main/java/org/sunbird/halloffame/service/HallOfFameService.java +++ b/src/main/java/org/sunbird/halloffame/service/HallOfFameService.java @@ -12,5 +12,5 @@ public interface HallOfFameService { public SBApiResponse learnerLeaderBoard(String rootOrgId, String authToken); - public SBApiResponse fetchingTop10Learners(String rootOrgId, String authToken); + public SBApiResponse fetchingTop10Learners(String ministryOrgId, String authToken); } diff --git a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java index 5b467b90b..b11020112 100644 --- a/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java +++ b/src/main/java/org/sunbird/halloffame/service/HallOfFameServiceImpl.java @@ -114,10 +114,10 @@ public SBApiResponse learnerLeaderBoard(String rootOrgId, String authToken) { } @Override - public SBApiResponse fetchingTop10Learners(String rootOrgId, String authToken) { + public SBApiResponse fetchingTop10Learners(String ministryOrgId, String authToken) { SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.TOP_10_LEARNERS); try { - if (StringUtils.isEmpty(rootOrgId)) { + if (StringUtils.isEmpty(ministryOrgId)) { setBadRequestResponse(response, Constants.ORG_ID_MISSING); return response; } @@ -126,24 +126,10 @@ public SBApiResponse fetchingTop10Learners(String rootOrgId, String authToken) { setBadRequestResponse(response, Constants.USER_ID_DOESNT_EXIST); return response; } - Map propertiesMap = new HashMap<>(); - propertiesMap.put(Constants.USER_ID_LOWER, userId); - - List> userRowNum = cassandraOperation.getRecordsByPropertiesWithoutFiltering( - Constants.SUNBIRD_KEY_SPACE_NAME, - Constants.TABLE_LEARNER_LEADER_BOARD_LOOK_UP, - propertiesMap, - null - ); - if (CollectionUtils.isEmpty(userRowNum)) { - setNotFoundResponse(response, Constants.USER_ID_DOESNT_EXIST); - return response; - } Map propMap = new HashMap<>(); - int res = (Integer) userRowNum.get(0).get(Constants.DB_COLUMN_ROW_NUM); List ranksFilter = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); propMap.put(Constants.DB_COLUMN_ROW_NUM, ranksFilter); - propMap.put(Constants.ORGID, rootOrgId); + propMap.put(Constants.ORGID, ministryOrgId); List> result = cassandraOperation.getRecordsByPropertiesWithoutFiltering( Constants.SUNBIRD_KEY_SPACE_NAME,