final Map<Long,Map<String,Boolean>> questionMap =
new LinkedHashMap<>();
Map<String ,List<LMSExamPaperQuestionReference>> map =
new LinkedHashMap<>();
List<LMSExamPaperQuestionReference> examPaperQuestionReferences = (List<LMSExamPaperQuestionReference>)examPaperQuestionReferenceCriteria.list();
for(
int i =
0;i<examPaperQuestionReferences.size();i++){
String groupName = examPaperQuestionReferences.get(i).getExamQuestion().getQuestionGroup();
if (!map.containsKey(groupName)){
map.put(examPaperQuestionReferences.get(i).getExamQuestion().getQuestionGroup(),
new LinkedList());
}
map.get(groupName).add(examPaperQuestionReferences.get(i)); //实现按groupName分组,即一个key对应多个value
}
for(Map.Entry<String,List<LMSExamPaperQuestionReference>> entry : map.entrySet()){ //遍历map得到value
List<LMSExamPaperQuestionReference> list2 = entry.getValue();
int index =
0 ;
for (LMSExamPaperQuestionReference item : list2) {
Map<String,Boolean> questionMapItem =
new LinkedHashMap<String, Boolean>();
questionMapItem.put(
"up",
true);
questionMapItem.put(
"down",
true);
questionMap.put(item.getExamQuestion().getId(),questionMapItem);
if(index ==
0){
questionMap.get(item.getExamQuestion().getId()).put(
"up",
false);
}
if(index == list2.size() -
1){
questionMap.get(item.getExamQuestion().getId()).put(
"down",
false);
}
index ++;
}
}