Search in sources :

Example 1 with AssessmentSection

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection in project OpenOLAT by OpenOLAT.

the class AssessmentTestHelper method getParentSection.

public static ParentPartItemRefs getParentSection(TestPlanNodeKey itemKey, TestSessionState testSessionState, ResolvedAssessmentTest resolvedAssessmentTest) {
    ParentPartItemRefs parentParts = new ParentPartItemRefs();
    try {
        TestPlanNode currentItem = testSessionState.getTestPlan().getNode(itemKey);
        List<AssessmentItemRef> itemRefs = resolvedAssessmentTest.getItemRefsBySystemIdMap().get(currentItem.getItemSystemId());
        AssessmentItemRef itemRef = null;
        if (itemRefs.size() == 1) {
            itemRef = itemRefs.get(0);
        } else {
            Identifier itemId = itemKey.getIdentifier();
            for (AssessmentItemRef ref : itemRefs) {
                if (ref.getIdentifier().equals(itemId)) {
                    itemRef = ref;
                    break;
                }
            }
        }
        if (itemRef != null) {
            for (QtiNode parentPart = itemRef.getParent(); parentPart != null; parentPart = parentPart.getParent()) {
                if (parentParts.getSectionIdentifier() == null && parentPart instanceof AssessmentSection) {
                    AssessmentSection section = (AssessmentSection) parentPart;
                    parentParts.setSectionIdentifier(section.getIdentifier().toString());
                } else if (parentParts.getTestPartIdentifier() == null && parentPart instanceof TestPart) {
                    TestPart testPart = (TestPart) parentPart;
                    parentParts.setTestPartIdentifier(testPart.getIdentifier().toString());
                }
            }
        }
    } catch (Exception e) {
        log.error("", e);
    }
    return parentParts;
}
Also used : ParentPartItemRefs(org.olat.ims.qti21.model.ParentPartItemRefs) TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) Identifier(uk.ac.ed.ph.jqtiplus.types.Identifier) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) QtiNode(uk.ac.ed.ph.jqtiplus.node.QtiNode)

Example 2 with AssessmentSection

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection in project OpenOLAT by OpenOLAT.

the class AssessmentTestHelper method visit.

/**
 * Go through the section part (assessmentSection or assessmentItemRef), visit recursively
 * the sections and assessment item refs.
 *
 * @param sectionPart
 * @param visitor
 */
public static void visit(SectionPart sectionPart, AssessmentTestVisitor visitor) {
    visitor.visit(sectionPart);
    if (sectionPart instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) sectionPart;
        List<SectionPart> childParts = section.getChildAbstractParts();
        if (childParts != null && childParts.size() > 0) {
            for (SectionPart childPart : childParts) {
                visit(childPart, visitor);
            }
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)

Example 3 with AssessmentSection

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection in project OpenOLAT by OpenOLAT.

the class QTI21ArchiveFormat method getItemInfos.

private List<AbstractInfos> getItemInfos() {
    if (elementInfos == null) {
        numOfSections = 0;
        elementInfos = new ArrayList<>();
        AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractAssumingSuccessful();
        for (TestPart part : assessmentTest.getTestParts()) {
            for (AssessmentSection section : part.getAssessmentSections()) {
                collectElementInfos(section);
            }
        }
    }
    return elementInfos;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 4 with AssessmentSection

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection in project OpenOLAT by OpenOLAT.

the class BigAssessmentTestPackageBuilder method createAssessmentTest.

@Test
public void createAssessmentTest() throws URISyntaxException {
    String date = format.format(new Date());
    File directory = new File("/HotCoffee/qti/" + date + "/");
    directory.mkdirs();
    ManifestBuilder manifest = ManifestBuilder.createAssessmentTestBuilder();
    System.out.println(directory);
    // test
    File testFile = new File(directory, IdentifierGenerator.newAssessmentTestFilename());
    AssessmentTest assessmentTest = AssessmentTestFactory.createAssessmentTest("Big test " + date, "Section");
    manifest.appendAssessmentTest(testFile.getName());
    TestPart part = assessmentTest.getTestParts().get(0);
    part.getAssessmentSections().clear();
    // section
    for (int i = 0; i < numOfSections; i++) {
        AssessmentSection section = new AssessmentSection(part);
        section.setFixed(Boolean.TRUE);
        section.setVisible(Boolean.TRUE);
        section.setTitle((i + 1) + ". Section");
        section.setIdentifier(IdentifierGenerator.newAsIdentifier("sec"));
        part.getAssessmentSections().add(section);
        Ordering ordering = new Ordering(section);
        ordering.setShuffle(true);
        section.setOrdering(ordering);
        Selection selection = new Selection(section);
        selection.setSelect(4);
        section.setSelection(selection);
        ItemSessionControl itemSessionControl = new ItemSessionControl(section);
        itemSessionControl.setAllowSkipping(Boolean.TRUE);
        itemSessionControl.setAllowComment(Boolean.FALSE);
        itemSessionControl.setShowFeedback(Boolean.FALSE);
        section.setItemSessionControl(itemSessionControl);
        RubricBlock rubrickBlock = new RubricBlock(section);
        rubrickBlock.setViews(Collections.singletonList(View.CANDIDATE));
        section.getRubricBlocks().add(rubrickBlock);
        for (int j = 0; j < numOfQuestions; j++) {
            // single choice
            String itemId = IdentifierGenerator.newAsString(QTI21QuestionType.sc.getPrefix());
            File itemFile = new File(directory, itemId + ".xml");
            AssessmentItem assessmentItem = AssessmentItemFactory.createSingleChoice("Single choice", "New answer");
            assessmentItem.setTitle((i + 1) + "." + (j + 1) + ". Question SC");
            AssessmentTestFactory.appendAssessmentItem(section, itemFile.getName());
            manifest.appendAssessmentItem(itemFile.getName());
            try (FileOutputStream out = new FileOutputStream(itemFile)) {
                qtiSerializer.serializeJqtiObject(assessmentItem, out);
            } catch (Exception e) {
                log.error("", e);
            }
        }
    }
    try (FileOutputStream out = new FileOutputStream(testFile)) {
        qtiSerializer.serializeJqtiObject(assessmentTest, out);
    } catch (Exception e) {
        log.error("", e);
    }
    manifest.write(new File(directory, "imsmanifest.xml"));
}
Also used : ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) FileOutputStream(java.io.FileOutputStream) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) File(java.io.File) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) Test(org.junit.Test)

Example 5 with AssessmentSection

use of uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection in project OpenOLAT by OpenOLAT.

the class AssessmentTestComposerController method doDelete.

private void doDelete(UserRequest ureq, TreeNode selectedNode) {
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof TestPart) {
        doDeleteTestPart(ureq, (TestPart) uobject);
    } else if (uobject instanceof AssessmentSection) {
        AssessmentSection section = (AssessmentSection) uobject;
        if (checkAtLeastOneSection(section)) {
            doDeleteAssessmentSection(ureq, section);
        } else {
            showWarning("warning.atleastonesection");
        }
    } else if (uobject instanceof AssessmentItemRef) {
        doDeleteAssessmentItemRef(ureq, (AssessmentItemRef) uobject);
    } else {
        // cannot delete test or test part
        return;
    }
    doSaveAssessmentTest(ureq, null);
    doSaveManifest();
    updateTreeModel(false);
    if (selectedNode != null && selectedNode.getParent() != null) {
        TreeNode parentNode = (TreeNode) selectedNode.getParent();
        menuTree.setSelectedNode(parentNode);
        menuTree.open(parentNode);
        partEditorFactory(ureq, parentNode);
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)

Aggregations

AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)62 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)28 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)26 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)26 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 File (java.io.File)20 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)20 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)20 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)20 URISyntaxException (java.net.URISyntaxException)16 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)14 IOException (java.io.IOException)12 URI (java.net.URI)12 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)12 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)10 SectionPart (uk.ac.ed.ph.jqtiplus.node.test.SectionPart)10 FileOutputStream (java.io.FileOutputStream)8 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 ArrayList (java.util.ArrayList)6 QuestionItemFull (org.olat.modules.qpool.QuestionItemFull)6