diff --git a/src/main/java/org/sunbird/common/service/ContentServiceImpl.java b/src/main/java/org/sunbird/common/service/ContentServiceImpl.java index f22af0f2c..f0212c192 100644 --- a/src/main/java/org/sunbird/common/service/ContentServiceImpl.java +++ b/src/main/java/org/sunbird/common/service/ContentServiceImpl.java @@ -186,7 +186,7 @@ public Map searchLiveContent(String contentId) { Map contentRequestValue = new HashMap<>(); contentRequestValue.put(Constants.FILTERS, filters); contentRequestValue.put(Constants.FIELDS, - Arrays.asList(Constants.IDENTIFIER, Constants.NAME, Constants.PRIMARY_CATEGORY, Constants.BATCHES)); + Arrays.asList(Constants.IDENTIFIER, Constants.NAME, Constants.PRIMARY_CATEGORY, Constants.BATCHES, Constants.LEAF_NODES_COUNT)); Map contentRequest = new HashMap<>(); contentRequest.put(Constants.REQUEST, contentRequestValue); response = outboundRequestHandlerService.fetchResultUsingPost( diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index 21586ebba..81f794262 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -530,6 +530,7 @@ public class Constants { public static final String CONTENT_TYPE_SEARCH = "contentType"; public static final String NEW_COURSES = "newcourses"; public static final String OVERVIEW_BATCH_KEY = "/overview?batchId="; + public static final String LEAF_NODES_COUNT = "leafNodesCount"; private Constants() { throw new IllegalStateException("Utility class"); diff --git a/src/main/java/org/sunbird/progress/service/MandatoryContentServiceImpl.java b/src/main/java/org/sunbird/progress/service/MandatoryContentServiceImpl.java index b33fc5bef..3066d9a70 100644 --- a/src/main/java/org/sunbird/progress/service/MandatoryContentServiceImpl.java +++ b/src/main/java/org/sunbird/progress/service/MandatoryContentServiceImpl.java @@ -198,8 +198,16 @@ public Map getUserProgress(SunbirdApiRequest requestBody, String // set completion percentage & status String courseId = (String) responseObj.get(Constants.COURSE_ID); if (!courseLeafCount.containsKey(courseId)) { - SunbirdApiResp contentResponse = contentService.getHeirarchyResponse(courseId); - courseLeafCount.put(courseId, contentResponse.getResult().getContent().getLeafNodesCount()); + Map contentResponse = contentService.searchLiveContent(courseId); + if (!ObjectUtils.isEmpty(contentResponse)) { + Map contentResult = (Map) contentResponse.get(Constants.RESULT); + if (0 < (Integer) contentResult.get(Constants.COUNT)) { + List> contentList = (List>) contentResult + .get(Constants.CONTENT); + Map content = contentList.get(0); + courseLeafCount.put(courseId, (Integer) content.get(Constants.LEAF_NODES_COUNT)); + } + } } setCourseCompletiondetails(responseObj, courseLeafCount.get(courseId)); }