Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/MonitoringUtil.java,v diff -u -r1.20 -r1.21 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 6 Mar 2006 22:51:46 -0000 1.20 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 7 Mar 2006 09:46:32 -0000 1.21 @@ -212,9 +212,11 @@ * @param mcContent * @return List */ - public static List buildGroupsQuestionData(HttpServletRequest request, QaContent qaContent, boolean allUsersData) + public static List buildGroupsQuestionData(HttpServletRequest request, QaContent qaContent, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId) { - logger.debug("allUsersData: " + allUsersData); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE); logger.debug("qaService: " + qaService); @@ -237,8 +239,9 @@ qaMonitoredAnswersDTO.setQuestionUid(qaQueContent.getUid().toString()); qaMonitoredAnswersDTO.setQuestion(qaQueContent.getQuestion()); - logger.debug("using allUsersData to retrieve users data: " + allUsersData); - Map questionAttemptData= buildGroupsAttemptData(request, qaContent, qaQueContent, qaQueContent.getUid().toString(), allUsersData ); + logger.debug("using allUsersData to retrieve users data: " + isUserNamesVisible); + Map questionAttemptData= buildGroupsAttemptData(request, qaContent, qaQueContent, qaQueContent.getUid().toString(), + isUserNamesVisible,isLearnerRequest, currentSessionId); logger.debug("questionAttemptData:..." + questionAttemptData); qaMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); listMonitoredAnswersContainerDTO.add(qaMonitoredAnswersDTO); @@ -250,9 +253,12 @@ } - public static Map buildGroupsAttemptData(HttpServletRequest request, QaContent qaContent, QaQueContent qaQueContent, String questionUid, boolean allUsersData) + public static Map buildGroupsAttemptData(HttpServletRequest request, QaContent qaContent, QaQueContent qaQueContent, String questionUid, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId) { - logger.debug("allUsersData: " + allUsersData); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("currentSessionId: " + currentSessionId); logger.debug("doing buildGroupsAttemptData..."); IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE); @@ -265,25 +271,62 @@ logger.debug("summaryToolSessions: " + summaryToolSessions); Iterator itMap = summaryToolSessions.entrySet().iterator(); - while (itMap.hasNext()) + + + /*request is for monitoring summary */ + if (!isLearnerRequest) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) - { - logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); - QaSession qaSession= qaService.retrieveQaSession(new Long(pairs.getValue().toString()).longValue()); - logger.debug("qaSession: " + " = " + qaSession); - if (qaSession != null) - { - List listUsers=qaService.getUserBySessionOnly(qaSession); - logger.debug("listMcUsers for session id:" + qaSession.getQaSessionId() + " = " + listUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request,qaSession.getQaSessionId(), listUsers, questionUid, allUsersData); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } + while (itMap.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) + { + logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); + QaSession qaSession= qaService.retrieveQaSession(new Long(pairs.getValue().toString()).longValue()); + logger.debug("qaSession: " + " = " + qaSession); + if (qaSession != null) + { + List listUsers=qaService.getUserBySessionOnly(qaSession); + logger.debug("listMcUsers for session id:" + qaSession.getQaSessionId() + " = " + listUsers); + Map sessionUsersAttempts=populateSessionUsersAttempts(request,qaSession.getQaSessionId(), listUsers, questionUid, + isUserNamesVisible, isLearnerRequest); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } + else + { + /*request is for learner report, use only the passed tool session in the report*/ + logger.debug("using currentSessionId for the learner report:" + currentSessionId); + while (itMap.hasNext()) + { + Map.Entry pairs = (Map.Entry)itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) + { + logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); + + if (currentSessionId.equals(pairs.getValue())) + { + logger.debug("only using this tool session for the learner report: " + " = " + pairs.getValue()); + QaSession qaSession= qaService.retrieveQaSession(new Long(pairs.getValue().toString()).longValue()); + logger.debug("qaSession: " + " = " + qaSession); + if (qaSession != null) + { + List listUsers=qaService.getUserBySessionOnly(qaSession); + logger.debug("listMcUsers for session id:" + qaSession.getQaSessionId() + " = " + listUsers); + Map sessionUsersAttempts=populateSessionUsersAttempts(request,qaSession.getQaSessionId(), listUsers, questionUid, + isUserNamesVisible, isLearnerRequest); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } + } logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); mapMonitoredAttemptsContainerDTO=convertToMap(listMonitoredAttemptsContainerDTO); @@ -300,9 +343,11 @@ * @param listUsers * @return List */ - public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listUsers, String questionUid, boolean allUsersData) + public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listUsers, String questionUid, + boolean isUserNamesVisible, boolean isLearnerRequest) { - logger.debug("allUsersData: " + allUsersData); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); logger.debug("doing populateSessionUsersAttempts..."); IQaService qaService = (IQaService)request.getSession().getAttribute(TOOL_SERVICE); @@ -313,8 +358,9 @@ Iterator itUsers=listUsers.iterator(); - if (allUsersData) + if ((isUserNamesVisible) && (!isLearnerRequest)) { + logger.debug("isUserNamesVisible true, isLearnerRequest false" ); logger.debug("getting alll the user' data"); while (itUsers.hasNext()) { @@ -350,41 +396,103 @@ } } } - else + else if ((isUserNamesVisible) && (isLearnerRequest)) { - logger.debug("getting only current user's data" ); + logger.debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session" ); + logger.debug("isUserNamesVisible true, isLearnerRequest true" ); String userID= (String)request.getSession().getAttribute(USER_ID); logger.debug("userID: " + userID); QaQueUsr qaQueUsr=qaService.getQaQueUsrById(new Long(userID).longValue()); logger.debug("the current user qaQueUsr " + qaQueUsr + " and username: " + qaQueUsr.getUsername()); - - if (qaQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + qaQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=qaService.getAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - QaUsrResp qaUsrResp=(QaUsrResp)itAttempts.next(); - logger.debug("qaUsrResp: " + qaUsrResp); - - if (qaUsrResp != null) - { - QaMonitoredUserDTO qaMonitoredUserDTO = new QaMonitoredUserDTO(); - qaMonitoredUserDTO.setAttemptTime(qaUsrResp.getAttemptTime().toString()); - qaMonitoredUserDTO.setTimeZone(qaUsrResp.getTimezone()); - qaMonitoredUserDTO.setUid(qaUsrResp.getResponseId().toString()); - qaMonitoredUserDTO.setUserName(qaQueUsr.getUsername()); - qaMonitoredUserDTO.setQueUsrId(qaQueUsr.getUid().toString()); - qaMonitoredUserDTO.setSessionId(sessionId.toString()); - qaMonitoredUserDTO.setResponse(qaUsrResp.getAnswer()); - qaMonitoredUserDTO.setQuestionUid(questionUid); - listMonitoredUserContainerDTO.add(qaMonitoredUserDTO); - } - } + + while (itUsers.hasNext()) + { + qaQueUsr=(QaQueUsr)itUsers.next(); + logger.debug("qaQueUsr: " + qaQueUsr); + + if (qaQueUsr != null) + { + logger.debug("getting listUserAttempts for user id: " + qaQueUsr.getUid() + " and que content id: " + questionUid); + List listUserAttempts=qaService.getAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts=listUserAttempts.iterator(); + while (itAttempts.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)itAttempts.next(); + logger.debug("qaUsrResp: " + qaUsrResp); + + if (qaUsrResp != null) + { + QaMonitoredUserDTO qaMonitoredUserDTO = new QaMonitoredUserDTO(); + qaMonitoredUserDTO.setAttemptTime(qaUsrResp.getAttemptTime().toString()); + qaMonitoredUserDTO.setTimeZone(qaUsrResp.getTimezone()); + qaMonitoredUserDTO.setUid(qaUsrResp.getResponseId().toString()); + qaMonitoredUserDTO.setUserName(qaQueUsr.getUsername()); + qaMonitoredUserDTO.setQueUsrId(qaQueUsr.getUid().toString()); + qaMonitoredUserDTO.setSessionId(sessionId.toString()); + qaMonitoredUserDTO.setResponse(qaUsrResp.getAnswer()); + qaMonitoredUserDTO.setQuestionUid(questionUid); + listMonitoredUserContainerDTO.add(qaMonitoredUserDTO); + } + } + } + } } + else if ((!isUserNamesVisible) && (isLearnerRequest)) + { + logger.debug("populating data normally exception are for a specific session and other user names are not visible."); + logger.debug("isUserNamesVisible false, isLearnerRequest true" ); + logger.debug("getting only current user's data" ); + String userID= (String)request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); + + while (itUsers.hasNext()) + { + QaQueUsr qaQueUsr=(QaQueUsr)itUsers.next(); + logger.debug("qaQueUsr: " + qaQueUsr); + + if (qaQueUsr != null) + { + logger.debug("getting listUserAttempts for user id: " + qaQueUsr.getUid() + " and que content id: " + questionUid); + List listUserAttempts=qaService.getAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts=listUserAttempts.iterator(); + while (itAttempts.hasNext()) + { + QaUsrResp qaUsrResp=(QaUsrResp)itAttempts.next(); + logger.debug("qaUsrResp: " + qaUsrResp); + + if (qaUsrResp != null) + { + QaMonitoredUserDTO qaMonitoredUserDTO = new QaMonitoredUserDTO(); + qaMonitoredUserDTO.setAttemptTime(qaUsrResp.getAttemptTime().toString()); + qaMonitoredUserDTO.setTimeZone(qaUsrResp.getTimezone()); + qaMonitoredUserDTO.setUid(qaUsrResp.getResponseId().toString()); + + logger.debug("userID versus queUsrId: " + userID + "-" + qaQueUsr.getQueUsrId()); + if (userID.equals(qaQueUsr.getQueUsrId().toString())) + { + logger.debug("this is current user, put his name normally."); + qaMonitoredUserDTO.setUserName(qaQueUsr.getUsername()); + } + else + { + logger.debug("this is not current user, put his name as blank."); + qaMonitoredUserDTO.setUserName("[ ]"); + } + + qaMonitoredUserDTO.setQueUsrId(qaQueUsr.getUid().toString()); + qaMonitoredUserDTO.setSessionId(sessionId.toString()); + qaMonitoredUserDTO.setResponse(qaUsrResp.getAnswer()); + qaMonitoredUserDTO.setQuestionUid(questionUid); + listMonitoredUserContainerDTO.add(qaMonitoredUserDTO); + } + } + } + } + } logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QAction.java,v diff -u -r1.32 -r1.33 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 6 Mar 2006 22:51:46 -0000 1.32 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 7 Mar 2006 09:46:32 -0000 1.33 @@ -50,6 +50,7 @@ import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaComparator; import org.lamsfoundation.lams.tool.qa.QaContent; +import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaUploadedFile; import org.lamsfoundation.lams.tool.qa.QaUtils; import org.lamsfoundation.lams.tool.qa.service.IQaService; @@ -568,32 +569,29 @@ QaContent qaContent=qaService.loadQa(toolContentID.longValue()); logger.debug("qaContent: " + qaContent); - Boolean isUserNamesVisible=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE); - logger.debug("isUserNamesVisible: " + isUserNamesVisible); + + String userID= (String)request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); + QaQueUsr qaQueUsr=qaService.getQaQueUsrById(new Long(userID).longValue()); + logger.debug("the current user qaQueUsr " + qaQueUsr + " and username: " + qaQueUsr.getUsername()); + logger.debug("the current user qaQueUsr's session " + qaQueUsr.getQaSession()); + String currentSessionId=qaQueUsr.getQaSession().getQaSessionId().toString(); + logger.debug("the current user SessionId " + currentSessionId); + + Boolean isUserNamesVisibleBoolean=(Boolean)request.getSession().getAttribute(IS_USERNAME_VISIBLE); + boolean isUserNamesVisible=isUserNamesVisibleBoolean.booleanValue(); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); - if (isUserNamesVisible.booleanValue()) - { - /*the report should have all the users' entries*/ - logger.debug("refreshing summary data for all..."); - qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, true); - } - else - { - /*the report should have only this user's entries*/ - logger.debug("refreshing summary data ..."); - qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, false); - } - + /*the report should have all the users' entries OR + * the report should have only the current session's entries*/ + qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, isUserNamesVisible, true, currentSessionId); + request.getSession().setAttribute(REQUEST_LEARNING_REPORT, new Boolean(true).toString()); logger.debug("fwd'ing to." + LEARNER_REPORT); return (mapping.findForward(LEARNER_REPORT)); } - /* - * Simulate learner leaving the current tool session. This will normally gets called by the container by - * leaveToolSession(toolSessionId, user) - */ else if (qaLearningForm.getEndLearning() != null) { endLearning(request, qaService, response); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java,v diff -u -r1.21 -r1.22 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 6 Mar 2006 22:51:46 -0000 1.21 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 7 Mar 2006 09:46:32 -0000 1.22 @@ -388,12 +388,14 @@ QaContent qaContent=qaService.loadQa(toolContentId.longValue()); logger.debug("existing qaContent:" + qaContent); - List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, qaContent, true); + List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, qaContent, true, false, null); request.getSession().setAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO, listMonitoredAnswersContainerDTO); logger.debug("LIST_MONITORED_ANSWERS_CONTAINER_DTO: " + request.getSession().getAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO)); } + + public ActionForward doneMonitoring(ActionMapping mapping, ActionForm form, HttpServletRequest request, @@ -479,10 +481,12 @@ return null; } - public void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService, boolean allUsersData) + public void refreshSummaryData(HttpServletRequest request, QaContent qaContent, IQaService qaService, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId) { - logger.debug("allUsersData: " + allUsersData); - + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + /* this section is related to summary tab. Starts here. */ Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, qaContent, qaService); logger.debug("summaryToolSessions: " + summaryToolSessions); @@ -508,8 +512,9 @@ logger.debug("CURRENT_MONITORED_TOOL_SESSION: " + request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION)); - logger.debug("using allUsersData to retrieve data: " + allUsersData); - List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, qaContent, allUsersData); + logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible); + List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, qaContent, + isUserNamesVisible, isLearnerRequest, currentSessionId); request.getSession().setAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO, listMonitoredAnswersContainerDTO); logger.debug("LIST_MONITORED_ANSWERS_CONTAINER_DTO: " + request.getSession().getAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO)); /* ends here. */ Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java,v diff -u -r1.25 -r1.26 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 6 Mar 2006 22:51:46 -0000 1.25 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java 7 Mar 2006 09:46:32 -0000 1.26 @@ -106,7 +106,7 @@ QaMonitoringAction qaMonitoringAction= new QaMonitoringAction(); logger.debug("refreshing summary data..."); - qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, true); + qaMonitoringAction.refreshSummaryData(request, qaContent, qaService, true, false, null); logger.debug("refreshing stats data..."); qaMonitoringAction.refreshStatsData(request);