Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/gradeBookApplicationContext.xml =================================================================== diff -u -ra8e4961c9f59aedf7bbc548462f658ecc539d0ca -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/gradeBookApplicationContext.xml (.../gradeBookApplicationContext.xml) (revision a8e4961c9f59aedf7bbc548462f658ecc539d0ca) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/gradeBookApplicationContext.xml (.../gradeBookApplicationContext.xml) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -9,22 +9,26 @@ + - - PROPAGATION_REQUIRED + + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED + PROPAGATION_REQUIRED PROPAGATION_REQUIRED - PROPAGATION_REQUIRED - PROPAGATION_REQUIRED - PROPAGATION_REQUIRED - PROPAGATION_REQUIRED Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/service/GradeBookService.java =================================================================== diff -u -ra0a70e62ee929b8c7e0529da783a2f232b193a2f -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/service/GradeBookService.java (.../GradeBookService.java) (revision a0a70e62ee929b8c7e0529da783a2f232b193a2f) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/service/GradeBookService.java (.../GradeBookService.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -34,19 +34,22 @@ import org.lamsfoundation.lams.gradebook.GradeBookUserLesson; import org.lamsfoundation.lams.gradebook.dao.IGradeBookDAO; import org.lamsfoundation.lams.gradebook.dto.GBActivityGridRowDTO; +import org.lamsfoundation.lams.gradebook.dto.GBLessonGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GBUserGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GradeBookGridRowDTO; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.learningdesign.CompetenceMapping; import org.lamsfoundation.lams.learningdesign.ToolActivity; import org.lamsfoundation.lams.lesson.LearnerProgress; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.monitoring.service.IMonitoringService; import org.lamsfoundation.lams.tool.OutputType; import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.ToolOutputDefinition; import org.lamsfoundation.lams.tool.ToolSession; import org.lamsfoundation.lams.tool.service.ILamsCoreToolService; +import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; @@ -62,12 +65,11 @@ private static Logger logger = Logger.getLogger(GradeBookService.class); - private static final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images"; - // Services private IMonitoringService monitoringService; private ILamsCoreToolService toolService; private IGradeBookDAO gradeBookDAO; + private ILessonService lessonService; /** * @see org.lamsfoundation.lams.gradebook.service.IGradeBookService#getGBActivityRowsForLearner(org.lamsfoundation.lams.lesson.Lesson, @@ -332,6 +334,51 @@ } /** + * @see org.lamsfoundation.lams.gradebook.service.IGradeBookService#getGBLessonRows(org.lamsfoundation.lams.usermanagement.Organisation) + */ + @SuppressWarnings("unchecked") + public List getGBLessonRows(Organisation organisation, User user) { + List lessonRows = new ArrayList(); + + if (organisation != null) { + + List lessons = lessonService.getLessonsByGroupAndUser(user.getUserId(), organisation + .getOrganisationId()); + if (lessons != null) { + + for (Lesson lesson : lessons) { + if (lesson.getLessonClass().isStaffMember(user)) { + GBLessonGridRowDTO lessonRow = new GBLessonGridRowDTO(); + lessonRow.setLessonName(lesson.getLessonName()); + lessonRow.setLessonId(lesson.getLessonId()); + lessonRow.setLessonDescription(lesson.getLessonDescription()); + lessonRow.setMark(gradeBookDAO.getAverageMarkForLesson(lesson.getLessonId())); + + + String gbMonURL = Configuration.get(ConfigurationKeys.SERVER_URL) + + "gradebook/gradebookMonitoring.do?lessonID=" + lesson.getLessonId().toString(); + + lessonRow.setGradeBookMonitorURL(gbMonURL); + if (lesson.getOrganisation().getOrganisationId() != organisation.getOrganisationId()) { + lessonRow.setSubGroup(lesson.getOrganisation().getName()); + } else { + lessonRow.setSubGroup("-"); + } + + lessonRows.add(lessonRow); + + } + } + } + + } else { + logger.error("Request for gradebook grid with a null organisation"); + } + + return lessonRows; + } + + /** * Adds a mark to the aggregated total and saves it * * @param gradeBookUserLesson @@ -472,6 +519,7 @@ private String getLessonStatusStr(LearnerProgress learnerProgress) { String status = "-"; + final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images"; if (learnerProgress != null) { if (learnerProgress.isComplete()) { status = ""; @@ -492,6 +540,7 @@ */ private String getActivityStatusStr(LearnerProgress learnerProgress, Activity activity) { + final String IMAGES_DIR = Configuration.get(ConfigurationKeys.SERVER_URL) + "images"; if (learnerProgress != null) { byte statusByte = learnerProgress.getProgressState(activity); if (statusByte == LearnerProgress.ACTIVITY_ATTEMPTED) { @@ -588,5 +637,12 @@ this.gradeBookDAO = gradeBookDAO; } + public ILessonService getLessonService() { + return lessonService; + } + + public void setLessonService(ILessonService lessonService) { + this.lessonService = lessonService; + } // ------------------------------------------------------------------------- } Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/service/IGradeBookService.java =================================================================== diff -u -rf2d64fc903d09f04b37223c41e8d5a18fa0d35eb -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/service/IGradeBookService.java (.../IGradeBookService.java) (revision f2d64fc903d09f04b37223c41e8d5a18fa0d35eb) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/service/IGradeBookService.java (.../IGradeBookService.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -25,10 +25,12 @@ import java.util.List; +import org.lamsfoundation.lams.gradebook.dto.GBLessonGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GBUserGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GradeBookGridRowDTO; import org.lamsfoundation.lams.learningdesign.Activity; import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; public interface IGradeBookService { @@ -111,5 +113,13 @@ */ public void updateUserLessonGradeBookFeedback(Lesson lesson, User learner, String feedback); + /** + * Gets the lesson row dtos for a given organisation + * + * @param organisation + * @return + */ + public List getGBLessonRows(Organisation organisation, User user); + } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/util/GradeBookUtil.java =================================================================== diff -u -rf4328ca969294c06bf12815f299236c17398c99c -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/util/GradeBookUtil.java (.../GradeBookUtil.java) (revision f4328ca969294c06bf12815f299236c17398c99c) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/util/GradeBookUtil.java (.../GradeBookUtil.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -43,11 +43,8 @@ public class GradeBookUtil { - public static final int GRID_TYPE_MONITOR_USER_VIEW = 0; - public static final int GRID_TYPE_MONITOR_ACTIVITY_VIEW = 1; - @SuppressWarnings("unchecked") - public static String toGridXML(Collection gridRows, int page, int totalPages, int gridType) { + public static String toGridXML(Collection gridRows, int page, int totalPages, String view) { String xml = ""; try { Document document = getDocument(); @@ -75,16 +72,9 @@ // Work out which grid we want to put the data into ArrayList gridRowStringArray = new ArrayList(); - switch (gridType) { - case GRID_TYPE_MONITOR_USER_VIEW: - gridRowStringArray = gridRow.toMonitorUserViewStringArray(); - break; - case GRID_TYPE_MONITOR_ACTIVITY_VIEW: - gridRowStringArray = gridRow.toMonitorActViewStringArray(); - break; - } - + gridRowStringArray = gridRow.toStringArray(view); + for (String gradeBookItem : gridRowStringArray) { Element cellElement = document.createElement("cell"); gradeBookItem = (gradeBookItem != null) ? gradeBookItem : ""; Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookAction.java =================================================================== diff -u -ra0a70e62ee929b8c7e0529da783a2f232b193a2f -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookAction.java (.../GradeBookAction.java) (revision a0a70e62ee929b8c7e0529da783a2f232b193a2f) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookAction.java (.../GradeBookAction.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -27,8 +27,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Set; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -37,8 +37,11 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.gradebook.dto.GBLessonGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GBUserGridRowDTO; import org.lamsfoundation.lams.gradebook.dto.GradeBookGridRowDTO; +import org.lamsfoundation.lams.gradebook.dto.comparators.GBLessonMarkComparator; +import org.lamsfoundation.lams.gradebook.dto.comparators.GBLessonNameComparator; import org.lamsfoundation.lams.gradebook.dto.comparators.GBUserFullNameComparator; import org.lamsfoundation.lams.gradebook.dto.comparators.GBUserMarkComparator; import org.lamsfoundation.lams.gradebook.service.IGradeBookService; @@ -48,13 +51,15 @@ import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.monitoring.service.IMonitoringService; +import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -154,14 +159,7 @@ } - String ret = ""; - if (method.equals("userView")) { - ret = GradeBookUtil.toGridXML(gradeBookActivityDTOs, page, rowLimit, - GradeBookUtil.GRID_TYPE_MONITOR_USER_VIEW); - } else if (method.equals("activityView")) { - ret = GradeBookUtil.toGridXML(gradeBookActivityDTOs, page, totalPages, - GradeBookUtil.GRID_TYPE_MONITOR_ACTIVITY_VIEW); - } + String ret = GradeBookUtil.toGridXML(gradeBookActivityDTOs, page, rowLimit, method); response.setContentType("text/xml"); PrintWriter out = response.getWriter(); @@ -176,14 +174,17 @@ /** * Returns an xml representation of the user grid for gradebook * - * This has two modes, userView and activityView + * This has three modes: userView, activityView and courseMonitorView * * User view will get all the learners in a lesson and print their gradebook - * data with their mark for the entire lesson] + * data with their mark for the entire lesson * * Activity view will take an extra parameter (activityID) and instead show * the user's mark just for one activity * + * Course monitor view gets the same as the user view, but the link is set + * to the lesson level gradebook instead of learner + * * @param mapping * @param form * @param request @@ -210,7 +211,7 @@ // Get the user gradebook list from the db List gradeBookUserDTOs = new ArrayList(); - if (method.equals("userView")) { + if (method.equals("userView") || method.equals("courseMonitorView")) { gradeBookUserDTOs = gradeBookService.getGBUserRowsForLesson(lesson); } else if (method.equals("activityView")) { Long activityID = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); @@ -245,8 +246,7 @@ String searchString = WebUtil.readStrParam(request, "searchString"); gradeBookUserDTOs = doUserSearch(gradeBookUserDTOs, searchField, searchOper, searchString.toLowerCase()); } - - + // Reverse the order if requested if (sortOrder != null && sortOrder.equals("desc")) { Collections.reverse(gradeBookUserDTOs); @@ -269,16 +269,8 @@ } - String ret = ""; + String ret = GradeBookUtil.toGridXML(gradeBookUserDTOs, page, totalPages, method); - if (method.equals("userView")) { - ret = GradeBookUtil.toGridXML(gradeBookUserDTOs, page, totalPages, - GradeBookUtil.GRID_TYPE_MONITOR_USER_VIEW); - } else if (method.equals("activityView")) { - ret = GradeBookUtil.toGridXML(gradeBookUserDTOs, page, totalPages, - GradeBookUtil.GRID_TYPE_MONITOR_ACTIVITY_VIEW); - } - response.setContentType("text/xml"); PrintWriter out = response.getWriter(); out.print(ret); @@ -289,81 +281,241 @@ return null; } + /** + * Returns an xml representation of the lesson grid for a course for + * gradebook + * + * This has two modes, learnerView and monitorView + * + * Learner view will get the data specific to one user + * + * Monitor will get the data average for whole lessons + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public ActionForward getCourseGridData(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + initServices(); + int page = WebUtil.readIntParam(request, GradeBookConstants.PARAM_PAGE); + int rowLimit = WebUtil.readIntParam(request, GradeBookConstants.PARAM_ROWS); + String sortOrder = WebUtil.readStrParam(request, GradeBookConstants.PARAM_SORD); + String sortBy = WebUtil.readStrParam(request, GradeBookConstants.PARAM_SIDX, true); + Boolean isSearch = WebUtil.readBooleanParam(request, "_search"); + String method = WebUtil.readStrParam(request, "method"); + + User user = getRealUser(); + + Integer courseID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); + Organisation organisation = (Organisation) userService.findById(Organisation.class, courseID); + + if (organisation != null && user != null) { + + Set lessons = (Set) organisation.getLessons(); + if (lessons != null) { + + List gradeBookLessonDTOs = new ArrayList(); + + gradeBookLessonDTOs = gradeBookService.getGBLessonRows(organisation, user); + + // if it is a search fix up the set + if (isSearch) { + String searchField = WebUtil.readStrParam(request, "searchField"); + String searchOper = WebUtil.readStrParam(request, "searchOper"); + String searchString = WebUtil.readStrParam(request, "searchString"); + gradeBookLessonDTOs = doLessonSearch(gradeBookLessonDTOs, searchField, searchOper, searchString + .toLowerCase()); + } + + // Sort the list appropriately + if (sortBy != null) { + if (sortBy.equals("lessonName")) { + Collections.sort(gradeBookLessonDTOs, new GBLessonNameComparator()); + } else if (sortBy.equals("mark")) { + Collections.sort(gradeBookLessonDTOs, new GBLessonMarkComparator()); + } else { + Collections.sort(gradeBookLessonDTOs, new GBLessonNameComparator()); + } + } else { + Collections.sort(gradeBookLessonDTOs, new GBLessonNameComparator()); + } + + // Reverse the order if requested + if (sortOrder != null && sortOrder.equals("desc")) { + Collections.reverse(gradeBookLessonDTOs); + } + + // Work out the sublist to fetch based on rowlimit and current page. + int totalPages = 1; + if (rowLimit < gradeBookLessonDTOs.size()) { + + totalPages = new Double(Math.ceil(new Integer(gradeBookLessonDTOs.size()).doubleValue() + / new Integer(rowLimit).doubleValue())).intValue(); + + int firstRow = (page - 1) * rowLimit; + int lastRow = firstRow + rowLimit; + + if (lastRow > gradeBookLessonDTOs.size()) { + gradeBookLessonDTOs = gradeBookLessonDTOs.subList(firstRow, gradeBookLessonDTOs.size()); + } else { + gradeBookLessonDTOs = gradeBookLessonDTOs.subList(firstRow, lastRow); + } + + } + + String ret = GradeBookUtil.toGridXML(gradeBookLessonDTOs, page, totalPages, method); + + response.setContentType("text/xml"); + PrintWriter out = response.getWriter(); + out.print(ret); + + } + + } else { + // Grid will handle error, just log and return null + logger.error("Error: request for course gradebook data with null user or course. CourseID: " + courseID); + } + + return null; + } + private List doUserSearch(List gradeBookUserDTOs, String searchField, String searchOper, String searchString) { List ret = new ArrayList(); - - if (searchField.equals("fullName")){ + + if (searchField.equals("fullName")) { for (GBUserGridRowDTO userRow : gradeBookUserDTOs) { - + String fullName = userRow.getLastName() + " " + userRow.getFirstName(); fullName = fullName.toLowerCase(); - + if (searchOper.equals("eq")) { if (fullName.equals(searchString)) { ret.add(userRow); } - } else if (searchOper.equals("ne")){ + } else if (searchOper.equals("ne")) { if (!fullName.equals(searchString)) { ret.add(userRow); - } - } else if (searchOper.equals("bw")){ + } + } else if (searchOper.equals("bw")) { if (fullName.startsWith(searchString)) { ret.add(userRow); } - } else if (searchOper.equals("ew")){ + } else if (searchOper.equals("ew")) { if (fullName.endsWith(searchString)) { ret.add(userRow); } - }else if (searchOper.equals("cn")){ + } else if (searchOper.equals("cn")) { if (fullName.contains(searchString)) { ret.add(userRow); } } } } - return ret; + return ret; } + + private List doLessonSearch(List gradeBookLessonDTOs , String searchField, + String searchOper, String searchString) { + List ret = new ArrayList(); + if (searchField.equals("lessonName")) { + for (GBLessonGridRowDTO lessonRow : gradeBookLessonDTOs) { + + String lessonName = lessonRow.getLessonName(); + lessonName = lessonName.toLowerCase(); + + if (searchOper.equals("eq")) { + if (lessonName.equals(searchString)) { + ret.add(lessonRow); + } + } else if (searchOper.equals("ne")) { + if (!lessonName.equals(searchString)) { + ret.add(lessonRow); + } + } else if (searchOper.equals("bw")) { + if (lessonName.startsWith(searchString)) { + ret.add(lessonRow); + } + } else if (searchOper.equals("ew")) { + if (lessonName.endsWith(searchString)) { + ret.add(lessonRow); + } + } else if (searchOper.equals("cn")) { + if (lessonName.contains(searchString)) { + ret.add(lessonRow); + } + } + } + } + return ret; + } + private UserDTO getUser() { HttpSession ss = SessionManager.getSession(); return (UserDTO) ss.getAttribute(AttributeNames.USER); } - public static IGradeBookService getGradeBookService() { - return gradeBookService; + private User getRealUser() { + UserDTO userDTO = getUser(); + if (userDTO != null) { + return getUserService().getUserByLogin(userDTO.getLogin()); + } else { + return null; + } } - public static IUserManagementService getUserService() { - return userService; - } - - public static ILessonService getLessonService() { - return lessonService; - } - private ActionForward displayMessage(ActionMapping mapping, HttpServletRequest req, String messageKey) { req.setAttribute("messageKey", messageKey); return mapping.findForward("message"); } private void initServices() { - ServletContext context = this.getServlet().getServletContext(); + getUserService(); + getLessonService(); + getMonitoringServiceService(); + getGradeBookService(); + } - if (gradeBookService == null) - gradeBookService = (IGradeBookService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("gradeBookService"); + private IUserManagementService getUserService() { + if (userService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + userService = (IUserManagementService) ctx.getBean("userManagementService"); + } + return userService; + } - if (userService == null) - userService = (IUserManagementService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("userManagementService"); + private ILessonService getLessonService() { + if (lessonService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + lessonService = (ILessonService) ctx.getBean("lessonService"); + } + return lessonService; + } - if (lessonService == null) - lessonService = (ILessonService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("lessonService"); + private IMonitoringService getMonitoringServiceService() { + if (monitoringService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + monitoringService = (IMonitoringService) ctx.getBean("monitoringService"); + } + return monitoringService; + } - if (monitoringService == null) - monitoringService = (IMonitoringService) WebApplicationContextUtils.getRequiredWebApplicationContext( - context).getBean("monitoringService"); + private IGradeBookService getGradeBookService() { + if (gradeBookService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + gradeBookService = (IGradeBookService) ctx.getBean("gradeBookService"); + } + return gradeBookService; } + } Index: lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookMonitoringAction.java =================================================================== diff -u -ra0a70e62ee929b8c7e0529da783a2f232b193a2f -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookMonitoringAction.java (.../GradeBookMonitoringAction.java) (revision a0a70e62ee929b8c7e0529da783a2f232b193a2f) +++ lams_central/src/java/org/lamsfoundation/lams/gradebook/web/action/GradeBookMonitoringAction.java (.../GradeBookMonitoringAction.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -23,7 +23,6 @@ /* $Id$ */ package org.lamsfoundation.lams.gradebook.web.action; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -39,13 +38,17 @@ import org.lamsfoundation.lams.lesson.dto.LessonDetailsDTO; import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.monitoring.service.IMonitoringService; +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.OrganisationDTO; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -61,6 +64,8 @@ * * @struts:action-forward name="monitorgradebook" * path="/gradebook/gradeBookMonitor.jsp" + * @struts:action-forward name="monitorcoursegradebook" + * path="/gradebook/gradeBookCourseMonitor.jsp" * @struts:action-forward name="error" path=".error" * @struts:action-forward name="message" path=".message" */ @@ -86,7 +91,7 @@ logger.error("User missing from session. "); return mapping.findForward("error"); } else { - Lesson lesson = lessonId != null ? getLessonService().getLesson(lessonId) : null; + Lesson lesson = lessonId != null ? lessonService.getLesson(lessonId) : null; if (lesson == null) { logger.error("Lesson " + lessonId + " does not exist. Unable to monitor lesson"); return mapping.findForward("error"); @@ -106,11 +111,54 @@ return mapping.findForward("monitorgradebook"); } } catch (Exception e) { - logger.error("Failed to load monitor lesson", e); + logger.error("Failed to load gradebook monitor", e); return mapping.findForward("error"); } - } + } + + @SuppressWarnings("unchecked") + public ActionForward courseMonitor(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + try { + initServices(); + Integer oranisationID = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID); + + logger.debug("request monitorGradebook for organisation: " + oranisationID.toString()); + UserDTO user = getUser(); + if (user == null) { + logger.error("User missing from session. "); + return mapping.findForward("error"); + } else { + + Organisation organisation = (Organisation)userService.findById(Organisation.class, oranisationID); + if (organisation == null) { + logger.error("Organisation " + oranisationID + " does not exist. Unable to load gradebook"); + return mapping.findForward("error"); + } + + // Validate whether this user is a monitor for this organisation + if (!userService.isUserInRole(user.getUserID(), oranisationID, Role.MONITOR)) { + logger.error("User " + user.getLogin() + + " is not a monitor in the requested course. Cannot access the course for gradebook."); + return displayMessage(mapping, request, "error.authorisation"); + } + + logger.debug("user is staff"); + + + + request.setAttribute("organisationID", oranisationID); + request.setAttribute("organisationName", organisation.getName()); + + return mapping.findForward("monitorcoursegradebook"); + } + } catch (Exception e) { + logger.error("Failed to load gradebook monitor", e); + return mapping.findForward("error"); + } + } + /** * Updates a user's mark or feedback for an entire lesson * @@ -211,41 +259,51 @@ return getUserService().getUserByLogin(dto.getLogin()); } - public static IGradeBookService getGradeBookService() { - return gradeBookService; + private ActionForward displayMessage(ActionMapping mapping, HttpServletRequest req, String messageKey) { + req.setAttribute("messageKey", messageKey); + return mapping.findForward("message"); } - public static IUserManagementService getUserService() { + private void initServices() { + getUserService(); + getLessonService(); + getMonitoringServiceService(); + getGradeBookService(); + } + + private IUserManagementService getUserService() { + if (userService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + userService = (IUserManagementService) ctx.getBean("userManagementService"); + } return userService; } - public static ILessonService getLessonService() { + private ILessonService getLessonService() { + if (lessonService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + lessonService = (ILessonService) ctx.getBean("lessonService"); + } return lessonService; } - - private ActionForward displayMessage(ActionMapping mapping, HttpServletRequest req, String messageKey) { - req.setAttribute("messageKey", messageKey); - return mapping.findForward("message"); + + private IMonitoringService getMonitoringServiceService() { + if (monitoringService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + monitoringService = (IMonitoringService) ctx.getBean("monitoringService"); + } + return monitoringService; } - - private void initServices() { - ServletContext context = this.getServlet().getServletContext(); - - if (gradeBookService == null) - gradeBookService = (IGradeBookService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("gradeBookService"); - - if (userService == null) - userService = (IUserManagementService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("userManagementService"); - - if (lessonService == null) - lessonService = (ILessonService) WebApplicationContextUtils.getRequiredWebApplicationContext(context) - .getBean("lessonService"); - - if (monitoringService == null) - monitoringService = (IMonitoringService) WebApplicationContextUtils.getRequiredWebApplicationContext( - context).getBean("monitoringService"); - + + private IGradeBookService getGradeBookService() { + if (gradeBookService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + gradeBookService = (IGradeBookService) ctx.getBean("gradeBookService"); + } + return gradeBookService; } } Index: lams_central/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -ra8e4961c9f59aedf7bbc548462f658ecc539d0ca -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision a8e4961c9f59aedf7bbc548462f658ecc539d0ca) +++ lams_central/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -550,6 +550,11 @@ redirect="false" /> + contextConfigLocation - - classpath:/org/lamsfoundation/lams/applicationContext.xml - classpath:/org/lamsfoundation/lams/toolApplicationContext.xml - classpath:/org/lamsfoundation/lams/contentrepository/applicationContext.xml - classpath:/org/lamsfoundation/lams/authoring/authoringApplicationContext.xml - classpath:/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml - classpath:/org/lamsfoundation/lams/workspace/workspaceApplicationContext.xml - classpath:/org/lamsfoundation/lams/web/webApplicationContext.xml - classpath:/org/lamsfoundation/lams/integrationContext.xml - classpath:/org/lamsfoundation/lams/usermanagement/ldapContext.xml - classpath:/org/lamsfoundation/lams/gradebook/gradeBookApplicationContext.xml - - classpath:/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml - classpath:/org/lamsfoundation/lams/learning/learningApplicationContext.xml - - + + + locatorFactorySelector + classpath*:/org/lamsfoundation/lams/**/beanRefContext.xml + + + parentContextKey + context.central + SystemSessionFilter Index: lams_central/web/gradebook/gradeBookCourseMonitor.jsp =================================================================== diff -u --- lams_central/web/gradebook/gradeBookCourseMonitor.jsp (revision 0) +++ lams_central/web/gradebook/gradeBookCourseMonitor.jsp (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -0,0 +1,192 @@ + + +<%@ page language="java" pageEncoding="UTF-8" + contentType="text/html;charset=utf-8"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-html" prefix="html"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c"%> + + + + Course GradeBook Monitor + + + + + + + + + + + + + + +
+ +
+ +
+

Course GradeBook for ${organisationName}

+
+
+
+
+
+
+ + +
+ +
\ No newline at end of file Index: lams_central/web/gradebook/gradeBookMonitor.jsp =================================================================== diff -u -ra0a70e62ee929b8c7e0529da783a2f232b193a2f -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_central/web/gradebook/gradeBookMonitor.jsp (.../gradeBookMonitor.jsp) (revision a0a70e62ee929b8c7e0529da783a2f232b193a2f) +++ lams_central/web/gradebook/gradeBookMonitor.jsp (.../gradeBookMonitor.jsp) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -8,7 +8,7 @@ - GradeBook Monitor + Lesson GradeBook Monitor @@ -64,7 +64,7 @@ pager: 'userViewPager', rowList:[5,10,20,30], rowNum:10, - cellurl: "/gradebook/gradebookMonitoring.do?dispatch=updateUserLessonGradeBookData&lessonID=${lessonDetails.lessonID}&login=test1", + cellurl: "/gradebook/gradebookMonitoring.do?dispatch=updateUserLessonGradeBookData&lessonID=${lessonDetails.lessonID}", colNames:["", 'Name', 'Progress', 'Lesson FeedBack', 'Lesson Mark'], colModel:[ {name:'login', index:'login', sortable:false, editable:false, hidden:true, search:false, hidedlg:true}, @@ -297,7 +297,7 @@
-

GradeBook for ${lessonDetails.lessonName}

+

Lesson GradeBook for ${lessonDetails.lessonName}


Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/IGradeBookDAO.java =================================================================== diff -u -rf4328ca969294c06bf12815f299236c17398c99c -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/IGradeBookDAO.java (.../IGradeBookDAO.java) (revision f4328ca969294c06bf12815f299236c17398c99c) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/IGradeBookDAO.java (.../IGradeBookDAO.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -38,6 +38,8 @@ public Double getGradeBookUserActivityMarkSum(Long lessonID, Integer userID); public List getAllGradeBookUserActivitiesForActivity(Long activityID); + + public Double getAverageMarkForLesson(Long lessonID); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/hibernate/GradeBookDAO.java =================================================================== diff -u -rf4328ca969294c06bf12815f299236c17398c99c -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/hibernate/GradeBookDAO.java (.../GradeBookDAO.java) (revision f4328ca969294c06bf12815f299236c17398c99c) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dao/hibernate/GradeBookDAO.java (.../GradeBookDAO.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -43,50 +43,70 @@ private static final String GET_GRADEBOOK_USER_ACTIVITIES_FOR_ACTIVITY = "from GradeBookUserActivity gact where " + "gact.activity.activityId=:activityID"; - - + + private static final String GET_AVERAGE_MARK_FOR_LESSON = "select avg(gles.mark) from GradeBookUserLesson gles where " + + "gles.lesson.lessonId=:lessonID"; + @SuppressWarnings("unchecked") public GradeBookUserActivity getGradeBookUserDataForActivity(Long activityID, Integer userID) { List result = getSession().createQuery(GET_GRADEBOOK_USER_ACTIVITY).setInteger("userID", userID.intValue()) .setLong("activityID", activityID.longValue()).list(); - if (result != null && result.size() > 0) { - return (GradeBookUserActivity) result.get(0); - } else { - return null; - } + if (result != null) { + if (result.size() > 0) + return (GradeBookUserActivity) result.get(0); + } + + return null; } @SuppressWarnings("unchecked") public GradeBookUserLesson getGradeBookUserDataForLesson(Long lessonID, Integer userID) { List result = getSession().createQuery(GET_GRADEBOOK_USER_LESSON).setInteger("userID", userID.intValue()) .setLong("lessonID", lessonID.longValue()).list(); - if (result != null && result.size() > 0) { - return (GradeBookUserLesson) result.get(0); - } else { - return null; - } + if (result != null) { + if (result.size() > 0) + return (GradeBookUserLesson) result.get(0); + } + + return null; + } @SuppressWarnings("unchecked") public Double getGradeBookUserActivityMarkSum(Long lessonID, Integer userID) { List result = getSession().createQuery(GET_GRADEBOOK_ACTIVITIES_FROM_LESSON_SUM).setInteger("userID", userID.intValue()).setLong("lessonID", lessonID.longValue()).list(); + + if (result != null) { + if (result.size() > 0) + return (Double) result.get(0); + } - if (result != null && result.size() > 0) { - return (Double) result.get(0); - } else { - return 0.0; - } + return 0.0; + } - + @SuppressWarnings("unchecked") public List getAllGradeBookUserActivitiesForActivity(Long activityID) { - List result = getSession().createQuery(GET_GRADEBOOK_USER_ACTIVITIES_FOR_ACTIVITY) - .setLong("activityID", activityID.longValue()).list(); - - return (List)result; + List result = getSession().createQuery(GET_GRADEBOOK_USER_ACTIVITIES_FOR_ACTIVITY).setLong("activityID", + activityID.longValue()).list(); + + return (List) result; } + + @SuppressWarnings("unchecked") + public Double getAverageMarkForLesson(Long lessonID) { + List result = getSession().createQuery(GET_AVERAGE_MARK_FOR_LESSON).setLong("lessonID", lessonID.longValue()) + .list(); + + if (result != null) { + if (result.size() > 0) + return (Double) result.get(0); + } + + return 0.0; + } } Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBActivityGridRowDTO.java =================================================================== diff -u -ra0a70e62ee929b8c7e0529da783a2f232b193a2f -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBActivityGridRowDTO.java (.../GBActivityGridRowDTO.java) (revision a0a70e62ee929b8c7e0529da783a2f232b193a2f) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBActivityGridRowDTO.java (.../GBActivityGridRowDTO.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -18,174 +18,166 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ -package org.lamsfoundation.lams.gradebook.dto; + */ +/* $Id$ */ +package org.lamsfoundation.lams.gradebook.dto; + import java.util.ArrayList; - -public class GBActivityGridRowDTO extends GradeBookGridRowDTO{ + +public class GBActivityGridRowDTO extends GradeBookGridRowDTO { + + public static final String VIEW_USER = "userView"; + public static final String VIEW_ACTIVITY = "activityView"; + long activityId; String activityTitle; String competences; //String toolString; - + // Properties for user view String status; String output; String activityUrl; //double timeTaken; - Double mark; + Double mark; String feedback; - + // Properties for activity view Double average; String monitorUrl; - - - public GBActivityGridRowDTO() {} - - @Override - public ArrayList toMonitorUserViewStringArray() { - ArrayList ret = new ArrayList(); - - ret.add("" + activityId); - - - if (activityUrl != null && activityUrl.length() != 0) { - ret.add("" +activityTitle +""); - } else { - ret.add(activityTitle); - } - - - ret.add(status); - ret.add(output); - ret.add(competences); - - ret.add(feedback); - - if (mark != null) { - ret.add(mark.toString()); - } else { - ret.add("-"); - } - - - return ret; + + public GBActivityGridRowDTO() { } - + @Override - public ArrayList toMonitorActViewStringArray() { + public ArrayList toStringArray(String view) { ArrayList ret = new ArrayList(); - ret.add("" + activityId); - if (monitorUrl != null && monitorUrl.length() != 0) { - ret.add("" +activityTitle +""); - } else { - ret.add(activityTitle); - } + if (view.equals(VIEW_USER)) { + if (activityUrl != null && activityUrl.length() != 0) { + ret.add("" + + activityTitle + ""); + } else { + ret.add(activityTitle); + } + ret.add(status); + ret.add(output); + ret.add(competences); + ret.add(feedback); + if (mark != null) { + ret.add(mark.toString()); + } else { + ret.add("-"); + } + + } else if (view.equals(VIEW_ACTIVITY)) { + if (monitorUrl != null && monitorUrl.length() != 0) { + ret.add("" + + activityTitle + ""); + } else { + ret.add(activityTitle); + } - ret.add(competences); - - if (average != null) { - ret.add(average.toString()); - } else { - ret.add("-"); + ret.add(competences); + + if (average != null) { + ret.add(average.toString()); + } else { + ret.add("-"); + } } - + return ret; } - + @Override public String getRowId() { return "" + activityId; } - - public int getId(){ + + public int getId() { return new Long(activityId).intValue(); } public long getActivityId() { - return activityId; + return activityId; } public void setActivityId(long activityId) { - this.activityId = activityId; + this.activityId = activityId; } public String getActivityTitle() { - return activityTitle; + return activityTitle; } public void setActivityTitle(String activityTitle) { - this.activityTitle = activityTitle; + this.activityTitle = activityTitle; } public String getStatus() { - return status; + return status; } public void setStatus(String status) { - this.status = status; + this.status = status; } public String getOutput() { - return output; + return output; } public void setOutput(String output) { - this.output = output; + this.output = output; } public Double getMark() { - return mark; + return mark; } public void setMark(Double mark) { - this.mark = mark; + this.mark = mark; } public String getCompetences() { - return competences; + return competences; } public void setCompetences(String competences) { - this.competences = competences; + this.competences = competences; } public String getActivityUrl() { - return activityUrl; + return activityUrl; } public void setActivityUrl(String activityUrl) { - this.activityUrl = activityUrl; + this.activityUrl = activityUrl; } public String getFeedback() { - return feedback; + return feedback; } public void setFeedback(String feedback) { - this.feedback = feedback; + this.feedback = feedback; } public Double getAverage() { - return average; + return average; } public void setAverage(Double average) { - this.average = average; + this.average = average; } public String getMonitorUrl() { - return monitorUrl; + return monitorUrl; } public void setMonitorUrl(String monitorUrl) { - this.monitorUrl = monitorUrl; + this.monitorUrl = monitorUrl; } } - \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBLessonGridRowDTO.java (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -0,0 +1,147 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.gradebook.dto; + +import java.util.ArrayList; + +public class GBLessonGridRowDTO extends GradeBookGridRowDTO { + + public static final String VIEW_MONITOR = "monitorView"; + public static final String VIEW_LEARNER = "learnerView"; + + Long lessonId; + String lessonName; + String lessonDescription; + Double mark; + String subGroup; + + // Only for monitor view + String gradeBookMonitorURL; + + // Only for learner view + String gradeBookLearnerURL; + + + public GBLessonGridRowDTO() { + } + + @Override + public String getRowId() { + // TODO Auto-generated method stub + return null; + } + + @Override + public ArrayList toStringArray(String view) { + ArrayList ret = new ArrayList(); + + ret.add(lessonId.toString()); + + if (view.equals(VIEW_MONITOR)) { + if (gradeBookMonitorURL != null && gradeBookMonitorURL.length() != 0) { + ret.add("" + lessonName + + ""); + } else { + ret.add(lessonName); + } + ret.add(subGroup); + ret.add(lessonDescription); + if (mark != null) { + ret.add(mark.toString()); + } else { + ret.add("-"); + } + } else if (view.equals(VIEW_LEARNER)) { + if (gradeBookLearnerURL != null && gradeBookLearnerURL.length() != 0) { + ret.add("" + lessonName + + ""); + } else { + ret.add(lessonName); + } + ret.add(lessonDescription); + if (mark != null) { + ret.add(mark.toString()); + } else { + ret.add("-"); + } + } + return ret; + } + + public Long getLessonId() { + return lessonId; + } + + public void setLessonId(Long lessonId) { + this.lessonId = lessonId; + } + + public String getLessonName() { + return lessonName; + } + + public void setLessonName(String lessonName) { + this.lessonName = lessonName; + } + + public String getLessonDescription() { + return lessonDescription; + } + + public void setLessonDescription(String lessonDescription) { + this.lessonDescription = lessonDescription; + } + + public Double getMark() { + return mark; + } + + public void setMark(Double mark) { + this.mark = mark; + } + + public String getGradeBookMonitorURL() { + return gradeBookMonitorURL; + } + + public void setGradeBookMonitorURL(String gradeBookMonitorURL) { + this.gradeBookMonitorURL = gradeBookMonitorURL; + } + + public String getGradeBookLearnerURL() { + return gradeBookLearnerURL; + } + + public void setGradeBookLearnerURL(String gradeBookLearnerURL) { + this.gradeBookLearnerURL = gradeBookLearnerURL; + } + + public String getSubGroup() { + return subGroup; + } + + public void setSubGroup(String subGroup) { + this.subGroup = subGroup; + } +} Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBUserGridRowDTO.java =================================================================== diff -u -rf4328ca969294c06bf12815f299236c17398c99c -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBUserGridRowDTO.java (.../GBUserGridRowDTO.java) (revision f4328ca969294c06bf12815f299236c17398c99c) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GBUserGridRowDTO.java (.../GBUserGridRowDTO.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -26,58 +26,56 @@ import java.util.ArrayList; public class GBUserGridRowDTO extends GradeBookGridRowDTO { + + public static final String VIEW_USER = "userView"; + public static final String VIEW_ACTIVITY = "activityView"; + public static final String VIEW_COURSE_MONITOR = "courseMonitorView"; + String login; String firstName; String lastName; String status; String feedback; - + // For user view, this represents total lesson mark in the grid // For activity view, this represents an activity mark Double mark; - + // For activity view String output; String activityUrl; - public GBUserGridRowDTO() { } - + @Override - public ArrayList toMonitorUserViewStringArray() { + public ArrayList toStringArray(String view) { ArrayList ret = new ArrayList(); + String fullName = lastName + " " + firstName; ret.add(login); - ret.add(lastName + " " + firstName); - ret.add(status); - ret.add(feedback); - if (mark != null) { - ret.add(mark.toString()); - } else { - ret.add("-"); - } + if (view.equals(VIEW_USER)) { + ret.add(fullName); + ret.add(status); + ret.add(feedback); + } else if (view.equals(VIEW_ACTIVITY)) { + if (activityUrl != null && activityUrl.length() != 0) { + ret.add("" + fullName + + ""); + } else { + ret.add(fullName); + } - return ret; - } - - @Override - public ArrayList toMonitorActViewStringArray() { - ArrayList ret = new ArrayList(); - - ret.add(login); - - String fullName = lastName + " " + firstName; - if (activityUrl != null && activityUrl.length() != 0) { - ret.add("" +fullName +""); - } else { - ret.add(login); + ret.add(status); + ret.add(output); + ret.add(feedback); + } else if (view.equals(VIEW_COURSE_MONITOR)){ + ret.add(fullName); + ret.add(status); + ret.add(feedback); + } - - ret.add(status); - ret.add(output); - ret.add(feedback); if (mark != null) { ret.add(mark.toString()); @@ -102,58 +100,58 @@ } public String getLogin() { - return login; + return login; } public void setLogin(String login) { - this.login = login; + this.login = login; } public String getFirstName() { - return firstName; + return firstName; } public void setFirstName(String firstName) { - this.firstName = firstName; + this.firstName = firstName; } public String getLastName() { - return lastName; + return lastName; } public void setLastName(String lastName) { - this.lastName = lastName; + this.lastName = lastName; } public String getStatus() { - return status; + return status; } public void setStatus(String status) { - this.status = status; + this.status = status; } - + public String getFeedback() { - return feedback; + return feedback; } public void setFeedback(String feedback) { - this.feedback = feedback; + this.feedback = feedback; } public String getOutput() { - return output; + return output; } public void setOutput(String output) { - this.output = output; + this.output = output; } public String getActivityUrl() { - return activityUrl; + return activityUrl; } public void setActivityUrl(String activityUrl) { - this.activityUrl = activityUrl; + this.activityUrl = activityUrl; } } Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GradeBookGridRowDTO.java =================================================================== diff -u -rf4328ca969294c06bf12815f299236c17398c99c -r662af4c9490c6c67127cda6c29d7d806a9e9eaca --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GradeBookGridRowDTO.java (.../GradeBookGridRowDTO.java) (revision f4328ca969294c06bf12815f299236c17398c99c) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/GradeBookGridRowDTO.java (.../GradeBookGridRowDTO.java) (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -27,10 +27,8 @@ public abstract class GradeBookGridRowDTO{ - public abstract ArrayList toMonitorUserViewStringArray(); + public abstract ArrayList toStringArray(String view); - public abstract ArrayList toMonitorActViewStringArray(); - public abstract String getRowId(); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonMarkComparator.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonMarkComparator.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonMarkComparator.java (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -0,0 +1,47 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.gradebook.dto.comparators; + +import java.util.Comparator; + +import org.lamsfoundation.lams.gradebook.dto.GBLessonGridRowDTO; + +@SuppressWarnings("unchecked") +public class GBLessonMarkComparator implements Comparator { + + public int compare(Object gbLessonRowDTO, Object anotherGbLessonRowDTO) { + + if (gbLessonRowDTO instanceof GBLessonGridRowDTO && anotherGbLessonRowDTO instanceof GBLessonGridRowDTO) { + + Double mark1 = ((GBLessonGridRowDTO) gbLessonRowDTO).getMark(); + Double mark2 = ((GBLessonGridRowDTO) anotherGbLessonRowDTO).getMark(); + + mark1 = (mark1 == null) ? 0.0 : mark1; + mark2 = (mark2 == null) ? 0.0 : mark2; + return new Double(mark1 - mark2).intValue(); + } else { + return 0; + } + } +} Index: lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonNameComparator.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonNameComparator.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/gradebook/dto/comparators/GBLessonNameComparator.java (revision 662af4c9490c6c67127cda6c29d7d806a9e9eaca) @@ -0,0 +1,45 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.gradebook.dto.comparators; + +import java.util.Comparator; + +import org.lamsfoundation.lams.gradebook.dto.GBLessonGridRowDTO; + +@SuppressWarnings("unchecked") +public class GBLessonNameComparator implements Comparator { + + public int compare(Object gbLessonRowDTO, Object anotherGbLessonRowDTO) { + + if (gbLessonRowDTO instanceof GBLessonGridRowDTO && anotherGbLessonRowDTO instanceof GBLessonGridRowDTO) { + + String name1 = ((GBLessonGridRowDTO)gbLessonRowDTO).getLessonName(); + String name2 = ((GBLessonGridRowDTO)anotherGbLessonRowDTO).getLessonName(); + + return name1.compareTo(name2); + } else { + return 0; + } + } +}