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 + * thetoolContentId
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:
+ *
+ * + * @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(); + ListActionForm 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.