Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerController.java =================================================================== diff -u -rebd388504924fe0a06bbf20a06fe0032abbf8d15 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerController.java (.../NbLearnerController.java) (revision ebd388504924fe0a06bbf20a06fe0032abbf8d15) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerController.java (.../NbLearnerController.java) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -1,210 +1,210 @@ -/**************************************************************** - * 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.controller; - -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.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.MessageService; -import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.web.session.SessionManager; -import org.lamsfoundation.lams.web.util.AttributeNames; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.context.WebApplicationContext; - -/** - * 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. - * - * - * - * - * - * - * - * - */ -@Controller -@RequestMapping("/learner") -public class NbLearnerController implements NoticeboardConstants { - - static Logger logger = Logger.getLogger(NbLearnerController.class.getName()); - - @Autowired - @Qualifier("nbService") - private INoticeboardService nbService; - - @Autowired - @Qualifier("nbMessageService") - private MessageService messageService; - - @Autowired - private WebApplicationContext applicationContext; - - /** 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) { - String error = messageService.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. - */ - @RequestMapping("/finish") - public String finish(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request, - HttpServletResponse response) - throws NbApplicationException, ToolException, DataMissingException, ServletException, IOException { - - Long userID = getUserID(request); - - Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.getToolSessionID()); - if (toolSessionID == null) { - String error = "Unable to continue. The parameters tool session id is missing"; - logger.error(error); - throw new NbApplicationException(error); - } - - ToolSessionManager sessionMgrService = NoticeboardServiceProxy - .getNbSessionManager(applicationContext.getServletContext()); - - ToolAccessMode mode = WebUtil.getToolAccessMode(nbLearnerForm.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(), nbLearnerForm.getReflectionText()); - } else { - // update existing entry - entry.setEntry(nbLearnerForm.getReflectionText()); - entry.setLastModified(new Date()); - nbService.updateEntry(entry); - } - } - - String nextActivityUrl; - try { - nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, getUserID(request)); - } catch (DataMissingException e) { - logger.error(e); - throw new ServletException(e); - } catch (ToolException e) { - logger.error(e); - throw new ServletException(e); - } - - response.sendRedirect(nextActivityUrl); - - return null; - - } - request.setAttribute(NoticeboardConstants.READ_ONLY_MODE, "true"); - - return "learnerContent"; - - } - - /** - * Indicates that the user has finished viewing the noticeboard, and will be - * passed onto the Notebook reflection screen. - */ - @RequestMapping("/reflect") - public String reflect(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request) { - - Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.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()); - request.setAttribute("anonymous", nbContent.isAllowAnonymous()); - - // 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, - applicationContext.getServletContext()); - - return "reflect"; - } -} \ No newline at end of file +///**************************************************************** +// * 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.controller; +// +//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.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.MessageService; +//import org.lamsfoundation.lams.util.WebUtil; +//import org.lamsfoundation.lams.web.session.SessionManager; +//import org.lamsfoundation.lams.web.util.AttributeNames; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.beans.factory.annotation.Qualifier; +//import org.springframework.stereotype.Controller; +//import org.springframework.web.bind.annotation.ModelAttribute; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.context.WebApplicationContext; +// +///** +// * 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. +// * +// * +// * +// * +// * +// * +// * +// * +// */ +//@Controller +//@RequestMapping("/learner") +//public class NbLearnerController implements NoticeboardConstants { +// +// static Logger logger = Logger.getLogger(NbLearnerController.class.getName()); +// +// @Autowired +// @Qualifier("nbService") +// private INoticeboardService nbService; +// +// @Autowired +// @Qualifier("nbMessageService") +// private MessageService messageService; +// +// @Autowired +// private WebApplicationContext applicationContext; +// +// /** 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) { +// String error = messageService.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. +// * +// * @throws ServletException +// * @throws IOException +// */ +// public String finish(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request, +// HttpServletResponse response) throws ServletException, IOException { +// +// Long userID = getUserID(request); +// +// Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.getToolSessionID()); +// if (toolSessionID == null) { +// String error = "Unable to continue. The parameters tool session id is missing"; +// logger.error(error); +// throw new NbApplicationException(error); +// } +// +// ToolSessionManager sessionMgrService = NoticeboardServiceProxy +// .getNbSessionManager(applicationContext.getServletContext()); +// +// ToolAccessMode mode = WebUtil.getToolAccessMode(nbLearnerForm.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(), nbLearnerForm.getReflectionText()); +// } else { +// // update existing entry +// entry.setEntry(nbLearnerForm.getReflectionText()); +// entry.setLastModified(new Date()); +// nbService.updateEntry(entry); +// } +// } +// +// String nextActivityUrl; +// try { +// nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, getUserID(request)); +// } catch (DataMissingException e) { +// logger.error(e); +// throw new ServletException(e); +// } catch (ToolException e) { +// logger.error(e); +// throw new ServletException(e); +// } +// +// response.sendRedirect(nextActivityUrl); +// +// return null; +// +// } +// request.setAttribute(NoticeboardConstants.READ_ONLY_MODE, "true"); +// +// return "learnerContent"; +// +// } +// +// /** +// * Indicates that the user has finished viewing the noticeboard, and will be +// * passed onto the Notebook reflection screen. +// */ +// public String reflect(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request) { +// +// Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.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()); +// request.setAttribute("anonymous", nbContent.isAllowAnonymous()); +// +// // 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, +// applicationContext.getServletContext()); +// +// return "reflect"; +// } +//} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerStarterController.java =================================================================== diff -u -rebd388504924fe0a06bbf20a06fe0032abbf8d15 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerStarterController.java (.../NbLearnerStarterController.java) (revision ebd388504924fe0a06bbf20a06fe0032abbf8d15) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbLearnerStarterController.java (.../NbLearnerStarterController.java) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -23,8 +23,12 @@ package org.lamsfoundation.lams.tool.noticeboard.web.controller; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; import java.util.List; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -34,10 +38,15 @@ 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; @@ -115,21 +124,24 @@ return WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); } - public String unspecified(@ModelAttribute NbLearnerForm NbLearnerForm, List messages, - HttpServletRequest request, HttpServletResponse response) { + public String unspecified(@ModelAttribute NbLearnerForm NbLearnerForm, HttpServletRequest request, + HttpServletResponse response) { - return learner(NbLearnerForm, messages, request, response); + return learner(NbLearnerForm, request, response); } @RequestMapping("/learner") - public String learner(@ModelAttribute NbLearnerForm NbLearnerForm, List messages, - HttpServletRequest request, HttpServletResponse response) { + public String learner(@ModelAttribute NbLearnerForm NbLearnerForm, HttpServletRequest request, + HttpServletResponse response) { NoticeboardContent nbContent = null; NoticeboardUser nbUser = null; - Long toolSessionID = NbWebUtil.convertToLong(NbLearnerForm.getToolSessionID()); +// Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID) + Long toolSessionID = Long.valueOf(NbLearnerForm.getToolSessionID()); + List messages = new ArrayList<>(); + if (toolSessionID == null) { String error = "Unable to continue. The parameters tool session id is missing"; messages.add(error); @@ -199,7 +211,7 @@ * 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, messages)) { + if (displayMessageToUser(nbContent)) { request.setAttribute("messages", messages); // return ("message"); } @@ -208,17 +220,15 @@ } - @RequestMapping("/teacher") - public String teacher(@ModelAttribute NbLearnerForm NbLearnerForm, List messages, - HttpServletRequest request, HttpServletResponse response) throws NbApplicationException { - return learner(NbLearnerForm, messages, request, response); + public String teacher(@ModelAttribute NbLearnerForm NbLearnerForm, HttpServletRequest request, + HttpServletResponse response) throws NbApplicationException { + return learner(NbLearnerForm, request, response); } - @RequestMapping("/author") - public String author(@ModelAttribute NbLearnerForm NbLearnerForm, List messages, HttpServletRequest request, + public String author(@ModelAttribute NbLearnerForm NbLearnerForm, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException { - return learner(NbLearnerForm, messages, request, response); + return learner(NbLearnerForm, request, response); } @@ -262,15 +272,10 @@ * 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, List messages) { + private boolean displayMessageToUser(NoticeboardContent content) { boolean isDefineLaterSet = isFlagSet(content, NoticeboardConstants.FLAG_DEFINE_LATER); + List messages = new ArrayList<>(); if (isDefineLaterSet) { if (isDefineLaterSet) { messages.add("message.defineLaterSet"); @@ -281,4 +286,100 @@ } } + /** + * Indicates that the user has finished viewing the noticeboard. + * The session is set to complete and leaveToolSession is called. + */ + public String finish(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + + Long userID = getUserID(request); + + Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.getToolSessionID()); + if (toolSessionID == null) { + String error = "Unable to continue. The parameters tool session id is missing"; + logger.error(error); + throw new NbApplicationException(error); + } + + ToolSessionManager sessionMgrService = NoticeboardServiceProxy + .getNbSessionManager(applicationContext.getServletContext()); + + ToolAccessMode mode = WebUtil.getToolAccessMode(nbLearnerForm.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(), nbLearnerForm.getReflectionText()); + } else { + // update existing entry + entry.setEntry(nbLearnerForm.getReflectionText()); + entry.setLastModified(new Date()); + nbService.updateEntry(entry); + } + } + + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, getUserID(request)); + } catch (DataMissingException e) { + logger.error(e); + throw new ServletException(e); + } catch (ToolException e) { + logger.error(e); + throw new ServletException(e); + } + + response.sendRedirect(nextActivityUrl); + + return null; + + } + request.setAttribute(NoticeboardConstants.READ_ONLY_MODE, "true"); + + return "learnerContent"; + + } + + /** + * Indicates that the user has finished viewing the noticeboard, and will be + * passed onto the Notebook reflection screen. + */ + public String reflect(@ModelAttribute NbLearnerForm nbLearnerForm, HttpServletRequest request) { + + Long toolSessionID = NbWebUtil.convertToLong(nbLearnerForm.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()); + request.setAttribute("anonymous", nbContent.isAllowAnonymous()); + + // 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, + applicationContext.getServletContext()); + + return "reflect"; + } + } \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbMonitoringController.java =================================================================== diff -u -rebd388504924fe0a06bbf20a06fe0032abbf8d15 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbMonitoringController.java (.../NbMonitoringController.java) (revision ebd388504924fe0a06bbf20a06fe0032abbf8d15) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/controller/NbMonitoringController.java (.../NbMonitoringController.java) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -69,11 +69,11 @@ public final static String FORM = "NbMonitoringForm"; @RequestMapping("/monitoring") - public String unspecified(@ModelAttribute NbMonitoringForm nbMonitoringForm, List messages, - HttpServletRequest request) { + public String unspecified(@ModelAttribute NbMonitoringForm nbMonitoringForm, HttpServletRequest request) { Long toolContentId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.TOOL_CONTENT_ID)); String contentFolderID = WebUtil.readStrParam(request, NoticeboardConstants.CONTENT_FOLDER_ID); + List messages = new ArrayList<>(); if (toolContentId == null) { String error = "Unable to continue. Tool content id missing"; messages.add(error); @@ -138,8 +138,7 @@ return "/monitoring/monitoring"; } - @RequestMapping("/reflection") - public String viewReflection(HttpServletRequest request) { + public String viewReflection(@ModelAttribute NbMonitoringForm nbMonitoringForm, HttpServletRequest request) { Long userId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.USER_ID)); Long toolSessionId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.TOOL_SESSION_ID)); NoticeboardUser nbUser = nbService.retrieveNoticeboardUser(userId, toolSessionId); @@ -153,8 +152,7 @@ return "/monitoring/reflection"; } - @RequestMapping("/comments") - public String viewComments(HttpServletRequest request) { + public String viewComments(@ModelAttribute NbMonitoringForm nbMonitoringForm, HttpServletRequest request) { Long toolSessionID = WebUtil.readLongParam(request, NoticeboardConstants.TOOL_SESSION_ID, false); NoticeboardContent nbContent = nbService.retrieveNoticeboardBySessionID(toolSessionID); Index: lams_tool_nb/web/authoring/authoring.jsp =================================================================== diff -u -rebd388504924fe0a06bbf20a06fe0032abbf8d15 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/authoring/authoring.jsp (.../authoring.jsp) (revision ebd388504924fe0a06bbf20a06fe0032abbf8d15) +++ lams_tool_nb/web/authoring/authoring.jsp (.../authoring.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -62,7 +62,6 @@ - Index: lams_tool_nb/web/learnerContent.jsp =================================================================== diff -u -re998cf2de8c4714022559cb5f67e61b677a2dd28 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/learnerContent.jsp (.../learnerContent.jsp) (revision e998cf2de8c4714022559cb5f67e61b677a2dd28) +++ lams_tool_nb/web/learnerContent.jsp (.../learnerContent.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -23,18 +23,18 @@ } } function submitForm(methodName) { - var f = document.getElementById('learnerForm'); + var f = document.getElementById('nbLearnerForm'); f.action += "?method=" + methodName; f.submit(); } - +
- +
- + @@ -57,12 +57,12 @@
-
- + Index: lams_tool_nb/web/monitoring/m_EditActivity.jsp =================================================================== diff -u -re998cf2de8c4714022559cb5f67e61b677a2dd28 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/monitoring/m_EditActivity.jsp (.../m_EditActivity.jsp) (revision e998cf2de8c4714022559cb5f67e61b677a2dd28) +++ lams_tool_nb/web/monitoring/m_EditActivity.jsp (.../m_EditActivity.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -2,7 +2,7 @@
- + @@ -14,15 +14,15 @@ - + - + Index: lams_tool_nb/web/monitoring/m_Statistics.jsp =================================================================== diff -u -re998cf2de8c4714022559cb5f67e61b677a2dd28 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/monitoring/m_Statistics.jsp (.../m_Statistics.jsp) (revision e998cf2de8c4714022559cb5f67e61b677a2dd28) +++ lams_tool_nb/web/monitoring/m_Statistics.jsp (.../m_Statistics.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -8,14 +8,14 @@ - + @@ -27,14 +27,14 @@
- +
- + - + - + Index: lams_tool_nb/web/monitoring/m_Summary.jsp =================================================================== diff -u -re998cf2de8c4714022559cb5f67e61b677a2dd28 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/monitoring/m_Summary.jsp (.../m_Summary.jsp) (revision e998cf2de8c4714022559cb5f67e61b677a2dd28) +++ lams_tool_nb/web/monitoring/m_Summary.jsp (.../m_Summary.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -9,8 +9,8 @@
-

-
+

+

Index: lams_tool_nb/web/reflect.jsp =================================================================== diff -u -re998cf2de8c4714022559cb5f67e61b677a2dd28 -r692cfbd845483c893176e6a4eb78d789399977ba --- lams_tool_nb/web/reflect.jsp (.../reflect.jsp) (revision e998cf2de8c4714022559cb5f67e61b677a2dd28) +++ lams_tool_nb/web/reflect.jsp (.../reflect.jsp) (revision 692cfbd845483c893176e6a4eb78d789399977ba) @@ -20,7 +20,7 @@ document.getElementById("finishButton").disabled = true; } function submitForm(methodName) { - var f = document.getElementById('learnerForm'); + var f = document.getElementById('nbLearnerForm'); f.submit(); }