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

OO-3523: disable the possibility to skip the launch page in LTI course element...

OO-3523: disable the possibility to skip the launch page in LTI course element if the configuration at the LMS level say so
parent 6dbdf295
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,6 @@ import java.util.ArrayList; ...@@ -31,7 +31,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.imsglobal.basiclti.BasicLTIUtil; import org.imsglobal.basiclti.BasicLTIUtil;
import org.olat.core.CoreSpringFactory;
import org.olat.core.gui.UserRequest; import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItem;
import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.FormItemContainer;
...@@ -56,9 +55,11 @@ import org.olat.core.util.StringHelper; ...@@ -56,9 +55,11 @@ import org.olat.core.util.StringHelper;
import org.olat.course.nodes.BasicLTICourseNode; import org.olat.course.nodes.BasicLTICourseNode;
import org.olat.ims.lti.LTIDisplayOptions; import org.olat.ims.lti.LTIDisplayOptions;
import org.olat.ims.lti.LTIManager; import org.olat.ims.lti.LTIManager;
import org.olat.ims.lti.LTIModule;
import org.olat.modules.ModuleConfiguration; import org.olat.modules.ModuleConfiguration;
import org.olat.user.UserManager; import org.olat.user.UserManager;
import org.olat.user.propertyhandlers.UserPropertyHandler; import org.olat.user.propertyhandlers.UserPropertyHandler;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* *
...@@ -153,6 +154,11 @@ public class LTIConfigForm extends FormBasicController { ...@@ -153,6 +154,11 @@ public class LTIConfigForm extends FormBasicController {
private String[] userPropKeys; private String[] userPropKeys;
private String[] userPropValues; private String[] userPropValues;
@Autowired
private LTIModule ltiModule;
@Autowired
private UserManager userManager;
/** /**
* Constructor for the tunneling configuration form * Constructor for the tunneling configuration form
* @param name * @param name
...@@ -164,7 +170,6 @@ public class LTIConfigForm extends FormBasicController { ...@@ -164,7 +170,6 @@ public class LTIConfigForm extends FormBasicController {
this.config = config; this.config = config;
int configVersion = config.getConfigurationVersion(); int configVersion = config.getConfigurationVersion();
UserManager userManager = CoreSpringFactory.getImpl(UserManager.class);
Translator userPropsTranslator = userManager.getPropertyHandlerTranslator(getTranslator()); Translator userPropsTranslator = userManager.getPropertyHandlerTranslator(getTranslator());
ltiRolesValues = new String[]{ ltiRolesValues = new String[]{
...@@ -268,12 +273,18 @@ public class LTIConfigForm extends FormBasicController { ...@@ -268,12 +273,18 @@ public class LTIConfigForm extends FormBasicController {
String[] enableValues = new String[]{ translate("on") }; String[] enableValues = new String[]{ translate("on") };
skipLaunchPageEl = uifactory.addCheckboxesHorizontal("display.config.skipLaunchPage", formLayout, enabledKeys, enableValues); skipLaunchPageEl = uifactory.addCheckboxesHorizontal("display.config.skipLaunchPage", formLayout, enabledKeys, enableValues);
if (config.getBooleanSafe(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE)) { if(ltiModule.isForceLaunchPage()) {
skipLaunchPageEl.select(enabledKeys[0], true);
skipLaunchPageEl.setEnabled(false);
} else if (config.getBooleanSafe(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE)) {
skipLaunchPageEl.select(enabledKeys[0], true); skipLaunchPageEl.select(enabledKeys[0], true);
} }
skipAcceptLaunchPageEl = uifactory.addCheckboxesHorizontal("display.config.skipAcceptLaunchPage", formLayout, enabledKeys, enableValues); skipAcceptLaunchPageEl = uifactory.addCheckboxesHorizontal("display.config.skipAcceptLaunchPage", formLayout, enabledKeys, enableValues);
if (config.getBooleanSafe(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE)) { if(ltiModule.isForceLaunchPage()) {
skipAcceptLaunchPageEl.select(enabledKeys[0], true);
skipAcceptLaunchPageEl.setEnabled(false);
} else if (config.getBooleanSafe(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE)) {
skipAcceptLaunchPageEl.select(enabledKeys[0], true); skipAcceptLaunchPageEl.select(enabledKeys[0], true);
} }
skipAcceptLaunchPageEl.setHelpTextKey("display.config.skipAcceptLaunchPageWarning", null); skipAcceptLaunchPageEl.setHelpTextKey("display.config.skipAcceptLaunchPageWarning", null);
...@@ -499,10 +510,9 @@ public class LTIConfigForm extends FormBasicController { ...@@ -499,10 +510,9 @@ public class LTIConfigForm extends FormBasicController {
return fullURL; return fullURL;
} }
@SuppressWarnings("unused")
@Override @Override
protected boolean validateFormLogic(UserRequest ureq) { protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = true; boolean allOk = super.validateFormLogic(ureq);
try { try {
new URL(thost.getValue()); new URL(thost.getValue());
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
...@@ -511,7 +521,7 @@ public class LTIConfigForm extends FormBasicController { ...@@ -511,7 +521,7 @@ public class LTIConfigForm extends FormBasicController {
} }
allOk &= validateFloat(cutValueEl); allOk &= validateFloat(cutValueEl);
allOk &= validateFloat(scaleFactorEl); allOk &= validateFloat(scaleFactorEl);
return allOk & super.validateFormLogic(ureq); return allOk;
} }
private boolean validateFloat(TextElement el) { private boolean validateFloat(TextElement el) {
...@@ -618,14 +628,14 @@ public class LTIConfigForm extends FormBasicController { ...@@ -618,14 +628,14 @@ public class LTIConfigForm extends FormBasicController {
config.set(CONFIGKEY_PASS, tpass.getValue()); config.set(CONFIGKEY_PASS, tpass.getValue());
config.set(CONFIG_KEY_DEBUG, Boolean.toString(doDebug.isSelected(0))); config.set(CONFIG_KEY_DEBUG, Boolean.toString(doDebug.isSelected(0)));
config.set(CONFIG_KEY_CUSTOM, getCustomConfig()); config.set(CONFIG_KEY_CUSTOM, getCustomConfig());
if (skipLaunchPageEl.isAtLeastSelected(1)) { if (ltiModule.isForceLaunchPage() || skipLaunchPageEl.isAtLeastSelected(1)) {
config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE, Boolean.TRUE); config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE, Boolean.TRUE);
} else { } else {
config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE, Boolean.FALSE); config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE, Boolean.FALSE);
} }
config.set(CONFIG_KEY_SENDNAME, Boolean.toString(sendName.isSelected(0))); config.set(CONFIG_KEY_SENDNAME, Boolean.toString(sendName.isSelected(0)));
config.set(CONFIG_KEY_SENDEMAIL, Boolean.toString(sendEmail.isSelected(0))); config.set(CONFIG_KEY_SENDEMAIL, Boolean.toString(sendEmail.isSelected(0)));
if (skipAcceptLaunchPageEl.isAtLeastSelected(1) && (sendName.isSelected(0) || sendEmail.isSelected(0))) { if ((ltiModule.isForceLaunchPage() || skipAcceptLaunchPageEl.isAtLeastSelected(1)) && (sendName.isSelected(0) || sendEmail.isSelected(0))) {
config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE, Boolean.TRUE); config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE, Boolean.TRUE);
} else { } else {
config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE, Boolean.FALSE); config.setBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE, Boolean.FALSE);
......
...@@ -65,12 +65,14 @@ import org.olat.course.run.userview.UserCourseEnvironment; ...@@ -65,12 +65,14 @@ import org.olat.course.run.userview.UserCourseEnvironment;
import org.olat.ims.lti.LTIContext; import org.olat.ims.lti.LTIContext;
import org.olat.ims.lti.LTIDisplayOptions; import org.olat.ims.lti.LTIDisplayOptions;
import org.olat.ims.lti.LTIManager; import org.olat.ims.lti.LTIManager;
import org.olat.ims.lti.LTIModule;
import org.olat.ims.lti.ui.PostDataMapper; import org.olat.ims.lti.ui.PostDataMapper;
import org.olat.ims.lti.ui.TalkBackMapper; import org.olat.ims.lti.ui.TalkBackMapper;
import org.olat.modules.ModuleConfiguration; import org.olat.modules.ModuleConfiguration;
import org.olat.modules.assessment.Role; import org.olat.modules.assessment.Role;
import org.olat.properties.Property; import org.olat.properties.Property;
import org.olat.resource.OLATResource; import org.olat.resource.OLATResource;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* Description:<br> * Description:<br>
...@@ -99,9 +101,13 @@ public class LTIRunController extends BasicController { ...@@ -99,9 +101,13 @@ public class LTIRunController extends BasicController {
private ChiefController thebaseChief; private ChiefController thebaseChief;
private final Roles roles; private final Roles roles;
private final LTIManager ltiManager;
private final LTIDisplayOptions display; private final LTIDisplayOptions display;
@Autowired
private LTIModule ltiModule;
@Autowired
private LTIManager ltiManager;
public LTIRunController(WindowControl wControl, ModuleConfiguration config, UserRequest ureq, BasicLTICourseNode ltCourseNode, public LTIRunController(WindowControl wControl, ModuleConfiguration config, UserRequest ureq, BasicLTICourseNode ltCourseNode,
CourseEnvironment courseEnv) { CourseEnvironment courseEnv) {
super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale())); super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale()));
...@@ -110,7 +116,6 @@ public class LTIRunController extends BasicController { ...@@ -110,7 +116,6 @@ public class LTIRunController extends BasicController {
this.roles = ureq.getUserSession().getRoles(); this.roles = ureq.getUserSession().getRoles();
this.courseEnv = courseEnv; this.courseEnv = courseEnv;
display = LTIDisplayOptions.iframe; display = LTIDisplayOptions.iframe;
ltiManager = CoreSpringFactory.getImpl(LTIManager.class);
run = createVelocityContainer("run"); run = createVelocityContainer("run");
// push title and learning objectives, only visible on intro page // push title and learning objectives, only visible on intro page
...@@ -354,9 +359,10 @@ public class LTIRunController extends BasicController { ...@@ -354,9 +359,10 @@ public class LTIRunController extends BasicController {
createExchangeDataProperties(); createExchangeDataProperties();
String dataExchangeHash = createHashFromExchangeDataProperties(); String dataExchangeHash = createHashFromExchangeDataProperties();
Boolean skipAcceptLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE); Boolean skipAcceptLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_ACCEPT_LAUNCH_PAGE);
if (dataExchangeHash == null || checkHasDataExchangeAccepted(dataExchangeHash) || (skipAcceptLaunchPage != null && skipAcceptLaunchPage.booleanValue()) ) { if (dataExchangeHash == null || checkHasDataExchangeAccepted(dataExchangeHash)
|| (!ltiModule.isForceLaunchPage() && skipAcceptLaunchPage != null && skipAcceptLaunchPage.booleanValue()) ) {
Boolean skipLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE); Boolean skipLaunchPage = config.getBooleanEntry(BasicLTICourseNode.CONFIG_SKIP_LAUNCH_PAGE);
if(skipLaunchPage != null && skipLaunchPage.booleanValue()) { if(!ltiModule.isForceLaunchPage() && skipLaunchPage != null && skipLaunchPage.booleanValue()) {
// start the content immediately // start the content immediately
openBasicLTIContent(ureq); openBasicLTIContent(ureq);
} else { } else {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"> http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="org.olat.ims.lti.manager,org.olat.ims.qti,org.olat.ims.qti21,uk.ac.ed.ph.jqtiplus" /> <context:component-scan base-package="org.olat.ims.lti,org.olat.ims.qti,org.olat.ims.qti21,uk.ac.ed.ph.jqtiplus" />
<bean id="org.olat.ims.cp.CPManager" class="org.olat.ims.cp.CPManagerImpl"/> <bean id="org.olat.ims.cp.CPManager" class="org.olat.ims.cp.CPManagerImpl"/>
......
/**
* <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.ims.lti;
import org.olat.core.configuration.AbstractSpringModule;
import org.olat.core.util.coordinate.CoordinatorManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
*
* Initial date: 29 mai 2018<br>
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*
*/
@Service
public class LTIModule extends AbstractSpringModule {
@Value("${course.node.basiclti.force.launchpage:false}")
private boolean forceLaunchPage;
@Autowired
public LTIModule(CoordinatorManager coordinatorManager) {
super(coordinatorManager);
}
@Override
public void init() {
//
}
@Override
protected void initFromChangedProperties() {
//
}
public boolean isForceLaunchPage() {
return forceLaunchPage;
}
}
...@@ -1218,6 +1218,8 @@ course.node.checklist.deprecated=false ...@@ -1218,6 +1218,8 @@ course.node.checklist.deprecated=false
course.node.dateenrollment.enabled=false course.node.dateenrollment.enabled=false
# The LTI course element # The LTI course element
course.node.basiclti.enabled=true course.node.basiclti.enabled=true
# Force the use of a launch page (or not)
course.node.basiclti.force.launchpage=false
course.node.portfolio.enabled=true course.node.portfolio.enabled=true
course.node.infomessage.enabled=true course.node.infomessage.enabled=true
course.node.members.enabled=true course.node.members.enabled=true
......
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