Search in sources :

Example 36 with AssessmentTest

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

the class CorrectionIdentityListController method doSaveTests.

private void doSaveTests(UserRequest ureq) {
    Set<Integer> selections = tableEl.getMultiSelectedIndex();
    List<AssessmentTestSession> rows = new ArrayList<>(selections.size());
    for (Integer i : selections) {
        CorrectionIdentityRow row = tableModel.getObject(i.intValue());
        if (row != null) {
            rows.add(row.getCandidateSession());
        }
    }
    AssessmentTest assessmentTest = model.getResolvedAssessmentTest().getRootNodeLookup().extractIfSuccessful();
    fireEvent(ureq, new CompleteAssessmentTestSessionEvent(rows, assessmentTest, AssessmentEntryStatus.done));
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) ArrayList(java.util.ArrayList) CompleteAssessmentTestSessionEvent(org.olat.modules.assessment.ui.event.CompleteAssessmentTestSessionEvent) CorrectionIdentityRow(org.olat.ims.qti21.ui.assessment.model.CorrectionIdentityRow)

Example 37 with AssessmentTest

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

the class QTI21AssessmentTestHandler method createMinimalAssessmentTest.

public void createMinimalAssessmentTest(String displayName, File directory, Locale locale) {
    ManifestBuilder manifestBuilder = ManifestBuilder.createAssessmentTestBuilder();
    Translator translator = Util.createPackageTranslator(AssessmentTestComposerController.class, locale);
    // single choice
    File itemFile = new File(directory, IdentifierGenerator.newAsString(QTI21QuestionType.sc.getPrefix()) + ".xml");
    AssessmentItem assessmentItem = AssessmentItemFactory.createSingleChoice(translator.translate("new.sc"), translator.translate("new.answer"));
    QtiSerializer qtiSerializer = qtiService.qtiSerializer();
    manifestBuilder.appendAssessmentItem(itemFile.getName());
    // test
    File testFile = new File(directory, IdentifierGenerator.newAssessmentTestFilename());
    AssessmentTest assessmentTest = AssessmentTestFactory.createAssessmentTest(displayName, translator.translate("new.section"));
    manifestBuilder.appendAssessmentTest(testFile.getName());
    // item -> test
    try {
        AssessmentSection section = assessmentTest.getTestParts().get(0).getAssessmentSections().get(0);
        AssessmentTestFactory.appendAssessmentItem(section, itemFile.getName());
    } catch (URISyntaxException e) {
        log.error("", e);
    }
    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);
    }
    manifestBuilder.write(new File(directory, "imsmanifest.xml"));
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ManifestBuilder(org.olat.ims.qti21.model.xml.ManifestBuilder) Translator(org.olat.core.gui.translator.Translator) QtiSerializer(uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer) AssessmentSection(uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection) FileOutputStream(java.io.FileOutputStream) AssessmentItem(uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem) URISyntaxException(java.net.URISyntaxException) File(java.io.File) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 38 with AssessmentTest

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

the class AssessmentTestComposerController method doConfirmDelete.

private void doConfirmDelete(UserRequest ureq) {
    if (confirmDeleteCtrl != null)
        return;
    TreeNode selectedNode = menuTree.getSelectedNode();
    if (selectedNode == null) {
        showWarning("warning.atleastone");
        return;
    }
    Object uobject = selectedNode.getUserObject();
    if (uobject instanceof AssessmentTest) {
        showWarning("error.cannot.delete");
    } else if (uobject instanceof TestPart) {
        TestPart testPart = (TestPart) uobject;
        if (testPart.getParent().getTestParts().size() == 1) {
            showWarning("error.cannot.delete");
        }
        String msg = translate("delete.testPart");
        confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
        confirmDeleteCtrl.setUserObject(selectedNode);
    } else {
        String msg;
        if (uobject instanceof AssessmentSection) {
            AssessmentSection section = (AssessmentSection) uobject;
            if (checkAtLeastOneSection(section)) {
                msg = translate("delete.section", selectedNode.getTitle());
            } else {
                showWarning("warning.atleastonesection");
                return;
            }
        } else if (uobject instanceof AssessmentItemRef) {
            msg = translate("delete.item", selectedNode.getTitle());
        } else {
            showError("error.cannot.delete");
            return;
        }
        confirmDeleteCtrl = activateYesNoDialog(ureq, translate("tools.change.delete"), msg, confirmDeleteCtrl);
        confirmDeleteCtrl.setUserObject(selectedNode);
    }
}
Also used : AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) 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)

Example 39 with AssessmentTest

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

the class QTI21StatisticResourceResult method getSubTreeModel.

/**
 * Return the tree model for a course and a specific test.
 */
@Override
public TreeModel getSubTreeModel() {
    GenericTreeModel subTreeModel = new GenericTreeModel();
    StatisticResourceNode rootTreeNode = new StatisticResourceNode(courseNode, this);
    subTreeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    buildRecursively(test, rootTreeNode);
    return subTreeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) StatisticResourceNode(org.olat.course.statistic.StatisticResourceNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

Example 40 with AssessmentTest

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

the class QTI21StatisticResourceResult method getTreeModel.

/**
 * Return the tree model for a test learn resource.
 *
 * @return
 */
public TreeModel getTreeModel() {
    GenericTreeModel treeModel = new GenericTreeModel();
    GenericTreeNode rootTreeNode = new GenericTreeNode();
    treeModel.setRootNode(rootTreeNode);
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    AssessmentTest test = resolvedAssessmentTest.getTestLookup().getRootNodeHolder().getRootNode();
    rootTreeNode.setTitle(test.getTitle());
    rootTreeNode.setUserObject(test);
    rootTreeNode.setIconCssClass("o_icon o_icon-lg o_qtiassessment_icon");
    buildRecursively(test, rootTreeNode);
    return treeModel;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) File(java.io.File)

Aggregations

AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)60 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)48 File (java.io.File)34 AssessmentSection (uk.ac.ed.ph.jqtiplus.node.test.AssessmentSection)22 TestPart (uk.ac.ed.ph.jqtiplus.node.test.TestPart)20 FileResourceManager (org.olat.fileresource.FileResourceManager)12 AssessmentItemRef (uk.ac.ed.ph.jqtiplus.node.test.AssessmentItemRef)12 ResolvedAssessmentItem (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentItem)12 IOException (java.io.IOException)10 URISyntaxException (java.net.URISyntaxException)10 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)10 AssessmentItem (uk.ac.ed.ph.jqtiplus.node.item.AssessmentItem)10 ArrayList (java.util.ArrayList)8 TreeNode (org.olat.core.gui.components.tree.TreeNode)8 ManifestBuilder (org.olat.ims.qti21.model.xml.ManifestBuilder)8 FileOutputStream (java.io.FileOutputStream)6 ManifestMetadataBuilder (org.olat.ims.qti21.model.xml.ManifestMetadataBuilder)6 QtiSerializer (uk.ac.ed.ph.jqtiplus.serialization.QtiSerializer)6 AssessmentTestBuilder (org.olat.ims.qti21.model.xml.AssessmentTestBuilder)5 CompleteAssessmentTestSessionEvent (org.olat.modules.assessment.ui.event.CompleteAssessmentTestSessionEvent)5