Search in sources :

Example 1 with ScoDocument

use of org.olat.modules.scorm.server.servermodels.ScoDocument in project OpenOLAT by OpenOLAT.

the class ScormAssessmentManager method collectData.

/**
 * Collects the cmi data of the given Scorm-file.
 * @param scoFile
 * @return
 */
private List<CmiData> collectData(VFSItem scoFile) {
    List<CmiData> datas = new ArrayList<CmiData>();
    ScoDocument document = new ScoDocument(null);
    try {
        if (scoFile instanceof LocalFileImpl) {
            document.loadDocument(((LocalFileImpl) scoFile).getBasefile());
        } else {
            logger.warn("Cannot use this type of VSFItem to load a SCO Datamodel: " + scoFile.getClass().getName(), null);
            return null;
        }
        String fileName = scoFile.getName();
        String itemId = fileName.substring(0, fileName.length() - 4);
        String[][] scoModel = document.getScoModel();
        for (String[] line : scoModel) {
            datas.add(new CmiData(itemId, line[0], line[1]));
        }
    } catch (Exception e) {
        logger.error("Cannot load a SCO Datamodel", e);
    }
    return datas;
}
Also used : ArrayList(java.util.ArrayList) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument) OLATRuntimeException(org.olat.core.logging.OLATRuntimeException)

Example 2 with ScoDocument

use of org.olat.modules.scorm.server.servermodels.ScoDocument in project openolat by klemens.

the class ItemSequence method loadInModel.

/**
 * Method to associate and load in the cmi model for this sco (if it is one)
 */
public void loadInModel() {
    // cmi data model we created when importing the package
    if (isItemSco()) {
        if (_scoitemID != null) {
            ScoDocument anSco = new ScoDocument(settings);
            anSco.loadDocument(_scoitemID);
            _scoDataModel = anSco;
        }
    }
}
Also used : ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument)

Example 3 with ScoDocument

use of org.olat.modules.scorm.server.servermodels.ScoDocument in project openolat by klemens.

the class ScormExportManager method collectData.

private void collectData(String username, VFSContainer scoFolder, ScormExportVisitor visitor) {
    List<VFSItem> contents = scoFolder.getItems(new XMLFilter());
    for (VFSItem file : contents) {
        ScoDocument document = new ScoDocument(null);
        try {
            if (file instanceof LocalFileImpl) {
                document.loadDocument(((LocalFileImpl) file).getBasefile());
            } else {
                logger.warn("Cannot use this type of VSFItem to load a SCO Datamodel: " + file.getClass().getName(), null);
                continue;
            }
            String[][] scoModel = document.getScoModel();
            ScoDatas parsedDatas = parseScoModel(file.getName(), username, scoModel);
            visitor.visit(parsedDatas);
        } catch (Exception e) {
            logger.error("Cannot load a SCO Datamodel", e);
        }
    }
}
Also used : VFSItem(org.olat.core.util.vfs.VFSItem) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument)

Example 4 with ScoDocument

use of org.olat.modules.scorm.server.servermodels.ScoDocument in project OpenOLAT by OpenOLAT.

the class ScormExportManager method collectData.

private void collectData(String username, VFSContainer scoFolder, ScormExportVisitor visitor) {
    List<VFSItem> contents = scoFolder.getItems(new XMLFilter());
    for (VFSItem file : contents) {
        ScoDocument document = new ScoDocument(null);
        try {
            if (file instanceof LocalFileImpl) {
                document.loadDocument(((LocalFileImpl) file).getBasefile());
            } else {
                logger.warn("Cannot use this type of VSFItem to load a SCO Datamodel: " + file.getClass().getName(), null);
                continue;
            }
            String[][] scoModel = document.getScoModel();
            ScoDatas parsedDatas = parseScoModel(file.getName(), username, scoModel);
            visitor.visit(parsedDatas);
        } catch (Exception e) {
            logger.error("Cannot load a SCO Datamodel", e);
        }
    }
}
Also used : VFSItem(org.olat.core.util.vfs.VFSItem) LocalFileImpl(org.olat.core.util.vfs.LocalFileImpl) ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument)

Example 5 with ScoDocument

use of org.olat.modules.scorm.server.servermodels.ScoDocument in project OpenOLAT by OpenOLAT.

the class ItemSequence method loadInModel.

/**
 * Method to associate and load in the cmi model for this sco (if it is one)
 */
public void loadInModel() {
    // cmi data model we created when importing the package
    if (isItemSco()) {
        if (_scoitemID != null) {
            ScoDocument anSco = new ScoDocument(settings);
            anSco.loadDocument(_scoitemID);
            _scoDataModel = anSco;
        }
    }
}
Also used : ScoDocument(org.olat.modules.scorm.server.servermodels.ScoDocument)

Aggregations

ScoDocument (org.olat.modules.scorm.server.servermodels.ScoDocument)6 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)4 ArrayList (java.util.ArrayList)2 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)2 VFSItem (org.olat.core.util.vfs.VFSItem)2