Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rdded08ea618c437f0f0f6424c6b1bbf54abe5bd7 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 Binary files differ Index: lams_common/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r2db3d8c498bd34aafde968bb05d1e7d4bdec9e50 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_common/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 2db3d8c498bd34aafde968bb05d1e7d4bdec9e50) +++ lams_common/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -59,6 +59,10 @@ validation.error.first.activity =You need at least one activity in the sequence. public.folder.name =Public Folder email.notifications.problems.sending.emails =Some problems occurred while sending emails. Please, contact your system administrator. +email.notifications.course =Course +email.notifications.lesson.caption =Lesson +email.notifications.lesson =lesson +email.notifications.tool =tool +email.notifications.activity =activity - #======= End labels: Exported 53 labels for en AU ===== Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== diff -u -re64a90c0cc74118c5b88f5cbae323065abd59cac -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision e64a90c0cc74118c5b88f5cbae323065abd59cac) +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -242,14 +242,16 @@ - - - + + + + + - + PROPAGATION_REQUIRED Index: lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java =================================================================== diff -u -r1edbb81f16cedfcc1326e4eca6e520b5b48cbddc -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java (.../EventNotificationService.java) (revision 1edbb81f16cedfcc1326e4eca6e520b5b48cbddc) +++ lams_common/src/java/org/lamsfoundation/lams/events/EventNotificationService.java (.../EventNotificationService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -3,12 +3,21 @@ import java.security.InvalidParameterException; import java.util.Date; import java.util.HashSet; +import java.util.List; import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.events.dao.EventDAO; +import org.lamsfoundation.lams.learningdesign.ToolActivity; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.service.ILessonService; +import org.lamsfoundation.lams.tool.ToolSession; +import org.lamsfoundation.lams.tool.service.ILamsToolService; +import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.MessageService; import org.quartz.JobDetail; import org.quartz.Scheduler; @@ -56,6 +65,10 @@ protected IUserManagementService userManagementService; protected MessageService messageService; + + protected ILessonService lessonService; + + protected ILamsToolService toolService; /** * Quartz scheduler used for resending messages. @@ -175,10 +188,6 @@ return EventNotificationService.availableDeliveryMethods; } - public EventDAO getEventDAO() { - return eventDAO; - } - @Override public boolean isSubscribed(String scope, String name, Long eventSessionId, Long userId) throws InvalidParameterException { @@ -265,13 +274,40 @@ } return true; } + + @Override + public boolean notifyLessonMonitors(Long sessionId, String message, boolean isHtmlFormat) { + final String NEW_LINE_CHARACTER = "\r\n"; - public void setEventDAO(EventDAO eventDAO) { - this.eventDAO = eventDAO; - } + List monitoringUsers = lessonService.getMonitorsByToolSessionId(sessionId); + if (monitoringUsers == null || monitoringUsers.isEmpty()) { + return true; + } + + Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; + for (int i = 0; i < monitoringUsersIds.length; i++) { + monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); + } + + ToolSession toolSession = toolService.getToolSession(sessionId); + Lesson lesson = toolSession.getLesson(); + ToolActivity toolActivity = toolSession.getToolActivity(); + String lessonName = lesson.getLessonName(); + String activityTitle = toolActivity.getTitle(); + String toolName = toolActivity.getTool().getToolDisplayName(); + String emailSubject = toolName + " " + messageService.getMessage("email.notifications.tool") + ": " + + activityTitle + " " + messageService.getMessage("email.notifications.activity") + " - " + + lessonName + " " + messageService.getMessage("email.notifications.lesson"); - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; + String courseName = lesson.getOrganisation().getName(); + String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL).trim(); + String emailBody = messageService.getMessage("email.notifications.course") + ": " + courseName + NEW_LINE_CHARACTER + + messageService.getMessage("email.notifications.lesson.caption") + ": " + lessonName + NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + + message + NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + + serverUrl; + + return sendMessage(null, monitoringUsersIds, IEventNotificationService.DELIVERY_METHOD_MAIL, emailSubject, + emailBody, isHtmlFormat); } @Override @@ -555,10 +591,6 @@ return result; } - protected IUserManagementService getUserManagementService() { - return userManagementService; - } - /** * Saves the event into the database * @@ -577,6 +609,22 @@ } } + public EventDAO getEventDAO() { + return eventDAO; + } + + public void setEventDAO(EventDAO eventDAO) { + this.eventDAO = eventDAO; + } + + protected IUserManagementService getUserManagementService() { + return userManagementService; + } + + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + private Scheduler getScheduler() { return scheduler; } @@ -588,4 +636,20 @@ protected MessageService getMessageService() { return messageService; } + + public void setLessonService(ILessonService lessonService) { + this.lessonService = lessonService; + } + + protected ILessonService getLessonService() { + return lessonService; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + protected ILamsToolService getToolService() { + return toolService; + } } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/events/IEventNotificationService.java =================================================================== diff -u -r1edbb81f16cedfcc1326e4eca6e520b5b48cbddc -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_common/src/java/org/lamsfoundation/lams/events/IEventNotificationService.java (.../IEventNotificationService.java) (revision 1edbb81f16cedfcc1326e4eca6e520b5b48cbddc) +++ lams_common/src/java/org/lamsfoundation/lams/events/IEventNotificationService.java (.../IEventNotificationService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -14,39 +14,39 @@ /** * Scope for the events that are common for the whole LAMS environment. */ - public static final String CORE_EVENTS_SCOPE = "CORE"; + static final String CORE_EVENTS_SCOPE = "CORE"; /** * Scope for events that were created after {@link #sendMessage(Long, AbstractDeliveryMethod, String, String)} * failed. */ - public static final String SINGLE_MESSAGE_SCOPE = "SINGLE_MESSAGE"; + static final String SINGLE_MESSAGE_SCOPE = "SINGLE_MESSAGE"; /** * User should be notified only once. Used when subscribing a user to an event. */ - public static final long PERIODICITY_SINGLE = 0; + static final long PERIODICITY_SINGLE = 0; /** * User should be notified daily. Used when subscribing a user to an event. */ - public static final long PERIODICITY_DAILY = 24 * 60 * 60; + static final long PERIODICITY_DAILY = 24 * 60 * 60; /** * User should be notified weekly. Used when subscribing a user to an event. */ - public static final long PERIODICITY_WEEKLY = IEventNotificationService.PERIODICITY_DAILY * 7; + static final long PERIODICITY_WEEKLY = IEventNotificationService.PERIODICITY_DAILY * 7; /** * User should be notified monthly. Used when subscribing a user to an event. */ - public static final long PERIODICITY_MONTHLY = IEventNotificationService.PERIODICITY_WEEKLY * 4; + static final long PERIODICITY_MONTHLY = IEventNotificationService.PERIODICITY_WEEKLY * 4; /** * Allows sending mail to users using the configured SMTP server. Currently it is the only delivery method * available. */ - public static final AbstractDeliveryMethod DELIVERY_METHOD_MAIL = DeliveryMethodMail.getInstance(); + static final AbstractDeliveryMethod DELIVERY_METHOD_MAIL = DeliveryMethodMail.getInstance(); /** * Creates an event and saves it into the database. @@ -67,7 +67,7 @@ * @throws InvalidParameterException * if scope was null or name was blank */ - public abstract boolean createEvent(String scope, String name, Long eventSessionId, String defaultSubject, + abstract boolean createEvent(String scope, String name, Long eventSessionId, String defaultSubject, String defaultMessage, boolean isHtmlFormat) throws InvalidParameterException; /** @@ -83,7 +83,7 @@ * @throws InvalidParameterException * if scope was null or name was blank */ - public abstract boolean deleteEvent(String scope, String name, Long eventSessionId) + abstract boolean deleteEvent(String scope, String name, Long eventSessionId) throws InvalidParameterException;; /** @@ -99,15 +99,15 @@ * @throws InvalidParameterException * if scope was null or name was blank */ - public abstract boolean eventExists(String scope, String name, Long eventSessionId) + abstract boolean eventExists(String scope, String name, Long eventSessionId) throws InvalidParameterException; /** * Gets the available delivery methods that can be used when subscribing an user to an event. * * @return set of available delivery methods in the system */ - public abstract Set getAvailableDeliveryMethods(); + abstract Set getAvailableDeliveryMethods(); /** * Checks if an user is subscribed to the given event. @@ -125,7 +125,7 @@ * @throws InvalidParameterException * if scope or user ID were null, name was blank or event does not exist */ - public abstract boolean isSubscribed(String scope, String name, Long eventSessionId, Long userId) + abstract boolean isSubscribed(String scope, String name, Long eventSessionId, Long userId) throws InvalidParameterException; /** @@ -146,7 +146,7 @@ * @throws InvalidParameterException * if userId or delivery method are null */ - public abstract boolean sendMessage(Integer fromUserId, Integer toUserId, AbstractDeliveryMethod deliveryMethod, + abstract boolean sendMessage(Integer fromUserId, Integer toUserId, AbstractDeliveryMethod deliveryMethod, String subject, String message, boolean isHtmlFormat) throws InvalidParameterException; /** @@ -169,8 +169,18 @@ * @throws InvalidParameterException * if userId array or delivery method are null */ - public abstract boolean sendMessage(Integer fromUserId, Integer[] toUserIds, AbstractDeliveryMethod deliveryMethod, + abstract boolean sendMessage(Integer fromUserId, Integer[] toUserIds, AbstractDeliveryMethod deliveryMethod, String subject, String message, boolean isHtmlFormat) throws InvalidParameterException; + + /** + * Notify lesson monitors with the specified message + * + * @param sessionId tool session to which monitors belong + * @param message message to be sent + * @isHtmlFormat whether email is required to of HTML format + * @return + */ + boolean notifyLessonMonitors(Long sessionId, String message, boolean isHtmlFormat); /** * Registeres an user for notification of the event. If a subscription with given user ID and delivery method @@ -191,7 +201,7 @@ * @throws InvalidParameterException * if scope, userId or delivery method are null, or name is blank */ - public abstract boolean subscribe(String scope, String name, Long eventSessionId, Integer userId, + abstract boolean subscribe(String scope, String name, Long eventSessionId, Integer userId, AbstractDeliveryMethod deliveryMethod, Long periodicity) throws InvalidParameterException; /** @@ -206,7 +216,7 @@ * @throws InvalidParameterException * if scope is null or name is blank */ - public abstract boolean trigger(String scope, String name, Long eventSessionId) throws InvalidParameterException; + abstract boolean trigger(String scope, String name, Long eventSessionId) throws InvalidParameterException; /** * Triggers the event with the default subject and message, modifying placeholders ({0}, {1}, {2}...) @@ -225,7 +235,7 @@ * @throws InvalidParameterException * if scope is null or name is blank */ - public abstract boolean trigger(String scope, String name, Long eventSessionId, Object[] parameterValues) + abstract boolean trigger(String scope, String name, Long eventSessionId, Object[] parameterValues) throws InvalidParameterException; /** @@ -245,7 +255,7 @@ * @throws InvalidParameterException * if scope is null or name is blank */ - public abstract boolean trigger(String scope, String name, Long eventSessionId, String subject, String message) + abstract boolean trigger(String scope, String name, Long eventSessionId, String subject, String message) throws InvalidParameterException; /** @@ -263,7 +273,7 @@ * @throws InvalidParameterException * if scope or userId are null or name is blank */ - public abstract boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId) + abstract boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId) throws InvalidParameterException; /** @@ -286,7 +296,7 @@ * @throws InvalidParameterException * if scope or userId are null or name is blank */ - public boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId, + boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId, Object[] parameterValues) throws InvalidParameterException; /** @@ -308,7 +318,7 @@ * @throws InvalidParameterException * if scope or userId are null or name is blank */ - public abstract boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId, + abstract boolean triggerForSingleUser(String scope, String name, Long eventSessionId, Integer userId, String subject, String message) throws InvalidParameterException; /** @@ -325,7 +335,7 @@ * @throws InvalidParameterException * if scope or userId are null or name is blank */ - public abstract boolean unsubscribe(String scope, String name, Long eventSessionId, Integer userId) + abstract boolean unsubscribe(String scope, String name, Long eventSessionId, Integer userId) throws InvalidParameterException; /** @@ -344,6 +354,6 @@ * @throws InvalidParameterException * if scope, userId or delivery method are null or name is blank */ - public abstract boolean unsubscribe(String scope, String name, Long eventSessionId, Integer userId, + abstract boolean unsubscribe(String scope, String name, Long eventSessionId, Integer userId, AbstractDeliveryMethod deliveryMethod) throws InvalidParameterException; } \ No newline at end of file Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java =================================================================== diff -u -ra251a980cfb285d985de39d6fe46e32eba7ad852 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision a251a980cfb285d985de39d6fe46e32eba7ad852) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/AssessmentServiceImpl.java (.../AssessmentServiceImpl.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -107,7 +107,7 @@ */ public class AssessmentServiceImpl implements IAssessmentService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { - static Logger log = Logger.getLogger(AssessmentServiceImpl.class.getName()); + private static Logger log = Logger.getLogger(AssessmentServiceImpl.class.getName()); private AssessmentDAO assessmentDao; @@ -998,6 +998,12 @@ public String getLearnerContentFolder(Long toolSessionId, Long userId) { return toolService.getLearnerContentFolder(toolSessionId, userId); } + + @Override + public void notifyTeachersOnAttemptCompletion(Long sessionId, String userName) { + String message = getLocalisedMessage("event.learner.completes.attempt.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } // ***************************************************************************** // private methods @@ -1429,25 +1435,10 @@ this.assessmentOutputFactory = assessmentOutputFactory; } - public ILessonService getLessonService() { - return lessonService; - } - public void setLessonService(ILessonService lessonService) { this.lessonService = lessonService; } - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getAssessmentOutputFactory().getSupportedDefinitionClasses(definitionType); } Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java =================================================================== diff -u -ref851974c4dc3f5468b188fab9997a37b73c0e50 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision ef851974c4dc3f5468b188fab9997a37b73c0e50) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/service/IAssessmentService.java (.../IAssessmentService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -279,7 +279,7 @@ */ AssessmentUser getUser(Long uid); - public IEventNotificationService getEventNotificationService(); + void notifyTeachersOnAttemptCompletion(Long sessionId, String userName); /** * Gets a message from assessment bundle. Same as in JSP pages. @@ -291,22 +291,13 @@ * @return message content */ String getLocalisedMessage(String key, Object[] args); - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId); /** * Get a message from the language files with the given key * @param key * @return */ - public String getMessage(String key); + String getMessage(String key); /** * Returns whether activity is grouped and therefore it is expected more than one tool session. Index: lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java =================================================================== diff -u -rf2fa59eadd6bb842ff33c567ca2d9e6d825071eb -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision f2fa59eadd6bb842ff33c567ca2d9e6d825071eb) +++ lams_tool_assessment/src/java/org/lamsfoundation/lams/tool/assessment/web/action/LearningAction.java (.../LearningAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -167,7 +167,7 @@ assessmentUser = getSpecifiedUser(service, toolSessionId, WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); } else { - assessmentUser = getCurrentUser(service, toolSessionId); + assessmentUser = getCurrentUser(toolSessionId); } Assessment assessment = service.getAssessmentBySessionId(toolSessionId); @@ -833,6 +833,7 @@ * Store user answers in DB in last unfinished attempt and notify teachers about it. */ private void storeUserAnswersIntoDatabase(SessionMap sessionMap, boolean isAutosave) { + ArrayList> pagedQuestions = (ArrayList>) sessionMap .get(AssessmentConstants.ATTR_PAGED_QUESTIONS); Long assessmentUid = ((Assessment) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT)).getUid(); @@ -842,29 +843,13 @@ // notify teachers ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); - if ((mode != null) && !mode.isTeacher() && !isAutosave) { - - Assessment assessment = (Assessment) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT); - if (assessment.isNotifyTeachersOnAttemptCompletion()) { - - Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - final boolean isHtmlFormat = false; - List monitoringUsers = service.getMonitorsByToolSessionId(toolSessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - AssessmentUser assessmentUser = getCurrentUser(service, toolSessionId); - String fullName = assessmentUser.getLastName() + " " + assessmentUser.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.learner.completes.attempt.subject", null), - service.getLocalisedMessage("event.learner.completes.attempt.body", new Object[] { fullName }), - isHtmlFormat); - } - - } + Assessment assessment = (Assessment) sessionMap.get(AssessmentConstants.ATTR_ASSESSMENT); + if ((mode != null) && !mode.isTeacher() && !isAutosave && assessment.isNotifyTeachersOnAttemptCompletion()) { + + Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + AssessmentUser assessmentUser = getCurrentUser(toolSessionId); + String fullName = assessmentUser.getLastName() + " " + assessmentUser.getFirstName(); + service.notifyTeachersOnAttemptCompletion(toolSessionId, fullName); } } @@ -874,7 +859,9 @@ return (IAssessmentService) wac.getBean(AssessmentConstants.ASSESSMENT_SERVICE); } - private AssessmentUser getCurrentUser(IAssessmentService service, Long sessionId) { + private AssessmentUser getCurrentUser(Long sessionId) { + IAssessmentService service = getAssessmentService(); + // try to get form system session HttpSession ss = SessionManager.getSession(); // get back login user DTO Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml (.../dacoApplicationContext.xml) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml (.../dacoApplicationContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -92,8 +92,7 @@ - - + Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -45,15 +45,13 @@ import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; -import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; @@ -86,18 +84,13 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; -import org.lamsfoundation.lams.util.audit.IAuditService; /** - * * @author Dapeng.Ni - * */ -public class DacoServiceImpl implements IDacoService, ToolContentManager, ToolSessionManager +public class DacoServiceImpl implements IDacoService, ToolContentManager, ToolSessionManager { + private static Logger log = Logger.getLogger(DacoServiceImpl.class.getName()); -{ - static Logger log = Logger.getLogger(DacoServiceImpl.class.getName()); - private DacoDAO dacoDao; private DacoQuestionDAO dacoQuestionDao; @@ -128,10 +121,9 @@ private IEventNotificationService eventNotificationService; - private ILessonService lessonService; - private DacoOutputFactory dacoOutputFactory; + @Override public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException { if (toContentId == null) { throw new ToolException("Failed to create the Data Collection tool seession"); @@ -153,12 +145,14 @@ dacoDao.saveObject(toContent); } + @Override public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + @Override public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { DacoSession session = new DacoSession(); session.setSessionId(toolSessionId); @@ -168,24 +162,29 @@ dacoSessionDao.saveObject(session); } + @Override public void createUser(DacoUser dacoUser) { dacoUserDao.saveObject(dacoUser); } + @Override public void deleteDacoAnswer(Long uid) { dacoAnswerDao.removeObject(DacoAnswer.class, uid); } + @Override public void deleteDacoQuestion(Long uid) { dacoQuestionDao.removeObject(DacoQuestion.class, uid); } + @Override public void deleteDacoRecord(List record) { for (DacoAnswer answer : record) { deleteDacoAnswer(answer.getUid()); } } + @Override public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException { ITicket ticket = getRepositoryLoginTicket(); try { @@ -196,6 +195,7 @@ } } + @Override public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException { Daco toolContentObj = dacoDao.getByContentId(toolContentId); if (toolContentObj == null) { @@ -219,15 +219,18 @@ } } + @Override public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException { return null; } + @Override public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException { return null; } + @Override public String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException { DacoUser user = dacoUserDao.getUserByUserIdAndSessionId(userId, toolSessionId); user.setSessionFinished(true); @@ -244,10 +247,7 @@ return nextUrl; } - public ICoreNotebookService getCoreNotebookService() { - return coreNotebookService; - } - + @Override public List> getDacoAnswersByUserUid(Long userUid) { DacoUser user = getUser(userUid); Set answers = user.getAnswers(); @@ -270,6 +270,7 @@ return result; } + @Override public Daco getDacoByContentId(Long contentId) { Daco daco = dacoDao.getByContentId(contentId); if (daco == null) { @@ -278,15 +279,18 @@ return daco; } + @Override public Daco getDacoBySessionId(Long sessionId) { DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId); return session.getDaco(); } + @Override public DacoQuestion getDacoQuestionByUid(Long questionUid) { return dacoQuestionDao.getByUid(questionUid); } + @Override public Daco getDefaultContent(Long contentId) throws DacoApplicationException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); @@ -316,6 +320,7 @@ return defaultDaco; } + @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); if (list == null || list.isEmpty()) { @@ -325,6 +330,37 @@ } } + @Override + public void updateEntry(NotebookEntry notebookEntry) { + coreNotebookService.updateEntry(notebookEntry); + } + + @Override + public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException { + try { + InputStream is = file.getInputStream(); + String fileName = file.getFileName(); + String fileType = file.getContentType(); + // For file only upload one sigle file + if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE + || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) { + NodeKey nodeKey = processFile(file); + answer.setFileUuid(nodeKey.getUuid()); + answer.setFileVersionId(nodeKey.getVersion()); + } + + // create the package from the directory contents + answer.setFileType(fileType); + answer.setFileName(fileName); + } catch (FileNotFoundException e) { + DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString()); + throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); + } catch (IOException e) { + DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString()); + throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); + } + } + // ******************************************************************************* // Service method // ******************************************************************************* @@ -366,6 +402,7 @@ } } + @Override public IVersionedNode getFileNode(Long answerUid, String relPathString) throws DacoApplicationException { DacoAnswer answer = (DacoAnswer) dacoAnswerDao.getObject(DacoQuestion.class, answerUid); if (answer == null) { @@ -374,7 +411,8 @@ return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString); } - + + @Override public Integer getGroupRecordCount(Long sessionId) { List users = dacoUserDao.getBySessionId(sessionId); @@ -385,6 +423,7 @@ return groupRecordCount; } + @Override public Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary) { if (monitoringSummary == null) { return null; @@ -396,10 +435,12 @@ return groupRecordCount; } + @Override public String getLocalisedMessage(String key, Object[] args) { return messageService.getMessage(key, args); } + @Override public List getMonitoringSummary(Long contentId, Long userUid) { List sessions = dacoSessionDao.getByContentId(contentId); List result = new ArrayList(sessions.size()); @@ -437,6 +478,7 @@ return result; } + @Override public List getQuestionSummaries(Long userUid) { List result = new ArrayList(); DacoUser user = (DacoUser) dacoUserDao.getObject(DacoUser.class, userUid); @@ -482,6 +524,20 @@ } return result; } + + @Override + public void notifyTeachersOnLearnerEntry(Long sessionId, DacoUser dacoUser) { + String userName = dacoUser.getLastName() + " " + dacoUser.getFirstName(); + String message = getLocalisedMessage("event.learnerentry.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } + + @Override + public void notifyTeachersOnRecordSumbit(Long sessionId, DacoUser dacoUser) { + String userName = dacoUser.getLastName() + " " + dacoUser.getFirstName(); + String message = getLocalisedMessage("event.recordsubmit.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } /** * This method verifies the credentials of the Daco Tool and gives it the Ticket to login and access @@ -584,10 +640,9 @@ } - public IUserManagementService getUserManagementService() { - return userManagementService; - } - + /* + * ===============Methods implemented from ToolContentImport102Manager =============== + */ public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion, String toVersion) throws ToolException { @@ -778,16 +833,18 @@ // set methods for Spring Bean // ***************************************************************************** + public ICoreNotebookService getCoreNotebookService() { + return coreNotebookService; + } + + public IUserManagementService getUserManagementService() { + return userManagementService; + } + public void setCoreNotebookService(ICoreNotebookService coreNotebookService) { this.coreNotebookService = coreNotebookService; } - /* - * ===============Methods implemented from ToolContentImport102Manager =============== - */ - - /* =================================================================================== */ - public void setDacoDao(DacoDAO dacoDao) { this.dacoDao = dacoDao; } @@ -832,38 +889,6 @@ this.userManagementService = userManagementService; } - /** - * @param notebookEntry - */ - public void updateEntry(NotebookEntry notebookEntry) { - coreNotebookService.updateEntry(notebookEntry); - } - - public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException { - try { - InputStream is = file.getInputStream(); - String fileName = file.getFileName(); - String fileType = file.getContentType(); - // For file only upload one sigle file - if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE - || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) { - NodeKey nodeKey = processFile(file); - answer.setFileUuid(nodeKey.getUuid()); - answer.setFileVersionId(nodeKey.getVersion()); - } - - // create the package from the directory contents - answer.setFileType(fileType); - answer.setFileName(fileName); - } catch (FileNotFoundException e) { - DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString()); - throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found")); - } catch (IOException e) { - DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString()); - throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception")); - } - } - public DacoAnswerDAO getDacoAnswerDao() { return dacoAnswerDao; } @@ -880,18 +905,6 @@ this.eventNotificationService = eventNotificationService; } - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - - public ILessonService getLessonService() { - return lessonService; - } - - public void setLessonService(ILessonService lessonService) { - this.lessonService = lessonService; - } - public int getRecordNum(Long userID, Long sessionId) { return dacoAnswerDao.getUserRecordCount(userID, sessionId); } Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -28,7 +28,6 @@ import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.contentrepository.IVersionedNode; -import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.daco.dao.DacoAnswerDAO; import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummarySessionDTO; @@ -222,6 +221,10 @@ * @return message content */ String getLocalisedMessage(String key, Object[] args); + + void notifyTeachersOnLearnerEntry(Long sessionId, DacoUser dacoUser); + + void notifyTeachersOnRecordSumbit(Long sessionId, DacoUser dacoUser); /** * Returns summaries for particular questions. A list of {@link QuestionSummaryDTO question summaries} is created, @@ -283,18 +286,14 @@ */ List getMonitoringSummary(Long contentId, Long userUid); - IEventNotificationService getEventNotificationService(); - - public List getMonitorsByToolSessionId(Long sessionId); - /** * Get how many records has the given user posted. * * @param userID * @param sessionId * @return */ - public int getRecordNum(Long userID, Long sessionId); + int getRecordNum(Long userID, Long sessionId); boolean isGroupedActivity(long toolContentID); } Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java (.../LearningAction.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java (.../LearningAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -237,20 +237,7 @@ sessionMap.put(DacoConstants.ATTR_DACO, daco); if (daco.isNotifyTeachersOnLearnerEntry()) { - final boolean isHtmlFormat = false; - - List monitoringUsers = service.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = dacoUser.getLastName() + " " + dacoUser.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.learnerentry.subject", null), - service.getLocalisedMessage("event.learnerentry.body", new Object[] { fullName }), - isHtmlFormat); - } + service.notifyTeachersOnLearnerEntry(sessionId, dacoUser); } return mapping.findForward(DacoConstants.SUCCESS); @@ -496,23 +483,8 @@ request.setAttribute(DacoConstants.ATTR_RECORD_OPERATION_SUCCESS, DacoConstants.RECORD_OPERATION_ADD); // notify teachers - if (daco.isNotifyTeachersOnRecordSumbit()) { - final boolean isHtmlFormat = false; - - List monitoringUsers = service.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = user.getLastName() + " " + user.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.recordsubmit.subject", null), - service.getLocalisedMessage("event.recordsubmit.body", new Object[] { fullName }), - isHtmlFormat); - } + service.notifyTeachersOnRecordSumbit(sessionId, user); } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java =================================================================== diff -u -r281244f5d518e88719ffc871ac71bb03136cb03e -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision 281244f5d518e88719ffc871ac71bb03136cb03e) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/service/ForumService.java (.../ForumService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -1459,19 +1459,9 @@ } if (forum.isNotifyTeachersOnForumPosting()) { - List monitoringUsers = lessonService.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - ArrayList monitoringUsersIds = new ArrayList(); - for (User monitoringUser : monitoringUsers) { - monitoringUsersIds.add(monitoringUser.getUserId()); - } - - getEventNotificationService().sendMessage(null, monitoringUsersIds.toArray(new Integer[0]), - IEventNotificationService.DELIVERY_METHOD_MAIL, - getLocalisedMessage("event.newposting.subject", new Object[] { forum.getTitle() }), - getLocalisedMessage("event.newposting.body", new Object[] { fullName, message.getBody() }), - isHtmlFormat); - } + String emailMessage = getLocalisedMessage("event.newposting.body", + new Object[] { fullName, message.getBody() }); + getEventNotificationService().notifyLessonMonitors(sessionId, emailMessage, isHtmlFormat); } } Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/imageGalleryApplicationContext.xml =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/imageGalleryApplicationContext.xml (.../imageGalleryApplicationContext.xml) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/imageGalleryApplicationContext.xml (.../imageGalleryApplicationContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -120,8 +120,7 @@ - - + Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/IImageGalleryService.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/IImageGalleryService.java (.../IImageGalleryService.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/IImageGalleryService.java (.../IImageGalleryService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -298,9 +298,9 @@ * imageGallery item * @return */ - public List>> exportBySessionId(Long sessionId, ImageGalleryUser user, boolean skipHide); + List>> exportBySessionId(Long sessionId, ImageGalleryUser user, boolean skipHide); - public List>> exportByContentId(Long contentId); + List>> exportByContentId(Long contentId); /** * Create refection entry into notebook tool. @@ -311,7 +311,7 @@ * @param userId * @param entryText */ - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText); /** @@ -323,12 +323,12 @@ * @param userID * @return */ - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); + NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); /** * @param notebookEntry */ - public void updateEntry(NotebookEntry notebookEntry); + void updateEntry(NotebookEntry notebookEntry); /** * Get Reflect DTO list grouped by sessionID. @@ -363,18 +363,16 @@ * @param key * @return */ - public ImageGalleryConfigItem getConfigItem(String key); + ImageGalleryConfigItem getConfigItem(String key); /** * Save a ImageGallery configItem * * @param item */ - public void saveOrUpdateImageGalleryConfigItem(ImageGalleryConfigItem item); + void saveOrUpdateImageGalleryConfigItem(ImageGalleryConfigItem item); - IEventNotificationService getEventNotificationService(); - - public List getMonitorsByToolSessionId(Long sessionId); + void notifyTeachersOnImageSumbit(Long sessionId, ImageGalleryUser imageGalleryUser); /** * Returns whether activity is grouped and therefore it is expected more than one tool session. Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java (.../ImageGalleryServiceImpl.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/service/ImageGalleryServiceImpl.java (.../ImageGalleryServiceImpl.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -44,18 +44,9 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.upload.FormFile; -import org.lamsfoundation.lams.contentrepository.AccessDeniedException; -import org.lamsfoundation.lams.contentrepository.ICredentials; -import org.lamsfoundation.lams.contentrepository.ITicket; -import org.lamsfoundation.lams.contentrepository.IVersionedNode; import org.lamsfoundation.lams.contentrepository.InvalidParameterException; -import org.lamsfoundation.lams.contentrepository.LoginException; import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; -import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; -import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; -import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; @@ -164,12 +155,11 @@ private IEventNotificationService eventNotificationService; - private ILessonService lessonService; - // ******************************************************************************* // Service method // ******************************************************************************* + @Override public ImageGallery getImageGalleryByContentId(Long contentId) { ImageGallery rs = imageGalleryDao.getByContentId(contentId); if (rs == null) { @@ -178,6 +168,7 @@ return rs; } + @Override public ImageGallery getDefaultContent(Long contentId) throws ImageGalleryException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); @@ -193,34 +184,42 @@ return content; } + @Override public List getAuthoredItems(Long imageGalleryUid) { return imageGalleryItemDao.getAuthoringItems(imageGalleryUid); } + @Override public void saveUser(ImageGalleryUser imageGalleryUser) { imageGalleryUserDao.saveObject(imageGalleryUser); } + @Override public ImageGalleryUser getUserByIDAndContent(Long userId, Long contentId) { return imageGalleryUserDao.getUserByUserIDAndContentID(userId, contentId); } + @Override public ImageGalleryUser getUserByIDAndSession(Long userId, Long sessionId) { return imageGalleryUserDao.getUserByUserIDAndSessionID(userId, sessionId); } + @Override public void saveOrUpdateImageGallery(ImageGallery imageGallery) { imageGalleryDao.saveObject(imageGallery); } + @Override public ImageGalleryItem getImageGalleryItemByUid(Long itemUid) { return imageGalleryItemDao.getByUid(itemUid); } + @Override public void saveOrUpdateImageGalleryItem(ImageGalleryItem image) { imageGalleryItemDao.saveObject(image); } + @Override public void deleteImage(Long toolSessionId, Long imageUid) { ImageGallery imageGallery = getImageGalleryBySessionId(toolSessionId); ImageGalleryItem image = getImageGalleryItemByUid(imageUid); @@ -231,10 +230,12 @@ saveOrUpdateImageGallery(imageGallery); } + @Override public ImageRating getImageRatingByImageAndUser(Long imageUid, Long userId) { return imageRatingDao.getImageRatingByImageAndUser(imageUid, userId); } + @Override public void saveOrUpdateImageRating(ImageRating rating) { imageRatingDao.saveObject(rating); } @@ -243,30 +244,37 @@ return imageVoteDao.getImageVoteByImageAndUser(imageUid, userId); } + @Override public int getNumberVotesByUserId(Long userId) { return imageVoteDao.getNumImageVotesByUserId(userId); } + @Override public void saveOrUpdateImageVote(ImageVote vote) { imageVoteDao.saveObject(vote); } + @Override public ImageComment getImageCommentByUid(Long commentUid) { return imageCommentDao.getCommentByUid(commentUid); } + @Override public void saveImageComment(ImageComment comment) { imageCommentDao.saveObject(comment); } + @Override public void deleteImageComment(Long uid) { imageCommentDao.removeObject(ImageComment.class, uid); } + @Override public void deleteImageGalleryItem(Long uid) { imageGalleryItemDao.removeObject(ImageGalleryItem.class, uid); } + @Override public ImageGallery getImageGalleryBySessionId(Long sessionId) { ImageGallerySession session = imageGallerySessionDao.getSessionBySessionId(sessionId); // to skip CGLib problem @@ -275,14 +283,17 @@ return res; } + @Override public ImageGallerySession getImageGallerySessionBySessionId(Long sessionId) { return imageGallerySessionDao.getSessionBySessionId(sessionId); } + @Override public void saveOrUpdateImageGallerySession(ImageGallerySession resSession) { imageGallerySessionDao.saveObject(resSession); } + @Override public void setItemAccess(Long imageGalleryItemUid, Long userId, Long sessionId) { ImageGalleryItemVisitLog log = imageGalleryItemVisitDao.getImageGalleryItemLog(imageGalleryItemUid, userId); if (log == null) { @@ -298,6 +309,7 @@ } } + @Override public String finishToolSession(Long toolSessionId, Long userId) throws ImageGalleryException { ImageGalleryUser user = imageGalleryUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); @@ -318,10 +330,12 @@ return nextUrl; } + @Override public List getUserListBySessionId(Long sessionId) { return imageGalleryUserDao.getBySessionID(sessionId); } + @Override public void setItemVisible(Long itemUid, boolean visible) { ImageGalleryItem item = imageGalleryItemDao.getByUid(itemUid); if (item != null) { @@ -342,12 +356,14 @@ } } + @Override public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); if (list == null || list.isEmpty()) { @@ -357,17 +373,17 @@ } } - /** - * @param notebookEntry - */ + @Override public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } + @Override public ImageGalleryUser getUser(Long uid) { return (ImageGalleryUser) imageGalleryUserDao.getObject(ImageGalleryUser.class, uid); } + @Override public List> getSummary(Long contentId) { List> groupList = new ArrayList>(); List group = new ArrayList(); @@ -403,6 +419,7 @@ return groupList; } + @Override public List> getImageSummary(Long contentId, Long imageUid) { List> imageSummary = new ArrayList>(); List group = new ArrayList(); @@ -434,6 +451,7 @@ } + @Override public Map> getReflectList(Long contentId, boolean setEntry) { Map> map = new HashMap>(); @@ -464,6 +482,7 @@ return map; } + @Override public List>> exportBySessionId(Long sessionId, ImageGalleryUser user, boolean skipHide) { ImageGallerySession session = imageGallerySessionDao.getSessionBySessionId(sessionId); @@ -497,6 +516,7 @@ return sessionList; } + @Override public List>> exportByContentId(Long contentId) { ImageGallery imageGallery = imageGalleryDao.getByContentId(contentId); List>> sessionList = new ArrayList(); @@ -528,6 +548,7 @@ return sessionList; } + @Override public void uploadImageGalleryItemFile(ImageGalleryItem image, FormFile file) throws UploadImageGalleryFileException { try { @@ -617,9 +638,17 @@ return node; } + @Override public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } + + @Override + public void notifyTeachersOnImageSumbit(Long sessionId, ImageGalleryUser imageGalleryUser) { + String userName = imageGalleryUser.getLastName() + " " + imageGalleryUser.getFirstName(); + String message = getLocalisedMessage("event.imagesubmit.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } // ***************************************************************************** // set methods for Spring Bean @@ -1045,26 +1074,10 @@ this.coreNotebookService = coreNotebookService; } - public IEventNotificationService getEventNotificationService() { - return eventNotificationService; - } - public void setEventNotificationService(IEventNotificationService eventNotificationService) { this.eventNotificationService = eventNotificationService; } - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - - public ILessonService getLessonService() { - return lessonService; - } - - public void setLessonService(ILessonService lessonService) { - this.lessonService = lessonService; - } - public String getLocalisedMessage(String key, Object[] args) { return messageService.getMessage(key, args); } Index: lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/web/action/LearningAction.java =================================================================== diff -u -r6d674e346dea6ce7a824366c8a7c315660677744 -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/web/action/LearningAction.java (.../LearningAction.java) (revision 6d674e346dea6ce7a824366c8a7c315660677744) +++ lams_tool_images/src/java/org/lamsfoundation/lams/tool/imageGallery/web/action/LearningAction.java (.../LearningAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -824,20 +824,7 @@ // notify teachers if (imageGallery.isNotifyTeachersOnImageSumbit()) { - final boolean isHtmlFormat = false; - - List monitoringUsers = service.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = imageGalleryUser.getLastName() + " " + imageGalleryUser.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.imagesubmit.subject", null), - service.getLocalisedMessage("event.imagesubmit.body", new Object[] { fullName }), isHtmlFormat); - } + service.notifyTeachersOnImageSumbit(sessionId, imageGalleryUser); } } Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/rsrcApplicationContext.xml =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/rsrcApplicationContext.xml (.../rsrcApplicationContext.xml) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/rsrcApplicationContext.xml (.../rsrcApplicationContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -91,11 +91,8 @@ - - - - - + + Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/IResourceService.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/IResourceService.java (.../IResourceService.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/IResourceService.java (.../IResourceService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -219,9 +219,9 @@ * resource item * @return */ - public List exportBySessionId(Long sessionId, boolean skipHide); + List exportBySessionId(Long sessionId, boolean skipHide); - public List> exportByContentId(Long contentId); + List> exportByContentId(Long contentId); /** * Create refection entry into notebook tool. @@ -232,7 +232,7 @@ * @param userId * @param entryText */ - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText); /** @@ -244,12 +244,12 @@ * @param userID * @return */ - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); + NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); /** * @param notebookEntry */ - public void updateEntry(NotebookEntry notebookEntry); + void updateEntry(NotebookEntry notebookEntry); /** * Get Reflect DTO list grouped by sessionID. @@ -267,27 +267,7 @@ */ ResourceUser getUser(Long uid); - public IEventNotificationService getEventNotificationService(); - - /** - * Gets a message from resource bundle. Same as in JSP pages. - * - * @param key - * key of the message - * @param args - * arguments for the message - * @return message content - */ - String getLocalisedMessage(String key, Object[] args); - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId); + void notifyTeachersOnAssigmentSumbit(Long sessionId, ResourceUser resourceUser); /** * Returns whether activity is grouped and therefore it is expected more than one tool session. Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java (.../ResourceServiceImpl.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/service/ResourceServiceImpl.java (.../ResourceServiceImpl.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -56,15 +56,13 @@ import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.WorkspaceNotFoundException; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.contentrepository.service.IRepositoryService; import org.lamsfoundation.lams.contentrepository.service.SimpleCredentials; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.learning.service.ILearnerService; import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; -import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; @@ -110,16 +108,12 @@ import org.lamsfoundation.lams.util.zipfile.ZipFileUtilException; /** - * * @author Dapeng.Ni - * */ public class ResourceServiceImpl implements IResourceService, ToolContentManager, ToolSessionManager, - ToolContentImport102Manager + ToolContentImport102Manager { + private static Logger log = Logger.getLogger(ResourceServiceImpl.class.getName()); -{ - static Logger log = Logger.getLogger(ResourceServiceImpl.class.getName()); - private ResourceDAO resourceDao; private ResourceItemDAO resourceItemDao; @@ -152,10 +146,9 @@ private IEventNotificationService eventNotificationService; - private ILessonService lessonService; - private ResourceOutputFactory resourceOutputFactory; + @Override public IVersionedNode getFileNode(Long itemUid, String relPathString) throws ResourceApplicationException { ResourceItem item = (ResourceItem) resourceItemDao.getObject(ResourceItem.class, itemUid); if (item == null) { @@ -232,6 +225,7 @@ } } + @Override public Resource getResourceByContentId(Long contentId) { Resource rs = resourceDao.getByContentId(contentId); if (rs == null) { @@ -240,6 +234,7 @@ return rs; } + @Override public Resource getDefaultContent(Long contentId) throws ResourceApplicationException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); @@ -254,26 +249,31 @@ return content; } + @Override public List getAuthoredItems(Long resourceUid) { return resourceItemDao.getAuthoringItems(resourceUid); } + @Override public void createUser(ResourceUser resourceUser) { resourceUserDao.saveObject(resourceUser); } + @Override public ResourceUser getUserByIDAndContent(Long userId, Long contentId) { return resourceUserDao.getUserByUserIDAndContentID(userId, contentId); } + @Override public ResourceUser getUserByIDAndSession(Long userId, Long sessionId) { return resourceUserDao.getUserByUserIDAndSessionID(userId, sessionId); } + @Override public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws ResourceApplicationException { ITicket ticket = getRepositoryLoginTicket(); try { @@ -284,18 +284,17 @@ } } + @Override public void saveOrUpdateResource(Resource resource) { resourceDao.saveObject(resource); } - public void saveOrUpdateResourceItem(ResourceItem item) { - resourceItemDao.saveObject(item); - } - + @Override public void deleteResourceItem(Long uid) { resourceItemDao.removeObject(ResourceItem.class, uid); } + @Override public List getResourceItemsBySessionId(Long sessionId) { ResourceSession session = resourceSessionDao.getSessionBySessionId(sessionId); if (session == null) { @@ -313,6 +312,7 @@ return items; } + @Override public List exportBySessionId(Long sessionId, boolean skipHide) { ResourceSession session = resourceSessionDao.getSessionBySessionId(sessionId); if (session == null) { @@ -350,6 +350,7 @@ return itemList; } + @Override public List> exportByContentId(Long contentId) { Resource resource = resourceDao.getByContentId(contentId); List> groupList = new ArrayList(); @@ -387,6 +388,7 @@ return groupList; } + @Override public Resource getResourceBySessionId(Long sessionId) { ResourceSession session = resourceSessionDao.getSessionBySessionId(sessionId); // to skip CGLib problem @@ -399,14 +401,17 @@ return res; } + @Override public ResourceSession getResourceSessionBySessionId(Long sessionId) { return resourceSessionDao.getSessionBySessionId(sessionId); } + @Override public void saveOrUpdateResourceSession(ResourceSession resSession) { resourceSessionDao.saveObject(resSession); } + @Override public void retrieveComplete(SortedSet resourceItemList, ResourceUser user) { for (ResourceItem item : resourceItemList) { ResourceItemVisitLog log = resourceItemVisitDao.getResourceItemLog(item.getUid(), user.getUserId()); @@ -418,6 +423,7 @@ } } + @Override public void setItemComplete(Long resourceItemUid, Long userId, Long sessionId) { ResourceItemVisitLog log = resourceItemVisitDao.getResourceItemLog(resourceItemUid, userId); if (log == null) { @@ -434,6 +440,7 @@ resourceItemVisitDao.saveObject(log); } + @Override public void setItemAccess(Long resourceItemUid, Long userId, Long sessionId) { ResourceItemVisitLog log = resourceItemVisitDao.getResourceItemLog(resourceItemUid, userId); if (log == null) { @@ -449,6 +456,7 @@ } } + @Override public String finishToolSession(Long toolSessionId, Long userId) throws ResourceApplicationException { ResourceUser user = resourceUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); @@ -469,6 +477,7 @@ return nextUrl; } + @Override public int checkMiniView(Long toolSessionId, Long userUid) { int miniView = resourceItemVisitDao.getUserViewLogCount(toolSessionId, userUid); ResourceSession session = resourceSessionDao.getSessionBySessionId(toolSessionId); @@ -481,10 +490,12 @@ return reqView - miniView; } + @Override public ResourceItem getResourceItemByUid(Long itemUid) { return resourceItemDao.getByUid(itemUid); } + @Override public List> getSummary(Long contentId) { List> groupList = new ArrayList>(); List group = new ArrayList(); @@ -534,6 +545,7 @@ } + @Override public Map> getReflectList(Long contentId, boolean setEntry) { Map> map = new HashMap>(); @@ -564,6 +576,7 @@ return map; } + @Override public List getUserListBySessionItem(Long sessionId, Long itemUid) { List logList = resourceItemVisitDao.getResourceItemLogBySession(sessionId, itemUid); List userList = new ArrayList(logList.size()); @@ -579,6 +592,7 @@ return userList; } + @Override public void setItemVisible(Long itemUid, boolean visible) { ResourceItem item = resourceItemDao.getByUid(itemUid); if (item != null) { @@ -599,12 +613,14 @@ } } + @Override public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); if (list == null || list.isEmpty()) { @@ -614,16 +630,22 @@ } } - /** - * @param notebookEntry - */ + @Override public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } + @Override public ResourceUser getUser(Long uid) { return (ResourceUser) resourceUserDao.getObject(ResourceUser.class, uid); } + + @Override + public void notifyTeachersOnAssigmentSumbit(Long sessionId, ResourceUser resourceUser) { + String userName = resourceUser.getLastName() + " " + resourceUser.getFirstName(); + String message = getLocalisedMessage("event.assigment.submit.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } // ***************************************************************************** // private methods @@ -691,6 +713,7 @@ return node; } + @Override public void uploadResourceItemFile(ResourceItem item, FormFile file) throws UploadResourceFileException { try { InputStream is = file.getInputStream(); @@ -750,7 +773,7 @@ throw new UploadResourceFileException(messageService.getMessage("error.msg.ims.application")); } } - + /** * Find out default.htm/html or index.htm/html in the given directory folder * @@ -782,62 +805,24 @@ return null; } } + + /** + * Gets a message from resource bundle. Same as in JSP pages. + * + * @param key + * key of the message + * @param args + * arguments for the message + * @return message content + */ + private String getLocalisedMessage(String key, Object[] args) { + return messageService.getMessage(key, args); + } public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } - - // ***************************************************************************** - // set methods for Spring Bean - // ***************************************************************************** - public void setAuditService(IAuditService auditService) { - this.auditService = auditService; - } - - public void setLearnerService(ILearnerService learnerService) { - this.learnerService = learnerService; - } - - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } - - public void setRepositoryService(IRepositoryService repositoryService) { - this.repositoryService = repositoryService; - } - - public void setResourceDao(ResourceDAO resourceDao) { - this.resourceDao = resourceDao; - } - - public void setResourceItemDao(ResourceItemDAO resourceItemDao) { - this.resourceItemDao = resourceItemDao; - } - - public void setResourceSessionDao(ResourceSessionDAO resourceSessionDao) { - this.resourceSessionDao = resourceSessionDao; - } - - public void setResourceToolContentHandler(ResourceToolContentHandler resourceToolContentHandler) { - this.resourceToolContentHandler = resourceToolContentHandler; - } - - public void setResourceUserDao(ResourceUserDAO resourceUserDao) { - this.resourceUserDao = resourceUserDao; - } - - public void setToolService(ILamsToolService toolService) { - this.toolService = toolService; - } - - public ResourceItemVisitDAO getResourceItemVisitDao() { - return resourceItemVisitDao; - } - - public void setResourceItemVisitDao(ResourceItemVisitDAO resourceItemVisitDao) { - this.resourceItemVisitDao = resourceItemVisitDao; - } - + // ******************************************************************************* // ToolContentManager, ToolSessionManager methods // ******************************************************************************* @@ -1259,8 +1244,61 @@ toolContentObj.setReflectInstructions(description); } - /* =================================================================================== */ + public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { + return getResourceOutputFactory().getSupportedDefinitionClasses(definitionType); + } + + // ***************************************************************************** + // set methods for Spring Bean + // ***************************************************************************** + public void setAuditService(IAuditService auditService) { + this.auditService = auditService; + } + public void setLearnerService(ILearnerService learnerService) { + this.learnerService = learnerService; + } + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + + public void setRepositoryService(IRepositoryService repositoryService) { + this.repositoryService = repositoryService; + } + + public void setResourceDao(ResourceDAO resourceDao) { + this.resourceDao = resourceDao; + } + + public void setResourceItemDao(ResourceItemDAO resourceItemDao) { + this.resourceItemDao = resourceItemDao; + } + + public void setResourceSessionDao(ResourceSessionDAO resourceSessionDao) { + this.resourceSessionDao = resourceSessionDao; + } + + public void setResourceToolContentHandler(ResourceToolContentHandler resourceToolContentHandler) { + this.resourceToolContentHandler = resourceToolContentHandler; + } + + public void setResourceUserDao(ResourceUserDAO resourceUserDao) { + this.resourceUserDao = resourceUserDao; + } + + public void setToolService(ILamsToolService toolService) { + this.toolService = toolService; + } + + public ResourceItemVisitDAO getResourceItemVisitDao() { + return resourceItemVisitDao; + } + + public void setResourceItemVisitDao(ResourceItemVisitDAO resourceItemVisitDao) { + this.resourceItemVisitDao = resourceItemVisitDao; + } + public IExportToolContentService getExportContentService() { return exportContentService; } @@ -1293,33 +1331,6 @@ this.eventNotificationService = eventNotificationService; } - public String getLocalisedMessage(String key, Object[] args) { - return messageService.getMessage(key, args); - } - - public ILessonService getLessonService() { - return lessonService; - } - - public void setLessonService(ILessonService lessonService) { - this.lessonService = lessonService; - } - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - - public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { - return getResourceOutputFactory().getSupportedDefinitionClasses(definitionType); - } - public ResourceOutputFactory getResourceOutputFactory() { return resourceOutputFactory; } Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java (.../LearningAction.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java (.../LearningAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -389,22 +389,9 @@ Resource resource = resSession.getResource(); if (resource.isNotifyTeachersOnAssigmentSumbit()) { - final boolean isHtmlFormat = false; - - List monitoringUsers = service.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = resourceUser.getLastName() + " " + resourceUser.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.assigment.submit.subject", null), - service.getLocalisedMessage("event.assigment.submit.body", new Object[] { fullName }), - isHtmlFormat); - } + service.notifyTeachersOnAssigmentSumbit(sessionId, resourceUser); } + return mapping.findForward(ResourceConstants.SUCCESS); } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -280,15 +280,6 @@ * @return message content */ String getLocalisedMessage(String key, Object[] args); - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - List getMonitorsByToolSessionId(Long sessionId); /** * Returns whether activity is grouped and therefore it is expected more than one tool session. Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -65,7 +65,6 @@ import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; -import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; @@ -138,8 +137,6 @@ private MessageService messageService; - private ILessonService lessonService; - private IGradebookService gradebookService; private SubmitFilesOutputFactory submitFilesOutputFactory; @@ -1148,18 +1145,6 @@ this.messageService = messageService; } - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - - public ILessonService getLessonService() { - return lessonService; - } - - public void setLessonService(ILessonService lessonService) { - this.lessonService = lessonService; - } - public void setGradebookService(IGradebookService gradebookService) { this.gradebookService = gradebookService; } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/submitFilesApplicationContext.xml =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/submitFilesApplicationContext.xml (.../submitFilesApplicationContext.xml) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/submitFilesApplicationContext.xml (.../submitFilesApplicationContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -54,7 +54,6 @@ - Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java =================================================================== diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java (.../LearnerAction.java) (revision be07c35c372d904a65581d98660e73f3b13b69db) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java (.../LearnerAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -268,21 +268,13 @@ SubmitFilesContent content = submitFilesService.getSessionById(sessionID).getContent(); if (content.isNotifyTeachersOnFileSubmit()) { - boolean isHtmlFormat = false; - List monitoringUsers = submitFilesService.getMonitorsByToolSessionId(sessionID); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = learner.getLastName() + " " + learner.getFirstName(); - submitFilesService.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - submitFilesService.getLocalisedMessage("event.file.submit.subject", null), - submitFilesService.getLocalisedMessage("event.file.submit.body", new Object[] { fullName }), - isHtmlFormat); - } + + String fullName = learner.getLastName() + " " + learner.getFirstName(); + String message = submitFilesService + .getLocalisedMessage("event.file.submit.body", new Object[] { fullName }); + submitFilesService.getEventNotificationService().notifyLessonMonitors(sessionID, message, false); } + return mapping.getInputForward(); } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -29,7 +29,6 @@ import java.util.Set; import java.util.SortedMap; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.survey.dto.AnswerDTO; @@ -236,7 +235,7 @@ * @param userId * @param entryText */ - public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, + Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText); /** @@ -248,12 +247,12 @@ * @param userID * @return */ - public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); + NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID); /** * @param notebookEntry */ - public void updateEntry(NotebookEntry notebookEntry); + void updateEntry(NotebookEntry notebookEntry); /** * Get Reflect DTO list grouped by sessionID. @@ -262,40 +261,20 @@ * @return */ Map> getReflectList(Long contentId, boolean setEntry); + + void notifyTeachersOnAnswerSumbit(Long sessionId, SurveyUser surveyUser); /** - * Gets a message from resource bundle. Same as in JSP pages. - * - * @param key - * key of the message - * @param args - * arguments for the message - * @return message content - */ - String getLocalisedMessage(String key, Object[] args); - - IEventNotificationService getEventNotificationService(); - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId); - - /** * Creates an unique name for a SurveyCondition. It consists of the tool output definition name and a unique * positive integer number. * * @param existingConditions * existing conditions; required to check if a condition with the same name does not exist. * @return unique SurveyCondition name */ - public String createConditionName(Collection existingConditions); + String createConditionName(Collection existingConditions); - public void deleteCondition(SurveyCondition condition); + void deleteCondition(SurveyCondition condition); /** * Returns whether activity is grouped and therefore it is expected more than one tool session. Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java =================================================================== diff -u -r567af22fafd6a56534cc071f3650eda4495d05ef -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision 567af22fafd6a56534cc071f3650eda4495d05ef) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -47,7 +47,6 @@ import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException; import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService; import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException; -import org.lamsfoundation.lams.lesson.service.ILessonService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; @@ -90,16 +89,12 @@ import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; /** - * * @author Dapeng.Ni - * */ public class SurveyServiceImpl implements ISurveyService, ToolContentManager, ToolSessionManager, - ToolContentImport102Manager + ToolContentImport102Manager { + private static Logger log = Logger.getLogger(SurveyServiceImpl.class.getName()); -{ - static Logger log = Logger.getLogger(SurveyServiceImpl.class.getName()); - // DAO private SurveyDAO surveyDao; @@ -130,8 +125,6 @@ private IEventNotificationService eventNotificationService; - private ILessonService lessonService; - private SurveyOutputFactory surveyOutputFactory; private Random generator = new Random(); @@ -140,6 +133,7 @@ // Service method // ******************************************************************************* + @Override public Survey getSurveyByContentId(Long contentId) { Survey rs = surveyDao.getByContentId(contentId); if (rs == null) { @@ -148,6 +142,7 @@ return rs; } + @Override public Survey getDefaultContent(Long contentId) throws SurveyApplicationException { if (contentId == null) { String error = messageService.getMessage("error.msg.default.content.not.find"); @@ -165,26 +160,27 @@ return content; } + @Override public void createUser(SurveyUser surveyUser) { surveyUserDao.saveObject(surveyUser); } + @Override public SurveyUser getUserByIDAndContent(Long userId, Long contentId) { - return surveyUserDao.getUserByUserIDAndContentID(userId, contentId); - } + @Override public SurveyUser getUserByIDAndSession(Long userId, Long sessionId) { - return surveyUserDao.getUserByUserIDAndSessionID(userId, sessionId); - } + @Override public void saveOrUpdateSurvey(Survey survey) { surveyDao.saveObject(survey); } + @Override public Survey getSurveyBySessionId(Long sessionId) { SurveySession session = surveySessionDao.getSessionBySessionId(sessionId); // to skip CGLib problem @@ -193,14 +189,17 @@ return res; } + @Override public SurveySession getSurveySessionBySessionId(Long sessionId) { return surveySessionDao.getSessionBySessionId(sessionId); } + @Override public void saveOrUpdateSurveySession(SurveySession resSession) { surveySessionDao.saveObject(resSession); } + @Override public String finishToolSession(Long toolSessionId, Long userId) throws SurveyApplicationException { SurveyUser user = surveyUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); @@ -221,6 +220,7 @@ return nextUrl; } + @Override public Map> getReflectList(Long contentId, boolean setEntry) { Map> map = new HashMap>(); @@ -251,12 +251,14 @@ return map; } + @Override public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId, String entryText) { return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText); } + @Override public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) { List list = coreNotebookService.getEntry(sessionId, idType, signature, userID); if (list == null || list.isEmpty()) { @@ -266,26 +268,28 @@ } } - /** - * @param notebookEntry - */ + @Override public void updateEntry(NotebookEntry notebookEntry) { coreNotebookService.updateEntry(notebookEntry); } + @Override public SurveyUser getUser(Long uid) { return (SurveyUser) surveyUserDao.getObject(SurveyUser.class, uid); } + @Override public List getSessionUsers(Long sessionId) { return surveyUserDao.getBySessionID(sessionId); } + @Override public void deleteQuestion(Long uid) { surveyQuestionDao.removeObject(SurveyQuestion.class, uid); } + @Override public List getQuestionAnswers(Long sessionId, Long userUid) { List questions = new ArrayList(); SurveySession session = surveySessionDao.getSessionBySessionId(sessionId); @@ -311,12 +315,14 @@ return answers; } + @Override public void updateAnswerList(List answerList) { for (SurveyAnswer ans : answerList) { surveyAnswerDao.saveObject(ans); } } + @Override public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid) { SurveyQuestion question = surveyQuestionDao.getByUid(questionUid); AnswerDTO answerDto = new AnswerDTO(question); @@ -384,6 +390,7 @@ } + @Override public SortedMap> getSummary(Long toolContentId) { SortedMap> summary = new TreeMap>( @@ -406,6 +413,7 @@ return summary; } + @Override public SortedMap getStatistic(Long contentId) { SortedMap result = new TreeMap(new SurveySessionComparator()); List sessionList = surveySessionDao.getByContentId(contentId); @@ -422,10 +430,12 @@ } + @Override public SurveyQuestion getQuestion(Long questionUid) { return surveyQuestionDao.getByUid(questionUid); } + @Override public SortedMap>> exportByContentId(Long toolContentID) { SortedMap>> summary = new TreeMap>>( @@ -454,6 +464,7 @@ return summary; } + @Override public SortedMap>> exportBySessionId(Long toolSessionID) { SortedMap>> summary = new TreeMap>>( @@ -477,6 +488,7 @@ return summary; } + @Override public SortedMap>> exportByLearner(SurveyUser learner) { SortedMap>> summary = new TreeMap>>( new SurveySessionComparator()); @@ -494,7 +506,45 @@ public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } + + @Override + public String createConditionName(Collection existingConditions) { + String uniqueNumber = null; + do { + uniqueNumber = String.valueOf(Math.abs(generator.nextInt())); + for (SurveyCondition condition : existingConditions) { + String[] splitedName = getSurveyOutputFactory().splitConditionName(condition.getName()); + if (uniqueNumber.equals(splitedName[1])) { + uniqueNumber = null; + } + } + } while (uniqueNumber == null); + return getSurveyOutputFactory().buildConditionName(uniqueNumber); + } + @Override + public void deleteCondition(SurveyCondition condition) { + surveyDao.deleteCondition(condition); + } + + @Override + public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { + return getSurveyOutputFactory().getSupportedDefinitionClasses(definitionType); + } + + @Override + public void notifyTeachersOnAnswerSumbit(Long sessionId, SurveyUser surveyUser) { + + //it appears surveyUser can be null (?) + if (surveyUser == null) { + return; + } + + String userName = surveyUser.getLastName() + " " + surveyUser.getFirstName(); + String message = getLocalisedMessage("event.answer.submit.body", new Object[] { userName }); + eventNotificationService.notifyLessonMonitors(sessionId, message, false); + } + // ***************************************************************************** // private methods // ***************************************************************************** @@ -999,55 +1049,11 @@ return messageService.getMessage(key, args); } - public ILessonService getLessonService() { - return lessonService; - } - - public void setLessonService(ILessonService lessonService) { - this.lessonService = lessonService; - } - - /** - * Finds out which lesson the given tool content belongs to and returns its monitoring users. - * - * @param sessionId - * tool session ID - * @return list of teachers that monitor the lesson which contains the tool with given session ID - */ - public List getMonitorsByToolSessionId(Long sessionId) { - return getLessonService().getMonitorsByToolSessionId(sessionId); - } - public SurveyOutputFactory getSurveyOutputFactory() { return surveyOutputFactory; } public void setSurveyOutputFactory(SurveyOutputFactory surveyOutputFactory) { this.surveyOutputFactory = surveyOutputFactory; } - - /** - * {@inheritDoc} - */ - public String createConditionName(Collection existingConditions) { - String uniqueNumber = null; - do { - uniqueNumber = String.valueOf(Math.abs(generator.nextInt())); - for (SurveyCondition condition : existingConditions) { - String[] splitedName = getSurveyOutputFactory().splitConditionName(condition.getName()); - if (uniqueNumber.equals(splitedName[1])) { - uniqueNumber = null; - } - } - } while (uniqueNumber == null); - return getSurveyOutputFactory().buildConditionName(uniqueNumber); - } - - public void deleteCondition(SurveyCondition condition) { - surveyDao.deleteCondition(condition); - } - - public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { - return getSurveyOutputFactory().getSupportedDefinitionClasses(definitionType); - } } \ No newline at end of file Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml (.../surveyApplicationContext.xml) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml (.../surveyApplicationContext.xml) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -85,10 +85,7 @@ - - - - + Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rbb597b8155375e6ac4dfe280f630d323b6e5e575 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) @@ -393,25 +393,10 @@ request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID); Survey survey = service.getSurveyBySessionId(sessionId); - HttpSession ss = SessionManager.getSession(); - UserDTO surveyUser = (UserDTO) ss.getAttribute(AttributeNames.USER); if (survey.isNotifyTeachersOnAnswerSumbit()) { - final boolean isHtmlFormat = false; - - List monitoringUsers = service.getMonitorsByToolSessionId(sessionId); - if (monitoringUsers != null && !monitoringUsers.isEmpty()) { - Integer[] monitoringUsersIds = new Integer[monitoringUsers.size()]; - for (int i = 0; i < monitoringUsersIds.length; i++) { - monitoringUsersIds[i] = monitoringUsers.get(i).getUserId(); - } - String fullName = surveyUser.getLastName() + " " + surveyUser.getFirstName(); - service.getEventNotificationService().sendMessage(null, monitoringUsersIds, - IEventNotificationService.DELIVERY_METHOD_MAIL, - service.getLocalisedMessage("event.answer.submit.subject", null), - service.getLocalisedMessage("event.answer.submit.body", new Object[] { fullName }), - isHtmlFormat); - } + service.notifyTeachersOnAnswerSumbit(sessionId, surveyLearner); } + return mapping.findForward(SurveyConstants.SUCCESS); }