diff --git a/pom.xml b/pom.xml
index 93d43dec3..a0501d899 100644
--- a/pom.xml
+++ b/pom.xml
@@ -171,6 +171,10 @@
poi-ooxml
3.11
+
+ redis.clients
+ jedis
+
diff --git a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV2Impl.java b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV2Impl.java
index df6a22f48..4c1377115 100644
--- a/src/main/java/org/sunbird/assessment/service/AssessmentServiceV2Impl.java
+++ b/src/main/java/org/sunbird/assessment/service/AssessmentServiceV2Impl.java
@@ -1,6 +1,16 @@
package org.sunbird.assessment.service;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -17,9 +27,8 @@
import org.sunbird.core.exception.ApplicationLogicError;
import org.sunbird.core.logger.CbExtLogger;
-import java.sql.Timestamp;
-import java.util.*;
-import java.util.stream.Collectors;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
@Service
@SuppressWarnings("unchecked")
@@ -43,52 +52,62 @@ public class AssessmentServiceV2Impl implements AssessmentServiceV2 {
@Autowired
AssessmentRepository assessmentRepository;
- public SBApiResponse readAssessment(String assessmentIdentifier, String token) throws Exception {
- SBApiResponse response = new SBApiResponse();
- try {
- String userId = RequestInterceptor.fetchUserIdFromAccessToken(token);
- if (userId != null) {
- Map assessmentAllDetail = (Map) redisCacheMgr
- .getCache(Constants.ASSESSMENT_ID + assessmentIdentifier);
- boolean isSuccess = true;
- if (ObjectUtils.isEmpty(assessmentAllDetail)) {
- Map hierarcyReadApiResponse = getReadHierarchyApiResponse(assessmentIdentifier, token);
- if (!Constants.OK.equalsIgnoreCase((String) hierarcyReadApiResponse.get(Constants.RESPONSE_CODE))) {
- isSuccess = false;
- } else {
- assessmentAllDetail = (Map) ((Map) hierarcyReadApiResponse
- .get(Constants.RESULT)).get(Constants.QUESTION_SET);
- redisCacheMgr.putCache(Constants.ASSESSMENT_ID + assessmentIdentifier, assessmentAllDetail);
- }
- }
- response = prepareAssessmentResponse(assessmentAllDetail, isSuccess);
- redisCacheMgr.putCache(Constants.USER_ASSESS_REQ + token, response.getResult().get(Constants.QUESTION_SET));
- if (assessmentAllDetail.get(Constants.DURATION) != null) {
- boolean resp = assessmentRepository.addUserAssesmentStartTime(userId, Constants.ASSESSMENT_ID + assessmentIdentifier, new Timestamp(new Date().getTime()));
- return response;
- }
- }
- } catch (Exception e) {
- logger.error(e);
- throw new ApplicationLogicError("REQUEST_COULD_NOT_BE_PROCESSED", e);
- }
- return response;
- }
+ public SBApiResponse readAssessment(String assessmentIdentifier, String token) throws Exception {
+ SBApiResponse response = new SBApiResponse();
+ try {
+ String userId = RequestInterceptor.fetchUserIdFromAccessToken(token);
+ if (userId != null) {
+ String strAssessmentAllDetail = redisCacheMgr.getCache(Constants.ASSESSMENT_ID + assessmentIdentifier);
+
+ Map assessmentAllDetail = mapper.readValue(strAssessmentAllDetail,
+ new TypeReference