Skip to content
Snippets Groups Projects
Commit 8d50e544 authored by srosse's avatar srosse
Browse files

Merge remote-tracking branch 'origin/OpenOLAT_14.1'

parents 6e8537e5 c965a154
No related branches found
No related tags found
No related merge requests found
Showing
with 110 additions and 257 deletions
...@@ -91,6 +91,11 @@ public class QTI12EditorController extends BasicController implements QPoolItemE ...@@ -91,6 +91,11 @@ public class QTI12EditorController extends BasicController implements QPoolItemE
putInitialPanel(mainVC); putInitialPanel(mainVC);
} }
@Override
public boolean isValid() {
return item != null;
}
@Override @Override
public QuestionItem getItem() { public QuestionItem getItem() {
return qitem; return qitem;
......
...@@ -30,6 +30,7 @@ import java.util.zip.ZipOutputStream; ...@@ -30,6 +30,7 @@ import java.util.zip.ZipOutputStream;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import org.apache.logging.log4j.Logger;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.Element; import org.dom4j.Element;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
...@@ -41,7 +42,6 @@ import org.olat.core.gui.translator.Translator; ...@@ -41,7 +42,6 @@ import org.olat.core.gui.translator.Translator;
import org.olat.core.helpers.Settings; import org.olat.core.helpers.Settings;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.FileUtils; import org.olat.core.util.FileUtils;
import org.olat.core.util.Util; import org.olat.core.util.Util;
...@@ -69,6 +69,7 @@ import org.olat.ims.resources.IMSEntityResolver; ...@@ -69,6 +69,7 @@ import org.olat.ims.resources.IMSEntityResolver;
import org.olat.modules.qpool.ExportFormatOptions; import org.olat.modules.qpool.ExportFormatOptions;
import org.olat.modules.qpool.ExportFormatOptions.Outcome; import org.olat.modules.qpool.ExportFormatOptions.Outcome;
import org.olat.modules.qpool.QItemFactory; import org.olat.modules.qpool.QItemFactory;
import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolSPI;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionItem;
...@@ -381,7 +382,7 @@ public class QTIQPoolServiceProvider implements QPoolSPI { ...@@ -381,7 +382,7 @@ public class QTIQPoolServiceProvider implements QPoolSPI {
} }
@Override @Override
public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) {
return new QTI12EditorController(ureq, wControl, item); return new QTI12EditorController(ureq, wControl, item);
} }
......
...@@ -88,6 +88,11 @@ public class QTI21EditorController extends BasicController implements QPoolItemE ...@@ -88,6 +88,11 @@ public class QTI21EditorController extends BasicController implements QPoolItemE
putInitialPanel(mainVC); putInitialPanel(mainVC);
} }
@Override
public boolean isValid() {
return true;
}
@Override @Override
public QuestionItem getItem() { public QuestionItem getItem() {
return questionItem; return questionItem;
......
...@@ -39,13 +39,13 @@ import java.util.zip.ZipOutputStream; ...@@ -39,13 +39,13 @@ import java.util.zip.ZipOutputStream;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import org.apache.logging.log4j.Logger;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.media.MediaResource; import org.olat.core.gui.media.MediaResource;
import org.olat.core.helpers.Settings; import org.olat.core.helpers.Settings;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.FileUtils; import org.olat.core.util.FileUtils;
import org.olat.core.util.StringHelper; import org.olat.core.util.StringHelper;
...@@ -76,6 +76,7 @@ import org.olat.imscp.xml.manifest.ResourceType; ...@@ -76,6 +76,7 @@ import org.olat.imscp.xml.manifest.ResourceType;
import org.olat.modules.qpool.ExportFormatOptions; import org.olat.modules.qpool.ExportFormatOptions;
import org.olat.modules.qpool.ExportFormatOptions.Outcome; import org.olat.modules.qpool.ExportFormatOptions.Outcome;
import org.olat.modules.qpool.QItemFactory; import org.olat.modules.qpool.QItemFactory;
import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolSPI;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionItem;
...@@ -321,7 +322,7 @@ public class QTI21QPoolServiceProvider implements QPoolSPI { ...@@ -321,7 +322,7 @@ public class QTI21QPoolServiceProvider implements QPoolSPI {
} }
@Override @Override
public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) { public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) {
return new QTI21EditorController(ureq, wControl, qitem, false); return new QTI21EditorController(ureq, wControl, qitem, false);
} }
...@@ -329,7 +330,6 @@ public class QTI21QPoolServiceProvider implements QPoolSPI { ...@@ -329,7 +330,6 @@ public class QTI21QPoolServiceProvider implements QPoolSPI {
public Controller getReadOnlyController(UserRequest ureq, WindowControl wControl, QuestionItem item) { public Controller getReadOnlyController(UserRequest ureq, WindowControl wControl, QuestionItem item) {
return new QTI21EditorController(ureq, wControl, item, true); return new QTI21EditorController(ureq, wControl, item, true);
} }
public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) { public QuestionItem createItem(Identity identity, QTI21QuestionType type, String title, Locale locale) {
AssessmentItemBuilder itemBuilder = AssessmentItemBuilderFactory.get(type, locale); AssessmentItemBuilder itemBuilder = AssessmentItemBuilderFactory.get(type, locale);
......
...@@ -103,7 +103,7 @@ drawing.opacity=Opacit\u00E9 ...@@ -103,7 +103,7 @@ drawing.opacity=Opacit\u00E9
error.as.directed=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9. error.as.directed=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9.
error.as.directed.kprim=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9. error.as.directed.kprim=Veuillez r\u00E9pondre \u00E0 la question comme indiqu\u00E9.
error.assessment.item=Le fichier n'a pas pu \u00EAtre lu. Il semble soit corrompu soit au mauvais format. error.assessment.item=Le fichier n'a pas pu \u00EAtre lu. Il semble soit corrompu soit au mauvais format.
error.assessment.item.missing=Le fichier de la question n'a pas \u00EAtre d\u00E9chiffr\u00E9. error.assessment.item.missing=Le fichier de la question n'a pas \u00EAtre lu.
error.choice=Vous devez choisir une des options suivantes. error.choice=Vous devez choisir une des options suivantes.
error.digital.certificate.cannotread=Le certificat n'a pas pu \u00EAtre lu. error.digital.certificate.cannotread=Le certificat n'a pas pu \u00EAtre lu.
error.digital.certificate.noPrivateKey=La "cl\u00E9 priv\u00E9e" n'a pas \u00E9t\u00E9 trouv\u00E9e. Elle est obligatoire. error.digital.certificate.noPrivateKey=La "cl\u00E9 priv\u00E9e" n'a pas \u00E9t\u00E9 trouv\u00E9e. Elle est obligatoire.
......
...@@ -30,5 +30,7 @@ import org.olat.core.gui.control.Controller; ...@@ -30,5 +30,7 @@ import org.olat.core.gui.control.Controller;
public interface QPoolItemEditorController extends Controller { public interface QPoolItemEditorController extends Controller {
public QuestionItem getItem(); public QuestionItem getItem();
public boolean isValid();
} }
...@@ -124,7 +124,7 @@ public interface QPoolSPI { ...@@ -124,7 +124,7 @@ public interface QPoolSPI {
* @param item * @param item
* @return * @return
*/ */
public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item); public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item);
/** /**
* Return the editable controller in a read only modus. This controller is e.g. * Return the editable controller in a read only modus. This controller is e.g.
......
...@@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest; ...@@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.modules.qpool.QItemFactory; import org.olat.modules.qpool.QItemFactory;
import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionItem;
import org.olat.modules.qpool.QuestionType; import org.olat.modules.qpool.QuestionType;
...@@ -86,8 +87,7 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider { ...@@ -86,8 +87,7 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider {
@Override @Override
public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) { public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) {
FilePreviewController fileController = new FilePreviewController(ureq, wControl, item); return new FilePreviewController(ureq, wControl, item);
return fileController;
} }
@Override @Override
...@@ -96,9 +96,8 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider { ...@@ -96,9 +96,8 @@ public class FileQPoolServiceProvider extends AbstractQPoolServiceProvider {
} }
@Override @Override
public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) {
FilePreviewController fileController = new FilePreviewController(ureq, wControl, item); return new FilePreviewController(ureq, wControl, item);
return fileController;
} }
@Override @Override
......
...@@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest; ...@@ -27,6 +27,7 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.modules.qpool.QItemFactory; import org.olat.modules.qpool.QItemFactory;
import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QuestionItem;
import org.olat.modules.qpool.QuestionType; import org.olat.modules.qpool.QuestionType;
...@@ -84,8 +85,7 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider { ...@@ -84,8 +85,7 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider {
@Override @Override
public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) { public Controller getPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem item, boolean summary) {
TextPreviewController txtController = new TextPreviewController(ureq, wControl, item, summary); return new TextPreviewController(ureq, wControl, item, summary);
return txtController;
} }
@Override @Override
...@@ -94,9 +94,8 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider { ...@@ -94,9 +94,8 @@ public class TextQPoolServiceProvider extends AbstractQPoolServiceProvider {
} }
@Override @Override
public Controller getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) { public QPoolItemEditorController getEditableController(UserRequest ureq, WindowControl wControl, QuestionItem item) {
TextPreviewController txtController = new TextPreviewController(ureq, wControl, item, false); return new TextPreviewController(ureq, wControl, item, false);
return txtController;
} }
@Override @Override
......
...@@ -27,8 +27,9 @@ import org.olat.core.gui.control.Event; ...@@ -27,8 +27,9 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.vfs.VFSLeaf; import org.olat.core.util.vfs.VFSLeaf;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem;
/** /**
* *
...@@ -36,12 +37,15 @@ import org.olat.modules.qpool.QPoolService; ...@@ -36,12 +37,15 @@ import org.olat.modules.qpool.QPoolService;
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
* *
*/ */
public class FilePreviewController extends BasicController { public class FilePreviewController extends BasicController implements QPoolItemEditorController {
private final VelocityContainer mainVC; private final VelocityContainer mainVC;
private final QuestionItem qitem;
public FilePreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) { public FilePreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem) {
super(ureq, wControl); super(ureq, wControl);
this.qitem = qitem;
QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class); QPoolService qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
mainVC = createVelocityContainer("file_preview"); mainVC = createVelocityContainer("file_preview");
...@@ -53,6 +57,16 @@ public class FilePreviewController extends BasicController { ...@@ -53,6 +57,16 @@ public class FilePreviewController extends BasicController {
putInitialPanel(mainVC); putInitialPanel(mainVC);
} }
@Override
public QuestionItem getItem() {
return qitem;
}
@Override
public boolean isValid() {
return true;
}
@Override @Override
protected void doDispose() { protected void doDispose() {
// //
......
...@@ -54,6 +54,7 @@ import org.olat.group.model.BusinessGroupSelectionEvent; ...@@ -54,6 +54,7 @@ import org.olat.group.model.BusinessGroupSelectionEvent;
import org.olat.group.ui.main.SelectBusinessGroupController; import org.olat.group.ui.main.SelectBusinessGroupController;
import org.olat.ims.qti.QTIConstants; import org.olat.ims.qti.QTIConstants;
import org.olat.modules.qpool.Pool; import org.olat.modules.qpool.Pool;
import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolSPI; import org.olat.modules.qpool.QPoolSPI;
import org.olat.modules.qpool.QPoolSecurityCallback; import org.olat.modules.qpool.QPoolSecurityCallback;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
...@@ -132,6 +133,7 @@ public class QuestionItemDetailsController extends BasicController implements To ...@@ -132,6 +133,7 @@ public class QuestionItemDetailsController extends BasicController implements To
private final int numberOfItems; private final int numberOfItems;
private Boolean showMetadatas; private Boolean showMetadatas;
private LockResult lock; private LockResult lock;
private boolean valid = true;
private boolean questionEdited = false; private boolean questionEdited = false;
@Autowired @Autowired
...@@ -195,9 +197,12 @@ public class QuestionItemDetailsController extends BasicController implements To ...@@ -195,9 +197,12 @@ public class QuestionItemDetailsController extends BasicController implements To
showWarning("locked.readonly", new String[] {displayName}); showWarning("locked.readonly", new String[] {displayName});
} }
if (spi != null) { if (spi != null) {
if (canEditContent) { if (canEditContent) {
questionCtrl = spi.getEditableController(ureq, getWindowControl(), item); QPoolItemEditorController editQuestionCtrl = spi.getEditableController(ureq, getWindowControl(), item);
valid = editQuestionCtrl.isValid();
questionCtrl = editQuestionCtrl;
} else { } else {
questionCtrl = spi.getReadOnlyController(ureq, getWindowControl(), item); questionCtrl = spi.getReadOnlyController(ureq, getWindowControl(), item);
} }
...@@ -211,7 +216,11 @@ public class QuestionItemDetailsController extends BasicController implements To ...@@ -211,7 +216,11 @@ public class QuestionItemDetailsController extends BasicController implements To
listenTo(questionCtrl); listenTo(questionCtrl);
if(mainVC != null) { if(mainVC != null) {
mainVC.put("type_specifics", questionCtrl.getInitialComponent()); if(valid) {
mainVC.put("type_specifics", questionCtrl.getInitialComponent());
} else {
mainVC.contextPut("corrupted", Boolean.TRUE);
}
} }
} }
...@@ -247,7 +256,7 @@ public class QuestionItemDetailsController extends BasicController implements To ...@@ -247,7 +256,7 @@ public class QuestionItemDetailsController extends BasicController implements To
copyItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_copy"); copyItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_copy");
commandDropdown.addComponent(copyItemLink); commandDropdown.addComponent(copyItemLink);
if (QTIConstants.QTI_12_FORMAT.equals(metadatasCtrl.getItem().getFormat())) { if (QTIConstants.QTI_12_FORMAT.equals(metadatasCtrl.getItem().getFormat()) && valid) {
convertItemLink = LinkFactory.createToolLink("convert", translate("convert.item"), this); convertItemLink = LinkFactory.createToolLink("convert", translate("convert.item"), this);
convertItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_convert"); convertItemLink.setIconLeftCSS("o_icon o_icon-fw o_icon_qitem_convert");
commandDropdown.addComponent(convertItemLink); commandDropdown.addComponent(convertItemLink);
......
...@@ -23,8 +23,6 @@ import java.io.InputStream; ...@@ -23,8 +23,6 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.StringWriter; import java.io.StringWriter;
import org.apache.commons.io.IOUtils;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.velocity.VelocityContainer; import org.olat.core.gui.components.velocity.VelocityContainer;
...@@ -32,8 +30,10 @@ import org.olat.core.gui.control.Event; ...@@ -32,8 +30,10 @@ import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController; import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.util.vfs.VFSLeaf; import org.olat.core.util.vfs.VFSLeaf;
import org.olat.modules.qpool.QuestionItem; import org.olat.modules.qpool.QPoolItemEditorController;
import org.olat.modules.qpool.QPoolService; import org.olat.modules.qpool.QPoolService;
import org.olat.modules.qpool.QuestionItem;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* *
...@@ -41,14 +41,15 @@ import org.olat.modules.qpool.QPoolService; ...@@ -41,14 +41,15 @@ import org.olat.modules.qpool.QPoolService;
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
* *
*/ */
public class TextPreviewController extends BasicController { public class TextPreviewController extends BasicController implements QPoolItemEditorController {
private final VelocityContainer mainVC; private final VelocityContainer mainVC;
private final QPoolService qpoolService;
@Autowired
private QPoolService qpoolService;
public TextPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem, boolean summary) { public TextPreviewController(UserRequest ureq, WindowControl wControl, QuestionItem qitem, boolean summary) {
super(ureq, wControl); super(ureq, wControl);
qpoolService = CoreSpringFactory.getImpl(QPoolService.class);
mainVC = createVelocityContainer("text_preview"); mainVC = createVelocityContainer("text_preview");
VFSLeaf leaf = qpoolService.getRootLeaf(qitem); VFSLeaf leaf = qpoolService.getRootLeaf(qitem);
...@@ -64,34 +65,41 @@ public class TextPreviewController extends BasicController { ...@@ -64,34 +65,41 @@ public class TextPreviewController extends BasicController {
putInitialPanel(mainVC); putInitialPanel(mainVC);
} }
@Override
public QuestionItem getItem() {
return null;
}
@Override
public boolean isValid() {
return true;
}
@Override @Override
protected void doDispose() { protected void doDispose() {
// //
} }
protected String readSummary(VFSLeaf leaf) { protected String readSummary(VFSLeaf leaf) {
StringWriter out = new StringWriter(); StringWriter out = new StringWriter();
InputStream in = leaf.getInputStream();
InputStreamReader inr = new InputStreamReader(in); try( InputStream in = leaf.getInputStream();
try { InputStreamReader inr = new InputStreamReader(in)) {
char[] buffer = new char[4096]; char[] buffer = new char[4096];
int count = 0; int count = 0;
int n = 0; int n = 0;
while (-1 != (n = inr.read(buffer))) { while (-1 != (n = inr.read(buffer))) {
out.write(buffer, 0, n); out.write(buffer, 0, n);
count += n; count += n;
if(count >= 10000) { if(count >= 10000) {
break; break;
} }
} }
} catch (Exception e) { } catch (Exception e) {
logError("", e); logError("", e);
} finally {
IOUtils.closeQuietly(inr);
IOUtils.closeQuietly(in);
} }
return out.toString(); return out.toString();
} }
@Override @Override
......
...@@ -13,7 +13,11 @@ ...@@ -13,7 +13,11 @@
<div class="row"> <div class="row">
#if($metadataSwitch) #if($metadataSwitch)
<div class="col-md-8"> <div class="col-md-8">
$r.render("type_specifics") #if($r.isTrue($corrupted))
<div class="o_error">$r.translate("error.corrupted.question")</div>
#elseif($r.available("type_specifics"))
$r.render("type_specifics")
#end
$r.render("comments") $r.render("comments")
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
...@@ -21,7 +25,11 @@ ...@@ -21,7 +25,11 @@
</div> </div>
#else #else
<div class="col-md-12"> <div class="col-md-12">
$r.render("type_specifics") #if($r.isTrue($corrupted))
<div class="o_error">$r.translate("error.corrupted.question")</div>
#elseif($r.available("type_specifics"))
$r.render("type_specifics")
#end
$r.render("comments") $r.render("comments")
</div> </div>
#end #end
......
...@@ -60,6 +60,7 @@ educational.learningTime.day=d ...@@ -60,6 +60,7 @@ educational.learningTime.day=d
educational.learningTime.hour=h educational.learningTime.hour=h
educational.learningTime.minute=m educational.learningTime.minute=m
educational.learningTime.second=s educational.learningTime.second=s
error.corrupted.question=Die Datei der Frage konnte nicht gelesen werden.
error.input.toolong=Leider ist Ihr gerade eingegebener Text mit {1} Zeichen zu lang. Bitte beschr\u00E4nken Sie sich auf maximal {0} Zeichen. error.input.toolong=Leider ist Ihr gerade eingegebener Text mit {1} Zeichen zu lang. Bitte beschr\u00E4nken Sie sich auf maximal {0} Zeichen.
error.qti.deprecated=Diese Version von QTI wird nicht mehr unterst\u00FCtzt. Bitte auf das neue QTI 2.1 konvertieren. error.qti.deprecated=Diese Version von QTI wird nicht mehr unterst\u00FCtzt. Bitte auf das neue QTI 2.1 konvertieren.
error.select.one=Sie m\u00FCssen mindestens eine Frage w\u00E4hlen. error.select.one=Sie m\u00FCssen mindestens eine Frage w\u00E4hlen.
......
...@@ -60,6 +60,7 @@ educational.learningTime.day=d ...@@ -60,6 +60,7 @@ educational.learningTime.day=d
educational.learningTime.hour=h educational.learningTime.hour=h
educational.learningTime.minute=m educational.learningTime.minute=m
educational.learningTime.second=s educational.learningTime.second=s
error.corrupted.question=The file of the question cannot be read.
error.input.toolong=The text you entered is to long ({1} characters). Only {1} characters are allowed. error.input.toolong=The text you entered is to long ({1} characters). Only {1} characters are allowed.
error.qti.deprecated=This version of QTI is deprecated. Please consider to convert your test to QTI 2.1. error.qti.deprecated=This version of QTI is deprecated. Please consider to convert your test to QTI 2.1.
error.select.one=You need to select at least one question. error.select.one=You need to select at least one question.
......
...@@ -60,6 +60,7 @@ educational.learningTime.day=j ...@@ -60,6 +60,7 @@ educational.learningTime.day=j
educational.learningTime.hour=h educational.learningTime.hour=h
educational.learningTime.minute=m educational.learningTime.minute=m
educational.learningTime.second=s educational.learningTime.second=s
error.corrupted.question=Le fichier de la question n'a pas \u00EAtre lu.
error.input.toolong=Le texte que vous avez entr\u00E9 est trop long ({1} caract\u00E8res). Limitez-vous s'il vous pla\u00EEt \u00E0 {1} caract\u00E8res. error.input.toolong=Le texte que vous avez entr\u00E9 est trop long ({1} caract\u00E8res). Limitez-vous s'il vous pla\u00EEt \u00E0 {1} caract\u00E8res.
error.qti.deprecated=Cette version de QTI est obsol\u00E8te. Pensez s'il vous pla\u00EEt \u00E0 convertir votre test au format QTI 2.1. error.qti.deprecated=Cette version de QTI est obsol\u00E8te. Pensez s'il vous pla\u00EEt \u00E0 convertir votre test au format QTI 2.1.
error.select.one=Vous devez s\u00E9lectionner au moins une question. error.select.one=Vous devez s\u00E9lectionner au moins une question.
......
...@@ -61,6 +61,7 @@ educational.learningTime.day=d ...@@ -61,6 +61,7 @@ educational.learningTime.day=d
educational.learningTime.hour=h educational.learningTime.hour=h
educational.learningTime.minute=m educational.learningTime.minute=m
educational.learningTime.second=s educational.learningTime.second=s
error.corrupted.question=O arquivo da pergunta n\u00E3o pode ser lido.
error.input.toolong=O texto que voc\u00EA digitou \u00E9 muito grande ({1} caracteres). Apenas {1} caracteres s\u00E3o permitidos. error.input.toolong=O texto que voc\u00EA digitou \u00E9 muito grande ({1} caracteres). Apenas {1} caracteres s\u00E3o permitidos.
error.qti.deprecated=Esta vers\u00E3o do QTI est\u00E1 obsoleta. Por favor, considere converter seu teste para o QTI 2.1. error.qti.deprecated=Esta vers\u00E3o do QTI est\u00E1 obsoleta. Por favor, considere converter seu teste para o QTI 2.1.
error.select.one=Voc\u00EA precisa selecionar pelo menos uma quest\u00E3o. error.select.one=Voc\u00EA precisa selecionar pelo menos uma quest\u00E3o.
......
...@@ -28,7 +28,6 @@ import java.util.Date; ...@@ -28,7 +28,6 @@ import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
...@@ -40,7 +39,6 @@ import net.fortuna.ical4j.model.Period; ...@@ -40,7 +39,6 @@ import net.fortuna.ical4j.model.Period;
import net.fortuna.ical4j.model.PeriodList; import net.fortuna.ical4j.model.PeriodList;
import net.fortuna.ical4j.model.component.VEvent; import net.fortuna.ical4j.model.component.VEvent;
import net.fortuna.ical4j.model.property.RecurrenceId; import net.fortuna.ical4j.model.property.RecurrenceId;
import net.fortuna.ical4j.util.CompatibilityHints;
/** /**
* *
...@@ -104,9 +102,8 @@ public class CalendarImportTest { ...@@ -104,9 +102,8 @@ public class CalendarImportTest {
Calendar calendar = builder.build(in); Calendar calendar = builder.build(in);
assertNotNull(calendar); assertNotNull(calendar);
} }
*/
@Test
@Test @Ignore
public void testImportFromFGiCal() throws IOException, ParserException { public void testImportFromFGiCal() throws IOException, ParserException {
//default settings in olat //default settings in olat
System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true"); System.setProperty(CompatibilityHints.KEY_RELAXED_UNFOLDING, "true");
...@@ -117,6 +114,7 @@ public class CalendarImportTest { ...@@ -117,6 +114,7 @@ public class CalendarImportTest {
Calendar calendar = builder.build(in); Calendar calendar = builder.build(in);
assertNotNull(calendar); assertNotNull(calendar);
} }
*/
@Test @Test
public void testImportRecurringCal() throws IOException, ParserException { public void testImportRecurringCal() throws IOException, ParserException {
......
...@@ -43,7 +43,6 @@ import java.util.regex.Pattern; ...@@ -43,7 +43,6 @@ import java.util.regex.Pattern;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.olat.core.gui.render.StringOutput; import org.olat.core.gui.render.StringOutput;
import org.olat.core.gui.render.URLBuilder; import org.olat.core.gui.render.URLBuilder;
...@@ -469,73 +468,11 @@ public class I18nTest extends OlatTestCase { ...@@ -469,73 +468,11 @@ public class I18nTest extends OlatTestCase {
} }
} }
/**
* Test methods i18nManager.getProperties(), i18nManager.saveOrUpdateProperties() and i18nManager.deleteProperties()
*/
@Ignore
@Test public void testGetSaveOrUpdateAndDeleteProperties() {
// test with existing files
Properties props = i18nMgr.getResolvedProperties(i18nMgr.getLocaleOrDefault("de"), "org.olat.core");
assertNotNull(props);
assertTrue(props.size() > 0);
// test with non existing files
String testNewBundle = "org.olat.core.util.i18n.junittestdata.new";
Locale testLocale = i18nMgr.getLocaleOrDefault("de");
File baseDir = i18nModule.getPropertyFilesBaseDir(testLocale, testNewBundle);
File testFile = i18nMgr.getPropertiesFile(testLocale, testNewBundle, baseDir);
// clean first existing files from previous broken testcase
if (testFile.exists()) {
i18nMgr.deleteProperties(testLocale, testNewBundle);
}
props = i18nMgr.getResolvedProperties(testLocale, testNewBundle);
assertNotNull(props);
assertEquals(0, props.size());
// test deleting of non existing
assertFalse(testFile.exists());
i18nMgr.deleteProperties(testLocale, testNewBundle);
assertFalse(testFile.exists());
// test saving of non existing
props.setProperty("test.key", "Hello wörld !");
i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle);
assertTrue(testFile.exists());
assertEquals("Hello wörld !", i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false));
// test saving of existing
props = new Properties();
props.setProperty("hello.world", "&%çest françias, ê alors");
i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle);
assertTrue(testFile.exists());
assertEquals("&%çest françias, ê alors", i18nMgr.getLocalizedString(testNewBundle, "hello.world", null, testLocale, false, false));
assertFalse("Hello wörld !".equals(i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false)));
// test various special cases
props.setProperty("chinesetest", "请选择你的大学");
props.setProperty("specialtest", "that's like \"really\" bad");
props.setProperty("multiline", "bla\tbla\nsecond line");
props.setProperty("html", "<h1>Hello World</h1>");
props.setProperty("empty.property", "");
i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle);
i18nMgr.clearCaches();
assertEquals("请选择你的大学", i18nMgr.getLocalizedString(testNewBundle, "chinesetest", null, testLocale, false, false));
assertEquals("that's like \"really\" bad", i18nMgr.getLocalizedString(testNewBundle, "specialtest", null, testLocale, false, false));
assertEquals("bla\tbla\nsecond line", i18nMgr.getLocalizedString(testNewBundle, "multiline", null, testLocale, false, false));
assertEquals("<h1>Hello World</h1>", i18nMgr.getLocalizedString(testNewBundle, "html", null, testLocale, false, false));
assertEquals("", i18nMgr.getLocalizedString(testNewBundle, "empty.property", null, testLocale, false, false));
assertEquals(null, i18nMgr.getLocalizedString(testNewBundle, "not.existing.property", null, testLocale, false, false));
// test deleting of existing
i18nMgr.deleteProperties(testLocale, testNewBundle);
assertFalse(testFile.exists());
assertFalse("Hello wörld !".equals(i18nMgr.getLocalizedString(testNewBundle, "test.key", null, testLocale, false, false)));
assertFalse("&%çest françias, ê alors".equals(i18nMgr.getLocalizedString(testNewBundle, "hello.world", null, testLocale, false, false)));
// clean up
if (testFile.exists()) {
i18nMgr.deleteProperties(testLocale, testNewBundle);
}
if (testFile.getParentFile().exists()) testFile.getParentFile().delete();
}
/** /**
* Test methods i18nManager.getBundlePriority(), i18nManager.getKeyPriority() * Test methods i18nManager.getBundlePriority(), i18nManager.getKeyPriority()
*/ */
@Test public void testGetBundleAndKeyPriority() { @Test
public void testGetBundleAndKeyPriority() {
// existing bundle prios // existing bundle prios
String bundleName = "org.olat.core.util.i18n.junittestdata"; String bundleName = "org.olat.core.util.i18n.junittestdata";
Properties metadataProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(null, bundleName); Properties metadataProperties = i18nMgr.getPropertiesWithoutResolvingRecursively(null, bundleName);
...@@ -555,7 +492,8 @@ public class I18nTest extends OlatTestCase { ...@@ -555,7 +492,8 @@ public class I18nTest extends OlatTestCase {
/** /**
* Test methods i18nManager.getAnnotation() * Test methods i18nManager.getAnnotation()
*/ */
@Test public void testGetAnnotation() { @Test
public void testGetAnnotation() {
// existing bundle prios // existing bundle prios
String bundleName = "org.olat.core.util.i18n.junittestdata"; String bundleName = "org.olat.core.util.i18n.junittestdata";
Locale testLocale = i18nMgr.getLocaleOrDefault("de"); Locale testLocale = i18nMgr.getLocaleOrDefault("de");
...@@ -569,61 +507,12 @@ public class I18nTest extends OlatTestCase { ...@@ -569,61 +507,12 @@ public class I18nTest extends OlatTestCase {
} }
} }
} }
/**
* Test methods i18nManager.countI18nItems() and i18nManager.countBundles()
*/
@Ignore
@Test public void testCountI18nItemsAndBundles() {
i18nModule.initBundleNames(); // remove dirty stuff from previous tests
int bundleCounter = i18nModule.getBundleNamesContainingI18nFiles().size();
String testNewBundle = "org.olat.core.util.i18n.junittestdata.new";
Locale testLocale = i18nMgr.getLocaleOrDefault("de");
File baseDir = i18nModule.getPropertyFilesBaseDir(testLocale, testNewBundle);
File testFile = i18nMgr.getPropertiesFile(testLocale, testNewBundle, baseDir);
// clean first existing files from previous broken testcase
if (testFile.exists()) {
i18nMgr.deleteProperties(testLocale, testNewBundle);
}
Properties props = i18nMgr.getResolvedProperties(testLocale, testNewBundle);
assertEquals(0, i18nMgr.countI18nItems(testLocale, testNewBundle, true));
assertEquals(0, i18nMgr.countI18nItems(testLocale, testNewBundle, false));
props.setProperty("key.1", "1");
props.setProperty("key.2", "2");
i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle);
assertEquals(2, i18nMgr.countI18nItems(testLocale, testNewBundle, false));
assertEquals(0, i18nMgr.countI18nItems(i18nMgr.getLocaleOrDefault("en"), testNewBundle, false));
assertEquals(bundleCounter + 1, i18nModule.getBundleNamesContainingI18nFiles().size());
// test all bundles
int allCount = i18nMgr.countI18nItems(testLocale, null, true);
assertEquals(allCount, i18nMgr.countI18nItems(testLocale, null, false));
props.remove("key.1");
i18nMgr.saveOrUpdateProperties(props, testLocale, testNewBundle);
assertEquals(allCount-1, i18nMgr.countI18nItems(testLocale, null, false));
i18nMgr.deleteProperties(testLocale, testNewBundle);
assertEquals(allCount-2, i18nMgr.countI18nItems(testLocale, null, false));
assertEquals(bundleCounter, i18nModule.getBundleNamesContainingI18nFiles().size());
// count bundles tests
assertEquals(0, i18nMgr.countBundles("org.olat.core.util.i18n.nonexisting", true));
assertEquals(1, i18nMgr.countBundles("org.olat.core.util.i18n.ui", true));
// finds 4: regular: i18n.devtools, i18n.ui;
assertEquals(2, i18nMgr.countBundles("org.olat.core.util.i18n", true));
assertEquals(0, i18nMgr.countBundles("org.olat.core.util.i18n", false));
assertEquals(1, i18nMgr.countBundles("org.olat.core.util.i18n.ui", false));
assertTrue(0 < i18nMgr.countBundles(null, false));
// clean up
if (testFile.exists()) {
i18nMgr.deleteProperties(testLocale, testNewBundle);
}
if (testFile.getParentFile().exists()) {
testFile.getParentFile().delete();
}
}
/** /**
* Test methods i18nManager.findInKeys() i18nManager.findInValues() * Test methods i18nManager.findInKeys() i18nManager.findInValues()
*/ */
@Test public void testFindInKeysAndFindInValues() { @Test
public void testFindInKeysAndFindInValues() {
Locale testLocale = i18nMgr.getLocaleOrDefault("de"); Locale testLocale = i18nMgr.getLocaleOrDefault("de");
// in keys speedtest // in keys speedtest
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
......
...@@ -19,15 +19,8 @@ ...@@ -19,15 +19,8 @@
*/ */
package org.olat.core.util.mail.manager; package org.olat.core.util.mail.manager;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.mail.Address; import javax.mail.Address;
import javax.mail.MessagingException; import javax.mail.MessagingException;
...@@ -37,12 +30,9 @@ import javax.mail.internet.MimeMessage; ...@@ -37,12 +30,9 @@ import javax.mail.internet.MimeMessage;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.olat.core.commons.persistence.DB; import org.olat.core.commons.persistence.DB;
import org.olat.core.id.Identity; import org.olat.core.id.Identity;
import org.apache.logging.log4j.Logger;
import org.olat.core.logging.Tracing;
import org.olat.core.util.WebappHelper; import org.olat.core.util.WebappHelper;
import org.olat.core.util.mail.ContactList; import org.olat.core.util.mail.ContactList;
import org.olat.core.util.mail.MailBundle; import org.olat.core.util.mail.MailBundle;
...@@ -63,8 +53,7 @@ import com.dumbster.smtp.SmtpMessage; ...@@ -63,8 +53,7 @@ import com.dumbster.smtp.SmtpMessage;
* *
*/ */
public class MailManagerTest extends OlatTestCase { public class MailManagerTest extends OlatTestCase {
private static final Logger log = Tracing.createLoggerFor(MailManagerTest.class);
@Autowired @Autowired
private MailManager mailManager; private MailManager mailManager;
@Autowired @Autowired
...@@ -237,48 +226,6 @@ public class MailManagerTest extends OlatTestCase { ...@@ -237,48 +226,6 @@ public class MailManagerTest extends OlatTestCase {
Assert.assertEquals(incomingMail, incomingsMails_3.get(0)); Assert.assertEquals(incomingMail, incomingsMails_3.get(0));
} }
@Test @Ignore // not really needed anymore, the subscribe process is asynchrone and serial
public void testParalellSubscribers() {
final int NUM_OF_THREADS = 10;
final int NUM_OF_USERS = 10;
final int NUM_OF_REDONDANCY = 50;
List<Identity> identities = new ArrayList<>();
for(int i=0; i<NUM_OF_USERS; i++) {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("fci-" + i + "-" + UUID.randomUUID());
for(int j=0; j<NUM_OF_REDONDANCY; j++) {
identities.add(id);
}
}
final CountDownLatch finishCount = new CountDownLatch(NUM_OF_THREADS);
List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>(1));
List<Boolean> statusList = Collections.synchronizedList(new ArrayList<Boolean>(1));
List<SubscribeThread> threads = new ArrayList<>();
for(int i=0; i<NUM_OF_THREADS; i++) {
List<Identity> ids = new ArrayList<>(identities);
SubscribeThread thread = new SubscribeThread(ids, exceptionHolder, statusList, finishCount);
threads.add(thread);
}
for(SubscribeThread thread:threads) {
thread.start();
}
// sleep until threads should have terminated/excepted
try {
sleep(30000);// eat all JMS events
finishCount.await(120, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("", e);
Assert.fail();
}
assertTrue("It throws an exception in test", exceptionHolder.isEmpty());
assertEquals("Thread(s) did not finish", NUM_OF_THREADS, statusList.size());
}
@Test @Test
public void sendExternMessage() { public void sendExternMessage() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mailman-1"); Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mailman-1");
...@@ -336,39 +283,4 @@ public class MailManagerTest extends OlatTestCase { ...@@ -336,39 +283,4 @@ public class MailManagerTest extends OlatTestCase {
msg3.getFrom()[0].equals(fromx)); msg3.getFrom()[0].equals(fromx));
Assert.assertNotNull(result3); Assert.assertNotNull(result3);
} }
private class SubscribeThread extends Thread {
private final List<Identity> ids;
private final List<Exception> exceptionHolder;
private final List<Boolean> statusList;
private final CountDownLatch countDown;
public SubscribeThread(List<Identity> ids, List<Exception> exceptionHolder, List<Boolean> statusList, CountDownLatch countDown) {
this.ids = ids;
this.exceptionHolder = exceptionHolder;
this.statusList = statusList;
this.countDown = countDown;
}
@Override
public void run() {
try {
Thread.sleep(10);
for(int i=5; i-->0; ) {
for(Identity id:ids) {
mailManager.subscribe(id);
}
}
statusList.add(Boolean.TRUE);
} catch (Exception ex) {
ex.printStackTrace();
log.error("", ex);
exceptionHolder.add(ex);// no exception should happen
} finally {
countDown.countDown();
dbInstance.closeSession();
}
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment