Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties =================================================================== diff -u -r86b5cdd388fcafe54ad59646071e12166c3757a1 -r2933e1ad39938f2c65040e8bf0199c5161e85c1f --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties (.../ApplicationResources.properties) (revision 86b5cdd388fcafe54ad59646071e12166c3757a1) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2933e1ad39938f2c65040e8bf0199c5161e85c1f) @@ -17,24 +17,36 @@ instructions.uploadOnlineInstr=Upload Online Instructions: instructions.uploadOfflineInstr=Upload Offline Instructions: -#buttons -button.cancel=Cancel -button.ok=OK -button.done=Done -button.finish=Finish -button.next=Next - -#Exception Messages -error.missingParam={0} missing. Unable to continue. - -#Messages displayed to user +# ========== Learner Page ========== message.defineLaterSet=Please wait for the teacher to complete the contents of this activity message.runOfflineSet=This activity is not being done on the computer. Please see your instructor for details #Messages displayed to Author message.author.defineLaterSet1=This feature is not available in the preview mode. message.author.defineLaterSet2=The teacher will set the content of this noticeboard once the lesson is in progress. Please click on the "NEXT" button below to continue +# ========== Monitoring Page ========== +button.summary=Summary +button.editActivity=Edit Activity +button.statistics=Statistics +button.edit=Edit -#Error Messages +titleHeading.summary=Summary +titleHeading.instructions=Instructions +titleHeading.statistics=Statistics +titleHeading.editActivity=Edit Activity + +message.contentInUseSet=The modification of content is not allowed since one or more students has attempted the activity. +message.summary=There is no summary available for this tool. + +# ========== Buttons ========== +button.cancel=Cancel +button.ok=OK +button.done=Done +button.finish=Finish +button.next=Next + + +# ========== Error/Exception Messages ========== +error.missingParam={0} missing. Unable to continue. error.exception.NbApplication=An internal error has occured with the Noticeboard Tool. If reporting this error, please report:
{0} \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringAction.java (revision 2933e1ad39938f2c65040e8bf0199c5161e85c1f) @@ -0,0 +1,197 @@ +/* + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + *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; either version 2 of the License, or + *(at your option) any later version. + * + *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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt + */ + +/* + * Created on Jul 14, 2005 + * + */ +package org.lamsfoundation.lams.tool.noticeboard.web; + +import java.util.HashMap; +import java.util.Map; + +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.actions.LookupDispatchAction; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.util.NbMonitoringUtil; +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; + +/** + * @author mtruong + * + */ + +/** + * Creation Date: 14-07-05 + * + * ----------------XDoclet Tags-------------------- + * + * @struts:action path="/tool/nb/monitoring" name="NbMonitoringForm" scope="session" type="org.lamsfoundation.lams.tool.noticeboard.web.NbMonitoringAction" + * input=".monitoringContent" validate="false" parameter="method" + * @struts:action-forward name="monitorPage" path=".monitoringContent" + * ----------------XDoclet Tags-------------------- + */ +public class NbMonitoringAction extends LookupDispatchAction { + + static Logger logger = Logger.getLogger(NbMonitoringAction.class.getName()); + + protected Map getKeyMethodMap() + { + Map map = new HashMap(); + map.put(NoticeboardConstants.BUTTON_EDIT_ACTIVITY, "editActivity"); + map.put(NoticeboardConstants.BUTTON_INSTRUCTIONS, "instructions"); + map.put(NoticeboardConstants.BUTTON_STATISTICS, "statistics"); + map.put(NoticeboardConstants.BUTTON_SUMMARY, "summary"); + return map; + } + + /** + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward editActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + NbMonitoringForm monitorForm = (NbMonitoringForm)form; + + Long toolContentId = (Long)request.getSession().getAttribute(NoticeboardConstants.TOOL_CONTENT_ID_INMONITORMODE); + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + NoticeboardContent content = nbService.retrieveNoticeboard(toolContentId); + + if (isContentEditable(content)) + { + request.getSession().removeAttribute(NoticeboardConstants.CONTENT_IN_USE); + + request.getSession().setAttribute(NoticeboardConstants.TITLE, content.getTitle()); + request.getSession().setAttribute(NoticeboardConstants.CONTENT, content.getContent()); + } + else + { + request.getSession().setAttribute(NoticeboardConstants.CONTENT_IN_USE, "true"); + } + //copyValuesIntoSession(request, content); + + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } + + /** + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward instructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + NbMonitoringForm monitorForm = (NbMonitoringForm)form; + // NbMonitoringUtil.cleanSession(request); + Long toolContentId = (Long)request.getSession().getAttribute(NoticeboardConstants.TOOL_CONTENT_ID_INMONITORMODE); + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + NoticeboardContent content = nbService.retrieveNoticeboard(toolContentId); + //copyValuesIntoSession(request, content); + + request.getSession().setAttribute(NoticeboardConstants.ONLINE_INSTRUCTIONS, content.getOnlineInstructions()); + request.getSession().setAttribute(NoticeboardConstants.OFFLINE_INSTRUCTIONS, content.getOfflineInstructions()); + + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } + + /** + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward summary(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } + + /** + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward statistics(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } + + /** + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private void copyValuesIntoSession(HttpServletRequest request, NoticeboardContent content) + { + request.getSession().setAttribute(NoticeboardConstants.TITLE, content.getTitle()); + request.getSession().setAttribute(NoticeboardConstants.CONTENT, content.getContent()); + request.getSession().setAttribute(NoticeboardConstants.ONLINE_INSTRUCTIONS, content.getOnlineInstructions()); + request.getSession().setAttribute(NoticeboardConstants.OFFLINE_INSTRUCTIONS, content.getOfflineInstructions()); + } + + /** + *

This method checks the two tool content flags, defineLater and contentInUse + * to determine whether the tool content is modifiable or not. Returns true is content is + * modifiable and false otherwise + *
Tool content is modifiable if: + *

  • defineLater is set to true
  • + *
  • defineLater is set to false and contentInUse is set to false
  • + *
    Tool content is not modifiable if: + *
  • contentInUse is set to true
  • + * @param content The instance of NoticeboardContent to check + * @return true if content is modifiable and false otherwise + * @throws NbApplicationException + */ + private boolean isContentEditable(NoticeboardContent content) throws NbApplicationException + { + if ( (content.isDefineLater() == true) && (content.isContentInUse()==true) ) + { + throw new NbApplicationException("An exception has occurred: There is a bug in this tool, conflicting flags are set"); + //return false; + } + else if ( (content.isDefineLater() == true) && (content.isContentInUse() == false)) + return true; + else if ( (content.isDefineLater() == false) && (content.isContentInUse() == false)) + return true; + else // (content.isContentInUse()==true && content.isDefineLater() == false) + return false; + + } + +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringForm.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringForm.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringForm.java (revision 2933e1ad39938f2c65040e8bf0199c5161e85c1f) @@ -0,0 +1,87 @@ +/* + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + *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; either version 2 of the License, or + *(at your option) any later version. + * + *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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt + */ + +/* + * Created on Jul 14, 2005 + * + */ +package org.lamsfoundation.lams.tool.noticeboard.web; + + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; + +/** + * @author mtruong + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ + +/** + * Creation Date: 12-07-05 + * + * ----------------XDoclet Tags-------------------- + * + * @struts:form name="NbMonitoringForm" type="org.lamsfoundation.lams.tool.noticeboard.web.NbMonitoringForm" + * + * ----------------XDoclet Tags-------------------- + */ +public class NbMonitoringForm extends ActionForm { + + static Logger logger = Logger.getLogger(NbMonitoringForm.class.getName()); + + private Long toolContentId; + + private String method; + + /** + * @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 Long getToolContentId() { + return toolContentId; + } + /** + * @param toolContentId The toolContentId to set. + */ + public void setToolContentId(Long toolContentId) { + this.toolContentId = toolContentId; + } + + public void reset() + { + this.method = null; + this.toolContentId = null; + + } +} Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringStarterAction.java =================================================================== diff -u --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringStarterAction.java (revision 0) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbMonitoringStarterAction.java (revision 2933e1ad39938f2c65040e8bf0199c5161e85c1f) @@ -0,0 +1,78 @@ +/* + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + *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; either version 2 of the License, or + *(at your option) any later version. + * + *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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt + */ + +/* + * Created on Jul 14, 2005 + */ +package org.lamsfoundation.lams.tool.noticeboard.web; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.web.NbMonitoringForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.tool.noticeboard.util.NbMonitoringUtil; + +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; + +/** + * @author mtruong + */ + +/** + * Creation Date: 14-07-05 + * + * ----------------XDoclet Tags-------------------- + * + * @struts:action path="/tool/nb/starter/monitor" name="NbMonitoringForm" scope="session" type="org.lamsfoundation.lams.tool.noticeboard.web.NbMonitoringStarterAction" + * input=".monitoringStarter" validate="false" + * @struts:action-forward name="monitorPage" path=".monitoringContent" + * ----------------XDoclet Tags-------------------- + */ + +public class NbMonitoringStarterAction extends Action { + + static Logger logger = Logger.getLogger(NbMonitoringStarterAction.class.getName()); + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException { + + //get the list of tool sessionId's and put them in session + NbMonitoringForm monitorForm = (NbMonitoringForm)form; + + INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); + monitorForm.reset(); + NbMonitoringUtil.cleanSession(request); + Long toolContentId = new Long(WebUtil.readLongParam(request, NoticeboardConstants.TOOL_CONTENT_ID)); + request.getSession().setAttribute(NoticeboardConstants.TOOL_CONTENT_ID_INMONITORMODE, toolContentId); + + //get the list of tool session ids + + return mapping.findForward(NoticeboardConstants.MONITOR_PAGE); + } +} \ No newline at end of file