diff --git a/src/main/java/org/olat/core/commons/chiefcontrollers/_content/body.html b/src/main/java/org/olat/core/commons/chiefcontrollers/_content/body.html index 38471a06aa1203af53760af52828800442803c87..1a8f82da9563e38b6bc41f2458fc5e44b3e18fad 100644 --- a/src/main/java/org/olat/core/commons/chiefcontrollers/_content/body.html +++ b/src/main/java/org/olat/core/commons/chiefcontrollers/_content/body.html @@ -53,26 +53,20 @@ function b_start(){ <script type="text/javascript" src='$r.staticLink("js/modernizr/modernizr.js")'></script> ## jQuery libraries <script type="text/javascript" src='$r.staticLink("js/jquery/jquery-1.9.1.min.js")'></script> -<script> -/* <![CDATA[ */ - jQuery.noConflict(); -/* ]]> */ -</script> <script type="text/javascript" src='$r.staticLink("js/jquery/jquery-migrate-1.1.1.min.js")'></script> <script type="text/javascript" src='$r.staticLink("js/jquery/ui/jquery-ui-1.10.2.custom.min.js")'></script> -<!-- can be compressed jquery.all.plugins.min.js --> +## Are compressed as js/js.plugins.min.js ## <script type="text/javascript" src='$r.staticLink("js/jquery/periodic/jquery.periodic.js")'></script> ## <script type="text/javascript" src='$r.staticLink("js/jshashtable-2.1_src.js")'></script> ## <script type="text/javascript" src='$r.staticLink("js/jquery/openolat/jquery.oolog.js")'></script> ## <script type="text/javascript" src='$r.staticLink("js/jquery/openolat/jquery.translator.js")'></script> ## <script type="text/javascript" src='$r.staticLink("js/functions.js")'></script> <script type="text/javascript" src='$r.staticLink("js/js.plugins.min.js")'></script> - <script type="text/javascript" src='$r.staticLink("movie/player.js")'></script> <script type="text/javascript" src='$r.staticLink("js/jsMath/easy/load.js")'></script> -<!-- loaded always --> +## Always loaded ## <link type="text/css" href='$r.staticLink("js/jquery/tagit/jquery.tagit.css")' rel="stylesheet"/> ## <link type="text/css" href='$r.staticLink("js/jquery/uilayout/layout-default-latest.css")' rel="stylesheet"/> ## <link type="text/css" href='$r.staticLink("js/jquery/fullcalendar/fullcalendar.css")' rel="stylesheet"/> @@ -82,6 +76,7 @@ function b_start(){ <script type="text/javascript"> /* <![CDATA[ */ + jQuery.noConflict(); ## references to objects for later access or cleanup o_info.objectMap = new Hashtable(); ## Initialize js translator factory with the js translator mapper path @@ -90,8 +85,6 @@ function b_start(){ /* ]]> */ </script> - -## ## LAYOUT ## 1) Dynamic component CSS included by components $r.render("jsCssRawHtmlHeader", "pre-theme") diff --git a/src/main/java/org/olat/core/commons/chiefcontrollers/controller/simple/SimpleBaseController.java b/src/main/java/org/olat/core/commons/chiefcontrollers/controller/simple/SimpleBaseController.java index eec77a9f0d37f9dfd4f31c700f86c441f330d984..1b7cf726e579434b62735e8047d804ea976e792f 100644 --- a/src/main/java/org/olat/core/commons/chiefcontrollers/controller/simple/SimpleBaseController.java +++ b/src/main/java/org/olat/core/commons/chiefcontrollers/controller/simple/SimpleBaseController.java @@ -78,7 +78,7 @@ public class SimpleBaseController extends BasicController implements Contentable guiMessage = new GUIMessage(); guimsgVc.contextPut("guiMessage", guiMessage); - guimsgPanel = new OncePanel("guimsgPanel"); + guimsgPanel = new OncePanel("simpleGuimsgPanel"); mainVc.put("guimessage", guimsgPanel); diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/FormUIFactory.java b/src/main/java/org/olat/core/gui/components/form/flexible/FormUIFactory.java index d293eb25995f4e4f29c313a11ad338f36986fa10..825c52fec0859dfe277a77101e0a43eebc912533 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/FormUIFactory.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/FormUIFactory.java @@ -573,7 +573,8 @@ public class FormUIFactory { */ public TextElement addTextElement(String name, final String i18nLabel, final int maxLen, String initialValue, FormItemContainer formLayout) { - return addTextElement(null, name, i18nLabel, maxLen, initialValue, formLayout); + String val = initialValue == null ? "" : initialValue; + return addTextElement(null, name, i18nLabel, maxLen, val, formLayout); } /** @@ -587,7 +588,8 @@ public class FormUIFactory { */ public TextElement addTextElement(String id, String name, final String i18nLabel, final int maxLen, String initialValue, FormItemContainer formLayout) { - TextElement te = new TextElementImpl(id, name, initialValue); + String val = initialValue == null ? "" : initialValue; + TextElement te = new TextElementImpl(id, name, val); te.setNotLongerThanCheck(maxLen, "text.element.error.notlongerthan"); setLabelIfNotNull(i18nLabel, te); te.setMaxLength(maxLen); diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormBasicController.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormBasicController.java index 9112a85ff0451c843cdc8c671a4673bbc6c7ba11..f6e7ab9750e974ffe0d67114682a41e6fdf88d08 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormBasicController.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/FormBasicController.java @@ -332,8 +332,7 @@ public abstract class FormBasicController extends BasicController { * evaluate normal inner form events */ FormItem fiSrc = fe.getFormItemSource(); - // check for InlineElments - //TODO jquery + // check for InlineElments remove as the tag library has been replaced /* if(fiSrc instanceof InlineElement){ if(!((InlineElement) fiSrc).isInlineEditingElement()){ //OO-137 diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java index b52f4523fd79d589828fab80e7a1a1bca2d392ca..bcacb0263c9aad00a0c0df8e40cbe6c5c7ed5a67 100644 --- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java +++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/richText/RichTextConfiguration.java @@ -390,8 +390,7 @@ public class RichTextConfiguration implements Disposable { plugins.add(SAFARI_PLUGIN); // Start observing of diry richt text element and trigger calling of setFlexiFormDirty() method // This check is initialized after the editor has fully loaded - //addOnInitCallbackFunction(ONINIT_CALLBACK_VALUE_START_DIRTY_OBSERVER + ".curry('" + rootFormDispatchId + "','" + domID + "')"); - addOnInitCallbackFunction(ONINIT_CALLBACK_VALUE_START_DIRTY_OBSERVER + "('" + rootFormDispatchId + "','" + domID + "')"); + addOnInitCallbackFunction(ONINIT_CALLBACK_VALUE_START_DIRTY_OBSERVER + ".curry('" + rootFormDispatchId + "','" + domID + "')"); } /** @@ -727,8 +726,7 @@ public class RichTextConfiguration implements Disposable { setQuotedConfigValue(THEME_ADVANCED_TOOLBAR_LOCATION, position); if (position.equals(THEME_ADVANCED_TOOLBAR_LOCATION_VALUE_EXTERNAL) && autoHide) { // set the on-init callback and add the auto-hide toolbar listener - //setNonQuotedConfigValue(INIT_INSTANCE_CALLBACK, INIT_INSTANCE_CALLBACK_VALUE_AUTO_HIDE_TOOLBAR + ".curry('" + domID + "')"); - setNonQuotedConfigValue(INIT_INSTANCE_CALLBACK, INIT_INSTANCE_CALLBACK_VALUE_AUTO_HIDE_TOOLBAR + "('" + domID + "')"); + setNonQuotedConfigValue(INIT_INSTANCE_CALLBACK, INIT_INSTANCE_CALLBACK_VALUE_AUTO_HIDE_TOOLBAR + ".curry('" + domID + "')"); } } else { throw new AssertException("Invalid configuration parameters, use RichTextConfigurationConstants"); @@ -1322,8 +1320,7 @@ public class RichTextConfiguration implements Disposable { */ public void setFileBrowserCallback(VFSContainer vfsContainer, CustomLinkTreeModel customLinkTreeModel, String[] supportedImageSuffixes, String[] supportedMediaSuffixes, String[] supportedFlashPlayerSuffixes) { // Add dom ID variable using prototype curry method - //TODO jquery setNonQuotedConfigValue(FILE_BROWSER_CALLBACK, FILE_BROWSER_CALLBACK_VALUE_LINK_BROWSER + ".curry('" + domID + "')"); - setNonQuotedConfigValue(FILE_BROWSER_CALLBACK, FILE_BROWSER_CALLBACK_VALUE_LINK_BROWSER + "('" + domID + "')"); + setNonQuotedConfigValue(FILE_BROWSER_CALLBACK, FILE_BROWSER_CALLBACK_VALUE_LINK_BROWSER + ".curry('" + domID + "')"); linkBrowserImageSuffixes = supportedImageSuffixes; linkBrowserMediaSuffixes = supportedMediaSuffixes; linkBrowserFlashPlayerSuffixes = supportedFlashPlayerSuffixes; diff --git a/src/main/java/org/olat/ims/cp/IMS_CP_Editor_Stand_der_Dinge_jan09_.pdf b/src/main/java/org/olat/ims/cp/IMS_CP_Editor_Stand_der_Dinge_jan09_.pdf deleted file mode 100644 index 645bab2b2064db5524881261e7f0de5416750285..0000000000000000000000000000000000000000 Binary files a/src/main/java/org/olat/ims/cp/IMS_CP_Editor_Stand_der_Dinge_jan09_.pdf and /dev/null differ diff --git a/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java b/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java index 4a05601662b536ff73fad92749a3102ba71fe6bc..64018bcf1fcd1c57d50e4c1de400cf74ed865534 100644 --- a/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java +++ b/src/main/java/org/olat/ims/qti/editor/QTIEditorMainController.java @@ -77,7 +77,7 @@ import org.olat.core.util.memento.Memento; import org.olat.core.util.nodes.INode; import org.olat.core.util.tree.TreeVisitor; import org.olat.core.util.tree.Visitor; -import org.olat.core.util.vfs.VFSLeaf; +import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.xml.XStreamHelper; import org.olat.course.CourseFactory; import org.olat.course.ICourse; @@ -110,7 +110,6 @@ import org.olat.modules.iq.IQDisplayController; import org.olat.modules.iq.IQManager; import org.olat.modules.iq.IQPreviewSecurityCallback; import org.olat.modules.qpool.QPoolService; -import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionItemView; import org.olat.modules.qpool.ui.QItemEvent; import org.olat.modules.qpool.ui.SelectItemController; @@ -907,9 +906,8 @@ public class QTIEditorMainController extends MainLayoutBasicController implement } private GenericQtiNode doConvertItemToQtiNode(QuestionItemView qitemv) { - QuestionItem qitem = qpoolService.loadItemById(qitemv.getKey()); - VFSLeaf leaf = qpoolService.getRootFile(qitem); - Item theItem = QTIEditHelper.readItemXml(leaf); + VFSContainer editorContainer = qtiPackage.getBaseDir(); + Item theItem = qtiQpoolServiceProvider.exportToQTIEditor(qitemv, editorContainer); GenericQtiNode node = new ItemNode(theItem, qtiPackage); return node; } @@ -933,7 +931,8 @@ public class QTIEditorMainController extends MainLayoutBasicController implement QTIObject qtiObject = itemNode.getUnderlyingQTIObject(); if(qtiObject instanceof Item) { Item item = (Item)qtiObject; - qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, getLocale()); + VFSContainer editorContainer = qtiPackage.getBaseDir(); + qtiQpoolServiceProvider.importBeecomItem(getIdentity(), item, editorContainer, getLocale()); showInfo("export.qpool.successful"); } } diff --git a/src/main/java/org/olat/ims/qti/qpool/QTIExportProcessor.java b/src/main/java/org/olat/ims/qti/qpool/QTIExportProcessor.java index 837da354c53e97a82401a60e6ae8e1adb825d816..803f26dbff960bd0a8c6de01838940e87235ad31 100644 --- a/src/main/java/org/olat/ims/qti/qpool/QTIExportProcessor.java +++ b/src/main/java/org/olat/ims/qti/qpool/QTIExportProcessor.java @@ -21,28 +21,43 @@ package org.olat.ims.qti.qpool; import java.io.IOException; import java.io.InputStream; +import java.io.StringReader; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import org.apache.commons.io.IOUtils; +import org.cyberneko.html.parsers.SAXParser; +import org.dom4j.Attribute; +import org.dom4j.CDATA; import org.dom4j.Document; import org.dom4j.DocumentFactory; import org.dom4j.Element; +import org.dom4j.Node; import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.CodeHelper; +import org.olat.core.util.FileUtils; +import org.olat.core.util.StringHelper; import org.olat.core.util.ZipUtil; import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.vfs.VFSItem; import org.olat.core.util.vfs.VFSLeaf; +import org.olat.core.util.vfs.VFSManager; import org.olat.core.util.xml.XMLParser; import org.olat.ims.qti.QTIConstants; import org.olat.ims.resources.IMSEntityResolver; import org.olat.modules.qpool.QuestionItemFull; import org.olat.modules.qpool.manager.FileStorage; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.helpers.DefaultHandler; /** * @@ -60,54 +75,198 @@ public class QTIExportProcessor { this.qpoolFileStorage = qpoolFileStorage; } - public void process(QuestionItemFull fullItem, ZipOutputStream zout) { + public void process(QuestionItemFull fullItem, ZipOutputStream zout, Set<String> names) { String dir = fullItem.getDirectory(); VFSContainer container = qpoolFileStorage.getContainer(dir); - ZipUtil.addToZip(container, "", zout); + + String rootDir = "qitem_" + fullItem.getKey(); + List<VFSItem> items = container.getItems(); + for(VFSItem item:items) { + ZipUtil.addToZip(item, rootDir, zout); + } } + /** + * <li>List all items + * <li>Rewrite path + * <li>Assemble qti.xml + * <li>Write files at new path + * @param fullItems + * @param zout + */ public void assembleTest(List<QuestionItemFull> fullItems, ZipOutputStream zout) { - Element sectionEl = createSectionBasedAssessment("Assessment"); + ItemsAndMaterials itemAndMaterials = new ItemsAndMaterials(); for(QuestionItemFull fullItem:fullItems) { - String dir = fullItem.getDirectory(); - String rootFilename = fullItem.getRootFilename(); - VFSContainer container = qpoolFileStorage.getContainer(dir); - VFSItem rootItem = container.resolve(rootFilename); - List<String> path = new ArrayList<String>(); - collectResource(container, "", path); - - if(rootItem instanceof VFSLeaf) { - VFSLeaf rootLeaf = (VFSLeaf)rootItem; - Element el = readItemXml(rootLeaf); - Element cloneEl = (Element)el.clone(); - enrichScore(cloneEl); - enrichWithMetadata(fullItem, cloneEl); - sectionEl.add(cloneEl); - } + collectMaterials(fullItem, itemAndMaterials); } try { + byte[] buffer = new byte[FileUtils.BSIZE]; + + //write qti.xml + Element sectionEl = createSectionBasedAssessment("Assessment"); + for(Element itemEl:itemAndMaterials.getItemEls()) { + sectionEl.add(itemEl); + } zout.putNextEntry(new ZipEntry("qti.xml")); XMLWriter xw = new XMLWriter(zout, new OutputFormat(" ", true)); xw.write(sectionEl.getDocument()); zout.closeEntry(); + + //write materials + for(ItemMaterial material:itemAndMaterials.getMaterials()) { + String exportPath = material.getExportUri(); + zout.putNextEntry(new ZipEntry(exportPath)); + InputStream in = material.getLeaf().getInputStream(); + int c; + while ((c = in.read(buffer, 0, buffer.length)) != -1) { + zout.write(buffer, 0, c); + } + IOUtils.closeQuietly(in); + zout.closeEntry(); + } } catch (IOException e) { log.error("", e); } } - private void collectResource(VFSContainer container, String currentPath, List<String> path) { - List<VFSItem> items = container.getItems(); - for(VFSItem item:items) { - String itemPath = currentPath + "/" + item.getName(); - if(item instanceof VFSLeaf) { - path.add(itemPath); - } else if(item instanceof VFSContainer) { - collectResource((VFSContainer)item, itemPath, path); + public Element exportToQTIEditor(QuestionItemFull fullItem, VFSContainer editorContainer) { + ItemsAndMaterials itemAndMaterials = new ItemsAndMaterials(); + collectMaterials(fullItem, itemAndMaterials); + if(itemAndMaterials.getItemEls().isEmpty()) { + return null;//nothing found + } + + Element itemEl = itemAndMaterials.getItemEls().get(0); + //write materials + for(ItemMaterial material:itemAndMaterials.getMaterials()) { + String exportPath = material.getExportUri(); + VFSLeaf leaf = editorContainer.createChildLeaf(exportPath); + VFSManager.copyContent(material.getLeaf(), leaf); + } + return itemEl; + } + + protected void collectMaterials(QuestionItemFull fullItem, ItemsAndMaterials materials) { + String dir = fullItem.getDirectory(); + String rootFilename = fullItem.getRootFilename(); + VFSContainer container = qpoolFileStorage.getContainer(dir); + VFSItem rootItem = container.resolve(rootFilename); + + if(rootItem instanceof VFSLeaf) { + VFSLeaf rootLeaf = (VFSLeaf)rootItem; + Element el = (Element)readItemXml(rootLeaf).clone(); + Element itemEl = (Element)el.clone(); + enrichScore(itemEl); + enrichWithMetadata(fullItem, itemEl); + collectResources(itemEl, container, materials); + materials.addItemEl(itemEl); + } + } + + private void collectResources(Element el, VFSContainer container, ItemsAndMaterials materials) { + collectResourcesInMatText(el, container, materials); + collectResourcesInMatMedias(el, container, materials); + } + + /** + * Collect the file and rewrite the + * @param el + * @param container + * @param materials + * @param paths + */ + private void collectResourcesInMatText(Element el, VFSContainer container, ItemsAndMaterials materials) { + //mattext + @SuppressWarnings("unchecked") + List<Element> mattextList = el.selectNodes(".//mattext"); + for(Element mat:mattextList) { + Attribute texttypeAttr = mat.attribute("texttype"); + String texttype = texttypeAttr.getValue(); + if("text/html".equals(texttype)) { + @SuppressWarnings("unchecked") + List<Node> childElList = new ArrayList<Node>(mat.content()); + for(Node childEl:childElList) { + mat.remove(childEl); + } + + for(Node childEl:childElList) { + if(Node.CDATA_SECTION_NODE == childEl.getNodeType()) { + CDATA data = (CDATA)childEl; + boolean changed = false; + String text = data.getText(); + List<String> materialPaths = findMaterialInMatText(text); + for(String materialPath:materialPaths) { + VFSItem matVfsItem = container.resolve(materialPath); + if(matVfsItem instanceof VFSLeaf) { + String exportUri = generateExportPath(materials.getPaths(), matVfsItem); + materials.addMaterial(new ItemMaterial((VFSLeaf)matVfsItem, exportUri)); + text = text.replaceAll(materialPath, exportUri); + changed = true; + } + } + if(changed) { + mat.addCDATA(text); + } else { + mat.add(childEl); + } + } else { + mat.add(childEl); + } + } } } } + @SuppressWarnings("unchecked") + private void collectResourcesInMatMedias(Element el, VFSContainer container, ItemsAndMaterials materials) { + //matimage uri + List<Element> matList = new ArrayList<Element>(); + matList.addAll(el.selectNodes(".//matimage")); + matList.addAll(el.selectNodes(".//mataudio")); + matList.addAll(el.selectNodes(".//matvideo")); + + for(Element mat:matList) { + Attribute uriAttr = mat.attribute("uri"); + String uri = uriAttr.getValue(); + + VFSItem matVfsItem = container.resolve(uri); + if(matVfsItem instanceof VFSLeaf) { + String exportUri = generateExportPath(materials.getPaths(), matVfsItem); + ItemMaterial iMat = new ItemMaterial((VFSLeaf)matVfsItem, exportUri); + materials.addMaterial(iMat); + mat.addAttribute("uri", exportUri); + } + } + } + + private String generateExportPath(Set<String> paths, VFSItem leaf) { + String filename = leaf.getName(); + for(int count=0; paths.contains(filename) && count < 999 ; ) { + filename = VFSManager.appendNumberAtTheEndOfFilename(filename, count++); + } + paths.add(filename); + return "media/" + filename; + } + + /** + * Parse the content and collect the images source + * @param content + * @param materialPath + */ + private List<String> findMaterialInMatText(String content) { + try { + SAXParser parser = new SAXParser(); + HTMLHandler contentHandler = new HTMLHandler(); + parser.setContentHandler(contentHandler); + parser.parse(new InputSource(new StringReader(content))); + return contentHandler.getMaterialPath(); + } catch (Exception e) { + log.error("", e); + return Collections.emptyList(); + } + } + private Element createSectionBasedAssessment(String title) { DocumentFactory df = DocumentFactory.getInstance(); Document doc = df.createDocument(); @@ -210,7 +369,7 @@ public class QTIExportProcessor { private void enrichWithMetadata(QuestionItemFull fullItem, Element item) { Element qtimetadata = (Element)item.selectSingleNode("./itemmetadata/qtimetadata"); String path = fullItem.getTaxonomicPath(); - System.out.println(qtimetadata + " " + path); + System.out.println("enrichWithMetadata: " + qtimetadata + " " + path); } private void addMetadataField(String label, String entry, Element qtimetadata) { @@ -219,7 +378,6 @@ public class QTIExportProcessor { qtimetadatafield.addElement("fieldentry").setText(entry); } - /* * * <itemmetadata> @@ -304,4 +462,67 @@ public class QTIExportProcessor { <qmd_topic>Migration</qmd_topic> </itemmetadata> */ + + private static final class HTMLHandler extends DefaultHandler { + private final List<String> materialPath = new ArrayList<String>(); + + public List<String> getMaterialPath() { + return materialPath; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) { + String elem = localName.toLowerCase(); + if("img".equals(elem)) { + String imgSrc = attributes.getValue("src"); + if(StringHelper.containsNonWhitespace(imgSrc)) { + materialPath.add(imgSrc); + } + } + } + } + + private static final class ItemsAndMaterials { + private final Set<String> paths = new HashSet<String>(); + private final List<Element> itemEls = new ArrayList<Element>(); + private final List<ItemMaterial> materials = new ArrayList<ItemMaterial>(); + + public Set<String> getPaths() { + return paths; + } + + public List<Element> getItemEls() { + return itemEls; + } + + public void addItemEl(Element el) { + itemEls.add(el); + } + + public List<ItemMaterial> getMaterials() { + return materials; + } + + public void addMaterial(ItemMaterial material) { + materials.add(material); + } + } + + private static final class ItemMaterial { + private final VFSLeaf leaf; + private final String exportUri; + + public ItemMaterial(VFSLeaf leaf, String exportUri) { + this.leaf = leaf; + this.exportUri = exportUri; + } + + public VFSLeaf getLeaf() { + return leaf; + } + + public String getExportUri() { + return exportUri; + } + } } diff --git a/src/main/java/org/olat/ims/qti/qpool/QTIImportProcessor.java b/src/main/java/org/olat/ims/qti/qpool/QTIImportProcessor.java index a1af3fae8244746152ce5e03a86ca3cea6de64ba..b3547e9a0581def37377af455c3a6243b57886ce 100644 --- a/src/main/java/org/olat/ims/qti/qpool/QTIImportProcessor.java +++ b/src/main/java/org/olat/ims/qti/qpool/QTIImportProcessor.java @@ -363,10 +363,12 @@ class QTIImportProcessor { List<Element> mattextList = el.selectNodes(".//mattext"); for(Element mat:mattextList) { Attribute texttypeAttr = mat.attribute("texttype"); - String texttype = texttypeAttr.getValue(); - if("text/html".equals(texttype)) { - String content = mat.getStringValue(); - findMaterialInMatText(content, materialPath); + if(texttypeAttr != null) { + String texttype = texttypeAttr.getValue(); + if("text/html".equals(texttype)) { + String content = mat.getStringValue(); + findMaterialInMatText(content, materialPath); + } } } //matimage uri diff --git a/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java b/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java index c65c3502cc0eea781d0c6f5776ad9be954bc7946..767e301d0f17cbd88bd5e5bb62a15f9dd689801d 100644 --- a/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java +++ b/src/main/java/org/olat/ims/qti/qpool/QTIQPoolServiceProvider.java @@ -24,6 +24,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.zip.ZipOutputStream; import org.dom4j.Document; @@ -46,6 +47,7 @@ import org.olat.ims.qti.QTI12PreviewController; import org.olat.ims.qti.QTIConstants; import org.olat.ims.qti.editor.QTIEditHelper; import org.olat.ims.qti.editor.beecom.objects.Item; +import org.olat.ims.qti.editor.beecom.parser.ParserManager; import org.olat.ims.resources.IMSEntityResolver; import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolService; @@ -151,7 +153,7 @@ public class QTIQPoolServiceProvider implements QPoolSPI { return processor.process(); } - public void importBeecomItem(Identity owner, Item item, Locale defaultLocale) { + public void importBeecomItem(Identity owner, Item item, VFSContainer sourceDir, Locale defaultLocale) { QTIImportProcessor processor = new QTIImportProcessor(owner, defaultLocale, questionItemDao, qItemTypeDao, qEduContextDao, qpoolFileStorage); @@ -166,10 +168,19 @@ public class QTIQPoolServiceProvider implements QPoolSPI { Element itemEl = (Element)doc.selectSingleNode("questestinterop/item"); QuestionItemImpl qitem = processor.processItem(itemEl, "", null, editor, editorVersion); //save to file System - VFSContainer baseDir = qpoolFileStorage.getContainer(qitem.getDirectory()); VFSLeaf leaf = baseDir.createChildLeaf(qitem.getRootFilename()); QTIEditHelper.serialiazeDoc(doc, leaf); + //process amterials + List<String> materials = processor.getMaterials(itemEl); + //copy materials + for(String material:materials) { + VFSItem sourceItem = sourceDir.resolve(material); + if(sourceItem instanceof VFSLeaf) { + VFSLeaf targetItem = baseDir.createChildLeaf(material); + VFSManager.copyContent((VFSLeaf)sourceItem, targetItem); + } + } } @Override @@ -178,9 +189,9 @@ public class QTIQPoolServiceProvider implements QPoolSPI { } @Override - public void exportItem(QuestionItemFull item, ZipOutputStream zout) { + public void exportItem(QuestionItemFull item, ZipOutputStream zout, Set<String> names) { QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage); - processor.process(item, zout); + processor.process(item, zout, names); } public void assembleTest(List<QuestionItemShort> items, ZipOutputStream zout) { @@ -193,6 +204,13 @@ public class QTIQPoolServiceProvider implements QPoolSPI { QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage); processor.assembleTest(fullItems, zout); } + + public Item exportToQTIEditor(QuestionItemShort qitem, VFSContainer editorContainer) { + QTIExportProcessor processor = new QTIExportProcessor(qpoolFileStorage); + QuestionItemFull fullItem = questionItemDao.loadById(qitem.getKey()); + Element itemEl = processor.exportToQTIEditor(fullItem, editorContainer); + return (Item)new ParserManager().parse(itemEl); + } @Override public void copyItem(QuestionItemFull original, QuestionItemFull copy) { diff --git a/src/main/java/org/olat/modules/qpool/QPoolSPI.java b/src/main/java/org/olat/modules/qpool/QPoolSPI.java index d2b9dc6250d428e60934881d343dc862ee85d8bc..af661b466eba269b984283f8692fec194f96f1b5 100644 --- a/src/main/java/org/olat/modules/qpool/QPoolSPI.java +++ b/src/main/java/org/olat/modules/qpool/QPoolSPI.java @@ -22,6 +22,7 @@ package org.olat.modules.qpool; import java.io.File; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.zip.ZipOutputStream; import org.olat.core.gui.UserRequest; @@ -67,9 +68,10 @@ public interface QPoolSPI { /** * Export the item to the Zip * @param item - * @param out + * @param zout + * @param names Collection of the file names used in the ZIP */ - public void exportItem(QuestionItemFull item, ZipOutputStream out); + public void exportItem(QuestionItemFull item, ZipOutputStream zout, Set<String> names); /** * Copy the item attachment... diff --git a/src/main/java/org/olat/modules/qpool/QPoolService.java b/src/main/java/org/olat/modules/qpool/QPoolService.java index d44062ecdddcf43518c5ad19cfa83867950ac1f7..c7aa9a7b04175c0659347ec3b158204ff430601f 100644 --- a/src/main/java/org/olat/modules/qpool/QPoolService.java +++ b/src/main/java/org/olat/modules/qpool/QPoolService.java @@ -22,6 +22,7 @@ package org.olat.modules.qpool; import java.io.File; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.zip.ZipOutputStream; import org.olat.core.commons.persistence.ResultInfos; @@ -90,7 +91,13 @@ public interface QPoolService { //import / export public MediaResource export(List<QuestionItemShort> items, String format); - public void exportItem(QuestionItemShort item, ZipOutputStream zout); + /** + * + * @param item + * @param zout + * @param names Collection of the names used in the ZIP dd + */ + public void exportItem(QuestionItemShort item, ZipOutputStream zout, Set<String> names); public List<QuestionItem> importItems(Identity owner, Locale defaultLocale, String filename, File file); @@ -170,6 +177,8 @@ public interface QPoolService { public QItemType getItemType(String type); + public boolean delete(QItemType itemType); + //item levels administration public QEducationalContext createEducationalContext(String level); diff --git a/src/main/java/org/olat/modules/qpool/manager/AbstractExportTestResource.java b/src/main/java/org/olat/modules/qpool/manager/AbstractExportTestResource.java index b7e057e2ae3ba22ba9f15db305f896e6a366b837..dd433c7bf672d1433282dbeb3396ebcd99cdeb2d 100644 --- a/src/main/java/org/olat/modules/qpool/manager/AbstractExportTestResource.java +++ b/src/main/java/org/olat/modules/qpool/manager/AbstractExportTestResource.java @@ -95,6 +95,8 @@ public abstract class AbstractExportTestResource implements MediaResource { exportTest(items, zout); } catch (IOException e) { log.error("", e); + } catch (Exception e) { + log.error("", e); } finally { IOUtils.closeQuietly(zout); } diff --git a/src/main/java/org/olat/modules/qpool/manager/AbstractQPoolServiceProvider.java b/src/main/java/org/olat/modules/qpool/manager/AbstractQPoolServiceProvider.java index 9633645dc3234901ab31a0b1b1a5aaea7ff1eebe..6fef6521c81a9bb1c75ec394422f4a911cb60261 100644 --- a/src/main/java/org/olat/modules/qpool/manager/AbstractQPoolServiceProvider.java +++ b/src/main/java/org/olat/modules/qpool/manager/AbstractQPoolServiceProvider.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -142,7 +143,7 @@ public abstract class AbstractQPoolServiceProvider implements QPoolSPI { } @Override - public void exportItem(QuestionItemFull item, ZipOutputStream zout) { + public void exportItem(QuestionItemFull item, ZipOutputStream zout, Set<String> names) { String directory = item.getDirectory(); VFSContainer itemDir = getFileStorage().getContainer(directory); VFSItem file = itemDir.resolve(item.getRootFilename()); diff --git a/src/main/java/org/olat/modules/qpool/manager/ExportQItemResource.java b/src/main/java/org/olat/modules/qpool/manager/ExportQItemResource.java index 179d87c41e317f76fd8357a6dc1b4ce0e7f3de8f..540d0b32e98a5caf52e5a76d9c671132333b4679 100644 --- a/src/main/java/org/olat/modules/qpool/manager/ExportQItemResource.java +++ b/src/main/java/org/olat/modules/qpool/manager/ExportQItemResource.java @@ -21,6 +21,8 @@ package org.olat.modules.qpool.manager; import java.io.IOException; import java.io.InputStream; +import java.util.HashSet; +import java.util.Set; import java.util.zip.ZipOutputStream; import javax.servlet.http.HttpServletResponse; @@ -31,8 +33,8 @@ import org.olat.core.gui.media.MediaResource; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; -import org.olat.modules.qpool.QuestionItemShort; import org.olat.modules.qpool.QPoolService; +import org.olat.modules.qpool.QuestionItemShort; /** * @@ -89,8 +91,9 @@ public class ExportQItemResource implements MediaResource { try { zout = new ZipOutputStream(hres.getOutputStream()); zout.setLevel(9); + Set<String> names = new HashSet<String>(); QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class); - qpoolService.exportItem(item, zout); + qpoolService.exportItem(item, zout, names); } catch (IOException e) { log.error("", e); } finally { diff --git a/src/main/java/org/olat/modules/qpool/manager/ExportQItemsZipResource.java b/src/main/java/org/olat/modules/qpool/manager/ExportQItemsZipResource.java new file mode 100644 index 0000000000000000000000000000000000000000..51f3fd1cf6a6f3c0c4943bf5556f74e209ae2376 --- /dev/null +++ b/src/main/java/org/olat/modules/qpool/manager/ExportQItemsZipResource.java @@ -0,0 +1,111 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.modules.qpool.manager; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.zip.ZipOutputStream; + +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.io.IOUtils; +import org.olat.core.CoreSpringFactory; +import org.olat.core.gui.media.MediaResource; +import org.olat.core.logging.OLog; +import org.olat.core.logging.Tracing; +import org.olat.core.util.StringHelper; +import org.olat.modules.qpool.QPoolService; +import org.olat.modules.qpool.QuestionItemFull; + +/** + * + * Initial date: 18.04.2013<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class ExportQItemsZipResource implements MediaResource { + + private static final OLog log = Tracing.createLoggerFor(ExportQItemsZipResource.class); + + private String encoding; + private final List<QuestionItemFull> items; + + public ExportQItemsZipResource(String encoding, List<QuestionItemFull> items) { + this.encoding = encoding; + this.items = items; + } + + @Override + public String getContentType() { + return "application/octet-stream"; + } + + @Override + public Long getSize() { + return null; + } + + @Override + public InputStream getInputStream() { + return null; + } + + @Override + public Long getLastModified() { + return null; + } + + @Override + public void prepare(HttpServletResponse hres) { + try { + hres.setCharacterEncoding(encoding); + } catch (Exception e) { + log.error("", e); + } + + String label = "ExportItems"; + String file = StringHelper.transformDisplayNameToFileSystemName(label) + ".zip"; + hres.setHeader("Content-Disposition","attachment; filename=\"" + StringHelper.urlEncodeISO88591(file) + "\""); + hres.setHeader("Content-Description",StringHelper.urlEncodeISO88591(label)); + + ZipOutputStream zout = null; + try { + zout = new ZipOutputStream(hres.getOutputStream()); + zout.setLevel(9); + Set<String> names = new HashSet<String>(); + QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class); + for(QuestionItemFull item:items) { + qpoolService.exportItem(item, zout, names); + } + } catch (IOException e) { + log.error("", e); + } finally { + IOUtils.closeQuietly(zout); + } + } + + @Override + public void release() { + // + } +} diff --git a/src/main/java/org/olat/modules/qpool/manager/LOMConverter.java b/src/main/java/org/olat/modules/qpool/manager/MetadataConverterHelper.java similarity index 82% rename from src/main/java/org/olat/modules/qpool/manager/LOMConverter.java rename to src/main/java/org/olat/modules/qpool/manager/MetadataConverterHelper.java index 65920902678e5c135b0a3742c9ce054d4a664a6b..953ddf6a515f5de5a136740fd640968582086877 100644 --- a/src/main/java/org/olat/modules/qpool/manager/LOMConverter.java +++ b/src/main/java/org/olat/modules/qpool/manager/MetadataConverterHelper.java @@ -19,38 +19,42 @@ */ package org.olat.modules.qpool.manager; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.olat.core.logging.OLog; -import org.olat.core.logging.Tracing; import org.olat.core.util.StringHelper; +import org.olat.core.util.xml.XStreamHelper; +import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.model.LOMDuration; +import org.olat.modules.qpool.model.QEducationalContext; +import org.olat.modules.qpool.model.QItemType; +import org.olat.modules.qpool.model.QLicense; import org.olat.modules.qpool.model.QuestionItemImpl; -import org.springframework.stereotype.Service; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.xml.sax.InputSource; +import org.olat.modules.qpool.model.TaxonomyLevelImpl; + +import com.thoughtworks.xstream.XStream; /** + * + * Some utilities to convert LOM specific date format * * Initial date: 11.03.2013<br> * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -@Service("lomConverter") -public class LOMConverter { +public class MetadataConverterHelper { - private static final OLog log = Tracing.createLoggerFor(LOMConverter.class); + private static XStream metadatXstream = XStreamHelper.createXStreamInstance(); + static { + + metadatXstream.alias("item", QuestionItemImpl.class); + metadatXstream.alias("educationalContext", QEducationalContext.class); + metadatXstream.alias("itemType", QItemType.class); + metadatXstream.alias("license", QLicense.class); + metadatXstream.alias("taxonomyLevel", TaxonomyLevelImpl.class); + } + public static String toXml(QuestionItem item) { + return metadatXstream.toXML(item); + } + /** * P[yY][mM][dD][T[hH][nM][s[.s]S]] where:<br> * y = number of years (integer, > 0, not restricted)<br> @@ -154,7 +158,7 @@ public class LOMConverter { String intVal = durationStr.substring(0, index); return Integer.parseInt(intVal); } - + /* protected void toLom(QuestionItemImpl item, OutputStream out) { try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); @@ -179,17 +183,51 @@ public class LOMConverter { protected void generalToLom(QuestionItemImpl item, Node lomEl, Document doc) { Node generalEl = lomEl.appendChild(doc.createElement("general")); - //language - Element languageEl = (Element)generalEl.appendChild(doc.createElement("language")); - languageEl.setAttribute("value", item.getLanguage()); + //identifier + + //master identifier + //title Node titleEl = generalEl.appendChild(doc.createElement("title")); stringToLom(item, item.getTitle(), titleEl, doc); //description Node descEl = generalEl.appendChild(doc.createElement("description")); stringToLom(item, item.getDescription(), descEl, doc); + //keywords + //coverage + //additional information + + //language + Element languageEl = (Element)generalEl.appendChild(doc.createElement("language")); + languageEl.setAttribute("value", item.getLanguage()); + } + + protected void taxonomyToLom(QuestionItemImpl item, Node lomEl, Document doc) { + Node generalEl = lomEl.appendChild(doc.createElement("classification")); + + } + + protected void educationalToLom(QuestionItemImpl item, Node lomEl, Document doc) { + Node generalEl = lomEl.appendChild(doc.createElement("educational")); + + } + + protected void lifecycleToLom(QuestionItemImpl item, Node lomEl, Document doc) { + Node generalEl = lomEl.appendChild(doc.createElement("lifecycle")); + + //version + //status + //urheber / contribute + + } + + protected void rightsToLom(QuestionItemImpl item, Node lomEl, Document doc) { + Node generalEl = lomEl.appendChild(doc.createElement("rights")); + + //copyright + //description } @@ -246,5 +284,5 @@ public class LOMConverter { } } return val; - } + }*/ } diff --git a/src/main/java/org/olat/modules/qpool/manager/QItemTypeDAO.java b/src/main/java/org/olat/modules/qpool/manager/QItemTypeDAO.java index 85f1c2d55cf93735f81a80407b35c057180012bd..ad22b9d0623cb1b1d045f75e442c19725015686e 100644 --- a/src/main/java/org/olat/modules/qpool/manager/QItemTypeDAO.java +++ b/src/main/java/org/olat/modules/qpool/manager/QItemTypeDAO.java @@ -94,6 +94,15 @@ public class QItemTypeDAO implements ApplicationListener<ContextRefreshedEvent> return types.get(0); } + public int countItemUsing(QItemType type) { + StringBuilder sb = new StringBuilder(); + sb.append("select count(item) from questionitem item where item.type.key=:itemTypeKey"); + return dbInstance.getCurrentEntityManager() + .createQuery(sb.toString(), Number.class) + .setParameter("itemTypeKey", type.getKey()) + .getSingleResult().intValue(); + } + public boolean delete(QItemType type) { QItemType reloadType = loadById(type.getKey()); if(reloadType.isDeletable()) { diff --git a/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java b/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java index df939359624021f04a1e38905f4c14d60a0566bd..c14c09e267367240daff1310639f38714010d4c2 100644 --- a/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java +++ b/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java @@ -21,8 +21,10 @@ package org.olat.modules.qpool.manager; import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.Set; import java.util.zip.ZipOutputStream; import org.olat.basesecurity.BaseSecurity; @@ -206,6 +208,9 @@ public class QuestionPoolServiceImpl implements QPoolService { public MediaResource export(List<QuestionItemShort> items, String format) { MediaResource mr = null; if(ZIP_EXPORT_FORMAT.equals(format)) { + List<Long> keys = toKeys(items); + List<QuestionItemFull> fullItems = questionItemDao.loadByIds(keys); + mr = new ExportQItemsZipResource("UTF-8", fullItems); //make a zip with all items } else { QPoolSPI selectedSp = null; @@ -221,18 +226,32 @@ public class QuestionPoolServiceImpl implements QPoolService { mr = selectedSp.exportTest(items, format); } } - + return mr; } + + private List<Long> toKeys(List<? extends QuestionItemShort> items) { + if(items == null || items.isEmpty()) return Collections.emptyList(); + List<Long> keys = new ArrayList<Long>(items.size()); + for(QuestionItemShort item:items) { + keys.add(item.getKey()); + } + return keys; + } @Override - public void exportItem(QuestionItemShort item, ZipOutputStream zout) { + public void exportItem(QuestionItemShort item, ZipOutputStream zout, Set<String> names) { QPoolSPI provider = qpoolModule.getQuestionPoolProvider(item.getFormat()); if(provider == null) { log.error("Not found provider for this format: " + item.getFormat()); } else { - QuestionItemImpl fullItem = questionItemDao.loadById(item.getKey()); - provider.exportItem(fullItem, zout); + QuestionItemFull fullItem; + if(item instanceof QuestionItemFull) { + fullItem = (QuestionItemFull)item; + } else { + fullItem = questionItemDao.loadById(item.getKey()); + } + provider.exportItem(fullItem, zout, names); } } @@ -634,6 +653,14 @@ public class QuestionPoolServiceImpl implements QPoolService { return qpoolItemTypeDao.loadByType(type); } + @Override + public boolean delete(QItemType itemType) { + if(qpoolItemTypeDao.countItemUsing(itemType) == 0) { + return qpoolItemTypeDao.delete(itemType); + } + return false; + } + @Override public QEducationalContext createEducationalContext(String level) { return qEduContextDao.create(level, true); diff --git a/src/main/java/org/olat/modules/qpool/ui/ImportController.java b/src/main/java/org/olat/modules/qpool/ui/ImportController.java index 698e2a406d75a8d60aedb0977213e296df926c9b..7596affff35c8226bf58ff5fa4d441a80f274f84 100644 --- a/src/main/java/org/olat/modules/qpool/ui/ImportController.java +++ b/src/main/java/org/olat/modules/qpool/ui/ImportController.java @@ -69,6 +69,18 @@ public class ImportController extends FormBasicController { return fileEl.getUploadFile(); } + @Override + protected boolean validateFormLogic(UserRequest ureq) { + boolean allOk = true; + + fileEl.clearError(); + if(fileEl.getUploadFile() == null) { + fileEl.setErrorKey("form.mandatory.hover", null); + allOk = false; + } + return allOk & super.validateFormLogic(ureq); + } + @Override protected void formOK(UserRequest ureq) { String filename = fileEl.getUploadFileName(); diff --git a/src/main/java/org/olat/modules/qpool/ui/QuestionItemPreviewController.java b/src/main/java/org/olat/modules/qpool/ui/QuestionItemPreviewController.java index c73b67f2146818836cd79014202e15a9ff4416f2..035c6c8e08cc3617befdc8093bc7a1e8b32b318a 100644 --- a/src/main/java/org/olat/modules/qpool/ui/QuestionItemPreviewController.java +++ b/src/main/java/org/olat/modules/qpool/ui/QuestionItemPreviewController.java @@ -69,25 +69,34 @@ public class QuestionItemPreviewController extends BasicController { previewPanel.setContent(null); } + public void refresh(UserRequest ureq) { + updateItem(ureq, item); + } + public void updateItem(UserRequest ureq, QuestionItem item) { this.item = item; removeAsListenerAndDispose(previewCtrl); - - Component content; - QPoolSPI spi = poolModule.getQuestionPoolProvider(item.getFormat()); - if(spi == null) { - content = getRawContent(item); + if(item == null) { + removeAsListenerAndDispose(previewCtrl); + previewCtrl = null; + previewPanel.setContent(null); } else { - previewCtrl = spi.getPreviewController(ureq, getWindowControl(), item); - if(previewCtrl == null) { + Component content; + QPoolSPI spi = poolModule.getQuestionPoolProvider(item.getFormat()); + if(spi == null) { content = getRawContent(item); } else { - listenTo(previewCtrl); - content = previewCtrl.getInitialComponent(); + previewCtrl = spi.getPreviewController(ureq, getWindowControl(), item); + if(previewCtrl == null) { + content = getRawContent(item); + } else { + listenTo(previewCtrl); + content = previewCtrl.getInitialComponent(); + } } + + previewPanel.setContent(content); } - - previewPanel.setContent(content); } private Component getRawContent(QuestionItem item) { diff --git a/src/main/java/org/olat/modules/qpool/ui/QuestionItemSummaryController.java b/src/main/java/org/olat/modules/qpool/ui/QuestionItemSummaryController.java index 3777b7bf1d7b0e9409baa33113f7b9ea0acedc03..d21d05dfa25a7c32c1abc6cad99a7e53f6ebf66b 100644 --- a/src/main/java/org/olat/modules/qpool/ui/QuestionItemSummaryController.java +++ b/src/main/java/org/olat/modules/qpool/ui/QuestionItemSummaryController.java @@ -78,29 +78,41 @@ public class QuestionItemSummaryController extends FormBasicController { return item; } + public void refresh() { + updateItem(item, canEdit); + } + public void updateItem(QuestionItem item, boolean canEdit) { this.item = item; - - keyEl.setValue(item.getKey().toString()); - identifierEl.setValue(item.getIdentifier()); - subjectEl.setValue(item.getTitle()); - String keywords = item.getKeywords(); - keywordsEl.setValue(keywords == null ? "" : keywords); - String taxonPath = item.getTaxonomicPath(); - studyFieldEl.setValue(taxonPath == null ? "" : taxonPath); - - int usage = item.getUsage(); - String usageStr = ""; - if(usage >= 0) { - usageStr = Integer.toString(usage); - } - usageEl.setValue(usageStr); - - String description = item.getDescription(); - if(StringHelper.containsNonWhitespace(description)) { - descriptionEl.setValue(description); - } else { + if(item == null) { + identifierEl.setValue(""); + subjectEl.setValue(""); + keywordsEl.setValue("" ); + studyFieldEl.setValue(""); + usageEl.setValue(""); descriptionEl.setValue(""); + } else { + keyEl.setValue(item.getKey().toString()); + identifierEl.setValue(item.getIdentifier()); + subjectEl.setValue(item.getTitle()); + String keywords = item.getKeywords(); + keywordsEl.setValue(keywords == null ? "" : keywords); + String taxonPath = item.getTaxonomicPath(); + studyFieldEl.setValue(taxonPath == null ? "" : taxonPath); + + int usage = item.getUsage(); + String usageStr = ""; + if(usage >= 0) { + usageStr = Integer.toString(usage); + } + usageEl.setValue(usageStr); + + String description = item.getDescription(); + if(StringHelper.containsNonWhitespace(description)) { + descriptionEl.setValue(description); + } else { + descriptionEl.setValue(""); + } } } diff --git a/src/main/java/org/olat/modules/qpool/ui/QuestionPoolMainEditorController.java b/src/main/java/org/olat/modules/qpool/ui/QuestionPoolMainEditorController.java index 185df7a4b6d6ef08a2dd2c53337a742e8731695f..5af9bd69fb347ee0440c6f71a5375fed0b0b3501 100644 --- a/src/main/java/org/olat/modules/qpool/ui/QuestionPoolMainEditorController.java +++ b/src/main/java/org/olat/modules/qpool/ui/QuestionPoolMainEditorController.java @@ -140,7 +140,7 @@ public class QuestionPoolMainEditorController extends BasicController implements String dropId = e.getDroppedNodeId(); //drop id w_o_fi1000002357-4 doDrop(targetId, dropId); - } else { + } else if(menuTree.getSelectedNode() != null){ TreeNode node = menuTree.getSelectedNode(); Object uNode = node.getUserObject(); if("menu.admin".equals(uNode)) { @@ -288,7 +288,7 @@ public class QuestionPoolMainEditorController extends BasicController implements myQuestionsCtrl.setStackedController(stackPanel); listenTo(myQuestionsCtrl); } else { - myQuestionsCtrl.updateSource(source); + myQuestionsCtrl.updateSource(ureq, source); } currentCtrl = myQuestionsCtrl; content.setContent(myQuestionsCtrl.getInitialComponent()); @@ -302,7 +302,7 @@ public class QuestionPoolMainEditorController extends BasicController implements markedQuestionsCtrl.setStackedController(stackPanel); listenTo(markedQuestionsCtrl); } else { - markedQuestionsCtrl.updateSource(source); + markedQuestionsCtrl.updateSource(ureq, source); } currentCtrl = markedQuestionsCtrl; content.setContent(markedQuestionsCtrl.getInitialComponent()); @@ -316,7 +316,7 @@ public class QuestionPoolMainEditorController extends BasicController implements selectedPoolCtrl.setStackedController(stackPanel); listenTo(selectedPoolCtrl); } else { - selectedPoolCtrl.updateSource(source); + selectedPoolCtrl.updateSource(ureq, source); } currentCtrl = selectedPoolCtrl; content.setContent(selectedPoolCtrl.getInitialComponent()); @@ -328,7 +328,7 @@ public class QuestionPoolMainEditorController extends BasicController implements sharedItemsCtrl.setStackedController(stackPanel); listenTo(sharedItemsCtrl); } else { - sharedItemsCtrl.updateSource(new SharedItemsSource(group, getIdentity(), ureq.getUserSession().getRoles())); + sharedItemsCtrl.updateSource(ureq, new SharedItemsSource(group, getIdentity(), ureq.getUserSession().getRoles())); } currentCtrl = sharedItemsCtrl; content.setContent(sharedItemsCtrl.getInitialComponent()); @@ -341,7 +341,7 @@ public class QuestionPoolMainEditorController extends BasicController implements collItemsCtrl.setStackedController(stackPanel); listenTo(collItemsCtrl); } else { - collItemsCtrl.updateSource(source); + collItemsCtrl.updateSource(ureq, source); } currentCtrl = collItemsCtrl; content.setContent(collItemsCtrl.getInitialComponent()); diff --git a/src/main/java/org/olat/modules/qpool/ui/QuestionsController.java b/src/main/java/org/olat/modules/qpool/ui/QuestionsController.java index f70848c18f16b3873d52547d38770101f77dc977..5863a2c44a2f61ee6f6a3ff06df6fe2587f12adf 100644 --- a/src/main/java/org/olat/modules/qpool/ui/QuestionsController.java +++ b/src/main/java/org/olat/modules/qpool/ui/QuestionsController.java @@ -102,8 +102,10 @@ public class QuestionsController extends BasicController implements StackedContr // } - public void updateSource(QuestionItemsSource source) { + public void updateSource(UserRequest ureq, QuestionItemsSource source) { listCtrl.updateSource(source); + detailsCtrl.refresh(); + previewCtrl.refresh(ureq); } public QuestionItemShort getQuestionAt(int index) { diff --git a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties index 382ebc03e666d79c4c16ee93590a751ade9b4617..e9e7f85800faaa39e039acdf0c57a60c9353dbe0 100644 --- a/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/qpool/ui/_i18n/LocalStrings_de.properties @@ -51,9 +51,7 @@ classification.taxonomy.level=Fachbereich classification.taxonomy.parents=Path educational=Educational educational.context=Level -educational.context.deleted=Level wurde erfolgreich gelöscht -educational.context.notdeleted=Level wurde nicht gelöscht, probably in use -educational.learningTime=Durschnittliche Bearbeitungszeit +educational.learningTime=Durchschnittliche Bearbeitungszeit educational.learningTime.day=d educational.learningTime.hour=h educational.learningTime.minute=m @@ -85,7 +83,7 @@ technical.editor=Editor technical.editorVersion=Editor Version technical.format=Format technical.creation=Erstellt -technical.lastModified=Letzte Anderung +technical.lastModified=Letzte \u00C4nderung rights=Rechte rights.copyright=Copyright rights.description=Lizenz @@ -97,7 +95,7 @@ sharing=Freigabe / Autoren sharing.authors=Autoren sharing.author.name=Name sharing.shares=Gruppen -manage.owners=Authoren +manage.owners=Autoren item.level=Level item.shared=Frage {0} wurde freigegeben. item.pooled=Frage {0} wurde im Pool hinzugefügt. @@ -125,8 +123,9 @@ item.type.fib=Fill-in-Black item.type.sc=Single-Choice item.type.kprim=KPrim item.type.essay=Essay -author.item=Authoren -author.choose.title=Authoren auswählen +item.type.unkown=Unbekannt +author.item=Autoren +author.choose.title=Autoren auswählen author.confirm.title=Bestätigen share.item=Freigeben unshare.item=Entfernen @@ -138,5 +137,5 @@ select.item=Bearbeiten export.item=Export import.item=Import error.input.toolong=Leider ist Ihr gerade eingegebener Text mit {1} Zeichen zu lang. Bitte beschr\u00E4nken Sie sich auf maximal {0} Zeichen. -share.options=Wollen Sie andere Personen diese Frage erlauben zu editieren? +share.options=Wollen Sie anderen Personen diese Frage erlauben zu editieren? share.editable=Editieren \ No newline at end of file diff --git a/src/main/java/org/olat/modules/qpool/ui/admin/QItemTypesAdminController.java b/src/main/java/org/olat/modules/qpool/ui/admin/QItemTypesAdminController.java index 3380a13dddd7d90d03ce1963e4ae403e2566fb61..fb673ae3cf315298d6f9cfd6dd50f1477f46fb07 100644 --- a/src/main/java/org/olat/modules/qpool/ui/admin/QItemTypesAdminController.java +++ b/src/main/java/org/olat/modules/qpool/ui/admin/QItemTypesAdminController.java @@ -205,8 +205,12 @@ public class QItemTypesAdminController extends FormBasicController { } private void doDelete(UserRequest ureq, QItemType type) { - //qpoolService.deletePool(pool); - reloadModel(); + if(qpoolService.delete(type)) { + reloadModel(); + showInfo("item.type.deleted"); + } else { + showError("item.type.notdeleted"); + } } private void doEdit(UserRequest ureq, QItemType type) { diff --git a/src/main/java/org/olat/modules/qpool/ui/admin/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/qpool/ui/admin/_i18n/LocalStrings_de.properties index 28f00b32e264223b89fba293f52ae98d5d451486..42648dabfa9f539e52fe03eec9b80af1aa882c01 100644 --- a/src/main/java/org/olat/modules/qpool/ui/admin/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/qpool/ui/admin/_i18n/LocalStrings_de.properties @@ -16,4 +16,8 @@ delete.license.confirm=Wollen Sie wirklich dieser Lizenz l create.level=Level erstellen create.license=Lizenz erstellen create.type=Typ erstellen -add.taxonomyLevel=Level erstellen \ No newline at end of file +add.taxonomyLevel=Level erstellen +educational.context.deleted=Level wurde erfolgreich gelöscht +educational.context.notdeleted=Level wurde nicht gelöscht, probably in use +item.type.deleted=Typ wurde erfolgreich gelöscht +item.type.notdeleted=Typ wurde nicht gelöscht, probably in use \ No newline at end of file diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataController.java b/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataController.java index aab7b492d0c039cc2a392d7c62e8f474b72e5309..872d9cde85f621dd9d6bedba1e2ff9fe12844cc9 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataController.java @@ -77,7 +77,11 @@ public class EducationalMetadataController extends FormBasicController { if(context == null || context.getLevel() == null) { contextEl.setValue(""); } else { - contextEl.setValue(context.getLevel()); + String translation = translate("item.level." + context.getLevel().toLowerCase()); + if(translation.length() > 128) { + translation = context.getLevel(); + } + contextEl.setValue(translation); } String learningTime = item.getEducationalLearningTime() == null ? "" : item.getEducationalLearningTime(); diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataEditController.java b/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataEditController.java index dd94dfbca55393643660c8dbc1f483d6aab62517..b2d825f3fb649b66f7a3155e9bd9619f31bebf42 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataEditController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/EducationalMetadataEditController.java @@ -34,7 +34,7 @@ import org.olat.core.gui.control.WindowControl; import org.olat.core.util.Util; import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QuestionItem; -import org.olat.modules.qpool.manager.LOMConverter; +import org.olat.modules.qpool.manager.MetadataConverterHelper; import org.olat.modules.qpool.model.LOMDuration; import org.olat.modules.qpool.model.QEducationalContext; import org.olat.modules.qpool.model.QuestionItemImpl; @@ -74,7 +74,11 @@ public class EducationalMetadataEditController extends FormBasicController { int count = 0; for(QEducationalContext level:levels) { contextKeys[count] = level.getLevel(); - contextValues[count++] = "item.level." + level.getLevel().toLowerCase(); + String translation = translate("item.level." + level.getLevel().toLowerCase()); + if(translation.length() > 128) { + translation = level.getLevel(); + } + contextValues[count++] = translation; } contextEl = uifactory.addDropdownSingleselect("educational.context", "educational.context", formLayout, contextKeys, contextValues, null); @@ -86,7 +90,7 @@ public class EducationalMetadataEditController extends FormBasicController { learningTimeContainer.setLabel("educational.learningTime", null); formLayout.add(learningTimeContainer); - LOMDuration duration = LOMConverter.convertDuration(item.getEducationalLearningTime()); + LOMDuration duration = MetadataConverterHelper.convertDuration(item.getEducationalLearningTime()); learningTimeDayElement = uifactory.addIntegerElement("learningTime.day", "", duration.getDay(), learningTimeContainer); learningTimeDayElement.setDisplaySize(3); learningTimeDayElement.setMandatory(true); @@ -135,7 +139,7 @@ public class EducationalMetadataEditController extends FormBasicController { int hour = learningTimeHourElement.getIntValue(); int minute = learningTimeMinuteElement.getIntValue(); int seconds = learningTimeSecondElement.getIntValue(); - String timeStr = LOMConverter.convertDuration(day, hour, minute, seconds); + String timeStr = MetadataConverterHelper.convertDuration(day, hour, minute, seconds); itemImpl.setEducationalLearningTime(timeStr); } item = qpoolService.updateItem(item); diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/LifecycleMetadataEditController.java b/src/main/java/org/olat/modules/qpool/ui/edit/LifecycleMetadataEditController.java index 9d6ab1d3349358f63cb9eb053876143d791cf623..8a7b64c33b618b36f1e8834d855941aeddca1a54 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/LifecycleMetadataEditController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/LifecycleMetadataEditController.java @@ -64,7 +64,7 @@ public class LifecycleMetadataEditController extends FormBasicController { protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { setFormTitle("lifecycle"); - versionEl = uifactory.addTextElement("lifecycle.version", "lifecycle.version", 50, "", formLayout); + versionEl = uifactory.addTextElement("lifecycle.version", "lifecycle.version", 50, item.getItemVersion(), formLayout); String[] statusTypeKeys = QuestionStatus.valueString(); String[] statusTypeValues = new String[statusTypeKeys.length]; @@ -73,6 +73,9 @@ public class LifecycleMetadataEditController extends FormBasicController { } statusEl = uifactory.addDropdownSingleselect("lifecycle.status", "lifecycle.status", formLayout, statusTypeKeys, statusTypeValues, null); + if(item.getQuestionStatus() != null) { + statusEl.select(item.getQuestionStatus().name(), true); + } FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); buttonsCont.setRootForm(mainForm); diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataController.java b/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataController.java index 48e687616935e52be04d8624383c973a81e54dce..71125b903351d410632cea68ad830f36090be760 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataController.java @@ -85,7 +85,11 @@ public class QuestionMetadataController extends FormBasicController { if(type == null || type.getType() == null) { typeEl.setValue(""); } else { - typeEl.setValue(type.getType()); + String translation = translate("item.type." + type.getType().toLowerCase()); + if(translation.length() > 128) { + translation = type.getType(); + } + typeEl.setValue(translation); } difficultyEl.setValue(toString(item.getDifficulty())); diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataEditController.java b/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataEditController.java index 8964b9c1f59618e7fa995cb0ac2d41a52995e5bf..92d1e13446def6233202010cf158c93ee4ba2445 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataEditController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/QuestionMetadataEditController.java @@ -73,21 +73,33 @@ public class QuestionMetadataEditController extends FormBasicController { int count = 0; for(QItemType type:types) { typeKeys[count] = type.getType(); - typeValues[count++] = translate("item.type." + type.getType().toLowerCase()); + String translation = translate("item.type." + type.getType().toLowerCase()); + if(translation.length() > 128) { + typeValues[count++] = typeKeys[count]; + } else { + typeValues[count++] = translation; + } } typeEl = uifactory.addDropdownSingleselect("question.type", "question.type", formLayout, typeKeys, typeValues, null); + if(item.getType() != null) { + typeEl.select(item.getType().getType(), true); + } - difficultyEl = uifactory.addTextElement("question.difficulty", "question.difficulty", 10, "", formLayout); + String difficulty = toString(item.getDifficulty()); + difficultyEl = uifactory.addTextElement("question.difficulty", "question.difficulty", 10, difficulty, formLayout); difficultyEl.setExampleKey("question.difficulty.example", null); difficultyEl.setDisplaySize(4); - stdevDifficultyEl = uifactory.addTextElement("question.stdevDifficulty", "question.stdevDifficulty", 10, "", formLayout); + + String stdevDifficulty = toString(item.getStdevDifficulty()); + stdevDifficultyEl = uifactory.addTextElement("question.stdevDifficulty", "question.stdevDifficulty", 10, stdevDifficulty, formLayout); stdevDifficultyEl.setExampleKey("question.stdevDifficulty.example", null); stdevDifficultyEl.setDisplaySize(4); - differentiationEl = uifactory.addTextElement("question.differentiation", "question.differentiation", 10, "", formLayout); + String differentiation = toString(item.getDifferentiation()); + differentiationEl = uifactory.addTextElement("question.differentiation", "question.differentiation", 10, differentiation, formLayout); differentiationEl.setExampleKey("question.differentiation.example", null); differentiationEl.setDisplaySize(4); - - numAnswerAltEl = uifactory.addTextElement("question.numOfAnswerAlternatives", "question.numOfAnswerAlternatives", 10, "", formLayout); + String numAnswerAlt = item.getNumOfAnswerAlternatives() < 0 ? "" : Integer.toString(item.getNumOfAnswerAlternatives()); + numAnswerAltEl = uifactory.addTextElement("question.numOfAnswerAlternatives", "question.numOfAnswerAlternatives", 10, numAnswerAlt, formLayout); numAnswerAltEl.setDisplaySize(4); uifactory.addStaticTextElement("question.usage", Integer.toString(item.getUsage()), formLayout); @@ -98,6 +110,9 @@ public class QuestionMetadataEditController extends FormBasicController { }; assessmentTypeEl = uifactory.addDropdownSingleselect("question.assessmentType", "question.assessmentType", formLayout, assessmentTypeKeys, assessmentTypeValues, null); + if(StringHelper.containsNonWhitespace(item.getAssessmentType())) { + assessmentTypeEl.select(item.getAssessmentType(), true); + } FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); buttonsCont.setRootForm(mainForm); @@ -200,6 +215,13 @@ public class QuestionMetadataEditController extends FormBasicController { return null; } + private String toString(BigDecimal val) { + if(val == null) { + return ""; + } + return val.toPlainString(); + } + private int toInt(String val) { if(StringHelper.containsNonWhitespace(val)) { return Integer.parseInt(val); diff --git a/src/main/java/org/olat/modules/qpool/ui/edit/TechnicalMetadataEditController.java b/src/main/java/org/olat/modules/qpool/ui/edit/TechnicalMetadataEditController.java index c6256b79f690213eecdaa496fa5e91c4721dccff..794f9857bc4501e40e1b9f59d625594793d0c5d4 100644 --- a/src/main/java/org/olat/modules/qpool/ui/edit/TechnicalMetadataEditController.java +++ b/src/main/java/org/olat/modules/qpool/ui/edit/TechnicalMetadataEditController.java @@ -64,9 +64,9 @@ public class TechnicalMetadataEditController extends FormBasicController { @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { setFormTitle("technical"); - - editorEl = uifactory.addTextElement("technical.editor", "technical.editor", 50, "", formLayout); - editorVersionEl = uifactory.addTextElement("technical.editorVersion", "technical.editorVersion", 50, "", formLayout); + + editorEl = uifactory.addTextElement("technical.editor", "technical.editor", 50, item.getEditor(), formLayout); + editorVersionEl = uifactory.addTextElement("technical.editorVersion", "technical.editorVersion", 50, item.getEditorVersion(), formLayout); String[] formatKeys = new String[]{ QTIConstants.QTI_12_FORMAT }; formatEl = uifactory.addDropdownSingleselect("technical.format", "technical.format", formLayout, diff --git a/src/main/java/org/olat/modules/qpool/ui/wizard/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/qpool/ui/wizard/_i18n/LocalStrings_de.properties index 858ba0805119efb76835ba83b5e65c5dff02b8b9..4002bd2812b09380f909dd5f4f048013502d518e 100644 --- a/src/main/java/org/olat/modules/qpool/ui/wizard/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/qpool/ui/wizard/_i18n/LocalStrings_de.properties @@ -1,6 +1,6 @@ #Mon Mar 02 09:54:04 CET 2009 -author.item=Authoren -author.choose.title=Authoren auswählen +author.item=Autoren +author.choose.title=Autoren auswählen author.confirm.title=Bestätigen table.user.login=$org.olat.admin.user\:table.user.login export.type=Typ diff --git a/src/main/webapp/static/js/functions.js b/src/main/webapp/static/js/functions.js index c1d7d802bbd0d02d2239cffdbec4741a5cb495e3..741d17b60e3249132c52938820b76a01c27af0e8 100644 --- a/src/main/webapp/static/js/functions.js +++ b/src/main/webapp/static/js/functions.js @@ -352,6 +352,19 @@ Array.prototype.search = function(s,q){ return false; } +if(!Function.prototype.curry) { + Function.prototype.curry = function() { + if (arguments.length<1) { + return this; //nothing to curry with - return function + } + var __method = this; + var args = Array.prototype.slice.call(arguments); + return function() { + return __method.apply(this, args.concat(Array.prototype.slice.call(arguments))); + } + } +} + if(!Array.prototype.indexOf) { Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) { "use strict"; @@ -1064,7 +1077,8 @@ function showMessageBox(type, title, message, buttonCallback){ //possible if the user has closed the window } } - }).dialog('open'); + }).dialog('open').dialog("widget").css('z-index', 11000); + } } diff --git a/src/main/webapp/static/js/js.plugins.min.js b/src/main/webapp/static/js/js.plugins.min.js index 1edaad76963641bddea2c332fb9957907f0d2492..31b56ddb462795f0b070bd7b83b76a04a84654ff 100644 --- a/src/main/webapp/static/js/js.plugins.min.js +++ b/src/main/webapp/static/js/js.plugins.min.js @@ -1,4 +1,4 @@ -OPOL={};var o2c=0;var o3c=new Array();o_info.guibusy=false;o_info.linkbusy=false;o_info.debug=true;var BLoader={_ajaxLoadedJS:new Array(),_isAlreadyLoadedJS:function(b){var a=true;jQuery("head script[src]").each(function(d,c){if(jQuery(c).attr("src").indexOf(b)!=-1){a=false}});if(jQuery.inArray(b,this._ajaxLoadedJS)!=-1){a=false}return !a},loadJS:function(b,c,a){if(!this._isAlreadyLoadedJS(b)){if(o_info.debug){o_log("BLoader::loadJS: loading ajax::"+a+" url::"+b)}if(a){jQuery.ajax(b,{async:false,dataType:"script",success:function(d,f,e){}});this._ajaxLoadedJS.push(b)}else{jQuery.getScript(b)}if(o_info.debug){o_log("BLoader::loadJS: loading DONE url::"+b)}}else{if(o_info.debug){o_log("BLoader::loadJS: already loaded url::"+b)}}},executeGlobalJS:function(jsString,contextDesc){try{if(window.execScript){window.execScript(jsString)}else{window.eval(jsString)}}catch(e){if(console){console.log(contextDesc,"cannot execute js",jsString)}if(o_info.debug){o_logerr("BLoader::executeGlobalJS: Error when executing JS code in contextDesc::"+contextDesc+' error::"'+showerror(e)+" for: "+escape(jsString))}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::executeGlobalJS: Error when executing JS code in contextDesc::"+contextDesc+' error::"'+showerror(e)+" for: "+escape(jsString),"functions.js::BLoader::executeGlobalJS::"+contextDesc)}if(window.location.href.indexOf("o_winrndo")!=-1){window.location.reload()}else{window.location.href=window.location.href+(window.location.href.indexOf("?")!=-1?"&":"?")+"o_winrndo=1"}}},loadCSS:function(b,o,q){var r=window.document;try{if(r.createStyleSheet){var j=r.styleSheets;var d=0;var p=0;for(i=0;i<j.length;i++){var m=j[i];var g=m.href;if(g==b){d++;if(m.disabled){m.disabled=false;return}else{if(o_info.debug){o_logwarn("BLoader::loadCSS: style: "+b+" already in document and not disabled! (duplicate add)")}return}}if(m.id=="b_theme_css"){p=i}}if(d>1&&o_info.debug){o_logwarn("BLoader::loadCSS: apply styles: num of stylesheets found was not 0 or 1:"+d)}if(q){p=j.length}var f=r.createStyleSheet(b,p)}else{var c=jQuery("#"+o);if(c&&c.size()>0){if(o_info.debug){o_logwarn("BLoader::loadCSS: stylesheet already found in doc when trying to add:"+b+", with id "+o)}return}else{var a=jQuery('<link id="'+o+'" rel="stylesheet" type="text/css" href="'+b+'">');if(q){a.insertBefore(jQuery("#b_fontSize_css"))}else{a.insertBefore(jQuery("#b_theme_css"))}}}}catch(n){if(console){console.log(n)}if(o_info.debug){o_logerr("BLoader::loadCSS: Error when loading CSS from URL::"+b)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::loadCSS: Error when loading CSS from URL::"+b,"functions.js::BLoader::loadCSS")}}},unLoadCSS:function(a,m){var n=window.document;try{if(n.createStyleSheet){var f=n.styleSheets;var d=0;var o=a;var b=window.location.href.substring(0,window.location.href.indexOf("/",8));if(a.indexOf(b)==0){o=a.substring(b.length)}for(i=0;i<f.length;i++){var g=f[i].href;if(g==a||g==o){d++;if(!f[i].disabled){f[i].disabled=true}else{if(o_info.debug){o_logwarn("stylesheet: when removing: matching url, but already disabled! url:"+g)}}}}if(d!=1&&o_info.debug){o_logwarn("stylesheet: when removeing: num of stylesheets found was not 1:"+d)}}else{var c=jQuery("#"+m);if(c){c.href="";c.remove();c=null;return}else{if(o_info.debug){o_logwarn("no link with id found to remove, id:"+m+", url "+a)}}}}catch(j){if(o_info.debug){o_logerr("BLoader::unLoadCSS: Error when unloading CSS from URL::"+a)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::unLoadCSS: Error when unloading CSS from URL::"+a,"functions.js::BLoader::loadCSS")}}}};var BFormatter={formatLatexFormulas:function(b){try{if(jsMath){if(jsMath.loaded){jsMath.ProcessBeforeShowing.curry(b).delay(0.01)}else{jsMath.Autoload.LoadJsMath();BFormatter.formatLatexFormulas.delay(0.1)}}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BFormatter::formatLatexFormulas: can not format latex formulas, jsMath not installed. Check your logfile","functions.js::BFormatter::formatLatexFormulas")}}}catch(a){if(o_info.debug){o_log("error in BFormatter.formatLatexFormulas: "+showerror(a))}}}};function o_init(){try{o_getMainWin().o_afterserver()}catch(a){if(o_info.debug){o_log("error in o_init: "+showerror(a))}}}function b_initEmPxFactor(){o_info.emPxFactor=jQuery("#b_width_1em").width();if(o_info.emPxFactor==0||o_info.emPxFactor=="undefined"){o_info.emPxFactor=12;if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Could not read with of element b_width_1em, set o_info.emPxFactor to 12","functions.js")}}}function o_getMainWin(){try{if(window.opener&&window.opener.OPOL){return window.opener}else{if(window.OPOL){return window}}}catch(a){if(o_info.debug){o_logerr('Exception while getting main window. rror::"'+showerror(a))}if(B_AjaxLogger.isDebugEnabled()){B_AjaxLogger.logDebug('Exception while getting main window. rror::"'+showerror(a),"functions.js")}}throw"Can not find main OpenOLAT window"}function o_beforeserver(){o_info.linkbusy=true;showAjaxBusy();if(window.suppressOlatOnUnloadOnce){window.suppressOlatOnUnloadOnce=false}else{if(window.olatonunload){olatonunload()}}}function o_afterserver(){o2c=0;o_info.linkbusy=false;removeAjaxBusy()}function o2cl(){if(o_info.linkbusy){return false}else{var a=(o2c==0||confirm(o_info.dirty_form));if(a){o_beforeserver()}return a}}function o3cl(d){if(o_info.linkbusy){return false}else{var b=o3c1.indexOf(d)>-1;var a=(b&&o3c1.length>1)||o3c1.length>0;var c=(!a||confirm(o_info.dirty_form));if(c){o_beforeserver()}return c}}function o_onc(a){var b=a.responseText;BLoader.executeGlobalJS("o_info.last_o_onc="+b+";","o_onc");o_ainvoke(o_info.last_o_onc,false)}function o_allowNextClick(){o_info.linkbusy=false;removeAjaxBusy()}function removeBusyAfterDownload(c,b,a){o2c=0;o_afterserver()}Array.prototype.search=function(c,d){var a=this.length;for(var b=0;b<a;b++){if(this[b].constructor==Array){if(this[b].search(c,d)){return true;break}}else{if(d){if(this[b].indexOf(c)!=-1){return true;break}}else{if(this[b]==c){return true;break}}}}return false};if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c){if(this==null){throw new TypeError()}var d=Object(this);var a=d.length>>>0;if(a===0){return -1}var e=0;if(arguments.length>1){e=Number(arguments[1]);if(e!=e){e=0}else{if(e!=0&&e!=Infinity&&e!=-Infinity){e=(e>0||-1)*Math.floor(Math.abs(e))}}}if(e>=a){return -1}var b=e>=0?e:Math.max(a-Math.abs(e),0);for(;b<a;b++){if(b in d&&d[b]===c){return b}}return -1}}var b_onDomReplacementFinished_callbacks=new Array();function b_AddOnDomReplacementFinishedCallback(a){var b=jQuery(document).ooLog().isDebugEnabled();if(b){jQuery(document).ooLog("debug","callback stack size: "+b_onDomReplacementFinished_callbacks.length,"functions.js ADD")}if(b&&jQuery.browser.mozilla&&!jQuery.browser.webkit){jQuery(document).ooLog("debug","stack content"+b_onDomReplacementFinished_callbacks.toSource(),"functions.js ADD")}b_onDomReplacementFinished_callbacks.push(a);if(b){jQuery(document).ooLog("debug","push to callback stack, func: "+a,"functions.js ADD")}}var b_changedDomEl=new Array();function b_AddOnDomReplacementFinishedUniqueCallback(a){if(a.constructor==Array){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","add: its an ARRAY! ","functions.js ADD")}if(b_onDomReplacementFinished_callbacks.search(a[0])){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","push to callback stack, already there!!: "+a[0],"functions.js ADD")}return}}b_AddOnDomReplacementFinishedCallback(a)}var o_debug_trid=0;function o_ainvoke(H){if(H==undefined){return}o_info.inainvoke=true;var D=H.cmdcnt;if(D>0){b_changedDomEl=new Array();if(o_info.debug){o_debug_trid++}var v=H.cmds;for(var N=0;N<D;N++){var E=v[N];var x=E.cmd;var L=E.cda;var O=E.w;var b=this.window;var F;if(b){switch(x){case 1:var G=L.e;BLoader.executeGlobalJS(G,"o_ainvoker::jsexec");if(o_info.debug){o_log("c1: execute jscode: "+G)}case 2:var s=L.cc;var B=L.cps;for(var K=0;K<s;K++){var h=B[K];var g=h.cid;var J=h.cidvis;var u=h.hfrag;var I=h.jsol;var f=h.hdr;if(o_info.debug){o_log("c2: redraw: "+h.cname+" ("+g+") "+h.hfragsize+" bytes, listener(s): "+h.clisteners)}var Q=f+"\n\n"+u;var z="";var M=false;var y=jQuery("#o_c"+g);if(y==null||(y.length==0)){y=jQuery("#o_fi"+g);M=true}if(y!=null){if(J){y.css("display","")}else{y.css("display","none")}if(M){y.replaceWith(Q)}else{y.empty();try{y.html(Q)}catch(T){if(console){console.log(T)}if(console){console.log("Fragment",Q)}}b_changedDomEl.push("o_c"+g)}y=null;if(z!=""){z.each(function(e){BLoader.executeGlobalJS(e,"o_ainvoker::inscripts")})}if(I!=""){BLoader.executeGlobalJS(I,"o_ainvoker::jsol")}}}break;case 3:b.o2c=0;var R=L.rurl;b.o_afterserver();b.document.location.replace(R);break;case 5:b.o2c=0;var R=L.rurl;b.o_afterserver();b.document.location.replace(R);break;case 6:b.o2c=0;b.o_afterserver();break;case 7:var n=b.document.location;var w=n.protocol+"//"+n.hostname;if(n.port!=""){w+=":"+n.port}var t=L.cssrm;for(K=0;K<t.length;K++){var A=t[K];var C=A.id;var d=w+A.url;BLoader.unLoadCSS(d,C);if(o_info.debug){o_log("c7: rm css: id:"+C+" ,url:'"+d+"'")}}var P=L.cssadd;for(k=0;k<P.length;k++){var A=P[k];var C=A.id;var d=w+A.url;var m=A.pt;BLoader.loadCSS(d,C,m);if(o_info.debug){o_log("c7: add css: id:"+C+" ,url:'"+d+"'")}}var o=L.jsadd;for(l=0;l<o.length;l++){var A=o[l];var S=A.before;if(jQuery.type(S)==="string"){BLoader.executeGlobalJS(S,"o_ainvoker::preJsAdd")}var d=A.url;var p=A.enc;if(jQuery.type(d)==="string"){BLoader.loadJS(d,p,true)}if(o_info.debug){o_log("c7: add js: "+d)}}break;default:if(o_info.debug){o_log("?: unknown command "+x)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in o_ainvoke(), ?: unknown command "+x,"functions.js")}break}}else{if(o_info.debug){o_log("could not find window??")}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in o_ainvoke(), could not find window??","functions.js")}}}var a=b_onDomReplacementFinished_callbacks.length;if(jQuery.browser.mozilla&&!jQuery.browser.webkit){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","stack content"+b_onDomReplacementFinished_callbacks.toSource(),"functions.js")}}for(mycounter=0;a>mycounter;mycounter++){if(mycounter>50){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stopped executing DOM replacement callback functions - to many functions::"+b_onDomReplacementFinished_callbacks.length,"functions.js")}break}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stacksize before shift: "+b_onDomReplacementFinished_callbacks.length,"functions.js")}var q=b_onDomReplacementFinished_callbacks.shift();if(typeof q.length==="number"){if(q[0]=="glosshighlighter"){var c=q[1];if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","arr fct: "+c,"functions.js")}q=c}}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Executing DOM replacement callback function #"+mycounter+" with timeout funct::"+q,"functions.js")}q();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stacksize after timeout: "+b_onDomReplacementFinished_callbacks.length,"functions.js")}}}o_info.inainvoke=false}function clearAfterAjaxIframeCall(){if(o_info.linkbusy){o_afterserver();showMessageBox("info",o_info.i18n_noresponse_title,o_info.i18n_noresponse,undefined)}}function showAjaxBusy(){if(o_info.linkbusy){try{jQuery("#b_ajax_busy").delay(500).queue(function(b){jQuery(this).addClass("b_ajax_busy");jQuery("#b_body").addClass("b_ajax_busy")})}catch(a){}}return}function removeAjaxBusy(){try{jQuery("#b_ajax_busy").delay(500).queue(function(b){jQuery(this).removeClass("b_ajax_busy");jQuery("#b_body").removeClass("b_ajax_busy")})}catch(a){}}var htmlEditorEnabled=(jQuery.browser.msie||jQuery.browser.mozilla);var scormPlayerEnabled=(jQuery.browser.msie||jQuery.browser.mozilla||jQuery.browser.webkit);function setFormDirty(c){o2c=1;var a=document.getElementById(c);if(a!=null){var b=a.olat_fosm_0;if(b==null){b=a.olat_fosm}if(b){b.className="b_button b_button_dirty"}}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in setFormDirty, myForm was null for formId="+c,"functions.js")}}}function contextHelpWindow(a){helpWindow=window.open(a,"HelpWindow","height=760, width=940, left=0, top=0, location=no, menubar=no, resizable=yes, scrollbars=yes, toolbar=no");helpWindow.focus()}function o_openPopUp(b,d,c,a,e){attributes="height="+a+", width="+c+", resizable=yes, scrollbars=yes, left=100, top=100, ";if(e){attributes+="location=yes, menubar=yes, status=yes, toolbar=yes"}else{attributes+="location=no, menubar=no, status=no, toolbar=no"}var f=window.open(b,d,attributes);f.focus()}function b_togglebox(a,b){jQuery("#"+a).slideToggle(400,function(){var c=jQuery(b);c.toggleClass("b_togglebox_closed");c.toggleClass("b_togglebox_opened")})}function b_handleFileUploadFormChange(e,b,d){var f=e.value;slashPos=f.lastIndexOf("/");if(slashPos!=-1){f=f.substring(slashPos+1)}slashPos=f.lastIndexOf("\\");if(slashPos!=-1){f=f.substring(slashPos+1)}b.value=f;if(d){d.className="b_button b_button_dirty"}var c=e.form.elements;for(i=0;i<c.length;i++){var a=c[i];if(a.name==b.name&&i+1<c.length){c[i+1].focus()}}}function gotonode(a){try{if(typeof o_activateCourseNode!="undefined"){o_activateCourseNode(a)}else{if(opener&&typeof opener.o_activateCourseNode!="undefined"){opener.o_activateCourseNode(a)}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in gotonode(), could not find main window","functions.js")}}}}catch(b){alert("Goto node error:"+b);if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in gotonode()::"+b.message,"functions.js")}}}function o_openUriInMainWindow(b){try{var a=o_getMainWin();a.focus();a.location.replace(b)}catch(c){showMessageBox("error","Error","Can not find main OpenOLAT window to open URL.")}}function b_viewportHeight(){var a=jQuery(document).height();if(a>0){return a}else{return 600}}OPOL.getMainColumnsMaxHeight=function(){var j=0,f=0,a=0,c=0,h=0,b,g=jQuery("#b_col1_content"),e=jQuery("#b_col2_content"),d=jQuery("#b_col3_content");if(g!="undefined"&&g!=null){j=g.height()}if(e!="undefined"&&e!=null){f=e.height()}if(d!="undefined"&&d!=null){a=d.height()}c=(j>f?j:f);c=(c>a?c:a);if(c>0){return c}b=jQuery("#b_main");if(b!="undefined"&&b!=null){h=b.height()}if(b>0){return b}return b_viewportHeight()};function b_resizeIframeToMainMaxHeight(f){var d=jQuery("#"+f);if(d!="undefined"&&d!=null){var c=OPOL.getMainColumnsMaxHeight();var b=b_viewportHeight()-100;var e=jQuery("#b_header");if(e!="undefined"&&e!=null){b=b-e.height()}e=jQuery("#b_nav");if(e!="undefined"&&e!=null){b=b-e.height()}e=jQuery("#b_footer");if(e!="undefined"&&e!=null){b=b-e.height()}var a=(b>c?b:c);d.height(a)}}var o_debu_oldcn,o_debu_oldtt;function o_debu_show(b,a){if(o_debu_oldcn){o_debu_hide(o_debu_oldcn,o_debu_oldtt)}jQuery(b).css("border","3px solid #00F").css("margin","0px").css("background-color","#FCFCB8");jQuery(a).show();o_debu_oldtt=a;o_debu_oldcn=b}function o_debu_hide(b,a){jQuery(a).hide();jQuery(b).css("border","1px dotted black").css("margin","2px").css("background-color","")}function o_dbg_mark(a){var b=jQuery("#"+a);if(b){b.css("background-color","#FCFCB8");b.css("border","3px solid #00F")}}function o_dbg_unmark(a){var b=jQuery("#"+a);if(b){b.css("border","");b.css("background-color","")}}function o_clearConsole(){o_log_all="";o_log(null)}var o_log_all="";function o_log(b){if(b){o_log_all="\n"+o_debug_trid+"> "+b+o_log_all;o_log_all=o_log_all.substr(0,4000)}var a=jQuery("#o_debug_cons");if(a){if(o_log_all.length==4000){o_log_all=o_log_all+"\n... (stripped: to long)... "}a.value=o_log_all}if(!jQuery.browser.IE&&!jQuery.type(window.console)==="undefined"){window.console.log(b)}}function o_logerr(a){o_log("ERROR:"+a)}function o_logwarn(a){o_log("WARN:"+a)}function showerror(c){var a="";for(var b in c){a+=b+": "+c[b]+"\n"}return"error detail:\n"+a}function o_ffEvent(e,d,c,h,j){var f,g,b,a;f=document.getElementById(d);g=f.value;f.value=c;b=document.getElementById(h);a=b.value;b.value=j;if(document.forms[e].onsubmit()){document.forms[e].submit()}f.value=g;b.value=a}function o_ffXHREvent(f,e,a,h,j){var c=new Object();c.dispatchuri=a;c.dispatchevent=j;if(arguments.length>5){var g=arguments.length;for(var d=5;d<g;d=d+2){if(g>d+1){c[arguments[d]]=arguments[d+1]}}}var b=jQuery("#"+f).attr("action");jQuery.ajax(b,{type:"GET",data:c,dataType:"json",success:function(n,o,m){o_ainvoke(n)},error:function(m,o,n){if(console){console.log("Error status",o)}}})}function setFlexiFormDirtyByListener(a){setFlexiFormDirty(a.data.formId)}function setFlexiFormDirty(b){var a=o3c.indexOf(b)>-1;if(!a){o3c.push(b)}jQuery("#"+b).each(function(){var c=jQuery(this).data("FlexiSubmit");if(c!=null){jQuery("#"+c).addClass("b_button b_button_dirty");o2c=1}})}function o_ffRegisterSubmit(b,a){jQuery("#"+b).data("FlexiSubmit",a)}function showInfoBox(f,c){var b=Math.floor(Math.random()*65536).toString(16);var e='<div id="'+b+'" class="b_msg-div msg" style="display:none;"><div class="b_msg_info_content b_msg_info_winicon o_sel_info_message"><h3>'+f+"</h3>"+c+"<br/><br/></div></div>";var a=jQuery("#b_page").prepend(e);var d=(c.length>150)?8000:((c.length>70)?6000:4000);jQuery("#"+b).slideDown(300).delay(d).slideUp(300);jQuery("#"+b).click(function(g){jQuery("#"+b).remove()});f=null;c=null;a=null;d=null}function showMessageBox(b,e,c,a){if(b=="info"){showInfoBox(e,c);return null}else{var d;if("warn"==b){d='<div><div class="b_msg_info_content b_msg_warn_winicon">'}else{if("error"==b){d='<div><div class="b_msg_info_content b_msg_error_winicon">'}else{d="<div><div>"}}return jQuery(d+"<p>"+c+"</p></div></div>").dialog({height:170,width:400,modal:true,title:e,resizable:false,close:function(f,g){try{jQuery(this).dialog("destroy").remove()}catch(h){}}}).dialog("open")}}function tableFormInjectCommandAndSubmit(a,b,c){document.forms[a].elements.cmd.value=b;document.forms[a].elements.param.value=c;document.forms[a].submit()}function b_table_toggleCheck(d,c){var a=document.forms[d].elements.tb_ms;len=a.length;if(typeof(len)=="undefined"){a.checked=c}else{var b;for(b=0;b<len;b++){a[b].checked=c}}}function onTreeStartDrag(a,b){jQuery(a.target).addClass("b_dd_proxy")}function onTreeStopDrag(a,b){jQuery(a.target).removeClass("b_dd_proxy")}function onTreeDrop(g,h){var a=jQuery(h.draggable[0]);var f=jQuery(this);f.css({position:"",width:""});var c=f.droppable("option","endUrl");if(c.lastIndexOf("/")==(c.length-1)){c=c.substring(0,c.length-1)}var e=a.attr("id");var b=e.substring(2,e.length);c+="%3Atnidle%3A"+b;var d=f.attr("id");if(d.indexOf("ds")==0){c+="%3Asne%3Ayes"}else{if(d.indexOf("dt")==0){c+="%3Asne%3Aend"}}frames.oaa0.location.href=c+"/"}function treeAcceptDrop(b){var c=jQuery(b);var e=c.attr("id");if(e!=undefined&&(e.indexOf("dd")==0||e.indexOf("ds")==0||e.indexOf("dt")==0||e.indexOf("da")==0||e.indexOf("row")==0)){var g=jQuery(this);var j=g.attr("id");var d=e.substring(2,e.length);var f=j.substring(2,j.length);if(d==f){return false}var h="";if(j.indexOf("ds")==0){h="yes"}else{if(j.indexOf("dt")==0){h="end"}}var m=g.data(d+"-"+h);if(m===undefined){var a=g.droppable("option","fbUrl");jQuery.ajax(a,{async:false,data:{nidle:d,tnidle:f,sne:h},dataType:"json",method:"GET",success:function(n){m=n.dropAllowed}});g.data(d+"-"+h,m)}return m}return false}function b_choice_toggleCheck(c,b){var d=document.forms[c].elements;len=d.length;if(typeof(len)=="undefined"){d.checked=b}else{var a;for(a=0;a<len;a++){if(d[a].type=="checkbox"&&d[a].getAttribute("class")=="b_checkbox"){d[a].checked=b}}}}function b_briefcase_isChecked(c,e){var b;var a=document.getElementById(c);var d=0;for(b=0;a.elements[b];b++){if(a.elements[b].type=="checkbox"&&a.elements[b].name=="paths"&&a.elements[b].checked){d++}}if(d<1){alert(e);return false}return true}function b_briefcase_toggleCheck(d,c){var a=document.getElementById(d);len=a.elements.length;var b;for(b=0;b<len;b++){if(a.elements[b].name=="paths"){a.elements[b].checked=c}}}function b_doPrint(){var d=jQuery("div.b_iframe_wrapper iframe");if(d.length>0){try{var a=d[0];frames[a.name].focus();frames[a.name].print();return}catch(c){for(i=0;frames.length>i;i++){a=frames[i];if(a.name=="oaa0"){continue}var b=document.getElementsByName(a.name)[0];if(b&&b.getAttribute("class")=="ext-shim"){continue}if(a.name!=""){try{frames[a.name].focus();frames[a.name].print()}catch(c){window.print()}return}}window.print()}}else{window.print()}}function b_attach_i18n_inline_editing(){jQuery("span.b_translation_i18nitem").hover(function(){jQuery(this.firstChild).show();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Entered i18nitem::"+this.firstChild,"functions.js:b_attach_i18n_inline_editing()")}},function(){jQuery("a.b_translation_i18nitem_launcher").hide();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Leaving i18nitem::"+this,"functions.js:b_attach_i18n_inline_editing()")}});jQuery("a.b_translation_i18nitem_launcher").hover(function(){var a=jQuery(this).parent("span.b_translation_i18nitem");a.effect("highlight")});b_AddOnDomReplacementFinishedCallback(b_attach_i18n_inline_editing)}var BDebugger={_lastDOMCount:0,_lastObjCount:0,_knownGlobalOLATObjects:["o_afterserver","o_onc","o_getMainWin","o_ainvoke","o_info","o_beforeserver","o_ffEvent","o_openPopUp","o_debu_show","o_logwarn","o_dbg_unmark","o_ffRegisterSubmit","o_clearConsole","o_init","o_log","o_allowNextClick","o_dbg_mark","o_debu_hide","o_logerr","o_debu_oldcn","o_debu_oldtt","o_openUriInMainWindow","o_debug_trid","o_log_all"],_countDOMElements:function(){return document.getElementsByTagName("*").length},_countGlobalObjects:function(){var a=0;for(prop in window){a++}return a},logDOMCount:function(){var b=BDebugger;var a=b._countDOMElements();var c=a-b._lastDOMCount;console.log((c>0?"+":"")+c+" \t"+a+" \tDOM element count after DOM replacement");b._lastDOMCount=a;a=null},logGlobalObjCount:function(){var b=BDebugger;var a=b._countGlobalObjects();var c=a-b._lastObjCount;console.log((c>0?"+":"")+c+" \t"+a+" \tGlobal object count after DOM replacement");b._lastObjCount=a;a=null},logGlobalOLATObjects:function(){var b=BDebugger;var a=new Array();for(prop in window){if(prop.indexOf("o_")==0&&b._knownGlobalOLATObjects.indexOf(prop)==-1){a.push(prop)}}if(a.length>0){console.log(a.length+" global OLAT objects found:");a.each(function(c){console.log("\t"+typeof window[c]+" \t"+c)})}},logManagedOLATObjects:function(){var a=BDebugger;if(o_info.objectMap.length>0){console.log(o_info.objectMap.length+" managed OLAT objects found:");o_info.objectMap.eachKey(function(b){var c=o_info.objectMap.get(b);console.log("\t"+typeof c+" \t"+b);return true})}}};var Hashtable=(function(){var p="function";var n=(typeof Array.prototype.splice==p)?function(s,r){s.splice(r,1)}:function(u,t){var s,v,r;if(t===u.length-1){u.length=t}else{s=u.slice(t+1);u.length=t;for(v=0,r=s.length;v<r;++v){u[t+v]=s[v]}}};function a(t){var r;if(typeof t=="string"){return t}else{if(typeof t.hashCode==p){r=t.hashCode();return(typeof r=="string")?r:a(r)}else{if(typeof t.toString==p){return t.toString()}else{try{return String(t)}catch(s){return Object.prototype.toString.call(t)}}}}}function g(r,s){return r.equals(s)}function e(r,s){return(typeof s.equals==p)?s.equals(r):(r===s)}function c(r){return function(s){if(s===null){throw new Error("null is not a valid "+r)}else{if(typeof s=="undefined"){throw new Error(r+" must not be undefined")}}}}var q=c("key"),l=c("value");function d(u,s,t,r){this[0]=u;this.entries=[];this.addEntry(s,t);if(r!==null){this.getEqualityFunction=function(){return r}}}var h=0,j=1,f=2;function o(r){return function(t){var s=this.entries.length,v,u=this.getEqualityFunction(t);while(s--){v=this.entries[s];if(u(t,v[0])){switch(r){case h:return true;case j:return v;case f:return[s,v[1]]}}}return false}}function k(r){return function(u){var v=u.length;for(var t=0,s=this.entries.length;t<s;++t){u[v+t]=this.entries[t][r]}}}d.prototype={getEqualityFunction:function(r){return(typeof r.equals==p)?g:e},getEntryForKey:o(j),getEntryAndIndexForKey:o(f),removeEntryForKey:function(s){var r=this.getEntryAndIndexForKey(s);if(r){n(this.entries,r[0]);return r[1]}return null},addEntry:function(r,s){this.entries[this.entries.length]=[r,s]},keys:k(0),values:k(1),getEntries:function(s){var u=s.length;for(var t=0,r=this.entries.length;t<r;++t){s[u+t]=this.entries[t].slice(0)}},containsKey:o(h),containsValue:function(s){var r=this.entries.length;while(r--){if(s===this.entries[r][1]){return true}}return false}};function m(s,t){var r=s.length,u;while(r--){u=s[r];if(t===u[0]){return r}}return null}function i(r,s){var t=r[s];return(t&&(t instanceof d))?t:null}function b(t,r){var w=this;var v=[];var u={};var x=(typeof t==p)?t:a;var s=(typeof r==p)?r:null;this.put=function(B,C){q(B);l(C);var D=x(B),E,A,z=null;E=i(u,D);if(E){A=E.getEntryForKey(B);if(A){z=A[1];A[1]=C}else{E.addEntry(B,C)}}else{E=new d(D,B,C,s);v[v.length]=E;u[D]=E}return z};this.get=function(A){q(A);var B=x(A);var C=i(u,B);if(C){var z=C.getEntryForKey(A);if(z){return z[1]}}return null};this.containsKey=function(A){q(A);var z=x(A);var B=i(u,z);return B?B.containsKey(A):false};this.containsValue=function(A){l(A);var z=v.length;while(z--){if(v[z].containsValue(A)){return true}}return false};this.clear=function(){v.length=0;u={}};this.isEmpty=function(){return !v.length};var y=function(z){return function(){var A=[],B=v.length;while(B--){v[B][z](A)}return A}};this.keys=y("keys");this.values=y("values");this.entries=y("getEntries");this.remove=function(B){q(B);var C=x(B),z,A=null;var D=i(u,C);if(D){A=D.removeEntryForKey(B);if(A!==null){if(!D.entries.length){z=m(v,C);n(v,z);delete u[C]}}}return A};this.size=function(){var A=0,z=v.length;while(z--){A+=v[z].entries.length}return A};this.each=function(C){var z=w.entries(),A=z.length,B;while(A--){B=z[A];C(B[0],B[1])}};this.putAll=function(H,C){var B=H.entries();var E,F,D,z,A=B.length;var G=(typeof C==p);while(A--){E=B[A];F=E[0];D=E[1];if(G&&(z=w.get(F))){D=C(F,z,D)}w.put(F,D)}};this.clone=function(){var z=new b(t,r);z.putAll(w);return z}}return b})();(function(b){b.fn.ooLog=function(f,d,e){var c=null;b(this).each(function(){c=b(this).data("_ooLog");if(c==undefined){c=new a();b(this).data("_ooLog",c)}});if(f==undefined){return c}else{if(typeof f==="string"){if(c){c.log(f,d,e)}}}};function a(){return this}a.prototype={isDebugEnabled:function(){return o_info.JSTracingLogDebugEnabled},log:function(e,c,d){if(!this.isDebugEnabled()){return}jQuery.post(o_info.JSTracingUri,{level:e,logMsg:c,jsFile:d})}}})(jQuery);(function(b){b.fn.ooTranslator=function(){var d=null;b(document).each(function(){d=b(document).data("_ooTranslator");if(d==undefined){d=new a();b(document).data("_ooTranslator",d)}});return d};function a(){return this}a.prototype={mapperUrl:null,translators:null,initialize:function(d){this.mapperUrl=d;this.translators=new Object()},getTranslator:function(d,f){if(this.translators[d]==null){this.translators[d]=new Object()}if(this.translators[d][f]==null){var e=this.mapperUrl+"/"+d+"/"+f+"/translations.js";jQuery.ajax(e,{async:false,dataType:"json",success:function(g,i,h){jQuery(document).ooTranslator()._createTranslator(g,d,f)}})}return this.translators[d][f]},_createTranslator:function(e,d,f){this.translators[d][f]=new c().initialize(e,d,f)}};function c(){return this}c.prototype={localizationData:null,bundle:null,locale:null,initialize:function(f,d,e){this.bundle=e;this.locale=d;this.localizationData=f;return this},translate:function(d){if(this.localizationData[d]){return this.localizationData[d]}else{return this.bundle+":"+d}}}})(jQuery);/*! +OPOL={};var o2c=0;var o3c=new Array();o_info.guibusy=false;o_info.linkbusy=false;o_info.debug=true;var BLoader={_ajaxLoadedJS:new Array(),_isAlreadyLoadedJS:function(b){var a=true;jQuery("head script[src]").each(function(d,c){if(jQuery(c).attr("src").indexOf(b)!=-1){a=false}});if(jQuery.inArray(b,this._ajaxLoadedJS)!=-1){a=false}return !a},loadJS:function(b,c,a){if(!this._isAlreadyLoadedJS(b)){if(o_info.debug){o_log("BLoader::loadJS: loading ajax::"+a+" url::"+b)}if(a){jQuery.ajax(b,{async:false,dataType:"script",success:function(d,f,e){}});this._ajaxLoadedJS.push(b)}else{jQuery.getScript(b)}if(o_info.debug){o_log("BLoader::loadJS: loading DONE url::"+b)}}else{if(o_info.debug){o_log("BLoader::loadJS: already loaded url::"+b)}}},executeGlobalJS:function(jsString,contextDesc){try{if(window.execScript){window.execScript(jsString)}else{window.eval(jsString)}}catch(e){if(console){console.log(contextDesc,"cannot execute js",jsString)}if(o_info.debug){o_logerr("BLoader::executeGlobalJS: Error when executing JS code in contextDesc::"+contextDesc+' error::"'+showerror(e)+" for: "+escape(jsString))}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::executeGlobalJS: Error when executing JS code in contextDesc::"+contextDesc+' error::"'+showerror(e)+" for: "+escape(jsString),"functions.js::BLoader::executeGlobalJS::"+contextDesc)}if(window.location.href.indexOf("o_winrndo")!=-1){window.location.reload()}else{window.location.href=window.location.href+(window.location.href.indexOf("?")!=-1?"&":"?")+"o_winrndo=1"}}},loadCSS:function(b,o,q){var r=window.document;try{if(r.createStyleSheet){var j=r.styleSheets;var d=0;var p=0;for(i=0;i<j.length;i++){var m=j[i];var g=m.href;if(g==b){d++;if(m.disabled){m.disabled=false;return}else{if(o_info.debug){o_logwarn("BLoader::loadCSS: style: "+b+" already in document and not disabled! (duplicate add)")}return}}if(m.id=="b_theme_css"){p=i}}if(d>1&&o_info.debug){o_logwarn("BLoader::loadCSS: apply styles: num of stylesheets found was not 0 or 1:"+d)}if(q){p=j.length}var f=r.createStyleSheet(b,p)}else{var c=jQuery("#"+o);if(c&&c.size()>0){if(o_info.debug){o_logwarn("BLoader::loadCSS: stylesheet already found in doc when trying to add:"+b+", with id "+o)}return}else{var a=jQuery('<link id="'+o+'" rel="stylesheet" type="text/css" href="'+b+'">');if(q){a.insertBefore(jQuery("#b_fontSize_css"))}else{a.insertBefore(jQuery("#b_theme_css"))}}}}catch(n){if(console){console.log(n)}if(o_info.debug){o_logerr("BLoader::loadCSS: Error when loading CSS from URL::"+b)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::loadCSS: Error when loading CSS from URL::"+b,"functions.js::BLoader::loadCSS")}}},unLoadCSS:function(a,m){var n=window.document;try{if(n.createStyleSheet){var f=n.styleSheets;var d=0;var o=a;var b=window.location.href.substring(0,window.location.href.indexOf("/",8));if(a.indexOf(b)==0){o=a.substring(b.length)}for(i=0;i<f.length;i++){var g=f[i].href;if(g==a||g==o){d++;if(!f[i].disabled){f[i].disabled=true}else{if(o_info.debug){o_logwarn("stylesheet: when removing: matching url, but already disabled! url:"+g)}}}}if(d!=1&&o_info.debug){o_logwarn("stylesheet: when removeing: num of stylesheets found was not 1:"+d)}}else{var c=jQuery("#"+m);if(c){c.href="";c.remove();c=null;return}else{if(o_info.debug){o_logwarn("no link with id found to remove, id:"+m+", url "+a)}}}}catch(j){if(o_info.debug){o_logerr("BLoader::unLoadCSS: Error when unloading CSS from URL::"+a)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BLoader::unLoadCSS: Error when unloading CSS from URL::"+a,"functions.js::BLoader::loadCSS")}}}};var BFormatter={formatLatexFormulas:function(b){try{if(jsMath){if(jsMath.loaded){jsMath.ProcessBeforeShowing.curry(b).delay(0.01)}else{jsMath.Autoload.LoadJsMath();BFormatter.formatLatexFormulas.delay(0.1)}}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","BFormatter::formatLatexFormulas: can not format latex formulas, jsMath not installed. Check your logfile","functions.js::BFormatter::formatLatexFormulas")}}}catch(a){if(o_info.debug){o_log("error in BFormatter.formatLatexFormulas: "+showerror(a))}}}};function o_init(){try{o_getMainWin().o_afterserver()}catch(a){if(o_info.debug){o_log("error in o_init: "+showerror(a))}}}function b_initEmPxFactor(){o_info.emPxFactor=jQuery("#b_width_1em").width();if(o_info.emPxFactor==0||o_info.emPxFactor=="undefined"){o_info.emPxFactor=12;if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Could not read with of element b_width_1em, set o_info.emPxFactor to 12","functions.js")}}}function o_getMainWin(){try{if(window.opener&&window.opener.OPOL){return window.opener}else{if(window.OPOL){return window}}}catch(a){if(o_info.debug){o_logerr('Exception while getting main window. rror::"'+showerror(a))}if(B_AjaxLogger.isDebugEnabled()){B_AjaxLogger.logDebug('Exception while getting main window. rror::"'+showerror(a),"functions.js")}}throw"Can not find main OpenOLAT window"}function o_beforeserver(){o_info.linkbusy=true;showAjaxBusy();if(window.suppressOlatOnUnloadOnce){window.suppressOlatOnUnloadOnce=false}else{if(window.olatonunload){olatonunload()}}}function o_afterserver(){o2c=0;o_info.linkbusy=false;removeAjaxBusy()}function o2cl(){if(o_info.linkbusy){return false}else{var a=(o2c==0||confirm(o_info.dirty_form));if(a){o_beforeserver()}return a}}function o3cl(d){if(o_info.linkbusy){return false}else{var b=o3c1.indexOf(d)>-1;var a=(b&&o3c1.length>1)||o3c1.length>0;var c=(!a||confirm(o_info.dirty_form));if(c){o_beforeserver()}return c}}function o_onc(a){var b=a.responseText;BLoader.executeGlobalJS("o_info.last_o_onc="+b+";","o_onc");o_ainvoke(o_info.last_o_onc,false)}function o_allowNextClick(){o_info.linkbusy=false;removeAjaxBusy()}function removeBusyAfterDownload(c,b,a){o2c=0;o_afterserver()}Array.prototype.search=function(c,d){var a=this.length;for(var b=0;b<a;b++){if(this[b].constructor==Array){if(this[b].search(c,d)){return true;break}}else{if(d){if(this[b].indexOf(c)!=-1){return true;break}}else{if(this[b]==c){return true;break}}}}return false};if(!Function.prototype.curry){Function.prototype.curry=function(){if(arguments.length<1){return this}var a=this;var b=Array.prototype.slice.call(arguments);return function(){return a.apply(this,b.concat(Array.prototype.slice.call(arguments)))}}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c){if(this==null){throw new TypeError()}var d=Object(this);var a=d.length>>>0;if(a===0){return -1}var e=0;if(arguments.length>1){e=Number(arguments[1]);if(e!=e){e=0}else{if(e!=0&&e!=Infinity&&e!=-Infinity){e=(e>0||-1)*Math.floor(Math.abs(e))}}}if(e>=a){return -1}var b=e>=0?e:Math.max(a-Math.abs(e),0);for(;b<a;b++){if(b in d&&d[b]===c){return b}}return -1}}var b_onDomReplacementFinished_callbacks=new Array();function b_AddOnDomReplacementFinishedCallback(a){var b=jQuery(document).ooLog().isDebugEnabled();if(b){jQuery(document).ooLog("debug","callback stack size: "+b_onDomReplacementFinished_callbacks.length,"functions.js ADD")}if(b&&jQuery.browser.mozilla&&!jQuery.browser.webkit){jQuery(document).ooLog("debug","stack content"+b_onDomReplacementFinished_callbacks.toSource(),"functions.js ADD")}b_onDomReplacementFinished_callbacks.push(a);if(b){jQuery(document).ooLog("debug","push to callback stack, func: "+a,"functions.js ADD")}}var b_changedDomEl=new Array();function b_AddOnDomReplacementFinishedUniqueCallback(a){if(a.constructor==Array){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","add: its an ARRAY! ","functions.js ADD")}if(b_onDomReplacementFinished_callbacks.search(a[0])){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","push to callback stack, already there!!: "+a[0],"functions.js ADD")}return}}b_AddOnDomReplacementFinishedCallback(a)}var o_debug_trid=0;function o_ainvoke(H){if(H==undefined){return}o_info.inainvoke=true;var D=H.cmdcnt;if(D>0){b_changedDomEl=new Array();if(o_info.debug){o_debug_trid++}var v=H.cmds;for(var N=0;N<D;N++){var E=v[N];var x=E.cmd;var L=E.cda;var O=E.w;var b=this.window;var F;if(b){switch(x){case 1:var G=L.e;BLoader.executeGlobalJS(G,"o_ainvoker::jsexec");if(o_info.debug){o_log("c1: execute jscode: "+G)}case 2:var s=L.cc;var B=L.cps;for(var K=0;K<s;K++){var h=B[K];var g=h.cid;var J=h.cidvis;var u=h.hfrag;var I=h.jsol;var f=h.hdr;if(o_info.debug){o_log("c2: redraw: "+h.cname+" ("+g+") "+h.hfragsize+" bytes, listener(s): "+h.clisteners)}var Q=f+"\n\n"+u;var z="";var M=false;var y=jQuery("#o_c"+g);if(y==null||(y.length==0)){y=jQuery("#o_fi"+g);M=true}if(y!=null){if(J){y.css("display","")}else{y.css("display","none")}if(M){y.replaceWith(Q)}else{y.empty();try{y.html(Q)}catch(T){if(console){console.log(T)}if(console){console.log("Fragment",Q)}}b_changedDomEl.push("o_c"+g)}y=null;if(z!=""){z.each(function(e){BLoader.executeGlobalJS(e,"o_ainvoker::inscripts")})}if(I!=""){BLoader.executeGlobalJS(I,"o_ainvoker::jsol")}}}break;case 3:b.o2c=0;var R=L.rurl;b.o_afterserver();b.document.location.replace(R);break;case 5:b.o2c=0;var R=L.rurl;b.o_afterserver();b.document.location.replace(R);break;case 6:b.o2c=0;b.o_afterserver();break;case 7:var n=b.document.location;var w=n.protocol+"//"+n.hostname;if(n.port!=""){w+=":"+n.port}var t=L.cssrm;for(K=0;K<t.length;K++){var A=t[K];var C=A.id;var d=w+A.url;BLoader.unLoadCSS(d,C);if(o_info.debug){o_log("c7: rm css: id:"+C+" ,url:'"+d+"'")}}var P=L.cssadd;for(k=0;k<P.length;k++){var A=P[k];var C=A.id;var d=w+A.url;var m=A.pt;BLoader.loadCSS(d,C,m);if(o_info.debug){o_log("c7: add css: id:"+C+" ,url:'"+d+"'")}}var o=L.jsadd;for(l=0;l<o.length;l++){var A=o[l];var S=A.before;if(jQuery.type(S)==="string"){BLoader.executeGlobalJS(S,"o_ainvoker::preJsAdd")}var d=A.url;var p=A.enc;if(jQuery.type(d)==="string"){BLoader.loadJS(d,p,true)}if(o_info.debug){o_log("c7: add js: "+d)}}break;default:if(o_info.debug){o_log("?: unknown command "+x)}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in o_ainvoke(), ?: unknown command "+x,"functions.js")}break}}else{if(o_info.debug){o_log("could not find window??")}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in o_ainvoke(), could not find window??","functions.js")}}}var a=b_onDomReplacementFinished_callbacks.length;if(jQuery.browser.mozilla&&!jQuery.browser.webkit){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","stack content"+b_onDomReplacementFinished_callbacks.toSource(),"functions.js")}}for(mycounter=0;a>mycounter;mycounter++){if(mycounter>50){if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stopped executing DOM replacement callback functions - to many functions::"+b_onDomReplacementFinished_callbacks.length,"functions.js")}break}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stacksize before shift: "+b_onDomReplacementFinished_callbacks.length,"functions.js")}var q=b_onDomReplacementFinished_callbacks.shift();if(typeof q.length==="number"){if(q[0]=="glosshighlighter"){var c=q[1];if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","arr fct: "+c,"functions.js")}q=c}}if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Executing DOM replacement callback function #"+mycounter+" with timeout funct::"+q,"functions.js")}q();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Stacksize after timeout: "+b_onDomReplacementFinished_callbacks.length,"functions.js")}}}o_info.inainvoke=false}function clearAfterAjaxIframeCall(){if(o_info.linkbusy){o_afterserver();showMessageBox("info",o_info.i18n_noresponse_title,o_info.i18n_noresponse,undefined)}}function showAjaxBusy(){if(o_info.linkbusy){try{jQuery("#b_ajax_busy").delay(500).queue(function(b){jQuery(this).addClass("b_ajax_busy");jQuery("#b_body").addClass("b_ajax_busy")})}catch(a){}}return}function removeAjaxBusy(){try{jQuery("#b_ajax_busy").delay(500).queue(function(b){jQuery(this).removeClass("b_ajax_busy");jQuery("#b_body").removeClass("b_ajax_busy")})}catch(a){}}var htmlEditorEnabled=(jQuery.browser.msie||jQuery.browser.mozilla);var scormPlayerEnabled=(jQuery.browser.msie||jQuery.browser.mozilla||jQuery.browser.webkit);function setFormDirty(c){o2c=1;var a=document.getElementById(c);if(a!=null){var b=a.olat_fosm_0;if(b==null){b=a.olat_fosm}if(b){b.className="b_button b_button_dirty"}}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in setFormDirty, myForm was null for formId="+c,"functions.js")}}}function contextHelpWindow(a){helpWindow=window.open(a,"HelpWindow","height=760, width=940, left=0, top=0, location=no, menubar=no, resizable=yes, scrollbars=yes, toolbar=no");helpWindow.focus()}function o_openPopUp(b,d,c,a,e){attributes="height="+a+", width="+c+", resizable=yes, scrollbars=yes, left=100, top=100, ";if(e){attributes+="location=yes, menubar=yes, status=yes, toolbar=yes"}else{attributes+="location=no, menubar=no, status=no, toolbar=no"}var f=window.open(b,d,attributes);f.focus()}function b_togglebox(a,b){jQuery("#"+a).slideToggle(400,function(){var c=jQuery(b);c.toggleClass("b_togglebox_closed");c.toggleClass("b_togglebox_opened")})}function b_handleFileUploadFormChange(e,b,d){var f=e.value;slashPos=f.lastIndexOf("/");if(slashPos!=-1){f=f.substring(slashPos+1)}slashPos=f.lastIndexOf("\\");if(slashPos!=-1){f=f.substring(slashPos+1)}b.value=f;if(d){d.className="b_button b_button_dirty"}var c=e.form.elements;for(i=0;i<c.length;i++){var a=c[i];if(a.name==b.name&&i+1<c.length){c[i+1].focus()}}}function gotonode(a){try{if(typeof o_activateCourseNode!="undefined"){o_activateCourseNode(a)}else{if(opener&&typeof opener.o_activateCourseNode!="undefined"){opener.o_activateCourseNode(a)}else{if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in gotonode(), could not find main window","functions.js")}}}}catch(b){alert("Goto node error:"+b);if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Error in gotonode()::"+b.message,"functions.js")}}}function o_openUriInMainWindow(b){try{var a=o_getMainWin();a.focus();a.location.replace(b)}catch(c){showMessageBox("error","Error","Can not find main OpenOLAT window to open URL.")}}function b_viewportHeight(){var a=jQuery(document).height();if(a>0){return a}else{return 600}}OPOL.getMainColumnsMaxHeight=function(){var j=0,f=0,a=0,c=0,h=0,b,g=jQuery("#b_col1_content"),e=jQuery("#b_col2_content"),d=jQuery("#b_col3_content");if(g!="undefined"&&g!=null){j=g.height()}if(e!="undefined"&&e!=null){f=e.height()}if(d!="undefined"&&d!=null){a=d.height()}c=(j>f?j:f);c=(c>a?c:a);if(c>0){return c}b=jQuery("#b_main");if(b!="undefined"&&b!=null){h=b.height()}if(b>0){return b}return b_viewportHeight()};function b_resizeIframeToMainMaxHeight(f){var d=jQuery("#"+f);if(d!="undefined"&&d!=null){var c=OPOL.getMainColumnsMaxHeight();var b=b_viewportHeight()-100;var e=jQuery("#b_header");if(e!="undefined"&&e!=null){b=b-e.height()}e=jQuery("#b_nav");if(e!="undefined"&&e!=null){b=b-e.height()}e=jQuery("#b_footer");if(e!="undefined"&&e!=null){b=b-e.height()}var a=(b>c?b:c);d.height(a)}}var o_debu_oldcn,o_debu_oldtt;function o_debu_show(b,a){if(o_debu_oldcn){o_debu_hide(o_debu_oldcn,o_debu_oldtt)}jQuery(b).css("border","3px solid #00F").css("margin","0px").css("background-color","#FCFCB8");jQuery(a).show();o_debu_oldtt=a;o_debu_oldcn=b}function o_debu_hide(b,a){jQuery(a).hide();jQuery(b).css("border","1px dotted black").css("margin","2px").css("background-color","")}function o_dbg_mark(a){var b=jQuery("#"+a);if(b){b.css("background-color","#FCFCB8");b.css("border","3px solid #00F")}}function o_dbg_unmark(a){var b=jQuery("#"+a);if(b){b.css("border","");b.css("background-color","")}}function o_clearConsole(){o_log_all="";o_log(null)}var o_log_all="";function o_log(b){if(b){o_log_all="\n"+o_debug_trid+"> "+b+o_log_all;o_log_all=o_log_all.substr(0,4000)}var a=jQuery("#o_debug_cons");if(a){if(o_log_all.length==4000){o_log_all=o_log_all+"\n... (stripped: to long)... "}a.value=o_log_all}if(!jQuery.browser.IE&&!jQuery.type(window.console)==="undefined"){window.console.log(b)}}function o_logerr(a){o_log("ERROR:"+a)}function o_logwarn(a){o_log("WARN:"+a)}function showerror(c){var a="";for(var b in c){a+=b+": "+c[b]+"\n"}return"error detail:\n"+a}function o_ffEvent(e,d,c,h,j){var f,g,b,a;f=document.getElementById(d);g=f.value;f.value=c;b=document.getElementById(h);a=b.value;b.value=j;if(document.forms[e].onsubmit()){document.forms[e].submit()}f.value=g;b.value=a}function o_ffXHREvent(f,e,a,h,j){var c=new Object();c.dispatchuri=a;c.dispatchevent=j;if(arguments.length>5){var g=arguments.length;for(var d=5;d<g;d=d+2){if(g>d+1){c[arguments[d]]=arguments[d+1]}}}var b=jQuery("#"+f).attr("action");jQuery.ajax(b,{type:"GET",data:c,dataType:"json",success:function(n,o,m){o_ainvoke(n)},error:function(m,o,n){if(console){console.log("Error status",o)}}})}function setFlexiFormDirtyByListener(a){setFlexiFormDirty(a.data.formId)}function setFlexiFormDirty(b){var a=o3c.indexOf(b)>-1;if(!a){o3c.push(b)}jQuery("#"+b).each(function(){var c=jQuery(this).data("FlexiSubmit");if(c!=null){jQuery("#"+c).addClass("b_button b_button_dirty");o2c=1}})}function o_ffRegisterSubmit(b,a){jQuery("#"+b).data("FlexiSubmit",a)}function showInfoBox(f,c){var b=Math.floor(Math.random()*65536).toString(16);var e='<div id="'+b+'" class="b_msg-div msg" style="display:none;"><div class="b_msg_info_content b_msg_info_winicon o_sel_info_message"><h3>'+f+"</h3>"+c+"<br/><br/></div></div>";var a=jQuery("#b_page").prepend(e);var d=(c.length>150)?8000:((c.length>70)?6000:4000);jQuery("#"+b).slideDown(300).delay(d).slideUp(300);jQuery("#"+b).click(function(g){jQuery("#"+b).remove()});f=null;c=null;a=null;d=null}function showMessageBox(b,e,c,a){if(b=="info"){showInfoBox(e,c);return null}else{var d;if("warn"==b){d='<div><div class="b_msg_info_content b_msg_warn_winicon">'}else{if("error"==b){d='<div><div class="b_msg_info_content b_msg_error_winicon">'}else{d="<div><div>"}}return jQuery(d+"<p>"+c+"</p></div></div>").dialog({height:170,width:400,modal:true,title:e,resizable:false,close:function(f,g){try{jQuery(this).dialog("destroy").remove()}catch(h){}}}).dialog("open")}}function tableFormInjectCommandAndSubmit(a,b,c){document.forms[a].elements.cmd.value=b;document.forms[a].elements.param.value=c;document.forms[a].submit()}function b_table_toggleCheck(d,c){var a=document.forms[d].elements.tb_ms;len=a.length;if(typeof(len)=="undefined"){a.checked=c}else{var b;for(b=0;b<len;b++){a[b].checked=c}}}function onTreeStartDrag(a,b){jQuery(a.target).addClass("b_dd_proxy")}function onTreeStopDrag(a,b){jQuery(a.target).removeClass("b_dd_proxy")}function onTreeDrop(g,h){var a=jQuery(h.draggable[0]);var f=jQuery(this);f.css({position:"",width:""});var c=f.droppable("option","endUrl");if(c.lastIndexOf("/")==(c.length-1)){c=c.substring(0,c.length-1)}var e=a.attr("id");var b=e.substring(2,e.length);c+="%3Atnidle%3A"+b;var d=f.attr("id");if(d.indexOf("ds")==0){c+="%3Asne%3Ayes"}else{if(d.indexOf("dt")==0){c+="%3Asne%3Aend"}}frames.oaa0.location.href=c+"/"}function treeAcceptDrop(b){var c=jQuery(b);var e=c.attr("id");if(e!=undefined&&(e.indexOf("dd")==0||e.indexOf("ds")==0||e.indexOf("dt")==0||e.indexOf("da")==0||e.indexOf("row")==0)){var g=jQuery(this);var j=g.attr("id");var d=e.substring(2,e.length);var f=j.substring(2,j.length);if(d==f){return false}var h="";if(j.indexOf("ds")==0){h="yes"}else{if(j.indexOf("dt")==0){h="end"}}var m=g.data(d+"-"+h);if(m===undefined){var a=g.droppable("option","fbUrl");jQuery.ajax(a,{async:false,data:{nidle:d,tnidle:f,sne:h},dataType:"json",method:"GET",success:function(n){m=n.dropAllowed}});g.data(d+"-"+h,m)}return m}return false}function b_choice_toggleCheck(c,b){var d=document.forms[c].elements;len=d.length;if(typeof(len)=="undefined"){d.checked=b}else{var a;for(a=0;a<len;a++){if(d[a].type=="checkbox"&&d[a].getAttribute("class")=="b_checkbox"){d[a].checked=b}}}}function b_briefcase_isChecked(c,e){var b;var a=document.getElementById(c);var d=0;for(b=0;a.elements[b];b++){if(a.elements[b].type=="checkbox"&&a.elements[b].name=="paths"&&a.elements[b].checked){d++}}if(d<1){alert(e);return false}return true}function b_briefcase_toggleCheck(d,c){var a=document.getElementById(d);len=a.elements.length;var b;for(b=0;b<len;b++){if(a.elements[b].name=="paths"){a.elements[b].checked=c}}}function b_doPrint(){var d=jQuery("div.b_iframe_wrapper iframe");if(d.length>0){try{var a=d[0];frames[a.name].focus();frames[a.name].print();return}catch(c){for(i=0;frames.length>i;i++){a=frames[i];if(a.name=="oaa0"){continue}var b=document.getElementsByName(a.name)[0];if(b&&b.getAttribute("class")=="ext-shim"){continue}if(a.name!=""){try{frames[a.name].focus();frames[a.name].print()}catch(c){window.print()}return}}window.print()}}else{window.print()}}function b_attach_i18n_inline_editing(){jQuery("span.b_translation_i18nitem").hover(function(){jQuery(this.firstChild).show();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Entered i18nitem::"+this.firstChild,"functions.js:b_attach_i18n_inline_editing()")}},function(){jQuery("a.b_translation_i18nitem_launcher").hide();if(jQuery(document).ooLog().isDebugEnabled()){jQuery(document).ooLog("debug","Leaving i18nitem::"+this,"functions.js:b_attach_i18n_inline_editing()")}});jQuery("a.b_translation_i18nitem_launcher").hover(function(){var a=jQuery(this).parent("span.b_translation_i18nitem");a.effect("highlight")});b_AddOnDomReplacementFinishedCallback(b_attach_i18n_inline_editing)}var BDebugger={_lastDOMCount:0,_lastObjCount:0,_knownGlobalOLATObjects:["o_afterserver","o_onc","o_getMainWin","o_ainvoke","o_info","o_beforeserver","o_ffEvent","o_openPopUp","o_debu_show","o_logwarn","o_dbg_unmark","o_ffRegisterSubmit","o_clearConsole","o_init","o_log","o_allowNextClick","o_dbg_mark","o_debu_hide","o_logerr","o_debu_oldcn","o_debu_oldtt","o_openUriInMainWindow","o_debug_trid","o_log_all"],_countDOMElements:function(){return document.getElementsByTagName("*").length},_countGlobalObjects:function(){var a=0;for(prop in window){a++}return a},logDOMCount:function(){var b=BDebugger;var a=b._countDOMElements();var c=a-b._lastDOMCount;console.log((c>0?"+":"")+c+" \t"+a+" \tDOM element count after DOM replacement");b._lastDOMCount=a;a=null},logGlobalObjCount:function(){var b=BDebugger;var a=b._countGlobalObjects();var c=a-b._lastObjCount;console.log((c>0?"+":"")+c+" \t"+a+" \tGlobal object count after DOM replacement");b._lastObjCount=a;a=null},logGlobalOLATObjects:function(){var b=BDebugger;var a=new Array();for(prop in window){if(prop.indexOf("o_")==0&&b._knownGlobalOLATObjects.indexOf(prop)==-1){a.push(prop)}}if(a.length>0){console.log(a.length+" global OLAT objects found:");a.each(function(c){console.log("\t"+typeof window[c]+" \t"+c)})}},logManagedOLATObjects:function(){var a=BDebugger;if(o_info.objectMap.length>0){console.log(o_info.objectMap.length+" managed OLAT objects found:");o_info.objectMap.eachKey(function(b){var c=o_info.objectMap.get(b);console.log("\t"+typeof c+" \t"+b);return true})}}};var Hashtable=(function(){var p="function";var n=(typeof Array.prototype.splice==p)?function(s,r){s.splice(r,1)}:function(u,t){var s,v,r;if(t===u.length-1){u.length=t}else{s=u.slice(t+1);u.length=t;for(v=0,r=s.length;v<r;++v){u[t+v]=s[v]}}};function a(t){var r;if(typeof t=="string"){return t}else{if(typeof t.hashCode==p){r=t.hashCode();return(typeof r=="string")?r:a(r)}else{if(typeof t.toString==p){return t.toString()}else{try{return String(t)}catch(s){return Object.prototype.toString.call(t)}}}}}function g(r,s){return r.equals(s)}function e(r,s){return(typeof s.equals==p)?s.equals(r):(r===s)}function c(r){return function(s){if(s===null){throw new Error("null is not a valid "+r)}else{if(typeof s=="undefined"){throw new Error(r+" must not be undefined")}}}}var q=c("key"),l=c("value");function d(u,s,t,r){this[0]=u;this.entries=[];this.addEntry(s,t);if(r!==null){this.getEqualityFunction=function(){return r}}}var h=0,j=1,f=2;function o(r){return function(t){var s=this.entries.length,v,u=this.getEqualityFunction(t);while(s--){v=this.entries[s];if(u(t,v[0])){switch(r){case h:return true;case j:return v;case f:return[s,v[1]]}}}return false}}function k(r){return function(u){var v=u.length;for(var t=0,s=this.entries.length;t<s;++t){u[v+t]=this.entries[t][r]}}}d.prototype={getEqualityFunction:function(r){return(typeof r.equals==p)?g:e},getEntryForKey:o(j),getEntryAndIndexForKey:o(f),removeEntryForKey:function(s){var r=this.getEntryAndIndexForKey(s);if(r){n(this.entries,r[0]);return r[1]}return null},addEntry:function(r,s){this.entries[this.entries.length]=[r,s]},keys:k(0),values:k(1),getEntries:function(s){var u=s.length;for(var t=0,r=this.entries.length;t<r;++t){s[u+t]=this.entries[t].slice(0)}},containsKey:o(h),containsValue:function(s){var r=this.entries.length;while(r--){if(s===this.entries[r][1]){return true}}return false}};function m(s,t){var r=s.length,u;while(r--){u=s[r];if(t===u[0]){return r}}return null}function i(r,s){var t=r[s];return(t&&(t instanceof d))?t:null}function b(t,r){var w=this;var v=[];var u={};var x=(typeof t==p)?t:a;var s=(typeof r==p)?r:null;this.put=function(B,C){q(B);l(C);var D=x(B),E,A,z=null;E=i(u,D);if(E){A=E.getEntryForKey(B);if(A){z=A[1];A[1]=C}else{E.addEntry(B,C)}}else{E=new d(D,B,C,s);v[v.length]=E;u[D]=E}return z};this.get=function(A){q(A);var B=x(A);var C=i(u,B);if(C){var z=C.getEntryForKey(A);if(z){return z[1]}}return null};this.containsKey=function(A){q(A);var z=x(A);var B=i(u,z);return B?B.containsKey(A):false};this.containsValue=function(A){l(A);var z=v.length;while(z--){if(v[z].containsValue(A)){return true}}return false};this.clear=function(){v.length=0;u={}};this.isEmpty=function(){return !v.length};var y=function(z){return function(){var A=[],B=v.length;while(B--){v[B][z](A)}return A}};this.keys=y("keys");this.values=y("values");this.entries=y("getEntries");this.remove=function(B){q(B);var C=x(B),z,A=null;var D=i(u,C);if(D){A=D.removeEntryForKey(B);if(A!==null){if(!D.entries.length){z=m(v,C);n(v,z);delete u[C]}}}return A};this.size=function(){var A=0,z=v.length;while(z--){A+=v[z].entries.length}return A};this.each=function(C){var z=w.entries(),A=z.length,B;while(A--){B=z[A];C(B[0],B[1])}};this.putAll=function(H,C){var B=H.entries();var E,F,D,z,A=B.length;var G=(typeof C==p);while(A--){E=B[A];F=E[0];D=E[1];if(G&&(z=w.get(F))){D=C(F,z,D)}w.put(F,D)}};this.clone=function(){var z=new b(t,r);z.putAll(w);return z}}return b})();(function(b){b.fn.ooLog=function(f,d,e){var c=null;b(this).each(function(){c=b(this).data("_ooLog");if(c==undefined){c=new a();b(this).data("_ooLog",c)}});if(f==undefined){return c}else{if(typeof f==="string"){if(c){c.log(f,d,e)}}}};function a(){return this}a.prototype={isDebugEnabled:function(){return o_info.JSTracingLogDebugEnabled},log:function(e,c,d){if(!this.isDebugEnabled()){return}jQuery.post(o_info.JSTracingUri,{level:e,logMsg:c,jsFile:d})}}})(jQuery);(function(b){b.fn.ooTranslator=function(){var d=null;b(document).each(function(){d=b(document).data("_ooTranslator");if(d==undefined){d=new a();b(document).data("_ooTranslator",d)}});return d};function a(){return this}a.prototype={mapperUrl:null,translators:null,initialize:function(d){this.mapperUrl=d;this.translators=new Object()},getTranslator:function(d,f){if(this.translators[d]==null){this.translators[d]=new Object()}if(this.translators[d][f]==null){var e=this.mapperUrl+"/"+d+"/"+f+"/translations.js";jQuery.ajax(e,{async:false,dataType:"json",success:function(g,i,h){jQuery(document).ooTranslator()._createTranslator(g,d,f)}})}return this.translators[d][f]},_createTranslator:function(e,d,f){this.translators[d][f]=new c().initialize(e,d,f)}};function c(){return this}c.prototype={localizationData:null,bundle:null,locale:null,initialize:function(f,d,e){this.bundle=e;this.locale=d;this.localizationData=f;return this},translate:function(d){if(this.localizationData[d]){return this.localizationData[d]}else{return this.bundle+":"+d}}}})(jQuery);/*! * jQuery periodic plugin * * Copyright 2010, Tom Anderson diff --git a/src/main/webapp/static/js/tinymce/openolat/plugins/olatmovieviewer/olatmovieviewer.htm b/src/main/webapp/static/js/tinymce/openolat/plugins/olatmovieviewer/olatmovieviewer.htm index 72c558105c23e85a5fc0f68fd5178d8277e71c77..f943ea61a0c77ea91411eb744f1ef8bdc05936b9 100644 --- a/src/main/webapp/static/js/tinymce/openolat/plugins/olatmovieviewer/olatmovieviewer.htm +++ b/src/main/webapp/static/js/tinymce/openolat/plugins/olatmovieviewer/olatmovieviewer.htm @@ -1,15 +1,16 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> - <script type="text/javascript" src="../../org.olat.core.gui.components.form.flexible.impl.elements.richText/js/tinymce/tiny_mce_popup.js"></script> + <script type="text/javascript" src="../../../../jquery/jquery-1.9.1.min.js"></script> + <script type="text/javascript" src="../../../tinymce/tiny_mce_popup.js"></script> <script type="text/javascript" src="jscripts/helpers.js"></script> <script type="text/javascript" src="jscripts/movieviewer.js"></script> <link type="text/css" rel="stylesheet" href="css/editor.css"></link> - <script type="text/javascript" src="../../../../raw/_noversion_/movie/player.js"></script> - <script type="text/javascript" src="../../org.olat.core.gui.components.form.flexible.impl.elements.richText/js/tinymce/utils/mctabs.js"></script> - <script type="text/javascript" src="../../org.olat.core.gui.components.form.flexible.impl.elements.richText/js/tinymce/utils/validate.js"></script> - <script type="text/javascript" src="../../org.olat.core.gui.components.form.flexible.impl.elements.richText/js/tinymce/utils/form_utils.js"></script> - <script type="text/javascript" src="../../org.olat.core.gui.components.form.flexible.impl.elements.richText/js/tinymce/utils/editable_selects.js"></script> + <script type="text/javascript" src="../../../../../movie/player.js"></script> + <script type="text/javascript" src="../../../tinymce/utils/mctabs.js"></script> + <script type="text/javascript" src="../../../tinymce/utils/validate.js"></script> + <script type="text/javascript" src="../../../tinymce/utils/form_utils.js"></script> + <script type="text/javascript" src="../../../tinymce/utils/editable_selects.js"></script> <script type="text/javascript"> /* <![CDATA[ */ // Load the OLAT translator diff --git a/src/test/java/org/olat/modules/qpool/manager/LOMConverterTest.java b/src/test/java/org/olat/modules/qpool/manager/MetadataConverterHelperTest.java similarity index 68% rename from src/test/java/org/olat/modules/qpool/manager/LOMConverterTest.java rename to src/test/java/org/olat/modules/qpool/manager/MetadataConverterHelperTest.java index 767bee52b653fbccba98b87fda0feef991ce17b1..f465de96b92fbfdc52ef2c043d1735340a6e22aa 100644 --- a/src/test/java/org/olat/modules/qpool/manager/LOMConverterTest.java +++ b/src/test/java/org/olat/modules/qpool/manager/MetadataConverterHelperTest.java @@ -19,17 +19,22 @@ */ package org.olat.modules.qpool.manager; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URISyntaxException; +import java.util.Locale; import javax.xml.bind.JAXBException; import junit.framework.Assert; import org.junit.Test; +import org.olat.ims.qti.QTIConstants; +import org.olat.modules.qpool.QuestionItem; +import org.olat.modules.qpool.QuestionType; import org.olat.modules.qpool.model.LOMDuration; -import org.olat.modules.qpool.model.QuestionItemImpl; +import org.olat.modules.qpool.model.QItemType; +import org.olat.test.OlatTestCase; +import org.springframework.beans.factory.annotation.Autowired; /** * @@ -37,31 +42,21 @@ import org.olat.modules.qpool.model.QuestionItemImpl; * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ -public class LOMConverterTest { - - @Test - public void itemToLom() - throws IOException, URISyntaxException, JAXBException { - QuestionItemImpl item = new QuestionItemImpl(); - item.setTitle("Psychologie"); - item.setDescription("Description psychologique"); - item.setLanguage("fr"); - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - new LOMConverter().toLom(item, out); - out.close(); - System.out.println("LOM: " + new String(out.toByteArray())); - } - +public class MetadataConverterHelperTest extends OlatTestCase { + + @Autowired + private QItemTypeDAO qItemTypeDao; + @Autowired + private QuestionItemDAO questionDao; @Test public void convertDuration_toString() throws IOException, URISyntaxException, JAXBException { //1h 30m - String duration1 = LOMConverter.convertDuration(0, 1, 30, 0); + String duration1 = MetadataConverterHelper.convertDuration(0, 1, 30, 0); Assert.assertEquals("PT1H30M", duration1); //1m 45s - String duration2 = LOMConverter.convertDuration(0, 0, 1, 45); + String duration2 = MetadataConverterHelper.convertDuration(0, 0, 1, 45); Assert.assertEquals("PT1M45S", duration2); } @@ -69,7 +64,7 @@ public class LOMConverterTest { public void convertDuration_toDuration() throws IOException, URISyntaxException, JAXBException { //1h 30m - LOMDuration duration1 = LOMConverter.convertDuration("PT1H30M"); + LOMDuration duration1 = MetadataConverterHelper.convertDuration("PT1H30M"); Assert.assertEquals(0, duration1.getYear()); Assert.assertEquals(0, duration1.getMonth()); Assert.assertEquals(0, duration1.getDay()); @@ -78,7 +73,7 @@ public class LOMConverterTest { Assert.assertEquals(0, duration1.getSeconds()); //1m 45s - LOMDuration duration2 = LOMConverter.convertDuration("PT1M45S"); + LOMDuration duration2 = MetadataConverterHelper.convertDuration("PT1M45S"); Assert.assertEquals(0, duration2.getYear()); Assert.assertEquals(0, duration2.getMonth()); Assert.assertEquals(0, duration2.getDay()); @@ -87,7 +82,7 @@ public class LOMConverterTest { Assert.assertEquals(45, duration2.getSeconds()); //2y 3 month and 4h 1minute 35s - LOMDuration duration3 = LOMConverter.convertDuration("P2Y3MT4H1M35S"); + LOMDuration duration3 = MetadataConverterHelper.convertDuration("P2Y3MT4H1M35S"); Assert.assertEquals(2, duration3.getYear()); Assert.assertEquals(3, duration3.getMonth()); Assert.assertEquals(0, duration3.getDay()); @@ -95,4 +90,14 @@ public class LOMConverterTest { Assert.assertEquals(1, duration3.getMinute()); Assert.assertEquals(35, duration3.getSeconds()); } + + @Test + public void serializeQuestionItem() { + + QItemType fibType = qItemTypeDao.loadByType(QuestionType.FIB.name()); + QuestionItem item = questionDao.createAndPersist(null, "Stars", QTIConstants.QTI_12_FORMAT, Locale.ENGLISH.getLanguage(), null, null, null, fibType); + + + + } } \ No newline at end of file diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index 3c7ccb9b92a98e91bfad4b5af6ae819cae5c715b..5981106fa3091b44d10712eb13730e4b13708104 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -122,7 +122,7 @@ import org.junit.runners.Suite; org.olat.ims.qti.qpool.QTIImportProcessorTest.class, org.olat.ims.qti.qpool.QTIExportProcessorTest.class, org.olat.modules.webFeed.FeedManagerImplTest.class, - org.olat.modules.qpool.manager.LOMConverterTest.class, + org.olat.modules.qpool.manager.MetadataConverterHelperTest.class, org.olat.modules.qpool.manager.QuestionDAOTest.class, org.olat.modules.qpool.manager.FileStorageTest.class, org.olat.modules.qpool.manager.CollectionDAOTest.class,