Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/AuthoringNotebookConditionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/LearningAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 749b841adf6115016059d15ddfa58aee5b11e26d refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/PedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringAction.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringAction.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringAction.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,270 @@ +/**************************************************************** + * 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.util.ArrayList; +import java.util.Date; +import java.util.List; +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.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; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +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.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; + +/** + * @author + * @version + * + * + * + * + */ +public class AuthoringAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(AuthoringAction.class); + + public INotebookService notebookService; + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + private static final String KEY_MODE = "mode"; + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + * toolContentID will be passed in. This will be used to retrieve content for this tool. + * + */ + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // Extract toolContentID from parameters. + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + + // set up notebookService + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + + // retrieving Notebook with given toolContentID + Notebook notebook = notebookService.getNotebookByContentId(toolContentID); + if (notebook == null) { + notebook = notebookService.copyDefaultContent(toolContentID); + notebook.setCreateDate(new Date()); + notebookService.saveOrUpdateNotebook(notebook); + // TODO NOTE: this causes DB orphans when LD not saved. + } + + if (mode.isTeacher()) { + // Set the defineLater flag so that learners cannot use content while we are editing. This flag is released + // when updateContent is called. + notebook.setDefineLater(true); + notebookService.saveOrUpdateNotebook(notebook); + + //audit log the teacher has started editing activity in monitor + notebookService.auditLogStartEditingActivityInMonitor(toolContentID); + } + + // Set up the authForm. + AuthoringForm authForm = (AuthoringForm) form; + updateAuthForm(authForm, notebook); + + // Set up sessionMap + SessionMap map = createSessionMap(notebook, mode, contentFolderID, + toolContentID); + authForm.setSessionMapID(map.getSessionID()); + + // add the sessionMap to HTTPSession. + request.getSession().setAttribute(map.getSessionID(), map); + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + // TODO need error checking. + + // get authForm and session map. + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + // get notebook content. + Notebook notebook = notebookService.getNotebookByContentId((Long) map.get(AuthoringAction.KEY_TOOL_CONTENT_ID)); + + // update notebook content using form inputs + updateNotebook(notebook, authForm); + + notebookService.releaseConditionsFromCache(notebook); + + Set conditions = notebook.getConditions(); + if (conditions == null) { + conditions = new TreeSet(new TextSearchConditionComparator()); + } + SortedSet conditionSet = (SortedSet) map + .get(NotebookConstants.ATTR_CONDITION_SET); + conditions.addAll(conditionSet); + + List deletedConditionList = (List) map + .get(NotebookConstants.ATTR_DELETED_CONDITION_LIST); + if (deletedConditionList != null) { + for (NotebookCondition condition : deletedConditionList) { + // remove from db, leave in repository + conditions.remove(condition); + notebookService.deleteCondition(condition); + } + } + + // set conditions in case it didn't exist + notebook.setConditions(conditionSet); + + // set the update date + notebook.setUpdateDate(new Date()); + + // releasing defineLater flag so that learner can start using the tool. + notebook.setDefineLater(false); + + notebookService.saveOrUpdateNotebook(notebook); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // add the sessionMapID to form + authForm.setSessionMapID(map.getSessionID()); + + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + /* ========== Private Methods ********** */ + + /** + * Updates Notebook content using AuthoringForm inputs. + * + * @param authForm + * @param mode + * @return + */ + private void updateNotebook(Notebook notebook, AuthoringForm authForm) { + notebook.setTitle(authForm.getTitle()); + notebook.setInstructions(authForm.getInstructions()); + notebook.setForceResponse(authForm.isForceResponse()); + notebook.setLockOnFinished(authForm.isLockOnFinished()); + notebook.setAllowRichEditor(authForm.isAllowRichEditor()); + } + + /** + * Updates AuthoringForm using Notebook content. + * + * @param notebook + * @param authForm + * @return + */ + private void updateAuthForm(AuthoringForm authForm, Notebook notebook) { + authForm.setTitle(notebook.getTitle()); + authForm.setInstructions(notebook.getInstructions()); + authForm.setLockOnFinished(notebook.isLockOnFinished()); + authForm.setForceResponse(notebook.isForceResponse()); + authForm.setAllowRichEditor(notebook.isAllowRichEditor()); + + } + + /** + * Updates SessionMap using Notebook content. + * + * @param notebook + * @param mode + */ + private SessionMap createSessionMap(Notebook notebook, ToolAccessMode mode, String contentFolderID, + Long toolContentID) { + + SessionMap map = new SessionMap(); + + map.put(AuthoringAction.KEY_MODE, mode); + map.put(AuthoringAction.KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(AuthoringAction.KEY_TOOL_CONTENT_ID, toolContentID); + map.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, new ArrayList()); + + SortedSet set = new TreeSet(new TextSearchConditionComparator()); + + if (notebook.getConditions() != null) { + set.addAll(notebook.getConditions()); + } + map.put(NotebookConstants.ATTR_CONDITION_SET, set); + return map; + } + + /** + * Retrieve the SessionMap from the HttpSession. + * + * @param request + * @param authForm + * @return + */ + private SessionMap getSessionMap(HttpServletRequest request, AuthoringForm authForm) { + return (SessionMap) request.getSession().getAttribute(authForm.getSessionMapID()); + } + + /** + * Lists deleted Notebook conditions, which could be persisted or non-persisted items. + * + * @param request + * @return + */ + private List getDeletedNotebookConditionList(SessionMap sessionMap) { + List list = (List) sessionMap.get(NotebookConstants.ATTR_DELETED_CONDITION_LIST); + if (list == null) { + list = new ArrayList(); + sessionMap.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, list); + } + return list; + + } +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringController.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,279 @@ +/**************************************************************** + * 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.util.ArrayList; +import java.util.Date; +import java.util.List; +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.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; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +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.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.RequestMapping; +import org.springframework.web.context.WebApplicationContext; + +/** + * @author + * @version + * + * + * + * + */ +@Controller +@RequestMapping("/authoring") +public class AuthoringController{ //extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(AuthoringController.class); + + @Autowired + @Qualifier("notebookService") + private INotebookService notebookService; + + @Autowired + private WebApplicationContext applicationContext; + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + private static final String KEY_MODE = "mode"; + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + * toolContentID will be passed in. This will be used to retrieve content for this tool. + * + */ +// @RequestMapping("/") + protected String unspecified(AuthoringForm authForm, HttpServletRequest request) { + + // Extract toolContentID from parameters. + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + + // 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) { + notebook = notebookService.copyDefaultContent(toolContentID); + notebook.setCreateDate(new Date()); + notebookService.saveOrUpdateNotebook(notebook); + // TODO NOTE: this causes DB orphans when LD not saved. + } + + if (mode.isTeacher()) { + // Set the defineLater flag so that learners cannot use content while we are editing. This flag is released + // when updateContent is called. + 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); + + // Set up sessionMap + SessionMap map = createSessionMap(notebook, mode, contentFolderID, + toolContentID); + authForm.setSessionMapID(map.getSessionID()); + + // add the sessionMap to HTTPSession. + request.getSession().setAttribute(map.getSessionID(), map); + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + @RequestMapping("/updateContent") + public String updateContent(AuthoringForm authForm, HttpServletRequest request) { + // TODO need error checking. + + // get authForm and session map. + SessionMap map = getSessionMap(request, authForm); + + // get notebook content. + Notebook notebook = notebookService.getNotebookByContentId((Long) map.get(AuthoringController.KEY_TOOL_CONTENT_ID)); + + // update notebook content using form inputs + updateNotebook(notebook, authForm); + + notebookService.releaseConditionsFromCache(notebook); + + Set conditions = notebook.getConditions(); + if (conditions == null) { + conditions = new TreeSet(new TextSearchConditionComparator()); + } + SortedSet conditionSet = (SortedSet) map + .get(NotebookConstants.ATTR_CONDITION_SET); + conditions.addAll(conditionSet); + + List deletedConditionList = (List) map + .get(NotebookConstants.ATTR_DELETED_CONDITION_LIST); + if (deletedConditionList != null) { + for (NotebookCondition condition : deletedConditionList) { + // remove from db, leave in repository + conditions.remove(condition); + notebookService.deleteCondition(condition); + } + } + + // set conditions in case it didn't exist + notebook.setConditions(conditionSet); + + // set the update date + notebook.setUpdateDate(new Date()); + + // releasing defineLater flag so that learner can start using the tool. + notebook.setDefineLater(false); + + notebookService.saveOrUpdateNotebook(notebook); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // add the sessionMapID to form + authForm.setSessionMapID(map.getSessionID()); + + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + /* ========== Private Methods ********** */ + + /** + * Updates Notebook content using AuthoringForm inputs. + * + * @param authForm + * @param mode + * @return + */ + private void updateNotebook(Notebook notebook, AuthoringForm authForm) { + notebook.setTitle(authForm.getTitle()); + notebook.setInstructions(authForm.getInstructions()); + notebook.setForceResponse(authForm.isForceResponse()); + notebook.setLockOnFinished(authForm.isLockOnFinished()); + notebook.setAllowRichEditor(authForm.isAllowRichEditor()); + } + + /** + * Updates AuthoringForm using Notebook content. + * + * @param notebook + * @param authForm + * @return + */ + private void updateAuthForm(AuthoringForm authForm, Notebook notebook) { + authForm.setTitle(notebook.getTitle()); + authForm.setInstructions(notebook.getInstructions()); + authForm.setLockOnFinished(notebook.isLockOnFinished()); + authForm.setForceResponse(notebook.isForceResponse()); + authForm.setAllowRichEditor(notebook.isAllowRichEditor()); + + } + + /** + * Updates SessionMap using Notebook content. + * + * @param notebook + * @param mode + */ + private SessionMap createSessionMap(Notebook notebook, ToolAccessMode mode, String contentFolderID, + Long toolContentID) { + + SessionMap map = new SessionMap(); + + map.put(AuthoringController.KEY_MODE, mode); + map.put(AuthoringController.KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(AuthoringController.KEY_TOOL_CONTENT_ID, toolContentID); + map.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, new ArrayList()); + + SortedSet set = new TreeSet(new TextSearchConditionComparator()); + + if (notebook.getConditions() != null) { + set.addAll(notebook.getConditions()); + } + map.put(NotebookConstants.ATTR_CONDITION_SET, set); + return map; + } + + /** + * Retrieve the SessionMap from the HttpSession. + * + * @param request + * @param authForm + * @return + */ + private SessionMap getSessionMap(HttpServletRequest request, AuthoringForm authForm) { + return (SessionMap) request.getSession().getAttribute(authForm.getSessionMapID()); + } + + /** + * Lists deleted Notebook conditions, which could be persisted or non-persisted items. + * + * @param request + * @return + */ + private List getDeletedNotebookConditionList(SessionMap sessionMap) { + List list = (List) sessionMap.get(NotebookConstants.ATTR_DELETED_CONDITION_LIST); + if (list == null) { + list = new ArrayList(); + sessionMap.put(NotebookConstants.ATTR_DELETED_CONDITION_LIST, list); + } + return list; + + } +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionAction.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionAction.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionAction.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,418 @@ +/**************************************************************** + * 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.notebook.web.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +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.WebUtil; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * Auxiliary action in author mode. It contains operations with NotebookCondition. The rest of operations are located in + * AuthoringAction action. + * + * @author Marcin Cieslak + * @see org.lamsfoundation.lams.tool.notebook.web.action.AuthoringAction + * + */ +public class AuthoringNotebookConditionAction extends Action { + public INotebookService notebookService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + String param = mapping.getParameter(); + + if (param.equals("newConditionInit")) { + return newConditionInit(mapping, form, request, response); + } + if (param.equals("editCondition")) { + return editCondition(mapping, form, request, response); + } + if (param.equals("saveOrUpdateCondition")) { + return saveOrUpdateCondition(mapping, form, request, response); + } + if (param.equals("removeCondition")) { + return removeCondition(mapping, form, request, response); + } + if (param.equals("upCondition")) { + return upCondition(mapping, form, request, response); + } + if (param.equals("downCondition")) { + return downCondition(mapping, form, request, response); + } + + return null; + } + + /** + * Display empty page for new taskList item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward newConditionInit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + ((NotebookConditionForm) form).setSessionMapID(sessionMapID); + ((NotebookConditionForm) form).setOrderId(-1); + return mapping.findForward("addcondition"); + } + + /** + * Display edit page for existed taskList item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward editCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + NotebookConditionForm notebookConditionForm = (NotebookConditionForm) form; + String sessionMapID = notebookConditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + NotebookCondition condition = null; + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId); + if (condition != null) { + populateConditionToForm(orderId, condition, (NotebookConditionForm) form, request); + } + } + return condition == null ? null : mapping.findForward("addcondition"); + } + + /** + * This method will get necessary information from taskList item form and save or update into + * HttpSession NotebookItemList. 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. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws ServletException + */ + private ActionForward saveOrUpdateCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + NotebookConditionForm conditionForm = (NotebookConditionForm) form; + ActionErrors errors = validateNotebookCondition(conditionForm, request); + + if (!errors.isEmpty()) { + this.addErrors(request, errors); + return mapping.findForward("addcondition"); + } + + try { + extractFormToNotebookCondition(request, conditionForm); + } catch (Exception e) { + // any upload exception will display as normal error message rather then throw exception directly + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(NotebookConstants.ERROR_MSG_CONDITION, e.getMessage())); + if (!errors.isEmpty()) { + this.addErrors(request, errors); + return mapping.findForward("addcondition"); + } + } + // set session map ID so that itemlist.jsp can get sessionMAP + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, conditionForm.getSessionMapID()); + // return null to close this window + return mapping.findForward(NotebookConstants.SUCCESS); + } + + /** + * Remove taskList item 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. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward removeCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + NotebookCondition condition = conditionList.remove(orderId); + for (NotebookCondition otherCondition : conditionSet) { + if (otherCondition.getOrderId() > orderId) { + otherCondition.setOrderId(otherCondition.getOrderId() - 1); + } + } + conditionSet.clear(); + conditionSet.addAll(conditionList); + // add to delList + List delList = getDeletedNotebookConditionList(sessionMap); + delList.add(condition); + } + + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward(NotebookConstants.SUCCESS); + } + + /** + * Move up current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward upCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchItem(mapping, request, true); + } + + /** + * Move down current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward downCondition(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchItem(mapping, request, false); + } + + private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) { + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + // get current and the target item, and switch their sequnece + NotebookCondition condition = conditionList.get(orderId); + NotebookCondition 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(NotebookConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward(NotebookConstants.SUCCESS); + } + + // ************************************************************************************* + // Private methods for internal needs + // ************************************************************************************* + + /** + * List save current taskList items. + * + * @param request + * @return + */ + private SortedSet getNotebookConditionSet(SessionMap sessionMap) { + SortedSet set = (SortedSet) sessionMap + .get(NotebookConstants.ATTR_CONDITION_SET); + if (set == null) { + set = new TreeSet(new TextSearchConditionComparator()); + sessionMap.put(NotebookConstants.ATTR_CONDITION_SET, set); + } + return set; + } + + /** + * List save deleted taskList items, which could be persisted or non-persisted items. + * + * @param request + * @return + */ + private List getDeletedNotebookConditionList(SessionMap sessionMap) { + return getListFromSession(sessionMap, NotebookConstants.ATTR_DELETED_CONDITION_LIST); + } + + /** + * Get java.util.List from HttpSession by given name. + * + * @param request + * @param name + * @return + */ + 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 taskList item information to its form for edit use. + * + * @param orderId + * @param condition + * @param form + * @param request + */ + private void populateConditionToForm(int orderId, NotebookCondition condition, NotebookConditionForm form, + HttpServletRequest request) { + form.populateForm(condition); + if (orderId >= 0) { + form.setOrderId(orderId + 1); + } + } + + /** + * Extract form content to taskListContent. + * + * @param request + * @param form + * @throws NotebookException + */ + private void extractFormToNotebookCondition(HttpServletRequest request, NotebookConditionForm form) + throws Exception { + /* + * BE CAREFUL: This method will copy necessary info from request form to a old or new NotebookItem instance. It + * gets all info EXCEPT NotebookItem.createDate and NotebookItem.createBy, which need be set when persisting + * this taskList item. + */ + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); + // check whether it is "edit(old item)" or "add(new item)" + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + int orderId = form.getOrderId(); + NotebookCondition condition = null; + + if (orderId == -1) { // add + String properConditionName = getNotebookService().createConditionName(conditionSet); + condition = form.extractCondition(); + condition.setName(properConditionName); + int maxSeq = 1; + if (conditionSet != null && conditionSet.size() > 0) { + NotebookCondition last = conditionSet.last(); + maxSeq = last.getOrderId() + 1; + } + condition.setOrderId(maxSeq); + conditionSet.add(condition); + } else { // edit + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId - 1); + form.extractCondition(condition); + } + } + + /** + * Validate taskListCondition + * + * @param conditionForm + * @return + */ + private ActionErrors validateNotebookCondition(NotebookConditionForm conditionForm, HttpServletRequest request) { + ActionErrors errors = new ActionErrors(); + + String formConditionName = conditionForm.getDisplayName(); + if (StringUtils.isBlank(formConditionName)) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(NotebookConstants.ERROR_MSG_NAME_BLANK)); + } else { + + Integer formConditionSequenceId = conditionForm.getOrderId(); + + String sessionMapID = conditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SortedSet conditionList = getNotebookConditionSet(sessionMap); + for (NotebookCondition condition : conditionList) { + if (formConditionName.equals(condition.getName()) + && !formConditionSequenceId.equals(new Integer(condition.getOrderId() - 1).toString())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(NotebookConstants.ERROR_MSG_NAME_DUPLICATED)); + break; + } + } + } + return errors; + } + + private ActionMessages validate(AuthoringForm taskListForm, ActionMapping mapping, HttpServletRequest request) { + return new ActionMessages(); + } + + private INotebookService getNotebookService() { + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + return notebookService; + } +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/AuthoringNotebookConditionController.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,390 @@ +/**************************************************************** + * 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.notebook.web.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.SortedSet; +import java.util.TreeSet; + +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; +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.validation.Errors; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * Auxiliary action in author mode. It contains operations with NotebookCondition. The rest of operations are located in + * AuthoringAction action. + * + * @author Marcin Cieslak + * @see org.lamsfoundation.lams.tool.notebook.web.action.AuthoringAction + * + */ +@Controller +@RequestMapping("/authoring") +public class AuthoringNotebookConditionController{ + + @Autowired + @Qualifier("notebookService") + private INotebookService notebookService; + + @Autowired + @Qualifier("notebookMessageService") + private MessageService messageService; + + /** + * Display empty page for new taskList item. + * + * @param notebookConditionForm + * @param request + * @return + */ + @RequestMapping("newConditionInit") + private String newConditionInit(NotebookConditionForm notebookConditionForm, HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + notebookConditionForm.setSessionMapID(sessionMapID); + notebookConditionForm.setOrderId(-1); + return "pages/authoring/addCondition"; + } + + /** + * Display edit page for existed taskList item. + * + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/editCondition") + private String editCondition(NotebookConditionForm notebookConditionForm, HttpServletRequest request) { + + String sessionMapID = notebookConditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + NotebookCondition condition = null; + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId); + if (condition != null) { + populateConditionToForm(orderId, condition, notebookConditionForm, request); + } + } + return condition == null ? null : "pages/authoring/addCondition"; + } + + /** + * This method will get necessary information from taskList item form and save or update into + * HttpSession NotebookItemList. 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. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws ServletException + */ + @RequestMapping("/saveOrUpdateCondition") + private String saveOrUpdateCondition(NotebookConditionForm notebookConditionForm, Errors errors, HttpServletRequest request, + HttpServletResponse response) { + + validateNotebookCondition(notebookConditionForm, errors, request); + + if (errors.hasErrors()) { + return "pages/authoring/addCondition"; + } + + try { + extractFormToNotebookCondition(request, notebookConditionForm); + } catch (Exception e) { + // any upload exception will display as normal error message rather then throw exception directly + errors.reject(null, null, messageService.getMessage(NotebookConstants.ERROR_MSG_CONDITION, e.getMessage())); + if (errors.hasErrors()) { + return "pages/authoring/addCondition"; + } + } + // set session map ID so that itemlist.jsp can get sessionMAP + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, notebookConditionForm.getSessionMapID()); + // return null to close this window + return "pages/authoring/conditionList"; + } + + /** + * Remove taskList item 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. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/removeCondition") + private String removeCondition(HttpServletRequest request) { + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + NotebookCondition condition = conditionList.remove(orderId); + for (NotebookCondition otherCondition : conditionSet) { + if (otherCondition.getOrderId() > orderId) { + otherCondition.setOrderId(otherCondition.getOrderId() - 1); + } + } + conditionSet.clear(); + conditionSet.addAll(conditionList); + // add to delList + List delList = getDeletedNotebookConditionList(sessionMap); + delList.add(condition); + } + + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "pages/authoring/conditionList"; + } + + /** + * Move up current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/upCondition") + private String upCondition(HttpServletRequest request) { + return switchItem(request, true); + } + + /** + * Move down current item. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/downCondition") + private String downCondition(HttpServletRequest request) { + return switchItem(request, false); + } + + @RequestMapping("/switchItem") + private String switchItem(HttpServletRequest request, boolean up) { + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, NotebookConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + int orderId = NumberUtils.stringToInt(request.getParameter(NotebookConstants.PARAM_ORDER_ID), -1); + if (orderId != -1) { + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + List conditionList = new ArrayList(conditionSet); + // get current and the target item, and switch their sequnece + NotebookCondition condition = conditionList.get(orderId); + NotebookCondition 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(NotebookConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "pages/authoring/conditionList"; + } + + // ************************************************************************************* + // Private methods for internal needs + // ************************************************************************************* + + /** + * List save current taskList items. + * + * @param request + * @return + */ + private SortedSet getNotebookConditionSet(SessionMap sessionMap) { + SortedSet set = (SortedSet) sessionMap + .get(NotebookConstants.ATTR_CONDITION_SET); + if (set == null) { + set = new TreeSet(new TextSearchConditionComparator()); + sessionMap.put(NotebookConstants.ATTR_CONDITION_SET, set); + } + return set; + } + + /** + * List save deleted taskList items, which could be persisted or non-persisted items. + * + * @param request + * @return + */ + private List getDeletedNotebookConditionList(SessionMap sessionMap) { + return getListFromSession(sessionMap, NotebookConstants.ATTR_DELETED_CONDITION_LIST); + } + + /** + * Get java.util.List from HttpSession by given name. + * + * @param request + * @param name + * @return + */ + 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 taskList item information to its form for edit use. + * + * @param orderId + * @param condition + * @param form + * @param request + */ + private void populateConditionToForm(int orderId, NotebookCondition condition, NotebookConditionForm form, + HttpServletRequest request) { + form.populateForm(condition); + if (orderId >= 0) { + form.setOrderId(orderId + 1); + } + } + + /** + * Extract form content to taskListContent. + * + * @param request + * @param form + * @throws NotebookException + */ + private void extractFormToNotebookCondition(HttpServletRequest request, NotebookConditionForm form) + throws Exception { + /* + * BE CAREFUL: This method will copy necessary info from request form to a old or new NotebookItem instance. It + * gets all info EXCEPT NotebookItem.createDate and NotebookItem.createBy, which need be set when persisting + * this taskList item. + */ + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); + // check whether it is "edit(old item)" or "add(new item)" + SortedSet conditionSet = getNotebookConditionSet(sessionMap); + int orderId = form.getOrderId(); + NotebookCondition condition = null; + + if (orderId == -1) { // add + String properConditionName = notebookService.createConditionName(conditionSet); + condition = form.extractCondition(); + condition.setName(properConditionName); + int maxSeq = 1; + if (conditionSet != null && conditionSet.size() > 0) { + NotebookCondition last = conditionSet.last(); + maxSeq = last.getOrderId() + 1; + } + condition.setOrderId(maxSeq); + conditionSet.add(condition); + } else { // edit + List conditionList = new ArrayList(conditionSet); + condition = conditionList.get(orderId - 1); + form.extractCondition(condition); + } + } + + /** + * Validate taskListCondition + * + * @param notebookConditionForm + * @return + */ + private void validateNotebookCondition(NotebookConditionForm notebookConditionForm, Errors errors, HttpServletRequest request) { + + String formConditionName = notebookConditionForm.getDisplayName(); + if (StringUtils.isBlank(formConditionName)) { + errors.reject(null, null, messageService.getMessage(NotebookConstants.ERROR_MSG_NAME_BLANK)); + } else { + + Integer formConditionSequenceId = notebookConditionForm.getOrderId(); + + String sessionMapID = notebookConditionForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SortedSet conditionList = getNotebookConditionSet(sessionMap); + for (NotebookCondition condition : conditionList) { + if (formConditionName.equals(condition.getName()) + && !formConditionSequenceId.equals(new Integer(condition.getOrderId() - 1).toString())) { + errors.reject(null, null, messageService.getMessage(NotebookConstants.ERROR_MSG_NAME_DUPLICATED)); + break; + } + } + } + } + +// private ActionMessages validate(AuthoringForm taskListForm, ActionMapping mapping, HttpServletRequest request) { +// return new ActionMessages(); +// } + +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/ClearSessionController.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,64 @@ +/**************************************************************** + * 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.notebook.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +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 { + + @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) { + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } + } + +} Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningAction.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningAction.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningAction.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,239 @@ +///**************************************************************** +// * 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.TimeZone; +// +//import javax.servlet.http.HttpServletRequest; +//import javax.servlet.http.HttpServletResponse; +//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; +//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.notebook.dto.NotebookDTO; +//import org.lamsfoundation.lams.tool.notebook.model.Notebook; +//import org.lamsfoundation.lams.tool.notebook.model.NotebookSession; +//import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; +//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.LearningForm; +//import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +//import org.lamsfoundation.lams.util.DateUtil; +//import org.lamsfoundation.lams.util.WebUtil; +//import org.lamsfoundation.lams.web.action.LamsDispatchAction; +//import org.lamsfoundation.lams.web.session.SessionManager; +//import org.lamsfoundation.lams.web.util.AttributeNames; +// +///** +// * @author +// * @version +// * +// * +// * +// * +// * +// */ +//public class LearningAction extends LamsDispatchAction { +// +// private static Logger log = Logger.getLogger(LearningAction.class); +// +// private static final boolean MODE_OPTIONAL = false; +// +// private INotebookService notebookService; +// +// @Override +// public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, +// HttpServletResponse response) throws Exception { +// +// LearningForm learningForm = (LearningForm) form; +// +// // '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, +// LearningAction.MODE_OPTIONAL); +// +// Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); +// +// // set up notebookService +// if (notebookService == null) { +// notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); +// } +// +// // Retrieve the session and content. +// NotebookSession notebookSession = notebookService.getSessionBySessionId(toolSessionID); +// if (notebookSession == null) { +// throw new NotebookException("Cannot retrieve session with toolSessionID" + toolSessionID); +// } +// +// Notebook notebook = notebookSession.getNotebook(); +// +// // check defineLater +// if (notebook.isDefineLater()) { +// return mapping.findForward("defineLater"); +// } +// +// // set mode, toolSessionID and NotebookDTO +// request.setAttribute("mode", mode.toString()); +// learningForm.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); +// +// // Set the content in use flag. +// if (!notebook.isContentInUse()) { +// notebook.setContentInUse(new Boolean(true)); +// notebookService.saveOrUpdateNotebook(notebook); +// } +// +// LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, +// getServlet().getServletContext()); +// +// NotebookUser notebookUser; +// if (mode.equals(ToolAccessMode.TEACHER)) { +// Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); +// notebookUser = notebookService.getUserByUserIdAndSessionId(userID, toolSessionID); +// } else { +// notebookUser = getCurrentUser(toolSessionID); +// } +// +// // get any existing notebook entry +// NotebookEntry nbEntry = null; +// if (notebookUser != null) { +// nbEntry = notebookService.getEntry(notebookUser.getEntryUID()); +// } +// if (nbEntry != null) { +// learningForm.setEntryText(nbEntry.getEntry()); +// } +// +// // set readOnly flag. +// if (mode.equals(ToolAccessMode.TEACHER) || (notebook.isLockOnFinished() && notebookUser.isFinishedActivity())) { +// request.setAttribute("contentEditable", false); +// } else { +// request.setAttribute("contentEditable", true); +// } +// +// if (notebookUser != null) { +// // get teacher's comment if available +// request.setAttribute("teachersComment", notebookUser.getTeachersComment()); +// +// request.setAttribute("finishedActivity", notebookUser.isFinishedActivity()); +// request.setAttribute(AttributeNames.ATTR_LEARNER_CONTENT_FOLDER, +// notebookService.getLearnerContentFolder(toolSessionID, notebookUser.getUserId())); +// } +// +// // date and time restriction +// Date submissionDeadline = notebook.getSubmissionDeadline(); +// if (submissionDeadline != null) { +// HttpSession ss = SessionManager.getSession(); +// UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); +// TimeZone learnerTimeZone = learnerDto.getTimeZone(); +// Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); +// Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); +// notebookDTO.submissionDeadline = tzSubmissionDeadline; +// +// // calculate whether deadline has passed, and if so forward to "submissionDeadline" +// if (currentLearnerDate.after(tzSubmissionDeadline)) { +// return mapping.findForward("submissionDeadline"); +// } +// } +// +// return mapping.findForward("notebook"); +// } +// +// private NotebookUser getCurrentUser(Long toolSessionId) { +// UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); +// +// // attempt to retrieve user using userId and toolSessionId +// NotebookUser notebookUser = notebookService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), +// toolSessionId); +// +// if (notebookUser == null) { +// NotebookSession notebookSession = notebookService.getSessionBySessionId(toolSessionId); +// notebookUser = notebookService.createNotebookUser(user, notebookSession); +// } +// +// return notebookUser; +// } +// +// public ActionForward finishActivity(ActionMapping mapping, ActionForm form, 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()) { +// // 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())); +// } else { +// // update existing entry. +// notebookService.updateEntry(notebookUser.getEntryUID(), learningForm.getEntryText()); +// } +// +// notebookUser.setFinishedActivity(true); +// notebookService.saveOrUpdateNotebookUser(notebookUser); +// } +// +// ToolSessionManager sessionMgrService = NotebookServiceProxy +// .getNotebookSessionManager(getServlet().getServletContext()); +// +// try { +// String nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, notebookUser.getUserId()); +// response.sendRedirect(nextActivityUrl); +// } catch (DataMissingException e) { +// throw new NotebookException(e); +// } catch (ToolException e) { +// throw new NotebookException(e); +// } catch (IOException e) { +// throw new NotebookException(e); +// } +// +// return null; // TODO need to return proper page. +// } +//} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/LearningController.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,238 @@ +/**************************************************************** + * 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.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +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; +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.notebook.dto.NotebookDTO; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +import org.lamsfoundation.lams.tool.notebook.model.NotebookSession; +import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; +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.LearningForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author + * @version + * + * + * + * + * + */ +public class LearningController extends LamsDispatchAction { + + private static Logger log = Logger.getLogger(LearningController.class); + + private static final boolean MODE_OPTIONAL = false; + + private INotebookService notebookService; + + @RequestMapping("unspecified") + public String unspecified(LearningForm learningForm, 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, + LearningController.MODE_OPTIONAL); + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + // set up notebookService + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + + // Retrieve the session and content. + NotebookSession notebookSession = notebookService.getSessionBySessionId(toolSessionID); + if (notebookSession == null) { + throw new NotebookException("Cannot retrieve session with toolSessionID" + toolSessionID); + } + + Notebook notebook = notebookSession.getNotebook(); + + // check defineLater + if (notebook.isDefineLater()) { + return "pages/learning/notebook"; + } + + // set mode, toolSessionID and NotebookDTO + request.setAttribute("mode", mode.toString()); + learningForm.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); + + // Set the content in use flag. + if (!notebook.isContentInUse()) { + notebook.setContentInUse(new Boolean(true)); + notebookService.saveOrUpdateNotebook(notebook); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + getServlet().getServletContext()); + + NotebookUser notebookUser; + if (mode.equals(ToolAccessMode.TEACHER)) { + Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); + notebookUser = notebookService.getUserByUserIdAndSessionId(userID, toolSessionID); + } else { + notebookUser = getCurrentUser(toolSessionID); + } + + // get any existing notebook entry + NotebookEntry nbEntry = null; + if (notebookUser != null) { + nbEntry = notebookService.getEntry(notebookUser.getEntryUID()); + } + if (nbEntry != null) { + learningForm.setEntryText(nbEntry.getEntry()); + } + + // set readOnly flag. + if (mode.equals(ToolAccessMode.TEACHER) || (notebook.isLockOnFinished() && notebookUser.isFinishedActivity())) { + request.setAttribute("contentEditable", false); + } else { + request.setAttribute("contentEditable", true); + } + + if (notebookUser != null) { + // get teacher's comment if available + request.setAttribute("teachersComment", notebookUser.getTeachersComment()); + + request.setAttribute("finishedActivity", notebookUser.isFinishedActivity()); + request.setAttribute(AttributeNames.ATTR_LEARNER_CONTENT_FOLDER, + notebookService.getLearnerContentFolder(toolSessionID, notebookUser.getUserId())); + } + + // date and time restriction + Date submissionDeadline = notebook.getSubmissionDeadline(); + if (submissionDeadline != null) { + HttpSession ss = SessionManager.getSession(); + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); + notebookDTO.submissionDeadline = tzSubmissionDeadline; + + // calculate whether deadline has passed, and if so forward to "submissionDeadline" + if (currentLearnerDate.after(tzSubmissionDeadline)) { + return "pages/learning/submissionDeadline"; + } + } + + return ""; //mapping.findForward("notebook"); + } + + private NotebookUser getCurrentUser(Long toolSessionId) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + // attempt to retrieve user using userId and toolSessionId + NotebookUser notebookUser = notebookService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), + toolSessionId); + + if (notebookUser == null) { + NotebookSession notebookSession = notebookService.getSessionBySessionId(toolSessionId); + notebookUser = notebookService.createNotebookUser(user, notebookSession); + } + + return notebookUser; + } + + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, 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()) { + // 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())); + } else { + // update existing entry. + notebookService.updateEntry(notebookUser.getEntryUID(), learningForm.getEntryText()); + } + + notebookUser.setFinishedActivity(true); + notebookService.saveOrUpdateNotebookUser(notebookUser); + } + + ToolSessionManager sessionMgrService = NotebookServiceProxy + .getNotebookSessionManager(getServlet().getServletContext()); + + try { + String nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, notebookUser.getUserId()); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new NotebookException(e); + } catch (ToolException e) { + throw new NotebookException(e); + } catch (IOException e) { + throw new NotebookException(e); + } + + return null; // TODO need to return proper page. + } +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringAction.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringAction.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/MonitoringAction.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,286 @@ +/**************************************************************** + * 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.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +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.service.NotebookServiceProxy; +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.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; +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; + +public class MonitoringAction extends LamsDispatchAction { + private static String noEntryText = null; // access via getNoEntryText() + + public INotebookService notebookService; + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + setupService(); + 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 mapping.findForward("success"); + } + + public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + setupService(); + 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((String) 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 + */ + public ActionForward saveTeacherComment(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + setupService(); + + 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 + */ + public ActionForward setSubmissionDeadline(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + setupService(); + + 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 */ + public ActionForward getStatistics(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + setupService(); + 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 mapping.findForward("statistic"); + } + + /** + * set up notebookService + */ + private void setupService() { + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + } + + private String getNoEntryText() { + if (noEntryText == null) { + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); + noEntryText = ((MessageService) wac.getBean("notebookMessageService")).getMessage("label.no.entry"); + } + return noEntryText; + } +} Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerAction.java =================================================================== diff -u --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerAction.java (revision 0) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/controller/PedagogicalPlannerAction.java (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,103 @@ +/**************************************************************** + * 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 javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.notebook.model.Notebook; +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.web.forms.NotebookPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author + * @version + * + * + * + * + * + */ +public class PedagogicalPlannerAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerAction.class); + + public INotebookService notebookService; + + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + return initPedagogicalPlannerForm(mapping, form, request, response); + } + + public ActionForward initPedagogicalPlannerForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + NotebookPedagogicalPlannerForm plannerForm = (NotebookPedagogicalPlannerForm) form; + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Notebook notebook = getNotebookService().getNotebookByContentId(toolContentID); + plannerForm.fillForm(notebook); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return mapping.findForward(NotebookConstants.SUCCESS); + } + + public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws IOException { + NotebookPedagogicalPlannerForm plannerForm = (NotebookPedagogicalPlannerForm) form; + ActionMessages errors = plannerForm.validate(); + if (errors.isEmpty()) { + String instructions = plannerForm.getInstructions(); + Long toolContentID = plannerForm.getToolContentID(); + Notebook notebook = getNotebookService().getNotebookByContentId(toolContentID); + notebook.setInstructions(instructions); + getNotebookService().saveOrUpdateNotebook(notebook); + } else { + saveErrors(request, errors); + } + return mapping.findForward(NotebookConstants.SUCCESS); + } + + private INotebookService getNotebookService() { + if (notebookService == null) { + notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); + } + return notebookService; + } +} \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java =================================================================== diff -u -r738b372e49bcdade985e305c024e4be00764ee9e -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 738b372e49bcdade985e305c024e4be00764ee9e) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -61,13 +61,7 @@ SessionMap sessionMap; - @Override - public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { - ActionErrors ac = new ActionErrors(); - ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); - return ac; - } public String getSessionMapID() { return sessionMapID; Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java (.../LearningForm.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/LearningForm.java (.../LearningForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -33,7 +33,7 @@ * * */ -public class LearningForm extends ActionForm { +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 -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -30,7 +30,7 @@ /** * */ -public class MonitoringForm extends ActionForm { +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 -r2f725f8ef2aa09a2663b2335bf67213074426d11 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/NotebookPedagogicalPlannerForm.java (.../NotebookPedagogicalPlannerForm.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/forms/NotebookPedagogicalPlannerForm.java (.../NotebookPedagogicalPlannerForm.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -29,7 +29,7 @@ /** * */ -public class NotebookPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { +public class NotebookPedagogicalPlannerForm extends PedagogicalPlannerSpringForm { String instructions; String contentFolderID; Index: lams_tool_notebook/web/WEB-INF/spring-servlet.xml =================================================================== diff -u --- lams_tool_notebook/web/WEB-INF/spring-servlet.xml (revision 0) +++ lams_tool_notebook/web/WEB-INF/spring-servlet.xml (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file Index: lams_tool_notebook/web/WEB-INF/web.xml =================================================================== diff -u -r26513e4a3a00a82cf700663c7cfe79d39c47732a -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/WEB-INF/web.xml (.../web.xml) (revision 26513e4a3a00a82cf700663c7cfe79d39c47732a) +++ lams_tool_notebook/web/WEB-INF/web.xml (.../web.xml) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -66,24 +66,10 @@ - action - org.apache.struts.action.ActionServlet - - config - /WEB-INF/struts-config.xml - - - debug - 999 - - - detail - 2 - - - validate - true - + spring + + org.springframework.web.servlet.DispatcherServlet + 1 @@ -116,7 +102,7 @@ - action + spring *.do Index: lams_tool_notebook/web/common/messages.jsp =================================================================== diff -u -ra0a249e0861e944d080689e4ebb853566cd40f2d -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/common/messages.jsp (.../messages.jsp) (revision a0a249e0861e944d080689e4ebb853566cd40f2d) +++ lams_tool_notebook/web/common/messages.jsp (.../messages.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,8 +1,7 @@ <%-- Error Messages --%> - - - - - - - + + + + + + \ No newline at end of file Index: lams_tool_notebook/web/common/taglibs.jsp =================================================================== diff -u -r5fd25049d526080b60f6753a3d4603fb18913202 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/common/taglibs.jsp (.../taglibs.jsp) (revision 5fd25049d526080b60f6753a3d4603fb18913202) +++ lams_tool_notebook/web/common/taglibs.jsp (.../taglibs.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,12 +1,7 @@ <%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> - <%@ taglib uri="tags-bean" prefix="bean"%> -<%@ taglib uri="tags-logic" prefix="logic"%> <%@ taglib uri="tags-function" prefix="fn" %> -<%@ taglib uri="tags-tiles" prefix="tiles"%> -<%@ taglib uri="tags-html" prefix="html"%> <%@ taglib uri="tags-core" prefix="c"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-lams" prefix="lams"%> - - \ No newline at end of file +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> \ No newline at end of file Index: lams_tool_notebook/web/pages/authoring/addCondition.jsp =================================================================== diff -u -rc43a7c4f1389ad2b5fdc526aa736be11ab5ad271 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision c43a7c4f1389ad2b5fdc526aa736be11ab5ad271) +++ lams_tool_notebook/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -11,20 +11,20 @@ <%@ include file="/common/messages.jsp"%> - - + +
- +
<%-- Text search form fields are being included --%> -
+
@@ -15,7 +15,7 @@
Index: lams_tool_notebook/web/pages/authoring/authoring.jsp =================================================================== diff -u -r6cfcb91c5526d4bbb22cd98dbd9d04c175cba1eb -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 6cfcb91c5526d4bbb22cd98dbd9d04c175cba1eb) +++ lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,23 +1,29 @@ + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.notebook.util.NotebookConstants"%> - - - - - +<%@ taglib uri="tags-lams" prefix="lams"%> + + + + + + + + + - - + + - + - - - - - + + + + + - + <%@ include file="/common/messages.jsp"%> @@ -43,5 +49,7 @@ - - + + + + \ No newline at end of file Index: lams_tool_notebook/web/pages/authoring/basic.jsp =================================================================== diff -u -r738b372e49bcdade985e305c024e4be00764ee9e -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/authoring/basic.jsp (.../basic.jsp) (revision 738b372e49bcdade985e305c024e4be00764ee9e) +++ lams_tool_notebook/web/pages/authoring/basic.jsp (.../basic.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,20 +1,19 @@ <%@ include file="/common/taglibs.jsp"%> - - +
- +
- +
Index: lams_tool_notebook/web/pages/authoring/conditions.jsp =================================================================== diff -u -r408c36ea4a07535a4a26875d73c347a2cc2147a0 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision 408c36ea4a07535a4a26875d73c347a2cc2147a0) +++ lams_tool_notebook/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,5 +1,4 @@ <%@ include file="/common/taglibs.jsp"%> - - - - - - + + + + -
@@ -124,7 +127,7 @@ - + @@ -149,7 +152,7 @@
- @@ -159,18 +162,14 @@ - +
-
+ - - - - \ No newline at end of file + + + + + Index: lams_tool_notebook/web/pages/learning/submissionDeadline.jsp =================================================================== diff -u -r65a41bd80f751917e945f17beb5f0d34926066ac -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 65a41bd80f751917e945f17beb5f0d34926066ac) +++ lams_tool_notebook/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,43 +1,55 @@ + <%@ include file="/common/taglibs.jsp"%> - - + - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - Index: lams_tool_notebook/web/pages/monitoring/daterestriction.jsp =================================================================== diff -u -r326a22552c270b321496ebb84887c1124f1881f1 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/monitoring/daterestriction.jsp (.../daterestriction.jsp) (revision 326a22552c270b321496ebb84887c1124f1881f1) +++ lams_tool_notebook/web/pages/monitoring/daterestriction.jsp (.../daterestriction.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -11,9 +11,9 @@ - +
- +
@@ -22,8 +22,8 @@ - + - + \ No newline at end of file Index: lams_tool_notebook/web/pages/monitoring/editActivity.jsp =================================================================== diff -u -r8b96d871bf93fc27f6f6d086977dc8c95d5e7f90 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision 8b96d871bf93fc27f6f6d086977dc8c95d5e7f90) +++ lams_tool_notebook/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -33,6 +33,6 @@ - + - + Index: lams_tool_notebook/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r2fab2e212d7c46f61829635d0834821eb5484837 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_notebook/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 2fab2e212d7c46f61829635d0834821eb5484837) +++ lams_tool_notebook/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -1,27 +1,61 @@ + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.notebook.util.NotebookConstants"%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + + + + - - - - - + + + + + + + + + - - - - - - - - - + + + + - \ No newline at end of file + Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java =================================================================== diff -u -rbd320e8b9a1e0e966b4a9f1ca718f06c593c34d9 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java (.../AuthoringConditionController.java) (revision bd320e8b9a1e0e966b4a9f1ca718f06c593c34d9) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/controller/AuthoringConditionController.java (.../AuthoringConditionController.java) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -51,6 +51,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; /** @@ -134,7 +135,7 @@ * @throws ServletException */ @RequestMapping("/saveOrUpdateCondition") - public String saveOrUpdateCondition(SurveyConditionForm surveyConditionForm, Errors errors, + public String saveOrUpdateCondition(@ModelAttribute("surveyConditionForm")SurveyConditionForm surveyConditionForm, Errors errors, HttpServletRequest request) { // ActionErrors errors = validateSurveyCondition(conditionForm, request); Index: lams_tool_survey/web/pages/authoring/conditions.jsp =================================================================== diff -u -rbd320e8b9a1e0e966b4a9f1ca718f06c593c34d9 -r749b841adf6115016059d15ddfa58aee5b11e26d --- lams_tool_survey/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision bd320e8b9a1e0e966b4a9f1ca718f06c593c34d9) +++ lams_tool_survey/web/pages/authoring/conditions.jsp (.../conditions.jsp) (revision 749b841adf6115016059d15ddfa58aee5b11e26d) @@ -40,7 +40,6 @@ //Packs additional elements and submits the question form function submitCondition(){ - debugger; var form = $('#surveyConditionForm'); $('#conditionInputArea').load(form.attr('action'), form.serialize()); }