Search in sources :

Example 16 with TestPart

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

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

the class AssessmentTestFactory method createAssessmentTest.

/**
 * Create an assessmentTest object but without items
 *
 * @param title
 * @return
 */
public static AssessmentTest createAssessmentTest(String title, String sectionTitle) {
    AssessmentTest assessmentTest = new AssessmentTest();
    assessmentTest.setIdentifier(IdentifierGenerator.newAsString("test"));
    assessmentTest.setTitle(title);
    assessmentTest.setToolName(QTI21Constants.TOOLNAME);
    assessmentTest.setToolVersion(Settings.getVersion());
    // outcome score
    OutcomeDeclaration scoreOutcomeDeclaration = new OutcomeDeclaration(assessmentTest);
    scoreOutcomeDeclaration.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
    scoreOutcomeDeclaration.setCardinality(Cardinality.SINGLE);
    scoreOutcomeDeclaration.setBaseType(BaseType.FLOAT);
    assessmentTest.getOutcomeDeclarations().add(scoreOutcomeDeclaration);
    // test part
    TestPart part = createTestPart(assessmentTest);
    appendAssessmentSection(sectionTitle, part);
    // outcome processing
    OutcomeProcessing outcomeProcessing = new OutcomeProcessing(assessmentTest);
    assessmentTest.setOutcomeProcessing(outcomeProcessing);
    SetOutcomeValue outcomeRule = new SetOutcomeValue(outcomeProcessing);
    outcomeRule.setIdentifier(QTI21Constants.SCORE_IDENTIFIER);
    Sum sum = new Sum(outcomeRule);
    outcomeRule.getExpressions().add(sum);
    TestVariables testVariables = new TestVariables(sum);
    testVariables.setVariableIdentifier(QTI21Constants.SCORE_IDENTIFIER);
    sum.getExpressions().add(testVariables);
    outcomeProcessing.getOutcomeRules().add(outcomeRule);
    return assessmentTest;
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) SetOutcomeValue(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.SetOutcomeValue) OutcomeProcessing(uk.ac.ed.ph.jqtiplus.node.test.outcome.processing.OutcomeProcessing) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart) Sum(uk.ac.ed.ph.jqtiplus.node.expression.operator.Sum) TestVariables(uk.ac.ed.ph.jqtiplus.node.expression.outcome.TestVariables) OutcomeDeclaration(uk.ac.ed.ph.jqtiplus.node.outcome.declaration.OutcomeDeclaration)

Example 18 with TestPart

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

the class AssessmentTestDisplayController method confirmEndTestPart.

private void confirmEndTestPart(UserRequest ureq) {
    TestPlanNode nextTestPart = testSessionController.findNextEnterableTestPart();
    if (nextTestPart == null) {
        String title = translate("confirm.finish.test.title");
        String text = translate("confirm.finish.test.text");
        endTestPartDialog = activateOkCancelDialog(ureq, title, text, endTestPartDialog);
    } else {
        TestPart currentTestPart = testSessionController.getCurrentTestPart();
        if (currentTestPart == null) {
            processEndTestPart(ureq);
        } else {
            String title = translate("confirm.finish.testpart.title");
            String text = translate("confirm.finish.testpart.text");
            endTestPartDialog = activateOkCancelDialog(ureq, title, text, endTestPartDialog);
        }
    }
}
Also used : TestPlanNode(uk.ac.ed.ph.jqtiplus.state.TestPlanNode) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Example 19 with TestPart

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

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 20 with TestPart

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

the class AssessmentTestHelper method visit.

/**
 * Go through the assessmentTest, visit recursively its test parts, sections and
 * assessment item refs.
 *
 * @param assessmentTest The assessment test to visit
 * @param visitor The visitor
 */
public static void visit(AssessmentTest assessmentTest, AssessmentTestVisitor visitor) {
    List<TestPart> testParts = assessmentTest.getTestParts();
    if (testParts != null && testParts.size() > 0) {
        for (TestPart testPart : testParts) {
            visitor.visit(testPart);
            List<AssessmentSection> sections = testPart.getAssessmentSections();
            if (sections != null && sections.size() > 0) {
                for (AssessmentSection section : sections) {
                    visit(section, visitor);
                }
            }
        }
    }
}
Also used : AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) TestPart(uk.ac.ed.ph.jqtiplus.node.test.TestPart)

Aggregations

TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)50 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)28 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)20 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)16 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)12 TreeNode (org.olat.core.gui.components.tree.TreeNode)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 File (java.io.File)8 ItemSessionControl (uk.ac.ed.ph.jqtiplus.node.test.ItemSessionControl)8 TestPlanNode (uk.ac.ed.ph.jqtiplus.state.TestPlanNode)8 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)6 URI (java.net.URI)4 Date (java.util.Date)4 NameValuePair (org.olat.core.gui.components.form.flexible.impl.NameValuePair)4 CandidateEvent (org.olat.ims.qti21.model.audit.CandidateEvent)4 RubricBlock (uk.ac.ed.ph.jqtiplus.node.content.variable.RubricBlock)4 Ordering (uk.ac.ed.ph.jqtiplus.node.test.Ordering)4 TestSessionState (uk.ac.ed.ph.jqtiplus.state.TestSessionState)4 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)3 FileOutputStream (java.io.FileOutputStream)2