Search in sources :

Example 1 with Ordering

use of uk.ac.ed.ph.jqtiplus.node.test.Ordering 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 2 with Ordering

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

the class AssessmentSectionOptionsEditorController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    section.setTitle(titleEl.getValue());
    // rubrics
    List<RubricBlock> rubricBlocks = new ArrayList<>();
    for (RichTextElement rubricEl : rubricEls) {
        String rubric = rubricEl.getRawValue();
        if (htmlBuilder.containsSomething(rubric)) {
            RubricBlock rubricBlock = (RubricBlock) rubricEl.getUserObject();
            if (rubricBlock == null) {
                rubricBlock = new RubricBlock(section);
                rubricBlock.setViews(Collections.singletonList(View.CANDIDATE));
            }
            rubricBlock.getBlocks().clear();
            htmlBuilder.appendHtml(rubricBlock, rubric);
            rubricBlocks.add(rubricBlock);
        }
    }
    section.getRubricBlocks().clear();
    section.getRubricBlocks().addAll(rubricBlocks);
    // shuffle
    boolean shuffle = (shuffleEl.isOneSelected() && shuffleEl.isSelected(0));
    if (shuffle) {
        if (section.getOrdering() == null) {
            section.setOrdering(new Ordering(section));
        }
        section.getOrdering().setShuffle(shuffle);
    } else {
        section.setOrdering(null);
    }
    // number of selected questions
    Integer randomSelection = null;
    if (StringHelper.containsNonWhitespace(randomSelectedEl.getSelectedKey())) {
        randomSelection = new Integer(randomSelectedEl.getSelectedKey());
    }
    if (randomSelection == null || randomSelection.intValue() < 1) {
        section.setSelection(null);
    } else {
        if (section.getSelection() == null) {
            section.setSelection(new Selection(section));
        }
        section.getSelection().setSelect(randomSelection);
    }
    fireEvent(ureq, new AssessmentSectionEvent(AssessmentSectionEvent.ASSESSMENT_SECTION_CHANGED, section));
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) Selection(uk.ac.ed.ph.jqtiplus.node.test.Selection) ArrayList(java.util.ArrayList) Ordering(uk.ac.ed.ph.jqtiplus.node.test.Ordering) RubricBlock(uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock) AssessmentSectionEvent(org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)

Example 3 with Ordering

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

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 4 with Ordering

use of uk.ac.ed.ph.jqtiplus.node.test.Ordering 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 5 with Ordering

use of uk.ac.ed.ph.jqtiplus.node.test.Ordering 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)

Aggregations

RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)6 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)6 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)4 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)4 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)4 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)4 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Test (org.junit.Test)2 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)2 AssessmentSectionEvent (org.olat.ims.qti21.ui.editor.events.AssessmentSectionEvent)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)2 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)2 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)2