Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dto/MindmapDTO.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dto/MindmapDTO.java (.../MindmapDTO.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dto/MindmapDTO.java (.../MindmapDTO.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -52,7 +52,8 @@ public Set offlineInstructionsFiles; public Set sessionDTOs = new TreeSet(); public Long currentTab; - + // reflection + public boolean reflectOnActivity; public String reflectInstructions; /* Constructors */ @@ -68,6 +69,8 @@ contentInUse = mindmap.isContentInUse(); lockOnFinish = mindmap.isLockOnFinished(); multiUserMode = mindmap.isMultiUserMode(); + reflectOnActivity = mindmap.isReflectOnActivity(); + reflectInstructions = mindmap.getReflectInstructions(); onlineInstructionsFiles = new TreeSet(); offlineInstructionsFiles = new TreeSet(); @@ -191,6 +194,14 @@ this.currentTab = currentTab; } + public boolean isReflectOnActivity() { + return reflectOnActivity; + } + + public void setReflectOnActivity(boolean reflectOnActivity) { + this.reflectOnActivity = reflectOnActivity; + } + public String getReflectInstructions() { return reflectInstructions; } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java (.../IMindmapService.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/IMindmapService.java (.../IMindmapService.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -175,10 +175,9 @@ public MessageService getMindmapMessageService(); - /* Outputs */ + /** Outputs */ public int getNumNodes(Long learnerId, Long toolSessionId); - /* MINDMAP Code */ public String getLanguageXML(); public void deleteNodeByUniqueMindmapUser(Long uniqueId, Long mindmapId, Long userId); Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -184,7 +184,6 @@ //MindmapUser mindmapUser = getUserByUserIdAndSessionId(learnerId, toolSessionId); //MindmapSession mindmapSession = getSessionBySessionId(toolSessionId); - // TODO: Implement Nodes output return mindmapNodeDAO.getNumNodesByUserAndSession(learnerId, toolSessionId); } @@ -214,13 +213,30 @@ Mindmap toContent = Mindmap.newInstance(fromContent, toContentId, mindmapToolContentHandler); mindmapDAO.saveOrUpdate(toContent); - /* MINDMAP Code */ - - MindmapNode fromMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); - - cloneMindmapNodesForRuntime(fromMindmapNode, null, fromContent, toContent); - - /* MINDMAP Code */ + /* Copying Mindmap Nodes */ + + // creating default nodes for current mindmap + String rootNodeName = getMindmapMessageService().getMessage("node.root.defaultName"); + String childNodeName1 = getMindmapMessageService().getMessage("node.child1.defaultName"); + String childNodeName2 = getMindmapMessageService().getMessage("node.child2.defaultName"); + + List rootNode = getAuthorRootNodeByMindmapId(fromContent.getUid()); + + MindmapNode rootMindmapNode = null; + if (rootNode == null || rootNode.size() == 0) + { + // Create default content + rootMindmapNode = saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, toContent); + saveOrUpdateMindmapNode(rootMindmapNode); + saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "ffffff", null, toContent); + saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "ffffff", null, toContent); + } + else { + rootMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); + } + + //MindmapNode fromMindmapNode = (MindmapNode) getAuthorRootNodeByMindmapId(fromContent.getUid()).get(0); + cloneMindmapNodesForRuntime(rootMindmapNode, null, fromContent, toContent); } /** Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -99,9 +99,7 @@ // Extract toolContentID from parameters. Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode", true); // set up mindmapService @@ -130,13 +128,12 @@ if (mode != null && mode.isTeacher()) { // Set the defineLater flag so that learners cannot use content - // while we - // are editing. This flag is released when updateContent is called. + // while we are editing. This flag is released when updateContent is called. mindmap.setDefineLater(true); mindmapService.saveOrUpdateMindmap(mindmap); } - /* MINDMAP Code */ + /* Mindmap Attributes */ String mindmapContentPath = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/authoring.do?dispatch=setMindmapContent%26mindmapId=" + mindmap.getUid(); @@ -151,16 +148,13 @@ String mindmapType = "images/mindmap_singleuser.swf"; request.setAttribute("mindmapType", mindmapType); - - /* MINDMAP Code */ // Set up the authForm. AuthoringForm authForm = (AuthoringForm) form; updateAuthForm(authForm, mindmap); // Set up sessionMap - SessionMap map = createSessionMap(mindmap, getAccessMode(request), contentFolderID, - toolContentID); + SessionMap map = createSessionMap(mindmap, getAccessMode(request), contentFolderID, toolContentID); authForm.setSessionMapID(map.getSessionID()); // add the sessionMap to HTTPSession. @@ -246,8 +240,6 @@ */ public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - // TODO need error checking. - // get authForm and session map. AuthoringForm authForm = (AuthoringForm) form; SessionMap map = getSessionMap(request, authForm); @@ -292,7 +284,7 @@ request.setAttribute(MindmapConstants.ATTR_SESSION_MAP, map); - /* MINDMAP Code */ + /* Saving Minmdap Nodes */ // getting xml data from SWF String mindmapContent = authForm.getMindmapContent(); @@ -306,8 +298,7 @@ List branches = rootNodeModel.getBranch(); // saving root Node into database - MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId(mindmap.getUid()) - .get(0); + MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId(mindmap.getUid()).get(0); rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); @@ -323,8 +314,6 @@ nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid(); mindmapService.deleteNodes(nodesToDeleteCondition); - /* MINDMAP Code */ - return mapping.findForward("success"); } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java (.../LearningAction.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java (.../LearningAction.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -162,8 +162,6 @@ } request.setAttribute("finishedActivity", mindmapUser.isFinishedActivity()); - /* MINDMAP Code */ - // mindmapContentPath Parameter String mindmapContentPath = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do?dispatch=setMindmapContent%26mindmapId=" + mindmap.getUid() + "%26userId=" @@ -205,13 +203,20 @@ String localizationPath = Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do?dispatch=setLocale"; request.setAttribute("localizationPath", localizationPath); - + // setting userId for reflection request.setAttribute("userIdParam", mindmapUser.getUid()); request.setAttribute("toolContentIdParam", mindmap.getUid()); request.setAttribute("reflectOnActivity", mindmap.isReflectOnActivity()); - - // in multi-user mode + + // AJAX calls for saving Mindmap every one minute + request.setAttribute("get", Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/learning.do"); + request.setAttribute("dispatch", "saveLastMindmapChanges"); + request.setAttribute("mindmapId", mindmap.getUid()); + request.setAttribute("userId", mindmapUser.getUid()); + request.setAttribute("multiMode", mindmap.isMultiUserMode()); + + // if not multi-user mode if (!mindmap.isMultiUserMode()) { // clonning Mindmap Nodes for current user List rootNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); @@ -223,8 +228,6 @@ } } - /* MINDMAP Code */ - return mapping.findForward("mindmap"); } @@ -575,6 +578,54 @@ return null; } + public ActionForward saveLastMindmapChanges(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolContentId = WebUtil.readLongParam(request, "mindmapId", false); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + + // Saving Mindmap Nodes + if (!mindmap.isMultiUserMode()) { + // getting xml data from SWF + String mindmapContent = WebUtil.readStrParam(request, "content", false); + // learningForm.getMindmapContent(); + + saveMindmapXML(mindmap, mindmapUser, mindmapContent); + } + + return null; + } + + public void saveMindmapXML(Mindmap mindmap, MindmapUser mindmapUser, String mindmapContent) { + // Saving Mindmap data to XML + XStream xstream = new XStream(); + xstream.alias("branch", NodeModel.class); + NodeModel rootNodeModel = (NodeModel) xstream.fromXML(mindmapContent); + NodeConceptModel nodeConceptModel = rootNodeModel.getConcept(); + List branches = rootNodeModel.getBranch(); + + // saving root Node into database + MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), + mindmapUser.getUid()).get(0); + rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); + + // string to accumulate deleted nodes for query + String nodesToDeleteCondition = " where uniqueId <> " + rootMindmapNode.getUniqueId(); + + // saving child Nodes into database + if (branches != null) { + mindmapService.setNodesToDeleteCondition(""); + mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); + } + + nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid() + + " and user_id = " + mindmapUser.getUid(); + mindmapService.deleteNodes(nodesToDeleteCondition); + } + /** * Returns the serialized XML of the Mindmap Nodes from Database * @@ -618,48 +669,49 @@ return mindmapUser; } - + /** - * Indicates that the user has finished viewing the noticeboard, and will - * be passed onto the Notebook reflection screen. + * Saving Mindmap nodes and proceed to reflection. + * * @param mapping * @param form * @param request * @param response * @return */ - public ActionForward reflect(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward reflect(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - + + LearningForm learningForm = (LearningForm) form; + Long userId = WebUtil.readLongParam(request, "userId", false); Long toolContentId = WebUtil.readLongParam(request, "toolContentId", false); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); - - //LearningForm learningForm = (LearningForm) form; - //Long toolSessionID = learningForm.getToolSessionID(); - //Mindmap mindmap = mindmapService.getMindmapByContentId(toolSessionID); Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); - - request.setAttribute("reflectTitle", mindmap.getTitle()); - request.setAttribute("reflectInstructions", mindmap.getReflectInstructions()); - if (mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity()) { + request.setAttribute("reflectTitle", mindmap.getTitle()); + request.setAttribute("reflectInstructions", mindmap.getReflectInstructions()); + + if (mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity()) request.setAttribute("contentEditable", false); - } else { + else request.setAttribute("contentEditable", true); - } - - NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); - - if (entry != null) { - request.setAttribute("reflectEntry", entry.getEntry()); - } - - return mapping.findForward("reflect"); + + // Saving Mindmap Nodes + if (!mindmap.isMultiUserMode()) + saveMindmapXML(mindmap, mindmapUser, learningForm.getMindmapContent()); + + // Reflection + NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); + if (entry != null) + request.setAttribute("reflectEntry", entry.getEntry()); + + return mapping.findForward("reflect"); } - + /** - * Saves Mindmap Nodes to Database + * Finish Mindmap Activity and save reflection if appropriate. * * @param mapping * @param form @@ -686,46 +738,15 @@ Mindmap mindmap = mindmapSession.getMindmap(); - if (!mindmap.isMultiUserMode()) { - // getting xml data from SWF - String mindmapContent = learningForm.getMindmapContent(); - - // Saving Mindmap data to XML - XStream xstream = new XStream(); - xstream.alias("branch", NodeModel.class); - NodeModel rootNodeModel = (NodeModel) xstream.fromXML(mindmapContent); - NodeConceptModel nodeConceptModel = rootNodeModel.getConcept(); - List branches = rootNodeModel.getBranch(); - - // saving root Node into database - MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getRootNodeByMindmapIdAndUserId( - mindmap.getUid(), mindmapUser.getUid()).get(0); - rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), - nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap); - - // string to accumulate deleted nodes for query - String nodesToDeleteCondition = " where uniqueId <> " + rootMindmapNode.getUniqueId(); - - // saving child Nodes into database - if (branches != null) { - mindmapService.setNodesToDeleteCondition(""); - mindmapService.getChildMindmapNodes(branches, rootMindmapNode, mindmapUser, mindmap); - } - - nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " - + mindmap.getUid() + " and user_id = " + mindmapUser.getUid(); - mindmapService.deleteNodes(nodesToDeleteCondition); - } - // save the reflection entry and call the notebook. if (mindmap.isReflectOnActivity()) { // check for existing notebook entry NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); if (entry == null) { // create new entry - Long entryUID = mindmapService.createNotebookEntry(toolSessionID, - CoreNotebookConstants.NOTEBOOK_TOOL, MindmapConstants.TOOL_SIGNATURE, - mindmapUser.getUserId().intValue(), learningForm.getEntryText()); + Long entryUID = mindmapService.createNotebookEntry(toolSessionID, + CoreNotebookConstants.NOTEBOOK_TOOL, MindmapConstants.TOOL_SIGNATURE, mindmapUser + .getUserId().intValue(), learningForm.getEntryText()); mindmapUser.setEntryUID(entryUID); mindmapService.saveOrUpdateMindmapUser(mindmapUser); } else { @@ -740,7 +761,8 @@ log.error("finishActivity(): couldn't find MindmapUser is null " + " and toolSessionID: " + toolSessionID); } - ToolSessionManager sessionMgrService = MindmapServiceProxy.getMindmapSessionManager(getServlet().getServletContext()); + ToolSessionManager sessionMgrService = MindmapServiceProxy.getMindmapSessionManager(getServlet() + .getServletContext()); String nextActivityUrl; try { @@ -755,8 +777,6 @@ } return null; - // TODO: need to return proper page. - // return finishActivity(mapping, form, request, response); } } Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -26,15 +26,16 @@ import java.io.IOException; import java.util.List; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.mindmap.dto.MindmapDTO; +import org.lamsfoundation.lams.tool.mindmap.dto.MindmapSessionDTO; import org.lamsfoundation.lams.tool.mindmap.dto.MindmapUserDTO; import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; import org.lamsfoundation.lams.tool.mindmap.model.MindmapNode; @@ -58,14 +59,16 @@ * @struts.action path="/monitoring" parameter="dispatch" scope="request" name="monitoringForm" validate="false" * @struts.action-forward name="success" path="tiles:/monitoring/main" * @struts.action-forward name="mindmap_display" path="tiles:/monitoring/mindmap_display" + * @struts.action-forward name="reflect" path="tiles:/monitoring/reflect" */ public class MonitoringAction extends LamsDispatchAction { - + private static Logger log = Logger.getLogger(MonitoringAction.class); public IMindmapService mindmapService; - + /** - * Default action on page load + * Default action on page load + * * @param mapping * @param form * @param request @@ -79,27 +82,32 @@ Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); - + if (mindmap == null) { - // TODO: error page. + log.error("unspecified(): Mindmap is not found!"); + return null; } boolean isGroupedActivity = mindmapService.isGroupedActivity(toolContentID); + MindmapDTO mindmapDTO = new MindmapDTO(mindmap); - MindmapDTO mindmapDT0 = new MindmapDTO(mindmap); - Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); - mindmapDT0.setCurrentTab(currentTab); + mindmapDTO.setCurrentTab(currentTab); - request.setAttribute("mindmapDTO", mindmapDT0); + Object[] users = ((MindmapSessionDTO) mindmapDTO.getSessionDTOs().toArray()[0]).getUserDTOs().toArray(); + if (users != null && users.length > 0) + request.setAttribute("mindmapUser", ((MindmapUserDTO) users[0])); + + request.setAttribute("mindmapDTO", mindmapDTO); request.setAttribute("contentFolderID", contentFolderID); request.setAttribute("isGroupedActivity", isGroupedActivity); return mapping.findForward("success"); } - + /** - * Returns the serialized XML of the Mindmap Nodes from Database + * Returns the serialized XML of the Mindmap Nodes from Database + * * @param mapping * @param form * @param request @@ -129,8 +137,8 @@ mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " + rootMindmapNode.getUser().getLastName(); - NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), - rootMindmapNode.getText(), rootMindmapNode.getColor(), mindmapUserName)); + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode + .getText(), rootMindmapNode.getColor(), mindmapUserName)); NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), mindmapId, rootNodeModel, null); XStream xstream = new XStream(); @@ -159,20 +167,21 @@ */ public ActionForward setLocale(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - + try { response.setContentType("text/xml"); - //response.setCharacterEncoding("utf-8"); + // response.setCharacterEncoding("utf-8"); response.getWriter().write(mindmapService.getLanguageXML()); } catch (IOException e) { e.printStackTrace(); } return null; } - + /** - * Shows Mindmap Nodes for each learner + * Shows Mindmap Nodes for each learner + * * @param mapping * @param form * @param request @@ -183,64 +192,96 @@ HttpServletResponse response) { setupService(); - + Long userId = new Long(WebUtil.readLongParam(request, "userUID")); Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); - + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); MindmapUser mindmapUser = mindmapService.getUserByUID(userId); - //NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); - MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser/*, entry*/); + MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser); request.setAttribute("userDTO", userDTO); - - /* MINDMAP Code */ // mindmapType Parameter String mindmapType = "images/mindmap_singleuser.swf"; request.setAttribute("mindmapType", mindmapType); // Mindmap path Parameter String mindmapContentPath = Configuration.get(ConfigurationKeys.SERVER_URL) - + "tool/lamind10/monitoring.do?dispatch=setMindmapContent%26mindmapId=" + toolContentID + "%26userId=" - + userId; + + "tool/lamind10/monitoring.do?dispatch=setMindmapContent%26mindmapId=" + mindmap.getUid() + + "%26userId=" + userId; request.setAttribute("mindmapContentPath", mindmapContentPath); // Current user Parameter String currentMindmapUser = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); request.setAttribute("currentMindmapUser", currentMindmapUser); - - String localizationPath = Configuration.get(ConfigurationKeys.SERVER_URL) + - "tool/lamind10/monitoring.do?dispatch=setLocale"; + + String localizationPath = Configuration.get(ConfigurationKeys.SERVER_URL) + + "tool/lamind10/monitoring.do?dispatch=setLocale"; request.setAttribute("localizationPath", localizationPath); request.setAttribute("toolContentID", toolContentID); + request.setAttribute("contentFolderID", contentFolderID); + request.setAttribute("isMultiUserMode", mindmap.isMultiUserMode()); + + // Attributes for AJAX calls while saving Mindmap + request.setAttribute("get", Configuration.get(ConfigurationKeys.SERVER_URL) + "tool/lamind10/monitoring.do"); + request.setAttribute("dispatch", "updateContent"); + request.setAttribute("mindmapId", mindmap.getUid()); + request.setAttribute("userId", mindmapUser.getUid()); - /* MINDMAP Code */ - return mapping.findForward("mindmap_display"); } /** - * Saves Mindmap Nodes to Database + * Shows Notebook reflection that Learner has done. + * * @param mapping * @param form * @param request * @param response - * @return null + * @return */ - public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward reflect(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - MonitoringForm monitorForm = (MonitoringForm) form; + Long userId = WebUtil.readLongParam(request, "userUID", false); + Long toolContentId = WebUtil.readLongParam(request, "toolContentID", false); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentId); + + request.setAttribute("reflectTitle", mindmap.getTitle()); + request.setAttribute("mindmapUser", mindmapUser.getFirstName() + " " + mindmapUser.getLastName()); + + // Reflection + NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); + if (entry != null) { + request.setAttribute("reflectEntry", entry.getEntry()); + } - Mindmap mindmap = mindmapService.getMindmapByContentId(monitorForm.getToolContentID()); - + return mapping.findForward("reflect"); + } + + /** + * Saves Mindmap Nodes to Database + * + * @param mapping + * @param form + * @param request + * @param response + * @return null + */ + public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolContentId = WebUtil.readLongParam(request, "mindmapId", false); + String mindmapContent = WebUtil.readStrParam(request, "content", false); + + Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + if (!mindmap.isMultiUserMode()) { - // getting xml data from SWF - String mindmapContent = monitorForm.getMindmapContent(); - Long userId = monitorForm.getUserId(); - MindmapUser mindmapUser = mindmapService.getUserByUID(userId); - // Saving Mindmap data to XML XStream xstream = new XStream(); xstream.alias("branch", NodeModel.class); @@ -268,7 +309,7 @@ mindmapService.deleteNodes(nodesToDeleteCondition); } - return mapping.findForward("success"); + return null; } /** Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java =================================================================== diff -u -r26ce6de9fba8494203a85a4ce076b6ffea4238ed -r4060c9d9376555e5c015b4d20656d121069f4f0d --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 26ce6de9fba8494203a85a4ce076b6ffea4238ed) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 4060c9d9376555e5c015b4d20656d121069f4f0d) @@ -46,6 +46,7 @@ String mindmapContent; Long userId; Long toolContentID; + Long contentFolderID; public String getMessageBody() { return messageBody; @@ -118,4 +119,12 @@ public void setToolContentID(Long toolContentID) { this.toolContentID = toolContentID; } + + public Long getContentFolderID() { + return contentFolderID; + } + + public void setContentFolderID(Long contentFolderID) { + this.contentFolderID = contentFolderID; + } }