use of org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse in project OpenOLAT by OpenOLAT.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptions.
@Override
public List<StatisticSurveyItem> getStatisticAnswerOptions(QTIStatisticSearchParams searchParams, List<Item> items) {
StringBuilder sb = new StringBuilder();
sb.append("select res.itemIdent, res.answer, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
decorateRSet(sb, searchParams).append(" and res.duration > 0").append(" group by res.itemIdent, res.answer").append(" order by res.itemIdent");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return Collections.emptyList();
}
Map<String, Item> identToItemMap = new HashMap<>();
for (Item item : items) {
identToItemMap.put(item.getIdent(), item);
}
StatisticSurveyItem currentItem = null;
Map<Item, StatisticSurveyItem> itemToStatisticsMap = new HashMap<>();
for (Object[] result : results) {
String itemIdent = (String) result[0];
String answer = (String) result[1];
Long numOfAnswers = (Long) result[2];
Item item = identToItemMap.get(itemIdent);
if (currentItem == null || !currentItem.getItem().getIdent().equals(itemIdent)) {
currentItem = new StatisticSurveyItem(item);
itemToStatisticsMap.put(item, currentItem);
}
Response response = findResponses(item, answer);
currentItem.getResponses().add(new StatisticSurveyItemResponse(response, answer, numOfAnswers));
}
List<StatisticSurveyItem> reorderList = new ArrayList<>();
for (Item item : items) {
StatisticSurveyItem statsItem = itemToStatisticsMap.get(item);
if (statsItem != null) {
reorderList.add(statsItem);
}
}
return reorderList;
}
use of org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse in project openolat by klemens.
the class QTIStatisticsManagerImpl method getStatisticAnswerOptions.
@Override
public List<StatisticSurveyItem> getStatisticAnswerOptions(QTIStatisticSearchParams searchParams, List<Item> items) {
StringBuilder sb = new StringBuilder();
sb.append("select res.itemIdent, res.answer, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
decorateRSet(sb, searchParams).append(" and res.duration > 0").append(" group by res.itemIdent, res.answer").append(" order by res.itemIdent");
TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
decorateRSetQuery(query, searchParams);
List<Object[]> results = query.getResultList();
if (results.isEmpty()) {
return Collections.emptyList();
}
Map<String, Item> identToItemMap = new HashMap<>();
for (Item item : items) {
identToItemMap.put(item.getIdent(), item);
}
StatisticSurveyItem currentItem = null;
Map<Item, StatisticSurveyItem> itemToStatisticsMap = new HashMap<>();
for (Object[] result : results) {
String itemIdent = (String) result[0];
String answer = (String) result[1];
Long numOfAnswers = (Long) result[2];
Item item = identToItemMap.get(itemIdent);
if (currentItem == null || !currentItem.getItem().getIdent().equals(itemIdent)) {
currentItem = new StatisticSurveyItem(item);
itemToStatisticsMap.put(item, currentItem);
}
Response response = findResponses(item, answer);
currentItem.getResponses().add(new StatisticSurveyItemResponse(response, answer, numOfAnswers));
}
List<StatisticSurveyItem> reorderList = new ArrayList<>();
for (Item item : items) {
StatisticSurveyItem statsItem = itemToStatisticsMap.get(item);
if (statsItem != null) {
reorderList.add(statsItem);
}
}
return reorderList;
}
Aggregations