Index: lams_tool_forum/.externalToolBuilders/SASS_lams_tool_forum.launch =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/.externalToolBuilders/SASS_lams_tool_forum.launch (.../SASS_lams_tool_forum.launch) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/.externalToolBuilders/SASS_lams_tool_forum.launch (.../SASS_lams_tool_forum.launch) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,16 +1,22 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20180806.sql =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20180806.sql (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/dbupdates/patch20180806.sql (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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/lafrum11/authoring/authoring.do', + learner_url = 'tool/lafrum11/learning/viewForum.do?mode=learner', + learner_preview_url = 'tool/lafrum11/learning/viewForum.do?mode=author', + learner_progress_url = 'tool/lafrum11/learning/viewForum.do?mode=teacher', + monitor_url = 'tool/lafrum11/monitoring/monitoring.do', + pedagogical_planner_url = 'tool/lafrum11/authoring/initPedagogicalPlannerForm.do' +WHERE tool_signature = 'lafrum11'; + +UPDATE lams_tool SET tool_version='20180806' WHERE tool_signature='lafrum11'; + +----------------------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 Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -41,7 +41,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.confidencelevel.ConfidenceLevelDTO; import org.lamsfoundation.lams.contentrepository.ICredentials; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -112,6 +111,7 @@ import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.MessageService; +import org.springframework.web.multipart.MultipartFile; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -405,16 +405,16 @@ } @Override - public Attachment uploadAttachment(FormFile uploadFile) throws PersistenceException { - if ((uploadFile == null) || StringUtils.isEmpty(uploadFile.getFileName())) { + public Attachment uploadAttachment(MultipartFile uploadFile) throws PersistenceException { + if ((uploadFile == null) || StringUtils.isEmpty(uploadFile.getOriginalFilename())) { throw new ForumException("Could not find upload file: " + uploadFile); } NodeKey nodeKey = processFile(uploadFile); Attachment file = new Attachment(); file.setFileUuid(nodeKey.getUuid()); file.setFileVersionId(nodeKey.getVersion()); - file.setFileName(uploadFile.getFileName()); + file.setFileName(uploadFile.getOriginalFilename()); return file; } @@ -678,9 +678,9 @@ messageRating.setUser(imageGalleryUser); messageRating.setMessage(message); } - + // LDEV-4590 Star Rating can never be more than 5 stars - if ( Float.compare(rating, RatingCriteria.RATING_STYLE_STAR_DEFAULT_MAX_AS_FLOAT) > 0) { + if (Float.compare(rating, RatingCriteria.RATING_STYLE_STAR_DEFAULT_MAX_AS_FLOAT) > 0) { rating = RatingCriteria.RATING_STYLE_STAR_DEFAULT_MAX_AS_FLOAT; } messageRating.setRating(rating); @@ -742,10 +742,10 @@ * @throws RepositoryCheckedException * @throws InvalidParameterException */ - private NodeKey processFile(FormFile file) { + private NodeKey processFile(MultipartFile file) { NodeKey node = null; - if ((file != null) && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); + if ((file != null) && !StringUtils.isEmpty(file.getOriginalFilename())) { + String fileName = file.getOriginalFilename(); try { node = getForumToolContentHandler().uploadFile(file.getInputStream(), fileName, file.getContentType()); } catch (InvalidParameterException e) { Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java (.../IForumService.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -26,7 +26,6 @@ import java.util.Collection; import java.util.List; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.logevent.service.ILogEventService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; @@ -41,6 +40,7 @@ import org.lamsfoundation.lams.tool.forum.persistence.Message; import org.lamsfoundation.lams.tool.forum.persistence.MessageSeq; import org.lamsfoundation.lams.tool.forum.persistence.PersistenceException; +import org.springframework.web.multipart.MultipartFile; /** * User: conradb Date: 8/06/2005 Time: 14:49:59 @@ -168,7 +168,7 @@ * @return Attachment A new instance of attachment has uploaded file VersionID and UUID information. * @throws PersistenceException */ - Attachment uploadAttachment(FormFile file) throws PersistenceException; + Attachment uploadAttachment(MultipartFile file) throws PersistenceException; // ************************************************************************************ // *********************Get topic methods ********************** Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AdminAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringConditionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/LearningAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AdminController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AdminController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AdminController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,69 @@ +/**************************************************************** + * 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.forum.web.controller; + +import javax.servlet.http.HttpServletRequest; + +import org.lamsfoundation.lams.tool.forum.persistence.ForumConfigItem; +import org.lamsfoundation.lams.tool.forum.service.IForumService; +import org.lamsfoundation.lams.tool.forum.web.forms.AdminForm; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author Marcin Cieslak + */ +@Controller +@RequestMapping("/admin") +public class AdminController { + + @Autowired + @Qualifier("forumService") + private IForumService forumService; + + @RequestMapping("/start") + public String start(@ModelAttribute AdminForm adminForm, HttpServletRequest request) { + + ForumConfigItem keepLearnerContent = forumService.getConfigItem(ForumConfigItem.KEY_KEEP_LEARNER_CONTENT); + if (keepLearnerContent != null) { + adminForm.setKeepLearnerContent(Boolean.valueOf(keepLearnerContent.getConfigValue())); + } + + request.setAttribute("error", false); + return "jsps/admin/config"; + } + + @RequestMapping("/saveContent") + public String saveContent(@ModelAttribute AdminForm adminForm, HttpServletRequest request) { + + ForumConfigItem keepLearnerContent = forumService.getConfigItem(ForumConfigItem.KEY_KEEP_LEARNER_CONTENT); + keepLearnerContent.setConfigValue(String.valueOf(adminForm.getKeepLearnerContent())); + forumService.saveForumConfigItem(keepLearnerContent); + + request.setAttribute("savedSuccess", true); + return "jsps/admin/configE"; + } +} \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringConditionController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringConditionController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringConditionController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,384 @@ +/**************************************************************** + * 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.forum.web.controller; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.tool.forum.dto.MessageDTO; +import org.lamsfoundation.lams.tool.forum.persistence.ForumCondition; +import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.tool.forum.service.IForumService; +import org.lamsfoundation.lams.tool.forum.util.ConditionTopicComparator; +import org.lamsfoundation.lams.tool.forum.util.ForumConstants; +import org.lamsfoundation.lams.tool.forum.util.MessageDtoComparator; +import org.lamsfoundation.lams.tool.forum.web.forms.ForumConditionForm; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Auxiliary action in author mode. It contains operations with ForumCondition. The rest of operations are located in + * AuthoringAction action. + * + * @author Marcin Cieslak + * @see org.lamsfoundation.lams.tool.forum.web.controller.AuthoringAction + */ +@Controller +@RequestMapping("/authoringCondition") +public class AuthoringConditionController { + + @Autowired + @Qualifier("forumService") + private IForumService forumService; + + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + + /** + * Display empty page for a new condition. + */ + @RequestMapping("/newConditionInit") + public String newConditionInit(@ModelAttribute ForumConditionForm forumConditionForm, HttpServletRequest request, + HttpServletResponse response) { + + populateFormWithPossibleItems(forumConditionForm, request); + forumConditionForm.setOrderId(-1); + return "jsps/authoring/addCondition"; + } + + /** + * Display edit page for an existing condition. + */ + @RequestMapping("/editCondition") + public String editCondition(@ModelAttribute ForumConditionForm forumConditionForm, HttpServletRequest request) { + + String sessionMapID = forumConditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(ForumConstants.PARAM_ORDER_ID), -1); + ForumCondition condition = null; + if (orderId != -1) { + SortedSet conditionSet = getForumConditionSet(sessionMap); + List conditionList = new ArrayList<>(conditionSet); + condition = conditionList.get(orderId); + if (condition != null) { + populateConditionToForm(orderId, condition, forumConditionForm, request); + } + } + + populateFormWithPossibleItems(forumConditionForm, request); + return condition == null ? null : "jsps/authoring/addCondition"; + } + + /** + * This method will get necessary information from condition form and save or update into HttpSession + * condition list. Notice, this save is not persist them into database, just save HttpSession + * temporarily. Only they will be persist when the entire authoring page is being persisted. + */ + @RequestMapping("/saveOrUpdateCondition") + public String saveOrUpdateCondition(@ModelAttribute ForumConditionForm forumConditionForm, + HttpServletRequest request) { + + MultiValueMap errorMap = validateForumCondition(forumConditionForm, request); + + if (!errorMap.isEmpty()) { + populateFormWithPossibleItems(forumConditionForm, request); + request.setAttribute("errorMap", errorMap); + return "jsps/authoring/addCondition"; + } + + try { + extractFormToForumCondition(request, forumConditionForm); + } catch (Exception e) { + + errorMap.add("GLOBAL", messageService.getMessage("error.condition")); + if (!errorMap.isEmpty()) { + populateFormWithPossibleItems(forumConditionForm, request); + request.setAttribute("errorMap", errorMap); + return "jsps/authoring/addCondition"; + } + } + + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, forumConditionForm.getSessionMapID()); + + return "jsps/authoring/conditionList"; + } + + /** + * Remove condition from HttpSession list and update page display. As authoring rule, all persist only happen when + * user submit whole page. So this remove is just impact HttpSession values. + */ + @RequestMapping("/removeCondition") + public String removeCondition(HttpServletRequest request) { + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(ForumConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getForumConditionSet(sessionMap); + List conditionList = new ArrayList<>(conditionSet); + ForumCondition condition = conditionList.remove(orderId); + + for (ForumCondition otherCondition : conditionSet) { + if (otherCondition.getOrderId() > orderId) { + otherCondition.setOrderId(otherCondition.getOrderId() - 1); + } + } + conditionSet.clear(); + conditionSet.addAll(conditionList); + // add to delList + List deletedList = getDeletedForumConditionList(sessionMap); + deletedList.add(condition); + } + + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "jsps/authoring/conditionList"; + } + + /** + * Move up current item. + */ + @RequestMapping("/upCondition") + public String upCondition(HttpServletRequest request) { + return switchItem(request, true); + } + + /** + * Move down current item. + */ + @RequestMapping("/downCondition") + public String downCondition(HttpServletRequest request) { + return switchItem(request, false); + } + + private String switchItem(HttpServletRequest request, boolean up) { + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(ForumConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getForumConditionSet(sessionMap); + List conditionList = new ArrayList<>(conditionSet); + // get current and the target item, and switch their sequnece + ForumCondition condition = conditionList.get(orderId); + ForumCondition repCondition; + if (up) { + repCondition = conditionList.get(--orderId); + } else { + repCondition = conditionList.get(++orderId); + } + int upSeqId = repCondition.getOrderId(); + repCondition.setOrderId(condition.getOrderId()); + condition.setOrderId(upSeqId); + + // put back list, it will be sorted again + conditionSet.clear(); + conditionSet.addAll(conditionList); + } + + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "jsps/authoring/conditionList"; + } + + // ************************************************************************************* + // Private methods for internal needs + // ************************************************************************************* + + /** + * List containing Forum conditions. + */ + private SortedSet getForumConditionSet(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(ForumConstants.ATTR_CONDITION_SET); + if (list == null) { + list = new TreeSet<>(new TextSearchConditionComparator()); + sessionMap.put(ForumConstants.ATTR_CONDITION_SET, list); + } + return list; + } + + private SortedSet getMessageDTOList(SessionMap sessionMap) { + SortedSet topics = (SortedSet) sessionMap.get(ForumConstants.AUTHORING_TOPICS_LIST); + if (topics == null) { + topics = new TreeSet<>(new MessageDtoComparator()); + sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topics); + } + return topics; + } + + /** + * Get the deleted condition list, which could be persisted or non-persisted items. + */ + private List getDeletedForumConditionList(SessionMap sessionMap) { + return getListFromSession(sessionMap, ForumConstants.ATTR_DELETED_CONDITION_LIST); + } + + /** + * Get java.util.List from HttpSession by given name. + */ + private List getListFromSession(SessionMap sessionMap, String name) { + List list = (List) sessionMap.get(name); + if (list == null) { + list = new ArrayList(); + sessionMap.put(name, list); + } + return list; + } + + /** + * This method will populate condition information to its form for edit use. + */ + private void populateConditionToForm(int orderId, ForumCondition condition, ForumConditionForm form, + HttpServletRequest request) { + form.populateForm(condition); + if (orderId >= 0) { + form.setOrderId(orderId + 1); + } + } + + /** + * This method will populate questions to choose to the form for edit use. + */ + private void populateFormWithPossibleItems(ForumConditionForm conditionForm, HttpServletRequest request) { + + // get back sessionMAP + String sessionMapID = conditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + Set messageDTOs = getMessageDTOList(sessionMap); + + // Initialise the LabelValueBeans in the possibleOptions array. + + Map possibleItems = new HashMap<>(messageDTOs.size()); + + for (MessageDTO messageDTO : messageDTOs) { + Message topic = messageDTO.getMessage(); + possibleItems.put(topic.getSubject(), new Long(topic.getCreated().getTime()).toString()); + } + conditionForm.setPossibleItems(possibleItems); + } + + /** + * Extract form content to ForumCondition. + */ + private void extractFormToForumCondition(HttpServletRequest request, ForumConditionForm form) throws Exception { + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); + // check whether it is "edit(old item)" or "add(new item)" + SortedSet conditionSet = getForumConditionSet(sessionMap); + int orderId = form.getOrderId(); + ForumCondition condition = null; + + if (orderId == -1) { // add + String properConditionName = forumService.createTextSearchConditionName(conditionSet); + condition = form.extractCondition(); + condition.setName(properConditionName); + int maxOrderId = 1; + if (conditionSet != null && conditionSet.size() > 0) { + ForumCondition last = conditionSet.last(); + maxOrderId = last.getOrderId() + 1; + } + condition.setOrderId(maxOrderId); + conditionSet.add(condition); + } else { // edit + List conditionList = new ArrayList<>(conditionSet); + condition = conditionList.get(orderId - 1); + form.extractCondition(condition); + } + + Long[] selectedItems = form.getSelectedItems(); + Set conditionTopics = new TreeSet<>(new ConditionTopicComparator()); + Set messageDTOs = getMessageDTOList(sessionMap); + + for (Long selectedItem : selectedItems) { + for (MessageDTO messageDTO : messageDTOs) { + Message topic = messageDTO.getMessage(); + if (selectedItem.equals(topic.getCreated().getTime())) { + conditionTopics.add(topic); + } + } + } + condition.setTopics(conditionTopics); + } + + /** + * Validate ForumCondition + */ + private MultiValueMap validateForumCondition(ForumConditionForm conditionForm, + HttpServletRequest request) { + + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + + String formConditionName = conditionForm.getDisplayName(); + if (StringUtils.isBlank(formConditionName)) { + + errorMap.add("GLOBAL", messageService.getMessage("error.condition.name.blank")); + } else { + + Integer formConditionOrderId = conditionForm.getOrderId(); + + String sessionMapID = conditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SortedSet conditionSet = getForumConditionSet(sessionMap); + for (ForumCondition condition : conditionSet) { + if (formConditionName.equals(condition.getDisplayName()) + && !formConditionOrderId.equals(condition.getOrderId())) { + + errorMap.add("GLOBAL", messageService.getMessage("error.condition.duplicated.name")); + break; + } + } + } + + // should be selected at least one question + Long[] selectedItems = conditionForm.getSelectedItems(); + if (selectedItems == null || selectedItems.length == 0) { + errorMap.add("GLOBAL", messageService.getMessage("error.condition.no.questions.selected")); + } + + return errorMap; + } + +} \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/AuthoringController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,958 @@ +/**************************************************************** + * 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.forum.web.controller; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.web.AuthoringAction; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.forum.dto.MessageDTO; +import org.lamsfoundation.lams.tool.forum.persistence.Attachment; +import org.lamsfoundation.lams.tool.forum.persistence.Forum; +import org.lamsfoundation.lams.tool.forum.persistence.ForumCondition; +import org.lamsfoundation.lams.tool.forum.persistence.ForumToolSession; +import org.lamsfoundation.lams.tool.forum.persistence.ForumUser; +import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.tool.forum.persistence.PersistenceException; +import org.lamsfoundation.lams.tool.forum.service.IForumService; +import org.lamsfoundation.lams.tool.forum.util.ForumConstants; +import org.lamsfoundation.lams.tool.forum.util.MessageComparator; +import org.lamsfoundation.lams.tool.forum.util.MessageDtoComparator; +import org.lamsfoundation.lams.tool.forum.web.forms.ForumForm; +import org.lamsfoundation.lams.tool.forum.web.forms.ForumPedagogicalPlannerForm; +import org.lamsfoundation.lams.tool.forum.web.forms.MessageForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author Steve.Ni + */ +@Controller +@RequestMapping("/authoring") +public class AuthoringController { + private static Logger log = Logger.getLogger(AuthoringAction.class); + + @Autowired + @Qualifier("forumService") + private IForumService forumService; + + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + + @Autowired + private WebApplicationContext applicationContext; + + // ****************************************************************************************************************** + // Forum Author functions + // ****************************************************************************************************************** + + /** + * This page will display initial submit tool content. Or just a blank page if the toolContentID does not exist + * before. + */ + @RequestMapping("/authoring") + public String initPage(@ModelAttribute ForumForm forumForm, HttpServletRequest request) { + // initial Session Map + SessionMap sessionMap = new SessionMap<>(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + Long contentId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + forumForm.setSessionMapID(sessionMap.getSessionID()); + forumForm.setContentFolderID(contentFolderID); + sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); + + // get back the topic list and display them on page + forumService = getForumManager(); + + List topics = null; + Forum forum = null; + try { + forum = forumService.getForumByContentId(contentId); + // if forum does not exist, try to use default content instead. + if (forum == null) { + forum = forumService.getDefaultContent(contentId); + if (forum.getMessages() != null) { + List list = new ArrayList<>(); + // sorted by create date + Iterator iter = forum.getMessages().iterator(); + while (iter.hasNext()) { + Message topic = (Message) iter.next(); + // contentFolderID != -1 means it is sysadmin: LDEV-906 + if (topic.getCreatedBy() == null && !StringUtils.equals(contentFolderID, "-1")) { + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser fuser = new ForumUser(user, null); + topic.setCreatedBy(fuser); + } + list.add(topic); + } + topics = MessageDTO.getMessageDTO(list); + } else { + topics = null; + } + } else { + topics = forumService.getAuthoredTopics(forum.getUid()); + // failure tolerance: if current contentID is defaultID, the createBy will be null. + // contentFolderID != -1 means it is sysadmin: LDEV-906 + if (!StringUtils.equals(contentFolderID, "-1")) { + for (MessageDTO messageDTO : topics) { + if (StringUtils.isBlank(messageDTO.getAuthor())) { + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser fuser = new ForumUser(user, null); + messageDTO.setAuthor(fuser.getFirstName() + " " + fuser.getLastName()); + } + } + } + } + + // tear down PO to normal object using clone() method + forumForm.setForum((Forum) forum.clone()); + + sessionMap.put(ForumConstants.AUTHORING_FORUM, forum); + } catch (Exception e) { + AuthoringController.log.error(e); + return "error"; + } + + // init it to avoid null exception in following handling + if (topics == null) { + topics = new ArrayList<>(); + } + + Set topicSet = new TreeSet<>(new MessageDtoComparator()); + topicSet.addAll(topics); + sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topicSet); + + // init condition set + SortedSet conditionSet = getForumConditionSet(sessionMap); + conditionSet.clear(); + conditionSet.addAll(forum.getConditions()); + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + + return "jsps/authoring/authoring"; + } + + @RequestMapping("/defineLater") + public String defineLater(@ModelAttribute ForumForm forumForm, HttpServletRequest request) { + + // update define later flag to true + Long contentId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + Forum forum = forumService.getForumByContentId(contentId); + + if (!forum.isContentInUse()) { + forum.setDefineLater(true); + forumService.updateForum(forum); + + // audit log the teacher has started editing activity in monitor + forumService.auditLogStartEditingActivityInMonitor(contentId); + } + + // initial Session Map + SessionMap sessionMap = new SessionMap<>(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + forumForm.setSessionMapID(sessionMap.getSessionID()); + forumForm.setContentFolderID(contentFolderID); + sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); + + // get back the topic list and display them on page + forumService = getForumManager(); + + List topics = null; + try { + forum = forumService.getForumByContentId(contentId); + // if forum does not exist, try to use default content instead. + if (forum == null) { + forum = forumService.getDefaultContent(contentId); + if (forum.getMessages() != null) { + List list = new ArrayList<>(); + // sorted by create date + Iterator iter = forum.getMessages().iterator(); + while (iter.hasNext()) { + Message topic = (Message) iter.next(); + // contentFolderID != -1 means it is sysadmin: LDEV-906 + if (topic.getCreatedBy() == null && !StringUtils.equals(contentFolderID, "-1")) { + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser fuser = new ForumUser(user, null); + topic.setCreatedBy(fuser); + } + list.add(topic); + } + topics = MessageDTO.getMessageDTO(list); + } else { + topics = null; + } + } else { + topics = forumService.getAuthoredTopics(forum.getUid()); + // failure tolerance: if current contentID is defaultID, the createBy will be null. + // contentFolderID != -1 means it is sysadmin: LDEV-906 + if (!StringUtils.equals(contentFolderID, "-1")) { + for (MessageDTO messageDTO : topics) { + if (StringUtils.isBlank(messageDTO.getAuthor())) { + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser fuser = new ForumUser(user, null); + messageDTO.setAuthor(fuser.getFirstName() + " " + fuser.getLastName()); + } + } + } + } + + // tear down PO to normal object using clone() method + forumForm.setForum((Forum) forum.clone()); + + sessionMap.put(ForumConstants.AUTHORING_FORUM, forum); + } catch (Exception e) { + AuthoringController.log.error(e); + return "error"; + } + + // init it to avoid null exception in following handling + if (topics == null) { + topics = new ArrayList<>(); + } + + Set topicSet = new TreeSet<>(new MessageDtoComparator()); + topicSet.addAll(topics); + sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topicSet); + + // init condition set + SortedSet conditionSet = getForumConditionSet(sessionMap); + conditionSet.clear(); + conditionSet.addAll(forum.getConditions()); + + request.setAttribute(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER); + + return "jsps/authoring/authoring"; + } + + /** + * Update all content for forum. These contents contain + *
    + *
  1. Forum authoring infomation, e.g. online/offline instruction, title, advacnce options, etc.
  2. + *
  3. Uploaded offline/online instruction files
  4. + *
  5. Topics author created
  6. + *
  7. Topics' attachment file
  8. + *
  9. Author user information
  10. + *
+ */ + @RequestMapping("/update") + public String updateContent(@ModelAttribute ForumForm forumForm, HttpServletRequest request) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(forumForm.getSessionMapID()); + // validation + MultiValueMap errorMap = validate(forumForm, request); + if (!errorMap.isEmpty()) { + request.setAttribute("errorMap", errorMap); + return "jsps/authoring/authoring"; + } + + Forum forum = forumForm.getForum(); + // get back tool content ID + forum.setContentId(forumForm.getToolContentID()); + + forumService = getForumManager(); + + // *******************************Handle user******************* + String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); + ForumUser forumUser = null; + // check whether it is sysadmin:LDEV-906 + if (!StringUtils.equals(contentFolderID, "-1")) { + // try to get form system session + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + forumUser = forumService.getUserByID(new Long(user.getUserID().intValue())); + if (forumUser == null) { + forumUser = new ForumUser(user, null); + forumService.createUser(forumUser); + } + } + // **********************************Get Forum PO********************* + Forum forumPO = forumService.getForumByContentId(forumForm.getToolContentID()); + if (forumPO == null) { + // new Forum, create it. + forumPO = forum; + forumPO.setContentId(forumForm.getToolContentID()); + + } else { + Long uid = forumPO.getUid(); + PropertyUtils.copyProperties(forumPO, forum); + // get back UID + forumPO.setUid(uid); + + // if it's a teacher - change define later status + if (mode.isTeacher()) { + forumPO.setDefineLater(false); + } + } + forumPO.setCreatedBy(forumUser); + + // copy back + forum = forumService.updateForum(forumPO); + + // delete message attachment + List topicDeleteAttachmentList = getTopicDeletedAttachmentList(sessionMap); + Iterator iter = topicDeleteAttachmentList.iterator(); + while (iter.hasNext()) { + Attachment delAtt = (Attachment) iter.next(); + iter.remove(); + } + + // **************************** Handle topic ********************* + Set topics = getTopics(sessionMap); + iter = topics.iterator(); + while (iter.hasNext()) { + MessageDTO dto = (MessageDTO) iter.next(); + if (dto.getMessage() != null) { + // This flushes user UID info to message if this user is a new user. + dto.getMessage().setCreatedBy(forumUser); + dto.getMessage().setModifiedBy(forumUser); + forumService.createRootTopic(forum.getUid(), null, dto.getMessage()); + } + } + // delete them from database. + List delTopics = getDeletedTopicList(sessionMap); + iter = delTopics.iterator(); + while (iter.hasNext()) { + MessageDTO dto = (MessageDTO) iter.next(); + iter.remove(); + if (dto.getMessage() != null && dto.getMessage().getUid() != null) { + forumService.deleteTopic(dto.getMessage().getUid()); + } + } + + // ******************************** Handle conditions **************** + Set conditions = getForumConditionSet(sessionMap); + List delConditions = getDeletedForumConditionList(sessionMap); + + // delete conditions that don't contain any topics + Iterator conditionIter = conditions.iterator(); + while (conditionIter.hasNext()) { + ForumCondition condition = conditionIter.next(); + if (condition.getTopics().isEmpty()) { + conditionIter.remove(); + delConditions.add(condition); + + // reorder remaining conditions + for (ForumCondition otherCondition : conditions) { + if (otherCondition.getOrderId() > condition.getOrderId()) { + otherCondition.setOrderId(otherCondition.getOrderId() - 1); + } + } + } + } + forum.setConditions(conditions); + + iter = delConditions.iterator(); + while (iter.hasNext()) { + ForumCondition condition = (ForumCondition) iter.next(); + iter.remove(); + forumService.deleteCondition(condition); + } + + forum = forumService.updateForum(forum); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + return "jsps/authoring/authoring"; + } + + // ****************************************************************************************************************** + // Topic functions + // ****************************************************************************************************************** + /** + * Display emtpy topic page for user input topic information. This page will contain all topics list which this + * author posted before. + */ + @RequestMapping("/newTopic") + public String newTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + messageForm.setSessionMapID(sessionMapID); + + return "jsps/authoring/message/create"; + } + + /** + * Create a topic in memory. This topic will be saved when user save entire authoring page. + */ + @RequestMapping("/createTopic") + public String createTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws IOException, ServletException, PersistenceException { + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(messageForm.getSessionMapID()); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + + SortedSet topics = getTopics(sessionMap); + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + // get message info from web page + Message message = messageForm.getMessage(); + // init some basic variables for first time create + message.setIsAuthored(true); + message.setCreated(new Date()); + message.setUpdated(new Date()); + message.setLastReplyDate(new Date()); + + int maxSeq = 1; + if (topics.size() > 0) { + MessageDTO last = (MessageDTO) topics.last(); + maxSeq = last.getMessage().getSequenceId() + 1; + } + message.setSequenceId(maxSeq); + + // check whether this user exist or not + ForumUser forumUser = forumService.getUserByID(new Long(user.getUserID().intValue())); + String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); + // check whether it is sysadmin:LDEV-906 + if (forumUser == null && !StringUtils.equals(contentFolderID, "-1")) { + // if user not exist, create new one in database + forumUser = new ForumUser(user, null); + } + message.setCreatedBy(forumUser); + // same person with create at first time + message.setModifiedBy(forumUser); + + // set attachment of this topic + Set attSet = null; + if (messageForm.getAttachmentFile() != null + && !StringUtils.isEmpty(messageForm.getAttachmentFile().getOriginalFilename())) { + forumService = getForumManager(); + Attachment att = forumService.uploadAttachment(messageForm.getAttachmentFile()); + // only allow one attachment, so replace whatever + attSet = new HashSet(); + attSet.add(att); + } + message.setAttachments(attSet); + + // create clones of this topic (appropriate only for editing in monitoring) + Forum forum = (Forum) sessionMap.get(ForumConstants.AUTHORING_FORUM); + if (forum != null) { + List toolSessions = forumService.getSessionsByContentId(forum.getContentId()); + for (ForumToolSession toolSession : toolSessions) { + Message newMsg = Message.newInstance(message); + newMsg.setToolSession(toolSession); + newMsg.setAttachments(new TreeSet()); + newMsg.setModifiedBy(null); + newMsg.setCreatedBy(null); + message.getSessionClones().add(newMsg); + } + } + + topics.add(MessageDTO.getMessageDTO(message)); + + return "jsps/authoring/message/topiclist"; + } + + /** + * Delete a topic form current topic list. But database record will be deleted only when user save whole authoring + * page. + */ + @RequestMapping("/deleteTopic") + public String deleteTopic(HttpServletRequest request) throws PersistenceException { + + // get SessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapID); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + String topicIndex = request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); + int topicIdx = NumberUtils.stringToInt(topicIndex, -1); + + if (topicIdx != -1) { + Set topics = getTopics(sessionMap); + List rList = new ArrayList(topics); + MessageDTO item = rList.remove(topicIdx); + topics.clear(); + topics.addAll(rList); + // add to delList + List delList = getDeletedTopicList(sessionMap); + delList.add(item); + + SortedSet list = getForumConditionSet(sessionMap); + Iterator conditionIter = list.iterator(); + + while (conditionIter.hasNext()) { + ForumCondition condition = conditionIter.next(); + Set topicList = condition.getTopics(); + if (topicList.contains(item.getMessage())) { + topicList.remove(item.getMessage()); + } + } + } + + return "jsps/authoring/message/topiclist"; + } + + /** + * Display a HTML FORM which contains subject, body and attachment information from a special topic. This page is + * ready for user update this topic. + */ + @RequestMapping("/editTopic") + public String editTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws PersistenceException { + + // get SessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapID); + + messageForm.setSessionMapID(sessionMapID); + + String topicIndex = request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); + int topicIdx = NumberUtils.stringToInt(topicIndex, -1); + if (topicIdx != -1) { + Set topics = getTopics(sessionMap); + List rList = new ArrayList(topics); + MessageDTO topic = rList.get(topicIdx); + if (topic != null) { + // update message to HTML Form to echo back to web page: for subject, body display + messageForm.setMessage(topic.getMessage()); + } + // echo back to web page: for attachment display + request.setAttribute(ForumConstants.AUTHORING_TOPIC, topic); + } + + request.setAttribute(ForumConstants.AUTHORING_TOPICS_INDEX, topicIndex); + return "jsps/authoring/message/edit"; + } + + /** + * Submit user updated inforamion in a topic to memory. This update will be submit to database only when user save + * whole authoring page. + */ + @RequestMapping("/updateTopic") + public String updateTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws PersistenceException { + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(messageForm.getSessionMapID()); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + + // get param from HttpServletRequest + String topicIndex = request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); + int topicIdx = NumberUtils.stringToInt(topicIndex, -1); + + if (topicIdx != -1) { + Message message = messageForm.getMessage(); + + Set topics = getTopics(sessionMap); + List rList = new ArrayList(topics); + MessageDTO newMsg = rList.get(topicIdx); + if (newMsg.getMessage() == null) { + newMsg.setMessage(new Message()); + } + + newMsg.getMessage().setSubject(message.getSubject()); + newMsg.getMessage().setBody(message.getBody()); + newMsg.getMessage().setUpdated(new Date()); + // update attachment + if (messageForm.getAttachmentFile() != null + && !StringUtils.isEmpty(messageForm.getAttachmentFile().getOriginalFilename())) { + forumService = getForumManager(); + Attachment att = forumService.uploadAttachment(messageForm.getAttachmentFile()); + // only allow one attachment, so replace whatever + Set attSet = new HashSet(); + attSet.add(att); + newMsg.setHasAttachment(true); + newMsg.getMessage().setAttachments(attSet); + } else if (!messageForm.isHasAttachment()) { + Set att = newMsg.getMessage().getAttachments(); + if (att != null && att.size() > 0) { + List delTopicAtt = getTopicDeletedAttachmentList(sessionMap); + delTopicAtt.add(att.iterator().next()); + } + newMsg.setHasAttachment(false); + newMsg.getMessage().setAttachments(null); + } + } + + request.setAttribute(ForumConstants.AUTHORING_TOPICS_INDEX, topicIndex); + return "jsps/authoring/message/topiclist"; + } + + /** + * Remove message attachment. + */ + @RequestMapping("/deleteAttachment") + public String deleteAttachment(HttpServletRequest request) { + request.setAttribute("itemAttachment", null); + return "jsps/authoring/parts/msgattachment"; + } + + /** + * Move up current topic. + */ + @RequestMapping("/upTopic") + public String upTopic(HttpServletRequest request) { + return switchTopic(request, true); + } + + /** + * Move down current topic. + */ + @RequestMapping("/downTopic") + public String downTopic(HttpServletRequest request) { + return switchTopic(request, false); + } + + private String switchTopic(HttpServletRequest request, boolean up) { + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapID); + + int itemIdx = NumberUtils.stringToInt(request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX), -1); + if (itemIdx != -1) { + Set topics = getTopics(sessionMap); + List rList = new ArrayList(topics); + MessageDTO newMsg = rList.get(itemIdx); + + // get current and the target item, and switch their sequence + MessageDTO item = rList.get(itemIdx); + MessageDTO repItem; + if (up) { + repItem = rList.get(--itemIdx); + } else { + repItem = rList.get(++itemIdx); + } + int upSeqId = repItem.getMessage().getSequenceId(); + repItem.getMessage().setSequenceId(item.getMessage().getSequenceId()); + item.getMessage().setSequenceId(upSeqId); + + // put back list, it will be sorted again + topics.clear(); + topics.addAll(rList); + } + + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "jsps/authoring/message/topiclist"; + } + + // ****************************************************************************************************************** + // Private method for internal functions + // ****************************************************************************************************************** + + private IForumService getForumManager() { + if (forumService == null) { + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(applicationContext.getServletContext()); + forumService = (IForumService) wac.getBean(ForumConstants.FORUM_SERVICE); + } + return forumService; + } + + private SortedSet getTopics(SessionMap sessionMap) { + SortedSet topics = (SortedSet) sessionMap.get(ForumConstants.AUTHORING_TOPICS_LIST); + if (topics == null) { + topics = new TreeSet<>(new MessageDtoComparator()); + sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topics); + } + return topics; + } + + private List getTopicDeletedAttachmentList(SessionMap sessionMap) { + return getListFromSession(sessionMap, ForumConstants.DELETED_ATTACHMENT_LIST); + } + + private List getDeletedTopicList(SessionMap sessionMap) { + return getListFromSession(sessionMap, ForumConstants.DELETED_AUTHORING_TOPICS_LIST); + } + + /** + * Get java.util.List from HttpSession by given name. + */ + private List getListFromSession(SessionMap sessionMap, String name) { + List list = (List) sessionMap.get(name); + if (list == null) { + list = new ArrayList(); + sessionMap.put(name, list); + } + return list; + } + + /** + * Forum validation method from STRUCT interface. + * + */ + public MultiValueMap validate(ForumForm form, HttpServletRequest request) { + + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(form.getSessionMapID()); + try { + String modeStr = request.getParameter(AttributeNames.ATTR_MODE); + // if (StringUtils.isBlank(form.getForum().getTitle())) { + // ActionMessage error = new ActionMessage("error.title.empty"); + // errors.add(ActionMessages.GLOBAL_MESSAGE, error); + // } + boolean allowNewTopic = form.getForum().isAllowNewTopic(); + // define it later mode(TEACHER): need read out AllowNewTopic flag rather than get from HTML form + // becuase defineLater does not include this field + if (StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())) { + forumService = getForumManager(); + Forum forumPO = forumService.getForumByContentId(form.getToolContentID()); + if (forumPO != null) { + allowNewTopic = forumPO.isAllowNewTopic(); + } else { + // failure tolerance + AuthoringController.log + .error("ERROR: Can not found Forum by toolContentID:" + form.getToolContentID()); + allowNewTopic = true; + } + } + if (!allowNewTopic) { + Set topics = getTopics(sessionMap); + if (topics.size() == 0) { + errorMap.add("GLOBAL", messageService.getMessage("error.must.have.topic")); + } + } + // define it later mode(TEACHER) skip below validation. + if (StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())) { + return errorMap; + } + if (!form.getForum().isAllowRichEditor() && form.getForum().isLimitedMaxCharacters()) { + if (form.getForum().getMaxCharacters() <= 0) { + errorMap.add("GLOBAL", messageService.getMessage("error.limit.char.less.zero")); + } + } + if (!form.getForum().isAllowRichEditor()) { + if (form.getForum().getMaxCharacters() != 0 + && form.getForum().getMaxCharacters() < form.getForum().getMinCharacters()) { + errorMap.add("GLOBAL", messageService.getMessage("error.min.post.char.less")); + } + } + if (form.getForum().isAllowRateMessages()) { + if (form.getForum().getMaximumRate() != 0 + && form.getForum().getMaximumRate() < form.getForum().getMinimumRate()) { + errorMap.add("GLOBAL", messageService.getMessage("error.min.rate.less.max")); + } + } + + if (!form.getForum().isAllowNewTopic()) { + if (form.getForum().getMaximumReply() != 0 + && form.getForum().getMaximumReply() < form.getForum().getMinimumReply()) { + errorMap.add("GLOBAL", messageService.getMessage("error.min.less.max")); + } + } + + } catch (Exception e) { + AuthoringController.log.error(e.toString()); + } + return errorMap; + } + + private float convertToMeg(int numBytes) { + return numBytes != 0 ? numBytes / 1024 / 1024 : 0; + } + + /** + * List containing Forum conditions. + */ + private SortedSet getForumConditionSet(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(ForumConstants.ATTR_CONDITION_SET); + if (list == null) { + list = new TreeSet<>(new TextSearchConditionComparator()); + sessionMap.put(ForumConstants.ATTR_CONDITION_SET, list); + } + return list; + } + + /** + * Get the deleted condition list, which could be persisted or non-persisted items. + */ + private List getDeletedForumConditionList(SessionMap sessionMap) { + return getListFromSession(sessionMap, ForumConstants.ATTR_DELETED_CONDITION_LIST); + } + + @RequestMapping("/initPedagogicalPlannerForm") + public String initPedagogicalPlannerForm(@ModelAttribute ForumPedagogicalPlannerForm plannerForm, + HttpServletRequest request) { + + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Forum forum = getForumManager().getForumByContentId(toolContentID); + plannerForm.fillForm(forum); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return "jsps/authoring/pedagogicalPlannerForm"; + + } + + @RequestMapping("/saveOrUpdatePedagogicalPlannerForm") + public String saveOrUpdatePedagogicalPlannerForm(@ModelAttribute ForumPedagogicalPlannerForm plannerForm, + HttpServletRequest request) throws IOException { + + MultiValueMap errorMap = plannerForm.validate(); + if (errorMap.isEmpty()) { + Forum forum = getForumManager().getForumByContentId(plannerForm.getToolContentID()); + forum.setInstructions(plannerForm.getInstructions()); + + int topicIndex = 0; + int sequenceId = 1; + Date currentDate = new Date(); + String topic = null; + String subject = null; + Message message = null; + List newTopics = new LinkedList<>(); + Set forumTopics = new TreeSet<>(new MessageComparator()); + for (Message existingMessage : forum.getMessages()) { + if (existingMessage.getIsAuthored() && existingMessage.getToolSession() == null) { + forumTopics.add(existingMessage); + } + } + Iterator forumTopicIterator = forumTopics.iterator(); + Pattern regexPattern = Pattern.compile(ForumConstants.WORD_REGEX, ForumConstants.PATTERN_MATCHING_OPTIONS); + + Matcher matcher = null; + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser forumUser = getForumManager().getUserByID(new Long(user.getUserID().intValue())); + + do { + topic = plannerForm.getTopic(topicIndex); + subject = WebUtil.removeHTMLtags(topic); + + // Getting 3 first words from body and making the subject out of it + if (StringUtils.isBlank(subject)) { + subject = null; + } else { + subject = subject.trim(); + matcher = regexPattern.matcher(subject); + int currentEnd = subject.length(); + for (short wordIndex = 0; wordIndex < ForumConstants.SUBJECT_WORD_COUNT; wordIndex++) { + if (matcher.find()) { + currentEnd = matcher.end(); + } else { + break; + } + } + subject = subject.substring(0, currentEnd).concat("..."); + } + + if (StringUtils.isEmpty(subject)) { + plannerForm.removeTopic(topicIndex); + } else if (forumTopicIterator.hasNext()) { + message = forumTopicIterator.next(); + message.setUpdated(currentDate); + message.setSubject(subject); + message.setBody(topic); + message.setSequenceId(sequenceId++); + } else { + message = new Message(); + message.setIsAuthored(true); + message.setCreated(currentDate); + message.setUpdated(currentDate); + message.setLastReplyDate(currentDate); + message.setCreatedBy(forumUser); + message.setModifiedBy(forumUser); + message.setSubject(subject); + message.setBody(topic); + message.setSequenceId(sequenceId++); + + newTopics.add(message); + message.setForum(forum); + getForumManager().createRootTopic(forum.getUid(), null, message); + } + topicIndex++; + } while (topic != null); + + while (forumTopicIterator.hasNext()) { + message = forumTopicIterator.next(); + forumTopicIterator.remove(); + getForumManager().deleteTopic(message.getUid()); + } + forum.getMessages().addAll(newTopics); + getForumManager().updateForum(forum); + } else { + request.setAttribute("errorMap", errorMap); + } + return "jsps/authoring/pedagogicalPlannerForm"; + } + + @RequestMapping("/createPedagogicalPlannerTopic") + public String createPedagogicalPlannerTopic(@ModelAttribute ForumPedagogicalPlannerForm plannerForm, + HttpServletRequest request) throws IOException, ServletException, PersistenceException { + plannerForm.setTopic(plannerForm.getTopicCount().intValue(), ""); + return "jsps/authoring/pedagogicalPlannerForm"; + } +} \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/ClearSessionController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,68 @@ +/**************************************************************** + * 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.forum.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); + } + } +} \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/LearningController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/LearningController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/LearningController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,1125 @@ +/**************************************************************** + * 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.forum.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.TimeZone; + +import javax.servlet.ServletException; +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.events.IEventNotificationService; +import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; +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.forum.dto.AverageRatingDTO; +import org.lamsfoundation.lams.tool.forum.dto.MessageDTO; +import org.lamsfoundation.lams.tool.forum.persistence.Attachment; +import org.lamsfoundation.lams.tool.forum.persistence.Forum; +import org.lamsfoundation.lams.tool.forum.persistence.ForumException; +import org.lamsfoundation.lams.tool.forum.persistence.ForumToolSession; +import org.lamsfoundation.lams.tool.forum.persistence.ForumUser; +import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.tool.forum.persistence.MessageSeq; +import org.lamsfoundation.lams.tool.forum.persistence.PersistenceException; +import org.lamsfoundation.lams.tool.forum.service.ForumServiceProxy; +import org.lamsfoundation.lams.tool.forum.service.IForumService; +import org.lamsfoundation.lams.tool.forum.util.ForumConstants; +import org.lamsfoundation.lams.tool.forum.web.forms.MessageForm; +import org.lamsfoundation.lams.tool.forum.web.forms.ReflectionForm; +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.FileValidatorUtil; +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.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.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +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 org.springframework.web.context.support.WebApplicationContextUtils; + +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * User: conradb Date: 24/06/2005 Time: 10:54:09 + */ +@Controller +@RequestMapping("/learning") +public class LearningController { + + private static Logger log = Logger.getLogger(LearningController.class); + + private static final boolean MODE_OPTIONAL = false; + + @Autowired + @Qualifier("forumService") + private IForumService forumService; + + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + + @Autowired + private WebApplicationContext applicationContext; + + // ========================================================================================== + // Forum level methods + // ========================================================================================== + /** + * Display root topics of a forum. This page will be the initial page of Learner page. + */ + @RequestMapping("/viewForum") + public String viewForum(HttpServletRequest request) throws Exception { + + // initial Session Map + String sessionMapID = request.getParameter(ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap; + // refresh forum page, not initial enter + if (sessionMapID != null) { + sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + } else { + sessionMap = new SessionMap<>(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + } + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + + // set the mode into http session + ToolAccessMode mode = null; + try { + mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, + LearningController.MODE_OPTIONAL); + } catch (Exception exp) { + } + if (mode == null) { + // set it as default mode + mode = ToolAccessMode.LEARNER; + } + + // get sessionId from HttpServletRequest + Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + // Try to get ForumID according to sessionId + forumService = getForumManager(); + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + + if (session == null || session.getForum() == null) { + LearningController.log.error("Failed on getting session by given sessionID:" + sessionId); + throw new Exception("Failed on getting session by given sessionID:" + sessionId); + } + + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + + Forum forum = session.getForum(); + // lock on finish + ForumUser forumUser = getCurrentUser(request, sessionId); + boolean lock = forum.getLockWhenFinished() && forumUser.isSessionFinished(); + + // set some option flag to HttpSession + // if allowRichEditor = true then don't restrict the number of chars + // if isLimitedInput = false then don't restrict the number of chars + // Indicate don't restrict number of chars by allowNumber = 0 + Long forumId = forum.getUid(); + Boolean allowRichEditor = new Boolean(forum.isAllowRichEditor()); + int minCharacters = forum.isLimitedMinCharacters() ? forum.getMinCharacters() : 0; + int maxCharacters = forum.isLimitedMaxCharacters() || forum.isAllowRichEditor() ? forum.getMaxCharacters() : 0; + + sessionMap.put(AttributeNames.ATTR_MODE, mode); + sessionMap.put(ForumConstants.ATTR_FORUM_ID, forumId); + sessionMap.put(ForumConstants.ATTR_FORUM_UID, forum.getUid()); + sessionMap.put(ForumConstants.ATTR_USER_UID, forumUser.getUid()); + sessionMap.put(ForumConstants.ATTR_FINISHED_LOCK, new Boolean(lock)); + sessionMap.put(ForumConstants.ATTR_LOCK_WHEN_FINISHED, forum.getLockWhenFinished()); + sessionMap.put(ForumConstants.ATTR_USER_FINISHED, forumUser.isSessionFinished()); + sessionMap.put(ForumConstants.ATTR_ALLOW_EDIT, forum.isAllowEdit()); + sessionMap.put(ForumConstants.ATTR_ALLOW_ANONYMOUS, forum.getAllowAnonym()); + + sessionMap.put(ForumConstants.ATTR_ALLOW_UPLOAD, forum.isAllowUpload()); + int uploadMaxFileSize = Configuration.getAsInt(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE); + // it defaults to -1 if property was not found + if (uploadMaxFileSize > 0) { + sessionMap.put(ForumConstants.ATTR_UPLOAD_MAX_FILE_SIZE, FileValidatorUtil.formatSize(uploadMaxFileSize)); + } + + sessionMap.put(ForumConstants.ATTR_ALLOW_RATE_MESSAGES, forum.isAllowRateMessages()); + sessionMap.put(ForumConstants.ATTR_MINIMUM_RATE, forum.getMinimumRate()); + sessionMap.put(ForumConstants.ATTR_MAXIMUM_RATE, forum.getMaximumRate()); + sessionMap.put(ForumConstants.ATTR_ALLOW_NEW_TOPICS, forum.isAllowNewTopic()); + sessionMap.put(ForumConstants.ATTR_ALLOW_RICH_EDITOR, allowRichEditor); + sessionMap.put(ForumConstants.ATTR_MIN_CHARACTERS, new Integer(minCharacters)); + sessionMap.put(ForumConstants.ATTR_MAX_CHARACTERS, new Integer(maxCharacters)); + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); + sessionMap.put(ForumConstants.ATTR_FORUM_TITLE, forum.getTitle()); + sessionMap.put(ForumConstants.ATTR_FORUM_INSTRCUTION, forum.getInstructions()); + sessionMap.put(AttributeNames.ATTR_LEARNER_CONTENT_FOLDER, + forumService.getLearnerContentFolder(sessionId, forumUser.getUserId())); + sessionMap.put(ForumConstants.ATTR_MINIMUM_REPLY, forum.getMinimumReply()); + sessionMap.put(ForumConstants.ATTR_MAXIMUM_REPLY, forum.getMaximumReply()); + + ActivityPositionDTO activityPosition = LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionId, + request, applicationContext.getServletContext()); + sessionMap.put(AttributeNames.ATTR_ACTIVITY_POSITION, activityPosition); + + int numOfRatings = forumService.getNumOfRatingsByUserAndForum(forumUser.getUid(), forum.getUid()); + boolean noMoreRatings = (forum.getMaximumRate() != 0) && (numOfRatings >= forum.getMaximumRate()) + && forum.isAllowRateMessages(); + boolean isMinRatingsCompleted = (forum.getMinimumRate() == 0) + || (numOfRatings >= forum.getMinimumRate()) && forum.isAllowRateMessages(); + sessionMap.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + sessionMap.put(ForumConstants.ATTR_IS_MIN_RATINGS_COMPLETED, isMinRatingsCompleted); + sessionMap.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); + + // Should we show the reflection or not? We shouldn't show it when the screen is accessed + // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. + // Need to constantly past this value on, rather than hiding just the once, as the View Forum + // screen has a refresh button. + boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false); + sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection); + + if (hideReflection) { + sessionMap.put(ForumConstants.ATTR_REFLECTION_ON, false); + sessionMap.put(ForumConstants.ATTR_REFLECTION_INSTRUCTION, ""); + sessionMap.put(ForumConstants.ATTR_REFLECTION_ENTRY, ""); + } else { + sessionMap.put(ForumConstants.ATTR_REFLECTION_ON, forum.isReflectOnActivity()); + sessionMap.put(ForumConstants.ATTR_REFLECTION_INSTRUCTION, forum.getReflectInstructions()); + + NotebookEntry notebookEntry = forumService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + ForumConstants.TOOL_SIGNATURE, forumUser.getUserId().intValue()); + sessionMap.put(ForumConstants.ATTR_REFLECTION_ENTRY, notebookEntry != null ? notebookEntry.getEntry() : ""); + } + + // add define later support + if (forum.isDefineLater()) { + return "jsps/learning/definelater"; + } + + // set contentInUse flag to true! + forum.setContentInUse(true); + forum.setDefineLater(false); + forumService.updateForum(forum); + + // get all root topic to display on init page + List rootTopics = forumService.getRootTopics(sessionId); + if (!forum.isAllowNewTopic()) { + // add the number post the learner has made for each topic. + for (MessageDTO messageDTO : rootTopics) { + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), + messageDTO.getMessage().getUid()); + messageDTO.setNumOfPosts(numOfPosts); + } + } + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + + // update new messages number + for (MessageDTO messageDTO : rootTopics) { + int numOfNewPosts = forumService.getNewMessagesNum(messageDTO.getMessage(), forumUser.getUid()); + messageDTO.setNewPostingsNum(numOfNewPosts); + } + + if (forum.isNotifyLearnersOnMarkRelease()) { + boolean isHtmlFormat = false; + + forumService.getEventNotificationService().createEvent(ForumConstants.TOOL_SIGNATURE, + ForumConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, forum.getContentId(), + forumService.getLocalisedMessage("event.mark.release.subject", null), + forumService.getLocalisedMessage("event.mark.release.body", null), isHtmlFormat); + + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + forumService.getEventNotificationService().subscribe(ForumConstants.TOOL_SIGNATURE, + ForumConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, forum.getContentId(), user.getUserID(), + IEventNotificationService.DELIVERY_METHOD_MAIL); + } + + // check if there is submission deadline + Date submissionDeadline = forum.getSubmissionDeadline(); + if (submissionDeadline != null) { + sessionMap.put(ForumConstants.ATTR_SUBMISSION_DEADLINE, forum.getSubmissionDeadline()); + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.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 "jsps/learning/submissionDeadline"; + } + } + + return "jsps/learning/viewforum"; + } + + /** + * Learner click "finish" button in forum page, this method will turn on session status flag for this learner. + */ + @RequestMapping("/finish") + public String finish(@ModelAttribute ReflectionForm reflectionForm, HttpServletRequest request, + HttpServletResponse response) { + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + forumService = getForumManager(); + + if (mode == ToolAccessMode.LEARNER || mode == ToolAccessMode.AUTHOR) { + if (!validateBeforeFinish(request, sessionMapID)) { + return "jsps/learning/viewforum"; + } + + String nextActivityUrl; + try { + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Long userID = new Long(user.getUserID().longValue()); + + // finish current session for user + forumService.finishUserSession(getCurrentUser(request, sessionId)); + ToolSessionManager sessionMgrService = ForumServiceProxy + .getToolSessionManager(applicationContext.getServletContext()); + nextActivityUrl = sessionMgrService.leaveToolSession(sessionId, userID); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new ForumException(e); + } catch (ToolException e) { + throw new ForumException(e); + } catch (IOException e) { + throw new ForumException(e); + } + return null; + + } + // get all root topic to display on init page + List rootTopics = forumService.getRootTopics(sessionId); + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + + return "jsps/learning/viewforum"; + } + + /** + * Submit reflection form input database. + */ + @RequestMapping("/submitReflection") + public String submitReflection(@ModelAttribute ReflectionForm reflectionForm, HttpServletRequest request, + HttpServletResponse response) { + + Integer userId = reflectionForm.getUserID(); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + // check for existing notebook entry + NotebookEntry entry = forumService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + ForumConstants.TOOL_SIGNATURE, userId); + + if (entry == null) { + // create new entry + forumService.createNotebookEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + ForumConstants.TOOL_SIGNATURE, userId, reflectionForm.getEntryText()); + } else { + // update existing entry + entry.setEntry(reflectionForm.getEntryText()); + entry.setLastModified(new Date()); + forumService.updateEntry(entry); + } + + return finish(reflectionForm, request, response); + } + + /** + * Display empty reflection form. + */ + @RequestMapping("/newReflection") + public String newReflection(@ModelAttribute ReflectionForm reflectionForm, HttpServletRequest request, + HttpServletResponse response) { + + // get session value + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + if (!validateBeforeFinish(request, sessionMapID)) { + return "jsps/learning/viewforum"; + } + + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + reflectionForm.setUserID(user.getUserID()); + reflectionForm.setSessionMapID(sessionMapID); + + // get the existing reflection entry + IForumService submitFilesService = getForumManager(); + + SessionMap map = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long toolSessionID = (Long) map.get(AttributeNames.PARAM_TOOL_SESSION_ID); + NotebookEntry entry = submitFilesService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + ForumConstants.TOOL_SIGNATURE, user.getUserID()); + + if (entry != null) { + reflectionForm.setEntryText(entry.getEntry()); + } + + return "jsps/learning/notebook"; + } + + // ========================================================================================== + // Topic level methods + // ========================================================================================== + + /** + * Display the messages for a particular topic. The Topic will arranged by Tree structure and loaded thread by + * thread (with paging). + */ + @RequestMapping("/viewTopic") + public String viewTopic(HttpServletRequest request) { + + forumService = getForumManager(); + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + // get forum user and forum + // if coming from topic list, the toolSessionId is in the SessionMap. + // if coming from the monitoring statistics window, it is passed in as a parameter. + Long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + if (toolSessionId != null) { + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId); + String mode = WebUtil.readStrParam(request, AttributeNames.PARAM_MODE, true); + if (mode != null) { + sessionMap.put(AttributeNames.PARAM_MODE, mode); + } + } else { + toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + } + ForumUser forumUser = getCurrentUser(request, toolSessionId); + Forum forum = forumUser.getSession().getForum(); + + Long lastMsgSeqId = WebUtil.readLongParam(request, ForumConstants.PAGE_LAST_ID, true); + Long pageSize = WebUtil.readLongParam(request, ForumConstants.PAGE_SIZE, true); + + setupViewTopicPagedDTOList(request, rootTopicId, sessionMapID, forumUser, forum, lastMsgSeqId, pageSize); + + // Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed + // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. + // Need to constantly past this value on, rather than hiding just the once, as the View Forum + // screen has a refresh button. Need to pass it through the view topic screen and dependent screens + // as it has a link from the view topic screen back to View Forum screen. + boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false); + sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection); + + return "jsps/learning/viewtopic"; + } + + private void setupViewTopicPagedDTOList(HttpServletRequest request, Long rootTopicId, String sessionMapID, + ForumUser forumUser, Forum forum, Long lastMsgSeqId, Long pageSize) { + // get root topic list + List msgDtoList = forumService.getTopicThread(rootTopicId, lastMsgSeqId, pageSize); + updateMesssageFlag(msgDtoList); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + + // check if we can still make posts in this topic + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), rootTopicId); + boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() + && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + + // transfer SessionMapID as well + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + // Saving or updating user timestamp + forumService.saveTimestamp(rootTopicId, forumUser); + } + + /** + * Display the messages for a particular thread in a particular topic. Returns all messages for this thread - does + * not need paging. + */ + @RequestMapping("/viewTopicThread") + public String viewTopicThread(HttpServletRequest request) { + + forumService = getForumManager(); + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + Long highlightMessageUid = WebUtil.readLongParam(request, ForumConstants.ATTR_MESS_ID, true); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + // get forum user and forum + ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + + Long threadId = WebUtil.readLongParam(request, ForumConstants.ATTR_THREAD_ID, true); + List msgDtoList = forumService.getThread(threadId); + updateMesssageFlag(msgDtoList); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + + // check if we can still make posts in this topic + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), rootTopicId); + boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() + && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + request.setAttribute(ForumConstants.ATTR_NO_MORE_PAGES, true); + + if (highlightMessageUid != null) { + request.setAttribute(ForumConstants.ATTR_MESS_ID, highlightMessageUid); + } + // transfer SessionMapID as well + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + return "jsps/learning/message/topicviewwrapper"; + } + + /** + * Display a single message. + */ + @RequestMapping("/viewMessage") + public String viewMessage(HttpServletRequest request) { + + forumService = getForumManager(); + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + Long messageUid = WebUtil.readLongParam(request, ForumConstants.ATTR_MESS_ID, true); + + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + // get forum user and forum + ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + + List msgDtoList = forumService.getMessageAsDTO(messageUid); + updateMesssageFlag(msgDtoList); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + + // check if we can still make posts in this topic + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), rootTopicId); + boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() + && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE; + request.setAttribute(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + request.setAttribute(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + request.setAttribute(ForumConstants.ATTR_NO_MORE_PAGES, true); + + if (messageUid != null) { + request.setAttribute(ForumConstants.ATTR_MESS_ID, messageUid); + } + // transfer SessionMapID as well + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + return "jsps/learning/message/msgviewwrapper"; + } + + /** + * Display empty page for a new topic in forum + */ + @RequestMapping("/newTopic") + public String newTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) { + // transfer SessionMapID as well + messageForm.setSessionMapID(WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID)); + + return "jsps/learning/create"; + } + + /** + * Create a new root topic. + */ + @RequestMapping("/createTopic") + public String createTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws IOException, ServletException, PersistenceException { + + SessionMap sessionMap = getSessionMap(request, messageForm); + Long forumId = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_ID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + List rootTopics = forumService.getRootTopics(sessionId); + + Message message = messageForm.getMessage(); + message.setIsAuthored(false); + message.setCreated(new Date()); + message.setUpdated(new Date()); + message.setLastReplyDate(new Date()); + int maxSeq = 1; + if (rootTopics.size() > 0) { + MessageDTO last = rootTopics.get(rootTopics.size() - 1); + maxSeq = last.getMessage().getSequenceId() + 1; + } + message.setSequenceId(maxSeq); + ForumUser forumUser = getCurrentUser(request, sessionId); + message.setCreatedBy(forumUser); + message.setModifiedBy(forumUser); + setAttachment(messageForm, message); + setMonitorMode(sessionMap, message); + + // save message into database + forumService = getForumManager(); + forumService.createRootTopic(forumId, sessionId, message); + + rootTopics.add(MessageDTO.getMessageDTO(message)); + // echo back current root topic to forum init page + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + + forumService.saveTimestamp(message.getUid(), forumUser); + + // update new messages number + for (MessageDTO messageDTO : rootTopics) { + int numOfNewPosts = forumService.getNewMessagesNum(messageDTO.getMessage(), forumUser.getUid()); + messageDTO.setNewPostingsNum(numOfNewPosts); + } + + // notify learners and teachers + forumService.sendNotificationsOnNewPosting(forumId, sessionId, message); + + return "jsps/learning/viewforum"; + } + + /** + * Display replay topic page. Message form subject will include parent topics same subject. + */ + @RequestMapping("/newReplyTopic") + public String newReplyTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) { + + String sessionMapID = request.getParameter(ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = getSessionMap(request, messageForm); + messageForm.setSessionMapID(sessionMapID); + + Long parentId = WebUtil.readLongParam(request, ForumConstants.ATTR_PARENT_TOPIC_ID); + sessionMap.put(ForumConstants.ATTR_PARENT_TOPIC_ID, parentId); + + // get parent topic, it can decide default subject of reply. + MessageDTO topic = getTopic(parentId); + if (topic != null && topic.getMessage() != null) { + String reTitle = topic.getMessage().getSubject(); + + MessageDTO originalMessage = MessageDTO.getMessageDTO(topic.getMessage()); + + sessionMap.put(ForumConstants.ATTR_ORIGINAL_MESSAGE, originalMessage); + + // echo back current topic subject to web page + if (reTitle != null && !reTitle.trim().startsWith("Re:")) { + messageForm.getMessage().setSubject("Re:" + reTitle); + } else { + messageForm.getMessage().setSubject(reTitle); + } + } + + // Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed + // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. + // Need to constantly past this value on, rather than hiding just the once, as the View Forum + // screen has a refresh button. Need to pass it through the view topic screen and dependent screens + // as it has a link from the view topic screen back to View Forum screen. + boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false); + sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection); + + return "jsps/learning/reply"; + } + + /** + * Create a replayed topic for a parent topic. + */ + @RequestMapping("/replyTopic") + public String replyTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request, + HttpServletResponse response) throws InterruptedException { + + SessionMap sessionMap = getSessionMap(request, messageForm); + Long parentId = (Long) sessionMap.get(ForumConstants.ATTR_PARENT_TOPIC_ID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + Message message = messageForm.getMessage(); + boolean isTestHarness = Boolean.valueOf(request.getParameter("testHarness")); + if (isTestHarness) { + message.setBody(request.getParameter("message.body__textarea")); + } + message.setIsAuthored(false); + message.setCreated(new Date()); + message.setUpdated(new Date()); + message.setLastReplyDate(new Date()); + ForumUser forumUser = getCurrentUser(request, sessionId); + message.setCreatedBy(forumUser); + message.setModifiedBy(forumUser); + setAttachment(messageForm, message); + setMonitorMode(sessionMap, message); + + // save message into database + forumService = getForumManager(); + + forumService.replyTopic(parentId, sessionId, message); + + // echo back this topic thread into page + Long rootTopicId = forumService.getRootTopicId(parentId); + + // check whether allow more posts for this user + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + Forum forum = session.getForum(); + + setupViewTopicPagedDTOList(request, rootTopicId, messageForm.getSessionMapID(), forumUser, forum, null, null); + + // notify learners and teachers + Long forumId = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_ID); + forumService.sendNotificationsOnNewPosting(forumId, sessionId, message); + sessionMap.remove(ForumConstants.ATTR_ORIGINAL_MESSAGE); + return "jsps/learning/viewtopic"; + } + + /** + * Create a replayed topic for a parent topic. + */ + @RequestMapping(path = "/replyTopicInline", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String replyTopicInline(@ModelAttribute MessageForm messageForm, HttpServletRequest request, + HttpServletResponse response) throws InterruptedException, IOException { + + SessionMap sessionMap = getSessionMap(request, messageForm); + Long parentId = (Long) sessionMap.get(ForumConstants.ATTR_PARENT_TOPIC_ID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + Message message = messageForm.getMessage(); + boolean isTestHarness = Boolean.valueOf(request.getParameter("testHarness")); + if (isTestHarness) { + message.setBody(request.getParameter("message.body__textarea")); + } + message.setIsAuthored(false); + message.setCreated(new Date()); + message.setUpdated(new Date()); + message.setLastReplyDate(new Date()); + ForumUser forumUser = getCurrentUser(request, sessionId); + message.setCreatedBy(forumUser); + message.setModifiedBy(forumUser); + setAttachment(messageForm, message); + setMonitorMode(sessionMap, message); + + // save message into database + forumService = getForumManager(); + MessageSeq newMessageSeq = forumService.replyTopic(parentId, sessionId, message); + + // check whether allow more posts for this user + Long rootTopicId = forumService.getRootTopicId(parentId); + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + Forum forum = session.getForum(); + + int numOfPosts = forumService.getNumOfPostsByTopic(forumUser.getUserId(), rootTopicId); + boolean noMorePosts = forum.getMaximumReply() != 0 && numOfPosts >= forum.getMaximumReply() + && !forum.isAllowNewTopic() ? Boolean.TRUE : Boolean.FALSE; + + ObjectNode ObjectNode = JsonNodeFactory.instance.objectNode(); + ObjectNode.put(ForumConstants.ATTR_MESS_ID, newMessageSeq.getMessage().getUid()); + ObjectNode.put(ForumConstants.ATTR_NO_MORE_POSTS, noMorePosts); + ObjectNode.put(ForumConstants.ATTR_NUM_OF_POSTS, numOfPosts); + ObjectNode.put(ForumConstants.ATTR_THREAD_ID, newMessageSeq.getThreadMessage().getUid()); + ObjectNode.put(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + ObjectNode.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + ObjectNode.put(ForumConstants.ATTR_PARENT_TOPIC_ID, newMessageSeq.getMessage().getParent().getUid()); + + return ObjectNode.toString(); + } + + private void setMonitorMode(SessionMap sessionMap, Message message) { + message.setIsMonitor(ToolAccessMode.TEACHER.equals(sessionMap.get(AttributeNames.ATTR_MODE))); + } + + /** + * Display a editable form for a special topic in order to update it. + */ + @RequestMapping("/editTopic") + public String editTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws PersistenceException { + Long topicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + + MessageDTO topic = getTopic(topicId); + + // echo current topic content to web page + if (topic != null) { + messageForm.setMessage(topic.getMessage()); + request.setAttribute(ForumConstants.AUTHORING_TOPIC, topic); + } + + // cache this topicID, using in Update topic + SessionMap sessionMap = getSessionMap(request, messageForm); + sessionMap.put(ForumConstants.ATTR_TOPIC_ID, topicId); + + // Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed + // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. + // Need to constantly past this value on, rather than hiding just the once, as the View Forum + // screen has a refresh button. Need to pass it through the view topic screen and dependent screens + // as it has a link from the view topic screen back to View Forum screen. + boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false); + sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection); + + return "jsps/learning/edit"; + } + + /** + * Delete attachment from topic. This method only reset attachment information in memory. The finally update will + * happen in updateTopic method. So topic can keep this attachment if user choose "Cancel" edit topic. + */ + @RequestMapping("/deleteAttachment") + public String deleteAttachment(HttpServletRequest request) { + // only reset not attachment flag. + MessageDTO dto = new MessageDTO(); + dto.setHasAttachment(false); + request.setAttribute(ForumConstants.AUTHORING_TOPIC, dto); + String sessionMapId = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapId); + request.setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD, sessionMap.get(ForumConstants.ATTR_ALLOW_UPLOAD)); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapId); + return "jsps/learning/message/msgattachment"; + } + + /** + * Update a topic. + */ + @RequestMapping("/updateTopic") + public String updateTopic(@ModelAttribute MessageForm messageForm, HttpServletRequest request) + throws PersistenceException { + + forumService = getForumManager(); + + SessionMap sessionMap = getSessionMap(request, messageForm); + Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID); + Message message = messageForm.getMessage(); + + doUpdateTopic(request, messageForm, sessionMap, topicId, message); + + // echo back this topic thread into page + Long rootTopicId = forumService.getRootTopicId(topicId); + ForumUser forumUser = getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)); + Forum forum = forumUser.getSession().getForum(); + setupViewTopicPagedDTOList(request, rootTopicId, messageForm.getSessionMapID(), forumUser, forum, null, null); + + return "jsps/learning/viewtopic"; + } + + private void doUpdateTopic(HttpServletRequest request, MessageForm messageForm, SessionMap sessionMap, Long topicId, + Message message) { + boolean makeAuditEntry = ToolAccessMode.TEACHER.equals(sessionMap.get(AttributeNames.ATTR_MODE)); + String oldMessageString = null; + + // get PO from database and sync with Form + Message messagePO = forumService.getMessage(topicId); + if (makeAuditEntry) { + oldMessageString = messagePO.toString(); + } + messagePO.setSubject(message.getSubject()); + messagePO.setBody(message.getBody()); + messagePO.setUpdated(new Date()); + messagePO.setModifiedBy(getCurrentUser(request, (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID))); + messagePO.setIsAnonymous(message.getIsAnonymous()); + setAttachment(messageForm, messagePO); + + if (makeAuditEntry) { + Long userId = 0L; + String loginName = "Default"; + Long toolContentId = null; + if (messagePO.getCreatedBy() != null) { + userId = messagePO.getCreatedBy().getUserId(); + loginName = messagePO.getCreatedBy().getLoginName(); + } + if (messagePO.getToolSession() != null && messagePO.getToolSession().getForum() != null) { + toolContentId = messagePO.getToolSession().getForum().getContentId(); + } + forumService.getLogEventService().logChangeLearnerContent(userId, loginName, toolContentId, + oldMessageString, messagePO.toString()); + } + + // save message into database + // if we are in monitoring then we are probably editing some else's entry so log the change. + forumService.updateTopic(messagePO); + } + + /** + * Update a topic. + */ + @RequestMapping(path = "/updateTopicInline", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String updateTopicInline(@ModelAttribute MessageForm messageForm, HttpServletRequest request, + HttpServletResponse response) throws PersistenceException, IOException { + + forumService = getForumManager(); + + SessionMap sessionMap = getSessionMap(request, messageForm); + Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID); + Message message = messageForm.getMessage(); + + doUpdateTopic(request, messageForm, sessionMap, topicId, message); + + ObjectNode ObjectNode = JsonNodeFactory.instance.objectNode(); + ObjectNode.put(ForumConstants.ATTR_MESS_ID, topicId); + ObjectNode.put(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + Long rootTopicId = forumService.getRootTopicId(topicId); + ObjectNode.put(ForumConstants.ATTR_ROOT_TOPIC_UID, rootTopicId); + + return ObjectNode.toString(); + } + + /** + * Sets the visibility of a message by updating the hide flag for a message + */ + @RequestMapping("/updateMessageHideFlag") + public String updateMessageHideFlag(HttpServletRequest request) { + + Long msgId = new Long(WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID)); + Boolean hideFlag = new Boolean(WebUtil.readBooleanParam(request, "hideFlag")); + forumService = getForumManager(); + + // TODO Skipping permissions for now, currently having issues with default learning designs not having an + // create_by field + // Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + // check if the user has permission to hide posts. + // ForumToolSession toolSession = forumService + // .getSessionBySessionId(sessionId); + // + // Forum forum = toolSession.getForum(); + // ForumUser currentUser = getCurrentUser(request,sessionId); + // ForumUser forumCreatedBy = forum.getCreatedBy(); + + // we should be looking at whether a user is a teacher and more specifically staff + // if (currentUser.getUserId().equals(forumCreatedBy.getUserId())) { + forumService.updateMessageHideFlag(msgId, hideFlag.booleanValue()); + // } else { + // log.info(currentUser + "does not have permission to hide/show postings in forum: " + forum.getUid()); + // log.info("Forum created by :" + forumCreatedBy.getUid() + ", Current User is: " + currentUser.getUid()); + // } + + // echo back this topic thread into page + Long rootTopicId = forumService.getRootTopicId(msgId); + List msgDtoList = forumService.getTopicThread(rootTopicId); + updateMesssageFlag(msgDtoList); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, + WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID)); + + return "jsps/learning/viewtopic"; + } + + /** + * Rates postings submitted by other learners. + */ + @RequestMapping(path = "/rateMessage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String rateMessage(HttpServletRequest request, HttpServletResponse response) throws IOException { + + forumService = getForumManager(); + String sessionMapId = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + Long forumUid = (Long) sessionMap.get(ForumConstants.ATTR_FORUM_UID); + Long userUid = (Long) sessionMap.get(ForumConstants.ATTR_USER_UID); + boolean isAllowRateMessages = (Boolean) sessionMap.get(ForumConstants.ATTR_ALLOW_RATE_MESSAGES); + int forumMaximumRate = (Integer) sessionMap.get(ForumConstants.ATTR_MAXIMUM_RATE); + int forumMinimumRate = (Integer) sessionMap.get(ForumConstants.ATTR_MINIMUM_RATE); + + float rating = Float.parseFloat(request.getParameter("rate")); + Long responseId = WebUtil.readLongParam(request, "idBox"); + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + Long userId = new Long(user.getUserID().intValue()); + + AverageRatingDTO averageRatingDTO = forumService.rateMessage(responseId, userId, toolSessionID, rating); + + //refresh numOfRatings and noMoreRatings + int numOfRatings = forumService.getNumOfRatingsByUserAndForum(userUid, forumUid); + boolean noMoreRatings = (forumMaximumRate != 0) && (numOfRatings >= forumMaximumRate) && isAllowRateMessages; + boolean isMinRatingsCompleted = (forumMinimumRate != 0) && (numOfRatings >= forumMinimumRate) + && isAllowRateMessages; + sessionMap.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + sessionMap.put(ForumConstants.ATTR_IS_MIN_RATINGS_COMPLETED, isMinRatingsCompleted); + sessionMap.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); + + ObjectNode ObjectNode = JsonNodeFactory.instance.objectNode(); + ObjectNode.put("averageRating", averageRatingDTO.getRating()); + ObjectNode.put("numberOfVotes", averageRatingDTO.getNumberOfVotes()); + ObjectNode.put(ForumConstants.ATTR_NO_MORE_RATINGSS, noMoreRatings); + ObjectNode.put(ForumConstants.ATTR_NUM_OF_RATINGS, numOfRatings); + + return ObjectNode.toString(); + } + + // ========================================================================================== + // Utility methods + // ========================================================================================== + /** + * Validation method to check whether user posts meet minimum number. + */ + private boolean validateBeforeFinish(HttpServletRequest request, String sessionMapID) { + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + Forum forum = session.getForum(); + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Long userID = new Long(user.getUserID().longValue()); + if (!forum.isAllowNewTopic()) { + + List list = forumService.getRootTopics(sessionId); + for (MessageDTO msgDto : list) { + Long topicId = msgDto.getMessage().getUid(); + int numOfPostsInTopic = forumService.getNumOfPostsByTopic(userID, topicId); + if (numOfPostsInTopic < forum.getMinimumReply()) { + // create error + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + errorMap.add("GLOBAL", + messageService.getMessage("error.less.mini.post", String.valueOf(forum.getMinimumReply()))); + request.setAttribute("errorMap", errorMap); + + // get all root topic to display on init page + List rootTopics = forumService.getRootTopics(sessionId); + request.setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, rootTopics); + return false; + } + + } + } + return true; + } + + /** + * This method will set flag in message DTO: + *
  • If this topic is created by current login user, then set Author mark true.
  • + */ + private void updateMesssageFlag(List msgDtoList) { + // set current user to web page, so that can display "edit" button + // correct. Only author alow to edit. + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + Long currUserId = new Long(user.getUserID().intValue()); + Iterator iter = msgDtoList.iterator(); + while (iter.hasNext()) { + MessageDTO dto = (MessageDTO) iter.next(); + if (dto.getMessage().getCreatedBy() != null + && currUserId.equals(dto.getMessage().getCreatedBy().getUserId())) { + dto.setAuthor(true); + } else { + dto.setAuthor(false); + } + } + } + + private MessageDTO getTopic(Long topicId) { + // get Topic content according to TopicID + forumService = getForumManager(); + MessageDTO topic = MessageDTO.getMessageDTO(forumService.getMessage(topicId)); + return topic; + } + + /** + * Get login user information from system level session. Check it whether it exists in database or not, and save it + * if it does not exists. Return an instance of PO of ForumUser. + */ + private ForumUser getCurrentUser(HttpServletRequest request, Long sessionId) { + // get login user (author) + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + ForumUser forumUser = forumService.getUserByUserAndSession(new Long(user.getUserID().intValue()), sessionId); + if (forumUser == null) { + // if user not exist, create new one in database + ForumToolSession session = forumService.getSessionBySessionId(sessionId); + forumUser = new ForumUser(user, session); + forumService.createUser(forumUser); + } + return forumUser; + } + + /** + * Get Forum Service. + */ + private IForumService getForumManager() { + if (forumService == null) { + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(applicationContext.getServletContext()); + forumService = (IForumService) wac.getBean(ForumConstants.FORUM_SERVICE); + } + return forumService; + } + + private void setAttachment(MessageForm messageForm, Message message) { + if (messageForm.getAttachmentFile() != null + && !StringUtils.isBlank(messageForm.getAttachmentFile().getOriginalFilename())) { + forumService = getForumManager(); + Attachment att = forumService.uploadAttachment(messageForm.getAttachmentFile()); + Set attSet = message.getAttachments(); + if (attSet == null) { + attSet = new HashSet(); + } + // only allow one attachment, so replace whatever + attSet.clear(); + attSet.add(att); + message.setAttachments(attSet); + } else if (!messageForm.isHasAttachment()) { + // user already called deleteAttachment in AJAX call + if (message.getAttachments() != null) { + Set atts = message.getAttachments(); + atts.clear(); + message.setAttachments(atts); + } else { + message.setAttachments(null); + } + } + } + + private SessionMap getSessionMap(HttpServletRequest request, MessageForm messageForm) { + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(messageForm.getSessionMapID()); + return sessionMap; + } + +} Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/MonitoringController.java (revision 0) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/controller/MonitoringController.java (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,759 @@ +/**************************************************************** + * 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.forum.web.controller; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TimeZone; +import java.util.TreeMap; +import java.util.TreeSet; + +import javax.servlet.ServletException; +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.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.lamsfoundation.lams.tool.forum.dto.MessageDTO; +import org.lamsfoundation.lams.tool.forum.dto.SessionDTO; +import org.lamsfoundation.lams.tool.forum.persistence.Forum; +import org.lamsfoundation.lams.tool.forum.persistence.ForumReport; +import org.lamsfoundation.lams.tool.forum.persistence.ForumToolSession; +import org.lamsfoundation.lams.tool.forum.persistence.ForumUser; +import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.tool.forum.service.IForumService; +import org.lamsfoundation.lams.tool.forum.util.ForumConstants; +import org.lamsfoundation.lams.tool.forum.util.ForumUserComparator; +import org.lamsfoundation.lams.tool.forum.util.ForumWebUtils; +import org.lamsfoundation.lams.tool.forum.util.MessageDTOByDateComparator; +import org.lamsfoundation.lams.tool.forum.util.SessionDTOComparator; +import org.lamsfoundation.lams.tool.forum.web.forms.ForumForm; +import org.lamsfoundation.lams.tool.forum.web.forms.MarkForm; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.NumberUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +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.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +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 org.springframework.web.util.HtmlUtils; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +@Controller +@RequestMapping("/monitoring") +public class MonitoringController { + + private static Logger log = Logger.getLogger(MonitoringController.class); + + @Autowired + @Qualifier("forumService") + private IForumService forumService; + + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + + @Autowired + private WebApplicationContext applicationContext; + + /** + * The initial method for monitoring + */ + @RequestMapping("/monitoring") + public String init(HttpServletRequest request) { + + // set back tool content ID + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); + + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentID); + + request.setAttribute("initialTabId", WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true)); + + // perform the actions for all the tabs. + summary(request); + viewInstructions(request); + viewActivity(request); + // statistic(request); + + return "jsps/monitoring/monitoring"; + } + + /** + * The initial method for monitoring. List all users according to given Content ID. + */ + public void summary(HttpServletRequest request) { + Long toolContentId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + // create sessionMap + SessionMap sessionMap = new SessionMap<>(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + + Forum forum = forumService.getForumByContentId(toolContentId); + sessionMap.put("forum", forum); + + List sessions = forumService.getSessionsByContentId(toolContentId); + + Set sessionDtos = new TreeSet<>(new SessionDTOComparator()); + // build a map with all users in the forumSessionList + for (ForumToolSession session : sessions) { + Long sessionId = session.getSessionId(); + SessionDTO sessionDto = new SessionDTO(); + + sessionDto.setSessionID(sessionId); + sessionDto.setSessionName(session.getSessionName()); + + // used for storing data for MonitoringAction.getUsers() serving tablesorter paging + List topics = forumService.getAllTopicsFromSession(sessionId); + Map> topicsByUser = getTopicsSortedByAuthor(topics); + sessionDto.setTopicsByUser(topicsByUser); + + sessionDtos.add(sessionDto); + } + sessionMap.put(ForumConstants.ATTR_SESSION_DTOS, sessionDtos); + + // check if there is submission deadline + Date submissionDeadline = forum.getSubmissionDeadline(); + if (submissionDeadline != null) { + HttpSession ss = SessionManager.getSession(); + org.lamsfoundation.lams.usermanagement.dto.UserDTO learnerDto = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss + .getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + sessionMap.put(ForumConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); + // use the unconverted time, as convertToStringForJSON() does the timezone conversion if needed + request.setAttribute(ForumConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, + DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale())); + } + + boolean isGroupedActivity = forumService.isGroupedActivity(toolContentId); + sessionMap.put("isGroupedActivity", isGroupedActivity); + } + + /** + * Refreshes user list. + */ + @RequestMapping(path = "/getUsers", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String getUsers(HttpServletRequest request) throws IOException, ServletException { + String sessionMapId = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + + // teacher timezone + HttpSession ss = SessionManager.getSession(); + org.lamsfoundation.lams.usermanagement.dto.UserDTO teacher = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss + .getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + + Long sessionId = WebUtil.readLongParam(request, "sessionId"); + + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); + Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true); + Integer isSort3 = WebUtil.readIntParam(request, "column[2]", true); + Integer isSort4 = WebUtil.readIntParam(request, "column[3]", true); + String searchString = request.getParameter("fcol[0]"); + + int sorting = ForumConstants.SORT_BY_NO; + if ((isSort1 != null) && isSort1.equals(0)) { + sorting = ForumConstants.SORT_BY_USER_NAME_ASC; + + } else if ((isSort1 != null) && isSort1.equals(1)) { + sorting = ForumConstants.SORT_BY_USER_NAME_DESC; + + } else if ((isSort2 != null) && isSort2.equals(0)) { + sorting = ForumConstants.SORT_BY_NUMBER_OF_POSTS_ASC; + + } else if ((isSort2 != null) && isSort2.equals(1)) { + sorting = ForumConstants.SORT_BY_NUMBER_OF_POSTS_DESC; + + } else if ((isSort3 != null) && isSort3.equals(0)) { + sorting = ForumConstants.SORT_BY_LAST_POSTING_ASC; + + } else if ((isSort3 != null) && isSort3.equals(1)) { + sorting = ForumConstants.SORT_BY_LAST_POSTING_DESC; + + } else if ((isSort4 != null) && isSort4.equals(0)) { + sorting = ForumConstants.SORT_BY_MARKED_ASC; + + } else if ((isSort4 != null) && isSort4.equals(1)) { + sorting = ForumConstants.SORT_BY_MARKED_DESC; + } + + Set sessionDtos = (Set) sessionMap.get(ForumConstants.ATTR_SESSION_DTOS); + SessionDTO currentSessionDto = null; + for (SessionDTO sessionDto : sessionDtos) { + if (sessionDto.getSessionID().equals(sessionId)) { + currentSessionDto = sessionDto; + break; + } + } + Map> topicsByUser = currentSessionDto.getTopicsByUser(); + + Forum forum = (Forum) sessionMap.get("forum"); + List users = forumService.getUsersForTablesorter(sessionId, page, size, sorting, searchString, + forum.isReflectOnActivity()); + + ArrayNode rows = JsonNodeFactory.instance.arrayNode(); + + ObjectNode responcedata = JsonNodeFactory.instance.objectNode(); + responcedata.put("total_rows", forumService.getCountUsersBySession(sessionId, searchString)); + + for (Object[] userAndReflection : users) { + + ObjectNode responseRow = JsonNodeFactory.instance.objectNode(); + + ForumUser user = (ForumUser) userAndReflection[0]; + + responseRow.put(ForumConstants.ATTR_USER_UID, user.getUid()); + responseRow.put(ForumConstants.ATTR_USER_ID, user.getUserId()); + responseRow.put("userName", HtmlUtils.htmlEscape(user.getLastName() + " " + user.getFirstName())); + + int numberOfPosts = 0; + boolean isAnyPostsMarked = false; + if (topicsByUser.get(user) != null) { + + // sort messages by date + TreeSet messages = new TreeSet<>(new MessageDTOByDateComparator()); + messages.addAll(topicsByUser.get(user)); + + MessageDTO lastMessage = messages.last(); + + // format lastEdited date + Date lastMessageDate = lastMessage.getMessage().getUpdated(); + DateFormat dateFormatter = new SimpleDateFormat("d MMMM yyyy h:mm:ss a"); + responseRow.put("lastMessageDate", dateFormatter.format(lastMessageDate)); + responseRow.put("timeAgo", DateUtil.convertToStringForTimeagoJSON(lastMessageDate)); + numberOfPosts = messages.size(); + for (MessageDTO message : messages) { + if (message.getMark() != null) { + isAnyPostsMarked = true; + break; + } + } + } + responseRow.put("anyPostsMarked", isAnyPostsMarked); + responseRow.put("numberOfPosts", numberOfPosts); + + if (userAndReflection.length > 1 && userAndReflection[1] != null) { + responseRow.put("notebookEntry", HtmlUtils.htmlEscape((String) userAndReflection[1])); + } + + if (userAndReflection.length > 2 && userAndReflection[2] != null) { + responseRow.put(ForumConstants.ATTR_PORTRAIT_ID, (String) userAndReflection[2]); + } + + rows.add(responseRow); + } + responcedata.set("rows", rows); + + return responcedata.toString(); + } + + /** + * Download marks for all users in a speical session. + */ + @RequestMapping("/downloadMarks") + public String downloadMarks(HttpServletRequest request, HttpServletResponse response) { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + List topicList = forumService.getAllTopicsFromSession(sessionID); + // construct Excel file format and download + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + try { + // create an empty excel file + HSSFWorkbook wb = new HSSFWorkbook(); + + HSSFSheet sheet = wb.createSheet("Marks"); + sheet.setColumnWidth(0, 5000); + HSSFRow row = null; + HSSFCell cell; + Iterator iter = getTopicsSortedByAuthor(topicList).values().iterator(); + Iterator dtoIter; + boolean first = true; + int idx = 0; + int fileCount = 0; + while (iter.hasNext()) { + List list = (List) iter.next(); + dtoIter = list.iterator(); + first = true; + + while (dtoIter.hasNext()) { + MessageDTO dto = (MessageDTO) dtoIter.next(); + if (first) { + first = false; + row = sheet.createRow(0); + cell = row.createCell(idx); + cell.setCellValue(messageService.getMessage("lable.topic.title.subject")); + sheet.setColumnWidth(idx, 8000); + ++idx; + + cell = row.createCell(idx); + cell.setCellValue(messageService.getMessage("lable.topic.title.author")); + sheet.setColumnWidth(idx, 8000); + ++idx; + + cell = row.createCell(idx); + cell.setCellValue(messageService.getMessage("label.download.marks.heading.date")); + sheet.setColumnWidth(idx, 8000); + ++idx; + + cell = row.createCell(idx); + cell.setCellValue(messageService.getMessage("label.download.marks.heading.marks")); + sheet.setColumnWidth(idx, 8000); + ++idx; + + cell = row.createCell(idx); + cell.setCellValue(messageService.getMessage("label.download.marks.heading.comments")); + sheet.setColumnWidth(idx, 8000); + ++idx; + } + ++fileCount; + idx = 0; + row = sheet.createRow(fileCount); + cell = row.createCell(idx++); + cell.setCellValue(dto.getMessage().getSubject()); + + cell = row.createCell(idx++); + cell.setCellValue(dto.getAuthor()); + + cell = row.createCell(idx++); + cell.setCellValue(DateFormat.getInstance().format(dto.getMessage().getCreated())); + + cell = row.createCell(idx++); + + if (dto.getMessage() != null && dto.getMessage().getReport() != null + && dto.getMessage().getReport().getMark() != null) { + cell.setCellValue(NumberUtil.formatLocalisedNumber(dto.getMessage().getReport().getMark(), + request.getLocale(), 2)); + } else { + cell.setCellValue(""); + } + + cell = row.createCell(idx++); + if (dto.getMessage() != null && dto.getMessage().getReport() != null) { + cell.setCellValue(dto.getMessage().getReport().getComment()); + } else { + cell.setCellValue(""); + } + } + } + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + wb.write(bos); + // construct download file response header + String fileName = "marks" + sessionID + ".xls"; + String mineType = "application/vnd.ms-excel"; + String header = "attachment; filename=\"" + fileName + "\";"; + response.setContentType(mineType); + response.setHeader("Content-Disposition", header); + + byte[] data = bos.toByteArray(); + response.getOutputStream().write(data, 0, data.length); + response.getOutputStream().flush(); + } catch (IOException e) { + MonitoringController.log.error(e); + errorMap.add("GLOBAL", messageService.getMessage("monitoring.download.error", e.toString())); + } + + if (!errorMap.isEmpty()) { + request.setAttribute("errorMap", errorMap); + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID); + return "jsps/monitoring/monitoring"; + } + + return null; + } + + /** + * View activity for content. + */ + private void viewActivity(HttpServletRequest request) { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + Forum forum = forumService.getForumByContentId(toolContentID); + String title = forum.getTitle(); + String instruction = forum.getInstructions(); + + boolean isForumEditable = ForumWebUtils.isForumEditable(forum); + request.setAttribute(ForumConstants.PAGE_EDITABLE, new Boolean(isForumEditable)); + request.setAttribute("title", title); + request.setAttribute("instruction", instruction); + } + + /** + * View instruction information for a content. + */ + private void viewInstructions(HttpServletRequest request) { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + Forum forum = forumService.getForumByContentId(toolContentID); + ForumForm forumForm = new ForumForm(); + forumForm.setForum(forum); + + request.setAttribute("forumForm", forumForm); + } + + /** + * Performs all necessary actions for showing statistic page. + */ + @RequestMapping("/statistic") + public String statistic(HttpServletRequest request) { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + Map sessionTopicsMap = new TreeMap>(new SessionDTOComparator()); + Map sessionAvaMarkMap = new HashMap(); + Map sessionTotalMsgMap = new HashMap(); + + List sessList = forumService.getSessionsByContentId(toolContentID); + Iterator sessIter = sessList.iterator(); + while (sessIter.hasNext()) { + ForumToolSession session = (ForumToolSession) sessIter.next(); + List topicList = forumService.getRootTopics(session.getSessionId()); + Iterator iter = topicList.iterator(); + int totalMsg = 0; + int msgNum; + float totalMsgMarkSum = 0; + float msgMarkSum = 0; + for (; iter.hasNext();) { + MessageDTO msgDto = (MessageDTO) iter.next(); + // get all message under this topic + List topicThread = forumService.getTopicThread(msgDto.getMessage().getUid()); + // loop all message under this topic + msgMarkSum = 0; + Iterator threadIter = topicThread.iterator(); + for (msgNum = 0; threadIter.hasNext(); msgNum++) { + MessageDTO dto = (MessageDTO) threadIter.next(); + if (dto.getMark() != null) { + msgMarkSum += dto.getMark().floatValue(); + } + } + // summary to total mark + totalMsgMarkSum += msgMarkSum; + // set average mark to topic message DTO for display use + msgDto.setMark(msgMarkSum / msgNum); + totalMsg += msgNum; + } + + float averMark = totalMsg == 0 ? 0 : totalMsgMarkSum / totalMsg; + + SessionDTO sessionDto = new SessionDTO(); + sessionDto.setSessionID(session.getSessionId()); + sessionDto.setSessionName(session.getSessionName()); + + sessionTopicsMap.put(sessionDto, topicList); + sessionAvaMarkMap.put(session.getSessionId(), averMark); + sessionTotalMsgMap.put(session.getSessionId(), new Integer(totalMsg)); + } + request.setAttribute("topicList", sessionTopicsMap); + request.setAttribute("markAverage", sessionAvaMarkMap); + request.setAttribute("totalMessage", sessionTotalMsgMap); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, + WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID)); + + return "jsps/monitoring/statisticpart"; + } + + /** + * View all messages under one topic. + */ + @RequestMapping("/viewTopicTree") + public String viewTopicTree(HttpServletRequest request) { + + Long rootTopicId = WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID); + // get root topic list + List msgDtoList = forumService.getTopicThread(rootTopicId); + request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList); + + return "jsps/monitoring/message/viewtopictree"; + } + + /** + * View topic subject, content and attachement. + */ + @RequestMapping("/viewTopic") + public String viewTopic(HttpServletRequest request) { + + Long msgUid = new Long(WebUtil.readLongParam(request, ForumConstants.ATTR_TOPIC_ID)); + + Message topic = forumService.getMessage(msgUid); + + request.setAttribute(ForumConstants.AUTHORING_TOPIC, MessageDTO.getMessageDTO(topic)); + return "jsps/monitoring/message/viewtopic"; + } + + @RequestMapping("/releaseMark") + @ResponseBody + public String releaseMark(HttpServletRequest request, HttpServletResponse response) { + // get service then update report table + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + forumService.releaseMarksForSession(sessionID); + + try { + response.setContentType("text/html;charset=utf-8"); + PrintWriter out = response.getWriter(); + ForumToolSession session = forumService.getSessionBySessionId(sessionID); + String sessionName = ""; + if (session != null) { + sessionName = session.getSessionName(); + } + out.write(messageService.getMessage("msg.mark.released", new String[] { sessionName })); + out.flush(); + + } catch (IOException e) { + } + return null; + } + + // ========================================================================================== + // View and update marks methods + // ========================================================================================== + + /** + * View a special user's mark + */ + @RequestMapping("/viewUserMark") + public String viewUserMark(HttpServletRequest request) { + Long userUid = new Long(WebUtil.readLongParam(request, ForumConstants.USER_UID)); + Long sessionId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + + // create sessionMap + String sessionMapId = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapId); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapId); + + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); + sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_USER); + + // get this user's all topics + List messages = forumService.getMessagesByUserUid(userUid, sessionId); + request.setAttribute(ForumConstants.ATTR_MESSAGES, messages); + + ForumUser user = forumService.getUser(userUid); + request.setAttribute(ForumConstants.ATTR_USER, user); + + return "jsps/monitoring/viewmarks"; + } + + /** + * Edit a special user's mark. + */ + @RequestMapping("/editMark") + public String editMark(@ModelAttribute MarkForm markForm, HttpServletRequest request) { + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(markForm.getSessionMapID()); + String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE); + // view forum mode + if (StringUtils.isBlank(updateMode)) { + sessionMap.put(ForumConstants.PARAM_UPDATE_MODE, ForumConstants.MARK_UPDATE_FROM_FORUM); + sessionMap.put(ForumConstants.ATTR_ROOT_TOPIC_UID, markForm.getTopicID()); + } + + // get Message and User from database + Message msg = forumService.getMessage(markForm.getTopicID()); + ForumUser user = msg.getCreatedBy(); + + // echo back to web page + if (msg.getReport() != null) { + if (msg.getReport().getMark() != null) { + markForm.setMark(NumberUtil.formatLocalisedNumber(msg.getReport().getMark(), request.getLocale(), 2)); + } else { + markForm.setMark(""); + } + markForm.setComment(msg.getReport().getComment()); + } + + // each back to web page + request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg)); + request.setAttribute(ForumConstants.ATTR_USER, user); + + // Should we show the reflection or not? We shouldn't show it when the View Forum screen is accessed + // from the Monitoring Summary screen, but we should when accessed from the Learner Progress screen. + // Need to constantly past this value on, rather than hiding just the once, as the View Forum + // screen has a refresh button. Need to pass it through the view topic screen and dependent screens + // as it has a link from the view topic screen back to View Forum screen. + boolean hideReflection = WebUtil.readBooleanParam(request, ForumConstants.ATTR_HIDE_REFLECTION, false); + sessionMap.put(ForumConstants.ATTR_HIDE_REFLECTION, hideReflection); + + return "jsps/monitoring/updatemarks"; + } + + /** + * Update mark for a special user + */ + @RequestMapping("/updateMark") + public String updateMark(@ModelAttribute MarkForm markForm, HttpServletRequest request, + HttpServletResponse response) { + + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, markForm.getSessionMapID()); + String markStr = markForm.getMark(); + Float mark = null; + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + if (StringUtils.isBlank(markStr)) { + errorMap.add("report.mark", messageService.getMessage("error.valueReqd")); + } else { + try { + mark = NumberUtil.getLocalisedFloat(markStr, request.getLocale()); + } catch (Exception e) { + errorMap.add("report.mark", messageService.getMessage("error.mark.invalid.number")); + } + } + + // echo back to web page + Message msg = forumService.getMessage(markForm.getTopicID()); + ForumUser user = msg.getCreatedBy(); + + request.setAttribute(ForumConstants.ATTR_USER, user); + if (!errorMap.isEmpty()) { + // each back to web page + request.setAttribute(ForumConstants.ATTR_TOPIC, MessageDTO.getMessageDTO(msg)); + request.setAttribute("errorMap", errorMap); + return "jsps/monitoring/monitoring"; + } + + // update message report + + ForumReport report = msg.getReport(); + if (report == null) { + report = new ForumReport(); + msg.setReport(report); + } + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(markForm.getSessionMapID()); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE); + + report.setMark(mark); + report.setComment(markForm.getComment()); + forumService.updateContainedReport(msg); + + // echo back to topic list page: it depends which screen is come from: view special user mark, or view all user + // marks. + if (StringUtils.equals(updateMode, ForumConstants.MARK_UPDATE_FROM_USER)) { + List messages = forumService.getMessagesByUserUid(user.getUid(), sessionId); + request.setAttribute(ForumConstants.ATTR_MESSAGES, messages); + // listMark + return "jsps/monitoring/viewmarks"; + + } else { // mark from view forum + // display root topic rather than leaf one + Long rootTopicId = forumService.getRootTopicId(msg.getUid()); + + String redirect = "redirect:/viewTopic.do"; + redirect = WebUtil.appendParameterToURL(redirect, ForumConstants.ATTR_SESSION_MAP_ID, + markForm.getSessionMapID()); + redirect = WebUtil.appendParameterToURL(redirect, ForumConstants.ATTR_USER, user.toString()); + redirect = WebUtil.appendParameterToURL(redirect, ForumConstants.ATTR_TOPIC_ID, rootTopicId.toString()); + return redirect; + } + + } + + /** + * Set Submission Deadline + */ + @RequestMapping(path = "setSubmissionDeadline", produces = MediaType.TEXT_PLAIN_VALUE) + @ResponseBody + public String setSubmissionDeadline(HttpServletRequest request) throws IOException { + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Forum forum = forumService.getForumByContentId(contentID); + + Long dateParameter = WebUtil.readLongParam(request, ForumConstants.ATTR_SUBMISSION_DEADLINE, true); + Date tzSubmissionDeadline = null; + String formattedDate = ""; + if (dateParameter != null) { + Date submissionDeadline = new Date(dateParameter); + HttpSession ss = SessionManager.getSession(); + org.lamsfoundation.lams.usermanagement.dto.UserDTO teacher = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss + .getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline); + formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale()); + } + forum.setSubmissionDeadline(tzSubmissionDeadline); + forumService.updateForum(forum); + + return formattedDate; + } + + // ========================================================================================== + // Utility methods + // ========================================================================================== + + private Map> getTopicsSortedByAuthor(List topics) { + Map> topicsByUser = new TreeMap<>(new ForumUserComparator()); + for (MessageDTO topic : topics) { + if (topic.getMessage().getIsAuthored()) { + continue; + } + topic.getMessage().getReport(); + ForumUser user = (ForumUser) topic.getMessage().getCreatedBy().clone(); + + List topicsByUserExist = topicsByUser.get(user); + if (topicsByUserExist == null) { + topicsByUserExist = new ArrayList<>(); + topicsByUser.put(user, topicsByUserExist); + } + topicsByUserExist.add(topic); + } + return topicsByUser; + } +} Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/AdminForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/AdminForm.java (.../AdminForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/AdminForm.java (.../AdminForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -22,9 +22,7 @@ package org.lamsfoundation.lams.tool.forum.web.forms; -import org.apache.struts.action.ActionForm; - -public class AdminForm extends ActionForm { +public class AdminForm { private static final long serialVersionUID = -9080785256404216422L; private boolean keepLearnerContent; Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumConditionForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumConditionForm.java (.../ForumConditionForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumConditionForm.java (.../ForumConditionForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -20,13 +20,13 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.forum.web.forms; -import org.apache.struts.util.LabelValueBean; +import java.util.Map; + import org.lamsfoundation.lams.tool.forum.persistence.ForumCondition; import org.lamsfoundation.lams.tool.forum.persistence.Message; -import org.lamsfoundation.lams.web.TextSearchActionForm; +import org.lamsfoundation.lams.web.TextSearchForm; /** * A text search form with additional parameters for Forum needs. @@ -35,11 +35,11 @@ * @author Marcin Cieslak * */ -public class ForumConditionForm extends TextSearchActionForm { +public class ForumConditionForm extends TextSearchForm { /** * Names of the topics that could be selected by a user. */ - private LabelValueBean[] possibleItems; + private Map possibleItems; /** * Dates of creation of topics that were selected by a user. */ @@ -71,11 +71,11 @@ setSelectedItems(selectedItems); } - public LabelValueBean[] getPossibleItems() { + public Map getPossibleItems() { return possibleItems; } - public void setPossibleItems(LabelValueBean[] possibleItems) { + public void setPossibleItems(Map possibleItems) { this.possibleItems = possibleItems; } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -21,14 +21,11 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.forum.web.forms; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.forum.persistence.Forum; /** @@ -40,7 +37,7 @@ * Date: 10/06/2005 * Time: 15:44:36 */ -public class ForumForm extends ActionForm { +public class ForumForm { private static final long serialVersionUID = -6054354910960460120L; private static Logger logger = Logger.getLogger(ForumForm.class.getName()); @@ -65,7 +62,7 @@ /** * Initialize this form by given Forum instance. - * + * * @param forum */ public void setForum(Forum forum) { @@ -79,8 +76,7 @@ } - @Override - public void reset(ActionMapping mapping, HttpServletRequest request) { + public void reset(HttpServletRequest request) { forum.setAllowEdit(false); forum.setAllowAnonym(false); forum.setAllowRichEditor(false); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumPedagogicalPlannerForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumPedagogicalPlannerForm.java (.../ForumPedagogicalPlannerForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumPedagogicalPlannerForm.java (.../ForumPedagogicalPlannerForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -20,7 +20,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.forum.web.forms; import java.util.ArrayList; @@ -29,24 +28,31 @@ import java.util.TreeSet; import org.apache.commons.lang.StringUtils; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.tool.forum.persistence.Forum; import org.lamsfoundation.lams.tool.forum.persistence.Message; import org.lamsfoundation.lams.tool.forum.util.MessageComparator; -import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivitySpringForm; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; /** * */ -public class ForumPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { +public class ForumPedagogicalPlannerForm extends PedagogicalPlannerActivitySpringForm { + + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + private List topic; private String contentFolderID; private String instructions; - @Override - public ActionMessages validate() { - ActionMessages errors = new ActionMessages(); + public MultiValueMap validate() { + MultiValueMap errorMap = new LinkedMultiValueMap<>(); boolean valid = true; boolean allEmpty = true; if (topic != null && !topic.isEmpty()) { @@ -58,23 +64,22 @@ } } if (allEmpty) { - ActionMessage error = new ActionMessage("error.must.have.topic"); - errors.add(ActionMessages.GLOBAL_MESSAGE, error); + errorMap.add("GLOBAL", messageService.getMessage("error.must.have.topic")); valid = false; topic = null; } setValid(valid); - return errors; + return errorMap; } public void fillForm(Forum forum) { if (forum != null) { setToolContentID(forum.getContentId()); setInstructions(forum.getInstructions()); - topic = new ArrayList(); - Set messages = new TreeSet(new MessageComparator()); + topic = new ArrayList<>(); + Set messages = new TreeSet<>(new MessageComparator()); messages.addAll(forum.getMessages()); if (messages != null) { int topicIndex = 0; @@ -89,7 +94,7 @@ public void setTopic(int number, String Topics) { if (topic == null) { - topic = new ArrayList(); + topic = new ArrayList<>(); } while (number >= topic.size()) { topic.add(null); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java (.../MarkForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MarkForm.java (.../MarkForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -21,19 +21,15 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.forum.web.forms; -import org.apache.struts.action.ActionForm; - /** * * @author Steve.Ni * * @version $Revision$ */ -public class MarkForm extends ActionForm { +public class MarkForm { private static final long serialVersionUID = -4967675292027554366L; private String mark; Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -21,20 +21,23 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.forum.web.forms; +import javax.servlet.http.HttpServletRequest; + import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.upload.FormFile; -import org.apache.struts.validator.ValidatorForm; import org.lamsfoundation.lams.tool.forum.persistence.Attachment; +import org.lamsfoundation.lams.tool.forum.persistence.Forum; import org.lamsfoundation.lams.tool.forum.persistence.Message; import org.lamsfoundation.lams.util.FileUtil; -import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.FileValidatorSpringUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.multipart.MultipartFile; /** * @@ -44,10 +47,14 @@ * * User: conradb Date: 10/06/2005 Time: 15:44:47 */ -public class MessageForm extends ValidatorForm { +public class MessageForm { private static final long serialVersionUID = -9054365604649146734L; private static Logger logger = Logger.getLogger(MessageForm.class.getName()); + @Autowired + @Qualifier("forumMessageService") + private MessageService messageService; + protected Message message; protected String sessionMapID; protected Long forumId; @@ -58,7 +65,7 @@ // attachment file name private String attachmentName; // Message attachment file - private FormFile attachmentFile; + private MultipartFile attachmentFile; public MessageForm() { message = new Message(); @@ -68,37 +75,35 @@ * MessageForm validation method from STRUCT interface. * */ - @Override - public ActionErrors validate(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { - ActionErrors errors = new ActionErrors(); + public MultiValueMap validate(HttpServletRequest request) { + + Forum forum = null; + MultiValueMap errorMap = new LinkedMultiValueMap<>(); try { if (StringUtils.isBlank(message.getSubject())) { - ActionMessage error = new ActionMessage("error.subject.required"); - errors.add("message.subject", error); + errorMap.add("message.subject" + forum.getUid(), messageService.getMessage("error.subject.required")); } boolean isTestHarness = Boolean.valueOf(request.getParameter("testHarness")); if (!isTestHarness && StringUtils.isBlank(message.getBody())) { - ActionMessage error = new ActionMessage("error.body.required"); - errors.add("message.body", error); + errorMap.add("message.body" + forum.getUid(), messageService.getMessage("error.body.required")); } // validate item size boolean largeFile = true; if (request.getRequestURI().indexOf("/learning/") != -1) { if ((this.getAttachmentFile() != null) - && FileUtil.isExecutableFile(this.getAttachmentFile().getFileName())) { - ActionMessage error = new ActionMessage("error.attachment.executable"); - errors.add("message.attachment", error); + && FileUtil.isExecutableFile(this.getAttachmentFile().getOriginalFilename())) { + errorMap.add("message.attachment" + forum.getUid(), messageService.getMessage("error.attachment.executable")); } largeFile = false; } - FileValidatorUtil.validateFileSize(this.getAttachmentFile(), largeFile, "message.attachment", errors); + FileValidatorSpringUtil.validateFileSize(this.getAttachmentFile(), largeFile); } catch (Exception e) { MessageForm.logger.error("", e); } - return errors; + return errorMap; } // -------------------------get/set methods---------------- @@ -151,11 +156,11 @@ this.attachmentName = attachmentName; } - public FormFile getAttachmentFile() { + public MultipartFile getAttachmentFile() { return attachmentFile; } - public void setAttachmentFile(FormFile attachmentFile) { + public void setAttachmentFile(MultipartFile attachmentFile) { this.attachmentFile = attachmentFile; } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ReflectionForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ReflectionForm.java (.../ReflectionForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ReflectionForm.java (.../ReflectionForm.java) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -21,19 +21,17 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.forum.web.forms; import org.apache.log4j.Logger; -import org.apache.struts.validator.ValidatorForm; /** * * Reflection Form. * * */ -public class ReflectionForm extends ValidatorForm { +public class ReflectionForm { private static final long serialVersionUID = -9054365604649146735L; private static Logger logger = Logger.getLogger(ReflectionForm.class.getName()); Index: lams_tool_forum/web/WEB-INF/spring-servlet.xml =================================================================== diff -u --- lams_tool_forum/web/WEB-INF/spring-servlet.xml (revision 0) +++ lams_tool_forum/web/WEB-INF/spring-servlet.xml (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/struts-config.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_forum/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/AuthoringRatingCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/CommentsAuthor.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -42,23 +42,21 @@
    -     -   +     +  
    Index: lams_tool_forum/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/Rating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/StyledRating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/TabBody.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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_forum/web/WEB-INF/tags/TabBodyArea.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -30,7 +30,6 @@ %> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-bean" prefix="bean"%>
    Index: lams_tool_forum/web/WEB-INF/tags/TextSearch.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -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 Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tiles-defs.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_forum/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -212,192 +212,6 @@ - - STRUTS-textarea - org.lamsfoundation.lams.web.tag.MultiLinesTextareaTag - empty - - accesskey - false - true - - - alt - false - true - - - altKey - false - true - - - bundle - false - true - - - cols - false - true - - - disabled - false - true - - - errorKey - false - true - - - errorStyle - false - true - - - errorStyleClass - false - true - - - errorStyleId - false - true - - - index - false - true - - - indexed - false - true - - - name - false - true - - - onblur - false - true - - - onchange - false - true - - - onclick - false - true - - - ondblclick - false - true - - - onfocus - false - true - - - onkeydown - false - true - - - onkeypress - false - true - - - onkeyup - false - true - - - onmousedown - false - true - - - onmousemove - false - true - - - onmouseout - false - true - - - onmouseover - false - true - - - onmouseup - false - true - - - property - true - true - - - readonly - false - true - - - rows - false - true - - - style - false - true - - - styleClass - false - true - - - styleId - false - true - - - tabindex - false - true - - - title - false - true - - - titleKey - false - true - - - value - false - true - - - Small portrait of a user User Portrait Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-bean-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-bean.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-html-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-html.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-logic-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-logic.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-nested.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-tiles-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/tlds/struts/struts-tiles.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/validation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf refers to a dead (removed) revision in file `lams_tool_forum/web/WEB-INF/validator-rules.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_forum/web/WEB-INF/web.xml =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/WEB-INF/web.xml (.../web.xml) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -65,36 +65,21 @@ /* + + 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 - - - Connector net.fckeditor.connector.ConnectorServlet @@ -122,7 +107,7 @@ - action + spring *.do @@ -151,43 +136,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_forum/web/common/messages.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/common/messages.jsp (.../messages.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/common/messages.jsp (.../messages.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,8 +1,8 @@ -<%-- Error Messages --%> - - - - - - - + + + + +
    +
    +
    +
    \ No newline at end of file Index: lams_tool_forum/web/common/taglibs.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/common/taglibs.jsp (.../taglibs.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/common/taglibs.jsp (.../taglibs.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,12 +1,8 @@ <%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> -<%@ taglib uri="tags-tiles" prefix="tiles" %> -<%@ taglib uri="tags-bean" prefix="bean" %> -<%@ taglib uri="tags-html" prefix="html" %> -<%@ taglib uri="tags-logic" prefix="logic" %> <%@ taglib uri="tags-function" prefix="fn" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> <%@ taglib uri="tags-xml" prefix="x" %> <%@ taglib uri="tags-lams" prefix="lams" %> - + <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> Index: lams_tool_forum/web/jsps/admin/config.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/admin/config.jsp (.../config.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/admin/config.jsp (.../config.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -11,7 +11,7 @@ - + @@ -23,14 +23,14 @@
    - +
    - -
    + + Index: lams_tool_forum/web/jsps/authoring/addCondition.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/authoring/addCondition.jsp (.../addCondition.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/authoring/addCondition.jsp (.../addCondition.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -19,31 +19,28 @@ <%@ include file="/common/messages.jsp"%> - - + +
    - +
    <%-- Text search form fields are being included --%> - +

    -
    - -
    - -
    -
    + +
    + +
    +
    - +
    Index: lams_tool_forum/web/jsps/authoring/advance.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/authoring/advance.jsp (.../advance.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/authoring/advance.jsp (.../advance.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -7,33 +7,33 @@
    -
    -
    -
    -
    -
    -
    -
    @@ -83,17 +83,17 @@
    -
    -
    @@ -125,44 +125,44 @@ key="label.authoring.advanced.send.emails.to" />
    -
    -
    -
    -
    -
    - +
    + + + - - - - - - - + - - + + + + + + + + + + + + + + + + + + + <%@ include file="/common/messages.jsp"%> + + + + + + + + + + + + + + + + + - - - - - - - - <%@ include file="/common/messages.jsp"%> - - - - - - - - - - - - - - - - + + + + + + Index: lams_tool_forum/web/jsps/authoring/basic.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/authoring/basic.jsp (.../basic.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/authoring/basic.jsp (.../basic.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -4,8 +4,6 @@ <%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_LARGE_MAX_SIZE)%> <%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> - - + + + <fmt:message key="activity.title" /> - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    + +
    +
    + + + + + + + + + <%@ include file="/jsps/learning/message/topicform.jsp"%> +
    +
    +
    +
    + +
    + - + +
    -
    -
    -
    - -
    -
    - - <%@ include file="/jsps/learning/message/topicform.jsp"%> -
    -
    -
    - - - - Index: lams_tool_forum/web/jsps/learning/definelater.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/definelater.jsp (.../definelater.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/definelater.jsp (.../definelater.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,11 +1,55 @@ + <%@ include file="/common/taglibs.jsp"%> +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE)%> +<%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> + + + - + + + <fmt:message key="activity.title" /> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - Index: lams_tool_forum/web/jsps/learning/edit.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/edit.jsp (.../edit.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/edit.jsp (.../edit.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,97 +1,148 @@ + <%@ include file="/common/taglibs.jsp"%> +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE)%> +<%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> + + + - + + + <fmt:message key="activity.title" /> - + + + + + + + + + + + + + - + + - + + + + + + + + +
    +
    +
    + +
    +
    + + + + + + + + + <%@ include file="/jsps/learning/message/topiceditform.jsp"%> +
    +
    +
    + +
    -
    -
    -
    - -
    -
    - - <%@ include file="/jsps/learning/message/topiceditform.jsp"%> -
    -
    -
    + +
    - - - - - Index: lams_tool_forum/web/jsps/learning/message/bodyarea.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/message/bodyarea.jsp (.../bodyarea.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/message/bodyarea.jsp (.../bodyarea.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -5,14 +5,14 @@ - <%-- Does not user general tag because this field need keep compatible with CKEditor's content --%> - + + + + + + + + + + Index: lams_tool_forum/web/jsps/learning/reply.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/reply.jsp (.../reply.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/reply.jsp (.../reply.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,113 +1,168 @@ + <%@ include file="/common/taglibs.jsp"%> +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE)%> +<%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> + + + - + + + <fmt:message key="activity.title" /> - + + + + + + + + + + + + + - + + - + + + + + + + + + + +
    +
    +
    + +
    +
    + + + + + + + + + <%@ include file="/jsps/learning/message/topicreplyform.jsp"%> +
    +
    +
    +
    - - -
    -
    -
    - -
    -
    - - <%@ include file="/jsps/learning/message/topicreplyform.jsp"%> -
    -
    -
    -
    + +
    + Index: lams_tool_forum/web/jsps/learning/submissionDeadline.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,54 +1,102 @@ + <%@ include file="/common/taglibs.jsp"%> - +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE)%> +<%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> + + + - - + + + <fmt:message key="activity.title" /> - - - - - + -
    - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file + + + + + + + + + + + + + + + +
    + + learning/newReflection.do?sessionMapID=${sessionMapID} + + + learning/finish.do?sessionMapID=${sessionMapID} + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + \ No newline at end of file Index: lams_tool_forum/web/jsps/learning/viewforum.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/viewforum.jsp (.../viewforum.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/viewforum.jsp (.../viewforum.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,176 +1,225 @@ + <%@ include file="/common/taglibs.jsp"%> - - - - - - - - - - - - - +<%@ page import="org.lamsfoundation.lams.util.Configuration" %> +<%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> +<%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE)%> +<%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> + + + - + + + <fmt:message key="activity.title" /> - + -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - -
    -
    -
    - + + + + + + + + + + + + + + +
    + + + + + learning/newTopic.do?sessionMapID=${sessionMapID} + + + learning/newReflection.do?sessionMapID=${sessionMapID} + + + learning/finish.do?sessionMapID=${sessionMapID} + + + learning/viewForum.do?mode=${sessionMap.mode}&toolSessionID=${sessionMap.toolSessionID}&sessionMapID=${sessionMapID}&hideReflection=${sessionMap.hideReflection}" + + + - <%@ include file="/common/messages.jsp"%> - - - <%@ include file="/jsps/learning/message/topiclist.jsp"%> - - - - -
    -
    - + + +
    +
    -
    -
    - -
    -
    - - -

    - -

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

    - -

    +
    -
    -
    - - - - + + -
    -
    - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
    + + + + + +
    + + + + <%@ include file="/common/messages.jsp"%> + + + <%@ include file="/jsps/learning/message/topiclist.jsp"%> + + + + +
    +
    + +
    +
    +
    + +
    +
    + + +

    + +

    +
    + +

    + +

    +
    +
    +
    + + + +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + Index: lams_tool_forum/web/jsps/learning/viewtopic.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/learning/viewtopic.jsp (.../viewtopic.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -30,7 +30,7 @@ @@ -53,7 +53,7 @@ function refreshTopic(){ var reqIDVar = new Date(); - location.href= ""+reqIDVar.getTime();; + location.href= "learning/viewTopic.do?sessionMapID=${sessionMapID}&topicID=${sessionMap.rootUid}&hideReflection=${sessionMap.hideReflection}&pageLastId=0&size=${pageSize}&reqUid="+reqIDVar.getTime();; } @@ -134,13 +134,12 @@ key="label.refresh" /> - + learning/viewForum.do?mode=${sessionMap.mode}&sessionMapID=${sessionMapID}&toolSessionID=${sessionMap.toolSessionID}&hideReflection=${sessionMap.hideReflection} - +
    Index: lams_tool_forum/web/jsps/monitoring/editactivity.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/editactivity.jsp (.../editactivity.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/editactivity.jsp (.../editactivity.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,5 +1,4 @@ <%@ include file="/common/taglibs.jsp"%> - @@ -29,13 +28,13 @@ - + - + - + Index: lams_tool_forum/web/jsps/monitoring/monitoring.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/monitoring.jsp (.../monitoring.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,28 +1,81 @@ + + + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.forum.util.ForumConstants"%> - - + + + <fmt:message key="activity.title" /> + <%@ include file="/common/tabbedheader.jsp"%> + + + + + - - - - - - - - - - + - - - - - - - - - @@ -21,9 +21,9 @@ - + - +
    \ No newline at end of file Index: lams_tool_forum/web/jsps/monitoring/statisticpart.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/statisticpart.jsp (.../statisticpart.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/statisticpart.jsp (.../statisticpart.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -74,11 +74,11 @@ - + learning/viewTopic.do?sessionMapID=${sessionMapID}&toolSessionID=${toolSessionDto.sessionID}&topicID=${topic.message.uid}&mode=teacher&hideReflection=true&pageLastId=0 - + - + Index: lams_tool_forum/web/jsps/monitoring/summary.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/summary.jsp (.../summary.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/summary.jsp (.../summary.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -208,27 +208,25 @@

    - + learning/viewForum.do?toolSessionID=${sessionDto.sessionID}&topicID=${topic.message.uid}&mode=teacher&hideReflection=true - + - - + + + + + " /> + - + - +

    Index: lams_tool_forum/web/jsps/monitoring/updatemarks.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/updatemarks.jsp (.../updatemarks.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/updatemarks.jsp (.../updatemarks.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,15 +1,15 @@ <%@ include file="/common/taglibs.jsp"%> - - - + + + - - - + + +

      @@ -20,11 +20,11 @@

    - + learning/viewTopic.do?topicID=${topic.message.uid}&create=${topic.message.created.time}&sessionMapID=${formBean.sessionMapID}&hideReflection=${sessionMap.hideReflection} - + - + @@ -34,12 +34,11 @@

    - +
    - - +
    @@ -49,13 +48,13 @@ - ?sessionMapID=${formBean.sessionMapID}&userUid=${user.uid}&toolSessionID=${sessionMap.toolSessionID} + ?sessionMapID=${markForm.sessionMapID}&userUid=${user.uid}&toolSessionID=${sessionMap.toolSessionID} - ?sessionMapID=${formBean.sessionMapID}&topicID=${sessionMap.rootUid}&hideReflection=${sessionMap.hideReflection} + ?sessionMapID=${markForm.sessionMapID}&topicID=${sessionMap.rootUid}&hideReflection=${sessionMap.hideReflection} @@ -68,4 +67,4 @@ }); -
    + Index: lams_tool_forum/web/jsps/monitoring/viewactivity.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/viewactivity.jsp (.../viewactivity.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/viewactivity.jsp (.../viewactivity.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -1,5 +1,4 @@ <%@ include file="/common/taglibs.jsp"%> - @@ -25,9 +24,9 @@
    - + - +
    Index: lams_tool_forum/web/jsps/monitoring/viewmarks.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf --- lams_tool_forum/web/jsps/monitoring/viewmarks.jsp (.../viewmarks.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_forum/web/jsps/monitoring/viewmarks.jsp (.../viewmarks.jsp) (revision e062c5aeec4bd7e7f970ae5e907e8a7e59edaeaf) @@ -46,11 +46,12 @@
    -
    - - +
    + + + " class="btn btn-default btn-sm" /> - +
    @@ -91,7 +92,7 @@ - + download/?uuid=${file.fileUuid}&versionID=${file.fileVersionId}&preferDownload=true