Index: lams_tool_mindmap/.classpath =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/.classpath (.../.classpath) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/.classpath (.../.classpath) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -2,7 +2,7 @@ - + @@ -14,10 +14,9 @@ - + - Index: lams_tool_mindmap/.externalToolBuilders/SASS Mindmap.launch =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/.externalToolBuilders/SASS Mindmap.launch (.../SASS Mindmap.launch) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/.externalToolBuilders/SASS Mindmap.launch (.../SASS Mindmap.launch) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,16 +1,22 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + Index: lams_tool_mindmap/build.xml =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/build.xml (.../build.xml) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/build.xml (.../build.xml) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -23,7 +23,7 @@ ${ant.project.name}: Copying additional Java classes to WAR Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dbupdates/patch20180731.sql =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dbupdates/patch20180731.sql (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/dbupdates/patch20180731.sql (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,23 @@ +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; +SET FOREIGN_KEY_CHECKS=0; +----------------------Put all sql statements below here------------------------- + +-- LDEV-4440 Change tool access URLs after migration to Spring MVC +UPDATE lams_tool SET + author_url = 'tool/lamind10/authoring/authoring.do', + learner_url = 'tool/lamind10/learning/learning.do?mode=learner', + learner_preview_url = 'tool/lamind10/learning/learning.do?mode=author', + learner_progress_url = 'tool/lamind10/learning/learning.do?mode=teacher', + monitor_url = 'tool/lamind10/monitoring/monitoring.do', + pedagogical_planner_url = 'tool/lamind10/pedagogicalPlanner/initPedagogicalPlannerForm.do' +WHERE tool_signature = 'lamind10'; + +UPDATE lams_tool SET tool_version='20180731' WHERE tool_signature='lamind10'; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/LearningWebsocketServer.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/actions/PedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/AuthoringController.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/AuthoringController.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,290 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.mindmap.dto.RootJSON; +import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapNode; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapUser; +import org.lamsfoundation.lams.tool.mindmap.service.IMindmapService; +import org.lamsfoundation.lams.tool.mindmap.util.MindmapConstants; +import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeConceptModel; +import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeModel; +import org.lamsfoundation.lams.tool.mindmap.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * @author Ruslan Kazakov + * @version 1.0.1 + * + * + * + * + */ +@Controller +@RequestMapping("/authoring") +public class AuthoringController { + + private static Logger logger = Logger.getLogger(AuthoringController.class); + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + private static final String KEY_MODE = "mode"; + + @Autowired + @Qualifier("mindmapService") + private IMindmapService mindmapService; + + @Autowired + @Qualifier("mindmapMessageService") + private MessageService messageService; + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + * toolContentID will be passed in. This will be used to retrieve content for this tool. + */ + @RequestMapping("/authoring") + public String unspecified(@ModelAttribute AuthoringForm authoringForm, HttpServletRequest request, + HttpServletResponse response) { + + // 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.readToolAccessModeAuthorDefaulted(request); + + // retrieving Mindmap with given toolContentID + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + if (mindmap == null) { + mindmap = mindmapService.copyDefaultContent(toolContentID); + mindmap.setCreateDate(new Date()); + mindmapService.saveOrUpdateMindmap(mindmap); + // TODO NOTE: this causes DB orphans when LD not saved. + + // creating default nodes for current mindmap + String rootNodeName = mindmapService.getMindmapMessageService().getMessage("node.root.defaultName"); + String childNodeName1 = mindmapService.getMindmapMessageService().getMessage("node.child1.defaultName"); + String childNodeName2 = mindmapService.getMindmapMessageService().getMessage("node.child2.defaultName"); + + MindmapNode rootMindmapNode = mindmapService.saveMindmapNode(null, null, 1l, rootNodeName, "#ffffff", null, + mindmap, null); + mindmapService.saveOrUpdateMindmapNode(rootMindmapNode); + mindmapService.saveMindmapNode(null, rootMindmapNode, 2l, childNodeName1, "#ffffff", null, mindmap, null); + mindmapService.saveMindmapNode(null, rootMindmapNode, 3l, childNodeName2, "#ffffff", null, mindmap, null); + } + + if (mode.isTeacher()) { + // Set the defineLater flag so that learners cannot use content + // while we are editing. This flag is released when updateContent is called. + mindmap.setDefineLater(true); + mindmapService.saveOrUpdateMindmap(mindmap); + + //audit log the teacher has started editing activity in monitor + mindmapService.auditLogStartEditingActivityInMonitor(toolContentID); + } + + /* Mindmap Attributes */ + request.setAttribute("mindmapId", mindmap.getUid()); + + // Set up the authForm. + updateAuthForm(authoringForm, mindmap); + + // Set up sessionMap + SessionMap map = createSessionMap(mindmap, mode, contentFolderID, toolContentID); + authoringForm.setSessionMapID(map.getSessionID()); + + // add the sessionMap to HTTPSession. + request.getSession().setAttribute(map.getSessionID(), map); + request.setAttribute(MindmapConstants.ATTR_SESSION_MAP, map); + + return "pages/authoring/authoring"; + } + + /** + * Returns the serialized XML of the Mindmap Nodes from Database + */ + @RequestMapping(path = "/setMindmapContentJSON", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String setMindmapContentJSON(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); + List mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapId(mindmapId); + + if (mindmapNodeList != null && mindmapNodeList.size() > 0) { + MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); + + String rootMindmapUser = messageService.getMessage("node.instructor.label"); + + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), + rootMindmapNode.getText(), rootMindmapNode.getColor(), rootMindmapUser, 1)); + NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), + mindmapId, rootNodeModel, null, false, true, false); + + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.set("mindmap", new RootJSON(currentNodeModel, false)); + + return jsonObject.toString(); + } + + return null; + } + + /** + * Saves Mindmap Nodes to Database + */ + @RequestMapping("/updateContent") + public String updateContent(@ModelAttribute AuthoringForm authoringForm, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + // get session map. + SessionMap map = getSessionMap(request, authoringForm); + + // get mindmap content. + Mindmap mindmap = mindmapService.getMindmapByContentId((Long) map.get(AuthoringController.KEY_TOOL_CONTENT_ID)); + + // update mindmap content using form inputs + updateMindmap(mindmap, authoringForm); + + // set the update date + mindmap.setUpdateDate(new Date()); + + // releasing defineLater flag so that learner can start using the tool. + mindmap.setDefineLater(false); + + mindmapService.saveOrUpdateMindmap(mindmap); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // add the sessionMapID to form + authoringForm.setSessionMapID(map.getSessionID()); + + request.setAttribute(MindmapConstants.ATTR_SESSION_MAP, map); + + /* Saving Minmdap Nodes */ + MindmapUser mindmapUser = mindmapService.getUserByUID(mindmap.getCreateBy()); + String mindmapContent = authoringForm.getMindmapContent(); + + NodeModel rootNodeModel = RootJSON.toNodeModel(mindmapContent); + if (rootNodeModel == null) { + String error = new StringBuilder("Unable to save mindmap for authoring. User:") + .append(mindmapUser.getLoginName()).append("(" + mindmapUser.getUserId()) + .append("). No root node. JSON: ").append(mindmapContent).toString(); + throw new IOException(error); + } + + NodeConceptModel nodeConceptModel = rootNodeModel.getConcept(); + List branches = rootNodeModel.getBranch(); + + // saving root Node into database + MindmapNode rootMindmapNode = (MindmapNode) mindmapService.getAuthorRootNodeByMindmapId(mindmap.getUid()) + .get(0); + rootMindmapNode = mindmapService.saveMindmapNode(rootMindmapNode, null, nodeConceptModel.getId(), + nodeConceptModel.getText(), nodeConceptModel.getColor(), mindmapUser, mindmap, null); + + // 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, null); + } + + nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid(); + mindmapService.deleteNodes(nodesToDeleteCondition); + + return "pages/authoring/authoring"; + } + + /** + * Updates Mindmap content using AuthoringForm inputs. + */ + private void updateMindmap(Mindmap mindmap, AuthoringForm authoringForm) { + mindmap.setTitle(authoringForm.getTitle()); + mindmap.setInstructions(authoringForm.getInstructions()); + mindmap.setLockOnFinished(authoringForm.isLockOnFinished()); + mindmap.setMultiUserMode(authoringForm.isMultiUserMode()); + // reflection + mindmap.setReflectOnActivity(authoringForm.isReflectOnActivity()); + mindmap.setReflectInstructions(authoringForm.getReflectInstructions()); + } + + /** + * Updates AuthoringForm using Mindmap content. + */ + private void updateAuthForm(AuthoringForm authoringForm, Mindmap mindmap) { + authoringForm.setTitle(mindmap.getTitle()); + authoringForm.setInstructions(mindmap.getInstructions()); + authoringForm.setLockOnFinished(mindmap.isLockOnFinished()); + authoringForm.setMultiUserMode(mindmap.isMultiUserMode()); + // reflection + authoringForm.setReflectOnActivity(mindmap.isReflectOnActivity()); + authoringForm.setReflectInstructions(mindmap.getReflectInstructions()); + } + + /** + * Updates SessionMap using Mindmap content. + */ + private SessionMap createSessionMap(Mindmap mindmap, ToolAccessMode mode, String contentFolderID, + Long toolContentID) { + + SessionMap map = new SessionMap<>(); + + map.put(AuthoringController.KEY_MODE, mode); + map.put(AuthoringController.KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(AuthoringController.KEY_TOOL_CONTENT_ID, toolContentID); + + return map; + } + + /** + * Retrieve the SessionMap from the HttpSession. + */ + private SessionMap getSessionMap(HttpServletRequest request, AuthoringForm authoringForm) { + return (SessionMap) request.getSession().getAttribute(authoringForm.getSessionMapID()); + } +} Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/ClearSessionController.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,71 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishController; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.WebApplicationContext; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + * + * + * + * + * @version $Revision$ + */ +@Controller +public class ClearSessionController extends LamsAuthoringFinishController { + private static Logger logger = Logger.getLogger(ClearSessionController.class.getName()); + + @Autowired + private WebApplicationContext applicationContext; + + @RequestMapping("/clearsession") + public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException { + super.execute(request, response, applicationContext); + } + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + session.removeAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG); + if (mode.isAuthor()) { + ClearSessionController.logger.debug("In Author mode"); + session.removeAttribute(customiseSessionID); + } + } +} Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningController.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningController.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningController.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,680 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.ToolSessionManager; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.mindmap.dto.IdeaJSON; +import org.lamsfoundation.lams.tool.mindmap.dto.MindmapDTO; +import org.lamsfoundation.lams.tool.mindmap.dto.NotifyResponseJSON; +import org.lamsfoundation.lams.tool.mindmap.dto.RootJSON; +import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapNode; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapRequest; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapSession; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapUser; +import org.lamsfoundation.lams.tool.mindmap.service.IMindmapService; +import org.lamsfoundation.lams.tool.mindmap.service.MindmapServiceProxy; +import org.lamsfoundation.lams.tool.mindmap.util.MindmapConstants; +import org.lamsfoundation.lams.tool.mindmap.util.MindmapException; +import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeConceptModel; +import org.lamsfoundation.lams.tool.mindmap.util.xmlmodel.NodeModel; +import org.lamsfoundation.lams.tool.mindmap.web.forms.LearningForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.JsonUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.WebApplicationContext; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * @author Ruslan Kazakov + * @version 1.0.1 + * + * + * + * + * + * + */ +@Controller +@RequestMapping("/learning") +public class LearningController { + + private static Logger log = Logger.getLogger(LearningController.class); + private static final boolean MODE_OPTIONAL = false; + + private static final String REQUEST_JSON_TYPE = "type"; // Expected to be int: 0 - delete; 1 - create node; 2 - change color; 3 - change text + private static final String REQUEST_JSON_REQUEST_ID = "requestId"; // Expected to be long + private static final String REQUEST_JSON_PARENT_NODE_ID = "parentId"; // Expected to be long + + @Autowired + @Qualifier("mindmapService") + private IMindmapService mindmapService; + + @Autowired + @Qualifier("mindmapMessageService") + private MessageService messageService; + + @Autowired + private WebApplicationContext applicationContext; + + /** + * Default action on page load. Clones Mindmap Nodes for each Learner in single-user mode. Uses shared (runtime + * created in CopyToolContent method) Mindmap Nodes in multi-user mode. + */ + @RequestMapping("/learning") + public String unspecified(@ModelAttribute LearningForm learningForm, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // 'toolSessionID' and 'mode' parameters are expected to be present. + // TODO need to catch exceptions and handle errors. + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, + LearningController.MODE_OPTIONAL); + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + // Retrieve the session and content. + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionID); + if (mindmapSession == null) { + throw new MindmapException("Cannot retrieve session with toolSessionID: " + toolSessionID); + } + + Mindmap mindmap = mindmapSession.getMindmap(); + + // check defineLater + if (mindmap.isDefineLater()) { + return "pages/learning/defineLater"; + } + + // set mode, toolSessionID and MindmapDTO + request.setAttribute("mode", mode.toString()); + learningForm.setToolSessionID(toolSessionID); + + MindmapDTO mindmapDTO = new MindmapDTO(); + mindmapDTO.title = mindmap.getTitle(); + mindmapDTO.instructions = mindmap.getInstructions(); + mindmapDTO.lockOnFinish = mindmap.isLockOnFinished(); + mindmapDTO.multiUserMode = mindmap.isMultiUserMode(); + mindmapDTO.reflectInstructions = mindmap.getReflectInstructions(); + + request.setAttribute("mindmapDTO", mindmapDTO); + + // Set the content in use flag. + if (!mindmap.isContentInUse()) { + mindmap.setContentInUse(new Boolean(true)); + mindmapService.saveOrUpdateMindmap(mindmap); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + applicationContext.getServletContext()); + + HttpSession ss = SessionManager.getSession(); + UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + + // check if there is submission deadline + Date submissionDeadline = mindmap.getSubmissionDeadline(); + if (submissionDeadline != null) { + // store submission deadline to sessionMap + request.setAttribute(MindmapConstants.ATTR_SUBMISSION_DEADLINE, submissionDeadline); + TimeZone learnerTimeZone = userDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); + + // calculate whether submission deadline has passed, and if so forward to "submissionDeadline" + if (currentLearnerDate.after(tzSubmissionDeadline)) { + return "pages/learning/submissionDeadline"; + } + } + + MindmapUser mindmapUser; + if (mode.equals(ToolAccessMode.TEACHER)) { + mindmapUser = mindmapService.getUserByUserIdAndSessionId(userDto.getUserID().longValue(), toolSessionID); + } else { + mindmapUser = getCurrentUser(toolSessionID); + } + + // set readOnly flag. + if (mode.equals(ToolAccessMode.TEACHER) || (mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity())) { + request.setAttribute("contentEditable", false); + } else { + request.setAttribute("contentEditable", true); + } + request.setAttribute("finishedActivity", mindmapUser.isFinishedActivity()); + + // mindmapContentPath Parameter + String mindmapContentPath = Configuration.get(ConfigurationKeys.SERVER_URL) + + "tool/lamind10/learning.do?dispatch=setMindmapContent%26mindmapId=" + mindmap.getUid() + "%26userId=" + + mindmapUser.getUid() + "%26sessionId=" + mindmapSession.getSessionId(); + request.setAttribute("mindmapContentPath", mindmapContentPath); + + // currentMindmapUser Parameter + String currentMindmapUser = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); + request.setAttribute("currentMindmapUser", currentMindmapUser); + + // setting userId for reflection + request.setAttribute("userIdParam", mindmapUser.getUid()); + request.setAttribute("toolContentIdParam", mindmap.getUid()); + request.setAttribute("reflectOnActivity", mindmap.isReflectOnActivity()); + + // 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("sessionId", toolSessionID); + request.setAttribute("multiMode", mindmap.isMultiUserMode()); + + // if not multi-user mode + if (!mindmap.isMultiUserMode()) { + // clonning Mindmap Nodes for every new user + List rootNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); + + if ((rootNodeList == null) || (rootNodeList.size() == 0)) { + MindmapNode fromMindmapNode = (MindmapNode) mindmapService + .getAuthorRootNodeByMindmapId(mindmap.getUid()).get(0); + cloneMindmapNodesForRuntime(fromMindmapNode, null, mindmap, mindmap, mindmapUser, mindmapSession); + } + } else { + // clonning Mindmap Nodes for every new session + List rootNodeList = mindmapService.getAuthorRootNodeBySessionId(toolSessionID); + + if ((rootNodeList == null) || (rootNodeList.size() == 0)) { + MindmapNode fromMindmapNode = (MindmapNode) mindmapService + .getAuthorRootNodeByMindmapId(mindmap.getUid()).get(0); + cloneMindmapNodesForRuntime(fromMindmapNode, null, mindmap, mindmap, null, mindmapSession); + } + + // Using Learner in Monitor mode (for Teachers to participate in multimode) + boolean isMonitor = WebUtil.readBooleanParam(request, "monitor", false); + request.setAttribute("isMonitor", isMonitor); + } + + return "pages/learning/mindmap"; + } + + /** + * Clones Mindmap Nodes for each Learner (used in single-user mode only). + */ + @SuppressWarnings("rawtypes") + public void cloneMindmapNodesForRuntime(MindmapNode fromMindmapNode, MindmapNode toMindmapNode, Mindmap fromContent, + Mindmap toContent, MindmapUser user, MindmapSession session) { + toMindmapNode = mindmapService.saveMindmapNode(null, toMindmapNode, fromMindmapNode.getUniqueId(), + fromMindmapNode.getText(), fromMindmapNode.getColor(), user, toContent, session); + + List childMindmapNodes = mindmapService.getMindmapNodeByParentId(fromMindmapNode.getNodeId(), + fromContent.getUid()); + + if ((childMindmapNodes != null) && (childMindmapNodes.size() > 0)) { + for (Iterator iterator = childMindmapNodes.iterator(); iterator.hasNext();) { + MindmapNode childMindmapNode = (MindmapNode) iterator.next(); + cloneMindmapNodesForRuntime(childMindmapNode, toMindmapNode, fromContent, toContent, user, session); + } + } + } + + /** + * Gets the Notify Requests (Actions) from Flash and returns proper Notify Responses + */ + @RequestMapping(path = "/notifyServerActionJSON", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String notifyServerActionJSON(HttpServletRequest request, HttpServletResponse response) + throws JsonProcessingException, IOException { + Long userId = WebUtil.readLongParam(request, "userId", false); + Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", false); + String requestAction = WebUtil.readStrParam(request, "actionJSON", false); + + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionId); + + ObjectNode notifyRequest = JsonUtil.readObject(requestAction); + int requestType = JsonUtil.optInt(notifyRequest, REQUEST_JSON_TYPE); + + MindmapRequest mindmapRequest = null; + if (notifyRequest.has(REQUEST_JSON_REQUEST_ID)) { + Long lastActionId = WebUtil.readLongParam(request, "lastActionId", false); + mindmapRequest = mindmapService.getRequestByUniqueId( + JsonUtil.optLong(notifyRequest, REQUEST_JSON_REQUEST_ID), userId, mindmapId, lastActionId); + } + + NotifyResponseJSON notifyResponse = null; + + MindmapUser currentUser = mindmapService.getUserByUID(userId); + if (currentUser == null + || (mindmapSession.getMindmap().isLockOnFinished() && currentUser.isFinishedActivity())) { + notifyResponse = new NotifyResponseJSON(0, null, null); + } + + // if request wasn't created before, create it + else if (mindmapRequest == null) { + // getting node to which changes will be applied + MindmapNode mindmapNode = null; + if (notifyRequest.has(IdeaJSON.MAPJS_JSON_ID_KEY) && requestType != 1) { + mindmapNode = mindmapService.getMindmapNodeByUniqueIdSessionId( + JsonUtil.optLong(notifyRequest, IdeaJSON.MAPJS_JSON_ID_KEY), mindmapId, toolSessionId); + if (mindmapNode == null) { + LearningController.log.error("notifyServerAction(): Error finding node!"); + return null; + } + } + + // delete node + if (requestType == 0) { + // if node is created not by author or by other user... cannot delete + if (mindmapNode.getUser() == mindmapService.getUserByUID(userId)) { + + List childNodes = mindmapService.getMindmapNodeByParentIdMindmapIdSessionId(mindmapNode.getNodeId(), + mindmapId, toolSessionId); + + if ((childNodes == null) || (childNodes.size() == 0)) // check if node has any children + { + mindmapService.deleteNodeByUniqueMindmapUser(mindmapNode.getUniqueId(), mindmapId, userId, + mindmapSession.getUid()); + mindmapRequest = saveMindmapRequestJSON(mindmapRequest, requestType, null, + mindmapNode.getUniqueId(), userId, mindmapId, null, toolSessionId); + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), null); + } else { + notifyResponse = new NotifyResponseJSON(0, null, null); + } + } else { + notifyResponse = new NotifyResponseJSON(0, null, null); + } + } + // create node + else if (requestType == 1) { + // no checking... users can create nodes everywhere. + + // node unique ID - keep the biggest out of (next database value, client node). this ensures + // that deletions don't go back and fill holes with nodes that may conflict with something on a client. + Long uniqueId = mindmapService.getNodeLastUniqueIdByMindmapUidSessionId(mindmapId, toolSessionId) + 1; + Long childIdFromRequest = JsonUtil.optLong(notifyRequest, IdeaJSON.MAPJS_JSON_ID_KEY); + if (childIdFromRequest.longValue() > uniqueId.longValue()) { + uniqueId = childIdFromRequest; + } + + Long parentNodeId = JsonUtil.optLong(notifyRequest, REQUEST_JSON_PARENT_NODE_ID); + MindmapNode parentNode = mindmapService.getMindmapNodeByUniqueIdSessionId(parentNodeId, mindmapId, + toolSessionId); + if (parentNode == null) { + LearningController.log.error("notifyServerAction(): Unable to find parent node: " + parentNodeId + + " toolSessionId " + toolSessionId); + } + + mindmapService.saveMindmapNode(null, parentNode, uniqueId, + JsonUtil.optString(notifyRequest, IdeaJSON.MAPJS_JSON_TITLE_KEY), + JsonUtil.optString(notifyRequest, IdeaJSON.MAPJS_JSON_BACKGROUND_COLOR_KEY), + mindmapService.getUserByUID(userId), mindmapService.getMindmapByUid(mindmapId), mindmapSession); + + mindmapRequest = saveMindmapRequestJSON(mindmapRequest, requestType, null, parentNodeId, userId, + mindmapId, uniqueId, toolSessionId); + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), uniqueId); + } + // change color + else if (requestType == 2) { + if (mindmapNode.getUser() == mindmapService.getUserByUID(userId)) { + mindmapNode.setColor(JsonUtil.optString(notifyRequest, IdeaJSON.MAPJS_JSON_BACKGROUND_COLOR_KEY)); + mindmapNode.setUser(mindmapService.getUserByUID(userId)); + mindmapService.saveOrUpdateMindmapNode(mindmapNode); + mindmapRequest = saveMindmapRequestJSON(mindmapRequest, requestType, null, + mindmapNode.getUniqueId(), userId, mindmapId, null, toolSessionId); + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), null); + } else { + notifyResponse = new NotifyResponseJSON(0, null, null); + } + } + // change text + else if (requestType == 3) { + if (mindmapNode.getUser() == mindmapService.getUserByUID(userId)) { + mindmapNode.setText(JsonUtil.optString(notifyRequest, IdeaJSON.MAPJS_JSON_TITLE_KEY)); + mindmapNode.setUser(mindmapService.getUserByUID(userId)); + mindmapService.saveOrUpdateMindmapNode(mindmapNode); + mindmapRequest = saveMindmapRequestJSON(mindmapRequest, requestType, null, + mindmapNode.getUniqueId(), userId, mindmapId, null, toolSessionId); + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), null); + } else { + notifyResponse = new NotifyResponseJSON(0, null, null); + } + } + } else { + if (requestType == 1) { + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), + mindmapRequest.getNodeChildId()); + } else { + notifyResponse = new NotifyResponseJSON(1, mindmapRequest.getGlobalId(), null); + } + } + + return notifyResponse.toString(); + } + + /** + * Saves Notify Requests to database + */ + private MindmapRequest saveMindmapRequestJSON(MindmapRequest mindmapRequest, int requestType, Long requestId, + Long nodeId, Long userId, Long mindmapId, Long nodeChildId, Long sessionId) { + mindmapRequest = new MindmapRequest(); + mindmapRequest.setType(requestType); + mindmapRequest.setUniqueId(requestId); + // incrementing lastRequestId + mindmapRequest.setGlobalId(mindmapService.getLastGlobalIdByMindmapId(mindmapId, sessionId) + 1); + mindmapRequest.setUser(mindmapService.getUserByUID(userId)); + mindmapRequest.setMindmap(mindmapService.getMindmapByUid(mindmapId)); + mindmapRequest.setNodeId(nodeId); + mindmapRequest.setNodeChildId(nodeChildId); // nodeChildId + mindmapService.saveOrUpdateMindmapRequest(mindmapRequest); + return mindmapRequest; + } + + /** + * Returns the serialized JSON of the Mindmap Nodes from Database + */ + @RequestMapping(path = "/setMindmapContentJSON", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String setMindmapContentJSON(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long mindmapId = WebUtil.readLongParam(request, "mindmapId", false); + Long toolSessionId = WebUtil.readLongParam(request, "sessionId", true); + Mindmap mindmap = mindmapService.getMindmapByUid(mindmapId); + + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, + LearningController.MODE_OPTIONAL); + boolean monitoring = mode.equals(ToolAccessMode.TEACHER); + + // In monitoring we do not need the user when accessing multi mode mindmap + Long userId = WebUtil.readLongParam(request, "userId", true); + if (userId == null && !(monitoring && mindmap.isMultiUserMode())) { + log.error( + "Unable to display mindmap as no user id is supplied. Can only skip user id if this is monitoring and multiuser mode."); + return null; + } + + MindmapUser mindmapUser = null; + if (userId != null) { + mindmapUser = mindmapService.getUserByUID(userId); + } + + List mindmapNodeList = null; + if (mindmap.isMultiUserMode()) { + mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmapId, toolSessionId); + } else { + mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmapId, userId); + } + + if ((mindmapNodeList != null) && (mindmapNodeList.size() > 0)) { + MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); + + String mindmapUserName = null; + if (rootMindmapNode.getUser() == null) { + mindmapUserName = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); + } else { + mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " + + rootMindmapNode.getUser().getLastName(); + } + + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), + rootMindmapNode.getText(), rootMindmapNode.getColor(), mindmapUserName, 0)); + + NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), + mindmapId, rootNodeModel, mindmapUser, monitoring, false, + mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity()); + + ObjectNode jsonObject = JsonNodeFactory.instance.objectNode(); + jsonObject.set("mindmap", new RootJSON(currentNodeModel, mindmap.isMultiUserMode())); + // adding lastActionId + if (mindmap.isMultiUserMode()) { + Long lastActionId = mindmapService.getLastGlobalIdByMindmapId(mindmap.getUid(), toolSessionId); + jsonObject.put("lastActionId", lastActionId); + } + + return jsonObject.toString(); + } + return null; + } + + @RequestMapping(path = "/saveLastMindmapChanges", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String saveLastMindmapChanges(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolContentId = WebUtil.readLongParam(request, "mindmapId", false); + Long toolSessionId = WebUtil.readLongParam(request, "toolSessionID", true); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionId); + + NotifyResponseJSON responseJSON = null; + // Saving Mindmap Nodes + if (!mindmap.isMultiUserMode()) { + // getting JSON from Mindmup + String mindmapContent = WebUtil.readStrParam(request, "content", false); + Long rootNodeId = saveMapJsJSON(mindmap, mindmapUser, mindmapContent, mindmapSession); + responseJSON = new NotifyResponseJSON(rootNodeId != null ? 1 : 0, null, rootNodeId); + } else { + responseJSON = new NotifyResponseJSON(0, null, 0L); + } + + return responseJSON.toString(); + } + + private Long saveMapJsJSON(Mindmap mindmap, MindmapUser mindmapUser, String mindmapContent, + MindmapSession mindmapSession) throws IOException { + + NodeModel rootNodeModel = RootJSON.toNodeModel(mindmapContent); + if (rootNodeModel == null) { + String error = new StringBuilder("Unable to save mindmap for session:") + .append(mindmapSession.getSessionName()).append("(").append(mindmapSession.getSessionId()) + .append(") user:").append(mindmapUser.getLoginName()).append("(" + mindmapUser.getUserId()) + .append("). No root node. JSON: ").append(mindmapContent).toString(); + throw new IOException(error); + } + + 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, mindmapSession); + + // 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, mindmapSession); + } + + nodesToDeleteCondition += mindmapService.getNodesToDeleteCondition() + " and mindmap_id = " + mindmap.getUid() + + " and user_id = " + mindmapUser.getUid(); + mindmapService.deleteNodes(nodesToDeleteCondition); + + return rootMindmapNode.getNodeId(); + } + + /** + * Returns current learner + */ + private MindmapUser getCurrentUser(Long toolSessionId) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + // attempt to retrieve user using userId and toolSessionId + MindmapUser mindmapUser = mindmapService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), + toolSessionId); + + if (mindmapUser == null) { + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionId); + mindmapUser = mindmapService.createMindmapUser(user, mindmapSession); + } + + return mindmapUser; + } + + /** + * Saving Mindmap nodes and proceed to reflection. + */ + @RequestMapping("/reflect") + public String reflect(@ModelAttribute LearningForm learningForm, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + Long userId = WebUtil.readLongParam(request, "userId", false); + Long toolContentId = WebUtil.readLongParam(request, "toolContentId", false); + + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + Mindmap mindmap = mindmapService.getMindmapByUid(toolContentId); + MindmapSession mindmapSession = mindmapUser.getMindmapSession(); + + request.setAttribute("reflectTitle", mindmap.getTitle()); + request.setAttribute("reflectInstructions", mindmap.getReflectInstructions()); + + if (mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity()) { + request.setAttribute("contentEditable", false); + } else { + request.setAttribute("contentEditable", true); + } + + // Saving Mindmap Nodes + if (!mindmap.isMultiUserMode() && !StringUtils.isBlank(learningForm.getMindmapContent())) { + saveMapJsJSON(mindmap, mindmapUser, learningForm.getMindmapContent(), mindmapSession); + } + + // Reflection + NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); + if (entry != null) { + request.setAttribute("reflectEntry", entry.getEntry()); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(mindmapSession.getSessionId(), request, + applicationContext.getServletContext()); + + return "pages/learning/reflect"; + } + + /** + * Finish Mindmap Activity and save reflection if appropriate. + */ + @RequestMapping("/finishActivity") + public String finishActivity(@ModelAttribute LearningForm learningForm, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID"); + MindmapUser mindmapUser = getCurrentUser(toolSessionID); + + // Retrieve the session and content + MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionID); + if (mindmapSession == null) { + throw new MindmapException("Cannot retrieve session with toolSessionID" + toolSessionID); + } + Mindmap mindmap = mindmapSession.getMindmap(); + + // if locked do not update anything - do not want to risk having accidently changed the mindmap + boolean contentLocked = mindmap.isLockOnFinished() && mindmapUser.isFinishedActivity(); + + if (mindmapUser != null) { + if (!contentLocked) { + + mindmapUser.setFinishedActivity(true); + mindmapService.saveOrUpdateMindmapUser(mindmapUser); + + // 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()); + mindmapUser.setEntryUID(entryUID); + mindmapService.saveOrUpdateMindmapUser(mindmapUser); + } else { + // update existing entry + entry.setEntry(learningForm.getEntryText()); + entry.setLastModified(new Date()); + mindmapService.updateEntry(entry); + } + } else { + if (!mindmap.isMultiUserMode() && !StringUtils.isBlank(learningForm.getMindmapContent())) { + saveMapJsJSON(mindmap, mindmapUser, learningForm.getMindmapContent(), mindmapSession); + } + } + } + + } else { + LearningController.log.error( + "finishActivity(): couldn't find MindmapUser is null " + " and toolSessionID: " + toolSessionID); + } + + ToolSessionManager sessionMgrService = MindmapServiceProxy + .getMindmapSessionManager(applicationContext.getServletContext()); + + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, mindmapUser.getUserId()); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new MindmapException(e); + } catch (ToolException e) { + throw new MindmapException(e); + } catch (IOException e) { + throw new MindmapException(e); + } + + return null; + } + +} Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningWebsocketServer.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningWebsocketServer.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/LearningWebsocketServer.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,291 @@ +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import javax.websocket.CloseReason; +import javax.websocket.CloseReason.CloseCodes; +import javax.websocket.OnClose; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.ServerEndpoint; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.mindmap.dto.NotifyActionJSON; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapNode; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapRequest; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapSession; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapUser; +import org.lamsfoundation.lams.tool.mindmap.service.IMindmapService; +import org.lamsfoundation.lams.tool.mindmap.service.MindmapServiceProxy; +import org.lamsfoundation.lams.util.hibernate.HibernateSessionManager; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * Sends Node changes to Learners. + * + * @author Fiona Malikoff, based on code from Marcin Cieslak + */ +@ServerEndpoint("/learningWebsocket") +public class LearningWebsocketServer { + + /** + * A singleton which updates Learners with node changes. + */ + private static class SendWorker extends Thread { + private boolean stopFlag = false; + // how ofter the thread runs + private static final long CHECK_INTERVAL = 3000; + + @Override + public void run() { + while (!stopFlag) { + try { + // websocket communication bypasses standard HTTP filters, so Hibernate session needs to be initialised manually + HibernateSessionManager.openSession(); + Iterator>> entryIterator = LearningWebsocketServer.websockets.entrySet() + .iterator(); + // go through activities and update registered learners with reports and vote count + while (entryIterator.hasNext()) { + Entry> entry = entryIterator.next(); + Long toolSessionId = entry.getKey(); + // if all learners left the activity, remove the obsolete mapping + Set sessionWebsockets = entry.getValue(); + if (sessionWebsockets.isEmpty()) { + entryIterator.remove(); + LearningWebsocketServer.globalIdCache.remove(toolSessionId); + continue; + } + SendWorker.send(toolSessionId, null, null); + } + } catch (Exception e) { + // error caught, but carry on + LearningWebsocketServer.log.error("Error in Mindmap worker thread", e); + } finally { + HibernateSessionManager.closeSession(); + try { + Thread.sleep(SendWorker.CHECK_INTERVAL); + } catch (InterruptedException e) { + LearningWebsocketServer.log.warn("Stopping Mindmap worker thread"); + stopFlag = true; + } + } + } + } + + /** + * Feeds websockets with reports and votes. + */ + private static void send(Long toolSessionId, Session newWebsocket, Long userLastGlobalId) throws IOException { + Long previousGlobalId = LearningWebsocketServer.globalIdCache.get(toolSessionId); + if (previousGlobalId == null) { + // first time run, create the cache + previousGlobalId = 0L; + LearningWebsocketServer.globalIdCache.put(toolSessionId, previousGlobalId); + } + + MindmapSession mindmapSession = LearningWebsocketServer.getMindmapService() + .getSessionBySessionId(toolSessionId); + + ObjectNode responseJSON = null; + // new user joined. Send everything from their initial globalId sent when the websocket was created + if (newWebsocket != null) { + responseJSON = SendWorker.getServerActionJSON(mindmapSession.getMindmap().getUid(), + mindmapSession.getSessionId(), userLastGlobalId); + newWebsocket.getBasicRemote().sendText(responseJSON.toString()); + + // send all requests since previousGlobalId + } else { + Long currentMaxGlobalId = LearningWebsocketServer.getMindmapService().getLastGlobalIdByMindmapId( + mindmapSession.getMindmap().getUid(), mindmapSession.getSessionId()); + if (currentMaxGlobalId > previousGlobalId) { + responseJSON = SendWorker.getServerActionJSON(mindmapSession.getMindmap().getUid(), + mindmapSession.getSessionId(), previousGlobalId); + LearningWebsocketServer.globalIdCache.put(toolSessionId, currentMaxGlobalId); + Set sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId); + for (Session websocket : sessionWebsockets) { + websocket.getBasicRemote().sendText(responseJSON.toString()); + } + } + } + } + + private static final String RESPONSE_JSON_ACTIONS = "actions"; + + private static ObjectNode getServerActionJSON(Long mindmapId, Long toolSessionId, Long lastActionId) { + + ObjectNode sendObjectNode = JsonNodeFactory.instance.objectNode(); + ArrayNode actions = JsonNodeFactory.instance.arrayNode(); + sendObjectNode.set(RESPONSE_JSON_ACTIONS, actions); + + List requestsList = mindmapService.getLastRequestsAfterGlobalId(lastActionId, mindmapId, + toolSessionId); + for (Iterator iterator = requestsList.iterator(); iterator.hasNext();) { + MindmapRequest mindmapRequest = iterator.next(); + int requestType = mindmapRequest.getType(); + + ObjectNode notifyRequestModel = null; + MindmapNode mindmapNode = null; + MindmapNode childMindmapNode = null; + if ((requestType != 0)) { + + mindmapNode = mindmapService.getMindmapNodeByUniqueIdSessionId(mindmapRequest.getNodeId(), + mindmapId, toolSessionId); + if (mindmapNode == null) { + LearningWebsocketServer.log.error( + "getServerActionJSON(): Error finding node while sending data about adding child, changing text or color. Cannot send request to clients. Request details:" + + mindmapRequest); + continue; + } + + if (requestType == 1) { + childMindmapNode = mindmapService.getMindmapNodeByUniqueIdSessionId( + mindmapRequest.getNodeChildId(), mindmapId, toolSessionId); + if (childMindmapNode == null) { + LearningWebsocketServer.log.error( + "pollServerAction(): Error finding node while sending data about creating a child node. Cannot send request to clients. Cannot send request to clients. Request details:" + + mindmapRequest); + continue; + } + } + } + + // delete node + if (requestType == 0) { + notifyRequestModel = new NotifyActionJSON(mindmapRequest.getGlobalId(), mindmapRequest.getNodeId(), + mindmapRequest.getType(), null, null, null, null); + } + // create node + else if (requestType == 1) { + String creator = null; + MindmapUser mindmapUser = childMindmapNode.getUser(); + if (mindmapUser != null) { + creator = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); + } else { + creator = "Student"; + } + notifyRequestModel = new NotifyActionJSON(mindmapRequest.getGlobalId(), mindmapRequest.getNodeId(), + mindmapRequest.getType(), mindmapRequest.getNodeChildId(), childMindmapNode.getText(), + childMindmapNode.getColor(), creator); + } + // change color + else if (requestType == 2) { + notifyRequestModel = new NotifyActionJSON(mindmapRequest.getGlobalId(), mindmapRequest.getNodeId(), + mindmapRequest.getType(), null, null, mindmapNode.getColor(), null); + } + // change text + else if (requestType == 3) { + notifyRequestModel = new NotifyActionJSON(mindmapRequest.getGlobalId(), mindmapRequest.getNodeId(), + mindmapRequest.getType(), null, mindmapNode.getText(), null, null); + } + + actions.add(notifyRequestModel); + } + + return sendObjectNode; + } + } + + private static Logger log = Logger.getLogger(LearningWebsocketServer.class); + + private static IMindmapService mindmapService; + + private static final SendWorker sendWorker = new SendWorker(); + // maps toolSessionId -> cached session data + private static final Map globalIdCache = new ConcurrentHashMap<>(); + private static final Map> websockets = new ConcurrentHashMap<>(); + + static { + // run the singleton thread + LearningWebsocketServer.sendWorker.start(); + } + + /** + * Registeres the Learner for processing by SendWorker. + */ + @OnOpen + public void registerUser(Session websocket) throws IOException { + Long toolSessionId = Long + .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); + Long lastActionId = Long.valueOf(websocket.getRequestParameterMap().get("lastActionId").get(0)); + Set sessionWebsockets = LearningWebsocketServer.websockets.get(toolSessionId); + if (sessionWebsockets == null) { + sessionWebsockets = ConcurrentHashMap.newKeySet(); + LearningWebsocketServer.websockets.put(toolSessionId, sessionWebsockets); + } + sessionWebsockets.add(websocket); + + if (LearningWebsocketServer.log.isDebugEnabled()) { + LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName() + + " entered Mindmap with toolSessionId: " + toolSessionId + " lastActionId: " + lastActionId); + } + + new Thread(() -> { + try { + HibernateSessionManager.openSession(); + SendWorker.send(toolSessionId, websocket, lastActionId); + } catch (Exception e) { + log.error("Error while sending messages", e); + } finally { + HibernateSessionManager.closeSession(); + } + }).start(); + } + + /** + * When user leaves the activity. + */ + @OnClose + public void unregisterUser(Session websocket, CloseReason reason) { + Long toolSessionId = Long + .valueOf(websocket.getRequestParameterMap().get(AttributeNames.PARAM_TOOL_SESSION_ID).get(0)); + LearningWebsocketServer.websockets.get(toolSessionId).remove(websocket); + + if (LearningWebsocketServer.log.isDebugEnabled()) { + // If there was something wrong with the connection, put it into logs. + LearningWebsocketServer.log.debug("User " + websocket.getUserPrincipal().getName() + + " left Mindmap with Tool Session ID: " + toolSessionId + + (!(reason.getCloseCode().equals(CloseCodes.GOING_AWAY) + || reason.getCloseCode().equals(CloseCodes.NORMAL_CLOSURE)) + ? ". Abnormal close. Code: " + reason.getCloseCode() + ". Reason: " + + reason.getReasonPhrase() + : "")); + } + } + + /** + * Receives a message sent by Learner via a websocket. + */ + @OnMessage + public void receiveRequest(String input, Session websocket) { + if (StringUtils.isBlank(input)) { + return; + } + if (input.equalsIgnoreCase("ping")) { + // just a ping every few minutes + return; + } + log.warn("Unexpected request received by Mindmap websocket. Message is being ignored. Message was: " + input); + } + + private static IMindmapService getMindmapService() { + if (LearningWebsocketServer.mindmapService == null) { + LearningWebsocketServer.mindmapService = MindmapServiceProxy + .getMindmapService(SessionManager.getServletContext()); + } + return LearningWebsocketServer.mindmapService; + } + +} \ No newline at end of file Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/MonitoringController.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/MonitoringController.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,188 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.mindmap.dto.MindmapDTO; +import org.lamsfoundation.lams.tool.mindmap.dto.MindmapUserDTO; +import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; +import org.lamsfoundation.lams.tool.mindmap.model.MindmapUser; +import org.lamsfoundation.lams.tool.mindmap.service.IMindmapService; +import org.lamsfoundation.lams.tool.mindmap.util.MindmapConstants; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author Ruslan Kazakov + * @version 1.0.1 + * + * + * + * + * + */ +@Controller +@RequestMapping("/monitoring") +public class MonitoringController { + + private static Logger log = Logger.getLogger(MonitoringController.class); + + @Autowired + @Qualifier("mindmapService") + private IMindmapService mindmapService; + + /** + * Default action on page load + */ + @RequestMapping("/monitoring") + public String unspecified(HttpServletRequest request, HttpServletResponse response) { + + 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) { + log.error("unspecified(): Mindmap is not found!"); + return null; + } + + boolean isGroupedActivity = mindmapService.isGroupedActivity(toolContentID); + MindmapDTO mindmapDTO = new MindmapDTO(mindmap); + + Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); + mindmapDTO.setCurrentTab(currentTab); + + request.setAttribute("mindmapDTO", mindmapDTO); + request.setAttribute("contentFolderID", contentFolderID); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + //set SubmissionDeadline, if any + if (mindmap.getSubmissionDeadline() != null) { + Date submissionDeadline = mindmap.getSubmissionDeadline(); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline); + request.setAttribute(MindmapConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); + request.setAttribute(MindmapConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, + DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale())); + } + + return "pages/monitoring/monitoring"; + } + + /** + * Shows Mindmap Nodes for each learner + */ + @RequestMapping("/showMindmap") + public String showMindmap(HttpServletRequest request, HttpServletResponse response) { + + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + request.setAttribute("isMultiUserMode", mindmap.isMultiUserMode()); + request.setAttribute("mindmapId", mindmap.getUid()); + request.setAttribute("sessionId", WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + request.setAttribute("mode", ToolAccessMode.TEACHER); + + if (!mindmap.isMultiUserMode()) { + Long userId = new Long(WebUtil.readLongParam(request, "userUID")); + MindmapUser mindmapUser = mindmapService.getUserByUID(userId); + MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser); + request.setAttribute("userDTO", userDTO); + request.setAttribute("userId", mindmapUser.getUid()); + } + + return "pages/monitoring/mindmapDisplay"; + } + + /** + * Shows Notebook reflection that Learner has done. + */ + @RequestMapping("/reflect") + public String reflect(HttpServletRequest request, HttpServletResponse response) { + + 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()); + request.setAttribute("mode", ToolAccessMode.TEACHER); + + // Reflection + NotebookEntry entry = mindmapService.getEntry(mindmapUser.getEntryUID()); + if (entry != null) { + request.setAttribute("reflectEntry", entry.getEntry()); + } + + return "pages/monitoring/reflect"; + } + + /** + * Set Submission Deadline + */ + @RequestMapping(path = "setSubmissionDeadline", produces = MediaType.TEXT_PLAIN_VALUE) + @ResponseBody + public String setSubmissionDeadline(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Mindmap mindmap = mindmapService.getMindmapByContentId(contentID); + + Long dateParameter = WebUtil.readLongParam(request, MindmapConstants.ATTR_SUBMISSION_DEADLINE, true); + Date tzSubmissionDeadline = null; + String formattedDate = ""; + if (dateParameter != null) { + Date submissionDeadline = new Date(dateParameter); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline); + formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale()); + } + mindmap.setSubmissionDeadline(tzSubmissionDeadline); + mindmapService.saveOrUpdateMindmap(mindmap); + return formattedDate; + } + +} Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/PedagogicalPlannerController.java =================================================================== diff -u --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/PedagogicalPlannerController.java (revision 0) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/controller/PedagogicalPlannerController.java (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,98 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.mindmap.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; +import org.lamsfoundation.lams.tool.mindmap.service.IMindmapService; +import org.lamsfoundation.lams.tool.mindmap.web.forms.MindmapPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author + * @version + * + * + * + * + * + */ +@Controller +@RequestMapping("/pedagogicalPlanner") +public class PedagogicalPlannerController { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerController.class); + + @Autowired + @Qualifier("mindmapService") + private IMindmapService mindmapService; + + @Autowired + @Qualifier("mindmapMessageService") + private MessageService messageService; + + @RequestMapping("/initPedagogicalPlannerForm") + public String initPedagogicalPlannerForm(@ModelAttribute MindmapPedagogicalPlannerForm plannerForm, + HttpServletRequest request, HttpServletResponse response) { + + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + plannerForm.fillForm(mindmap); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return "pages/authoring/pedagogicalPlannerForm"; + + } + + @RequestMapping("/saveOrUpdatePedagogicalPlannerForm") + public String saveOrUpdatePedagogicalPlannerForm(@ModelAttribute MindmapPedagogicalPlannerForm plannerForm, + HttpServletRequest request, HttpServletResponse response) throws IOException { + + MultiValueMap errorMap = plannerForm.validate(messageService); + if (errorMap.isEmpty()) { + String instructions = plannerForm.getInstructions(); + Long toolContentID = plannerForm.getToolContentID(); + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + mindmap.setInstructions(instructions); + mindmapService.saveOrUpdateMindmap(mindmap); + } else { + request.setAttribute("errorMap", errorMap); + } + return "pages/authoring/pedagogicalPlannerForm"; + } + +} Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/AuthoringForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -21,23 +21,19 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.mindmap.web.forms; import javax.servlet.http.HttpServletRequest; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; /** * */ -public class AuthoringForm extends ActionForm { +public class AuthoringForm { private static final long serialVersionUID = 3950453134542135495L; @@ -54,12 +50,12 @@ private boolean reflectOnActivity; private String reflectInstructions; - @Override - public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { - ActionErrors ac = new ActionErrors(); - ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); + public MultiValueMap validate(MessageService messageService, HttpServletRequest arg1) { - return ac; + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + errorMap.add("GLOBAL", messageService.getMessage("this is an error")); + + return errorMap; } public String getSessionMapID() { Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/LearningForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/LearningForm.java (.../LearningForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/LearningForm.java (.../LearningForm.java) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -21,18 +21,14 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.mindmap.web.forms; -import org.apache.struts.action.ActionForm; - /** * @author Anthony Sukkar * * */ -public class LearningForm extends ActionForm { +public class LearningForm { private static final long serialVersionUID = -4728946254882237144L; Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MindmapPedagogicalPlannerForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MindmapPedagogicalPlannerForm.java (.../MindmapPedagogicalPlannerForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MindmapPedagogicalPlannerForm.java (.../MindmapPedagogicalPlannerForm.java) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -20,16 +20,15 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.mindmap.web.forms; import org.lamsfoundation.lams.tool.mindmap.model.Mindmap; -import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivitySpringForm; /** * */ -public class MindmapPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { +public class MindmapPedagogicalPlannerForm extends PedagogicalPlannerActivitySpringForm { String instructions; String contentFolderID; Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -21,16 +21,12 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.mindmap.web.forms; -import org.apache.struts.action.ActionForm; - /** * */ -public class MonitoringForm extends ActionForm { +public class MonitoringForm { private static final long serialVersionUID = 9096908688391850595L; Index: lams_tool_mindmap/web/WEB-INF/spring-servlet.xml =================================================================== diff -u --- lams_tool_mindmap/web/WEB-INF/spring-servlet.xml (revision 0) +++ lams_tool_mindmap/web/WEB-INF/spring-servlet.xml (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file Index: lams_tool_mindmap/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -32,7 +32,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ attribute name="formID" required="true" rtexprvalue="true" %> @@ -123,11 +122,11 @@ } \ No newline at end of file Index: lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -8,9 +8,9 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ attribute name="criterias" required="true" rtexprvalue="true" type="java.util.Collection" %> @@ -284,42 +284,38 @@ - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + + 1 + + + + + + + + + + - - - - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + + + + + + + + + + + + Index: lams_tool_mindmap/web/WEB-INF/tags/CommentsAuthor.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -42,23 +42,21 @@
-     -   +     +  
Index: lams_tool_mindmap/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -4,6 +4,7 @@ <%@ taglib uri="tags-lams" prefix="lams"%> <%@ attribute name="type" required="true" rtexprvalue="true"%> +<%@ attribute name="formID" required="false" rtexprvalue="true"%> <%@ attribute name="style" required="false" rtexprvalue="true"%> <%@ attribute name="title" required="false" rtexprvalue="true"%> <%@ attribute name="titleHelpURL" required="false" rtexprvalue="true"%> @@ -88,8 +89,8 @@ - - + + ${toolForm.toolSessionID} @@ -434,4 +435,4 @@
- + \ No newline at end of file Index: lams_tool_mindmap/web/WEB-INF/tags/Rating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_mindmap/web/WEB-INF/tags/StyledRating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_mindmap/web/WEB-INF/tags/TabBody.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -34,7 +34,6 @@ <%@ attribute name="titleKey" required="false" rtexprvalue="true"%> <%@ attribute name="page" required="false" rtexprvalue="true"%> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-bean" prefix="bean"%> Index: lams_tool_mindmap/web/WEB-INF/tags/TabBodyArea.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -30,7 +30,6 @@ %> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-bean" prefix="bean"%>
Index: lams_tool_mindmap/web/WEB-INF/tags/TextSearch.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -32,12 +32,11 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ taglib uri="tags-lams" prefix="lams" %> <%-- Required attributes --%> <%@ attribute name="sessionMapID" required="true" rtexprvalue="true" %> -<%@ attribute name="wrapInFormTag" required="true" rtexprvalue="true" %> <%-- Optional attributes --%> <%@ attribute name="action" required="false" rtexprvalue="true" %> @@ -53,10 +52,10 @@ <%-- Default value for message key --%> - + - + @@ -85,52 +84,40 @@ - -
- - -

- - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- - - - - - - - - + +

+ + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
\ No newline at end of file Index: lams_tool_mindmap/web/WEB-INF/tiles-defs.xml =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/tiles-defs.xml (.../tiles-defs.xml) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/tiles-defs.xml (.../tiles-defs.xml) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -91,7 +91,9 @@ - + Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-bean-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-bean.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-html-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-html.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-logic-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-logic.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-nested.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-tiles-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/tlds/struts/struts-tiles.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/validation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ebe9a494826fab1aebb345e6801ad512abb52416 refers to a dead (removed) revision in file `lams_tool_mindmap/web/WEB-INF/validator-rules.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_mindmap/web/WEB-INF/web.xml =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/WEB-INF/web.xml (.../web.xml) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/WEB-INF/web.xml (.../web.xml) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -66,34 +66,20 @@ /* + + spring + + org.springframework.web.servlet.DispatcherServlet + + 1 + + org.springframework.web.context.ContextLoaderListener - - action - org.apache.struts.action.ActionServlet - - config - /WEB-INF/struts-config.xml - - - debug - 999 - - - detail - 2 - - - validate - true - - 1 - - @@ -125,7 +111,7 @@ - action + spring *.do @@ -154,43 +140,7 @@ - - - - - tags-bean - /WEB-INF/tlds/struts/struts-bean.tld - - - tags-html - /WEB-INF/tlds/struts/struts-html.tld - - - tags-logic - /WEB-INF/tlds/struts/struts-logic.tld - - - tags-tiles - /WEB-INF/tlds/struts/struts-tiles.tld - - - tags-bean-el - /WEB-INF/tlds/struts/struts-bean-el.tld - - - tags-html-el - /WEB-INF/tlds/struts/struts-html-el.tld - - - tags-logic-el - /WEB-INF/tlds/struts/struts-logic-el.tld - - - tags-tiles-el - /WEB-INF/tlds/struts/struts-tiles-el.tld - - Index: lams_tool_mindmap/web/common/mapjs.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/common/mapjs.jsp (.../mapjs.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -33,8 +33,8 @@ mindMupContent = content; $.ajax({ method: "POST", - url: "${url=='author'?'authoring.do':'learning.do'}", - data: { dispatch: "setMindmapContentJSON", mindmapId: "${mindmapId}", userId: "${userId}", + url: "setMindmapContentJSON.do", + data: { mindmapId: "${mindmapId}", userId: "${userId}", sessionId: "${sessionId}", mode: "${mode}" } , dataType: "json", success: function (response) { @@ -160,8 +160,8 @@ $.ajax({ method: "POST", - url: "learning.do", - data: { dispatch: "notifyServerActionJSON", mindmapId: "${mindmapId}", userId: "${userId}", + url: "notifyServerActionJSON.do", + data: { mindmapId: "${mindmapId}", userId: "${userId}", sessionId: "${sessionId}", lastActionId: lastActionId, actionJSON: JSON.stringify(updateRequest) } , dataType: "json", success: function (response) { @@ -370,9 +370,8 @@ disableButtons(); $.ajax({ method: "POST", - url: "learning.do", + url: "saveLastMindmapChanges.do", data: { - dispatch: "saveLastMindmapChanges", mindmapId: "${mindmapId}", userId: "${userId}", toolSessionID: "${sessionId}", Index: lams_tool_mindmap/web/common/messages.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/common/messages.jsp (.../messages.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/common/messages.jsp (.../messages.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,8 +1,12 @@ +<%@include file="/common/taglibs.jsp"%> + <%-- Error Messages --%> - - - -
-
-
-
\ No newline at end of file + + + + + + + + + Index: lams_tool_mindmap/web/common/taglibs.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/common/taglibs.jsp (.../taglibs.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/common/taglibs.jsp (.../taglibs.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,11 +1,7 @@ <%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> -<%@ taglib uri="tags-bean" prefix="bean"%> -<%@ taglib uri="tags-logic" prefix="logic"%> -<%@ taglib uri="tags-tiles" prefix="tiles"%> -<%@ taglib uri="tags-html" prefix="html"%> +<%@ taglib uri="tags-function" prefix="fn" %> <%@ taglib uri="tags-core" prefix="c"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-lams" prefix="lams"%> - - +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> Index: lams_tool_mindmap/web/layouts/learningLayout.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/layouts/learningLayout.jsp (.../learningLayout.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/layouts/learningLayout.jsp (.../learningLayout.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -8,4 +8,4 @@ - + \ No newline at end of file Index: lams_tool_mindmap/web/pages/authoring/advanced.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -6,7 +6,7 @@
@@ -17,21 +17,21 @@
- +
Index: lams_tool_mindmap/web/pages/authoring/authoring.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,64 +1,86 @@ + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.mindmap.util.MindmapConstants"%> - - - + - - - - - - - - - + + - - - - + + + <fmt:message key="activity.title" /> + + - - - - - - - - <%@ include file="/common/messages.jsp"%> - - - - - - + + + + - -
- -
- -
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + <%@ include file="/common/messages.jsp"%> + + + + + + + + +
+ +
+
+
+ + +
+ +
- Index: lams_tool_mindmap/web/pages/authoring/basic.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/authoring/basic.jsp (.../basic.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/authoring/basic.jsp (.../basic.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,22 +1,31 @@ <%@ include file="/common/taglibs.jsp"%> - - - + + + + + + + + + + + +
- +
-
Index: lams_tool_mindmap/web/pages/authoring/pedagogicalPlannerForm.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/authoring/pedagogicalPlannerForm.jsp (.../pedagogicalPlannerForm.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/authoring/pedagogicalPlannerForm.jsp (.../pedagogicalPlannerForm.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -18,20 +18,19 @@ <%@ include file="/common/messages.jsp"%>

- - - - - - + + + + +
-
+ Index: lams_tool_mindmap/web/pages/learning/defineLater.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/learning/defineLater.jsp (.../defineLater.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/learning/defineLater.jsp (.../defineLater.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,11 +1,30 @@ + <%@ include file="/common/taglibs.jsp"%> - - - - - - + + + + + + + <fmt:message key="activity.title" /> + + + + + + + + + + + + + + + + Index: lams_tool_mindmap/web/pages/learning/mindmap.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/learning/mindmap.jsp (.../mindmap.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/learning/mindmap.jsp (.../mindmap.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,124 +1,132 @@ + <%@ include file="/common/taglibs.jsp"%> - - - - - - - - - - - - function enableButtons() { - $("#spinnerArea_Busy").hide(); - $("#finishButton").removeAttr("disabled"); - } + - function submitForm() { - var mindmapContent = document.getElementById("mindmapContent"); - mindmapContent.value = JSON.stringify(contentAggregate); - var f = document.getElementById('submitForm'); - f.submit(); - } - - - - - - - - - - - - - <%--Advanced settings and notices-----------------------------------%> + + + + -
- -
- - - - - - - - - - - - - + + + + - - - - - - - - -   + + + + + + + + + + + <%--Advanced settings and notices-----------------------------------%> + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +   + + <%--MindMup -----------------------------------%> + <%@ include file="/common/mapjs.jsp"%> + <%-- End MindMup -----------------------------------%> + +
- - - - + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - -
- -
-
+
+ + + + + + Index: lams_tool_mindmap/web/pages/learning/reflect.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/learning/reflect.jsp (.../reflect.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/learning/reflect.jsp (.../reflect.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,54 +1,73 @@ + <%@ include file="/common/taglibs.jsp"%> - - $(document).ready(function() { - document.getElementById("focused").focus(); - }); - - - - - - - - + -
- -
+ + + + + + + + - - - - - - -

- -

-
-
- - - - - - - - - - - - - +
+ +
+ + + + + + + +

+ +

+
+
+ + + + + + + + + + + + + + +
+
-
-
+ + + \ No newline at end of file Index: lams_tool_mindmap/web/pages/learning/submissionDeadline.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,44 +1,63 @@ + <%@ include file="/common/taglibs.jsp"%> - + + + + + - - - - - - - - - - - - - -
- - - - - - - - - - - - -
-
-
+ -
+ + + + + + + + + + + + + + + + + + + + Index: lams_tool_mindmap/web/pages/monitoring/dateRestriction.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/dateRestriction.jsp (.../dateRestriction.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/dateRestriction.jsp (.../dateRestriction.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -14,9 +14,9 @@ - + - + @@ -28,9 +28,9 @@ - + - + \ No newline at end of file Index: lams_tool_mindmap/web/pages/monitoring/editActivity.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -29,16 +29,16 @@

- + - + - +

Index: lams_tool_mindmap/web/pages/monitoring/mindmapDisplay.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/mindmapDisplay.jsp (.../mindmapDisplay.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/mindmapDisplay.jsp (.../mindmapDisplay.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,29 +1,52 @@ <%@ include file="/common/taglibs.jsp"%> - - - + +<%@ include file="/common/taglibs.jsp"%> - - - - + + + + + + + + + + + + + + - - -

-
- -

-
-
+ + + -<%-- Monitor cannot edit mindmaps. mapjs.jsp also uses sessionId and mindmapId --%> -${isMultiUserMode} -false +
+ + + +

+
+ +

+
+
-<%@ include file="/common/mapjs.jsp"%> + <%-- Monitor cannot edit mindmaps. mapjs.jsp also uses sessionId and mindmapId --%> + ${isMultiUserMode} + false + + <%@ include file="/common/mapjs.jsp"%> + + - - button.back - +
+ +
+ +
\ No newline at end of file Index: lams_tool_mindmap/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,19 +1,40 @@ + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.mindmap.util.MindmapConstants"%> - - - - - - + + - - - - - - - + + - + + + + +
+ + + + + + + + + + + + + + + + + + +
+ +
+ +
\ No newline at end of file Index: lams_tool_mindmap/web/pages/monitoring/reflect.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/reflect.jsp (.../reflect.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/reflect.jsp (.../reflect.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -1,22 +1,42 @@ + <%@ include file="/common/taglibs.jsp"%> -

- label.notebookEntry -

+ + + + + - - - - - - - -
- -
- -
- - - button.back - + + + + +
+

+ label.notebookEntry +

+ + + + + + + + +
+ +
+ +
+ + + +
+ +
+ +
Index: lams_tool_mindmap/web/pages/monitoring/summary.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -rebe9a494826fab1aebb345e6801ad512abb52416 --- lams_tool_mindmap/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_mindmap/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision ebe9a494826fab1aebb345e6801ad512abb52416) @@ -13,7 +13,7 @@ lams: '${lams}', submissionDeadline: '${submissionDeadline}', submissionDateString: '${submissionDateString}', - setSubmissionDeadlineUrl: '', + setSubmissionDeadlineUrl: '', toolContentID: '${param.toolContentID}', messageNotification: '', messageRestrictionSet: '', @@ -110,13 +110,13 @@ - + - + @@ -131,7 +131,7 @@ - + @@ -155,7 +155,7 @@ - + @@ -164,7 +164,7 @@ - +