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

OO-1751: make the password protection in structure element work in preview

parent a2fb9ae1
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 41 deletions
...@@ -31,6 +31,8 @@ public interface CourseNodePasswordManager { ...@@ -31,6 +31,8 @@ public interface CourseNodePasswordManager {
* @return * @return
*/ */
public AdditionalConditionAnswerContainer getAnswerContainer(Identity identity); public AdditionalConditionAnswerContainer getAnswerContainer(Identity identity);
public AdditionalConditionAnswerContainer removeAnswerContainerFromCache(Identity identity);
/** /**
* updates inputted password * updates inputted password
...@@ -39,7 +41,7 @@ public interface CourseNodePasswordManager { ...@@ -39,7 +41,7 @@ public interface CourseNodePasswordManager {
* @param courseId * @param courseId
* @param value * @param value
*/ */
public void updatePwd(Identity identity, String nodeIdentifier, String courseId, String value); public void updatePwd(Identity identity, String nodeIdentifier, Long courseId, String value);
/** /**
* deletes password for a repository entry * deletes password for a repository entry
......
...@@ -27,6 +27,7 @@ import org.olat.core.id.Identity; ...@@ -27,6 +27,7 @@ import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.course.condition.additionalconditions.AdditionalConditionAnswerContainer; import org.olat.course.condition.additionalconditions.AdditionalConditionAnswerContainer;
import org.olat.course.condition.additionalconditions.PasswordStore; import org.olat.course.condition.additionalconditions.PasswordStore;
import org.olat.course.run.preview.PreviewIdentity;
import org.olat.properties.Property; import org.olat.properties.Property;
import org.olat.properties.PropertyManager; import org.olat.properties.PropertyManager;
...@@ -65,28 +66,38 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager ...@@ -65,28 +66,38 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager
*/ */
@Override @Override
public AdditionalConditionAnswerContainer getAnswerContainer(Identity identity) { public AdditionalConditionAnswerContainer getAnswerContainer(Identity identity) {
AdditionalConditionAnswerContainer acac = new AdditionalConditionAnswerContainer(); AdditionalConditionAnswerContainer acac;
if(identity == null) { if(identity == null) {
//do nothing acac = new AdditionalConditionAnswerContainer();
} else if (cache.containsKey(identity.getKey())) { } else if (cache.containsKey(identity.getKey())) {
acac = cache.get(identity.getKey()); acac = cache.get(identity.getKey());
} else { } else {
PropertyManager pm = PropertyManager.getInstance(); PropertyManager pm = PropertyManager.getInstance();
List<Property> properties = pm.listProperties(identity, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME); List<Property> properties = pm.listProperties(identity, null, AdditionalConditionAnswerContainer.RESOURCE_NAME, null, null, AdditionalConditionAnswerContainer.RESOURCE_NAME);
if(properties == null) return null; if(properties == null) {
for (Object object : properties) { acac = null;
Property property = (Property) object; } else {
PasswordStore store = new PasswordStore(); acac = new AdditionalConditionAnswerContainer();
store.setPassword(property.getStringValue()); for (Object object : properties) {
store.setCourseId(property.getLongValue()); Property property = (Property) object;
store.setNodeIdent(property.getResourceTypeId()); PasswordStore store = new PasswordStore();
acac.insertAnswer(Long.toString(property.getResourceTypeId()), Long.toString(property.getLongValue()), store); store.setPassword(property.getStringValue());
store.setCourseId(property.getLongValue());
store.setNodeIdent(property.getResourceTypeId());
acac.insertAnswer(Long.toString(property.getResourceTypeId()), property.getLongValue(), store);
}
cache.put(identity.getKey(), acac);
} }
cache.put(identity.getKey(), acac);
} }
return acac; return acac;
} }
@Override
public AdditionalConditionAnswerContainer removeAnswerContainerFromCache(Identity identity) {
if(identity == null) return null;
return cache.remove(identity.getKey());
}
/** /**
* persist answer container to database * persist answer container to database
* *
...@@ -94,7 +105,10 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager ...@@ -94,7 +105,10 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager
* @param answers * @param answers
*/ */
private void persistAnswerContainer(Identity identity, AdditionalConditionAnswerContainer answers) { private void persistAnswerContainer(Identity identity, AdditionalConditionAnswerContainer answers) {
if (!answers.isContainerEmpty()) { if(identity instanceof PreviewIdentity) {
//preview identity are not persistable
cache.put(identity.getKey(), answers);
} else if (!answers.isContainerEmpty()) {
boolean updateInDatabase = false; boolean updateInDatabase = false;
PropertyManager pm = PropertyManager.getInstance(); PropertyManager pm = PropertyManager.getInstance();
Map<String, Object> container = answers.getContainer(); Map<String, Object> container = answers.getContainer();
...@@ -137,7 +151,9 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager ...@@ -137,7 +151,9 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager
updateInDatabase = true; updateInDatabase = true;
} }
} }
if (updateInDatabase) cache.put(identity.getKey(), answers); if (updateInDatabase) {
cache.put(identity.getKey(), answers);
}
} }
} }
...@@ -145,7 +161,7 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager ...@@ -145,7 +161,7 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager
* @see de.bps.course.nodes.CourseNodePasswordManager#updatePwd(org.olat.core.id.Identity, java.lang.String, java.lang.String, java.lang.String) * @see de.bps.course.nodes.CourseNodePasswordManager#updatePwd(org.olat.core.id.Identity, java.lang.String, java.lang.String, java.lang.String)
*/ */
@Override @Override
public void updatePwd(Identity identity, String nodeIdentifier, String courseId, String value) { public void updatePwd(Identity identity, String nodeIdentifier, Long courseId, String value) {
AdditionalConditionAnswerContainer answers = getAnswerContainer(identity); AdditionalConditionAnswerContainer answers = getAnswerContainer(identity);
if (answers == null) { if (answers == null) {
...@@ -183,8 +199,8 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager ...@@ -183,8 +199,8 @@ public class CourseNodePasswordManagerImpl implements CourseNodePasswordManager
private void removeAnswers(Long nodeId, Long courseId) { private void removeAnswers(Long nodeId, Long courseId) {
for (Long key : cache.keySet()) { for (Long key : cache.keySet()) {
AdditionalConditionAnswerContainer acac = cache.get(key); AdditionalConditionAnswerContainer acac = cache.get(key);
if (acac.containsAnswer(Long.toString(nodeId), Long.toString(courseId))) { if (acac.containsAnswer(Long.toString(nodeId), courseId)) {
acac.removeAnswer(Long.toString(nodeId), Long.toString(courseId)); acac.removeAnswer(Long.toString(nodeId), courseId);
} }
} }
} }
......
...@@ -26,6 +26,7 @@ import org.olat.core.gui.control.Controller; ...@@ -26,6 +26,7 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl; import org.olat.core.gui.control.WindowControl;
import org.olat.course.condition.Condition; import org.olat.course.condition.Condition;
import org.olat.course.nodes.AbstractAccessableCourseNode; import org.olat.course.nodes.AbstractAccessableCourseNode;
import org.olat.course.run.userview.UserCourseEnvironment;
public abstract class AdditionalCondition extends Condition implements Cloneable, Serializable { public abstract class AdditionalCondition extends Condition implements Cloneable, Serializable {
...@@ -58,7 +59,7 @@ public abstract class AdditionalCondition extends Condition implements Cloneable ...@@ -58,7 +59,7 @@ public abstract class AdditionalCondition extends Condition implements Cloneable
* @param wControl * @param wControl
* @return the controller, null if this condition could not be fulfilled by the user and no specific message i.e webservice not reachable should be shown * @return the controller, null if this condition could not be fulfilled by the user and no specific message i.e webservice not reachable should be shown
*/ */
public abstract Controller getUserInputController(UserRequest ureq, WindowControl wControl); public abstract Controller getUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv);
public String getNodeIdentifier() { public String getNodeIdentifier() {
return node != null ? node.getIdent() : null; return node != null ? node.getIdent() : null;
......
...@@ -32,17 +32,19 @@ public class AdditionalConditionAnswerContainer { ...@@ -32,17 +32,19 @@ public class AdditionalConditionAnswerContainer {
private final Map<String, Object> container = new HashMap<String, Object>(); private final Map<String, Object> container = new HashMap<String, Object>();
public Object getAnswers(String nodeKey, String courseId){ public Object getAnswers(String nodeKey, Long courseId){
return container.get(generateMapKey(nodeKey, courseId)); return container.get(generateMapKey(nodeKey, courseId));
} }
private String generateMapKey(String nodeKey, String courseId) { private String generateMapKey(String nodeKey, Long courseId) {
return nodeKey+SEPARATOR+courseId; return nodeKey + SEPARATOR + courseId;
} }
public void insertAnswer(String nodeKey, String courseId, Object answer){ public void insertAnswer(String nodeKey, Long courseId, Object answer){
Object object = container.get(generateMapKey(nodeKey, courseId)); Object object = container.get(generateMapKey(nodeKey, courseId));
if(!answer.equals(object)) container.put(generateMapKey(nodeKey, courseId), answer); if(!answer.equals(object)) {
container.put(generateMapKey(nodeKey, courseId), answer);
}
} }
public Map<String, Object> getContainer() { public Map<String, Object> getContainer() {
...@@ -53,11 +55,11 @@ public class AdditionalConditionAnswerContainer { ...@@ -53,11 +55,11 @@ public class AdditionalConditionAnswerContainer {
return container.isEmpty(); return container.isEmpty();
} }
public void removeAnswer(String nodeKey, String courseId) { public void removeAnswer(String nodeKey, Long courseId) {
container.remove(generateMapKey(nodeKey, courseId)); container.remove(generateMapKey(nodeKey, courseId));
} }
public boolean containsAnswer(String nodeKey, String courseId) { public boolean containsAnswer(String nodeKey, Long courseId) {
return container.containsKey(generateMapKey(nodeKey, courseId)); return container.containsKey(generateMapKey(nodeKey, courseId));
} }
} }
...@@ -26,6 +26,7 @@ import org.olat.course.nodes.AbstractAccessableCourseNode; ...@@ -26,6 +26,7 @@ import org.olat.course.nodes.AbstractAccessableCourseNode;
import org.olat.course.nodes.CourseNodeConfiguration; import org.olat.course.nodes.CourseNodeConfiguration;
import org.olat.course.nodes.CourseNodeFactory; import org.olat.course.nodes.CourseNodeFactory;
import org.olat.course.nodes.TitledWrapperHelper; import org.olat.course.nodes.TitledWrapperHelper;
import org.olat.course.run.userview.UserCourseEnvironment;
public class AdditionalConditionManager { public class AdditionalConditionManager {
...@@ -61,13 +62,13 @@ public class AdditionalConditionManager { ...@@ -61,13 +62,13 @@ public class AdditionalConditionManager {
* @param wControl * @param wControl
* @return null if either nothing is wrong or the user is unable to influence the condition in olat (and won't get a more detailed error-message) * @return null if either nothing is wrong or the user is unable to influence the condition in olat (and won't get a more detailed error-message)
*/ */
public Controller nextUserInputController(UserRequest ureq, WindowControl wControl){ public Controller nextUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv) {
for(AdditionalCondition cond : node.getAdditionalConditions()){ for(AdditionalCondition cond : node.getAdditionalConditions()){
cond.setNode(node); cond.setNode(node);
cond.setCourseId(courseId); cond.setCourseId(courseId);
boolean retVal = cond.evaluate(answers); boolean retVal = cond.evaluate(answers);
if(!retVal) { if(!retVal) {
Controller ctrl = cond.getUserInputController(ureq, wControl); Controller ctrl = cond.getUserInputController(ureq, wControl, userCourseEnv);
CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfiguration(node.getType()); CourseNodeConfiguration config = CourseNodeFactory.getInstance().getCourseNodeConfiguration(node.getType());
return TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, node, config.getIconCSSClass()); return TitledWrapperHelper.getWrapper(ureq, wControl, ctrl, node, config.getIconCSSClass());
} }
......
...@@ -23,6 +23,7 @@ import org.olat.core.gui.UserRequest; ...@@ -23,6 +23,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.course.nodes.AbstractAccessableCourseNode; import org.olat.course.nodes.AbstractAccessableCourseNode;
import org.olat.course.run.userview.UserCourseEnvironment;
/** /**
* Only a placeholder to import courses from other vendors * Only a placeholder to import courses from other vendors
...@@ -53,7 +54,7 @@ public class PasswordCondition extends AdditionalCondition { ...@@ -53,7 +54,7 @@ public class PasswordCondition extends AdditionalCondition {
String userAnswer = null; String userAnswer = null;
if(userAnswerObj instanceof AdditionalConditionAnswerContainer) { if(userAnswerObj instanceof AdditionalConditionAnswerContainer) {
AdditionalConditionAnswerContainer answersContainer = (AdditionalConditionAnswerContainer)userAnswerObj; AdditionalConditionAnswerContainer answersContainer = (AdditionalConditionAnswerContainer)userAnswerObj;
Object obj = answersContainer.getAnswers(node.getIdent(), courseId.toString()); Object obj = answersContainer.getAnswers(node.getIdent(), courseId);
if(obj instanceof PasswordStore){ if(obj instanceof PasswordStore){
userAnswer = ((PasswordStore)obj).getPassword(); userAnswer = ((PasswordStore)obj).getPassword();
} }
...@@ -65,8 +66,8 @@ public class PasswordCondition extends AdditionalCondition { ...@@ -65,8 +66,8 @@ public class PasswordCondition extends AdditionalCondition {
} }
@Override @Override
public Controller getUserInputController(UserRequest ureq, WindowControl wControl){ public Controller getUserInputController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv){
return new PasswordVerificationController(ureq, wControl, this); return new PasswordVerificationController(ureq, wControl, this, userCourseEnv);
} }
@Override @Override
......
...@@ -29,6 +29,7 @@ import org.olat.core.gui.control.Event; ...@@ -29,6 +29,7 @@ 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.util.StringHelper; import org.olat.core.util.StringHelper;
import org.olat.course.run.RunMainController; import org.olat.course.run.RunMainController;
import org.olat.course.run.userview.UserCourseEnvironment;
import de.bps.course.nodes.CourseNodePasswordManager; import de.bps.course.nodes.CourseNodePasswordManager;
import de.bps.course.nodes.CourseNodePasswordManagerImpl; import de.bps.course.nodes.CourseNodePasswordManagerImpl;
...@@ -39,13 +40,16 @@ import de.bps.course.nodes.CourseNodePasswordManagerImpl; ...@@ -39,13 +40,16 @@ import de.bps.course.nodes.CourseNodePasswordManagerImpl;
* @author srosse, stephane.rosse@frentix.com * @author srosse, stephane.rosse@frentix.com
*/ */
public class PasswordVerificationController extends FormBasicController { public class PasswordVerificationController extends FormBasicController {
private final PasswordCondition condition;
private TextElement pwElement; private TextElement pwElement;
private final PasswordCondition condition;
private final UserCourseEnvironment userCourseEnv;
protected PasswordVerificationController(UserRequest ureq, WindowControl wControl, PasswordCondition condition) { protected PasswordVerificationController(UserRequest ureq, WindowControl wControl, PasswordCondition condition, UserCourseEnvironment userCourseEnv) {
super(ureq, wControl); super(ureq, wControl);
this.condition = condition; this.condition = condition;
this.userCourseEnv = userCourseEnv;
initForm(ureq); initForm(ureq);
} }
...@@ -84,7 +88,8 @@ public class PasswordVerificationController extends FormBasicController { ...@@ -84,7 +88,8 @@ public class PasswordVerificationController extends FormBasicController {
valid = condition.evaluate(pwElement.getValue()); valid = condition.evaluate(pwElement.getValue());
if (valid) { if (valid) {
CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance(); CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance();
cnpm.updatePwd(ureq.getIdentity(), condition.getNodeIdentifier(), condition.getCourseId().toString(), pwElement.getValue()); //used the identity of the user course environment for the preview of courses
cnpm.updatePwd(userCourseEnv.getIdentityEnvironment().getIdentity(), condition.getNodeIdentifier(), condition.getCourseId(), pwElement.getValue());
} else { } else {
pwElement.setErrorKey("password.incorrect", new String[0]); pwElement.setErrorKey("password.incorrect", new String[0]);
} }
......
...@@ -47,6 +47,7 @@ import org.olat.core.gui.control.WindowControl; ...@@ -47,6 +47,7 @@ import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.messages.MessageUIFactory; import org.olat.core.gui.control.generic.messages.MessageUIFactory;
import org.olat.core.gui.control.generic.title.TitledWrapperController; import org.olat.core.gui.control.generic.title.TitledWrapperController;
import org.olat.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.core.id.Identity;
import org.olat.core.id.OLATResourceable; import org.olat.core.id.OLATResourceable;
import org.olat.core.id.context.BusinessControlFactory; import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry; import org.olat.core.id.context.ContextEntry;
...@@ -360,7 +361,8 @@ public class NavigationHandler implements Disposable { ...@@ -360,7 +361,8 @@ public class NavigationHandler implements Disposable {
if (courseNode instanceof AbstractAccessableCourseNode) { if (courseNode instanceof AbstractAccessableCourseNode) {
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId(); Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance(); CourseNodePasswordManager cnpm = CourseNodePasswordManagerImpl.getInstance();
AdditionalConditionAnswerContainer answerContainer = cnpm.getAnswerContainer(ureq.getIdentity()); Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity();
AdditionalConditionAnswerContainer answerContainer = cnpm.getAnswerContainer(identity);
addMan = new AdditionalConditionManager( (AbstractAccessableCourseNode) courseNode, courseId, answerContainer); addMan = new AdditionalConditionManager( (AbstractAccessableCourseNode) courseNode, courseId, answerContainer);
} }
...@@ -373,7 +375,7 @@ public class NavigationHandler implements Disposable { ...@@ -373,7 +375,7 @@ public class NavigationHandler implements Disposable {
//this is the case if only one of the additional conditions failed //this is the case if only one of the additional conditions failed
if (nodeEval.oldStyleConditionsOk()) { if (nodeEval.oldStyleConditionsOk()) {
controller = addMan.nextUserInputController(ureq, wControl); controller = addMan.nextUserInputController(ureq, wControl, userCourseEnv);
if (listeningController != null) { if (listeningController != null) {
controller.addControllerListener(listeningController); controller.addControllerListener(listeningController);
} }
...@@ -399,7 +401,6 @@ public class NavigationHandler implements Disposable { ...@@ -399,7 +401,6 @@ public class NavigationHandler implements Disposable {
nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false); nclr = new NodeClickedRef(treeModel, true, newSelectedNodeId, null, courseNode, ncr, false);
} else { // access ok } else { // access ok
// fxdiff FXOLAT-262
if (STCourseNode.isDelegatingSTCourseNode(courseNode) && (courseNode.getChildCount() > 0)) { if (STCourseNode.isDelegatingSTCourseNode(courseNode) && (courseNode.getChildCount() > 0)) {
// the clicked node is a STCourse node and is set to "delegate", so // the clicked node is a STCourse node and is set to "delegate", so
// delegate to its first visible child; if no child is visible, just skip and do normal eval // delegate to its first visible child; if no child is visible, just skip and do normal eval
......
...@@ -35,30 +35,36 @@ import org.olat.core.id.Persistable; ...@@ -35,30 +35,36 @@ import org.olat.core.id.Persistable;
import org.olat.core.id.Preferences; import org.olat.core.id.Preferences;
import org.olat.core.id.User; import org.olat.core.id.User;
import org.olat.core.id.UserConstants; import org.olat.core.id.UserConstants;
import org.olat.core.util.CodeHelper;
/** /**
* Initial Date: 08.02.2005 * Initial Date: 08.02.2005
* *
* @author Mike Stock * @author Mike Stock
*/ */
final class PreviewIdentity implements Identity, User { public final class PreviewIdentity implements Identity, User {
private static final long serialVersionUID = 6582855975941440446L; private static final long serialVersionUID = 6582855975941440446L;
private final Map<String, String> data = new HashMap<String, String>(); private final Map<String, String> data = new HashMap<String, String>();
private final Long key;
private Map<String, String> envAttrs; private Map<String, String> envAttrs;
{ {
data.put(UserConstants.FIRSTNAME, "Jane"); data.put(UserConstants.FIRSTNAME, "Jane");
data.put(UserConstants.LASTNAME, "Doe"); data.put(UserConstants.LASTNAME, "Doe");
data.put(UserConstants.EMAIL, "jane.doe@testmail.com"); data.put(UserConstants.EMAIL, "jane.doe@testmail.com");
} }
public PreviewIdentity() {
key = CodeHelper.getRAMUniqueID();
}
/** /**
* @see org.olat.core.commons.persistence.Persistable#getKey() * @see org.olat.core.commons.persistence.Persistable#getKey()
*/ */
@Override @Override
public Long getKey() { public Long getKey() {
return 2l; return key;
} }
@Override @Override
......
...@@ -49,15 +49,18 @@ import org.olat.core.id.IdentityEnvironment; ...@@ -49,15 +49,18 @@ import org.olat.core.id.IdentityEnvironment;
import org.olat.course.condition.Condition; import org.olat.course.condition.Condition;
import org.olat.course.groupsandrights.CourseGroupManager; import org.olat.course.groupsandrights.CourseGroupManager;
import org.olat.course.nodes.CourseNode; import org.olat.course.nodes.CourseNode;
import org.olat.course.run.RunMainController;
import org.olat.course.run.environment.CourseEnvironment; import org.olat.course.run.environment.CourseEnvironment;
import org.olat.course.run.navigation.NavigationHandler; import org.olat.course.run.navigation.NavigationHandler;
import org.olat.course.run.navigation.NodeClickedRef; import org.olat.course.run.navigation.NodeClickedRef;
import org.olat.course.run.userview.VisibleTreeFilter;
import org.olat.course.run.userview.UserCourseEnvironment; import org.olat.course.run.userview.UserCourseEnvironment;
import org.olat.course.run.userview.UserCourseEnvironmentImpl; import org.olat.course.run.userview.UserCourseEnvironmentImpl;
import org.olat.course.run.userview.VisibleTreeFilter;
import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroup;
import org.olat.group.area.BGArea; import org.olat.group.area.BGArea;
import de.bps.course.nodes.CourseNodePasswordManagerImpl;
/** /**
* Description: <br> * Description: <br>
* *
...@@ -67,8 +70,9 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -67,8 +70,9 @@ public class PreviewRunController extends MainLayoutBasicController {
private MenuTree luTree; private MenuTree luTree;
private Panel content; private Panel content;
private NavigationHandler navHandler; private final NavigationHandler navHandler;
private UserCourseEnvironment uce; private final UserCourseEnvironment uce;
private CourseNode currentCourseNode;
private Controller currentNodeController; // the currently open node private Controller currentNodeController; // the currently open node
private VelocityContainer detail; private VelocityContainer detail;
...@@ -116,6 +120,7 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -116,6 +120,7 @@ public class PreviewRunController extends MainLayoutBasicController {
content = new Panel("building_block_content"); content = new Panel("building_block_content");
currentNodeController = nclr.getRunController(); currentNodeController = nclr.getRunController();
currentCourseNode = nclr.getCalledCourseNode();
currentNodeController.addControllerListener(this); currentNodeController.addControllerListener(this);
content.setContent(currentNodeController.getInitialComponent()); content.setContent(currentNodeController.getInitialComponent());
detail.put("content", content); detail.put("content", content);
...@@ -150,6 +155,7 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -150,6 +155,7 @@ public class PreviewRunController extends MainLayoutBasicController {
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component, org.olat.core.gui.control.Event) * org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/ */
@Override
public void event(UserRequest ureq, Component source, Event event) { public void event(UserRequest ureq, Component source, Event event) {
if (source == luTree) { if (source == luTree) {
if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) { if (event.getCommand().equals(MenuTree.COMMAND_TREENODE_CLICKED)) {
...@@ -190,6 +196,7 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -190,6 +196,7 @@ public class PreviewRunController extends MainLayoutBasicController {
String visibilityExpr = (c.getConditionExpression() == null? translate("details.visibility.none") : c.getConditionExpression()); String visibilityExpr = (c.getConditionExpression() == null? translate("details.visibility.none") : c.getConditionExpression());
detail.contextPut("visibilityExpr", visibilityExpr); detail.contextPut("visibilityExpr", visibilityExpr);
detail.contextPut("coursenode", cn); detail.contextPut("coursenode", cn);
currentCourseNode = cn;
} }
Component nodeComp = currentNodeController.getInitialComponent(); Component nodeComp = currentNodeController.getInitialComponent();
...@@ -204,6 +211,7 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -204,6 +211,7 @@ public class PreviewRunController extends MainLayoutBasicController {
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event) * org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/ */
@Override
public void event(UserRequest ureq, Controller source, Event event) { public void event(UserRequest ureq, Controller source, Event event) {
if (source == currentNodeController) { if (source == currentNodeController) {
if (event instanceof OlatCmdEvent) { if (event instanceof OlatCmdEvent) {
...@@ -215,6 +223,8 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -215,6 +223,8 @@ public class PreviewRunController extends MainLayoutBasicController {
updateTreeAndContent(ureq, identNode); updateTreeAndContent(ureq, identNode);
oe.accept(); oe.accept();
} }
} else if (RunMainController.REBUILD.equals(event.getCommand())) {
updateTreeAndContent(ureq, currentCourseNode);
} }
} }
} }
...@@ -266,6 +276,7 @@ public class PreviewRunController extends MainLayoutBasicController { ...@@ -266,6 +276,7 @@ public class PreviewRunController extends MainLayoutBasicController {
currentNodeController.dispose(); currentNodeController.dispose();
currentNodeController = null; currentNodeController = null;
} }
CourseNodePasswordManagerImpl.getInstance().removeAnswerContainerFromCache(uce.getIdentityEnvironment().getIdentity());
navHandler.dispose(); navHandler.dispose();
} }
} }
\ No newline at end of file
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