Index: lams_build/lib/lams/lams-gradebook.jar =================================================================== diff -u -rbbd946d0a18f784ff7f72d0cebaaa3828980dfd0 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a Binary files differ Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== diff -u -r8b05244abcc5ccff96d377a8ac5ddf7fd50f2dae -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision 8b05244abcc5ccff96d377a8ac5ddf7fd50f2dae) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java (.../GradebookService.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -41,15 +41,9 @@ import java.util.TimeZone; import java.util.TreeSet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.gradebook.GradebookUserActivity; import org.lamsfoundation.lams.gradebook.GradebookUserLesson; @@ -62,7 +56,6 @@ import org.lamsfoundation.lams.gradebook.util.GradebookConstants; import org.lamsfoundation.lams.gradebook.util.LessonComparator; import org.lamsfoundation.lams.learningdesign.Activity; -import org.lamsfoundation.lams.learningdesign.ActivityEvaluation; import org.lamsfoundation.lams.learningdesign.Group; import org.lamsfoundation.lams.learningdesign.Grouping; import org.lamsfoundation.lams.learningdesign.ToolActivity; @@ -87,7 +80,6 @@ import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.ExcelCell; import org.lamsfoundation.lams.util.MessageService; -import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.audit.IAuditService; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -116,11 +108,11 @@ private IAuditService auditService; @Override - @SuppressWarnings("unchecked") - public List getGBActivityRowsForLearner(Lesson lesson, User learner) { + public List getGBActivityRowsForLearner(Long lessonId, Integer userId) { + GradebookService.logger.debug("Getting gradebook user data for lesson: " + lessonId + ". For user: " + userId); - logger.debug("Getting gradebook user data for lesson: " + lesson.getLessonId() + ". For user: " - + learner.getUserId()); + Lesson lesson = lessonService.getLesson(lessonId); + User learner = (User) userService.findById(User.class, userId); List gradebookActivityDTOs = new ArrayList(); @@ -161,10 +153,10 @@ // Get the tool outputs for this user if there are any ToolSession toolSession = toolService.getToolSessionByLearner(learner, activity); - if (toolSession != null && learnerProgress != null) { + if ((toolSession != null) && (learnerProgress != null)) { byte activityState = learnerProgress.getProgressState(activity); - if (activityState == LearnerProgress.ACTIVITY_ATTEMPTED - || activityState == LearnerProgress.ACTIVITY_COMPLETED) { + if ((activityState == LearnerProgress.ACTIVITY_ATTEMPTED) + || (activityState == LearnerProgress.ACTIVITY_COMPLETED)) { // Set the activityLearner URL for this gradebook activity activityDTO.setActivityUrl(Configuration.get(ConfigurationKeys.SERVER_URL) + activity.getTool().getLearnerProgressUrl() + "&userID=" + learner.getUserId() @@ -181,10 +173,10 @@ @Override @SuppressWarnings("unchecked") - public List getGBActivityRowsForLesson(Lesson lesson) { - - logger.debug("Getting gradebook data for lesson: " + lesson.getLessonId()); - + public List getGBActivityRowsForLesson(Long lessonId) { + GradebookService.logger.debug("Getting gradebook data for lesson: " + lessonId); + + Lesson lesson = lessonService.getLesson(lessonId); List gradebookActivityDTOs = new ArrayList(); Set activities = getLessonActivities(lesson); @@ -197,14 +189,14 @@ if (groups != null) { for (Group group : groups) { - GBActivityGridRowDTO activityDTO = getGradebookActivityDTO((ToolActivity) activity, lesson, + GBActivityGridRowDTO activityDTO = getGradebookActivityDTO(activity, lesson, group.getGroupName(), group.getGroupId()); gradebookActivityDTOs.add(activityDTO); } } } else { - GBActivityGridRowDTO activityDTO = getGradebookActivityDTO((ToolActivity) activity, lesson, null, null); + GBActivityGridRowDTO activityDTO = getGradebookActivityDTO(activity, lesson, null, null); gradebookActivityDTOs.add(activityDTO); } } @@ -248,11 +240,11 @@ // Get the tool outputs for this user if there are any ToolSession toolSession = toolService.getToolSessionByLearner(learner, activity); - if (toolSession != null && learnerProgress != null) { + if ((toolSession != null) && (learnerProgress != null)) { // Set the activityLearner URL for this gradebook activity byte activityState = learnerProgress.getProgressState(activity); - if (activityState == LearnerProgress.ACTIVITY_ATTEMPTED - || activityState == LearnerProgress.ACTIVITY_COMPLETED) { + if ((activityState == LearnerProgress.ACTIVITY_ATTEMPTED) + || (activityState == LearnerProgress.ACTIVITY_COMPLETED)) { gUserDTO.setActivityUrl(Configuration.get(ConfigurationKeys.SERVER_URL) + activity.getTool().getLearnerProgressUrl() + "&userID=" + learner.getUserId() + "&toolSessionID=" + toolSession.getToolSessionId().toString()); @@ -303,7 +295,7 @@ // calculate time taken if (learnerProgress != null) { - if (learnerProgress.getStartDate() != null && learnerProgress.getFinishDate() != null) { + if ((learnerProgress.getStartDate() != null) && (learnerProgress.getFinishDate() != null)) { gradebookUserDTO.setTimeTaken(learnerProgress.getFinishDate().getTime() - learnerProgress.getStartDate().getTime()); } @@ -350,7 +342,7 @@ public GradebookUserLesson getGradebookUserLesson(Long lessonID, Integer userID) { return gradebookDAO.getGradebookUserDataForLesson(lessonID, userID); } - + @Override public List getGradebookUserLesson(Long lessonID) { return gradebookDAO.getGradebookUserDataForLesson(lessonID); @@ -380,7 +372,7 @@ @Override public void updateUserLessonGradebookMark(Lesson lesson, User learner, Double mark) { - if (lesson != null && learner != null) { + if ((lesson != null) && (learner != null)) { GradebookUserLesson gradebookUserLesson = gradebookDAO.getGradebookUserDataForLesson(lesson.getLessonId(), learner.getUserId()); @@ -391,7 +383,7 @@ gradebookUserLesson.setMark(mark); gradebookDAO.insertOrUpdate(gradebookUserLesson); - + // audit log changed gradebook mark UserDTO monitorUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); String[] args = new String[] { learner.getLogin() + "(" + learner.getUserId() + ")", @@ -404,7 +396,7 @@ @Override public void updateUserActivityGradebookMark(Lesson lesson, User learner, Activity activity, Double mark, Boolean markedInGradebook, boolean isAuditLogRequired) { - if (lesson != null && activity != null && learner != null && activity.isToolActivity()) { + if ((lesson != null) && (activity != null) && (learner != null) && activity.isToolActivity()) { // First, update the mark for the activity GradebookUserActivity gradebookUserActivity = gradebookDAO.getGradebookUserDataForActivity( @@ -432,7 +424,7 @@ } aggregateTotalMarkForLesson(gradebookUserLesson); - + // audit log changed gradebook mark if (isAuditLogRequired) { UserDTO monitorUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); @@ -473,7 +465,7 @@ gradebookUserActivity.setUpdateDate(new Date()); gradebookDAO.insertOrUpdate(gradebookUserActivity); } - + @Override public void toggleMarksReleased(Long lessonId) { @@ -482,11 +474,11 @@ boolean isMarksReleased = (lesson.getMarksReleased() != null) && lesson.getMarksReleased(); lesson.setMarksReleased(!isMarksReleased); userService.save(lesson); - + // audit log marks released UserDTO monitor = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); String messageKey = (isMarksReleased) ? "audit.marks.released.off" : "audit.marks.released.on"; - String message = messageService.getMessage(messageKey, new String[] {lessonId.toString()}); + String message = messageService.getMessage(messageKey, new String[] { lessonId.toString() }); auditService.log(monitor, GradebookConstants.MODULE_NAME, message); } @@ -510,11 +502,11 @@ boolean hasTeacherPermission = lesson.getLessonClass().isStaffMember(viewer) || userService.isUserInRole(viewer.getUserId(), organisationToCheckPermission, Role.GROUP_MANAGER); - boolean marksReleased = lesson.getMarksReleased() != null && lesson.getMarksReleased(); + boolean marksReleased = (lesson.getMarksReleased() != null) && lesson.getMarksReleased(); boolean hasLearnerPermission = lesson.getAllLearners().contains(user); - if (!((view == GBGridView.MON_COURSE) && hasTeacherPermission || (view == GBGridView.LRN_COURSE) - && hasLearnerPermission && marksReleased || (view == GBGridView.MON_USER) - && hasTeacherPermission && hasLearnerPermission)) { + if (!(((view == GBGridView.MON_COURSE) && hasTeacherPermission) + || ((view == GBGridView.LRN_COURSE) && hasLearnerPermission && marksReleased) || ((view == GBGridView.MON_USER) + && hasTeacherPermission && hasLearnerPermission))) { continue; } @@ -550,7 +542,7 @@ lesson.getLessonId()); lessonRow.setStatus(getLessonStatusStr(learnerProgress)); if (learnerProgress != null) { - if (learnerProgress.getStartDate() != null && learnerProgress.getFinishDate() != null) { + if ((learnerProgress.getStartDate() != null) && (learnerProgress.getFinishDate() != null)) { lessonRow.setTimeTaken(learnerProgress.getFinishDate().getTime() - learnerProgress.getStartDate().getTime()); } @@ -571,7 +563,7 @@ } } else { - logger.error("Request for gradebook grid with a null organisation"); + GradebookService.logger.error("Request for gradebook grid with a null organisation"); } return lessonRows; @@ -595,7 +587,7 @@ Map userToGradebookUserActivityMap = getUserToGradebookUserActivityMap(activity); List userDTOs = new ArrayList(); - + SortedMap toolOutputNames = toolService.getOutputDefinitionsFromTool( activity.getToolContentId(), ToolOutputDefinition.DATA_OUTPUT_DEFINITION_TYPE_CONDITION); @@ -620,11 +612,11 @@ } // Get the tool outputs for this user if there are any. - if (toolSession != null && learnerProgress != null) { + if ((toolSession != null) && (learnerProgress != null)) { // Set the activityLearner URL for this gradebook activity byte activityState = learnerProgress.getProgressState(activity); - if (activityState == LearnerProgress.ACTIVITY_ATTEMPTED - || activityState == LearnerProgress.ACTIVITY_COMPLETED) { + if ((activityState == LearnerProgress.ACTIVITY_ATTEMPTED) + || (activityState == LearnerProgress.ACTIVITY_COMPLETED)) { userDTO.setActivityUrl(Configuration.get(ConfigurationKeys.SERVER_URL) + activity.getTool().getLearnerProgressUrl() + "&userID=" + learner.getUserId() + "&toolSessionID=" + toolSession.getToolSessionId().toString()); @@ -668,10 +660,10 @@ lessonAverageTimeTaken[1] = new ExcelCell(gradebookDAO.getAverageDurationLesson(lesson.getLessonId()) / 1000, false); rowList.add(lessonAverageTimeTaken); - rowList.add(EMPTY_ROW); + rowList.add(GradebookService.EMPTY_ROW); // Adding the activity average data to the summary - List activityRows = getGBActivityRowsForLesson(lesson); + List activityRows = getGBActivityRowsForLesson(lesson.getLessonId()); ExcelCell[] activityAverageTitle = new ExcelCell[1]; activityAverageTitle[0] = new ExcelCell(getMessage("gradebook.export.activities"), true); rowList.add(activityAverageTitle); @@ -695,7 +687,7 @@ activityDataRow[3] = new ExcelCell(activityRow.getAverageMark(), false); rowList.add(activityDataRow); } - rowList.add(EMPTY_ROW); + rowList.add(GradebookService.EMPTY_ROW); // Adding the user lesson marks to the summary ExcelCell[] userMarksTitle = new ExcelCell[1]; @@ -759,7 +751,7 @@ rowList1.add(userDataRow); } - rowList1.add(EMPTY_ROW); + rowList1.add(GradebookService.EMPTY_ROW); } ExcelCell[][] activityData = rowList1.toArray(new ExcelCell[][] {}); @@ -828,7 +820,7 @@ rowList2.add(activityDataRow); } - rowList2.add(EMPTY_ROW); + rowList2.add(GradebookService.EMPTY_ROW); } ExcelCell[][] userData = rowList2.toArray(new ExcelCell[][] {}); @@ -865,7 +857,7 @@ lessons.add(lesson); } - if (lessons != null && (lessons.size() > 0)) { + if ((lessons != null) && (lessons.size() > 0)) { // collect users from all lessons Set allLearners = new LinkedHashSet(); @@ -874,7 +866,7 @@ allLearners.addAll(dbLessonUsers); } - int numberOfCellsInARow = 2 + lessons.size() * 4; + int numberOfCellsInARow = 2 + (lessons.size() * 4); // Adding the user lesson marks to the summary---------------------- ExcelCell[] lessonsNames = new ExcelCell[numberOfCellsInARow]; @@ -978,7 +970,7 @@ activityTouserToGradebookUserActivityMap.put(activity.getActivityId(), userToGradebookUserActivityMap); } - int numberCellsPerRow = selectedLessons.size() * 6 + allActivities.size() * 2 + 5; + int numberCellsPerRow = (selectedLessons.size() * 6) + (allActivities.size() * 2) + 5; // Lesson names row---------------------- ExcelCell[] lessonsNames = new ExcelCell[numberCellsPerRow]; @@ -987,7 +979,7 @@ Set lessonActivities = lessonActivitiesMap.get(lesson.getLessonId()); int numberActivities = lessonActivities.size(); lessonsNames[i + numberActivities] = new ExcelCell(lesson.getLessonName(), true); - i += 6 + numberActivities * 2; + i += 6 + (numberActivities * 2); } i -= 2; lessonsNames[i++] = new ExcelCell("", ExcelCell.BORDER_STYLE_LEFT_THIN); @@ -1044,7 +1036,7 @@ // check if learner is participating in this lesson if (!lesson.getAllLearners().contains(learner)) { - i += 1 + activities.size() * 2; + i += 1 + (activities.size() * 2); userRow[i++] = new ExcelCell("", ExcelCell.BORDER_STYLE_LEFT_THIN); userRow[i++] = new ExcelCell("", false); userRow[i++] = new ExcelCell("", ExcelCell.BORDER_STYLE_RIGHT_THICK); @@ -1111,14 +1103,15 @@ Boolean markedInGradebook) { ToolSession toolSession = toolService.getToolSessionById(toolSessionID); User learner = (User) userService.findById(User.class, userID); - if (learner != null && toolSession != null) { + if ((learner != null) && (toolSession != null)) { ToolActivity activity = toolSession.getToolActivity(); GradebookUserActivity gradebookUserActivity = getGradebookUserActivity(activity.getActivityId(), userID); // If gradebook user activity is null or the mark is set by teacher or was set previously by user - save the // mark and feedback - if (gradebookUserActivity == null || markedInGradebook || !gradebookUserActivity.getMarkedInGradebook()) { - updateUserActivityGradebookMark(toolSession.getLesson(), learner, activity, mark, markedInGradebook, false); + if ((gradebookUserActivity == null) || markedInGradebook || !gradebookUserActivity.getMarkedInGradebook()) { + updateUserActivityGradebookMark(toolSession.getLesson(), learner, activity, mark, markedInGradebook, + false); updateUserActivityGradebookFeedback(activity, learner, feedback); } } @@ -1189,7 +1182,7 @@ // calculate time taken if (learnerProgress != null) { - if (learnerProgress.getStartDate() != null && learnerProgress.getFinishDate() != null) { + if ((learnerProgress.getStartDate() != null) && (learnerProgress.getFinishDate() != null)) { gradebookUserDTO.setTimeTaken(learnerProgress.getFinishDate().getTime() - learnerProgress.getStartDate().getTime()); } @@ -1219,7 +1212,7 @@ * @return */ private String getLocaleDateString(User user, Date date) { - if (user == null || date == null) { + if ((user == null) || (date == null)) { return null; } @@ -1272,7 +1265,7 @@ Long groupId) { GBActivityGridRowDTO activityDTO = new GBActivityGridRowDTO(activity, groupName, groupId); - if (groupName != null && groupId != null) { + if ((groupName != null) && (groupId != null)) { // Setting averages for group activityDTO @@ -1319,10 +1312,10 @@ if (startDate != null) { if (StringUtils.isBlank(timeZone)) { - logger.warn("No user time zone provided, leaving server default"); + GradebookService.logger.warn("No user time zone provided, leaving server default"); } else { - if (logger.isTraceEnabled()) { - logger.trace("Adjusting time according to zone \"" + timeZone + "\""); + if (GradebookService.logger.isTraceEnabled()) { + GradebookService.logger.trace("Adjusting time according to zone \"" + timeZone + "\""); } TimeZone userTimeZone = TimeZone.getTimeZone(timeZone); startDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, startDate); @@ -1338,7 +1331,7 @@ if (compProg != null) { Date startTime = compProg.getStartDate(); Date endTime = compProg.getFinishDate(); - if (startTime != null && endTime != null) { + if ((startTime != null) && (endTime != null)) { return endTime.getTime() - startTime.getTime(); } } @@ -1360,8 +1353,8 @@ if (learnerProgress != null) { if (learnerProgress.isComplete()) { status = ""; - } else if (learnerProgress.getAttemptedActivities() != null - && learnerProgress.getAttemptedActivities().size() > 0) { + } else if ((learnerProgress.getAttemptedActivities() != null) + && (learnerProgress.getAttemptedActivities().size() > 0)) { status = ""; } @@ -1402,11 +1395,12 @@ * @param learner * @return */ - private String getToolOutputsStr(ToolActivity toolAct, SortedMap toolOutputNames, ToolSession toolSession, User learner) { + private String getToolOutputsStr(ToolActivity toolAct, SortedMap toolOutputNames, + ToolSession toolSession, User learner) { String toolOutputsStr = ""; boolean noOutputs = true; - if (toolAct != null && toolSession != null && learner != null) { + if ((toolAct != null) && (toolSession != null) && (learner != null)) { if (toolOutputNames == null) { toolOutputNames = toolService.getOutputDefinitionsFromTool(toolAct.getToolContentId(), @@ -1423,7 +1417,7 @@ ToolOutput toolOutput = toolService.getOutputFromTool(outputName, toolSession, learner.getUserId()); - if (toolOutput != null && toolOutput.getValue().getType() != OutputType.OUTPUT_COMPLEX) { + if ((toolOutput != null) && (toolOutput.getValue().getType() != OutputType.OUTPUT_COMPLEX)) { toolOutputs.add(toolOutput); toolOutputsStr += toolOutput.getDescription() + ": " + toolOutput.getValue().getString(); @@ -1433,9 +1427,8 @@ } } catch (RuntimeException e) { - logger.debug( - "Runtime exception when attempted to get outputs for activity: " - + toolAct.getActivityId() + ", continuing for other activities", e); + GradebookService.logger.debug("Runtime exception when attempted to get outputs for activity: " + + toolAct.getActivityId() + ", continuing for other activities", e); } } } @@ -1458,7 +1451,7 @@ if (lesson != null) { List learnerProgressList = lessonService.getUserProgressForLesson(lesson.getLessonId()); - if (learnerProgressList != null && learnerProgressList.size() > 0) { + if ((learnerProgressList != null) && (learnerProgressList.size() > 0)) { Map map = new HashMap(); for (LearnerProgress learnerProgress : learnerProgressList) { map.put(learnerProgress.getUser().getUserId(), learnerProgress); @@ -1481,7 +1474,7 @@ List gradebookUserActivities = gradebookDAO .getAllGradebookUserActivitiesForActivity(activity.getActivityId()); - if (gradebookUserActivities != null && gradebookUserActivities.size() > 0) { + if ((gradebookUserActivities != null) && (gradebookUserActivities.size() > 0)) { Map map = new HashMap(); for (GradebookUserActivity gradebookUserActivity : gradebookUserActivities) { map.put(gradebookUserActivity.getLearner().getUserId(), gradebookUserActivity); @@ -1517,7 +1510,7 @@ List learnerProgressList = baseDAO.find(query, new Object[] { user.getUserId(), organisationId, organisationId }); - if (learnerProgressList != null && learnerProgressList.size() > 0) { + if ((learnerProgressList != null) && (learnerProgressList.size() > 0)) { Map map = new HashMap(); for (LearnerProgress learnerProgress : learnerProgressList) { map.put(learnerProgress.getLesson().getLessonId(), learnerProgress); @@ -1539,7 +1532,7 @@ String query = "select ul from GradebookUserLesson ul where ul.lesson.lessonId=?"; List gradebookUserLessons = baseDAO.find(query, new Object[] { lesson.getLessonId() }); - if (gradebookUserLessons != null && gradebookUserLessons.size() > 0) { + if ((gradebookUserLessons != null) && (gradebookUserLessons.size() > 0)) { Map map = new HashMap(); for (GradebookUserLesson gradebookUserLesson : gradebookUserLessons) { map.put(gradebookUserLesson.getLearner().getUserId(), gradebookUserLesson); @@ -1562,7 +1555,7 @@ List gradebookUserLessons = baseDAO.find(query, new Object[] { user.getUserId(), organisationId, organisationId }); - if (gradebookUserLessons != null && gradebookUserLessons.size() > 0) { + if ((gradebookUserLessons != null) && (gradebookUserLessons.size() > 0)) { Map map = new HashMap(); for (GradebookUserLesson gradebookUserLesson : gradebookUserLessons) { map.put(gradebookUserLesson.getLesson().getLessonId(), gradebookUserLesson); @@ -1584,11 +1577,11 @@ } // Getter and setter methods ----------------------------------------------- - + public void setAuditService(IAuditService auditService) { this.auditService = auditService; } - + public ILamsCoreToolService getToolService() { return toolService; } Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java =================================================================== diff -u -r8b05244abcc5ccff96d377a8ac5ddf7fd50f2dae -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java (.../IGradebookService.java) (revision 8b05244abcc5ccff96d377a8ac5ddf7fd50f2dae) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java (.../IGradebookService.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -18,11 +18,11 @@ * * http://www.gnu.org/licenses/gpl.txt * **************************************************************** - */ - -/* $Id$ */ -package org.lamsfoundation.lams.gradebook.service; + */ +/* $Id$ */ +package org.lamsfoundation.lams.gradebook.service; + import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -39,47 +39,45 @@ import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.ExcelCell; - + public interface IGradebookService { - + /** - * Gets all the activity rows for a lesson, with the mark for each activity - * being the average for all users in the lesson + * Gets all the activity rows for a lesson, with the mark for each activity being the average for all users in the + * lesson * - * @param lesson + * @param lesson * @return */ - List getGBActivityRowsForLesson(Lesson lesson); - + List getGBActivityRowsForLesson(Long lessonId); + /** - * Gets all the activity rows for a user, with the mark for the activity - * being the user's individual mark + * Gets all the activity rows for a user, with the mark for the activity being the user's individual mark * - * @param - * @param learner + * @param + * @param learner * @return */ - List getGBActivityRowsForLearner(Lesson lesson, User learner); - + List getGBActivityRowsForLearner(Long lessonId, Integer userId); + /** - * Gets the GBActivityDTO list for an activity, which provides the marks - * for all users in an activity + * Gets the GBActivityDTO list for an activity, which provides the marks for all users in an activity * * @param lesson * @param activity * @param groupId * @return */ List getGBUserRowsForActivity(Lesson lesson, ToolActivity activity, Long groupId); - + /** - * Gets the user rows and the user's entire lesson mark for all users - * in a lesson + * Gets the user rows and the user's entire lesson mark for all users in a lesson + * * @param lesson * @return */ List getGBUserRowsForLesson(Lesson lesson); - + /** * Gets the user rows for specified organisation * @@ -96,7 +94,7 @@ * @param mark */ void updateUserLessonGradebookMark(Lesson lesson, User learner, Double mark); - + /** * Updates a user's activity mark, this will automatically add up all the user's activity marks for a lesson and set * the lesson mark too @@ -106,7 +104,8 @@ * @param activity * @param mark * @param markedInGradebook - * @param isAuditLogRequired should this event be logged with audit service + * @param isAuditLogRequired + * should this event be logged with audit service */ void updateUserActivityGradebookMark(Lesson lesson, User learner, Activity activity, Double mark, Boolean markedInGradebook, boolean isAuditLogRequired); @@ -119,7 +118,7 @@ * @param feedback */ void updateUserActivityGradebookFeedback(Activity activity, User learner, String feedback); - + /** * Updates the user's feedback for a lesson * @@ -128,25 +127,27 @@ * @param feedback */ void updateUserLessonGradebookFeedback(Lesson lesson, User learner, String feedback); - + /** * Toggle on/off marks released option * * @param lessonId */ void toggleMarksReleased(Long lessonId); - + /** * Gets the lesson row dtos for a given organisation * * @param organisation - * @param user user which results is requested - * @param viewer user who view gradebook. We display list of lessons based on his rights. + * @param user + * user which results is requested + * @param viewer + * user who view gradebook. We display list of lessons based on his rights. * @param view * @return */ List getGBLessonRows(Organisation organisation, User user, User viewer, GBGridView view); - + /** * Gets a gradebook lesson mark/feedback for a given user and lesson * @@ -155,15 +156,15 @@ * @return */ GradebookUserLesson getGradebookUserLesson(Long lessonID, Integer userID); - + /** * Gets a gradebook lesson mark/feedback for all users in a given lesson * * @param lessonID * @return */ List getGradebookUserLesson(Long lessonID); - + /** * Gets a gradebook activity mark/feedback for a given activity and user * @@ -172,25 +173,27 @@ * @return */ GradebookUserActivity getGradebookUserActivity(Long activityID, Integer userID); - + /** * Returns the average mark for a given activity. Activity can be grouped - then supply according groupId to receive * AverageMarkForGroupedActivity. * * @param activityID - * @param groupID return AverageMarkForActivity if groupId is null and AverageMarkForGroupedActivity if groupId is specified + * @param groupID + * return AverageMarkForActivity if groupId is null and AverageMarkForGroupedActivity if groupId is + * specified * @return */ Double getAverageMarkForActivity(Long activityID, Long groupID); - + /** * Returns the average mark for a lesson * * @param lessonID * @return */ Double getAverageMarkForLesson(Long lessonID); - + /** * Method for updating an activity mark that tools can call * @@ -200,29 +203,31 @@ * @param toolSessionID */ void updateActivityMark(Double mark, String feedback, Integer userID, Long toolSessionID, Boolean markedInGradebook); - + /** * Get an activity from the db by id * * @param activityID * @return */ Activity getActivityById(Long activityID); - + /** * Get a language label + * * @param key * @return */ String getMessage(String key); - + /** * Get the summary data in a 2s array for an excel export + * * @param lesson * @return */ LinkedHashMap exportLessonGradebook(Lesson lesson); - + /** * Get the summary data for course in order to create excel export * @@ -231,7 +236,6 @@ * @return */ LinkedHashMap exportCourseGradebook(Integer userId, Integer organisationId); - /** * Get the summary data for selected lessons in order to create excel export @@ -240,7 +244,6 @@ * @param organisationId * @return */ - LinkedHashMap exportSelectedLessonsGradebook(Integer userId, Integer organisationId, String[] lessonIds); - -} - + LinkedHashMap exportSelectedLessonsGradebook(Integer userId, Integer organisationId, + String[] lessonIds); +} \ No newline at end of file Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java =================================================================== diff -u -rb128694883b5db515c3f98f6803b573e04d203d2 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java (.../GradebookAction.java) (revision b128694883b5db515c3f98f6803b573e04d203d2) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookAction.java (.../GradebookAction.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -134,23 +134,14 @@ } } - Lesson lesson = getLessonService().getLesson(lessonID); List gradebookActivityDTOs = new ArrayList(); // Get the user gradebook list from the db // A slightly different list is needed for userview or activity view if ((view == GBGridView.MON_USER) || (view == GBGridView.LRN_ACTIVITY)) { - // Integer userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_USERID); - User learner = (User) getUserService().findById(User.class, userID); - if (learner != null) { - gradebookActivityDTOs = getGradebookService().getGBActivityRowsForLearner(lesson, learner); - } else { - // return null and the grid will report the error - GradebookAction.logger.error("No learner found for: " + userID); - return null; - } + gradebookActivityDTOs = getGradebookService().getGBActivityRowsForLearner(lessonID, userID); } else if (view == GBGridView.MON_ACTIVITY) { - gradebookActivityDTOs = getGradebookService().getGBActivityRowsForLesson(lesson); + gradebookActivityDTOs = getGradebookService().getGBActivityRowsForLesson(lessonID); } if ((sortBy == null) || sortBy.equals("")) { @@ -382,8 +373,10 @@ if ((lesson != null) && (learner != null)) { GradebookUserLesson lessonMark = getGradebookService().getGradebookUserLesson(lessonID, userID); - writeResponse(response, LamsDispatchAction.CONTENT_TYPE_TEXT_PLAIN, LamsDispatchAction.ENCODING_UTF8, - GradebookUtil.niceFormatting(lessonMark.getMark())); + if (lessonMark.getMark() != null) { + writeResponse(response, LamsDispatchAction.CONTENT_TYPE_TEXT_PLAIN, LamsDispatchAction.ENCODING_UTF8, + GradebookUtil.niceFormatting(lessonMark.getMark())); + } } else { // Grid will handle error, just log and return null GradebookAction.logger Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java =================================================================== diff -u -r27f1c5a7f08417a5d6f5e4c7faff092f520078a6 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java (.../GradebookMonitoringAction.java) (revision 27f1c5a7f08417a5d6f5e4c7faff092f520078a6) +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/web/action/GradebookMonitoringAction.java (.../GradebookMonitoringAction.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -227,7 +227,7 @@ userID = WebUtil.readIntParam(request, GradebookConstants.PARAM_USERID); } - Activity activity = (Activity) getUserService().findById(Activity.class, activityID); + Activity activity = getGradebookService().getActivityById(activityID); if ((activity == null) || !activity.isToolActivity()) { GradebookMonitoringAction.log.error("Activity with ID " + activityID + " could not be found or it is not a Tool Activity"); Index: lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java =================================================================== diff -u -r37b49e5e78d2b57936d98e68f6057539472b7725 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java (.../ChatOutputFactory.java) (revision 37b49e5e78d2b57936d98e68f6057539472b7725) +++ lams_tool_chat/src/java/org/lamsfoundation/lams/tool/chat/service/ChatOutputFactory.java (.../ChatOutputFactory.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -63,12 +63,6 @@ Chat chat = (Chat) toolContentObject; // adding all existing conditions chatMessagesDefinition.setDefaultConditions(new ArrayList(chat.getConditions())); - // if no conditions were created in the tool instance, a default condition is added; - if (chatMessagesDefinition.getDefaultConditions().isEmpty()) { - ChatCondition defaultCondition = createDefaultUserMessagesCondition(chat); - chat.getConditions().add(defaultCondition); - chatMessagesDefinition.getDefaultConditions().add(defaultCondition); - } chatMessagesDefinition.setShowConditionNameOnly(true); definitionMap.put(ChatConstants.USER_MESSAGES_DEFINITION_NAME, chatMessagesDefinition); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java =================================================================== diff -u -r3fd384118cee7535fc2e8a3964be830e26b97612 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java (.../ForumOutputFactory.java) (revision 3fd384118cee7535fc2e8a3964be830e26b97612) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumOutputFactory.java (.../ForumOutputFactory.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -71,20 +71,11 @@ ToolOutputDefinition chosenTopicAnswersDefinition = buildComplexOutputDefinition( ForumConstants.TOPIC_DATE_TO_ANSWERS_DEFINITION_NAME, topicDatesToAnswersClass); Forum forum = (Forum) toolContentObject; - + // adding all existing conditions chosenTopicAnswersDefinition .setDefaultConditions(new ArrayList(forum.getConditions())); - - // if no conditions were created in the tool instance, a default condition is added; - if (chosenTopicAnswersDefinition.getDefaultConditions().isEmpty() && !forum.getMessages().isEmpty()) { - - ForumCondition defaultCondition = createDefaultTopicDateToAnswersCondition(forum); - if (defaultCondition != null) { - forum.getConditions().add(defaultCondition); - chosenTopicAnswersDefinition.getDefaultConditions().add(defaultCondition); - } - } + chosenTopicAnswersDefinition.setShowConditionNameOnly(true); definitionMap.put(ForumConstants.TOPIC_DATE_TO_ANSWERS_DEFINITION_NAME, chosenTopicAnswersDefinition); } @@ -143,8 +134,8 @@ } if (names == null || names.contains(ForumConstants.LEARNER_NUM_POSTS_DEFINITION_NAME)) { - outputs.put(ForumConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, getNumPosts(forumService, learnerId, - toolSessionId)); + outputs.put(ForumConstants.LEARNER_NUM_POSTS_DEFINITION_NAME, + getNumPosts(forumService, learnerId, toolSessionId)); } return outputs; @@ -226,19 +217,19 @@ * Creates a default condition so teachers know how to use complex conditions for this tool. * * @param forum - * content of the tool + * content of the tool * @return default Forum condition */ protected ForumCondition createDefaultTopicDateToAnswersCondition(Forum forum) { - + Set messages = new HashSet(); for (Message message : (Set) forum.getMessages()) { if (message.getIsAuthored() && message.getToolSession() == null) { messages.add(message); break; } } - + if (messages.isEmpty()) { return null; } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (.../QaOutputFactory.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (.../QaOutputFactory.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -74,14 +74,6 @@ // adding all existing conditions userAnswersDefinition.setDefaultConditions(new ArrayList(qaContent.getConditions())); - // if no conditions were created in the tool instance, a default condition is added; - if (userAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQueContents().isEmpty()) { - - QaCondition defaultCondition = createDefaultComplexUserAnswersCondition(qaContent); - qaContent.getConditions().add(defaultCondition); - - userAnswersDefinition.getDefaultConditions().add(defaultCondition); - } userAnswersDefinition.setShowConditionNameOnly(true); definitionMap.put(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, userAnswersDefinition); } Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java =================================================================== diff -u -r37b49e5e78d2b57936d98e68f6057539472b7725 -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java (.../NotebookOutputFactory.java) (revision 37b49e5e78d2b57936d98e68f6057539472b7725) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookOutputFactory.java (.../NotebookOutputFactory.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -62,12 +62,6 @@ Notebook notebook = (Notebook) toolContentObject; // adding all existing conditions notebookEntryDefinition.setDefaultConditions(new ArrayList(notebook.getConditions())); - // if no conditions were created in the tool instance, a default condition is added; - if (notebookEntryDefinition.getDefaultConditions().isEmpty()) { - NotebookCondition defaultCondition = createDefaultUserEntryCondition(notebook); - notebook.getConditions().add(defaultCondition); - notebookEntryDefinition.getDefaultConditions().add(defaultCondition); - } notebookEntryDefinition.setShowConditionNameOnly(true); definitionMap.put(NotebookConstants.USER_ENTRY_DEFINITION_NAME, notebookEntryDefinition); } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java =================================================================== diff -u -r4beb18f54cdba854ab69ce78c9fa313234a482cd -rf83f367fdcf4b417d1ccbd74cca5dd88dc24df7a --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java (.../SurveyOutputFactory.java) (revision 4beb18f54cdba854ab69ce78c9fa313234a482cd) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyOutputFactory.java (.../SurveyOutputFactory.java) (revision f83f367fdcf4b417d1ccbd74cca5dd88dc24df7a) @@ -66,16 +66,7 @@ // adding all existing conditions allAnswersDefinition.setDefaultConditions(new ArrayList(survey.getConditions())); - - // if no conditions were created in the tool instance, a default condition is added; - if (allAnswersDefinition.getDefaultConditions().isEmpty() && !survey.getQuestions().isEmpty()) { - - SurveyCondition defaultCondition = createDefaultComplexCondition(survey); - if (defaultCondition != null) { - survey.getConditions().add(defaultCondition); - allAnswersDefinition.getDefaultConditions().add(defaultCondition); - } - } + allAnswersDefinition.setShowConditionNameOnly(true); definitionMap.put(SurveyConstants.TEXT_SEARCH_DEFINITION_NAME, allAnswersDefinition); }