From e71cc6c2a21c80794cfbf7b0e1d700a1ff604546 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Mon, 24 Oct 2016 09:00:42 +0200 Subject: [PATCH] OO-2290: if the test cannot be found, show a message instead of a red screen --- src/main/java/org/olat/modules/iq/IQManager.java | 12 +++++++++--- .../olat/modules/iq/_i18n/LocalStrings_de.properties | 2 ++ .../olat/modules/iq/_i18n/LocalStrings_en.properties | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/olat/modules/iq/IQManager.java b/src/main/java/org/olat/modules/iq/IQManager.java index 9b12cb8338a..242bae681ef 100644 --- a/src/main/java/org/olat/modules/iq/IQManager.java +++ b/src/main/java/org/olat/modules/iq/IQManager.java @@ -123,10 +123,16 @@ public class IQManager implements UserDataDeletable { // -- VERY RARE CASE -- 1) qti is open in an editor session right now on the screen (or session on the way to timeout) // -- 99% of cases -- 2) qti is ready to be run as test/survey String repositorySoftkey = (String) moduleConfiguration.get(IQEditController.CONFIG_KEY_REPOSITORY_SOFTKEY); - RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, true); - if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(re.getOlatResource(), null)){ + RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntryBySoftkey(repositorySoftkey, false); + if(re == null) { + log.error("The test repository entry with this soft key could not be found: " + repositorySoftkey); Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale()); - //so this resource is locked, let's find out who locked it + String title = translator.translate("error.test.deleted.title"); + String msg = translator.translate("error.test.deleted.msg"); + return MessageUIFactory.createInfoMessage(ureq, wControl, title, msg); + } else if (CoordinatorManager.getInstance().getCoordinator().getLocker().isLocked(re.getOlatResource(), null)){ + Translator translator = Util.createPackageTranslator(this.getClass(), ureq.getLocale()); + //so this resource is locked, let's find out who locked it LockResult lockResult = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(re.getOlatResource(), ureq.getIdentity(), null); String fullName = userManager.getUserDisplayName(lockResult.getOwner()); return MessageUIFactory.createInfoMessage(ureq, wControl, translator.translate("status.currently.locked.title"), diff --git a/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_de.properties index 63a2b4dea10..70927cbcf8f 100644 --- a/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_de.properties @@ -23,6 +23,8 @@ confirmCancel=Wollen Sie wirklich abbrechen? Es werden keine Daten gespeichert\! confirmSubmit=Wollen Sie wirklich abschliessen? confirmSuspend=Wollen Sie wirklich unterbrechen? couldNotDisplayItem=Die Frage ist geschlossen und kann daher nicht mehr angezeigt werden. +error.test.deleted.title=Fehlende Test +error.test.deleted.msg=Der Test wurde gel\u00F6scht oder konnte nicht gefunden werden. itemclosed=Frage geschlossen noMaxScore=Kein Maximum question=Frage diff --git a/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_en.properties index a8fa3e7c2c6..108549c5035 100644 --- a/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/modules/iq/_i18n/LocalStrings_en.properties @@ -24,6 +24,8 @@ confirmCancel=Do you really want to cancel? No data will be saved\! confirmSubmit=Do you really want to submit? confirmSuspend=Do you really want to suspend? couldNotDisplayItem=This question is closed and can therefore not be displayed anymore. +error.test.deleted.title=Missing Test +error.test.deleted.msg=The Testwas deleted or it cannot be found. itemclosed=Question closed noMaxScore=No maximum qti.marker.title={0} solution attempt(s), not marked -- GitLab