Search in sources :

Example 41 with AssessmentSection

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

the class AssessmentTestFactory method appendAssessmentSectionInternal.

private static final AssessmentSection appendAssessmentSectionInternal(String title, AbstractPart part) {
    // section
    AssessmentSection section = new AssessmentSection(part);
    section.setFixed(Boolean.TRUE);
    section.setVisible(Boolean.TRUE);
    section.setTitle(title);
    section.setIdentifier(IdentifierGenerator.newAsIdentifier("sect"));
    if (part instanceof TestPart) {
        ((TestPart) part).getAssessmentSections().add(section);
    } else if (part instanceof AssessmentSection) {
        ((AssessmentSection) part).getSectionParts().add(section);
    }
    // section ordering
    Ordering ordering = new Ordering(section);
    ordering.setShuffle(false);
    section.setOrdering(ordering);
    // section rubric block
    RubricBlock rubricBlock = new RubricBlock(section);
    rubricBlock.setViews(Collections.singletonList(View.CANDIDATE));
    section.getRubricBlocks().add(rubricBlock);
    ItemSessionControl itemSessionControl = new ItemSessionControl(section);
    section.setItemSessionControl(itemSessionControl);
    return section;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)

Example 42 with AssessmentSection

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

the class QTI21WordExport method exportTest.

private void exportTest(AssessmentTest assessmentTest, String header, ZipOutputStream out, boolean withResponses) {
    try (ShieldOutputStream sout = new ShieldOutputStream(out);
        ZipOutputStream zout = new ZipOutputStream(sout)) {
        zout.setLevel(9);
        OpenXMLDocument document = new OpenXMLDocument();
        document.setMediaContainer(mediaContainer);
        document.setDocumentHeader(header);
        Translator translator = Util.createPackageTranslator(AssessmentTestDisplayController.class, locale, Util.createPackageTranslator(AssessmentTestComposerController.class, locale));
        renderAssessmentTest(assessmentTest, document, translator);
        for (TestPart testPart : assessmentTest.getChildAbstractParts()) {
            List<AssessmentSection> assessmentSections = testPart.getAssessmentSections();
            for (AssessmentSection assessmentSection : assessmentSections) {
                renderAssessmentSection(assessmentSection, document, withResponses, translator);
            }
        }
        OpenXMLDocumentWriter writer = new OpenXMLDocumentWriter();
        writer.createDocument(zout, document);
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : OpenXMLDocumentWriter(org.olat.core.util.openxml.OpenXMLDocumentWriter) ShieldOutputStream(org.olat.core.util.io.ShieldOutputStream) Translator(org.olat.core.gui.translator.Translator) ZipOutputStream(java.util.zip.ZipOutputStream) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) OpenXMLDocument(org.olat.core.util.openxml.OpenXMLDocument) AssessmentTestComposerController(org.olat.ims.qti21.ui.editor.AssessmentTestComposerController) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException)

Example 43 with AssessmentSection

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

the class QTI21WordExport method renderAssessmentSection.

public void renderAssessmentSection(AssessmentSection assessmentSection, OpenXMLDocument document, boolean withResponses, Translator translator) {
    String title = assessmentSection.getTitle();
    document.appendHeading1(title, null);
    List<RubricBlock> rubricBlocks = assessmentSection.getRubricBlocks();
    for (RubricBlock rubricBlock : rubricBlocks) {
        String htmlRubric = htmlBuilder.blocksString(rubricBlock.getBlocks());
        document.appendHtmlText(htmlRubric, true);
    }
    for (SectionPart sectionPart : assessmentSection.getChildAbstractParts()) {
        if (sectionPart instanceof AssessmentSection) {
            renderAssessmentSection((AssessmentSection) sectionPart, document, withResponses, translator);
        } else if (sectionPart instanceof AssessmentItemRef) {
            AssessmentItemRef itemRef = (AssessmentItemRef) sectionPart;
            ResolvedAssessmentItem resolvedAssessmentItem = resolvedAssessmentTest.getResolvedAssessmentItem(itemRef);
            AssessmentItem assessmentItem = resolvedAssessmentItem.getRootNodeLookup().extractIfSuccessful();
            URI itemUri = resolvedAssessmentTest.getSystemIdByItemRefMap().get(itemRef);
            renderAssessmentItem(assessmentItem, new File(itemUri), mediaDir, document, withResponses, translator, htmlBuilder);
            document.appendPageBreak();
        }
    }
}
Also used : SectionPart(uk.ac.ed.ph.jqtiplus.node.test.SectionPart) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) AssessmentItemRef(uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef) ResolvedAssessmentItem(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) URI(java.net.URI) File(java.io.File)

Example 44 with AssessmentSection

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

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 45 with AssessmentSection

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

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)

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