Fisheye: Tag 6a6275134085f309616b1514c4315beaa9988690 refers to a dead (removed) revision in file `lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/AdminAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6a6275134085f309616b1514c4315beaa9988690 refers to a dead (removed) revision in file `lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6a6275134085f309616b1514c4315beaa9988690 refers to a dead (removed) revision in file `lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6a6275134085f309616b1514c4315beaa9988690 refers to a dead (removed) revision in file `lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/LearningAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 6a6275134085f309616b1514c4315beaa9988690 refers to a dead (removed) revision in file `lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AdminController.java =================================================================== diff -u --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AdminController.java (revision 0) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AdminController.java (revision 6a6275134085f309616b1514c4315beaa9988690) @@ -0,0 +1,104 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.zoom.web.controller; + +import java.util.LinkedList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.actions.DispatchAction; +import org.lamsfoundation.lams.tool.zoom.model.ZoomApi; +import org.lamsfoundation.lams.tool.zoom.service.IZoomService; +import org.lamsfoundation.lams.tool.zoom.service.ZoomServiceProxy; +import org.lamsfoundation.lams.util.JsonUtil; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class AdminController extends DispatchAction { + + private IZoomService zoomService; + + private static final Logger logger = Logger.getLogger(AdminController.class); + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + // set up zoomService + zoomService = ZoomServiceProxy.getZoomService(this.getServlet().getServletContext()); + return super.execute(mapping, form, request, response); + } + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + List apis = zoomService.getApis(); + ArrayNode apisJSON = JsonNodeFactory.instance.arrayNode(); + for (ZoomApi api : apis) { + apisJSON.add(api.toJSON()); + } + request.setAttribute("apis", apisJSON); + return mapping.findForward("success"); + } + + public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + String apisJSONString = request.getParameter("apisJSON"); + ArrayNode apisJSON = JsonUtil.readArray(apisJSONString); + List apis = new LinkedList(); + for (int index = 0; index < apisJSON.size(); index++) { + ObjectNode apiJSON = (ObjectNode) apisJSON.get(index); + ZoomApi api = new ZoomApi(apiJSON); + apis.add(api); + } + zoomService.saveApis(apis); + request.setAttribute("saveOK", true); + if (logger.isDebugEnabled()) { + logger.debug("Saved " + apis.size() + " Zoom APIs"); + } + + ActionErrors errors = new ActionErrors(); + apis = zoomService.getApis(); + for (ZoomApi api : apis) { + if (!zoomService.pingZoomApi(api.getUid())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.api.ping", api.getEmail())); + } + } + if (!errors.isEmpty()) { + this.addErrors(request, errors); + } + + return unspecified(mapping, form, request, response); + } +} \ No newline at end of file Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AuthoringController.java (revision 0) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/AuthoringController.java (revision 6a6275134085f309616b1514c4315beaa9988690) @@ -0,0 +1,220 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.zoom.web.controller; + +import java.lang.reflect.InvocationTargetException; +import java.util.Date; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.actions.DispatchAction; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.zoom.model.Zoom; +import org.lamsfoundation.lams.tool.zoom.service.IZoomService; +import org.lamsfoundation.lams.tool.zoom.service.ZoomServiceProxy; +import org.lamsfoundation.lams.tool.zoom.util.ZoomConstants; +import org.lamsfoundation.lams.tool.zoom.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.CommonConstants; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +public class AuthoringController extends DispatchAction { + + private IZoomService zoomService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // set up zoomService + zoomService = ZoomServiceProxy.getZoomService(this.getServlet().getServletContext()); + + return super.execute(mapping, form, request, response); + } + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + * toolContentID will be passed in. This will be used to retrieve content for this tool. + * + * @throws ServletException + * + */ + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws ServletException { + + // Extract toolContentID from parameters. + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + + // retrieving Zoom with given toolContentID + Zoom zoom = zoomService.getZoomByContentId(toolContentID); + if (zoom == null) { + zoom = zoomService.copyDefaultContent(toolContentID); + zoom.setCreateDate(new Date()); + zoomService.saveOrUpdateZoom(zoom); + } + + if (mode.isTeacher()) { + // Set the defineLater flag so that learners cannot use content + // while we are editing. This flag is released when updateContent is + // called. + zoom.setDefineLater(true); + zoomService.saveOrUpdateZoom(zoom); + + //audit log the teacher has started editing activity in monitor + zoomService.auditLogStartEditingActivityInMonitor(toolContentID); + } + + // Set up the authForm. + AuthoringForm authForm = (AuthoringForm) form; + copyProperties(authForm, zoom); + + // Set up sessionMap + SessionMap map = createSessionMap(zoom, mode, contentFolderID, toolContentID); + authForm.setSessionMapID(map.getSessionID()); + + // add the sessionMap to HTTPSession. + request.getSession().setAttribute(map.getSessionID(), map); + request.setAttribute(ZoomConstants.ATTR_SESSION_MAP, map); + + if (zoomService.getApis().isEmpty()) { + ActionErrors errors = new ActionErrors(); + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.api.none.configured")); + this.addErrors(request, errors); + } + + return mapping.findForward("success"); + } + + public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // get authForm and session map. + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + // get zoom content. + Zoom zoom = zoomService.getZoomByContentId((Long) map.get(ZoomConstants.KEY_TOOL_CONTENT_ID)); + + // update zoom content using form inputs + copyProperties(zoom, authForm); + + // set the update date + zoom.setUpdateDate(new Date()); + + // releasing defineLater flag so that learner can start using the tool. + zoom.setDefineLater(false); + zoomService.saveOrUpdateZoom(zoom); + + request.setAttribute(CommonConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // add the sessionMapID to form + authForm.setSessionMapID(map.getSessionID()); + + request.setAttribute(ZoomConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + /* ========== Private Methods */ + + /** + * Updates Zoom content using AuthoringForm inputs. + * + * @param authForm + * @param mode + * @return + */ + private void copyProperties(Zoom zoom, AuthoringForm authForm) { + zoom.setTitle(authForm.getTitle()); + zoom.setInstructions(authForm.getInstructions()); + zoom.setReflectOnActivity(authForm.isReflectOnActivity()); + zoom.setReflectInstructions(authForm.getReflectInstructions()); + zoom.setStartInMonitor(authForm.isStartInMonitor()); + Integer duration = authForm.getDuration(); + zoom.setDuration(duration != null && duration > 0 ? duration : null); + } + + /** + * Updates AuthoringForm using Zoom content. + * + * @param zoom + * @param authForm + * @return + * @throws ServletException + */ + private void copyProperties(AuthoringForm authForm, Zoom zoom) throws ServletException { + try { + BeanUtils.copyProperties(authForm, zoom); + } catch (IllegalAccessException e) { + throw new ServletException(e); + } catch (InvocationTargetException e) { + throw new ServletException(e); + } + } + + /** + * Updates SessionMap using Zoom content. + * + * @param zoom + * @param mode + */ + private SessionMap createSessionMap(Zoom zoom, ToolAccessMode mode, String contentFolderID, + Long toolContentID) { + + SessionMap map = new SessionMap(); + + map.put(ZoomConstants.KEY_MODE, mode); + map.put(ZoomConstants.KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(ZoomConstants.KEY_TOOL_CONTENT_ID, toolContentID); + + return map; + } + + /** + * Retrieve the SessionMap from the HttpSession. + * + * @param request + * @param authForm + * @return + */ + @SuppressWarnings("unchecked") + private SessionMap getSessionMap(HttpServletRequest request, AuthoringForm authForm) { + return (SessionMap) request.getSession().getAttribute(authForm.getSessionMapID()); + } +} Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/ClearSessionController.java (revision 6a6275134085f309616b1514c4315beaa9988690) @@ -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.zoom.web.controller; + +import javax.servlet.http.HttpSession; + +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.web.action.LamsAuthoringFinishAction; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + * + * + * + * + * + * @version $Revision$ + */ +public class ClearSessionController extends LamsAuthoringFinishAction { + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } + } + +} Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/LearningController.java =================================================================== diff -u --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/LearningController.java (revision 0) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/LearningController.java (revision 6a6275134085f309616b1514c4315beaa9988690) @@ -0,0 +1,251 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.zoom.web.controller; + +import java.io.IOException; +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.actions.DispatchAction; +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.zoom.dto.ContentDTO; +import org.lamsfoundation.lams.tool.zoom.dto.NotebookEntryDTO; +import org.lamsfoundation.lams.tool.zoom.dto.ZoomUserDTO; +import org.lamsfoundation.lams.tool.zoom.model.Zoom; +import org.lamsfoundation.lams.tool.zoom.model.ZoomSession; +import org.lamsfoundation.lams.tool.zoom.model.ZoomUser; +import org.lamsfoundation.lams.tool.zoom.service.IZoomService; +import org.lamsfoundation.lams.tool.zoom.service.ZoomServiceProxy; +import org.lamsfoundation.lams.tool.zoom.util.ZoomConstants; +import org.lamsfoundation.lams.tool.zoom.util.ZoomUtil; +import org.lamsfoundation.lams.tool.zoom.web.forms.LearningForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +public class LearningController extends DispatchAction { + + private static final Logger logger = Logger.getLogger(LearningController.class); + + private IZoomService zoomService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // set up zoomService + zoomService = ZoomServiceProxy.getZoomService(this.getServlet().getServletContext()); + + return super.execute(mapping, form, request, response); + } + + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + ZoomUser user = getCurrentUser(toolSessionID); + + if (user != null) { + + LearningForm learningForm = (LearningForm) form; + + if (user.getNotebookEntryUID() == null) { + user.setNotebookEntryUID(zoomService.createNotebookEntry(toolSessionID, + CoreNotebookConstants.NOTEBOOK_TOOL, ZoomConstants.TOOL_SIGNATURE, user.getUserId().intValue(), + learningForm.getEntryText())); + } else { + // update existing entry. + zoomService.updateNotebookEntry(user.getNotebookEntryUID(), learningForm.getEntryText()); + } + + user.setFinishedActivity(true); + zoomService.saveOrUpdateZoomUser(user); + } else { + logger.error("finishActivity(): couldn't find/create ZoomUser in toolSessionID: " + toolSessionID); + } + + ToolSessionManager sessionMgrService = ZoomServiceProxy.getZoomSessionManager(getServlet().getServletContext()); + + String nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, user.getUserId().longValue()); + response.sendRedirect(nextActivityUrl); + + return null; + } + + private ZoomUser getCurrentUser(Long toolSessionId) { + org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager + .getSession().getAttribute(AttributeNames.USER); + + // attempt to retrieve user using userId and toolSessionId + ZoomUser user = zoomService.getUserByUserIdAndSessionId(lamsUserDTO.getUserID(), toolSessionId); + + if (user == null) { + ZoomSession zoomSession = zoomService.getSessionBySessionId(toolSessionId); + user = zoomService.createZoomUser(lamsUserDTO, zoomSession); + } + + return user; + } + + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + LearningForm lrnForm = (LearningForm) form; + + // set the finished flag + ZoomUser user = getCurrentUser(lrnForm.getToolSessionID()); + ContentDTO contentDTO = new ContentDTO(user.getZoomSession().getZoom()); + + request.setAttribute(ZoomConstants.ATTR_CONTENT_DTO, contentDTO); + + NotebookEntry notebookEntry = zoomService.getNotebookEntry(user.getNotebookEntryUID()); + + if (notebookEntry != null) { + lrnForm.setEntryText(notebookEntry.getEntry()); + } + + WebUtil.putActivityPositionInRequestByToolSessionId(lrnForm.getToolSessionID(), request, + getServlet().getServletContext()); + + return mapping.findForward("notebook"); + + } + + public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + // save the reflection entry and call the notebook. + + LearningForm lrnForm = (LearningForm) form; + + ZoomUser user = getCurrentUser(lrnForm.getToolSessionID()); + Long toolSessionID = user.getZoomSession().getSessionId(); + Integer userID = user.getUserId().intValue(); + + // check for existing notebook entry + NotebookEntry entry = zoomService.getNotebookEntry(user.getNotebookEntryUID()); + + if (entry == null) { + // create new entry + Long entryUID = zoomService.createNotebookEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + ZoomConstants.TOOL_SIGNATURE, userID, lrnForm.getEntryText()); + user.setNotebookEntryUID(entryUID); + zoomService.saveOrUpdateZoomUser(user); + } else { + // update existing entry + entry.setEntry(lrnForm.getEntryText()); + entry.setLastModified(new Date()); + zoomService.updateNotebookEntry(entry); + } + + return finishActivity(mapping, form, request, response); + } + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + LearningForm learningForm = (LearningForm) form; + + // 'toolSessionID' and 'mode' parameters are expected to be present. + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, false); + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + // Retrieve the session and content. + ZoomSession session = zoomService.getSessionBySessionId(toolSessionID); + if (session == null) { + } + + Zoom zoom = session.getZoom(); + + // set mode, toolSessionID and ZoomDTO + request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + learningForm.setToolSessionID(toolSessionID); + + ContentDTO contentDTO = new ContentDTO(); + contentDTO.setTitle(zoom.getTitle()); + contentDTO.setInstructions(zoom.getInstructions()); + contentDTO.setReflectOnActivity(zoom.isReflectOnActivity()); + contentDTO.setReflectInstructions(zoom.getReflectInstructions()); + + request.setAttribute(ZoomConstants.ATTR_CONTENT_DTO, contentDTO); + + // Set the content in use flag. + if (!zoom.isContentInUse()) { + zoom.setContentInUse(true); + zoomService.saveOrUpdateZoom(zoom); + } + + WebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, getServlet().getServletContext()); + + ZoomUser user; + if (mode.equals(ToolAccessMode.TEACHER)) { + Integer userID = WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false); + user = zoomService.getUserByUserIdAndSessionId(userID, toolSessionID); + } else { + user = getCurrentUser(toolSessionID); + } + + // get any existing notebook entries and create userDTO + NotebookEntry entry = zoomService.getNotebookEntry(user.getNotebookEntryUID()); + ZoomUserDTO userDTO = new ZoomUserDTO(user); + if (entry != null) { + userDTO.setNotebookEntryDTO(new NotebookEntryDTO(entry)); + } + request.setAttribute(ZoomConstants.ATTR_USER_DTO, userDTO); + // set toolSessionID in request + request.setAttribute(ZoomConstants.ATTR_TOOL_SESSION_ID, session.getSessionId()); + + if (mode.isAuthor() || !zoom.isStartInMonitor()) { + // start a meeting just like a monitor would + ActionErrors errors = ZoomUtil.startMeeting(zoomService, zoom, request); + if (!errors.isEmpty()) { + this.addErrors(request, errors); + } + } + if (!mode.isAuthor()) { + // register a learner for the meeting + String meetingURL = user.getMeetingJoinUrl(); + if (meetingURL == null && zoom.getMeetingId() != null) { + meetingURL = zoomService.registerUser(zoom.getUid(), user.getUid(), session.getSessionName()); + } + // if start in monitor is not set, this overwrites the URL set in ZoomUtil.startMeeting() above + request.setAttribute(ZoomConstants.ATTR_MEETING_URL, meetingURL); + } + + return mapping.findForward("zoom"); + } +} Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/MonitoringController.java (revision 0) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/controller/MonitoringController.java (revision 6a6275134085f309616b1514c4315beaa9988690) @@ -0,0 +1,122 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.zoom.web.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.actions.DispatchAction; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.zoom.dto.ContentDTO; +import org.lamsfoundation.lams.tool.zoom.dto.NotebookEntryDTO;//import org.lamsfoundation.lams.tool.zoom.dto.UserDTO; +import org.lamsfoundation.lams.tool.zoom.dto.ZoomUserDTO; +import org.lamsfoundation.lams.tool.zoom.model.Zoom; +import org.lamsfoundation.lams.tool.zoom.model.ZoomUser; +import org.lamsfoundation.lams.tool.zoom.service.IZoomService; +import org.lamsfoundation.lams.tool.zoom.service.ZoomServiceProxy; +import org.lamsfoundation.lams.tool.zoom.util.ZoomConstants; +import org.lamsfoundation.lams.tool.zoom.util.ZoomUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; + +public class MonitoringController extends DispatchAction { + + private static final Logger logger = Logger.getLogger(MonitoringController.class); + + private IZoomService zoomService; + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // set up zoomService + zoomService = ZoomServiceProxy.getZoomService(this.getServlet().getServletContext()); + + return super.execute(mapping, form, request, response); + } + + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + Zoom zoom = zoomService.getZoomByContentId(toolContentID); + + if (zoom == null) { + logger.error("Unable to find tool content with id :" + toolContentID); + } + + ContentDTO contentDTO = new ContentDTO(zoom); + + Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); + contentDTO.setCurrentTab(currentTab); + contentDTO.setGroupedActivity(zoomService.isGroupedActivity(toolContentID)); + + request.setAttribute(ZoomConstants.ATTR_CONTENT_DTO, contentDTO); + request.setAttribute(ZoomConstants.ATTR_CONTENT_FOLDER_ID, contentFolderID); + + return mapping.findForward("success"); + } + + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + Long uid = new Long(WebUtil.readLongParam(request, ZoomConstants.PARAM_USER_UID)); + + ZoomUser user = zoomService.getUserByUID(uid); + NotebookEntry entry = zoomService.getNotebookEntry(user.getNotebookEntryUID()); + + ZoomUserDTO userDTO = new ZoomUserDTO(user); + userDTO.setNotebookEntryDTO(new NotebookEntryDTO(entry)); + + request.setAttribute(ZoomConstants.ATTR_USER_DTO, userDTO); + + return mapping.findForward("notebook"); + } + + public ActionForward startMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID, false); + Zoom zoom = zoomService.getZoomByContentId(toolContentID); + + ContentDTO contentDTO = new ContentDTO(); + contentDTO.setTitle(zoom.getTitle()); + contentDTO.setInstructions(zoom.getInstructions()); + request.setAttribute(ZoomConstants.ATTR_CONTENT_DTO, contentDTO); + + ActionErrors errors = ZoomUtil.startMeeting(zoomService, zoom, request); + if (!errors.isEmpty()) { + this.addErrors(request, errors); + } + + return mapping.findForward("learning"); + } +}