Search in sources :

Example 56 with FileResourceManager

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

the class CPManagerImpl method getCPPackageConfig.

@Override
public CPPackageConfig getCPPackageConfig(OLATResourceable ores) {
    FileResourceManager frm = FileResourceManager.getInstance();
    File reFolder = frm.getFileResourceRoot(ores);
    File configXml = new File(reFolder, PACKAGE_CONFIG_FILE_NAME);
    CPPackageConfig config;
    if (configXml.exists()) {
        config = (CPPackageConfig) configXstream.fromXML(configXml);
    } else {
        // set default config
        config = new CPPackageConfig();
        config.setDeliveryOptions(DeliveryOptions.defaultWithGlossary());
        setCPPackageConfig(ores, config);
    }
    return config;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) CPPackageConfig(org.olat.ims.cp.ui.CPPackageConfig) File(java.io.File)

Example 57 with FileResourceManager

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

the class QTIQPoolServiceProvider method importRepositoryEntry.

public List<QuestionItem> importRepositoryEntry(Identity owner, RepositoryEntry repositoryEntry, Locale defaultLocale) {
    OLATResourceable ores = repositoryEntry.getOlatResource();
    FileResourceManager frm = FileResourceManager.getInstance();
    File testFile = frm.getFileResource(ores);
    List<QuestionItem> importedItem = importItems(owner, defaultLocale, testFile.getName(), testFile);
    if (importedItem != null && importedItem.size() > 0) {
        dbInstance.getCurrentEntityManager().flush();
    }
    return importedItem;
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) OLATResourceable(org.olat.core.id.OLATResourceable) File(java.io.File) QuestionItem(org.olat.modules.qpool.QuestionItem)

Example 58 with FileResourceManager

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

the class QTI21ArchiveFormat method exportWorkbook.

public void exportWorkbook(OutputStream exportStream) {
    RepositoryEntry testEntry = searchParams.getTestEntry();
    FileResourceManager frm = FileResourceManager.getInstance();
    File unzippedDirRoot = frm.unzipFileResource(testEntry.getOlatResource());
    resolvedAssessmentTest = qtiService.loadAndResolveAssessmentTest(unzippedDirRoot, false, false);
    // content
    final List<AssessmentTestSession> sessions = testSessionDao.getTestSessionsOfResponse(searchParams);
    final List<AssessmentResponse> responses = responseDao.getResponse(searchParams);
    try (OpenXMLWorkbook workbook = new OpenXMLWorkbook(exportStream, 1)) {
        // headers
        OpenXMLWorksheet exportSheet = workbook.nextWorksheet();
        exportSheet.setHeaderRows(2);
        writeHeaders_1(exportSheet, workbook);
        writeHeaders_2(exportSheet, workbook);
        writeData(sessions, responses, exportSheet, workbook);
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : AssessmentTestSession(org.olat.ims.qti21.AssessmentTestSession) FileResourceManager(org.olat.fileresource.FileResourceManager) OpenXMLWorkbook(org.olat.core.util.openxml.OpenXMLWorkbook) RepositoryEntry(org.olat.repository.RepositoryEntry) OpenXMLWorksheet(org.olat.core.util.openxml.OpenXMLWorksheet) File(java.io.File) AssessmentResponse(org.olat.ims.qti21.AssessmentResponse) IOException(java.io.IOException)

Example 59 with FileResourceManager

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

the class QTI21AssessmentDetailsController method doOpenResult.

private void doOpenResult(UserRequest ureq, AssessmentTestSession session) {
    if (resultCtrl != null)
        return;
    // reload it to prevent lazy loading issues
    session = qtiService.getAssessmentTestSession(session.getKey());
    FileResourceManager frm = FileResourceManager.getInstance();
    File fUnzippedDirRoot = frm.unzipFileResource(session.getTestEntry().getOlatResource());
    URI assessmentObjectUri = qtiService.createAssessmentTestUri(fUnzippedDirRoot);
    File submissionDir = qtiService.getSubmissionDirectory(session);
    String mapperUri = registerCacheableMapper(ureq, "QTI21DetailsResources::" + session.getKey(), new ResourcesMapper(assessmentObjectUri, submissionDir));
    resultCtrl = new AssessmentResultController(ureq, getWindowControl(), assessedIdentity, false, session, fUnzippedDirRoot, mapperUri, null, QTI21AssessmentResultsOptions.allOptions(), true, true, true);
    listenTo(resultCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", resultCtrl.getInitialComponent(), true, translate("results.report"));
    cmc.activate();
    listenTo(cmc);
}
Also used : FileResourceManager(org.olat.fileresource.FileResourceManager) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) File(java.io.File) URI(java.net.URI)

Example 60 with FileResourceManager

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

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)

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