Search in sources :

Example 1 with StatisticSurveyItem

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);
}
Also used : StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) BarSeries(org.olat.core.gui.components.chart.BarSeries) ArrayList(java.util.ArrayList) StatisticFormatter.getModeString(org.olat.ims.qti.statistics.ui.StatisticFormatter.getModeString) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 2 with StatisticSurveyItem

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);
}
Also used : StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) BarSeries(org.olat.core.gui.components.chart.BarSeries) ArrayList(java.util.ArrayList) StatisticFormatter.getModeString(org.olat.ims.qti.statistics.ui.StatisticFormatter.getModeString) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Example 3 with StatisticSurveyItem

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;
}
Also used : StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)

Example 4 with StatisticSurveyItem

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;
}
Also used : StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) StatisticSurveyItem(org.olat.ims.qti.statistics.model.StatisticSurveyItem) StatisticsItem(org.olat.ims.qti.statistics.model.StatisticsItem) Item(org.olat.ims.qti.editor.beecom.objects.Item) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) StatisticSurveyItemResponse(org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)

Aggregations

ArrayList (java.util.ArrayList)4 Item (org.olat.ims.qti.editor.beecom.objects.Item)4 StatisticItem (org.olat.ims.qti.statistics.model.StatisticItem)4 StatisticSurveyItem (org.olat.ims.qti.statistics.model.StatisticSurveyItem)4 HashMap (java.util.HashMap)2 BarSeries (org.olat.core.gui.components.chart.BarSeries)2 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)2 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)2 Response (org.olat.ims.qti.editor.beecom.objects.Response)2 StatisticSurveyItemResponse (org.olat.ims.qti.statistics.model.StatisticSurveyItemResponse)2 StatisticsItem (org.olat.ims.qti.statistics.model.StatisticsItem)2 StatisticFormatter.getModeString (org.olat.ims.qti.statistics.ui.StatisticFormatter.getModeString)2