Index: lams_monitoring/web/includes/javascript/monitorLesson.js =================================================================== diff -u -r15045d0b9b0dbb930f42a9da7757207e7a325341 -r2447250db06e37961dc34f540968aa843f4c2e6c --- lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 15045d0b9b0dbb930f42a9da7757207e7a325341) +++ lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 2447250db06e37961dc34f540968aa843f4c2e6c) @@ -644,21 +644,21 @@ }, 'buttons' : [ { - 'text' : LABELS.FORCE_COMPLETE_REMOVE_CONTENT_YES, + 'text' : LABELS.FORCE_COMPLETE_REMOVE_CONTENT_NO, 'click' : function() { - $(this).dialog('close'); + $(this).dialog('close'); forceCompleteExecute($(this).dialog('option', 'learnerId'), - $(this).dialog('option', 'activityId'), - true); + $(this).dialog('option', 'activityId'), + false); } }, { - 'text' : LABELS.FORCE_COMPLETE_REMOVE_CONTENT_NO, + 'text' : LABELS.FORCE_COMPLETE_REMOVE_CONTENT_YES, 'click' : function() { - $(this).dialog('close'); + $(this).dialog('close'); forceCompleteExecute($(this).dialog('option', 'learnerId'), - $(this).dialog('option', 'activityId'), - false); + $(this).dialog('option', 'activityId'), + true); } }, { Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -r2447250db06e37961dc34f540968aa843f4c2e6c --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/service/MindmapService.java (.../MindmapService.java) (revision 2447250db06e37961dc34f540968aa843f4c2e6c) @@ -25,7 +25,6 @@ package org.lamsfoundation.lams.tool.mindmap.service; import java.util.ArrayList; -import java.util.Collections; import java.util.Date; import java.util.Hashtable; import java.util.Iterator; @@ -209,7 +208,7 @@ List rootNode = getAuthorRootNodeByMindmapId(fromContent.getUid()); MindmapNode rootMindmapNode = null; - if (rootNode == null || rootNode.size() == 0) { + if ((rootNode == null) || (rootNode.size() == 0)) { // Create default content rootMindmapNode = saveMindmapNode(null, null, 1l, rootNodeName, "ffffff", null, fromContent, null); saveOrUpdateMindmapNode(rootMindmapNode); @@ -241,7 +240,7 @@ List childMindmapNodes = getMindmapNodeByParentId(fromMindmapNode.getNodeId(), fromContent.getUid()); - if (childMindmapNodes != null && childMindmapNodes.size() > 0) { + if ((childMindmapNodes != null) && (childMindmapNodes.size() > 0)) { for (Iterator iterator = childMindmapNodes.iterator(); iterator.hasNext();) { MindmapNode childMindmapNode = (MindmapNode) iterator.next(); cloneMindmapNodesForRuntime(childMindmapNode, toMindmapNode, fromContent, toContent); @@ -291,7 +290,7 @@ MindmapUser mindmapUser) { List mindmapNodes = getMindmapNodeByParentId(rootNodeId, mindmapId); - if (mindmapNodes != null && mindmapNodes.size() > 0) { + if ((mindmapNodes != null) && (mindmapNodes.size() > 0)) { for (Iterator iterator = mindmapNodes.iterator(); iterator.hasNext();) { MindmapNode mindmapNode = (MindmapNode) iterator.next(); @@ -341,7 +340,7 @@ } MindmapNode currentMindmapNode = null; - if (curMindmapNodeList != null && curMindmapNodeList.size() > 0) { + if ((curMindmapNodeList != null) && (curMindmapNodeList.size() > 0)) { currentMindmapNode = (MindmapNode) curMindmapNodeList.get(0); } nodesToDeleteCondition += " and uniqueId <> " + nodeConceptModel.getId(); @@ -381,13 +380,15 @@ @SuppressWarnings("unchecked") public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException { - if (logger.isDebugEnabled()) { - logger.debug("Removing Mindmap content for user ID " + userId + " and toolContentId " + toolContentId); + if (MindmapService.logger.isDebugEnabled()) { + MindmapService.logger.debug("Removing Mindmap content for user ID " + userId + " and toolContentId " + + toolContentId); } Mindmap mindmap = mindmapDAO.getByContentId(toolContentId); if (mindmap == null) { - logger.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content"); + MindmapService.logger.warn("Did not find activity with toolContentId: " + toolContentId + + " to remove learner content"); return; } @@ -398,7 +399,7 @@ for (MindmapNode node : nodes) { List descendants = new LinkedList(); - if (node.getUser() != null && node.getUser().getUserId().equals(userId.longValue()) + if ((node.getUser() != null) && node.getUser().getUserId().equals(userId.longValue()) && !nodesToDelete.contains(node) && userOwnsChildrenNodes(node, userId.longValue(), descendants)) { // reverse so leafs are first and nodes closer to root are last @@ -412,11 +413,6 @@ mindmapNodeDAO.delete(node); } - List requests = mindmapRequestDAO.getRequestsByUserId(userId.longValue()); - for (MindmapRequest request : requests) { - mindmapRequestDAO.delete(request); - } - for (MindmapSession session : (Set) mindmap.getMindmapSessions()) { MindmapUser user = mindmapUserDAO.getByUserIdAndSessionId(userId.longValue(), session.getSessionId()); if (user != null) { @@ -425,17 +421,19 @@ mindmapDAO.delete(entry); } - mindmapUserDAO.delete(user); + user.setEntryUID(null); + user.setFinishedActivity(false); + mindmapDAO.update(user); } } } - + @SuppressWarnings("unchecked") private boolean userOwnsChildrenNodes(MindmapNode node, Long userId, List descendants) { List children = mindmapNodeDAO.getMindmapNodeByParentIdMindmapIdSessionId(node.getNodeId(), node .getMindmap().getUid(), node.getSession().getSessionId()); for (MindmapNode child : children) { - boolean userOwnsChild = child.getUser() != null && child.getUser().getUserId().equals(userId) + boolean userOwnsChild = (child.getUser() != null) && child.getUser().getUserId().equals(userId) && userOwnsChildrenNodes(child, userId, descendants); if (!userOwnsChild) { return false; @@ -444,15 +442,14 @@ } return true; } - - + /** * Export the XML fragment for the tool's content, along with any files needed for the content. * * @throws DataMissingException - * if no tool content matches the toolSessionId + * if no tool content matches the toolSessionId * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { Mindmap mindmap = mindmapDAO.getByContentId(toolContentId); @@ -466,13 +463,13 @@ // generating Mindmap XML to export String mindmapContent = null; List mindmapNodeList = getAuthorRootNodeByMindmapId(mindmap.getUid()); - if (mindmapNodeList != null && mindmapNodeList.size() > 0) { + if ((mindmapNodeList != null) && (mindmapNodeList.size() > 0)) { MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); String rootMindmapUser = getMindmapMessageService().getMessage("node.instructor.label"); - NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode - .getText(), rootMindmapNode.getColor(), rootMindmapUser, 1)); + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), + rootMindmapNode.getText(), rootMindmapNode.getColor(), rootMindmapUser, 1)); NodeModel currentNodeModel = getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), mindmap.getUid(), rootNodeModel, null); @@ -497,14 +494,14 @@ * Import the XML fragment for the tool's content, along with any files needed for the content. * * @throws ToolException - * if any other error occurs + * if any other error occurs */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { try { // register version filter class exportContentService.registerImportVersionFilterClass(MindmapImportContentVersionFilter.class); - + Object toolPOJO = exportContentService.importToolContent(toolContentPath, mindmapToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof Mindmap)) { @@ -561,11 +558,11 @@ } return getMindmapOutputFactory().getToolOutputDefinitions(mindmap, definitionType); } - + public String getToolContentTitle(Long toolContentId) { return getMindmapByContentId(toolContentId).getTitle(); } - + /* IMindmapService Methods */ public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry) {