From fb62e7051b9d6d3950acf2a72d638133050aeda6 Mon Sep 17 00:00:00 2001 From: gnaegi <none@none> Date: Mon, 21 Oct 2013 14:50:33 +0200 Subject: [PATCH] OO-824 open LTI tool in new real window and not in iframe that is opened in new window --- .../nodes/basiclti/LTIRunController.java | 34 ++++++------------- .../nodes/basiclti/_content/runPopup.html | 13 +++++++ .../basiclti/_i18n/LocalStrings_de.properties | 2 ++ .../basiclti/_i18n/LocalStrings_en.properties | 3 ++ 4 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 src/main/java/org/olat/course/nodes/basiclti/_content/runPopup.html diff --git a/src/main/java/org/olat/course/nodes/basiclti/LTIRunController.java b/src/main/java/org/olat/course/nodes/basiclti/LTIRunController.java index 7f79fd36616..4d1969e93eb 100644 --- a/src/main/java/org/olat/course/nodes/basiclti/LTIRunController.java +++ b/src/main/java/org/olat/course/nodes/basiclti/LTIRunController.java @@ -32,7 +32,6 @@ import java.util.Map; import org.imsglobal.basiclti.BasicLTIUtil; import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory; import org.olat.core.dispatcher.mapper.Mapper; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; @@ -40,12 +39,9 @@ import org.olat.core.gui.components.link.Link; import org.olat.core.gui.components.link.LinkFactory; import org.olat.core.gui.components.panel.Panel; import org.olat.core.gui.components.velocity.VelocityContainer; -import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.controller.BasicController; -import org.olat.core.gui.control.creator.ControllerCreator; -import org.olat.core.gui.control.generic.popup.PopupBrowserWindow; import org.olat.core.helpers.Settings; import org.olat.core.id.Roles; import org.olat.core.id.User; @@ -279,7 +275,12 @@ public class LTIRunController extends BasicController { * @param ureq */ private void doRun(UserRequest ureq) { - run = createVelocityContainer("run"); + if (newWindow) { + // Use other container for popup opening. Rest of code is the same + run = createVelocityContainer("runPopup"); + } else { + run = createVelocityContainer("run"); + } // push title and learning objectives, only visible on intro page run.contextPut("menuTitle", courseNode.getShortTitle()); run.contextPut("displayTitle", courseNode.getLongTitle()); @@ -290,10 +291,6 @@ public class LTIRunController extends BasicController { startPage.contextPut("displayTitle", courseNode.getLongTitle()); startButton = LinkFactory.createButton("start", startPage, this); - if(newWindow) { - startButton.setTarget("_help"); - } - Boolean assessable = config.getBooleanEntry(BasicLTICourseNode.CONFIG_KEY_HAS_SCORE_FIELD); if(assessable != null && assessable.booleanValue()) { @@ -322,21 +319,9 @@ public class LTIRunController extends BasicController { public void event(UserRequest ureq, Component source, Event event) { if(source == startButton) { courseNode.incrementUserAttempts(userCourseEnv); - if(newWindow) { - //wrap the content controller into a full header layout - ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, new ControllerCreator() { - @Override - public Controller createController(UserRequest lureq, WindowControl lwControl) { - return new LTIPopedController(lureq, lwControl); - } - }); - //open in new browser window - PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr); - pbw.open(ureq); - } else { - doBasicLTI(ureq, run); - mainPanel.setContent(run); - } + // container is "run" or "runPopup" depending in configuration + doBasicLTI(ureq, run); + mainPanel.setContent(run); } else if (source == acceptLink) { storeDataExchangeAcceptance(); doRun(ureq); @@ -377,6 +362,7 @@ public class LTIRunController extends BasicController { String debug = (String) config.get(LTIConfigForm.CONFIG_KEY_DEBUG); String serverUri = Settings.createServerURI(); String sourcedId = courseEnv.getCourseResourceableId() + "_" + courseNode.getIdent() + "_" + getIdentity().getKey(); + container.contextPut("sourcedId", sourcedId); OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource(); Mapper talkbackMapper = new TalkBackMapper(); diff --git a/src/main/java/org/olat/course/nodes/basiclti/_content/runPopup.html b/src/main/java/org/olat/course/nodes/basiclti/_content/runPopup.html new file mode 100644 index 00000000000..4dfd3140c8c --- /dev/null +++ b/src/main/java/org/olat/course/nodes/basiclti/_content/runPopup.html @@ -0,0 +1,13 @@ +<div class="b_iframe_wrapper"> + <script type="text/javascript"> + /* <![CDATA[ */ + window.open("$mapperUri", "_win_$sourcedId", "location=yes#if($width!='auto'),width=${width}#end #if($height!='auto'),height=${height}#{end}"); + /* ]]> */ + </script> +</div> +<p> + $r.translate("popup.info") +</p> +<p> + <a href="$mapperUri" target="_win_$sourcedId">$r.translate("popup.link")</a> +</p> diff --git a/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_de.properties index ecff3e82cbf..2bcb644805f 100644 --- a/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_de.properties +++ b/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_de.properties @@ -47,6 +47,8 @@ roles.lti.administrator=Administrator roles.lti.teachingAssistant=Assistent Lehrperson roles.lti.contentDeveloper=Inhaltersteller roles.lti.mentor=Mentor +popup.info=Dieser Lerninhalt öffnet sich in einem separatem Fenster. Wählen Sie den untenstehenden Link wenn sich das Fenster nicht automatisch geöffnet hat. +popup.link=Erneut öffnen preview=Vorschau start=LTI-Lerninhalt anzeigen score.title=$org.olat.course.nodes.scorm\:score.title diff --git a/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_en.properties index 5ac47249627..36c6184aae6 100644 --- a/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_en.properties +++ b/src/main/java/org/olat/course/nodes/basiclti/_i18n/LocalStrings_en.properties @@ -75,6 +75,9 @@ roles.lti.mentor=Mentor\t\t roles.lti.teachingAssistant=Teaching assistant roles.title.lti=LTI roles roles.title.oo=OpenOLAT roles +popup.info=This learning content is opened in a new window. Please click the link below if the new window does not open automatically. +Dieser Lerninhalt öffnet sich in einem separatem Fenster. Wählen Sie den untenstehenden Link wenn sich das Fenster nicht automatisch geöffnet hat. +popup.link=Open content again scaleFactor=Scaling factor score.noscoreinfoyet=No score information is available for this LTI modules as you never launched the module. score.title=$org.olat.course.nodes.scorm\:score.title -- GitLab