Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java =================================================================== diff -u -r3a8732a27caaa2eda8712c7a2f24f5788c7d110a -r3badb4923296aa60ac88664390cf74ccc68a7e53 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 3a8732a27caaa2eda8712c7a2f24f5788c7d110a) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 3badb4923296aa60ac88664390cf74ccc68a7e53) @@ -191,4 +191,6 @@ public static final String ERROR_MSG_REQUIRED_FIELDS_MISSING = "error.required.fields.missing"; public static final String ERROR_MSG_ENTERED_MARKS_NOT_COMMA_SEPARATED_INTEGERS = "error.entered.marks.not.comma.separates"; + + public static final String ATTR_SHOW_RESULTS = "showResults"; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== diff -u -r357137c5d97f2317d166b2c8803d057c619bd3e1 -r3badb4923296aa60ac88664390cf74ccc68a7e53 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 357137c5d97f2317d166b2c8803d057c619bd3e1) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 3badb4923296aa60ac88664390cf74ccc68a7e53) @@ -248,64 +248,11 @@ } } - // set scratched flag for display purpose - Collection items = service.getItemsWithIndicatedScratches(toolSessionId); + storeItemsToSessionMap(toolSessionId, scratchie, sessionMap, mode.isTeacher()); - // shuffling items - if (scratchie.isShuffleItems()) { - //items is a Set at this moment - ArrayList shuffledItems = new ArrayList(items); - //use random with a seed so people from the same group get the "same shuffle" - Random randomGenerator = new Random(toolSessionId); - Collections.shuffle(shuffledItems, randomGenerator); - items = shuffledItems; - } - - // for teacher in monitoring display the number of attempt. - if (mode.isTeacher()) { - service.getScratchesOrder(items, toolSessionId); - } - - //display confidence levels - if (scratchie.isConfidenceLevelsEnabled()) { - service.populateItemsWithConfidenceLevels(user.getUserId(), toolSessionId, scratchie.getConfidenceLevelsActivityUiid(), items); - } - - // populate items with the existing burning questions for displaying purposes - List burningQuestions = null; - if (scratchie.isBurningQuestionsEnabled()) { - - burningQuestions = service.getBurningQuestionsBySession(toolSessionId); - for (ScratchieItem item : items) { - - // find corresponding burningQuestion - String question = ""; - for (ScratchieBurningQuestion burningQuestion : burningQuestions) { - if (!burningQuestion.isGeneralQuestion() - && burningQuestion.getScratchieItem().getUid().equals(item.getUid())) { - question = burningQuestion.getQuestion(); - break; - } - } - item.setBurningQuestion(question); - } - - // find general burning question - String generalBurningQuestion = ""; - for (ScratchieBurningQuestion burningQuestion : burningQuestions) { - if (burningQuestion.isGeneralQuestion()) { - generalBurningQuestion = burningQuestion.getQuestion(); - break; - } - } - sessionMap.put(ScratchieConstants.ATTR_GENERAL_BURNING_QUESTION, generalBurningQuestion); - } - + sessionMap.put(ScratchieConstants.ATTR_SCRATCHIE, scratchie); // calculate max score int maxScore = service.getMaxPossibleScore(scratchie); - - sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items); - sessionMap.put(ScratchieConstants.ATTR_SCRATCHIE, scratchie); sessionMap.put(ScratchieConstants.ATTR_MAX_SCORE, maxScore); boolean isScratchingFinished = toolSession.isScratchingFinished(); @@ -319,15 +266,15 @@ redirect.addParameter(AttributeNames.ATTR_MODE, mode); return redirect; - // show results page + // 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); return redirect; - // show learning.jsp page + // show learning.jsp page } else { // time limit feature @@ -381,6 +328,68 @@ } /** + * Stores into session map all data needed to display scratchies and answers + */ + private void storeItemsToSessionMap(Long toolSessionId, Scratchie scratchie, SessionMap sessionMap, + boolean showOrder) { + // set scratched flag for display purpose + Collection items = service.getItemsWithIndicatedScratches(toolSessionId); + + // shuffling items + if (scratchie.isShuffleItems()) { + //items is a Set at this moment + ArrayList shuffledItems = new ArrayList(items); + //use random with a seed so people from the same group get the "same shuffle" + Random randomGenerator = new Random(toolSessionId); + Collections.shuffle(shuffledItems, randomGenerator); + items = shuffledItems; + } + + // for teacher in monitoring display the number of attempt. + if (showOrder) { + service.getScratchesOrder(items, toolSessionId); + } + + //display confidence levels + if (scratchie.isConfidenceLevelsEnabled()) { + service.populateItemsWithConfidenceLevels((Long) sessionMap.get(ScratchieConstants.ATTR_USER_ID), + toolSessionId, scratchie.getConfidenceLevelsActivityUiid(), items); + } + + // populate items with the existing burning questions for displaying purposes + List burningQuestions = null; + if (scratchie.isBurningQuestionsEnabled()) { + + burningQuestions = service.getBurningQuestionsBySession(toolSessionId); + for (ScratchieItem item : items) { + + // find corresponding burningQuestion + String question = ""; + for (ScratchieBurningQuestion burningQuestion : burningQuestions) { + if (!burningQuestion.isGeneralQuestion() + && burningQuestion.getScratchieItem().getUid().equals(item.getUid())) { + question = burningQuestion.getQuestion(); + break; + } + } + item.setBurningQuestion(question); + } + + // find general burning question + String generalBurningQuestion = ""; + for (ScratchieBurningQuestion burningQuestion : burningQuestions) { + if (burningQuestion.isGeneralQuestion()) { + generalBurningQuestion = burningQuestion.getQuestion(); + break; + } + } + sessionMap.put(ScratchieConstants.ATTR_GENERAL_BURNING_QUESTION, generalBurningQuestion); + } + + sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items); + } + + /** * Record in DB that leader has scratched specified answer. And return whether scratchie answer is correct or not. */ private ActionForward recordItemScratched(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -472,9 +481,10 @@ ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId); Scratchie scratchie = toolSession.getScratchie(); Long userUid = (Long) sessionMap.get(ScratchieConstants.ATTR_USER_UID); - + //handle burning questions saving if needed - if (toolSession.isUserGroupLeader(userUid) && scratchie.isBurningQuestionsEnabled() && !toolSession.isScratchingFinished()) { + if (toolSession.isUserGroupLeader(userUid) && scratchie.isBurningQuestionsEnabled() + && !toolSession.isScratchingFinished()) { saveBurningQuestions(request); } @@ -518,9 +528,12 @@ request.setAttribute(ScratchieConstants.ATTR_REFLECTIONS, reflections); } + storeItemsToSessionMap(toolSessionId, scratchie, sessionMap, true); + request.setAttribute(ScratchieConstants.ATTR_SHOW_RESULTS, true); + return mapping.findForward(ScratchieConstants.SUCCESS); } - + /** * Saves newly entered burning question. Used by jqGrid cellediting feature. */ @@ -633,20 +646,20 @@ String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); - final Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - + final Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + // only leader is allowed to submit burning questions ScratchieUser leader = getCurrentUser(sessionId); ScratchieSession toolSession = service.getScratchieSessionBySessionId(sessionId); if (!toolSession.isUserGroupLeader(leader.getUid())) { return null; } - + saveBurningQuestions(request); return null; } - + /** * Saves burning questions entered by user. It also updates its values in SessionMap. */ @@ -662,7 +675,8 @@ for (ScratchieItem item : items) { final Long itemUid = item.getUid(); - final String burningQuestion = request.getParameter(ScratchieConstants.ATTR_BURNING_QUESTION_PREFIX + itemUid); + final String burningQuestion = request + .getParameter(ScratchieConstants.ATTR_BURNING_QUESTION_PREFIX + itemUid); // update question in sessionMap item.setBurningQuestion(burningQuestion); @@ -707,9 +721,10 @@ ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId); Scratchie scratchie = toolSession.getScratchie(); - + //handle burning questions saving if needed - if (toolSession.isUserGroupLeader(userUid) && scratchie.isBurningQuestionsEnabled() && !toolSession.isScratchingFinished()) { + if (toolSession.isUserGroupLeader(userUid) && scratchie.isBurningQuestionsEnabled() + && !toolSession.isScratchingFinished()) { saveBurningQuestions(request); } Index: lams_tool_scratchie/web/pages/learning/questionlist.jsp =================================================================== diff -u -rc33eb1e7a41ae757e5c1f833f1225230e73003b8 -r3badb4923296aa60ac88664390cf74ccc68a7e53 --- lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision c33eb1e7a41ae757e5c1f833f1225230e73003b8) +++ lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision 3badb4923296aa60ac88664390cf74ccc68a7e53) @@ -94,104 +94,10 @@
- -
- -
-
- -
+ + <%@ include file="scratchies.jsp"%> + - - - - - - - - -
- - - - - - - - - - - - - - - - - -
- - ${answer.attemptOrder} - -
-
-
class="answer-with-confidence-level-portrait" - > - - - -
- - -
- - - -
-
- - - -
-
-
-
-
-
-
- ${confidenceLevelDto.level}0% -
-
- -
-
-
-
- - <%-- show burning questions --%> - -
- - - - - -
in"> - -
-
-
- -
- <%-- show general burning question --%>
Index: lams_tool_scratchie/web/pages/learning/results.jsp =================================================================== diff -u -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 -r3badb4923296aa60ac88664390cf74ccc68a7e53 --- lams_tool_scratchie/web/pages/learning/results.jsp (.../results.jsp) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) +++ lams_tool_scratchie/web/pages/learning/results.jsp (.../results.jsp) (revision 3badb4923296aa60ac88664390cf74ccc68a7e53) @@ -261,10 +261,12 @@
- +
+ + <%@ include file="scratchies.jsp"%> Index: lams_tool_scratchie/web/pages/learning/scratchies.jsp =================================================================== diff -u --- lams_tool_scratchie/web/pages/learning/scratchies.jsp (revision 0) +++ lams_tool_scratchie/web/pages/learning/scratchies.jsp (revision 3badb4923296aa60ac88664390cf74ccc68a7e53) @@ -0,0 +1,97 @@ + +
+ +
+
+ +
+ + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
+ + ${answer.attemptOrder} + +
+
+
class="answer-with-confidence-level-portrait" + > + + + +
+ + +
+ + + +
+
+ + + +
+
+
+
+
+
+
+ ${confidenceLevelDto.level}0% +
+
+ +
+
+
+
+ + <%-- show burning questions --%> + +
+ + + + + +
in"> + +
+
+
+ +
\ No newline at end of file