Skip to content
Snippets Groups Projects
Commit 3947c257 authored by srosse's avatar srosse
Browse files

OO-1177: fix several onyx issues related to the detection of QTI 2.1 files

parent 5e53403b
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,7 @@ import org.olat.core.configuration.ConfigOnOff;
import org.olat.core.configuration.PersistedProperties;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable;
import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.core.util.PathUtils;
......@@ -77,6 +78,13 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff {
private String assessmentPlugin;
private static Map<Long,Boolean> onyxMap = new ConcurrentHashMap<Long,Boolean>();
/**
* [used by spring]
*/
private OnyxModule() {
//
}
@Override
public boolean isEnabled() {
......@@ -143,13 +151,6 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff {
this.assessmentPlugin = assessmentPlugin;
}
/**
* [used by spring]
*/
private OnyxModule() {
//
}
@Override
public void init() {
PLAYERTEMPLATES = new ArrayList<PlayerTemplate>();
......@@ -161,14 +162,12 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff {
@Override
protected void initDefaultProperties() {
// TODO Auto-generated method stub
//
}
@Override
protected void initFromChangedProperties() {
// TODO Auto-generated method stub
//
}
@Override
......@@ -196,12 +195,17 @@ public class OnyxModule extends AbstractOLATModule implements ConfigOnOff {
Long resourceId = res.getResourceableId();
Boolean onyx = onyxMap.get(resourceId);
if(onyx == null) {
final Resolver resolver = new ImsRepositoryResolver(res);
// search for qti.xml, it not exists for qti2
if (resolver.getQTIDocument() == null) {
onyx = Boolean.TRUE;
} else {
onyx = Boolean.FALSE;
onyx = Boolean.FALSE;
try {
final Resolver resolver = new ImsRepositoryResolver(res);
// search for qti.xml, it not exists for qti2
if (resolver.getQTIDocument() == null) {
onyx = Boolean.TRUE;
} else {
onyx = Boolean.FALSE;
}
} catch(OLATRuntimeException e) {
log.error("", e);
}
onyxMap.put(resourceId, onyx);
}
......
......@@ -128,9 +128,10 @@ public class FileResourceManager extends BasicManager {
private File getFileResource(OLATResourceable res, String resourceFolderName) {
FileResource fr = getAsGenericFileResource(res);
File f = getFile(fr, resourceFolderName);
if (f == null) // folder not existing or no file in it
throw new OLATRuntimeException(FileResourceManager.class, "could not getFileResource for OLATResourceable " + res.getResourceableId()
if (f == null) {// folder not existing or no file in it
throw new OLATRuntimeException(FileResourceManager.class, "could not getFileResource for OLATResourceable " + res.getResourceableId()
+ ":" + res.getResourceableTypeName(), null);
}
return f;
}
......@@ -230,19 +231,21 @@ public class FileResourceManager extends BasicManager {
// o_clusterOK by:ld
zipTargetDir = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(res, new SyncerCallback<File>() {
public File execute() {
File zipTargetDir = null;
File targetDir = null;
// now we are the only one unzipping. We
// only need to unzip when the previous
// threads that aquired this lock have not unzipped "our" version's
// resources yet
zipTargetDir = new File(dir, ZIPDIR);
if (!zipTargetDir.exists()) { // means I am the first to unzip this
targetDir = new File(dir, ZIPDIR);
if (!targetDir.exists()) { // means I am the first to unzip this
// version's resource
zipTargetDir.mkdir();
targetDir.mkdir();
File zipFile = getFileResource(res);
if (!ZipUtil.unzip(zipFile, zipTargetDir)) return null;
if (!ZipUtil.unzip(zipFile, targetDir)) {
return null;
}
}
return zipTargetDir;
return targetDir;
}
});
}
......
......@@ -224,7 +224,7 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController
protected void initToolbar(Dropdown toolsDropdown, Dropdown settingsDropdown) {
if (reSecurity.isEntryAdmin()) {
//tools
if(handler.supportsEdit(re) == EditionSupport.yes) {
if(handler.supportsEdit(re.getOlatResource()) == EditionSupport.yes) {
boolean managed = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.editcontent);
editLink = LinkFactory.createToolLink("edit.cmd", translate("details.openeditor"), this, "o_sel_repository_editor");
editLink.setIconLeftCSS("o_icon o_icon-lg o_icon_edit");
......@@ -479,10 +479,12 @@ public class RepositoryEntryRuntimeController extends MainLayoutBasicController
if(!reSecurity.isEntryAdmin()) return;
Controller ctrl = handler.createEditorController(re, ureq, getWindowControl());
listenTo(ctrl);
editorCtrl = pushController(ureq, translate("resource.editor"), ctrl);
currentToolCtr = editorCtrl;
setActiveTool(editLink);
if(ctrl != null) {
listenTo(ctrl);
editorCtrl = pushController(ureq, translate("resource.editor"), ctrl);
currentToolCtr = editorCtrl;
setActiveTool(editLink);
}
}
protected void doDetails(UserRequest ureq) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment