Search in sources :

Example 51 with Item

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

the class QTIStatisticResourceResult method buildQTICourseNodeSubTree.

private void buildQTICourseNodeSubTree(QTIDocument qtiDoc, GenericTreeNode rootNode) {
    for (Section section : qtiDoc.getAssessment().getSections()) {
        GenericTreeNode sectionNode = new SectionNode(section, null);
        sectionNode.setUserObject(section);
        rootNode.addChild(sectionNode);
        for (Item item : section.getItems()) {
            GenericTreeNode itemNode = new ItemNode(item);
            itemNode.setIdent(Long.toString(CodeHelper.getForeverUniqueID()));
            if (sectionNode.getDelegate() == null) {
                sectionNode.setDelegate(itemNode);
            }
            itemNode.setUserObject(item);
            sectionNode.addChild(itemNode);
        }
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) ItemNode(org.olat.ims.qti.editor.tree.ItemNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) Section(org.olat.ims.qti.editor.beecom.objects.Section) SectionNode(org.olat.ims.qti.editor.tree.SectionNode)

Example 52 with Item

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

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

the class QTIQPoolServiceProvider method copyItem.

@Override
public void copyItem(QuestionItemFull original, QuestionItemFull copy) {
    VFSContainer originalDir = qpoolFileStorage.getContainer(original.getDirectory());
    VFSContainer copyDir = qpoolFileStorage.getContainer(copy.getDirectory());
    VFSManager.copyContent(originalDir, copyDir);
    VFSLeaf itemLeaf = qpoolService.getRootLeaf(copy);
    Item item = QTIEditHelper.readItemXml(itemLeaf);
    item.setTitle(copy.getTitle());
    QTIEditHelper.serialiazeItem(item, itemLeaf);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) Item(org.olat.ims.qti.editor.beecom.objects.Item) VFSItem(org.olat.core.util.vfs.VFSItem) QuestionItem(org.olat.modules.qpool.QuestionItem) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 54 with Item

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

the class CSVToQuestionConverter method processFeedbackWrongAnswer.

private void processFeedbackWrongAnswer(String[] parts) {
    if (currentItem == null || parts.length < 2)
        return;
    String feedback = parts[1];
    if (StringHelper.containsNonWhitespace(feedback)) {
        Item item = currentItem.getItem();
        Control control = QTIEditHelper.getControl(item);
        if (control.getFeedback() != 1) {
            control.setFeedback(1);
        }
        QTIEditHelper.setFeedbackFail(item, feedback);
    }
}
Also used : Item(org.olat.ims.qti.editor.beecom.objects.Item) Control(org.olat.ims.qti.editor.beecom.objects.Control)

Example 55 with Item

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

the class IQConfigurationController method needManualCorrectionQTI12.

private boolean needManualCorrectionQTI12(RepositoryEntry re) {
    boolean needManualCorrection = false;
    QTIDocument doc = TestFileResource.getQTIDocument(re.getOlatResource());
    if (doc != null && doc.getAssessment() != null) {
        Assessment ass = doc.getAssessment();
        // Sections with their Items
        List<Section> sections = ass.getSections();
        for (Section section : sections) {
            List<Item> items = section.getItems();
            for (Item item : items) {
                String ident = item.getIdent();
                if (ident != null && ident.startsWith("QTIEDIT:ESSAY")) {
                    needManualCorrection = true;
                    break;
                }
            }
        }
    }
    return needManualCorrection;
}
Also used : QTIDocument(org.olat.ims.qti.editor.beecom.objects.QTIDocument) Item(org.olat.ims.qti.editor.beecom.objects.Item) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) Section(org.olat.ims.qti.editor.beecom.objects.Section)

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