use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class FileResourceTest method scormPackage.
@Test
public void scormPackage() throws URISyntaxException {
URL fileUrl = FileResourceTest.class.getResource("very_simple_scorm.zip");
File file = new File(fileUrl.toURI());
ResourceEvaluation eval = ScormCPFileResource.evaluate(file, file.getName());
Assert.assertTrue(eval.isValid());
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class VideoHandler method acceptImport.
@Override
public ResourceEvaluation acceptImport(File file, String filename) {
if (!StringHelper.containsNonWhitespace(filename)) {
filename = file.getName();
}
ResourceEvaluation eval = new ResourceEvaluation(false);
String extension = FileUtils.getFileSuffix(filename);
if (StringHelper.containsNonWhitespace(extension)) {
VideoFileResource.validate(file, filename, eval);
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class BinderTemplateResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
BinderFileFilter visitor = new BinderFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
eval.setValid(true);
Path repoXml = fPath.resolve(RepositoryEntryImportExport.PROPERTIES_FILE);
if (Files.exists(repoXml)) {
RepositoryEntryImport re = RepositoryEntryImportExport.getConfiguration(repoXml);
if (re != null) {
eval.setDisplayname(re.getDisplayname());
eval.setDescription(re.getDescription());
}
}
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class SurveyFileResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
QTIFileFilter visitor = new QTIFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
Path qtiPath = fPath.resolve(QTI_FILE);
Document doc = QTIHelper.getDocument(qtiPath);
validateQti(doc, eval);
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
use of org.olat.fileresource.types.ResourceEvaluation in project openolat by klemens.
the class TestFileResource method evaluate.
public static ResourceEvaluation evaluate(File file, String filename) {
ResourceEvaluation eval = new ResourceEvaluation();
try {
QTIFileFilter visitor = new QTIFileFilter();
Path fPath = PathUtils.visit(file, filename, visitor);
if (visitor.isValid()) {
Path qtiPath = fPath.resolve(QTI_FILE);
Document doc = QTIHelper.getDocument(qtiPath);
validateQti(doc, eval);
} else {
eval.setValid(false);
}
PathUtils.closeSubsequentFS(fPath);
} catch (IOException | IllegalArgumentException e) {
log.error("", e);
eval.setValid(false);
}
return eval;
}
Aggregations