mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
不知道这个还在使用不使用,同步一下吧
This commit is contained in:
@@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.module.scorm.cam.load.SCORMPackageManager;
|
||||
import com.xboe.module.scorm.cam.load.ZipUtils;
|
||||
import com.xboe.module.scorm.cam.model.ContentPackage;
|
||||
import com.xboe.module.scorm.cam.model.Item;
|
||||
import com.xboe.module.scorm.cam.model.Manifest;
|
||||
@@ -23,7 +24,13 @@ public class SCORMParser {
|
||||
|
||||
public String parserToJson(String path) throws Exception {
|
||||
// System.out.println("test");
|
||||
ContentPackage cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
||||
ContentPackage cp=null;
|
||||
if(ZipUtils.isEndWithZip(path)) {
|
||||
cp=SCORMPackageManager.getInstance().loadSCORMContentPackageFromZipFile("1", path);
|
||||
}else {
|
||||
cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||
}
|
||||
//ContentPackage cp=SCORMPackageManager.getInstance().readSCORMContentPackage("1", path);
|
||||
Manifest manifest= cp.getManifest();
|
||||
// System.out.println(cp.getManifest().getIdentifier());
|
||||
// System.out.println(cp.getContent());
|
||||
@@ -81,8 +88,14 @@ public class SCORMParser {
|
||||
}
|
||||
|
||||
//scorm的版本
|
||||
data.setSchema(manifest.getMetadata().getSchema());
|
||||
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
||||
if(manifest.getMetadata()==null) {
|
||||
data.setSchema("ADL SCORM");
|
||||
data.setVersion("1.2");
|
||||
}else {
|
||||
data.setSchema(manifest.getMetadata().getSchema());
|
||||
data.setVersion(manifest.getMetadata().getSchemaVersion());
|
||||
}
|
||||
|
||||
data.setScoItems(scoItems);//sco共有多少个
|
||||
if(scoItems.size()>0 && scoItems.get(0).getScoUrl()!=null) {
|
||||
data.setIndex(scoItems.get(0).getScoUrl());//打开播放时进入的第一个sco
|
||||
@@ -108,7 +121,7 @@ public class SCORMParser {
|
||||
// public static void main(String[] args) {
|
||||
// SCORMParser parser=new SCORMParser();
|
||||
// //String path1="E:/Projects/BOEU/scorm/file/ContentPackagingOneFilePerSCO_SCORM12.zip";
|
||||
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e.zip";
|
||||
// String path1="E:/Projects/BOEU/scorm/file/7a462dbee222ba62810191d2f512576e";
|
||||
// try {
|
||||
// String json= parser.parserToJson(path1);
|
||||
// System.out.println(json);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.xboe.module.scorm.cam.model.Resource;
|
||||
import com.xboe.module.scorm.common.LMSPersistDriverManager;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -112,6 +113,50 @@ public class SCORMPackageManager {
|
||||
|
||||
return contentPackage;
|
||||
}
|
||||
|
||||
public ContentPackage readSCORMContentPackage(String lmsContentPackageID, String packagePath) {
|
||||
if (StringUtils.isBlank(packagePath)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 1: uncompress
|
||||
File f=new File(packagePath);
|
||||
if(!f.exists()) {
|
||||
log.error( packagePath+ " is not exists");
|
||||
return null;
|
||||
}
|
||||
if(!f.isDirectory()) {
|
||||
log.error( packagePath+ " is not directory");
|
||||
return null;
|
||||
}
|
||||
|
||||
String saveDir=packagePath;
|
||||
// step 2: validate all xml file in saveDir
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
if (!XmlSchemaValidator.validateAllXmlFileWithSchemaFileInPath(saveDir)) {
|
||||
log.error("validate xml schema error.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 3: 读取imsmanifest.xml,生成ContentPackage
|
||||
ContentPackage contentPackage = new ContentPackageGenerator().generateContentPackageFromFile(saveDir);
|
||||
if (contentPackage == null) {
|
||||
log.error("generate content package error.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// step 4: 验证ContentPackage
|
||||
// ContentPackageValidator validator = new ContentPackageValidator(false);
|
||||
// boolean validateResult = validator.validate(contentPackage, saveDir);
|
||||
// if (!validateResult) {
|
||||
// log.error("validate content package error: " + validator.getErrors());
|
||||
// return null;
|
||||
// }
|
||||
|
||||
contentPackageMap.put(lmsContentPackageID, contentPackage);
|
||||
|
||||
return contentPackage;
|
||||
}
|
||||
|
||||
public int contentPackageCount() {
|
||||
return contentPackageMap.size();
|
||||
|
||||
Reference in New Issue
Block a user