Search in sources :

Example 11 with ItemSessionControl

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

the class ItemSessionControlController method checkNotNull.

private ItemSessionControl checkNotNull(ItemSessionControl itemSessionControl) {
    if (itemSessionControl == null) {
        itemSessionControl = new ItemSessionControl(part);
        part.setItemSessionControl(itemSessionControl);
    }
    return itemSessionControl;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)

Example 12 with ItemSessionControl

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

the class AssessmentItemRefEditorController method getOrCreateItemSessionControl.

protected final ItemSessionControl getOrCreateItemSessionControl() {
    ItemSessionControl itemSessionControl = assessmentItemRef.getItemSessionControl();
    if (itemSessionControl == null) {
        itemSessionControl = new ItemSessionControl(assessmentItemRef);
        assessmentItemRef.setItemSessionControl(itemSessionControl);
    }
    return itemSessionControl;
}
Also used : ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)

Example 13 with ItemSessionControl

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

the class QTI12To21Converter method convert.

public AssessmentTest convert(VFSContainer originalContainer, QTIDocument doc, QTI21DeliveryOptions qti21Options) throws URISyntaxException {
    Assessment assessment = doc.getAssessment();
    AssessmentTest assessmentTest = new AssessmentTest();
    String assessmentTestIdentifier = IdentifierGenerator.newAssessmentTestFilename();
    File testFile = new File(unzippedDirRoot, assessmentTestIdentifier + ".xml");
    manifest.appendAssessmentTest(testFile.getName());
    assessmentTest.setIdentifier(assessmentTestIdentifier);
    assessmentTest.setTitle(assessment.getTitle());
    assessmentTest.setToolName(QTI21Constants.TOOLNAME);
    assessmentTest.setToolVersion(Settings.getVersion());
    convertDuration((Duration) assessment.getDuration(), assessmentTest);
    TestPart testPart = AssessmentTestFactory.createTestPart(assessmentTest);
    ItemSessionControl itemSessionControl = testPart.getItemSessionControl();
    Control tmpControl = QTIEditHelper.getControl(assessment);
    if (tmpControl.getSolution() == Control.CTRL_YES) {
        itemSessionControl.setShowSolution(Boolean.TRUE);
    }
    if (qti21Options != null) {
        qti21Options.setHideFeedbacks(false);
        if (assessment.isInheritControls() && tmpControl.getFeedback() != Control.CTRL_YES) {
            qti21Options.setHideFeedbacks(true);
        }
    }
    AssessmentTestBuilder assessmentTestBuilder = new AssessmentTestBuilder(assessmentTest);
    // root
    List<Section> sections = assessment.getSections();
    for (Section section : sections) {
        convert(section, testPart);
    }
    // this are lost in QTI 2.1
    // assessment.getSelection_ordering().getOrderType();
    // assessment.getSelection_ordering().getSelectionNumber();
    OutcomesProcessing outcomesProcessing = assessment.getOutcomes_processing();
    if (outcomesProcessing != null) {
        String cutValue = outcomesProcessing.getField(OutcomesProcessing.CUTVALUE);
        if (StringHelper.containsNonWhitespace(cutValue)) {
            try {
                assessmentTestBuilder.setCutValue(Double.valueOf(cutValue));
            } catch (NumberFormatException e) {
                log.error("Cannot parse cut value: " + cutValue, e);
            }
        }
    }
    assessmentTestBuilder.setMaxScore(atomicMaxScore.doubleValue());
    assessmentTest = assessmentTestBuilder.build();
    persistAssessmentObject(testFile, assessmentTest);
    manifest.write(new File(unzippedDirRoot, "imsmanifest.xml"));
    copyMaterial(originalContainer);
    return assessmentTest;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) AssessmentTestBuilder(org.olat.ims.qti21.model.xml.AssessmentTestBuilder) ItemSessionControl(uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl) Control(org.olat.ims.qti.editor.beecom.objects.Control) Assessment(org.olat.ims.qti.editor.beecom.objects.Assessment) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) OutcomesProcessing(org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing) File(java.io.File) Section(org.olat.ims.qti.editor.beecom.objects.Section) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)

Example 14 with ItemSessionControl

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

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

ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)18 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)8 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)6 File (java.io.File)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 FileOutputStream (java.io.FileOutputStream)2 URISyntaxException (java.net.URISyntaxException)2 Date (java.util.Date)2 Test (org.junit.Test)2 Assessment (org.olat.ims.qti.editor.beecom.objects.Assessment)2 Control (org.olat.ims.qti.editor.beecom.objects.Control)2 OutcomesProcessing (org.olat.ims.qti.editor.beecom.objects.OutcomesProcessing)2 Section (org.olat.ims.qti.editor.beecom.objects.Section)2 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)2 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)2 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)2 Selection (uk.ac.ed.ph.jqtiplus.node.test.Selection)2 TimeLimits (uk.ac.ed.ph.jqtiplus.node.test.TimeLimits)2