Skip to content

Commit

Permalink
Changes for Handling Retired Courses
Browse files Browse the repository at this point in the history
  • Loading branch information
saipradeep_ravipati committed Apr 16, 2024
1 parent 0741676 commit 09cb72c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static Map<String, Object> getContent(String id) {
if(obj != null)
return obj;
else{
contentMap.putAll(ContentUtil.getAllContent(Arrays.asList(id.split("")),Integer.parseInt(PropertiesCache.getInstance()
contentMap.putAll(ContentUtil.getAllContent(Arrays.asList(id),Integer.parseInt(PropertiesCache.getInstance()
.getProperty(JsonKey.PAGE_SIZE_CONTENT_FETCH))));
return (Map<String, Object>)contentMap.get(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ public static Map.Entry<Integer, Map<String, Map<String, Object>>> contents(List
queryFields.addAll(Arrays.asList(queryFieldsParam.split(",")));
searchDTO.setFields(queryFields);
filters.put(JsonKey.MIME_TYPE, JsonKey.COLLECTION_MIME_TYPE);
filters.put(JsonKey.STATUS,JsonKey.LIVE);
List<String> status = new ArrayList<>();
status.add(JsonKey.LIVE);
status.add(JsonKey.RETIRED);
filters.put(JsonKey.STATUS,status);
if(identifierList != null && identifierList.size() > 0)
filters.put(JsonKey.IDENTIFIER,identifierList);
searchDTO.getAdditionalProperties().put(JsonKey.FILTERS, filters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,28 @@ class CourseEnrolmentActor @Inject()(@Named("course-batch-notification-actor") c
enrolmentData.setStatus(getCompletionStatus(enrolmentData.getProgress, leafNodesCount))
}

def addCourseDetails_v2(activeEnrolments: java.util.List[java.util.Map[String, AnyRef]]): java.util.List[java.util.Map[String, AnyRef]] = {
def getCourseContent(courseId: String): java.util.Map[String, AnyRef] = {
val coursesMap = ContentCacheHandler.getContentMap.asInstanceOf[java.util.Map[String, java.util.Map[String, AnyRef]]]
activeEnrolments.map(enrolment => {
var courseContent = coursesMap.get(enrolment.get(JsonKey.COURSE_ID))
if (courseContent == null || courseContent.size() < 1)
courseContent = ContentCacheHandler.getContent(enrolment.get(JsonKey.COURSE_ID).asInstanceOf[String])
var courseContent = coursesMap.get(courseId)
if (courseContent == null || courseContent.size() < 1)
courseContent = ContentCacheHandler.getContent(courseId)
courseContent
}

def isCourseEligible(enrolment: java.util.Map[String, AnyRef]): Boolean = {
val courseContent = getCourseContent(enrolment.get(JsonKey.COURSE_ID).asInstanceOf[String])
if (null == courseContent || (!JsonKey.LIVE.equalsIgnoreCase(courseContent.get(JsonKey.STATUS).asInstanceOf[String])
&& !isRetiredCoursesIncludedInEnrolList)) {
false
}
else {
true
}
}

def addCourseDetails_v2(activeEnrolments: java.util.List[java.util.Map[String, AnyRef]]): java.util.List[java.util.Map[String, AnyRef]] = {
activeEnrolments.filter(enrolment => isCourseEligible(enrolment)).map(enrolment => {
val courseContent = getCourseContent(enrolment.get(JsonKey.COURSE_ID).asInstanceOf[String])
enrolment.put(JsonKey.COURSE_NAME, courseContent.get(JsonKey.NAME))
enrolment.put(JsonKey.DESCRIPTION, courseContent.get(JsonKey.DESCRIPTION))
enrolment.put(JsonKey.LEAF_NODE_COUNT, courseContent.get(JsonKey.LEAF_NODE_COUNT))
Expand All @@ -533,6 +549,7 @@ class CourseEnrolmentActor @Inject()(@Named("course-batch-notification-actor") c
enrolment
}).toList.asJava
}

def enrollProgram(request: Request): Unit = {
val programId: String = request.get(JsonKey.PROGRAM_ID).asInstanceOf[String]
val isAdminAPI: Boolean = request.get(JsonKey.IS_ADMIN_API).asInstanceOf[Boolean]
Expand Down

0 comments on commit 09cb72c

Please sign in to comment.