Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java,v diff -u -r1.1.2.9 -r1.1.2.10 --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java 22 Apr 2009 06:39:06 -0000 1.1.2.9 +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/GradebookService.java 22 Apr 2009 08:41:37 -0000 1.1.2.10 @@ -117,8 +117,8 @@ * manually so it can be cast as a ToolActivity - if it is one */ - Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign() - .getFirstActivity().getActivityId()); + Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign().getFirstActivity() + .getActivityId()); if (firstActivity != null && firstActivity.isToolActivity() && firstActivity instanceof ToolActivity) { @@ -162,8 +162,8 @@ * THIS IS A HACK to retrieve the first tool activity * manually so it can be cast as a ToolActivity - if it is one */ - Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign() - .getFirstActivity().getActivityId()); + Activity firstActivity = activityDAO.getActivityByActivityId(lesson.getLearningDesign().getFirstActivity() + .getActivityId()); if (firstActivity.isToolActivity() && firstActivity instanceof ToolActivity) { Grouping grouping = firstActivity.getGrouping(); @@ -519,6 +519,32 @@ return lessonRows; } + /** + * @see org.lamsfoundation.lams.gradebook.service.IGradebookService#updateActivityMark(java.lang.Double, + * java.lang.String, java.lang.Integer, java.lang.Long) + */ + public void updateActivityMark(Double mark, String feedback, Integer userID, Long toolSessionID) { + ToolSession toolSession = toolService.getToolSessionById(toolSessionID); + User learner = (User) userService.findById(User.class, userID); + if (learner != null && toolSession != null) { + ToolActivity activity = toolSession.getToolActivity(); + GradebookUserActivity gradebookUserActivity = getGradebookUserActivity(activity.getActivityId(), userID); + + // If gradebook user activity is null, save the mark and feedback + if (gradebookUserActivity == null) { + updateUserActivityGradebookMark(toolSession.getLesson(), learner, activity, mark); + } + + } + } + + /** + * Gets the internationalised date + * + * @param user + * @param date + * @return + */ private String getLocaleDateString(User user, Date date) { if (user == null || date == null) { return null; @@ -849,11 +875,10 @@ Map properties = new HashMap(); properties.put("lesson", lesson); properties.put("user", user); - List learnerProgressList = baseDAO.findByProperties(LearnerProgress.class, - properties); - - if (learnerProgressList != null && learnerProgressList.size() > 0){ - return (LearnerProgress)learnerProgressList.get(0); + List learnerProgressList = baseDAO.findByProperties(LearnerProgress.class, properties); + + if (learnerProgressList != null && learnerProgressList.size() > 0) { + return (LearnerProgress) learnerProgressList.get(0); } else { return null; } @@ -905,12 +930,12 @@ } public IActivityDAO getActivityDAO() { - return activityDAO; + return activityDAO; } public void setActivityDAO(IActivityDAO activityDAO) { - this.activityDAO = activityDAO; + this.activityDAO = activityDAO; } - + // ------------------------------------------------------------------------- } Index: lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java,v diff -u -r1.1.2.2 -r1.1.2.3 --- lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java 22 Apr 2009 03:30:58 -0000 1.1.2.2 +++ lams_gradebook/src/java/org/lamsfoundation/lams/gradebook/service/IGradebookService.java 22 Apr 2009 08:41:37 -0000 1.1.2.3 @@ -159,5 +159,15 @@ * @return */ public Double getAverageMarkForLesson(Long lessonID); + + /** + * Method for updating an activity mark that tools can call + * + * @param mark + * @param feedback + * @param userID + * @param toolSessionID + */ + public void updateActivityMark(Double mark, String feedback, Integer userID, Long toolSessionID); } Index: lams_tool_forum/.classpath =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/.classpath,v diff -u -r1.14 -r1.14.4.1 --- lams_tool_forum/.classpath 29 Jan 2009 21:55:30 -0000 1.14 +++ lams_tool_forum/.classpath 22 Apr 2009 08:41:38 -0000 1.14.4.1 @@ -13,5 +13,6 @@ + Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml,v diff -u -r1.22 -r1.22.2.1 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml 26 Mar 2009 10:00:38 -0000 1.22 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/forumApplicationContext.xml 22 Apr 2009 08:41:38 -0000 1.22.2.1 @@ -130,6 +130,9 @@ + + + uuid and versionID from the content - * repository + * This method deletes the content with the given uuid and + * versionID from the content repository * * @param uuid * The uuid of the node to be deleted @@ -538,6 +541,7 @@ } } messageDao.saveOrUpdate(msg); + } if (notifyLearnersOnMarkRelease) { notificationMessageParameters = new Object[1]; @@ -546,9 +550,18 @@ getEventNotificationService().triggerForSingleUser(ForumConstants.TOOL_SIGNATURE, ForumConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, forum.getContentId(), userID, notificationMessageParameters); + } } + List users = (List) getUsersBySessionId(sessionID); + if (users != null) { + for (ForumUser user : users) { + // send marks to gradebook where applicable + sendMarksToGradebook(user, sessionID); + } + } + // update session to set MarkRelease flag. session.setMarkReleased(true); forumToolSessionDao.saveOrUpdate(session); @@ -612,11 +625,12 @@ } /** - * This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket to login and - * access the Content Repository. + * This method verifies the credentials of the SubmitFiles Tool and gives it + * the Ticket to login and access the Content Repository. * - * A valid ticket is needed in order to access the content from the repository. This method would be called evertime - * the tool needs to upload/download files from the content repository. + * A valid ticket is needed in order to access the content from the + * repository. This method would be called evertime the tool needs to + * upload/download files from the content repository. * * @return ITicket The ticket for repostory access * @throws SubmitFilesException @@ -745,7 +759,8 @@ } /** - * Export the XML fragment for the tool's content, along with any files needed for the content. + * Export the XML fragment for the tool's content, along with any files + * needed for the content. * * @throws DataMissingException * if no tool content matches the toolSessionId @@ -792,7 +807,8 @@ } /** - * Import the XML fragment for the tool's content, along with any files needed for the content. + * Import the XML fragment for the tool's content, along with any files + * needed for the content. * * @throws ToolException * if any other error occurs @@ -844,12 +860,14 @@ } /** - * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions - * that are always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created - * for a particular activity such as the answer to the third question contains the word Koala and hence the need for - * the toolContentId + * Get the definitions for possible output for an activity, based on the + * toolContentId. These may be definitions that are always available for the + * tool (e.g. number of marks for Multiple Choice) or a custom definition + * created for a particular activity such as the answer to the third + * question contains the word Koala and hence the need for the toolContentId * - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition + * @return SortedMap of ToolOutputDefinitions with the key being the name of + * each definition */ public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { Forum forum = getForumByContentId(toolContentId); @@ -860,8 +878,8 @@ } /** - * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, - * java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, + * java.lang.String, java.lang.Long) */ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { ForumToolSession session = new ForumToolSession(); @@ -929,8 +947,8 @@ /** * Get the tool output for the given tool output names. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, - * java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, + * java.lang.Long, java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { @@ -941,8 +959,8 @@ /** * Get the tool output for the given tool output name. * - * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, - * java.lang.Long) + * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, + * java.lang.Long, java.lang.Long) */ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return forumOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); @@ -1102,7 +1120,10 @@ } - /** Set the description, throws away the title value as this is not supported in 2.0 */ + /** + * Set the description, throws away the title value as this is not supported + * in 2.0 + */ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException, DataMissingException { @@ -1116,6 +1137,31 @@ toolContentObj.setReflectInstructions(description); } + /** + * @see org.lamsfoundation.lams.tool.forum.service.IForumService#sendMarksToGradebook(org.lamsfoundation.lams.tool.forum.persistence.ForumReport, + * java.lang.Integer, java.lang.Long) + */ + @SuppressWarnings("unchecked") + public void sendMarksToGradebook(ForumUser user, Long toolSessionID) { + + List messages = (List) getMessagesByUserUid(user.getUid(), toolSessionID); + if (messages != null) { + Float totalMark = null; + for (MessageDTO message : messages) { + if (totalMark == null) { + totalMark = message.getMark(); + } else if (message.getMark() != null) { + totalMark += message.getMark(); + } + } + if (totalMark != null) { + Double mark = new Double(totalMark); + gradebookService.updateActivityMark(mark, null, user.getUserId().intValue(), toolSessionID); + } + } + + } + // *************************************************************************************************************** // Get / Set methods // *************************************************************************************************************** @@ -1142,13 +1188,13 @@ public void setForumDao(ForumDao forumDao) { this.forumDao = forumDao; } - + public TimestampDao getTimestampDao() { - return timestampDao; + return timestampDao; } public void setTimestampDao(TimestampDao timestampDao) { - this.timestampDao = timestampDao; + this.timestampDao = timestampDao; } public MessageDao getMessageDao() { @@ -1251,6 +1297,10 @@ return messageService.getMessage(key, args); } + public void setGradebookService(IGradebookService gradebookService) { + this.gradebookService = gradebookService; + } + /** * {@inheritDoc} */ @@ -1267,47 +1317,47 @@ } while (uniqueNumber == null); return getForumOutputFactory().buildTextSearchConditionName(uniqueNumber); } - + /** * Get number of new postings. * * @param messageId * @param userId - * @return + * @return */ public int getNewMessagesNum(Long messageId, Long userId) { return timestampDao.getNewMessagesNum(messageId, userId); } - + /** * Get last topic date. * * @param messageId - * @return + * @return */ public Date getLastTopicDate(Long messageId) { return messageDao.getLastTopicDate(messageId); } - + /** * Get timestamp. * * @param messageId * @param forumUserId - * @return + * @return */ public Timestamp getTimestamp(Long MessageId, Long forumUserId) throws PersistenceException { return timestampDao.getTimestamp(MessageId, forumUserId); } - + /** * Save timestamp. * * @param timestamp - * @return + * @return */ public void saveTimestamp(Timestamp timestamp) { timestampDao.saveOrUpdate(timestamp); } - + } \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java,v diff -u -r1.44 -r1.44.4.1 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 2 Feb 2009 03:38:28 -0000 1.44 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/IForumService.java 22 Apr 2009 08:41:38 -0000 1.44.4.1 @@ -431,4 +431,12 @@ public String createTextSearchConditionName(Collection existingConditions); public void deleteCondition(ForumCondition condition) throws PersistenceException; + + /** + * Sends marks straight to gradebook from a forum report + * + * @param user + * @param toolSessionID + */ + public void sendMarksToGradebook(ForumUser user, Long toolSessionID); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java,v diff -u -r1.39.6.1 -r1.39.6.2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java 22 Apr 2009 07:35:59 -0000 1.39.6.1 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/MonitoringAction.java 22 Apr 2009 08:41:38 -0000 1.39.6.2 @@ -795,6 +795,11 @@ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(markForm.getSessionMapID()); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); String updateMode = (String) sessionMap.get(ForumConstants.PARAM_UPDATE_MODE); + + // update gradebook marks if they have been released + if(report.getDateMarksReleased() != null) { + forumService.sendMarksToGradebook(user, sessionId); + } //only session has been released mark, the data of mark release will have value. ForumToolSession toolSession = forumService.getSessionBySessionId(sessionId);