Fisheye: Tag b55462c1bed962dba08744bf8ceac6594c3462f2 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java (.../AuthoringController.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -21,7 +21,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.notebook.web.controller; import java.util.ArrayList; @@ -32,13 +31,8 @@ import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.authoring.web.AuthoringConstants; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; import org.lamsfoundation.lams.tool.ToolAccessMode; @@ -49,12 +43,12 @@ import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; import org.lamsfoundation.lams.tool.notebook.web.forms.AuthoringForm; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.web.action.LamsDispatchAction; 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.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.context.WebApplicationContext; @@ -67,15 +61,14 @@ * */ @Controller -@RequestMapping("/authoring") -public class AuthoringController{ //extends LamsDispatchAction { +public class AuthoringController { private static Logger logger = Logger.getLogger(AuthoringController.class); - + @Autowired @Qualifier("notebookService") private INotebookService notebookService; - + @Autowired private WebApplicationContext applicationContext; @@ -89,8 +82,8 @@ * toolContentID will be passed in. This will be used to retrieve content for this tool. * */ -// @RequestMapping("/") - protected String unspecified(AuthoringForm authForm, HttpServletRequest request) { + @RequestMapping("/authoring") + protected String unspecified(@ModelAttribute AuthoringForm authoringForm, HttpServletRequest request) { // Extract toolContentID from parameters. Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); @@ -99,11 +92,6 @@ ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); - // set up notebookService - if (notebookService == null) { - notebookService = NotebookServiceProxy.getNotebookService(this.applicationContext.getServletContext()); - } - // retrieving Notebook with given toolContentID Notebook notebook = notebookService.getNotebookByContentId(toolContentID); if (notebook == null) { @@ -118,44 +106,45 @@ // when updateContent is called. notebook.setDefineLater(true); notebookService.saveOrUpdateNotebook(notebook); - + //audit log the teacher has started editing activity in monitor notebookService.auditLogStartEditingActivityInMonitor(toolContentID); } // Set up the authForm. - updateAuthForm(authForm, notebook); + updateAuthForm(authoringForm, notebook); // Set up sessionMap - SessionMap map = createSessionMap(notebook, mode, contentFolderID, - toolContentID); - authForm.setSessionMapID(map.getSessionID()); + SessionMap map = createSessionMap(notebook, mode, contentFolderID, toolContentID); + authoringForm.setSessionMapID(map.getSessionID()); // add the sessionMap to HTTPSession. request.getSession().setAttribute(map.getSessionID(), map); request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + request.setAttribute("authoringForm", authoringForm); - return mapping.findForward("success"); + return "pages/authoring/authoring"; } @RequestMapping("/updateContent") - public String updateContent(AuthoringForm authForm, HttpServletRequest request) { + public String updateContent(@ModelAttribute("authoringForm") AuthoringForm authoringForm, HttpServletRequest request) { // TODO need error checking. // get authForm and session map. - SessionMap map = getSessionMap(request, authForm); + SessionMap map = getSessionMap(request, authoringForm); // get notebook content. - Notebook notebook = notebookService.getNotebookByContentId((Long) map.get(AuthoringController.KEY_TOOL_CONTENT_ID)); + Notebook notebook = notebookService + .getNotebookByContentId((Long) map.get(AuthoringController.KEY_TOOL_CONTENT_ID)); // update notebook content using form inputs - updateNotebook(notebook, authForm); + updateNotebook(notebook, authoringForm); notebookService.releaseConditionsFromCache(notebook); Set conditions = notebook.getConditions(); if (conditions == null) { - conditions = new TreeSet(new TextSearchConditionComparator()); + conditions = new TreeSet<>(new TextSearchConditionComparator()); } SortedSet conditionSet = (SortedSet) map .get(NotebookConstants.ATTR_CONDITION_SET); @@ -185,11 +174,12 @@ request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); // add the sessionMapID to form - authForm.setSessionMapID(map.getSessionID()); + authoringForm.setSessionMapID(map.getSessionID()); request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + request.setAttribute("authoringForm", authoringForm); - return mapping.findForward("success"); + return "pages/authoring/authoring"; } /* ========== Private Methods ********** */ @@ -234,14 +224,14 @@ private SessionMap createSessionMap(Notebook notebook, ToolAccessMode mode, String contentFolderID, Long toolContentID) { - SessionMap map = new SessionMap(); + SessionMap map = new SessionMap<>(); map.put(AuthoringController.KEY_MODE, mode); map.put(AuthoringController.KEY_CONTENT_FOLDER_ID, contentFolderID); map.put(AuthoringController.KEY_TOOL_CONTENT_ID, toolContentID); map.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, new ArrayList()); - SortedSet set = new TreeSet(new TextSearchConditionComparator()); + SortedSet set = new TreeSet<>(new TextSearchConditionComparator()); if (notebook.getConditions() != null) { set.addAll(notebook.getConditions()); Fisheye: Tag b55462c1bed962dba08744bf8ceac6594c3462f2 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java (.../AuthoringNotebookConditionController.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java (.../AuthoringNotebookConditionController.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -29,24 +29,14 @@ import javax.servlet.ServletException; 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.apache.struts.action.Action; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; import org.lamsfoundation.lams.tool.notebook.model.NotebookCondition; import org.lamsfoundation.lams.tool.notebook.service.INotebookService; -import org.lamsfoundation.lams.tool.notebook.service.NotebookServiceProxy; import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; import org.lamsfoundation.lams.tool.notebook.util.NotebookException; -import org.lamsfoundation.lams.tool.notebook.web.forms.AuthoringForm; import org.lamsfoundation.lams.tool.notebook.web.forms.NotebookConditionForm; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; @@ -55,6 +45,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; /** @@ -66,25 +57,25 @@ * */ @Controller -@RequestMapping("/authoring") -public class AuthoringNotebookConditionController{ - - @Autowired - @Qualifier("notebookService") +@RequestMapping("/authoringCondition") +public class AuthoringNotebookConditionController { + + @Autowired + @Qualifier("notebookService") private INotebookService notebookService; - - @Autowired - @Qualifier("notebookMessageService") - private MessageService messageService; + @Autowired + @Qualifier("notebookMessageService") + private MessageService messageService; + /** * Display empty page for new taskList item. * * @param notebookConditionForm * @param request * @return */ - @RequestMapping("newConditionInit") + @RequestMapping("newConditionInit") private String newConditionInit(NotebookConditionForm notebookConditionForm, HttpServletRequest request) { String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); notebookConditionForm.setSessionMapID(sessionMapID); @@ -100,7 +91,7 @@ * @param response * @return */ - @RequestMapping("/editCondition") + @RequestMapping("/editCondition") private String editCondition(NotebookConditionForm notebookConditionForm, HttpServletRequest request) { String sessionMapID = notebookConditionForm.getSessionMapID(); @@ -110,7 +101,7 @@ NotebookCondition condition = null; if (orderId != -1) { SortedSet conditionSet = getNotebookConditionSet(sessionMap); - List conditionList = new ArrayList(conditionSet); + List conditionList = new ArrayList<>(conditionSet); condition = conditionList.get(orderId); if (condition != null) { populateConditionToForm(orderId, condition, notebookConditionForm, request); @@ -133,8 +124,9 @@ * @throws ServletException */ @RequestMapping("/saveOrUpdateCondition") - private String saveOrUpdateCondition(NotebookConditionForm notebookConditionForm, Errors errors, HttpServletRequest request, - HttpServletResponse response) { + private String saveOrUpdateCondition( + @ModelAttribute("notebookConditionForm") NotebookConditionForm notebookConditionForm, Errors errors, + HttpServletRequest request) { validateNotebookCondition(notebookConditionForm, errors, request); @@ -153,6 +145,7 @@ } // set session map ID so that itemlist.jsp can get sessionMAP request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, notebookConditionForm.getSessionMapID()); + request.setAttribute("notebookConditionForm", notebookConditionForm); // return null to close this window return "pages/authoring/conditionList"; } @@ -177,7 +170,7 @@ int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); if (orderId != -1) { SortedSet conditionSet = getNotebookConditionSet(sessionMap); - List conditionList = new ArrayList(conditionSet); + List conditionList = new ArrayList<>(conditionSet); NotebookCondition condition = conditionList.remove(orderId); for (NotebookCondition otherCondition : conditionSet) { if (otherCondition.getOrderId() > orderId) { @@ -222,7 +215,7 @@ private String downCondition(HttpServletRequest request) { return switchItem(request, false); } - + @RequestMapping("/switchItem") private String switchItem(HttpServletRequest request, boolean up) { // get back sessionMAP @@ -232,7 +225,7 @@ int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); if (orderId != -1) { SortedSet conditionSet = getNotebookConditionSet(sessionMap); - List conditionList = new ArrayList(conditionSet); + List conditionList = new ArrayList<>(conditionSet); // get current and the target item, and switch their sequnece NotebookCondition condition = conditionList.get(orderId); NotebookCondition repCondition; @@ -268,7 +261,7 @@ SortedSet set = (SortedSet) sessionMap .get(NotebookConstants.ATTR_CONDITION_SET); if (set == null) { - set = new TreeSet(new TextSearchConditionComparator()); + set = new TreeSet<>(new TextSearchConditionComparator()); sessionMap.put(NotebookConstants.ATTR_CONDITION_SET, set); } return set; @@ -349,7 +342,7 @@ condition.setOrderId(maxSeq); conditionSet.add(condition); } else { // edit - List conditionList = new ArrayList(conditionSet); + List conditionList = new ArrayList<>(conditionSet); condition = conditionList.get(orderId - 1); form.extractCondition(condition); } @@ -361,7 +354,8 @@ * @param notebookConditionForm * @return */ - private void validateNotebookCondition(NotebookConditionForm notebookConditionForm, Errors errors, HttpServletRequest request) { + private void validateNotebookCondition(NotebookConditionForm notebookConditionForm, Errors errors, + HttpServletRequest request) { String formConditionName = notebookConditionForm.getDisplayName(); if (StringUtils.isBlank(formConditionName)) { Fisheye: Tag b55462c1bed962dba08744bf8ceac6594c3462f2 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java (.../LearningController.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java (.../LearningController.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -21,7 +21,6 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.notebook.web.controller; import java.io.IOException; @@ -33,9 +32,6 @@ import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; @@ -78,9 +74,8 @@ private INotebookService notebookService; @RequestMapping("unspecified") - public String unspecified(LearningForm learningForm, HttpServletRequest request) throws Exception { + public String unspecified(LearningForm messageForm, HttpServletRequest request) throws Exception { - // 'toolSessionID' and 'mode' paramters are expected to be present. // TODO need to catch exceptions and handle errors. ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, @@ -103,20 +98,19 @@ // check defineLater if (notebook.isDefineLater()) { - return "pages/learning/notebook"; + return "pages/learning/defineLater"; } // set mode, toolSessionID and NotebookDTO request.setAttribute("mode", mode.toString()); - learningForm.setToolSessionID(toolSessionID); + messageForm.setToolSessionID(toolSessionID); NotebookDTO notebookDTO = new NotebookDTO(); notebookDTO.title = notebook.getTitle(); notebookDTO.instructions = notebook.getInstructions(); notebookDTO.allowRichEditor = notebook.isAllowRichEditor(); notebookDTO.lockOnFinish = notebook.isLockOnFinished(); notebookDTO.forceResponse = notebook.isForceResponse(); - request.setAttribute("notebookDTO", notebookDTO); @@ -143,7 +137,7 @@ nbEntry = notebookService.getEntry(notebookUser.getEntryUID()); } if (nbEntry != null) { - learningForm.setEntryText(nbEntry.getEntry()); + messageForm.setEntryText(nbEntry.getEntry()); } // set readOnly flag. @@ -178,7 +172,7 @@ } } - return ""; //mapping.findForward("notebook"); + return "pages/learning/notebook"; } private NotebookUser getCurrentUser(Long toolSessionId) { @@ -196,23 +190,22 @@ return notebookUser; } - public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + @RequestMapping("/finishActivity") + public String finishActivity(LearningForm messageForm, HttpServletRequest request, HttpServletResponse response) { Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID"); - LearningForm learningForm = (LearningForm) form; NotebookUser notebookUser = getCurrentUser(toolSessionID); // learningForm.getContentEditable() will be null if the deadline has passed - if (learningForm.getContentEditable() != null && learningForm.getContentEditable()) { + if (messageForm.getContentEditable() != null && messageForm.getContentEditable()) { // TODO fix idType to use real value not 999 if (notebookUser.getEntryUID() == null) { notebookUser.setEntryUID(notebookService.createNotebookEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, NotebookConstants.TOOL_SIGNATURE, - notebookUser.getUserId().intValue(), learningForm.getEntryText())); + notebookUser.getUserId().intValue(), messageForm.getEntryText())); } else { // update existing entry. - notebookService.updateEntry(notebookUser.getEntryUID(), learningForm.getEntryText()); + notebookService.updateEntry(notebookUser.getEntryUID(), messageForm.getEntryText()); } notebookUser.setFinishedActivity(true); Fisheye: Tag b55462c1bed962dba08744bf8ceac6594c3462f2 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringController.java (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -0,0 +1,281 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.notebook.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.struts.action.ActionForward; +import org.lamsfoundation.lams.tool.notebook.dto.NotebookSessionsDTO; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; +import org.lamsfoundation.lams.tool.notebook.service.INotebookService; +import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +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 String noEntryText = null; // access via getNoEntryText() + + @Autowired + @Qualifier("notebookService") + private INotebookService notebookService; + + @Autowired + @Qualifier("notebookMessageService") + private MessageService messageService; + + @RequestMapping("/") + public String unspecified(HttpServletRequest request) { + + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + request.setAttribute("contentFolderID", contentFolderID); + + Notebook notebook = notebookService.getNotebookByContentId(toolContentID); + if (notebook == null) { + // TODO error page. + } + + boolean isGroupedActivity = notebookService.isGroupedActivity(toolContentID); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + NotebookSessionsDTO notebookDTO = new NotebookSessionsDTO(notebook); + Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); + notebookDTO.setCurrentTab(currentTab != null ? currentTab : 1); + + request.setAttribute("notebookDTO", notebookDTO); + + Date submissionDeadline = notebook.getSubmissionDeadline(); + if (submissionDeadline != null) { + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline); + request.setAttribute(NotebookConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); + request.setAttribute(NotebookConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, + DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale())); + } + + return "pages/monitoring/monitoring"; + } + + @RequestMapping("/getUsers") + public ActionForward getUsers(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long toolSessionId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + + boolean hasSearch = WebUtil.readBooleanParam(request, "_search", false); + String searchString = hasSearch ? request.getParameter(NotebookConstants.PARAM_NAME) : null; + int page = WebUtil.readIntParam(request, "page"); + int size = WebUtil.readIntParam(request, "rows"); + int sorting = NotebookConstants.SORT_BY_NO; + String sidx = request.getParameter("sidx"); + String sord = request.getParameter("sord"); + if (sidx != null) { + if (sidx.equals(NotebookConstants.PARAM_NAME)) { + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_USERNAME_ASC + : NotebookConstants.SORT_BY_USERNAME_DESC; + } else if (sidx.equals(NotebookConstants.PARAM_MODIFIED_DATE)) { + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_DATE_ASC + : NotebookConstants.SORT_BY_DATE_DESC; + } else if (sidx.equals(NotebookConstants.PARAM_COMMENT_SORT)) { + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_COMMENT_ASC + : NotebookConstants.SORT_BY_COMMENT_DESC; + } + } + + ObjectNode responsedata = JsonNodeFactory.instance.objectNode(); + int totalRows = notebookService.getCountUsersBySession(toolSessionId, searchString); + responsedata.put("total_rows", totalRows); + responsedata.put("page", page); + responsedata.put("total", Math.ceil((float) totalRows / size)); + + ArrayNode rows = JsonNodeFactory.instance.arrayNode(); + // our code expects the first page to be 0 but jqgrid uses 1 for the first page. + List users = notebookService.getUsersForTablesorter(toolSessionId, page > 0 ? page - 1 : 0, size, + sorting, searchString); + + String noEntry = getNoEntryText(); + + int id = 1; + for (Object[] userAndReflection : users) { + + ObjectNode responseRow = JsonNodeFactory.instance.objectNode(); + + NotebookUser user = (NotebookUser) userAndReflection[0]; + responseRow.put("id", id++); + responseRow.put(NotebookConstants.PARAM_USER_UID, user.getUid()); + responseRow.put(NotebookConstants.PARAM_NAME, + HtmlUtils.htmlEscape(user.getLastName() + " " + user.getFirstName())); + if (userAndReflection.length > 1 && userAndReflection[1] != null) { + responseRow.put(NotebookConstants.PARAM_ENTRY, HtmlUtils.htmlEscape((String) userAndReflection[1])); + } + if (user.getTeachersComment() != null && user.getTeachersComment().length() > 0) { + responseRow.put(NotebookConstants.PARAM_COMMENT, HtmlUtils.htmlEscape(user.getTeachersComment())); + } + + if (userAndReflection.length > 2 && userAndReflection[2] != null) { + Date modifiedDate = (Date) userAndReflection[2]; + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE, + DateUtil.convertToStringForJSON(modifiedDate, request.getLocale())); + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE_TIMEAGO, + DateUtil.convertToStringForTimeagoJSON(modifiedDate)); + } else { + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE, noEntry); + } + + responseRow.put(NotebookConstants.ATTR_USER_ID, user.getUserId()); + if (userAndReflection.length > 3 && userAndReflection[3] != null) { + responseRow.put(NotebookConstants.ATTR_PORTRAIT_ID, (String) userAndReflection[3]); + } + rows.add(responseRow); + } + responsedata.set("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(responsedata.toString()); + return null; + + } + + /** + * Updates a user's mark or feedback for an entire lesson + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws Exception + */ + + @RequestMapping("/saveTeacherComment") + public String saveTeacherComment(HttpServletRequest request) throws Exception { + + String teachersComment = WebUtil.readStrParam(request, "value", true); + Long userUid = WebUtil.readLongParam(request, NotebookConstants.PARAM_USER_UID); + boolean isNotifyLearner = WebUtil.readBooleanParam(request, "isNotifyLearner"); + NotebookUser user = notebookService.getUserByUID(userUid); + + //check user had available notebook entry and teachersComment is not blank + if ((user.getEntryUID() == null) && StringUtils.isNotBlank(teachersComment)) { + return null; + } + + user.setTeachersComment(teachersComment); + notebookService.saveOrUpdateNotebookUser(user); + + if (isNotifyLearner) { + notebookService.notifyUser(user.getUserId().intValue(), teachersComment); + } + + return null; + } + + /** + * Set Submission Deadline + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + */ + + @RequestMapping("/setSubmissionDeadline") + public String setSubmissionDeadline(HttpServletRequest request, HttpServletResponse response) throws IOException { + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + + Notebook notebook = notebookService.getNotebookByContentId(contentID); + + Long dateParameter = WebUtil.readLongParam(request, NotebookConstants.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()); + } + notebook.setSubmissionDeadline(tzSubmissionDeadline); + notebookService.saveOrUpdateNotebook(notebook); + response.setContentType("text/plain;charset=utf-8"); + response.getWriter().print(formattedDate); + return null; + } + + /** Get the statistics for monitoring */ + + @RequestMapping("/getStatistics") + public String getStatistics(HttpServletRequest request) { + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + + boolean isGroupedActivity = notebookService.isGroupedActivity(contentID); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + request.setAttribute("statisticList", notebookService.getStatisticsBySession(contentID)); + + return "pages/monitoring/statisticpart"; + } + + /** + * set up notebookService + */ + + private String getNoEntryText() { + if (noEntryText == null) { + noEntryText = messageService.getMessage("label.no.entry"); + } + return noEntryText; + } + +} Fisheye: Tag b55462c1bed962dba08744bf8ceac6594c3462f2 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerController.java (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -0,0 +1,95 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.notebook.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +import org.lamsfoundation.lams.tool.notebook.service.INotebookService; +import org.lamsfoundation.lams.tool.notebook.web.forms.NotebookPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author + * @version + * + * + * + * + * + */ +@Controller +@RequestMapping("/pedagogicalPlanner") +public class PedagogicalPlannerController { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerController.class); + + @Autowired + @Qualifier("notebookService") + private INotebookService notebookService; + + @RequestMapping("/") + protected String unspecified(NotebookPedagogicalPlannerForm pedagogicalPlannerForm, HttpServletRequest request) { +// if (notebookService == null) { +// notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); +// } + return initPedagogicalPlannerForm(pedagogicalPlannerForm, request); + } + + @RequestMapping("/initPedagogicalPlannerForm") + public String initPedagogicalPlannerForm(NotebookPedagogicalPlannerForm pedagogicalPlannerForm, + HttpServletRequest request) { + NotebookPedagogicalPlannerForm plannerForm = pedagogicalPlannerForm; + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Notebook notebook = notebookService.getNotebookByContentId(toolContentID); + plannerForm.fillForm(notebook); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return "pages/authoring/pedagogicalPlannerForm"; + } + + @RequestMapping("/saveOrUpdatePedagogicalPlannerForm") + public String saveOrUpdatePedagogicalPlannerForm(NotebookPedagogicalPlannerForm pedagogicalPlannerForm, + Errors errors, HttpServletRequest request) throws IOException { + pedagogicalPlannerForm.validate(); + if (!errors.hasErrors()) { + String instructions = pedagogicalPlannerForm.getInstructions(); + Long toolContentID = pedagogicalPlannerForm.getToolContentID(); + Notebook notebook = notebookService.getNotebookByContentId(toolContentID); + notebook.setInstructions(instructions); + notebookService.saveOrUpdateNotebook(notebook); + } + return "pages/authoring/pedagogicalPlannerForm"; + } + +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -21,23 +21,14 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.notebook.web.forms; -import javax.servlet.http.HttpServletRequest; - -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; import org.lamsfoundation.lams.web.util.SessionMap; /** * */ -public class AuthoringForm extends ActionForm { +public class AuthoringForm { private static final long serialVersionUID = 3950453134542135495L; @@ -48,7 +39,7 @@ String instructions; boolean lockOnFinished; - + boolean forceResponse; boolean allowRichEditor; @@ -61,23 +52,20 @@ SessionMap sessionMap; - - public String getSessionMapID() { return sessionMapID; } public void setSessionMapID(String sessionMapID) { this.sessionMapID = sessionMapID; } - public boolean isForceResponse() { - return forceResponse; + return forceResponse; } public void setForceResponse(boolean forceResponse) { - this.forceResponse = forceResponse; + this.forceResponse = forceResponse; } public String getCurrentTab() { Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java (.../LearningForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java (.../LearningForm.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -21,19 +21,15 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.notebook.web.forms; -import org.apache.struts.action.ActionForm; - /** * * @author Anthony Sukkar * * */ -public class LearningForm{ +public class LearningForm { private static final long serialVersionUID = -4728946254882237144L; Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/MonitoringForm.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -21,16 +21,12 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.notebook.web.forms; -import org.apache.struts.action.ActionForm; - /** * */ -public class MonitoringForm{ +public class MonitoringForm { private static final long serialVersionUID = 9096908688391850595L; Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/NotebookPedagogicalPlannerForm.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/NotebookPedagogicalPlannerForm.java (.../NotebookPedagogicalPlannerForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/NotebookPedagogicalPlannerForm.java (.../NotebookPedagogicalPlannerForm.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -20,16 +20,15 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.notebook.web.forms; import org.lamsfoundation.lams.tool.notebook.model.Notebook; -import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivitySpringForm; /** * */ -public class NotebookPedagogicalPlannerForm extends PedagogicalPlannerSpringForm { +public class NotebookPedagogicalPlannerForm extends PedagogicalPlannerActivitySpringForm { String instructions; String contentFolderID; Index: lams_tool_notebook/web/WEB-INF/spring-servlet.xml =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/web/WEB-INF/spring-servlet.xml (.../spring-servlet.xml) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/web/WEB-INF/spring-servlet.xml (.../spring-servlet.xml) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -8,7 +8,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> - + Index: lams_tool_notebook/web/WEB-INF/tags/TextSearch.tag =================================================================== diff -u -re64f3e306f3139c78e8917240c33ea232e75e848 -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision e64f3e306f3139c78e8917240c33ea232e75e848) +++ lams_tool_notebook/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -32,8 +32,8 @@ <%@ 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="http://www.springframework.org/tags/form" prefix="form" %> <%-- Required attributes --%> <%@ attribute name="sessionMapID" required="true" rtexprvalue="true" %> @@ -88,39 +88,39 @@
- +

- +
- +
- +
- +
Index: lams_tool_notebook/web/pages/authoring/addCondition.jsp =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -9,16 +9,19 @@
- - <%@ include file="/common/messages.jsp"%> + <%-- For some reason Spring MVC consumes this first form and only renders the second one. + If this redundant form is removed, the other one would be consumed, so this one needs to stay --%> + + + <%@ include file="/common/messages.jsp"%>
-
Index: lams_tool_notebook/web/pages/authoring/authoring.jsp =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -8,7 +8,7 @@ - + Index: lams_tool_notebook/web/pages/authoring/conditions.jsp =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_notebook/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_notebook/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -13,26 +13,26 @@ } function editCondition(orderId,sessionMapID){ - var url = "" + var url = "" + orderId + "&sessionMapID=" + sessionMapID; showConditionMessage(url); } function deleteCondition(orderId, sessionMapID){ - $("#conditionsArea").load("",{ + $("#conditionsArea").load("",{ 'orderId' : orderId, 'sessionMapID' : sessionMapID }); } function upCondition(orderId,sessionMapID){ - $("#conditionsArea").load("",{ + $("#conditionsArea").load("",{ 'orderId' : orderId, 'sessionMapID' : sessionMapID }); } function downCondition(orderId,sessionMapID){ - $("#conditionsArea").load("",{ + $("#conditionsArea").load("",{ 'orderId' : orderId, 'sessionMapID' : sessionMapID }); @@ -54,7 +54,7 @@
-  
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java =================================================================== diff -u -r749b841adf6115016059d15ddfa58aee5b11e26d -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java (.../AuthoringConditionController.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java (.../AuthoringConditionController.java) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -52,7 +52,9 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; /** * Auxiliary action in author mode. It contains operations with SurveyCondition. The rest of operations are located in @@ -172,8 +174,8 @@ * @param response * @return */ - @RequestMapping("/removeCondition") - public String removeCondition(ActionForm surveyConditionForm, HttpServletRequest request) { + @RequestMapping(value="/removeCondition", method = RequestMethod.POST) + public String removeCondition(@ModelAttribute("surveyConditionForm")ActionForm surveyConditionForm, HttpServletRequest request) { // get back sessionMAP String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID); @@ -197,6 +199,7 @@ } request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID); + request.setAttribute("surveyConditionForm", surveyConditionForm); return "pages/authoring/conditionList"; } Index: lams_tool_survey/web/pages/authoring/addCondition.jsp =================================================================== diff -u -rbd320e8b9a1e0e966b4a9f1ca718f06c593c34d9 -rb55462c1bed962dba08744bf8ceac6594c3462f2 --- lams_tool_survey/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision bd320e8b9a1e0e966b4a9f1ca718f06c593c34d9) +++ lams_tool_survey/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision b55462c1bed962dba08744bf8ceac6594c3462f2) @@ -9,7 +9,10 @@
- + <%-- For some reason Spring MVC consumes this first form and only renders the second one. + If this redundant form is removed, the other one would be consumed, so this one needs to stay --%> + + <%@ include file="/common/messages.jsp"%>