Search in sources :

Example 6 with ScoDocument

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

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)

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