use of org.olat.ims.qti.statistics.model.StatisticSurveyItem in project OpenOLAT by OpenOLAT.
the class QTI12AssessmentStatisticsController method initItemsOverview.
private void initItemsOverview(List<Item> items) {
List<StatisticSurveyItem> surveyItems = qtiStatisticsManager.getStatisticAnswerOptions(resourceResult.getSearchParams(), items);
int count = 0;
List<String> overviewList = new ArrayList<>();
for (StatisticSurveyItem surveyItem : surveyItems) {
Item item = surveyItem.getItem();
Series series = seriesfactory.getSeries(item, null);
if (series != null) {
// essay hasn't a series
String name = "overview_" + count++;
VelocityContainer vc = createVelocityContainer(name, "hbar_item_overview");
vc.contextPut("series", series);
vc.contextPut("question", item.getQuestion().getQuestion().renderAsHtml(mediaBaseURL));
vc.contextPut("questionType", item.getQuestion().getType());
vc.contextPut("title", item.getTitle());
mainVC.put(vc.getDispatchID(), vc);
overviewList.add(vc.getDispatchID());
}
}
mainVC.contextPut("overviewList", overviewList);
}
use of org.olat.ims.qti.statistics.model.StatisticSurveyItem in project openolat by klemens.
the class QTI12AssessmentStatisticsController method initItemsOverview.
private void initItemsOverview(List<Item> items) {
List<StatisticSurveyItem> surveyItems = qtiStatisticsManager.getStatisticAnswerOptions(resourceResult.getSearchParams(), items);
int count = 0;
List<String> overviewList = new ArrayList<>();
for (StatisticSurveyItem surveyItem : surveyItems) {
Item item = surveyItem.getItem();
Series series = seriesfactory.getSeries(item, null);
if (series != null) {
// essay hasn't a series
String name = "overview_" + count++;
VelocityContainer vc = createVelocityContainer(name, "hbar_item_overview");
vc.contextPut("series", series);
vc.contextPut("question", item.getQuestion().getQuestion().renderAsHtml(mediaBaseURL));
vc.contextPut("questionType", item.getQuestion().getType());
vc.contextPut("title", item.getTitle());
mainVC.put(vc.getDispatchID(), vc);
overviewList.add(vc.getDispatchID());
}
}
mainVC.contextPut("overviewList", overviewList);
}
use of org.olat.ims.qti.statistics.model.StatisticSurveyItem 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.StatisticSurveyItem 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