Commits (2)
......@@ -191,4 +191,14 @@ public class ReportController {
log.debug("Inside ReportController called method getPercentageWiseInfographicReport with parameter,startDate={},endDate={},assessmentId={},subLobId={}",startDate,endDate,assessmentId,subLobId);
return reportService.getPercentageWiseInfographicReport(startDate, endDate, assessmentId,subLobId);
}
@RequestMapping(method=RequestMethod.GET,value="/api/admin/getQuizResultWiseAssesmentInfographicReport")
public ResponseEntity<Map<String, Integer>> getQuizResultWiseAssesmentInfographicReport (
@RequestParam(value = "startDate", required = true) String startDate,
@RequestParam(value = "endDate", required = true) String endDate,
@RequestParam(value = "assessmentId", required = true) long assessmentId,
@RequestParam(value = "subLobId") long subLobId) throws Exception{
log.debug("Inside ReportController called method getQuizResultWiseAssesmentInfographicReport with parameter,startDate={},endDate={},assessmentId={},subLobId={}",startDate,endDate,assessmentId,subLobId);
return reportService.getQuizResultWiseAssesmentInfographicReport(startDate, endDate, assessmentId,subLobId);
}
}
......@@ -41,4 +41,6 @@ public interface QuestionSetRepositoryCustom {
public List<BotQuizResult> getUserQuestionList(String userId) throws Exception;
List<DBObject> getUnattemptedUsers(Date startDate,Date endDate,String filterCriteria,String filterValue) throws Exception;
List<DBObject> getUnattemptedQuestionSetCount(long assessmentId) throws Exception;
}
......@@ -247,4 +247,23 @@ public class QuestionSetRepositoryImpl implements QuestionSetRepositoryCustom{
return result.getMappedResults();
}
@Override
public List<DBObject> getUnattemptedQuestionSetCount(long assessmentId) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside QuestionSetRepositoryImpl called getUnattemptedQuestionSetUsers method");
//AggregationOperation match = Aggregation.match(Criteria.where("isAttempted").is(false).and(Criteria.where("")));
AggregationOperation match = Aggregation.match(new Criteria().andOperator(
(Criteria.where("assessmentId").is(assessmentId))));
Cond questionSet =ConditionalOperators.when(Criteria.where("isAttempted").is(false)).then(1).otherwise(0);
AggregationOperation project = Aggregation.project("assessmentId").and(questionSet).as("pendingCount");
AggregationOperation group = Aggregation.group("assessmentId").sum("pendingCount").as("pendingCount");
Aggregation agg = Aggregation.newAggregation(match,project,group);
AggregationResults<DBObject> result = template.aggregate(agg,COLLECTION,DBObject.class);
log.debug("Response returned from QuestionSetRepositoryImpl -- getUnattemptedQuestionSetUsers , result={}",result.getMappedResults());
if(result.getMappedResults().size()!=0)
return result.getMappedResults();
else
return null;
}
}
......@@ -3,11 +3,15 @@
*/
package com.statestreet.dao;
import java.util.Date;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import com.mongodb.DBObject;
import com.statestreet.model.QuizResult;
/**
......@@ -19,4 +23,5 @@ import com.statestreet.model.QuizResult;
public interface QuizResultRepository extends MongoRepository<QuizResult, String>,QuizResultRepositoryCustom{
List<QuizResult> findByQuestionSet_QuestionSetId(long questionSetId);
}
......@@ -76,4 +76,6 @@ public interface QuizResultRepositoryCustom {
List<DBObject> getPercentageWiseAssessmentReport(Date stDate, Date enDate, long assessmentId, long subLobId) throws Exception;
List<DBObject> getQuizResultWiseAssesmentInfographicReport(Date stDate, Date enDate, long assessmentId,
long subLobId)throws Exception;
}
......@@ -840,6 +840,39 @@ AggregationOperation match = Aggregation.match(new Criteria().andOperator(Crite
return result.getMappedResults();
}
@Override
public List<DBObject> getQuizResultWiseAssesmentInfographicReport(Date stDate, Date enDate, long assessmentId,
long subLobId) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside QuizResultRepositoryImpl called getQuizResultWiseAssesmentInfographicReport method, with parameter "
+ "stDate={},enDate={},assessmentId={},subLobId={}",stDate,enDate,assessmentId,subLobId);
AggregationOperation match = null;
if(subLobId>0)
{
match = Aggregation.match(new Criteria().andOperator(Criteria.where("quizDate").gte(stDate).lte(enDate),Criteria.where("questionSet.subLob._id").is(subLobId)
, Criteria.where("questionSet.assessmentId").is(assessmentId)));
}
//AggregationOperation project = Aggregation.project("_id").and("quizOutcome").as("quizOutcome");
// AggregationOperation sort = Aggregation.sort(Sort.Direction.ASC,"_id");
// AggregationOperation group=Aggregation.group("_id","quizOutcome").last("userId").as("userId");
Cond passQuiz =ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Pass.name())).then(1).otherwise(0);
Cond failQuiz =ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Fail.name())).then(1).otherwise(0);
Cond evalPendingQuiz = ConditionalOperators.when(Criteria.where("quizOutcome").is(CommonUtils.Quiz_Status.Pending.name())).then(1).otherwise(0);
AggregationOperation projectQ = Aggregation.project("_id").and("questionSet.assessmentId").as("assessmentId")
.and(passQuiz).as("pass").and(failQuiz).as("fail").and(evalPendingQuiz).as("evalPending")
;
AggregationOperation groupQ=Aggregation.group("assessmentId").sum("pass").as("pass").sum("fail").as("fail")
.sum("evalPending").as("evalPending");
Aggregation agg = Aggregation.newAggregation(match,projectQ,groupQ);
AggregationResults<DBObject> result = template.aggregate(agg,COLLECTION,DBObject.class);
log.debug("Response returned from QuizResultRepositoryImpl--getQuizResultWiseAssesmentInfographicReport method,result={}",result.getMappedResults().size());
return result.getMappedResults();
}
////
......
......@@ -58,4 +58,7 @@ public interface ReportService {
public ResponseEntity<Map<String, Integer>> getPercentageWiseInfographicReport(String startDate, String endDate,
long assessmentId, long subLobId)throws Exception;
public ResponseEntity<Map<String, Integer>> getQuizResultWiseAssesmentInfographicReport(String startDate,
String endDate, long assessmentId, long subLobId)throws Exception;
}
......@@ -586,4 +586,50 @@ public class ReportServiceImpl implements ReportService{
}
}
@Override
public ResponseEntity<Map<String, Integer>> getQuizResultWiseAssesmentInfographicReport(String startDate,
String endDate, long assessmentId, long subLobId) throws Exception {
// TODO Auto-generated method stub
log.debug("Inside ReportServiceImpl called method getQuizResultWiseAssesmentInfographicReport with parameter, startDate={},endDate={},assessmentId={},subLobId={}",
startDate,endDate,assessmentId,subLobId);
DATE_FORMAT.setTimeZone(CommonUtils.TIME_ZONE);
Date stDate=DATE_FORMAT.parse(startDate);
Date enDate=DATE_FORMAT.parse(endDate);
Calendar cal = Calendar.getInstance();
cal.setTime(enDate);
cal.add(Calendar.DATE,1);
enDate=DATE_FORMAT.parse(DATE_FORMAT.format(cal.getTime()));
int grandTotal=0;
int pending=0;
List<DBObject> quizResult=quizResultRepo.getQuizResultWiseAssesmentInfographicReport(stDate, enDate, assessmentId,subLobId);
List<DBObject> questionSet = quesSetRepo.getUnattemptedQuestionSetCount(assessmentId);
Map<String, Integer> hashMap = new HashMap<String,Integer>();
for(DBObject result:quizResult) {
if(questionSet.size()>0)
pending = (Integer)questionSet.get(0).get("pendingCount");
grandTotal=(Integer)result.get("pass")+(Integer)result.get("fail")+(Integer)result.get("evalPending")+pending;
hashMap.put("pass",(Integer)result.get("pass"));
hashMap.put("fail",(Integer)result.get("fail"));
hashMap.put("evalPending",(Integer)result.get("evalPending"));
hashMap.put("pending", pending);
hashMap.put("grand total", grandTotal);
}
if(hashMap.size()>0)
{
log.debug("Response returned from ReportServiceImpl --getQuizResultWiseAssesmentInfographicReport method, No of record={}",hashMap.size());
return new ResponseEntity<Map<String, Integer>> (hashMap,HttpStatus.OK);
}
else
{
log.debug("Response returned from ReportServiceImpl --getQuizResultWiseAssesmentInfographicReport method -- No record found");
return new ResponseEntity<Map<String, Integer>> (HttpStatus.NO_CONTENT);
}
}
}