Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NbApplicationException.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== diff -u -r2abc3485dc2d24ea02044a64271f3ee0d3b8c11b -r983160690fed1d94b51c2ea9206c58093a29040d --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision 2abc3485dc2d24ea02044a64271f3ee0d3b8c11b) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java (.../NoticeboardServicePOJO.java) (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -54,14 +54,14 @@ 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.noticeboard.NbApplicationException; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardContentDAO; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardUserDAO; +import org.lamsfoundation.lams.tool.noticeboard.util.NbApplicationException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.JsonUtil; Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbApplicationException.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbApplicationException.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbApplicationException.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,68 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.noticeboard.util; + +/** + * Generic exception class for the noticeboard tool + */ + +public class NbApplicationException extends RuntimeException { + /** + * Default Constructor + */ + public NbApplicationException() { + super(); + } + + /** + * Constructor for customized error message + * + * @param message + */ + public NbApplicationException(String message) { + super(message); + } + + /** + * Constructor for wrapping the throwable object + * + * @param cause + */ + public NbApplicationException(Throwable cause) { + super(cause); + } + + /** + * Constructor for wrapping both the customized error message and + * throwable exception object. + * + * @param message + * @param cause + */ + public NbApplicationException(String message, Throwable cause) { + super(message, cause); + } + +} Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbLearnerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbLearnerForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbLearnerStarterAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbPedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 983160690fed1d94b51c2ea9206c58093a29040d refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbPedagogicalPlannerForm.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/ClearSessionAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/ClearSessionAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/ClearSessionAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,51 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +import javax.servlet.http.HttpSession; + +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; +import org.lamsfoundation.lams.tool.ToolAccessMode; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + * + * + * + * + * @version $Revision$ + */ +public class ClearSessionAction extends LamsAuthoringFinishAction { + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } + } + +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbAuthoringAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbAuthoringAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbAuthoringAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,236 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +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.apache.struts.util.MessageResources; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.tool.noticeboard.web.form.NbAuthoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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; + +/** + *

+ * This class is a simple combination of NbAuthoringStarterAction and NbAuthoringAction. It has been created for the + * purpose of supporting the new authoring page which is done using DHTML. + *

+ * + *

+ * The unspecified method, is the same as the execute method for NbAuthoringStarterAction. It will get called when the + * method parameter is not specified (that is on first entry into the authoring environment). + *

+ * + *

+ * The save, upload and delete method is the same as that of NbAuthoringAction, to see its explanation, please see + * org.lamsfoundation.lams.tool.noticeboard.web.NbAuthoringAction + *

+ * + * @author mtruong + */ +public class NbAuthoringAction extends LamsDispatchAction { + private static Logger logger = Logger.getLogger(NbAuthoringAction.class.getName()); + public final static String FORM = "NbAuthoringForm"; + + /** Get the user from the shared session */ + public UserDTO getUser(HttpServletRequest request) { + // set up the user details + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user == null) { + MessageResources resources = getResources(request); + String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User"); + logger.error(error); + throw new NbApplicationException(error); + } + return user; + } + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + /* + * Retrieve the Service + */ + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + + //to ensure that we are working with a new form, not one from previous session + NbAuthoringForm nbForm = new NbAuthoringForm(); + + Long contentId = WebUtil.readLongParam(request, NoticeboardConstants.TOOL_CONTENT_ID); + String contentFolderId = WebUtil.readStrParam(request, NoticeboardConstants.CONTENT_FOLDER_ID); + + nbForm.setToolContentID(contentId.toString()); + + /* + * DefineLater is used in the basic screen. If defineLater is set, then in the authoring page, + * the two tabs {Advanced, Instructions} are not visible. + */ + nbForm.setDefineLater(request.getParameter(NoticeboardConstants.DEFINE_LATER)); + + if (!contentExists(nbService, contentId)) { + // Pre-fill the form with the default content + //NoticeboardContent nb = nbService.retrieveNoticeboard(NoticeboardConstants.DEFAULT_CONTENT_ID); + Long defaultToolContentId = nbService + .getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE); + // logger.debug("Default tool content id is " + defaultToolContentId); + NoticeboardContent nb = nbService.retrieveNoticeboard(defaultToolContentId); + + if (nb == null) { + String error = "There is data missing in the database"; + logger.error(error); + throw new NbApplicationException(error); + } + + //initialise the values in the form, so the values will be shown in the jsp + nbForm.setToolContentID(contentId.toString()); + nbForm.setContentFolderID(contentFolderId); + nbForm.setTitle(nb.getTitle()); + nbForm.setBasicContent(nb.getContent()); + + //content already exists on the database + } else { + //get the values from the database + NoticeboardContent nb = nbService.retrieveNoticeboard(contentId); + + /* + * If retrieving existing content, check whether the contentInUse flag is set, if set, the + * author is not allowed to edit content + */ + + /* + * Define later set to true when the edit activity tab is brought up + * So that users cannot start using the content while the staff member is editing the content + */ + nbForm.populateFormWithNbContentValues(nb); + nbForm.setContentFolderID(contentFolderId); + boolean isDefineLater = Boolean.parseBoolean(nbForm.getDefineLater()); + nb.setDefineLater(isDefineLater); + nbService.saveNoticeboard(nb); + + if (isDefineLater) { + request.setAttribute(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER.toString()); + + // audit log the teacher has started editing activity in monitor + nbService.auditLogStartEditingActivityInMonitor(contentId); + } + } + + request.setAttribute(FORM, nbForm); + return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE); + } + + /** + * Checks the session to see if the title and content session variables exist or not. + * + * @param session + * The HttpSession to check. + * @return true if the parameters title and content exists in the session, false otherwise + */ + private boolean contentExists(INoticeboardService service, Long id) { + NoticeboardContent nb = service.retrieveNoticeboard(id); + if (nb == null) { + return false; + } else { + return true; + } + + } + + public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + + NbAuthoringForm nbForm = (NbAuthoringForm) form; + //copyAuthoringFormValuesIntoFormBean(request, nbForm); + + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + String idAsString = nbForm.getToolContentID(); + if (idAsString == null) { + MessageResources resources = getResources(request); + String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "Tool Content Id"); + logger.error(error); + throw new NbApplicationException(error); + } + Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentID()); + + //throws exception if the content id does not exist + checkContentId(content_id); + + NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id); + if (nbContent == null) { + //create a new noticeboard object + nbContent = new NoticeboardContent(); + nbContent.setNbContentId(content_id); + } + + nbForm.copyValuesIntoNbContent(nbContent); + if (nbContent.getDateCreated() == null) { + nbContent.setDateCreated(nbContent.getDateUpdated()); + } + + UserDTO user = getUser(request); + nbContent.setCreatorUserId(new Long(user.getUserID().longValue())); + + // Author has finished editing the content and mark the defineLater flag to false + nbContent.setDefineLater(false); + nbService.saveNoticeboard(nbContent); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE); + + } + + /** + * It is assumed that the contentId is passed as a http parameter + * if the contentId is null, an exception is thrown, otherwise proceed as normal + * + * @param contentId + * the toolContentId to check + */ + private void checkContentId(Long contentId) { + if (contentId == null) { + String error = "Unable to continue. Tool content id missing."; + + throw new NbApplicationException(error); + } + } + +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,212 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +import java.io.IOException; +import java.util.Date; + +import javax.servlet.ServletException; +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.apache.struts.util.MessageResources; +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.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.tool.noticeboard.web.form.NbLearnerForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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; + +/** + * Creation Date: 29-06-05 + * + * This class has been created so that when a learner finishes an activity, + * leaveToolSession() will be called to inform the progress engine + * that the user has completed this activity. + * + * A note: at the time of writing (11-08-05) a null pointer exception + * occurs when making a call to leaveToolSession(). Will have to wait until + * the learner side of things is tested first. + * + * + * + * + * + * + * + * + */ +public class NbLearnerAction extends LamsDispatchAction { + + static Logger logger = Logger.getLogger(NbLearnerAction.class.getName()); + + /** Get the user id from the shared session */ + public Long getUserID(HttpServletRequest request) { + // set up the user details + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user == null) { + MessageResources resources = getResources(request); + String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User"); + logger.error(error); + throw new NbApplicationException(error); + } + return new Long(user.getUserID().longValue()); + } + + /** + * Indicates that the user has finished viewing the noticeboard. + * The session is set to complete and leaveToolSession is called. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward finish(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) + throws NbApplicationException, ToolException, DataMissingException, ServletException, IOException { + + NbLearnerForm learnerForm = (NbLearnerForm) form; + Long userID = getUserID(request); + + Long toolSessionID = NbWebUtil.convertToLong(learnerForm.getToolSessionID()); + if (toolSessionID == null) { + String error = "Unable to continue. The parameters tool session id is missing"; + logger.error(error); + throw new NbApplicationException(error); + } + + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + ToolSessionManager sessionMgrService = NoticeboardServiceProxy + .getNbSessionManager(getServlet().getServletContext()); + + ToolAccessMode mode = WebUtil.getToolAccessMode(learnerForm.getMode()); + if (mode == ToolAccessMode.LEARNER || mode == ToolAccessMode.AUTHOR) { + NoticeboardSession nbSession = nbService.retrieveNoticeboardSession(toolSessionID); + NoticeboardUser nbUser = nbService.retrieveNbUserBySession(userID, toolSessionID); + + nbUser.setUserStatus(NoticeboardUser.COMPLETED); + nbService.updateNoticeboardSession(nbSession); + nbService.updateNoticeboardUser(nbUser); + + // Create the notebook entry if reflection is set. + NoticeboardContent nbContent = nbService.retrieveNoticeboardBySessionID(toolSessionID); + if (nbContent.getReflectOnActivity()) { + // check for existing notebook entry + NotebookEntry entry = nbService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + NoticeboardConstants.TOOL_SIGNATURE, userID.intValue()); + + if (entry == null) { + // create new entry + nbService.createNotebookEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + NoticeboardConstants.TOOL_SIGNATURE, userID.intValue(), learnerForm.getReflectionText()); + } else { + // update existing entry + entry.setEntry(learnerForm.getReflectionText()); + entry.setLastModified(new Date()); + nbService.updateEntry(entry); + } + } + + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, getUserID(request)); + } catch (DataMissingException e) { + log.error(e); + throw new ServletException(e); + } catch (ToolException e) { + log.error(e); + throw new ServletException(e); + } + + response.sendRedirect(nextActivityUrl); + + return null; + + } + request.setAttribute(NoticeboardConstants.READ_ONLY_MODE, "true"); + + return mapping.findForward(NoticeboardConstants.DISPLAY_LEARNER_CONTENT); + + } + + /** + * Indicates that the user has finished viewing the noticeboard, and will be + * passed onto the Notebook reflection screen. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward reflect(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + + NbLearnerForm learnerForm = (NbLearnerForm) form; + Long toolSessionID = NbWebUtil.convertToLong(learnerForm.getToolSessionID()); + NoticeboardContent nbContent = nbService.retrieveNoticeboardBySessionID(toolSessionID); + request.setAttribute("reflectInstructions", nbContent.getReflectInstructions()); + request.setAttribute("title", nbContent.getTitle()); + request.setAttribute("allowComments", nbContent.isAllowComments()); + request.setAttribute("likeAndDislike", nbContent.isCommentsLikeAndDislike()); + + // get the existing reflection entry + NotebookEntry entry = nbService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + NoticeboardConstants.TOOL_SIGNATURE, getUserID(request).intValue()); + if (entry != null) { + request.setAttribute("reflectEntry", entry.getEntry()); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + getServlet().getServletContext()); + + return mapping.findForward(NoticeboardConstants.REFLECT_ON_ACTIVITY); + } +} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerStarterAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerStarterAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbLearnerStarterAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,278 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +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.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.util.MessageResources; +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.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.tool.noticeboard.web.form.NbLearnerForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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; + +/** + * Creation Date: 27-06-05 + * + * The learner url can be of three modes learner, teacher or author. Depending on + * what mode was set, it will trigger the corresponding action. If the mode parameter + * is missing or a key is not found in the keymap, it will call the unspecified method + * which defaults to the learner action. + * + *

+ * The difference between author mode (which is basically the preview) + * is that if the defineLater flag is set, it will not be able to see the noticeboard screen + *

+ * + * + * + * + * + * + * + * + * + */ + +public class NbLearnerStarterAction extends LamsDispatchAction { + + static Logger logger = Logger.getLogger(NbLearnerStarterAction.class.getName()); + + private UserDTO getUserDTO(HttpServletRequest request) { + // set up the user details + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (user == null) { + MessageResources resources = getResources(request); + String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "User"); + logger.error(error); + throw new NbApplicationException(error); + } + return user; + } + + /** Get the user id from the shared session */ + public Long getUserID(HttpServletRequest request) { + UserDTO user = getUserDTO(request); + return new Long(user.getUserID().longValue()); + } + + /** Get the user id from the url - needed for the monitoring mode */ + public Long getUserIDFromURLCall(HttpServletRequest request) { + return WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); + } + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + return learner(mapping, form, request, response); + } + + public ActionForward learner(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + + NoticeboardContent nbContent = null; + NoticeboardUser nbUser = null; + saveMessages(request, null); + + NbLearnerForm learnerForm = (NbLearnerForm) form; + + ActionMessages message = new ActionMessages(); + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + + Long toolSessionID = NbWebUtil.convertToLong(learnerForm.getToolSessionID()); + + if (toolSessionID == null) { + String error = "Unable to continue. The parameters tool session id is missing"; + logger.error(error); + throw new NbApplicationException(error); + } + + nbContent = nbService.retrieveNoticeboardBySessionID(toolSessionID); + // nbSession = nbService.retrieveNoticeboardSession(toolSessionId); + + if (nbContent == null) { + String error = "An Internal error has occurred. Please exit and retry this sequence"; + logger.error(error); + throw new NbApplicationException(error); + } + + if (isFlagSet(nbContent, NoticeboardConstants.FLAG_DEFINE_LATER)) { + return mapping.findForward(NoticeboardConstants.DEFINE_LATER); + } + + boolean readOnly = false; + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, false); + Long userID = null; + if (mode == ToolAccessMode.LEARNER || mode == ToolAccessMode.AUTHOR) { + userID = getUserID(request); + nbUser = nbService.retrieveNbUserBySession(userID, toolSessionID); + + if (!nbContent.isContentInUse()) { + /* Set the ContentInUse flag to true, and defineLater flag to false */ + nbContent.setContentInUse(true); + nbService.saveNoticeboard(nbContent); + } + + if (nbUser == null) { + //create a new user with this session id + nbUser = new NoticeboardUser(userID); + UserDTO user = getUserDTO(request); + nbUser.setUsername(user.getLogin()); + nbUser.setFullname(user.getFirstName() + " " + user.getLastName()); + nbService.addUser(toolSessionID, nbUser); + } + } else { + // user will not exist if force completed. + userID = getUserIDFromURLCall(request); + nbUser = nbService.retrieveNbUserBySession(userID, toolSessionID); + readOnly = true; + } + + learnerForm.copyValuesIntoForm(nbContent, readOnly, mode.toString()); + + NotebookEntry notebookEntry = nbService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + NoticeboardConstants.TOOL_SIGNATURE, userID.intValue()); + if (notebookEntry != null) { + request.setAttribute("reflectEntry", notebookEntry.getEntry()); + } + request.setAttribute("reflectInstructions", nbContent.getReflectInstructions()); + request.setAttribute("reflectOnActivity", nbContent.getReflectOnActivity()); + request.setAttribute("allowComments", nbContent.isAllowComments()); + request.setAttribute("likeAndDislike", nbContent.isCommentsLikeAndDislike()); + + Boolean userFinished = (nbUser != null && NoticeboardUser.COMPLETED.equals(nbUser.getUserStatus())); + request.setAttribute("userFinished", userFinished); + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + getServlet().getServletContext()); + + /* + * Checks to see if the runOffline flag is set. + * If the particular flag is set, control is forwarded to jsp page + * displaying to the user the message according to what flag is set. + */ + if (displayMessageToUser(nbContent, message)) { + saveMessages(request, message); + return mapping.findForward(NoticeboardConstants.DISPLAY_MESSAGE); + } + + return mapping.findForward(NoticeboardConstants.DISPLAY_LEARNER_CONTENT); + + } + + public ActionForward teacher(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + return learner(mapping, form, request, response); + } + + public ActionForward author(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + + return learner(mapping, form, request, response); + + } + + /** + *

+ * Performs a check on the flag indicated by flag + * In this noticeboard tool, there are 3 possible flags: + *

  • defineLater
  • + *
  • contentInUse
  • + *
    + * Returns true if the flag is set, false otherwise + *

    + * + * @param content + * The instance of NoticeboardContent + * @param flag + * The flag to check, can take the following set of values (defineLater, contentInUse) + * @return Returns true if flag is set, false otherwise + */ + private boolean isFlagSet(NoticeboardContent content, int flag) throws NbApplicationException { + switch (flag) { + case NoticeboardConstants.FLAG_DEFINE_LATER: + return (content.isDefineLater()); + // break; + case NoticeboardConstants.FLAG_CONTENT_IN_USE: + return (content.isContentInUse()); + // break; + default: + throw new NbApplicationException("Invalid flag"); + } + + } + + /** + *

    + * This methods checks the defineLater and runOffline flag. + * If defineLater flag is set, then a message is added to an ActionMessages + * object saying that the contents have not been defined yet. If the runOffline + * flag is set, a message is added to ActionMessages saying that the contents + * are not being run online. + * This method will return true if any one of the defineLater or runOffline flag is set. + * Otherwise false will be returned. + *

    + * + * @param content + * The instance of NoticeboardContent + * @param message + * the instance of ActtionMessages + * @return true if any of the flags are set, false otherwise + */ + private boolean displayMessageToUser(NoticeboardContent content, ActionMessages message) { + boolean isDefineLaterSet = isFlagSet(content, NoticeboardConstants.FLAG_DEFINE_LATER); + if (isDefineLaterSet) { + if (isDefineLaterSet) { + message.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.defineLaterSet")); + } + return true; + } else { + return false; + } + } + +} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbMonitoringAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbMonitoringAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbMonitoringAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,164 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +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.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; +import org.lamsfoundation.lams.tool.noticeboard.dto.ReflectionDTO; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.tool.noticeboard.web.form.NbMonitoringForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * The buttons are a switch between tabs and will forward to a jsp and display + * the appropriate page. + * + * @author mtruong + */ +public class NbMonitoringAction extends LamsDispatchAction { + + static Logger logger = Logger.getLogger(NbMonitoringAction.class.getName()); + + public final static String FORM = "NbMonitoringForm"; + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + Long toolContentId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.TOOL_CONTENT_ID)); + String contentFolderID = WebUtil.readStrParam(request, NoticeboardConstants.CONTENT_FOLDER_ID); + if (toolContentId == null) { + String error = "Unable to continue. Tool content id missing"; + logger.error(error); + throw new NbApplicationException(error); + } + + NbMonitoringForm monitorForm = new NbMonitoringForm(); + + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + NoticeboardContent content = nbService.retrieveNoticeboard(toolContentId); + + monitorForm.setTitle(content.getTitle()); + monitorForm.setBasicContent(content.getContent()); + + request.setAttribute(NoticeboardConstants.TOOL_CONTENT_ID, toolContentId); + request.setAttribute(NoticeboardConstants.CONTENT_FOLDER_ID, contentFolderID); + + //Get the total number of learners that have participated in this tool activity + monitorForm.setTotalLearners(nbService.calculateTotalNumberOfUsers(toolContentId)); + + Set sessions = content.getNbSessions(); + Iterator i = sessions.iterator(); + Map numUsersMap = new HashMap(); + Map sessionIdMap = new HashMap(); + List reflections = new ArrayList(); + while (i.hasNext()) { + NoticeboardSession session = (NoticeboardSession) i.next(); + int numUsersInSession = nbService.getNumberOfUsersInSession(session); + numUsersMap.put(session.getNbSessionName(), new Integer(numUsersInSession)); + sessionIdMap.put(session.getNbSessionName(), session.getNbSessionId()); + // Get list of users that have made a reflection entry + if (content.getReflectOnActivity()) { + List sessionUsers = nbService.getUsersBySession(session.getNbSessionId()); + for (int j = 0; j < sessionUsers.size(); j++) { + NoticeboardUser nbUser = (NoticeboardUser) sessionUsers.get(j); + NotebookEntry nbEntry = nbService.getEntry(session.getNbSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, NoticeboardConstants.TOOL_SIGNATURE, + nbUser.getUserId().intValue()); + if (nbEntry != null) { + ReflectionDTO dto = new ReflectionDTO(nbEntry); + dto.setExternalId(session.getNbSessionId()); + dto.setUserId(nbUser.getUserId()); + dto.setUsername(nbUser.getUsername()); + reflections.add(dto); + } + } + } + } + monitorForm.setGroupStatsMap(numUsersMap); + monitorForm.setSessionIdMap(sessionIdMap); + + boolean isGroupedActivity = nbService.isGroupedActivity(toolContentId); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + // Set reflection statistics, if reflection is set + request.setAttribute("reflectOnActivity", content.getReflectOnActivity()); + request.setAttribute("reflectInstructions", content.getReflectInstructions()); + request.setAttribute("reflections", reflections); + + request.setAttribute("allowComments", content.isAllowComments()); + + String currentTab = WebUtil.readStrParam(request, AttributeNames.PARAM_CURRENT_TAB, true); + monitorForm.setCurrentTab(currentTab != null ? currentTab : "1"); + request.setAttribute(FORM, monitorForm); + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } + + public ActionForward viewReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + Long userId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.USER_ID)); + Long toolSessionId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.TOOL_SESSION_ID)); + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + NoticeboardUser nbUser = nbService.retrieveNoticeboardUser(userId, toolSessionId); + NotebookEntry nbEntry = nbService.getEntry(nbUser.getNbSession().getNbSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, NoticeboardConstants.TOOL_SIGNATURE, userId.intValue()); + if (nbEntry != null) { + request.setAttribute("nbEntry", nbEntry.getEntry()); + request.setAttribute("name", nbUser.getFullname()); + } + + return mapping.findForward(NoticeboardConstants.MONITOR_REFLECTION_PAGE); + } + + public ActionForward viewComments(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + request.setAttribute(NoticeboardConstants.TOOL_SESSION_ID, + request.getParameter(NoticeboardConstants.TOOL_SESSION_ID)); + return mapping.findForward(NoticeboardConstants.MONITOR_COMMENTS_PAGE); + } + +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbPedagogicalPlannerAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbPedagogicalPlannerAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/action/NbPedagogicalPlannerAction.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,104 @@ +/**************************************************************** + * 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.noticeboard.web.action; + +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.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.web.form.NbPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author + * @version + * + * + * + * + * + */ +public class NbPedagogicalPlannerAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerAction.class); + + public INoticeboardService noticeboardService; + + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + if (noticeboardService == null) { + noticeboardService = NoticeboardServiceProxy.getNbService(this.getServlet().getServletContext()); + } + return initPedagogicalPlannerForm(mapping, form, request, response); + } + + public ActionForward initPedagogicalPlannerForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + NbPedagogicalPlannerForm plannerForm = (NbPedagogicalPlannerForm) form; + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + NoticeboardContent noticeboard = getNoticeboardService().retrieveNoticeboard(toolContentID); + plannerForm.fillForm(noticeboard); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return mapping.findForward("success"); + + } + + public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws IOException { + NbPedagogicalPlannerForm plannerForm = (NbPedagogicalPlannerForm) form; + ActionMessages errors = plannerForm.validate(); + if (errors.isEmpty()) { + String content = plannerForm.getBasicContent(); + Long toolContentID = plannerForm.getToolContentID(); + NoticeboardContent noticeboard = getNoticeboardService().retrieveNoticeboard(toolContentID); + noticeboard.setContent(content); + getNoticeboardService().saveNoticeboard(noticeboard); + } else { + saveErrors(request, errors); + } + return mapping.findForward("success"); + } + + private INoticeboardService getNoticeboardService() { + if (noticeboardService == null) { + noticeboardService = NoticeboardServiceProxy.getNbService(this.getServlet().getServletContext()); + } + return noticeboardService; + } +} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbAuthoringForm.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbAuthoringForm.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbAuthoringForm.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,234 @@ +/**************************************************************** + * 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.noticeboard.web.form; + +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; + +/** + *

    ActionForm which holds the state of the noticeboard form content in the Authoring + * environment. Stores all values in the session scope.

    + * + *

    The validate method does not check whether any of the input from + * title, content are empty or not. + * This is because I have encountered a situation where even though the field is + * empty, the FCKEditor places a
    tag and so the validate method doesnt work. + * However, the validate method checks the length of the file that has been uploaded, + * the maximum filesize that can be uploaded is a property that is in the UploadFileUtil.

    + * + */ +public class NbAuthoringForm extends ActionForm { + + private static final long serialVersionUID = -8425012664714570196L; + + static Logger logger = Logger.getLogger(NbAuthoringForm.class.getName()); + + private String title; + private String basicContent; + + private String method; + private String toolContentID; + private String contentFolderID; + private String defineLater; + + private boolean allowComments; + private boolean commentsLikeAndDislike; + private boolean reflectOnActivity; + private String reflectInstructions; + + private String currentTab; + + /** + * @return Returns the defineLater. + */ + public String getDefineLater() { + return defineLater; + } + + /** + * @param defineLater + * The defineLater to set. + */ + public void setDefineLater(String defineLater) { + this.defineLater = defineLater; + } + + public boolean isAllowComments() { + return allowComments; + } + + public void setAllowComments(boolean allowComments) { + this.allowComments = allowComments; + } + + public boolean isCommentsLikeAndDislike() { + return commentsLikeAndDislike; + } + + public void setCommentsLikeAndDislike(boolean commentsLikeAndDislike) { + this.commentsLikeAndDislike = commentsLikeAndDislike; + } + + public boolean getReflectOnActivity() { + return reflectOnActivity; + } + + public void setReflectOnActivity(boolean reflectOnActivity) { + this.reflectOnActivity = reflectOnActivity; + } + + public String getReflectInstructions() { + return reflectInstructions; + } + + public void setReflectInstructions(String reflectInstructions) { + this.reflectInstructions = reflectInstructions; + } + + /** + * @return Returns the content. + */ + public String getBasicContent() { + return basicContent; + } + + /** + * @param basicContent + * The content to set. + */ + public void setBasicContent(String basicContent) { + this.basicContent = basicContent; + } + + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + + /** + * @param title + * The title to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return Returns the method. + */ + public String getMethod() { + return method; + } + + /** + * @param method + * The method to set. + */ + public void setMethod(String method) { + this.method = method; + } + + /** + * @return Returns the toolContentID. + */ + public String getToolContentID() { + return toolContentID; + } + + /** + * @param toolContentID + * The toolContentID to set. + */ + public void setToolContentID(String toolContentID) { + this.toolContentID = toolContentID; + } + + /** + * + * @return Returns the contentFolderID + */ + public String getContentFolderID() { + return contentFolderID; + } + + /** + * + * @param contentFolderID + * The contentFolderID is set + */ + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + @Override + public void reset(ActionMapping mapping, HttpServletRequest request) { + // this.content = null; + //this.title = null; + this.method = null; + this.defineLater = null; + } + + /** + * This method is to prepopulate the form with values from a noticeboard content + * object. Used in AuthoringStarterAction + * + * @param nbContent + */ + public void populateFormWithNbContentValues(NoticeboardContent nbContent) { + setTitle(nbContent.getTitle()); + setBasicContent(nbContent.getContent()); + setAllowComments(nbContent.isAllowComments()); + setCommentsLikeAndDislike(nbContent.isCommentsLikeAndDislike()); + setReflectOnActivity(nbContent.getReflectOnActivity()); + setReflectInstructions(nbContent.getReflectInstructions()); + } + + public void copyValuesIntoNbContent(NoticeboardContent nbContent) { + nbContent.setTitle(getTitle()); + nbContent.setContent(getBasicContent()); + nbContent.setAllowComments(isAllowComments()); + nbContent.setCommentsLikeAndDislike(isCommentsLikeAndDislike()); + nbContent.setReflectOnActivity(getReflectOnActivity()); + nbContent.setReflectInstructions(getReflectInstructions()); + nbContent.setDateUpdated(new Date(System.currentTimeMillis())); + } + + public String getCurrentTab() { + return currentTab; + } + + public void setCurrentTab(String currentTab) { + this.currentTab = currentTab; + } + +} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbLearnerForm.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbLearnerForm.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbLearnerForm.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,167 @@ +/**************************************************************** + * 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.noticeboard.web.form; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; + +/** + * Creation Date: 19-05-05 + * + * + * + * + * + * + */ + +public class NbLearnerForm extends ActionForm { + + private static final long serialVersionUID = -669035956406254875L; + + static Logger logger = Logger.getLogger(NbLearnerForm.class.getName()); + + private String title; + + private String basicContent; + + private String toolSessionID; + + private String method; + + private String mode; + + private Boolean readOnly; + + private String reflectionText; + + /** + * @return Returns the toolSessionID. + */ + public String getToolSessionID() { + return toolSessionID; + } + + /** + * @param toolSessionID + * The toolSessionID to set. + */ + public void setToolSessionID(String toolSessionID) { + this.toolSessionID = toolSessionID; + } + + /** + * @return Returns the content. + */ + public String getBasicContent() { + return basicContent; + } + + /** + * @param basicContent + * The content to set. + */ + public void setBasicContent(String basicContent) { + this.basicContent = basicContent; + } + + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + + /** + * @param title + * The title to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * @return Returns the method. + */ + public String getMethod() { + return method; + } + + /** + * @param method + * The method to set. + */ + public void setMethod(String method) { + this.method = method; + } + + public void reset() { + this.basicContent = null; + this.title = null; + this.toolSessionID = null; + this.method = null; + this.mode = null; + + } + + public void copyValuesIntoForm(NoticeboardContent content, boolean readOnly, String mode) { + setTitle(content.getTitle()); + setBasicContent(content.getContent()); + setMode(mode); + setReadOnly(new Boolean(readOnly)); + } + + /** + * @return Returns the mode. + */ + public String getMode() { + return mode; + } + + /** + * @param mode + * The mode to set. + */ + public void setMode(String mode) { + this.mode = mode; + } + + public Boolean getReadOnly() { + return readOnly; + } + + public void setReadOnly(Boolean readOnly) { + this.readOnly = readOnly; + } + + public String getReflectionText() { + return reflectionText; + } + + public void setReflectionText(String reflectionText) { + this.reflectionText = reflectionText; + } +} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbMonitoringForm.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbMonitoringForm.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbMonitoringForm.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,140 @@ +/**************************************************************** + * 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.noticeboard.web.form; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; + +/** + * @author mtruong + */ +public class NbMonitoringForm extends ActionForm { + + private static final long serialVersionUID = 6958826482877304278L; + + static Logger logger = Logger.getLogger(NbMonitoringForm.class.getName()); + + private String toolContentID; + + private String method; + + private String currentTab; + + /* Only valid when form just set up by Java. Values are not returned from jsp page */ + private String title; + private String basicContent; + private Integer totalLearners; + private Map groupStatsMap; + private Map sessionIdMap; + + /** + * @return Returns the method. + */ + public String getMethod() { + return method; + } + + /** + * @param method + * The method to set. + */ + public void setMethod(String method) { + this.method = method; + } + + /** + * @return Returns the toolContentId. + */ + public String getToolContentID() { + return toolContentID; + } + + /** + * @param toolContentId + * The toolContentId to set. + */ + public void setToolContentID(String toolContentId) { + this.toolContentID = toolContentId; + } + + @Override + public void reset(ActionMapping mapping, HttpServletRequest request) { + this.method = null; + + } + + public String getCurrentTab() { + return currentTab; + } + + public void setCurrentTab(String currentTab) { + this.currentTab = currentTab; + } + + public String getBasicContent() { + return basicContent; + } + + public String getTitle() { + return title; + } + + public void setBasicContent(String basicContent) { + this.basicContent = basicContent; + } + + public void setTitle(String title) { + this.title = title; + } + + public Map getGroupStatsMap() { + return groupStatsMap; + } + + public void setGroupStatsMap(Map groupStatsMap) { + this.groupStatsMap = groupStatsMap; + } + + public Integer getTotalLearners() { + return totalLearners; + } + + public void setTotalLearners(Integer totalLearners) { + this.totalLearners = totalLearners; + } + + public Map getSessionIdMap() { + return sessionIdMap; + } + + public void setSessionIdMap(Map sessionIdMap) { + this.sessionIdMap = sessionIdMap; + } +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbPedagogicalPlannerForm.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbPedagogicalPlannerForm.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/form/NbPedagogicalPlannerForm.java (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -0,0 +1,60 @@ +/**************************************************************** + * 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.noticeboard.web.form; + +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; + +/** + * + * + */ +public class NbPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { + private String basicContent; + private String contentFolderID; + + public String getContentFolderID() { + return contentFolderID; + } + + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + public String getBasicContent() { + return basicContent; + } + + public void setBasicContent(String instructions) { + basicContent = instructions; + } + + public void fillForm(NoticeboardContent noticeboard) { + if (noticeboard != null) { + String content = noticeboard.getContent(); + setBasicContent(content); + setToolContentID(noticeboard.getNbContentId()); + } + } +} \ No newline at end of file Index: lams_tool_nb/web/WEB-INF/struts-config.xml =================================================================== diff -u -r58448aa728e808e025d15546ea5375e6db321ff3 -r983160690fed1d94b51c2ea9206c58093a29040d --- lams_tool_nb/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 58448aa728e808e025d15546ea5375e6db321ff3) +++ lams_tool_nb/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 983160690fed1d94b51c2ea9206c58093a29040d) @@ -15,19 +15,19 @@