Skip to content

Commit

Permalink
Merge Conflicts dev-4.8.16 to cbrelease-4.8.16 (#654)
Browse files Browse the repository at this point in the history
* KB-3998 | DEV | Assessment | BE | Analysis and code changes for the randomization of the options/choices. (#645)

1. Created a custom method to shuffle the options.

* Commiting for top 10 learners api (#644)

* Commiting for top 10 learners api

* Commiting for top 10 learners api

* KB-6027 | DEV | Assessment | BE | Changes to allow new Question Type for Standalone Assessment which support FTB with Options. (#646)

1. Added new Qtype  to score calculation logic.

* Revert "KB-6027 | DEV | Assessment | BE | Changes to allow new Question Type …" (#649)

This reverts commit 745a081.

* commiting for fixed bug for top 10 learners (#651)

* KB-6027 |DEV | Assessment | BE | Changes to allow for Standalone Assessment with question type FTB to show Options. (#652)

1. Enabled the options to be show for the fill in the blanks with options.

* changed for rootorgId to minstryOrgId for top 10 learner. (#653)

* commiting for fixed bug for top 10 learners

* changed for rootorgId to minstryOrgId for top 10 learner.

---------

Co-authored-by: pathiktarento1089 <[email protected]>
  • Loading branch information
tarentomaheshvakkund and pathiktarento1089 authored Jul 25, 2024
1 parent 25e740d commit 5780fee
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public SBApiResponse readQuestionList(Map<String, Object> requestBody, String au
String assessmentIdFromRequest = (String) requestBody.get(Constants.ASSESSMENT_ID_KEY);
Map<String, Object> questionsMap = assessUtilServ.readQListfromCache(identifierList,assessmentIdFromRequest,editMode,authUserToken);
for (String questionId : identifierList) {
questionList.add(assessUtilServ.filterQuestionMapDetail((Map<String, Object>) questionsMap.get(questionId),
questionList.add(assessUtilServ.filterQuestionMapDetailV2((Map<String, Object>) questionsMap.get(questionId),
result.get(Constants.PRIMARY_CATEGORY)));
}
if (errMsg.isEmpty() && identifierList.size() == questionList.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public Map<String, Object> validateQumlAssessment(List<String> originalQuestionL
*/
public Map<String, Object> validateQumlAssessmentV2(Map<String, Object> questionSetDetailsMap, List<String> originalQuestionList,
List<Map<String, Object>> userQuestionList, Map<String,Object> questionMap);

Map<String, Object> filterQuestionMapDetailV2(Map<String, Object> questionMapResponse, String primaryCategory);
}
Original file line number Diff line number Diff line change
Expand Up @@ -796,4 +796,41 @@ public static List<Map<String, Object>> shuffleOptions(List<Map<String, Object>>
Collections.shuffle(shuffledList);
return shuffledList;
}

@Override
public Map<String, Object> filterQuestionMapDetailV2(Map<String, Object> questionMapResponse,
String primaryCategory) {
List<String> questionParams = serverProperties.getAssessmentQuestionParams();
Map<String, Object> 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<String, Object> editorState = (Map<String, Object>) questionMapResponse.get(Constants.EDITOR_STATE);
updatedQuestionMap.put(Constants.EDITOR_STATE, editorState);
}
if (questionMapResponse.containsKey(Constants.CHOICES)
&& updatedQuestionMap.containsKey(Constants.PRIMARY_CATEGORY)) {
Map<String, Object> choicesObj = (Map<String, Object>) questionMapResponse.get(Constants.CHOICES);
Map<String, Object> updatedChoicesMap = new HashMap<>();
if (choicesObj.containsKey(Constants.OPTIONS)) {
List<Map<String, Object>> optionsMapList = (List<Map<String, Object>>) 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<Object> rhsChoicesObj = (List<Object>) questionMapResponse.get(Constants.RHS_CHOICES);
Collections.shuffle(rhsChoicesObj);
updatedQuestionMap.put(Constants.RHS_CHOICES, rhsChoicesObj);
}

return updatedQuestionMap;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,11 +32,11 @@ public ResponseEntity<Map<String, Object>> fetchHallOfFameData() {
return new ResponseEntity<>(response, response.getResponseCode());
}

@GetMapping("/v1/top/learners")
@GetMapping("/v1/top/learners/{ministryOrgId}")
public ResponseEntity<SBApiResponse> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -126,24 +126,10 @@ public SBApiResponse fetchingTop10Learners(String rootOrgId, String authToken) {
setBadRequestResponse(response, Constants.USER_ID_DOESNT_EXIST);
return response;
}
Map<String, Object> propertiesMap = new HashMap<>();
propertiesMap.put(Constants.USER_ID_LOWER, userId);

List<Map<String, Object>> 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<String, Object> propMap = new HashMap<>();
int res = (Integer) userRowNum.get(0).get(Constants.DB_COLUMN_ROW_NUM);
List<Integer> 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<Map<String, Object>> result = cassandraOperation.getRecordsByPropertiesWithoutFiltering(
Constants.SUNBIRD_KEY_SPACE_NAME,
Expand Down

0 comments on commit 5780fee

Please sign in to comment.