Search in sources :

Example 26 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class AssessmentTestPreWarm method run.

@Override
public void run() {
    long start = System.nanoTime();
    FileResourceManager frm = FileResourceManager.getInstance();
    List<RepositoryEntry> entries = repositoryEntryDao.getLastUsedRepositoryEntries(ImsQTI21Resource.TYPE_NAME, 0, 20);
    for (RepositoryEntry entry : entries) {
        try {
            File fUnzippedDirRoot = frm.unzipFileResource(entry.getOlatResource());
            qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
        } catch (RuntimeException e) {
            log.error("Loading the AssessmentTest of repository entry: " + entry.getKey() + " (" + entry.getDisplayname() + ")", e);
        }
    }
    log.info(entries.size() + " AssessmentTest preloaded in (ms): " + CodeHelper.nanoToMilliTime(start));
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) RepositoryEntry(org.olat.repository.RepositoryEntry) File(java.io.File)

Example 27 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class QTI21RuntimeController method getAssessableElement.

private AssessableResource getAssessableElement(RepositoryEntry testEntry) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    Double maxScore = QtiNodesExtractor.extractMaxScore(assessmentTest);
    Double minScore = QtiNodesExtractor.extractMinScore(assessmentTest);
    boolean hasScore = assessmentTest.getOutcomeDeclaration(QTI21Constants.SCORE_IDENTIFIER) != null;
    boolean hasPassed = assessmentTest.getOutcomeDeclaration(QTI21Constants.PASS_IDENTIFIER) != null;
    return new QTI21AssessableResource(hasScore, hasPassed, true, true, minScore, maxScore, null);
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Example 28 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class IQ12EditForm method update.

/**
 * Update the module configuration from the qti file: read min/max/cut values
 * @param res
 */
protected void update(OLATResource res) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedRoot = frm.unzipFileResource(res);
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedRoot);
    VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    if (vfsQTI == null) {
        throw new AssertException("qti file did not exist even it should be guaranteed by repositor check-in ");
    }
    // ensures that InputStream is closed in every case.
    Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    if (doc == null) {
        // error reading qti file (existence check was made before)
        throw new AssertException("qti file could not be read " + ((LocalFileImpl) vfsQTI).getBasefile().getAbsolutePath());
    }
    // Extract min, max and cut value
    Float minValue = null, maxValue = null, cutValue = null;
    Element decvar = (Element) doc.selectSingleNode("questestinterop/assessment/outcomes_processing/outcomes/decvar");
    if (decvar != null) {
        Attribute minval = decvar.attribute("minvalue");
        if (minval != null) {
            String mv = minval.getValue();
            try {
                minValue = new Float(Float.parseFloat(mv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
        Attribute maxval = decvar.attribute("maxvalue");
        if (maxval != null) {
            String mv = maxval.getValue();
            try {
                maxValue = new Float(Float.parseFloat(mv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
        Attribute cutval = decvar.attribute("cutvalue");
        if (cutval != null) {
            String cv = cutval.getValue();
            try {
                cutValue = new Float(Float.parseFloat(cv));
            } catch (NumberFormatException e1) {
            // if not correct in qti file -> ignore
            }
        }
    }
    // Put values to module configuration
    minScoreEl.setValue(minValue == null ? "" : AssessmentHelper.getRoundedScore(minValue));
    minScoreEl.setVisible(minValue != null);
    maxScoreEl.setValue(maxValue == null ? "" : AssessmentHelper.getRoundedScore(maxValue));
    maxScoreEl.setVisible(maxValue != null);
    cutValueEl.setValue(cutValue == null ? "" : AssessmentHelper.getRoundedScore(cutValue));
    cutValueEl.setVisible(cutValue != null);
}
Also used : AssertException(org.olat.core.logging.AssertException) FileResourceManager(org.olat.fileresource.FileResourceManager) Attribute(org.dom4j.Attribute) VFSContainer(org.olat.core.util.vfs.VFSContainer) SelectionElement(org.olat.core.gui.components.form.flexible.elements.SelectionElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) Element(org.dom4j.Element) VFSItem(org.olat.core.util.vfs.VFSItem) Document(org.dom4j.Document) File(java.io.File) LocalFolderImpl(org.olat.core.util.vfs.LocalFolderImpl)

Example 29 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class QTI21AssessmentRunController method doShowResults.

private void doShowResults(UserRequest ureq) {
    removeAsListenerAndDispose(resultCtrl);
    AssessmentTestSession session = null;
    if (courseNode instanceof SelfAssessableCourseNode) {
        RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
        session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
    } else {
        AssessmentManager am = userCourseEnv.getCourseEnvironment().getAssessmentManager();
        AssessmentEntry assessmentEntry = am.getAssessmentEntry(courseNode, getIdentity());
        if (assessmentEntry.getAssessmentId() != null) {
            session = qtiService.getAssessmentTestSession(assessmentEntry.getAssessmentId());
        } else {
            RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
            session = qtiService.getLastAssessmentTestSessions(courseEntry, courseNode.getIdent(), testEntry, getIdentity());
        }
    }
    if (session == null) {
        mainVC.contextPut("showResults", Boolean.FALSE);
    } else {
        FileResourceManager frm = FileResourceManager.getInstance();
        File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
        URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
        File submissionDir = qtiService.getAssessmentResultFile(session);
        String mapperUri = registerCacheableMapper(ureq, "QTI21CNResults::" + session.getTestEntry().getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
        resultCtrl = new AssessmentResultController(ureq, getWindowControl(), getIdentity(), true, session, fUnzippedDirRoot, mapperUri, null, getDeliveryOptions().getAssessmentResultsOptions(), false, false, true);
        listenTo(resultCtrl);
        mainVC.put("resultReport", resultCtrl.getInitialComponent());
        mainVC.contextPut("showResults", Boolean.TRUE);
    }
    saveOpenPanel(ureq, "results", Boolean.TRUE);
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) AssessmentManager(org.olat.course.assessment.AssessmentManager) ResourcesMapper(org.olat.ims.qti21.ui.ResourcesMapper) RepositoryEntry(org.olat.repository.RepositoryEntry) AssessmentResultController(org.olat.ims.qti21.ui.AssessmentResultController) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) File(java.io.File) URI(java.net.URI) SelfAssessableCourseNode(org.olat.course.nodes.SelfAssessableCourseNode)

Example 30 with FileResourceManager

use of org.olat.fileresource.FileResourceManager in project openolat by klemens.

the class QTI21AssessmentRunController method getAssessmentTestMaxTimeLimit.

/**
 * @return The maximum time limit in seconds.
 */
private Long getAssessmentTestMaxTimeLimit() {
    if (overrideOptions != null && overrideOptions.getAssessmentTestMaxTimeLimit() != null) {
        Long timeLimits = overrideOptions.getAssessmentTestMaxTimeLimit();
        return timeLimits.longValue() > 0 ? timeLimits.longValue() : null;
    }
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    ResolvedAssessmentTest resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(fUnzippedDirRoot, false, false);
    AssessmentTest assessmentTest = resolvedAssessmentTest.getRootNodeLookup().extractIfSuccessful();
    if (assessmentTest != null && assessmentTest.getTimeLimits() != null && assessmentTest.getTimeLimits().getMaximum() != null) {
        return assessmentTest.getTimeLimits().getMaximum().longValue();
    }
    return null;
}
Also used : ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) AssessmentTest(uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest) FileResourceManager(org.olat.fileresource.FileResourceManager) ResolvedAssessmentTest(uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest) File(java.io.File)

Aggregations

FileResourceManager (org.olat.fileresource.FileResourceManager)62 File (java.io.File)60 ResolvedAssessmentTest (uk.ac.ed.ph.jqtiplus.resolution.ResolvedAssessmentTest)16 IOException (java.io.IOException)14 AssessmentTest (uk.ac.ed.ph.jqtiplus.node.test.AssessmentTest)12 OutputStream (java.io.OutputStream)10 FileOutputStream (java.io.FileOutputStream)8 AssessmentTestSession (org.olat.ims.qti21.AssessmentTestSession)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8 URI (java.net.URI)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)4 OpenXMLWorkbook (org.olat.core.util.openxml.OpenXMLWorkbook)4 AssessmentResultController (org.olat.ims.qti21.ui.AssessmentResultController)4 QuestionItem (org.olat.modules.qpool.QuestionItem)4 OpenXMLWorksheet (org.olat.core.util.openxml.OpenXMLWorksheet)3 AssessmentResponse (org.olat.ims.qti21.AssessmentResponse)3 ZipOutputStream (java.util.zip.ZipOutputStream)2 Attribute (org.dom4j.Attribute)2