Index: lams_tool_scribe/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/.classpath,v diff -u -r1.6.2.8 -r1.6.2.9 --- lams_tool_scribe/.classpath 25 Nov 2014 10:47:21 -0000 1.6.2.8 +++ lams_tool_scribe/.classpath 12 Apr 2016 12:04:02 -0000 1.6.2.9 @@ -20,6 +20,7 @@ + Index: lams_tool_scribe/build.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/build.xml,v diff -u -r1.22 -r1.22.2.1 --- lams_tool_scribe/build.xml 12 Dec 2012 13:50:47 -0000 1.22 +++ lams_tool_scribe/build.xml 12 Apr 2016 12:04:02 -0000 1.22.2.1 @@ -3,5 +3,23 @@ - + + + + + + ${ant.project.name}: Copying additional Java classes to WAR + + \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml,v diff -u -r1.8.2.6 -r1.8.2.7 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml 10 Aug 2015 15:24:48 -0000 1.8.2.6 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml 12 Apr 2016 12:04:02 -0000 1.8.2.7 @@ -40,6 +40,7 @@ PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED + PROPAGATION_REQUIRED PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED PROPAGATION_REQUIRED Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java,v diff -u -r1.9 -r1.9.2.1 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java 17 Jan 2014 22:12:31 -0000 1.9 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java 12 Apr 2016 12:04:02 -0000 1.9.2.1 @@ -24,12 +24,12 @@ package org.lamsfoundation.lams.tool.scribe.service; -import org.apache.struts.upload.FormFile; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.scribe.model.Scribe; import org.lamsfoundation.lams.tool.scribe.model.ScribeSession; import org.lamsfoundation.lams.tool.scribe.model.ScribeUser; -import org.lamsfoundation.lams.tool.scribe.util.ScribeException; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; /** @@ -136,5 +136,7 @@ boolean isGroupedActivity(long toolContentID); + void submitReport(Long toolSessionId, String userName, JSONObject requestJSON) throws JSONException; + public void deleteHeading(Long headingUid); } \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java,v diff -u -r1.30.2.7 -r1.30.2.8 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java 18 Feb 2016 15:44:54 -0000 1.30.2.7 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java 12 Apr 2016 12:04:02 -0000 1.30.2.8 @@ -483,6 +483,37 @@ return toolService.isGroupedActivity(toolContentID); } + @Override + @SuppressWarnings("unchecked") + public void submitReport(Long toolSessionId, String userName, JSONObject requestJSON) throws JSONException { + ScribeSession scribeSession = getSessionBySessionId(toolSessionId); + ScribeUser scribe = scribeSession.getAppointedScribe(); + if ((scribe == null) || !scribe.getLoginName().equals(userName)) { + return; + } + + for (ScribeUser learner : (Set) scribeSession.getScribeUsers()) { + learner.setReportApproved(false); + saveOrUpdateScribeUser(learner); + } + + JSONArray reportsJSON = requestJSON.getJSONArray("reports"); + for (int reportIndex = 0; reportIndex < reportsJSON.length(); reportIndex++) { + JSONObject reportJSON = reportsJSON.getJSONObject(reportIndex); + Long uid = reportJSON.getLong("uid"); + String text = reportJSON.getString("text"); + for (ScribeReportEntry report : (Set) scribeSession.getScribeReportEntries()) { + if (report.getUid().equals(uid)) { + report.setEntryText(text); + break; + } + } + } + + scribeSession.setReportSubmitted(true); + saveOrUpdateScribeSession(scribeSession); + } + /* ********** Used by Spring to "inject" the linked objects ************* */ public IScribeDAO getScribeDAO() { Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/util/ScribeUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/util/ScribeUtils.java,v diff -u -r1.2 -r1.2.12.1 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/util/ScribeUtils.java 16 Nov 2007 07:49:40 -0000 1.2 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/util/ScribeUtils.java 12 Apr 2016 12:04:02 -0000 1.2.12.1 @@ -1,71 +1,44 @@ package org.lamsfoundation.lams.tool.scribe.util; -import java.util.Iterator; import java.util.Set; import java.util.TreeMap; import org.lamsfoundation.lams.tool.scribe.dto.ScribeSessionDTO; import org.lamsfoundation.lams.tool.scribe.model.ScribeSession; -import org.lamsfoundation.lams.tool.scribe.model.ScribeUser; public class ScribeUtils { - - public static int calculateVotePercentage(int numberOfVotes, int numberOfLearners) { - - Float v = new Float(numberOfVotes); - Float l = new Float(numberOfLearners); - - Float result = v/l*100; - - return result.intValue(); - } - /** Create the session DTO for a user's session/group. Includes the number of votes - * for, percentages, etc. - * @param scribeSession - */ - public static ScribeSessionDTO createSessionDTO(ScribeSession scribeSession) { - ScribeSessionDTO sessionDTO = new ScribeSessionDTO(scribeSession); + public static int calculateVotePercentage(int numberOfVotes, int numberOfLearners) { + Float v = new Float(numberOfVotes); + Float l = new Float(numberOfLearners); - int numberOfVotes = 0; - for (Iterator iter = scribeSession.getScribeUsers().iterator(); iter - .hasNext();) { - ScribeUser user = (ScribeUser) iter.next(); - if (user.isReportApproved()) { - numberOfVotes++; - } - } + Float result = (v / l) * 100; - int numberOfLearners = scribeSession.getScribeUsers().size(); + return result.intValue(); + } - sessionDTO.setNumberOfVotes(numberOfVotes); - sessionDTO.setNumberOfLearners(numberOfLearners); - sessionDTO.setVotePercentage(ScribeUtils.calculateVotePercentage( - numberOfVotes, numberOfLearners)); + /** + * Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key is the + * group/session name. The code ensures that the session name is unique, adding the session id if necessary. It will + * only include the finalized reports. + */ + public static TreeMap getReportDTOs(ScribeSession scribeSession) { + Set scribeSessionsForContent = scribeSession.getScribe().getScribeSessions(); + TreeMap otherScribeSessions = new TreeMap(); + for (ScribeSession session : scribeSessionsForContent) { + if (!session.equals(scribeSession) && session.isForceComplete()) { - return sessionDTO; - } - - /** Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key - * is the group/session name. The code ensures that the session name is unique, adding the session id if necessary. - * It will only include the finalized reports. */ - public static TreeMap getReportDTOs(ScribeSession scribeSession) { - Set scribeSessionsForContent = scribeSession.getScribe().getScribeSessions(); - TreeMap otherScribeSessions = new TreeMap(); - for ( ScribeSession session : scribeSessionsForContent ) { - if ( ! session.equals(scribeSession) && session.isForceComplete() ) { - - // ensure a unique group name, as we will sort on that - String sessionKey = session.getSessionName(); - if ( otherScribeSessions.containsKey(sessionKey) ) { - sessionKey = sessionKey + "("+session.getSessionId().toString()+")"; - } - - ScribeSessionDTO dto = new ScribeSessionDTO(session); - otherScribeSessions.put(sessionKey, dto); - } + // ensure a unique group name, as we will sort on that + String sessionKey = session.getSessionName(); + if (otherScribeSessions.containsKey(sessionKey)) { + sessionKey = sessionKey + "(" + session.getSessionId().toString() + ")"; } - return otherScribeSessions; + + ScribeSessionDTO dto = new ScribeSessionDTO(session); + otherScribeSessions.put(sessionKey, dto); + } } + return otherScribeSessions; + } } Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java,v diff -u -r1.17 -r1.17.2.1 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java 17 Jan 2014 22:12:31 -0000 1.17 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningAction.java 12 Apr 2016 12:04:02 -0000 1.17.2.1 @@ -25,10 +25,7 @@ package org.lamsfoundation.lams.tool.scribe.web.actions; import java.io.IOException; -import java.util.Iterator; -import java.util.Set; import java.util.TreeMap; -import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -38,6 +35,7 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.tomcat.util.json.JSONException; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; @@ -46,11 +44,9 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scribe.dto.ScribeDTO; -import org.lamsfoundation.lams.tool.scribe.dto.ScribeReportEntryDTO; import org.lamsfoundation.lams.tool.scribe.dto.ScribeSessionDTO; import org.lamsfoundation.lams.tool.scribe.dto.ScribeUserDTO; import org.lamsfoundation.lams.tool.scribe.model.Scribe; -import org.lamsfoundation.lams.tool.scribe.model.ScribeReportEntry; import org.lamsfoundation.lams.tool.scribe.model.ScribeSession; import org.lamsfoundation.lams.tool.scribe.model.ScribeUser; import org.lamsfoundation.lams.tool.scribe.service.IScribeService; @@ -70,437 +66,303 @@ * @author * @version * - * @struts.action path="/learning" parameter="dispatch" scope="request" - * name="learningForm" + * @struts.action path="/learning" parameter="dispatch" scope="request" name="learningForm" * @struts.action-forward name="learning" path="tiles:/learning/main" * @struts.action-forward name="scribe" path="tiles:/learning/scribe" * @struts.action-forward name="defineLater" path="tiles:/learning/defineLater" * @struts.action-forward name="waitForScribe" path="tiles:/learning/waitForScribe" * @struts.action-forward name="notebook" path="tiles:/learning/notebook" - * @struts.action-forward name="voteDisplay" path="/pages/parts/voteDisplay.jsp" * @struts.action-forward name="report" path="tiles:/learning/report" - * @struts.action-forward name="instructions" - * path="tiles:/learning/instructions" + * @struts.action-forward name="instructions" path="tiles:/learning/instructions" */ public class LearningAction extends LamsDispatchAction { - private static Logger log = Logger.getLogger(LearningAction.class); + private static Logger log = Logger.getLogger(LearningAction.class); - private static final boolean MODE_OPTIONAL = false; + private static final boolean MODE_OPTIONAL = false; - private IScribeService scribeService; + private IScribeService scribeService; - public ActionForward unspecified(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) - throws Exception { - // 'toolSessionID' and 'mode' paramters are expected to be present. - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, - AttributeNames.PARAM_MODE, MODE_OPTIONAL); + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + // 'toolSessionID' and 'mode' paramters are expected to be present. + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, + LearningAction.MODE_OPTIONAL); - Long toolSessionID = WebUtil.readLongParam(request, - AttributeNames.PARAM_TOOL_SESSION_ID); + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); - // set up scribeService - if (scribeService == null) { - scribeService = ScribeServiceProxy.getScribeService(this - .getServlet().getServletContext()); - } - //try to clone scribe heading from content. This method will execute - //for every new learner enter, but the heading only copied once. - try{ - scribeService.createReportEntry(toolSessionID); - } catch (ObjectOptimisticLockingFailureException e) { - log.debug("Multiple learner get into scribe simultaneously. Cloning report entry skipped"); - } + // set up scribeService + if (scribeService == null) { + scribeService = ScribeServiceProxy.getScribeService(this.getServlet().getServletContext()); + } + //try to clone scribe heading from content. This method will execute + //for every new learner enter, but the heading only copied once. + try { + scribeService.createReportEntry(toolSessionID); + } catch (ObjectOptimisticLockingFailureException e) { + LearningAction.log.debug("Multiple learner get into scribe simultaneously. Cloning report entry skipped"); + } - // Retrieve the session and content. - ScribeSession scribeSession = scribeService - .getSessionBySessionId(toolSessionID); - if (scribeSession == null) { - throw new ScribeException( - "Cannot retrieve session with toolSessionID" - + toolSessionID); - } - Scribe scribe = scribeSession.getScribe(); - - // check defineLater - if (scribe.isDefineLater()) { - return mapping.findForward("defineLater"); - } - - // Ensure that the content in use flag is set. - if (!scribe.isContentInUse()) { - scribe.setContentInUse(new Boolean(true)); - scribeService.saveOrUpdateScribe(scribe); - } - - LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, getServlet() - .getServletContext()); - - // Retrieve the current user - ScribeUser scribeUser = getCurrentUser(toolSessionID); - - // check whether scribe has been appointed - while (scribeSession.getAppointedScribe() == null) { - // check autoSelectScribe - if (scribe.isAutoSelectScribe() == false) { - // learner needs to wait until a scribe has been appointed by - // teacher. - return mapping.findForward("waitForScribe"); - - } else { - // appoint the currentUser as the scribe - scribeSession.setAppointedScribe(scribeUser); - - // attempt to update the scribeSession. - try { - scribeService.saveOrUpdateScribeSession(scribeSession); - } catch (ObjectOptimisticLockingFailureException le) { - // scribeSession has been modified. Reload scribeSession and - // check again. - scribeSession = scribeService - .getSessionBySessionId(toolSessionID); - } - } - } - - // setup dto's forms and attributes. - ((LearningForm) form).setToolSessionID(scribeSession.getSessionId()); - request.setAttribute("MODE", mode.toString()); - setupDTOs(request, scribeSession, scribeUser); - - // check force complete - if (scribeSession.isForceComplete()) { - // go to report page - if ( scribeSession.getScribe().isShowAggregatedReports() ) - setupOtherGroupReportDTO(request, scribeSession, scribeUser); - return mapping.findForward("report"); - } - - // check if user has started activity - if (!scribeUser.isStartedActivity()) { - if (scribeSession.getAppointedScribe().getUid() == scribeUser - .getUid()) { - request.setAttribute("role", "scribe"); - } else { - request.setAttribute("role", "learner"); - } - return mapping.findForward("instructions"); - } - - // check if current user is the scribe. - if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { - return mapping.findForward("scribe"); - } else { - return mapping.findForward("learning"); - } - + // Retrieve the session and content. + ScribeSession scribeSession = scribeService.getSessionBySessionId(toolSessionID); + if (scribeSession == null) { + throw new ScribeException("Cannot retrieve session with toolSessionID" + toolSessionID); } + Scribe scribe = scribeSession.getScribe(); - private ScribeUser getCurrentUser(Long toolSessionID) { - UserDTO user = (UserDTO) SessionManager.getSession().getAttribute( - AttributeNames.USER); - - // attempt to retrieve user using userId and toolSessionID - ScribeUser scribeUser = scribeService.getUserByUserIdAndSessionId( - new Long(user.getUserID().intValue()), toolSessionID); - - if (scribeUser == null) { - ScribeSession scribeSession = scribeService - .getSessionBySessionId(toolSessionID); - scribeUser = scribeService.createScribeUser(user, scribeSession); - } - - return scribeUser; + // check defineLater + if (scribe.isDefineLater()) { + return mapping.findForward("defineLater"); } - public ActionForward startActivity(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { - - LearningForm lrnForm = (LearningForm) form; - Long toolSessionID = lrnForm.getToolSessionID(); - - ScribeSession scribeSession = scribeService - .getSessionBySessionId(toolSessionID); - ScribeUser scribeUser = getCurrentUser(toolSessionID); - - // setup dto's, forms and attributes. - lrnForm.setToolSessionID(scribeSession.getSessionId()); - request.setAttribute("MODE", lrnForm.getMode()); - setupDTOs(request, scribeSession, scribeUser); - - // update scribe user and go to instructions page - scribeUser.setStartedActivity(true); - scribeService.saveOrUpdateScribeUser(scribeUser); - - // check if current user is the scribe. - if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { - return mapping.findForward("scribe"); - } - - return mapping.findForward("learning"); + // Ensure that the content in use flag is set. + if (!scribe.isContentInUse()) { + scribe.setContentInUse(new Boolean(true)); + scribeService.saveOrUpdateScribe(scribe); } - public ActionForward finishActivity(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + getServlet().getServletContext()); - LearningForm lrnForm = (LearningForm) form; + // Retrieve the current user + ScribeUser scribeUser = getCurrentUser(toolSessionID); - // set the finished flag - ScribeUser scribeUser = scribeService.getUserByUID(lrnForm - .getScribeUserUID()); - if (scribeUser != null) { - scribeUser.setFinishedActivity(true); - scribeService.saveOrUpdateScribeUser(scribeUser); - } else { - log.error("finishActivity(): couldn't find ScribeUser with uid: " - + lrnForm.getScribeUserUID()); - } + // check whether scribe has been appointed + while (scribeSession.getAppointedScribe() == null) { + // check autoSelectScribe + if (scribe.isAutoSelectScribe() == false) { + // learner needs to wait until a scribe has been appointed by + // teacher. + return mapping.findForward("waitForScribe"); - ToolSessionManager sessionMgrService = ScribeServiceProxy - .getScribeSessionManager(getServlet().getServletContext()); + } else { + // appoint the currentUser as the scribe + scribeSession.setAppointedScribe(scribeUser); - HttpSession ss = SessionManager.getSession(); - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - Long userID = new Long(user.getUserID().longValue()); - Long toolSessionID = scribeUser.getScribeSession().getSessionId(); - - String nextActivityUrl; + // attempt to update the scribeSession. try { - nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, - userID); - response.sendRedirect(nextActivityUrl); - } catch (DataMissingException e) { - throw new ScribeException(e); - } catch (ToolException e) { - throw new ScribeException(e); - } catch (IOException e) { - throw new ScribeException(e); + scribeService.saveOrUpdateScribeSession(scribeSession); + } catch (ObjectOptimisticLockingFailureException le) { + // scribeSession has been modified. Reload scribeSession and + // check again. + scribeSession = scribeService.getSessionBySessionId(toolSessionID); } - - return null; // TODO need to return proper page. + } } - public ActionForward openNotebook(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + // setup dto's forms and attributes. + ((LearningForm) form).setToolSessionID(scribeSession.getSessionId()); + request.setAttribute("MODE", mode.toString()); + setupDTOs(request, scribeSession, scribeUser); - LearningForm lrnForm = (LearningForm) form; + // check force complete + if (scribeSession.isForceComplete()) { + // go to report page + if (scribeSession.getScribe().isShowAggregatedReports()) { + setupOtherGroupReportDTO(request, scribeSession, scribeUser); + } + return mapping.findForward("report"); + } - // set the finished flag - ScribeUser scribeUser = scribeService.getUserByUID(lrnForm - .getScribeUserUID()); - ScribeDTO scribeDTO = new ScribeDTO(scribeUser.getScribeSession() - .getScribe()); + // check if user has started activity + if (!scribeUser.isStartedActivity()) { + if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { + request.setAttribute("role", "scribe"); + } else { + request.setAttribute("role", "learner"); + } + return mapping.findForward("instructions"); + } - request.setAttribute("scribeDTO", scribeDTO); - - LearningWebUtil.putActivityPositionInRequestByToolSessionId(scribeUser.getScribeSession().getSessionId(), - request, getServlet().getServletContext()); - - return mapping.findForward("notebook"); + // check if current user is the scribe. + if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { + return mapping.findForward("scribe"); + } else { + return mapping.findForward("learning"); } - public ActionForward submitReflection(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + } - // save the reflection entry and call the notebook. + private ScribeUser getCurrentUser(Long toolSessionID) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); - LearningForm lrnForm = (LearningForm) form; + // attempt to retrieve user using userId and toolSessionID + ScribeUser scribeUser = scribeService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), + toolSessionID); - ScribeUser scribeUser = scribeService.getUserByUID(lrnForm - .getScribeUserUID()); - - scribeService.createNotebookEntry(scribeUser.getScribeSession() - .getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - ScribeConstants.TOOL_SIGNATURE, scribeUser.getUserId() - .intValue(), lrnForm.getEntryText()); - - return finishActivity(mapping, form, request, response); + if (scribeUser == null) { + ScribeSession scribeSession = scribeService.getSessionBySessionId(toolSessionID); + scribeUser = scribeService.createScribeUser(user, scribeSession); } - public ActionForward submitReport(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + return scribeUser; + } - LearningForm lrnForm = (LearningForm) form; - Long toolSessionID = lrnForm.getToolSessionID(); + public ActionForward startActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { - ScribeSession session = scribeService - .getSessionBySessionId(toolSessionID); + LearningForm lrnForm = (LearningForm) form; + Long toolSessionID = lrnForm.getToolSessionID(); - ScribeUser scribeUser = getCurrentUser(toolSessionID); + ScribeSession scribeSession = scribeService.getSessionBySessionId(toolSessionID); + ScribeUser scribeUser = getCurrentUser(toolSessionID); - boolean reportValid = false; + // setup dto's, forms and attributes. + lrnForm.setToolSessionID(scribeSession.getSessionId()); + request.setAttribute("MODE", lrnForm.getMode()); + setupDTOs(request, scribeSession, scribeUser); - for (Iterator iter = session.getScribeReportEntries().iterator(); iter - .hasNext();) { - ScribeReportEntry report = (ScribeReportEntry) iter.next(); + // update scribe user and go to instructions page + scribeUser.setStartedActivity(true); + scribeService.saveOrUpdateScribeUser(scribeUser); - String entryText = (String) lrnForm.getReport(report.getUid() - .toString()); + // check if current user is the scribe. + if (scribeSession.getAppointedScribe().getUid() == scribeUser.getUid()) { + return mapping.findForward("scribe"); + } - if (entryText.length() != 0) { - reportValid = true; - } - } + return mapping.findForward("learning"); + } - if (reportValid) { - // update scribeReports - for (Iterator iter = session.getScribeReportEntries().iterator(); iter - .hasNext();) { - ScribeReportEntry report = (ScribeReportEntry) iter.next(); + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { - String entryText = (String) lrnForm.getReport(report.getUid() - .toString()); - report.setEntryText(entryText); - } + LearningForm lrnForm = (LearningForm) form; - // persist changes - for (Iterator iter = session.getScribeUsers().iterator(); iter - .hasNext();) { - ScribeUser user = (ScribeUser) iter.next(); - user.setReportApproved(false); - scribeService.saveOrUpdateScribeUser(scribeUser); - } + // set the finished flag + ScribeUser scribeUser = scribeService.getUserByUID(lrnForm.getScribeUserUID()); + if (scribeUser != null) { + scribeUser.setFinishedActivity(true); + scribeService.saveOrUpdateScribeUser(scribeUser); + } else { + LearningAction.log + .error("finishActivity(): couldn't find ScribeUser with uid: " + lrnForm.getScribeUserUID()); + } - session.setReportSubmitted(true); - scribeService.saveOrUpdateScribeSession(session); - } + ToolSessionManager sessionMgrService = ScribeServiceProxy + .getScribeSessionManager(getServlet().getServletContext()); - request.setAttribute("MODE", lrnForm.getMode()); - setupDTOs(request, session, scribeUser); + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Long userID = new Long(user.getUserID().longValue()); + Long toolSessionID = scribeUser.getScribeSession().getSessionId(); - return mapping.findForward("scribe"); + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, userID); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new ScribeException(e); + } catch (ToolException e) { + throw new ScribeException(e); + } catch (IOException e) { + throw new ScribeException(e); } - public ActionForward submitApproval(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + return null; // TODO need to return proper page. + } - LearningForm lrnForm = (LearningForm) form; + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { - // get session and user - ScribeSession session = scribeService.getSessionBySessionId(lrnForm - .getToolSessionID()); - ScribeUser scribeUser = getCurrentUser(session.getSessionId()); + LearningForm lrnForm = (LearningForm) form; - scribeUser.setReportApproved(true); + // set the finished flag + ScribeUser scribeUser = scribeService.getUserByUID(lrnForm.getScribeUserUID()); + ScribeDTO scribeDTO = new ScribeDTO(scribeUser.getScribeSession().getScribe()); - request.setAttribute("MODE", lrnForm.getMode()); - setupDTOs(request, session, scribeUser); + request.setAttribute("scribeDTO", scribeDTO); - scribeService.saveOrUpdateScribeUser(scribeUser); + LearningWebUtil.putActivityPositionInRequestByToolSessionId(scribeUser.getScribeSession().getSessionId(), + request, getServlet().getServletContext()); - if (session.getAppointedScribe().equals(scribeUser)) { - // send updated voteDisplay - return getVoteDisplay(mapping, form, request, response); - } else { - // load learning page. - return mapping.findForward("learning"); - } - } + return mapping.findForward("notebook"); + } - public ActionForward getVoteDisplay(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) { + public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { - Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID"); + // save the reflection entry and call the notebook. - ScribeSession session = scribeService - .getSessionBySessionId(toolSessionID); + LearningForm lrnForm = (LearningForm) form; - int numberOfVotes = 0; + ScribeUser scribeUser = scribeService.getUserByUID(lrnForm.getScribeUserUID()); - for (Iterator iter = session.getScribeUsers().iterator(); iter - .hasNext();) { - ScribeUser user = (ScribeUser) iter.next(); + scribeService.createNotebookEntry(scribeUser.getScribeSession().getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ScribeConstants.TOOL_SIGNATURE, scribeUser.getUserId().intValue(), + lrnForm.getEntryText()); - if (user.isReportApproved()) { - numberOfVotes++; - } - } + return finishActivity(mapping, form, request, response); + } - int numberOfLearners = session.getScribeUsers().size(); - int votePercentage = ScribeUtils.calculateVotePercentage(numberOfVotes, - numberOfLearners); + public ActionForward forceCompleteActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + LearningForm lrnForm = (LearningForm) form; + ScribeUser scribeUser = scribeService.getUserByUID(lrnForm.getScribeUserUID()); + ScribeSession session = scribeUser.getScribeSession(); - ScribeSessionDTO sessionDTO = new ScribeSessionDTO(); - sessionDTO.setNumberOfVotes(numberOfVotes); - sessionDTO.setNumberOfLearners(numberOfLearners); - sessionDTO.setVotePercentage(votePercentage); - - request.setAttribute("scribeSessionDTO", sessionDTO); - - return mapping.findForward("voteDisplay"); + if (session.getAppointedScribe().getUid() == scribeUser.getUid()) { + session.setForceComplete(true); + } else { + // TODO need to implement this. + LearningAction.log + .error("ScribeUserUID: " + scribeUser.getUid() + " is not allowed to forceComplete this session"); } - public ActionForward forceCompleteActivity(ActionMapping mapping, - ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + request.setAttribute("MODE", lrnForm.getMode()); + setupDTOs(request, session, scribeUser); + scribeService.saveOrUpdateScribeUser(scribeUser); - LearningForm lrnForm = (LearningForm) form; + LearningWebsocketServer.sendCloseRequest(session.getSessionId()); - ScribeUser scribeUser = scribeService.getUserByUID(lrnForm - .getScribeUserUID()); + if (session.getScribe().isShowAggregatedReports()) { + setupOtherGroupReportDTO(request, session, scribeUser); + } - ScribeSession session = scribeUser.getScribeSession(); + LearningWebUtil.putActivityPositionInRequestByToolSessionId(session.getSessionId(), request, + getServlet().getServletContext()); - if (session.getAppointedScribe().getUid() == scribeUser.getUid()) { - session.setForceComplete(true); - } else { - // TODO need to implement this. - log.error("ScribeUserUID: " + scribeUser.getUid() - + " is not allowed to forceComplete this session"); - } + return mapping.findForward("report"); + } - request.setAttribute("MODE", lrnForm.getMode()); - setupDTOs(request, session, scribeUser); + // Private methods. - scribeService.saveOrUpdateScribeUser(scribeUser); + /** + * Set up all the DTO relating to this session. Doesn't set up the DTO containing the reports of the other groups. + */ + private void setupDTOs(HttpServletRequest request, ScribeSession scribeSession, ScribeUser scribeUser) { - if ( session.getScribe().isShowAggregatedReports() ) - setupOtherGroupReportDTO(request, session, scribeUser); - - LearningWebUtil.putActivityPositionInRequestByToolSessionId(session.getSessionId(), request, getServlet() - .getServletContext()); + ScribeDTO scribeDTO = new ScribeDTO(scribeSession.getScribe()); + request.setAttribute("scribeDTO", scribeDTO); - return mapping.findForward("report"); + ScribeSessionDTO sessionDTO = new ScribeSessionDTO(scribeSession); + request.setAttribute("scribeSessionDTO", sessionDTO); + + ScribeUserDTO scribeUserDTO = new ScribeUserDTO(scribeUser); + if (scribeUser.isFinishedActivity()) { + // get the notebook entry. + NotebookEntry notebookEntry = scribeService.getEntry(scribeSession.getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, ScribeConstants.TOOL_SIGNATURE, + scribeUser.getUserId().intValue()); + if (notebookEntry != null) { + scribeUserDTO.notebookEntry = notebookEntry.getEntry(); + } } + request.setAttribute("scribeUserDTO", scribeUserDTO); + } - // Private methods. - - /** Set up all the DTO relating to this session. Doesn't set up the DTO containing the reports of the other groups. */ - private void setupDTOs(HttpServletRequest request, - ScribeSession scribeSession, ScribeUser scribeUser) { - - ScribeDTO scribeDTO = new ScribeDTO(scribeSession.getScribe()); - request.setAttribute("scribeDTO", scribeDTO); - - ScribeSessionDTO sessionDTO = ScribeUtils.createSessionDTO(scribeSession); - request.setAttribute("scribeSessionDTO", sessionDTO); - - ScribeUserDTO scribeUserDTO = new ScribeUserDTO(scribeUser); - if (scribeUser.isFinishedActivity()) { - // get the notebook entry. - NotebookEntry notebookEntry = scribeService.getEntry(scribeSession - .getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL, - ScribeConstants.TOOL_SIGNATURE, scribeUser.getUserId() - .intValue()); - if (notebookEntry != null) { - scribeUserDTO.notebookEntry = notebookEntry.getEntry(); - } - } - request.setAttribute("scribeUserDTO", scribeUserDTO); + /** + * Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key is the + * group/session name. The code ensures that the session name is unique, adding the session id if necessary. It will + * only include the finalized reports. + */ + private void setupOtherGroupReportDTO(HttpServletRequest request, ScribeSession scribeSession, + ScribeUser scribeUser) { + TreeMap otherScribeSessions = ScribeUtils.getReportDTOs(scribeSession); + if (otherScribeSessions.size() > 0) { + request.setAttribute("otherScribeSessions", otherScribeSessions.values()); } - - /** Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key - * is the group/session name. The code ensures that the session name is unique, adding the session id if necessary. - * It will only include the finalized reports. */ - private void setupOtherGroupReportDTO(HttpServletRequest request, - ScribeSession scribeSession, ScribeUser scribeUser) { - TreeMap otherScribeSessions = ScribeUtils.getReportDTOs(scribeSession); - if ( otherScribeSessions.size() > 0 ) { - request.setAttribute("otherScribeSessions", otherScribeSessions.values()); - } - } + } - } Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/LearningWebsocketServer.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/MonitoringAction.java,v diff -u -r1.11.10.1 -r1.11.10.2 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/MonitoringAction.java 8 Oct 2015 20:55:59 -0000 1.11.10.1 +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/MonitoringAction.java 12 Apr 2016 12:04:02 -0000 1.11.10.2 @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.tool.scribe.web.actions; +import java.io.IOException; import java.util.Iterator; import javax.servlet.http.HttpServletRequest; @@ -33,6 +34,7 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.tomcat.util.json.JSONException; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.scribe.dto.ScribeDTO; @@ -136,14 +138,16 @@ } public ActionForward forceCompleteActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) throws JSONException, IOException { MonitoringForm monForm = (MonitoringForm) form; ScribeSession session = scribeService.getSessionBySessionId(monForm.getToolSessionID()); session.setForceComplete(true); scribeService.saveOrUpdateScribeSession(session); + LearningWebsocketServer.sendCloseRequest(session.getSessionId()); + ScribeDTO scribeDTO = setupScribeDTO(session.getScribe()); request.setAttribute("monitoringDTO", scribeDTO); request.setAttribute("contentFolderID", monForm.getContentFolderID()); Fisheye: Tag 1.1.14.1 refers to a dead (removed) revision in file `lams_tool_scribe/web/includes/javascript/learning.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scribe/web/pages/learning/learning.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/web/pages/learning/learning.jsp,v diff -u -r1.13.2.1 -r1.13.2.2 --- lams_tool_scribe/web/pages/learning/learning.jsp 26 Feb 2016 15:44:21 -0000 1.13.2.1 +++ lams_tool_scribe/web/pages/learning/learning.jsp 12 Apr 2016 12:04:02 -0000 1.13.2.2 @@ -8,12 +8,58 @@ - + @@ -32,10 +78,6 @@

: ${appointedScribe}

- - - - @@ -46,36 +88,29 @@
- - + - - - - - - + + + +
- -
-
- - - -
+
+
+
- +
- - - + \ No newline at end of file Index: lams_tool_scribe/web/pages/learning/scribe.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/web/pages/learning/scribe.jsp,v diff -u -r1.13.2.1 -r1.13.2.2 --- lams_tool_scribe/web/pages/learning/scribe.jsp 26 Feb 2016 15:44:21 -0000 1.13.2.1 +++ lams_tool_scribe/web/pages/learning/scribe.jsp 12 Apr 2016 12:04:02 -0000 1.13.2.2 @@ -7,44 +7,83 @@ - - + @@ -54,68 +93,55 @@
- - - - +
+ <%@include file="/pages/parts/voteDisplay.jsp"%> +
-
- <%@include file="/pages/parts/voteDisplay.jsp"%> -
+

+ + +

+ +
+
+
+
+ +
+
-

- - -

- - - -
-
-
-
- -
-
+
+ - -
- - - - - - -
-
- - - - - - + + + +
+ + + +
- +
+
- -
-
- - - -
+ +
+
+
- +
+
- -
@@ -131,22 +157,12 @@
- -
- - -
-
+
+ + +
- - - - - + \ No newline at end of file Index: lams_tool_scribe/web/pages/parts/voteDisplay.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scribe/web/pages/parts/voteDisplay.jsp,v diff -u -r1.3.2.1 -r1.3.2.2 --- lams_tool_scribe/web/pages/parts/voteDisplay.jsp 26 Feb 2016 15:44:21 -0000 1.3.2.1 +++ lams_tool_scribe/web/pages/parts/voteDisplay.jsp 12 Apr 2016 12:04:02 -0000 1.3.2.2 @@ -1,15 +1,17 @@ <%@ include file="/common/taglibs.jsp"%>
-
${scribeSessionDTO.votePercentage}% -
- - - - - (${scribeSessionDTO.votePercentage}%) +
+ + + + + + + (${scribeSessionDTO.votePercentage}%)