Search in sources :

Example 86 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTIWordExport method renderItem.

public static void renderItem(Item item, OpenXMLDocument document, boolean withResponses, Translator translator) {
    Element el = DocumentFactory.getInstance().createElement("dummy");
    item.addToElement(el);
    Element itemEl = (Element) el.elements().get(0);
    org.olat.ims.qti.container.qtielements.Item foo = new org.olat.ims.qti.container.qtielements.Item(itemEl);
    RenderInstructions renderInstructions = new RenderInstructions();
    renderInstructions.put(RenderInstructions.KEY_STATICS_PATH, "/");
    renderInstructions.put(RenderInstructions.KEY_LOCALE, translator.getLocale());
    renderInstructions.put(RenderInstructions.KEY_RENDER_TITLE, Boolean.TRUE);
    if (item.getQuestion() != null) {
        Map<String, String> iinput = new HashMap<String, String>();
        String questionType = null;
        String questionScore = null;
        Question question = item.getQuestion();
        if (question instanceof ChoiceQuestion) {
            ChoiceQuestion choice = (ChoiceQuestion) question;
            if (question.getType() == Question.TYPE_SC) {
                questionType = translator.translate("item.type.sc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_MC) {
                questionType = translator.translate("item.type.mc");
                fetchPointsOfMultipleChoices(itemEl, choice, iinput);
            } else if (question.getType() == Question.TYPE_KPRIM) {
                questionType = translator.translate("item.type.kprim");
                fetchPointsOfKPrim(itemEl, choice, iinput);
            }
        } else if (question instanceof FIBQuestion) {
            questionType = translator.translate("item.type.sc");
            for (Response response : question.getResponses()) {
                FIBResponse fibResponse = (FIBResponse) response;
                if ("BLANK".equals(fibResponse.getType())) {
                    iinput.put(fibResponse.getIdent(), fibResponse.getCorrectBlank());
                }
            }
        } else if (question instanceof EssayQuestion) {
            questionType = translator.translate("item.type.essay");
        }
        if (question != null && question.getMaxValue() > 0.0f) {
            questionScore = AssessmentHelper.getRoundedScore(question.getMaxValue());
            questionScore = translator.translate("item.score.long", new String[] { questionScore });
        }
        renderInstructions.put(RenderInstructions.KEY_RENDER_CORRECT_RESPONSES, new Boolean(withResponses));
        renderInstructions.put(RenderInstructions.KEY_CORRECT_RESPONSES_MAP, iinput);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_TYPE, questionType);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_SCORE, questionScore);
        renderInstructions.put(RenderInstructions.KEY_QUESTION_OO_TYPE, new Integer(question.getType()));
    }
    foo.renderOpenXML(document, renderInstructions);
}
Also used : EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) HashMap(java.util.HashMap) Element(org.dom4j.Element) RenderInstructions(org.olat.ims.qti.container.qtielements.RenderInstructions) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Response(org.olat.ims.qti.editor.beecom.objects.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) FIBResponse(org.olat.ims.qti.editor.beecom.objects.FIBResponse) Item(org.olat.ims.qti.editor.beecom.objects.Item) EssayQuestion(org.olat.ims.qti.editor.beecom.objects.EssayQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) Question(org.olat.ims.qti.editor.beecom.objects.Question) ChoiceQuestion(org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion) FIBQuestion(org.olat.ims.qti.editor.beecom.objects.FIBQuestion)

Example 87 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTIStatisticResourceResult method getController.

public Controller getController(UserRequest ureq, WindowControl wControl, TooledStackedPanel stackPanel, TreeNode selectedNode, boolean printMode) {
    if (selectedNode instanceof StatisticResourceNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else if (selectedNode instanceof SectionNode) {
        return createAssessmentController(ureq, wControl, stackPanel, printMode);
    } else if (selectedNode instanceof ItemNode) {
        Section section = null;
        INode sectionNode = selectedNode.getParent();
        if (sectionNode instanceof SectionNode) {
            section = (Section) ((SectionNode) sectionNode).getUserObject();
        }
        Item item = (Item) ((ItemNode) selectedNode).getUserObject();
        return createItemController(ureq, wControl, section, item, printMode);
    }
    return null;
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) INode(org.olat.core.util.nodes.INode) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) SectionNode(org.olat.ims.qti.editor.tree.SectionNode) Section(org.olat.ims.qti.editor.beecom.objects.Section)

Example 88 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item 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)

Example 89 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTIStatisticsManagerImpl method getStatisticPerItem.

@Override
public List<StatisticItem> getStatisticPerItem(List<Item> items, QTIStatisticSearchParams searchParams, double numOfParticipants) {
    StringBuilder sb = new StringBuilder();
    sb.append("select res.itemIdent, res.score, count(res.key) from qtistatsresult res ").append(" inner join res.resultSet rset");
    decorateRSet(sb, searchParams);
    sb.append(" group by res.itemIdent, res.score");
    TypedQuery<Object[]> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
    decorateRSetQuery(query, searchParams);
    List<Object[]> results = query.getResultList();
    Map<String, StatisticItemHelper> itemToHelpers = new HashMap<>();
    for (Object[] result : results) {
        String itemIdent = (String) result[0];
        Float score = (Float) result[1];
        Long count = (Long) result[2];
        if (count == null || score == null || itemIdent == null)
            continue;
        StatisticItemHelper helper = itemToHelpers.get(itemIdent);
        if (helper == null) {
            helper = new StatisticItemHelper();
            itemToHelpers.put(itemIdent, helper);
        }
        helper.count += count.longValue();
        helper.totalScore += (count.longValue() * score.doubleValue());
        for (Item item : items) {
            if (item.getIdent().equals(itemIdent)) {
                double maxValue = item.getQuestion().getMaxValue();
                if (Math.abs(score.doubleValue() - maxValue) < 0.0001) {
                    helper.countCorrectAnswers += count.longValue();
                }
            }
        }
    }
    List<StatisticItem> averages = new ArrayList<>();
    for (Item item : items) {
        StatisticItemHelper helper = itemToHelpers.get(item.getIdent());
        if (helper == null) {
            averages.add(new StatisticItem(item, -1.0, -1.0, -1, -1));
        } else {
            long numOfAnswersItem = helper.count;
            long numOfCorrectAnswers = helper.countCorrectAnswers;
            double average = (helper.totalScore / helper.count);
            double averageParticipants = (helper.totalScore / numOfParticipants);
            averages.add(new StatisticItem(item, average, averageParticipants, numOfAnswersItem, numOfCorrectAnswers));
        }
    }
    return averages;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem)

Example 90 with Item

use of org.olat.ims.qti.editor.beecom.objects.Item in project openolat by klemens.

the class QTI12AssessmentStatisticsController method initScoreStatisticPerItem.

private void initScoreStatisticPerItem(List<Item> items, double numOfParticipants) {
    BarSeries d1 = new BarSeries();
    BarSeries d2 = new BarSeries();
    List<StatisticItem> statisticItems = qtiStatisticsManager.getStatisticPerItem(items, resourceResult.getSearchParams(), numOfParticipants);
    int i = 0;
    List<ItemInfos> itemInfos = new ArrayList<>(items.size());
    for (StatisticItem statisticItem : statisticItems) {
        Item item = statisticItem.getItem();
        String label = Integer.toString(++i);
        String text = item.getTitle();
        d1.add(statisticItem.getAverageScore(), label);
        double numOfRightAnswers = statisticItem.getNumOfCorrectAnswers();
        double res = numOfRightAnswers;
        d2.add(res, label);
        itemInfos.add(new ItemInfos(label, text));
    }
    mainVC.contextPut("itemInfoList", itemInfos);
    VelocityContainer averageScorePeritemVC = createVelocityContainer("hbar_average_score_per_item");
    Stringuified data1 = BarSeries.getDatasAndColors(Collections.singletonList(d1), "bar_default");
    averageScorePeritemVC.contextPut("datas", data1);
    mainVC.put("averageScorePerItemChart", averageScorePeritemVC);
    VelocityContainer percentRightAnswersPerItemVC = createVelocityContainer("hbar_right_answer_per_item");
    Stringuified data2 = BarSeries.getDatasAndColors(Collections.singletonList(d2), "bar_green");
    percentRightAnswersPerItemVC.contextPut("datas", data2);
    percentRightAnswersPerItemVC.contextPut("numOfParticipants", Long.toString(Math.round(numOfParticipants)));
    mainVC.put("percentRightAnswersPerItemChart", percentRightAnswersPerItemVC);
}
Also used : 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) StatisticItem(org.olat.ims.qti.statistics.model.StatisticItem) Stringuified(org.olat.core.gui.components.chart.BarSeries.Stringuified) ArrayList(java.util.ArrayList) BarSeries(org.olat.core.gui.components.chart.BarSeries) StatisticFormatter.getModeString(org.olat.ims.qti.statistics.ui.StatisticFormatter.getModeString) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer)

Aggregations

Item (org.olat.ims.qti.editor.beecom.objects.Item)92 VFSItem (org.olat.core.util.vfs.VFSItem)38 Section (org.olat.ims.qti.editor.beecom.objects.Section)28 ArrayList (java.util.ArrayList)24 VFSContainer (org.olat.core.util.vfs.VFSContainer)18 Control (org.olat.ims.qti.editor.beecom.objects.Control)18 Element (org.dom4j.Element)16 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)16 ChoiceQuestion (org.olat.ims.qti.editor.beecom.objects.ChoiceQuestion)16 Translator (org.olat.core.gui.translator.Translator)14 FIBResponse (org.olat.ims.qti.editor.beecom.objects.FIBResponse)14 Response (org.olat.ims.qti.editor.beecom.objects.Response)14 ItemNode (org.olat.ims.qti.editor.tree.ItemNode)14 File (java.io.File)12 QuestionItem (org.olat.modules.qpool.QuestionItem)12 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10 FIBQuestion (org.olat.ims.qti.editor.beecom.objects.FIBQuestion)10 GenericQtiNode (org.olat.ims.qti.editor.tree.GenericQtiNode)10 SectionNode (org.olat.ims.qti.editor.tree.SectionNode)10 StatisticItem (org.olat.ims.qti.statistics.model.StatisticItem)10