Index: lams_tool_scratchie/conf/xdoclet/struts-actions.xml =================================================================== diff -u -r0f1d0cc4e194182f9384119b42101bfa18a18085 -r2158f834350c93ef5ee874a09d9c7046850553a9 --- lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 0f1d0cc4e194182f9384119b42101bfa18a18085) +++ lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 2158f834350c93ef5ee874a09d9c7046850553a9) @@ -190,6 +190,7 @@ parameter="start" > + @@ -199,6 +200,10 @@ parameter="refreshQuestionList" > + + Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java =================================================================== diff -u -r28e0c7b1e1c001a249f208dbd45343fedc0c60fa -r2158f834350c93ef5ee874a09d9c7046850553a9 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 28e0c7b1e1c001a249f208dbd45343fedc0c60fa) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 2158f834350c93ef5ee874a09d9c7046850553a9) @@ -105,6 +105,8 @@ public static final String ATTR_IS_SCRATCHING_FINISHED = "isScratchingFinished"; + public static final String ATTR_IS_WAITING_FOR_LEADER_TO_SUBMIT_NOTEBOOK = "isWaitingForLeaderToSubmitNotebook"; + public static final String ATTR_LEARNERS = "learners"; public static final String ATTR_VISIT_LOGS = "visitLogs"; Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== diff -u -rc01bd4b6b818ad0e3bd91a9743a300f2a36f2047 -r2158f834350c93ef5ee874a09d9c7046850553a9 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision c01bd4b6b818ad0e3bd91a9743a300f2a36f2047) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 2158f834350c93ef5ee874a09d9c7046850553a9) @@ -96,6 +96,9 @@ if (param.equals("refreshQuestionList")) { return refreshQuestionList(mapping, form, request, response); } + if (param.equals("checkLeaderSubmittedNotebook")) { + return checkLeaderSubmittedNotebook(mapping, form, request, response); + } if (param.equals("isAnswerCorrect")) { return isAnswerCorrect(mapping, form, request, response); } @@ -209,15 +212,12 @@ request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); // get notebook entry - String entryText = new String(); + NotebookEntry notebookEntry = null; if (isReflectOnActivity && (groupLeader != null)) { - NotebookEntry notebookEntry = LearningAction.service.getEntry(toolSessionId, - CoreNotebookConstants.NOTEBOOK_TOOL, ScratchieConstants.TOOL_SIGNATURE, groupLeader.getUserId() - .intValue()); - if (notebookEntry != null) { - entryText = notebookEntry.getEntry(); - } + notebookEntry = LearningAction.service.getEntry(toolSessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + ScratchieConstants.TOOL_SIGNATURE, groupLeader.getUserId().intValue()); } + String entryText = (notebookEntry == null) ? new String() : notebookEntry.getEntry(); // basic information sessionMap.put(ScratchieConstants.ATTR_TITLE, scratchie.getTitle()); @@ -331,10 +331,19 @@ sessionMap.put(ScratchieConstants.ATTR_MAX_SCORE, maxScore); boolean isScratchingFinished = toolSession.isScratchingFinished(); - - // decide whether to show results page or learning one - boolean isShowResults = isScratchingFinished && !mode.isTeacher(); - if (isShowResults) { + boolean isWaitingForLeaderToSubmitNotebook = isReflectOnActivity && (notebookEntry == null); + boolean isShowResults = (isScratchingFinished && !isWaitingForLeaderToSubmitNotebook) && !mode.isTeacher(); + + //show leader notebook page + if (isUserLeader && isScratchingFinished && isWaitingForLeaderToSubmitNotebook) { + ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("newReflection")); + redirect.addParameter(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + redirect.addParameter(AttributeNames.ATTR_MODE, mode); + return redirect; + + // show results page + } else if (isShowResults) { + ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("showResults")); redirect.addParameter(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); redirect.addParameter(AttributeNames.ATTR_MODE, mode); @@ -343,13 +352,17 @@ + "]: leaving start()"); } return redirect; + + //show learning.jsp page } else { if (LearningAction.log.isDebugEnabled()) { LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + "]: leaving start()"); } - + sessionMap.put(ScratchieConstants.ATTR_IS_SCRATCHING_FINISHED, (Boolean) isScratchingFinished); + sessionMap.put(ScratchieConstants.ATTR_IS_WAITING_FOR_LEADER_TO_SUBMIT_NOTEBOOK, + (Boolean) isWaitingForLeaderToSubmitNotebook); return mapping.findForward(ScratchieConstants.SUCCESS); } @@ -405,7 +418,48 @@ } return mapping.findForward(ScratchieConstants.SUCCESS); } + + /** + * Return whether leader still needs submit notebook. + */ + private ActionForward checkLeaderSubmittedNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered checkLeaderSubmittedNotebook()"); + } + initializeScratchieService(); + + // get back SessionMap + String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); + boolean isReflectOnActivity = (Boolean) sessionMap.get(ScratchieConstants.ATTR_REFLECTION_ON); + Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId); + ScratchieUser groupLeader = toolSession.getGroupLeader(); + + // get notebook entry + NotebookEntry notebookEntry = null; + if (isReflectOnActivity && (groupLeader != null)) { + notebookEntry = service.getEntry(toolSessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + ScratchieConstants.TOOL_SIGNATURE, groupLeader.getUserId().intValue()); + } + boolean isWaitingForLeaderToSubmitNotebook = isReflectOnActivity && (notebookEntry == null); + JSONObject JSONObject = new JSONObject(); + JSONObject.put(ScratchieConstants.ATTR_IS_WAITING_FOR_LEADER_TO_SUBMIT_NOTEBOOK, isWaitingForLeaderToSubmitNotebook); + response.setContentType("application/x-json;charset=utf-8"); + response.getWriter().print(JSONObject); + + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving checkLeaderSubmittedNotebook()"); + } + return null; + } + /** * Return whether scratchie answer is correct or not */ Index: lams_tool_scratchie/web/pages/learning/questionlist.jsp =================================================================== diff -u -rc01bd4b6b818ad0e3bd91a9743a300f2a36f2047 -r2158f834350c93ef5ee874a09d9c7046850553a9 --- lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision c01bd4b6b818ad0e3bd91a9743a300f2a36f2047) +++ lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision 2158f834350c93ef5ee874a09d9c7046850553a9) @@ -11,14 +11,48 @@ + @@ -87,20 +121,19 @@ - -
- - - - - - - - - - - - -
-
- \ No newline at end of file + +
+ + + + + + + + + + + + +
+
\ No newline at end of file