Index: lams_tool_sbmt/conf/language/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/conf/language/Attic/ApplicationResources.properties,v diff -u -r1.11 -r1.12 --- lams_tool_sbmt/conf/language/ApplicationResources.properties 1 Aug 2006 07:10:12 -0000 1.11 +++ lams_tool_sbmt/conf/language/ApplicationResources.properties 2 Aug 2006 01:08:47 -0000 1.12 @@ -108,4 +108,4 @@ label.no.user.available =No user available #======= End labels: Exported 100 labels for en AU ===== -msg.mark.released=Marks have been released. +msg.mark.released=Marks in {0} have been released. Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java,v diff -u -r1.30 -r1.31 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java 1 Aug 2006 07:10:12 -0000 1.30 +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java 2 Aug 2006 01:08:47 -0000 1.31 @@ -83,12 +83,26 @@ * * @struts.action-forward name="success" path="/monitoring/monitoring.jsp" * + * @struts.action-forward name="statistic" path="/monitoring/parts/statisticpart.jsp" + * */ public class MonitoringAction extends LamsDispatchAction { public ISubmitFilesService submitFilesService; + private class SessionComparator implements Comparator{ + public int compare(SessionDTO o1, SessionDTO o2) { + if(o1 != null && o2 != null){ + int c = o1.getSessionName().compareTo(o2.getSessionName()); + //to ensure session can be put into map even they have duplicated name. + return c==0?1:c; + }else if(o1 != null) + return 1; + else + return -1; + } + } /** * Default ActionForward for Monitor */ @@ -103,75 +117,9 @@ // List userList = submitFilesService.getUsers(sessionID); List submitFilesSessionList = submitFilesService.getSubmitFilesSessionByContentID(contentID); - Map sessionUserMap = new TreeMap(new Comparator(){ - public int compare(SessionDTO o1, SessionDTO o2) { - if(o1 != null && o2 != null){ - int c = o1.getSessionName().compareTo(o2.getSessionName()); - //to ensure session can be put into map even they have duplicated name. - return c==0?1:c; - }else if(o1 != null) - return 1; - else - return -1; - } - - }); - - //build a map with all users in the submitFilesSessionList - Iterator it = submitFilesSessionList.iterator(); - while(it.hasNext()){ - SessionDTO sessionDto = new SessionDTO(); - SubmitFilesSession sfs = (SubmitFilesSession)it.next(); - - Long sessionID = sfs.getSessionID(); - sessionDto.setSessionID(sessionID); - sessionDto.setSessionName(sfs.getSessionName()); - List userList = submitFilesService.getUsers(sessionID); - sessionUserMap.put(sessionDto, userList); - } - - //request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); - request.setAttribute("sessionUserMap",sessionUserMap); + summary(request, submitFilesSessionList); + statistic(request, submitFilesSessionList); - Map sessionStatisticMap = new HashMap(); - - // build a map with all users in the submitFilesSessionList - it = submitFilesSessionList.iterator(); - while (it.hasNext()) { - - SubmitFilesSession sfs = (SubmitFilesSession) it.next(); - Long sessionID = sfs.getSessionID(); - String sessionName = sfs.getSessionName(); - - //return FileDetailsDTO list according to the given sessionID - Map userFilesMap = submitFilesService.getFilesUploadedBySession(sessionID); - Iterator iter = userFilesMap.values().iterator(); - Iterator dtoIter; - int notMarkedCount = 0; - int markedCount = 0; - while(iter.hasNext()){ - List list = (List) iter.next(); - dtoIter = list.iterator(); - while(dtoIter.hasNext()){ - FileDetailsDTO dto = (FileDetailsDTO) dtoIter.next(); - if(dto.getMarks() == null) - notMarkedCount++; - else - markedCount++; - } - } - StatisticDTO statisticDto = new StatisticDTO(); - SessionDTO sessionDto = new SessionDTO(); - statisticDto.setMarkedCount(markedCount); - statisticDto.setNotMarkedCount(notMarkedCount); - statisticDto.setTotalUploadedFiles(markedCount+notMarkedCount); - sessionDto.setSessionID(sessionID); - sessionDto.setSessionName(sessionName); - sessionStatisticMap.put(sessionDto,statisticDto); - } - - request.setAttribute("statisticList",sessionStatisticMap); - //instruction SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(contentID); //if this content does not exist, then reset the contentID to current value to keep it on HTML page. @@ -183,8 +131,30 @@ return mapping.findForward("success"); } - - + /** + * AJAX call to refresh statisitic page. + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward doStatistic( + ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + { + Long contentID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + submitFilesService = getSubmitFilesService(); + +// List userList = submitFilesService.getUsers(sessionID); + List submitFilesSessionList = submitFilesService.getSubmitFilesSessionByContentID(contentID); + statistic(request, submitFilesSessionList); + + return mapping.findForward("statistic"); + + } /** * Release mark * @param mapping @@ -202,10 +172,13 @@ submitFilesService = getSubmitFilesService(); Long sessionID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_SESSION_ID)); submitFilesService.releaseMarksForSession(sessionID); - try { PrintWriter out = response.getWriter(); - out.write(getMessageService().getMessage("msg.mark.released")); + SubmitFilesSession session = submitFilesService.getSessionById(sessionID); + String sessionName = ""; + if(session != null) + sessionName = session.getSessionName(); + out.write(getMessageService().getMessage("msg.mark.released",new String[]{sessionName})); out.flush(); } catch (IOException e) { } @@ -398,9 +371,12 @@ if(!errors.isEmpty()){ setMarkPage(request, sessionID, userID, detailID, updateMode); //to echo back to error page. - FileDetailsDTO details = (FileDetailsDTO) request.getAttribute("report"); - if(details != null) - details.setComments(comments); + List list = (List) request.getAttribute("report"); + if(list != null){ + FileDetailsDTO details = list.get(0); + if(details != null) + details.setComments(comments); + } saveErrors(request,errors); return mapping.findForward("updateMark"); } @@ -461,7 +437,15 @@ private MessageService getMessageService() { WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); return (MessageService) wac.getBean("sbmtMessageService"); - } + } + /** + * Save file mark information into HttpRequest + * @param request + * @param sessionID + * @param userID + * @param detailID + * @param updateMode + */ private void setMarkPage(HttpServletRequest request, Long sessionID, Long userID, Long detailID, String updateMode) { submitFilesService = getSubmitFilesService(); @@ -471,4 +455,75 @@ request.setAttribute("report",report); request.setAttribute("updateMode", updateMode); } + /** + * Save statistic information into request + * @param request + * @param submitFilesSessionList + */ + private void statistic(HttpServletRequest request, List submitFilesSessionList) { + Iterator it; + Map sessionStatisticMap = new TreeMap(this.new SessionComparator()); + + // build a map with all users in the submitFilesSessionList + it = submitFilesSessionList.iterator(); + while (it.hasNext()) { + + SubmitFilesSession sfs = (SubmitFilesSession) it.next(); + Long sessionID = sfs.getSessionID(); + String sessionName = sfs.getSessionName(); + + //return FileDetailsDTO list according to the given sessionID + Map userFilesMap = submitFilesService.getFilesUploadedBySession(sessionID); + Iterator iter = userFilesMap.values().iterator(); + Iterator dtoIter; + int notMarkedCount = 0; + int markedCount = 0; + while(iter.hasNext()){ + List list = (List) iter.next(); + dtoIter = list.iterator(); + while(dtoIter.hasNext()){ + FileDetailsDTO dto = (FileDetailsDTO) dtoIter.next(); + if(dto.getMarks() == null) + notMarkedCount++; + else + markedCount++; + } + } + StatisticDTO statisticDto = new StatisticDTO(); + SessionDTO sessionDto = new SessionDTO(); + statisticDto.setMarkedCount(markedCount); + statisticDto.setNotMarkedCount(notMarkedCount); + statisticDto.setTotalUploadedFiles(markedCount+notMarkedCount); + sessionDto.setSessionID(sessionID); + sessionDto.setSessionName(sessionName); + sessionStatisticMap.put(sessionDto,statisticDto); + } + + request.setAttribute("statisticList",sessionStatisticMap); + } + /** + * Save Summary information into HttpRequest. + * @param request + * @param submitFilesSessionList + */ + private void summary(HttpServletRequest request, List submitFilesSessionList) { + Map sessionUserMap = new TreeMap(this.new SessionComparator()); + + //build a map with all users in the submitFilesSessionList + Iterator it = submitFilesSessionList.iterator(); + while(it.hasNext()){ + SessionDTO sessionDto = new SessionDTO(); + SubmitFilesSession sfs = (SubmitFilesSession)it.next(); + + Long sessionID = sfs.getSessionID(); + sessionDto.setSessionID(sessionID); + sessionDto.setSessionName(sfs.getSessionName()); + List userList = submitFilesService.getUsers(sessionID); + sessionUserMap.put(sessionDto, userList); + } + + //request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); + request.setAttribute("sessionUserMap",sessionUserMap); + } + } Index: lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.31 -r1.32 --- lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml 1 Aug 2006 07:10:12 -0000 1.31 +++ lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml 2 Aug 2006 01:08:47 -0000 1.32 @@ -140,6 +140,11 @@ path="/monitoring/monitoring.jsp" redirect="false" /> + "; + var reqIDVar = new Date(); + var param = "method=doStatistic&toolContentID=" + ${param.toolContentID} +"&reqID="+reqIDVar.getTime(); + messageLoading(); + var myAjax = new Ajax.Updater( + statisticTargetDiv, + url, + { + method:'get', + parameters:param, + onComplete:messageComplete, + evalScripts:true + } + ); + + } + + function showBusy(targetDiv){ + if($(targetDiv+"_Busy") != null){ + Element.show(targetDiv+"_Busy"); + } + } + function hideBusy(targetDiv){ + if($(targetDiv+"_Busy") != null){ + Element.hide(targetDiv+"_Busy"); + } + } + function messageLoading(){ + showBusy(statisticTargetDiv); + } + function messageComplete(){ + hideBusy(statisticTargetDiv); + } Index: lams_tool_sbmt/web/monitoring/parts/statistic.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/web/monitoring/parts/statistic.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_sbmt/web/monitoring/parts/statistic.jsp 1 Aug 2006 07:10:12 -0000 1.1 +++ lams_tool_sbmt/web/monitoring/parts/statistic.jsp 2 Aug 2006 01:08:46 -0000 1.2 @@ -1,37 +1,5 @@ <%@ include file="/common/taglibs.jsp"%> - - - - - - - - - - - - - - - - - - - - -
- : -
- - - -
- - - -
- - - -
-
+ +
+ <%@ include file="statisticpart.jsp"%> +
\ No newline at end of file Index: lams_tool_sbmt/web/monitoring/parts/statisticpart.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_sbmt/web/monitoring/parts/statisticpart.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_sbmt/web/monitoring/parts/statisticpart.jsp 2 Aug 2006 01:08:46 -0000 1.1 @@ -0,0 +1,37 @@ +<%-- This is for AJAX call to refresh statistic page --%> +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + + + + + + + + + + + + +
+ : +
+ + + +
+ + + +
+ + + +
+
\ No newline at end of file