Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,106 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + + +package org.lamsfoundation.lams.tool.sbmt; + +public class SbmtConstants { + + public static final String TOOL_SIGNATURE = "lasbmt11"; + + public static final String DEFAULT_TITLE = "Submit Files Title"; + + public static final String AUTHORING_DTO = "authoring"; + + public static final String TOOL_CONTENT_HANDLER_NAME = "sbmtToolContentHandler"; + + public static final String USER_ID = "userID"; + + public static final String PAGE_EDITABLE = "isPageEditable"; + + public static final String ATTR_FILE_TYPE_FLAG = "fileTypeFlag"; + + public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; + + public static final String ATTR_USER_UID = "userUid"; + + public static final String ATTR_USER_FULLNAME = "fullName"; + + public static final String ATTR_USER_REFLECTION = "reflection"; + + public static final String ATTR_USER_NUM_FILE = "numFiles"; + + public static final String ATTR_USER_FILE_MARKED = "marked"; + + public static final String SUCCESS = "success"; + + public static final String ATTR_FINISH_LOCK = "finishLock"; + + public static final String ATTR_REFLECTION_ON = "reflectOn"; + + public static final String ATTR_REFLECTION_INSTRUCTION = "reflectInstructions"; + + public static final String ATTR_TITLE = "title"; + + public static final String ATTR_INSTRUCTION = "instruction"; + + public static final String ATTR_LOCK_ON_FINISH = "lockOnFinish"; + + public static final String PARAM_MIN_UPLOAD = "minUpload"; + + public static final String ATTR_LIMIT_UPLOAD = "limitUpload"; + + public static final String ATTR_LIMIT_UPLOAD_NUMBER = "limitUploadNumber"; + + public static final Object ATTR_ARRIVE_LIMIT = "arriveLimit"; + + public static final String ATTR_USER_FINISHED = "userFinished"; + + public static final String ATTR_IS_GROUPED_ACTIVITY = "isGroupedActivity"; + + public static final String ATTR_UPLOAD_MAX_FILE_SIZE = "uploadMaxFileSize"; + + public static final String EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE = "notify_learners_on_mark_release"; + + public static final String EVENT_NAME_NOTIFY_TEACHERS_ON_FILE_SUBMIT = "notify_teachers_on_file_submit"; + + public static final String ATTR_SUBMISSION_DEADLINE = "submissionDeadline"; + public static final String ATTR_SUBMISSION_DEADLINE_DATESTRING = "submissionDateString"; + public static final String ATTR_IS_SUBMISSION_DEADLINE_PASSED = "isSubmissionDeadlinePassed"; + + public static final String EVENT_NAME_NOTIFY_LEARNERS_ON_MARKED_FILE = "notify_learners_on_marked_file"; + + public static final String SUBMITTED_ITEMS_DEFINITION_NAME = "submitted.items.output.definition.sbmt"; + + public static final String AUDIT_LOG_MODULE_NAME = "Submit Files"; + + public static final int SORT_BY_NO = 1; + public static final int SORT_BY_USERNAME_ASC = 2; + public static final int SORT_BY_USERNAME_DESC = 3; + public static final int SORT_BY_MARKED_ASC = 4; + public static final int SORT_BY_MARKED_DESC = 5; + public static final int SORT_BY_NUM_FILES_ASC = 6; + public static final int SORT_BY_NUM_FILES_DESC = 7; + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/dao/hibernate/SubmitUserDAO.java =================================================================== diff -u -r8b6a003b5813a17da4f53fba29c40c19b5f8647b -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/dao/hibernate/SubmitUserDAO.java (.../SubmitUserDAO.java) (revision 8b6a003b5813a17da4f53fba29c40c19b5f8647b) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/dao/hibernate/SubmitUserDAO.java (.../SubmitUserDAO.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -36,10 +36,10 @@ import org.hibernate.type.StringType; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; import org.lamsfoundation.lams.tool.sbmt.SubmitUser; import org.lamsfoundation.lams.tool.sbmt.dao.ISubmitUserDAO; import org.lamsfoundation.lams.tool.sbmt.dto.StatisticDTO; -import org.lamsfoundation.lams.tool.sbmt.util.SbmtConstants; import org.springframework.stereotype.Repository; @Repository Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/exception/SubmitFilesException.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/form/AuthoringForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/form/LearnerForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/form/MarkForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/form/ReflectionForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/form/SubmitFilesPedagogicalPlannerForm.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java =================================================================== diff -u -r2abc3485dc2d24ea02044a64271f3ee0d3b8c11b -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision 2abc3485dc2d24ea02044a64271f3ee0d3b8c11b) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -42,7 +42,7 @@ import org.lamsfoundation.lams.tool.sbmt.SubmitUser; import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; import org.lamsfoundation.lams.tool.sbmt.dto.StatisticDTO; -import org.lamsfoundation.lams.tool.sbmt.exception.SubmitFilesException; +import org.lamsfoundation.lams.tool.sbmt.util.SubmitFilesException; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; /** Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesOutputFactory.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesOutputFactory.java (.../SubmitFilesOutputFactory.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesOutputFactory.java (.../SubmitFilesOutputFactory.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -32,9 +32,9 @@ import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.ToolOutputDefinition; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; import org.lamsfoundation.lams.tool.sbmt.dto.SubmitUserDTO; -import org.lamsfoundation.lams.tool.sbmt.util.SbmtConstants; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.web.util.AttributeNames; Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -ra71bf2630935c6bc8b907ca22801208a2d3bd657 -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -79,6 +79,7 @@ import org.lamsfoundation.lams.tool.ToolSessionManager; import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; import org.lamsfoundation.lams.tool.sbmt.SubmissionDetails; import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; import org.lamsfoundation.lams.tool.sbmt.SubmitFilesReport; @@ -92,9 +93,8 @@ import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; import org.lamsfoundation.lams.tool.sbmt.dto.StatisticDTO; import org.lamsfoundation.lams.tool.sbmt.dto.SubmitUserDTO; -import org.lamsfoundation.lams.tool.sbmt.exception.SubmitFilesException; -import org.lamsfoundation.lams.tool.sbmt.util.SbmtConstants; import org.lamsfoundation.lams.tool.sbmt.util.SbmtToolContentHandler; +import org.lamsfoundation.lams.tool.sbmt.util.SubmitFilesException; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SbmtConstants.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SubmitFilesException.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SubmitFilesException.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SubmitFilesException.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,71 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + + +package org.lamsfoundation.lams.tool.sbmt.util; + +/** + * @author Manpreet Minhas + */ +public class SubmitFilesException extends RuntimeException { + + private static final long serialVersionUID = 8623508856810983309L; + + /** + * Default Constructor + */ + public SubmitFilesException() { + super(); + } + + /** + * Constructor for customized error message + * + * @param message + */ + public SubmitFilesException(String message) { + super(message); + } + + /** + * Constructor for wrapping the throwable object + * + * @param cause + */ + public SubmitFilesException(Throwable cause) { + super(cause); + } + + /** + * Constructor for wrapping both the customized error message and + * throwable exception object. + * + * @param message + * @param cause + */ + public SubmitFilesException(String message, Throwable cause) { + super(message, cause); + } + +} Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MarkAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/ReflectAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag f98151f6d4d6f66f3d8e482481aa198076133e71 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/SubmitFilesPedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/AuthoringAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/AuthoringAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/AuthoringAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,238 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + + +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.lang.reflect.InvocationTargetException; +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.tool.sbmt.SubmitUser; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.tool.sbmt.web.form.AuthoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * @author Manpreet Minhas + * @author Steve Ni + */ +public class AuthoringAction extends LamsDispatchAction { + private Logger log = Logger.getLogger(AuthoringAction.class); + + public ISubmitFilesService submitFilesService; + + /** + * This page will display initial submit tool content. Or just a blank page if the toolContentID does not exist + * before. + * + *
+ * Define later will use this method to initial page as well. + * + * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) + */ + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + + SessionMap sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + sessionMap.put(AttributeNames.PARAM_MODE, mode); + + Long contentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + // get back the upload file list and display them on page + submitFilesService = getService(); + + SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(contentID); + + if (mode.isTeacher()) { + persistContent.setDefineLater(true); + submitFilesService.saveOrUpdateContent(persistContent); + + //audit log the teacher has started editing activity in monitor + submitFilesService.auditLogStartEditingActivityInMonitor(contentID); + } + + // if this content does not exist(empty without id), create a content by default content record. + if (persistContent == null) { + persistContent = submitFilesService.createDefaultContent(contentID); + } + + // set back STRUTS component value + AuthoringForm authForm = (AuthoringForm) form; + authForm.initContentValue(persistContent); + // session map + authForm.setSessionMapID(sessionMap.getSessionID()); + authForm.setContentFolderID(contentFolderID); + + return mapping.findForward("success"); + } + + /** + * Update all content for submit tool except online/offline instruction files list. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws Exception + */ + public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + AuthoringForm authForm = (AuthoringForm) form; + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(authForm.getSessionMapID()); + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.PARAM_MODE); + + ActionMessages errors = validate(authForm, mapping, request); + if (!errors.isEmpty()) { + saveErrors(request, errors); + return mapping.getInputForward(); + } + + SubmitFilesContent content = getContent(form); + + submitFilesService = getService(); + SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(content.getContentID()); + + if (persistContent == null) { + // new content + persistContent = content; + content.setCreated(new Date()); + } else { + + Long uid = persistContent.getContentID(); + PropertyUtils.copyProperties(persistContent, content); + persistContent.setContentID(uid); + + // if it is Teacher (from monitor) - change define later status + if (mode.isTeacher()) { + persistContent.setDefineLater(false); + } + } + // *******************************Handle user******************* + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + + Long contentId = authForm.getToolContentID(); + SubmitUser user = submitFilesService.getContentUser(contentId, userDto.getUserID()); + if (user == null) { + user = submitFilesService.createContentUser(userDto, contentId); + } + persistContent.setCreatedBy(user); + + submitFilesService.saveOrUpdateContent(persistContent); + + // to jump to common success page in lams_central + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + return mapping.findForward("success"); + } + + // *********************************************************** + // Private/protected methods + // *********************************************************** + /** + * The private method to get content from ActionForm parameters (web page). + * + * @param form + * @return + */ + private SubmitFilesContent getContent(ActionForm form) { + AuthoringForm authForm = (AuthoringForm) form; + Long contentId = authForm.getToolContentID(); + + SubmitFilesContent content = new SubmitFilesContent(); + content.setContentID(contentId); + content.setInstruction(authForm.getInstructions()); + content.setTitle(authForm.getTitle()); + content.setLockOnFinished(authForm.isLockOnFinished()); + content.setReflectInstructions(authForm.getReflectInstructions()); + content.setReflectOnActivity(authForm.isReflectOnActivity()); + content.setLimitUpload(authForm.isLimitUpload()); + content.setLimitUploadNumber(authForm.getLimitUploadNumber()); + content.setNotifyLearnersOnMarkRelease(authForm.isNotifyLearnersOnMarkRelease()); + content.setNotifyTeachersOnFileSubmit(authForm.isNotifyTeachersOnFileSubmit()); + return content; + } + + /** + * Get submit file service bean. + * + * @return + */ + private ISubmitFilesService getService() { + if (submitFilesService == null) { + return SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } else { + return submitFilesService; + } + } + + private ActionMessages validate(AuthoringForm sbmtForm, ActionMapping mapping, HttpServletRequest request) { + ActionMessages errors = new ActionMessages(); + // if (StringUtils.isBlank(sbmtForm.getTitle())) { + // ActionMessage error = new ActionMessage("error.title.blank"); + // errors.add(ActionMessages.GLOBAL_MESSAGE, error); + // } + // define it later mode(TEACHER) skip below validation. + String modeStr = request.getParameter(AttributeNames.ATTR_MODE); + if (StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())) { + return errors; + } + + // Some other validation outside basic Tab. + + return errors; + } + +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ClearSessionAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ClearSessionAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ClearSessionAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,48 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import javax.servlet.http.HttpSession; + +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; +import org.lamsfoundation.lams.tool.ToolAccessMode; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + * + * @version $Revision$ + */ +public class ClearSessionAction extends LamsAuthoringFinishAction { + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/LearnerAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/LearnerAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/LearnerAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,472 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + + +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.io.IOException; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.actions.DispatchAction; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.events.IEventNotificationService; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.ToolSessionManager; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesSession; +import org.lamsfoundation.lams.tool.sbmt.SubmitUser; +import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; +import org.lamsfoundation.lams.tool.sbmt.dto.SubmitUserDTO; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.tool.sbmt.util.SubmitFilesException; +import org.lamsfoundation.lams.tool.sbmt.web.form.LearnerForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.filter.LocaleFilter; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * @author Manpreet Minhas + * @author Steve.Ni + */ +public class LearnerAction extends DispatchAction { + + private static final boolean MODE_OPTIONAL = false; + + public static Logger logger = Logger.getLogger(LearnerAction.class); + public ISubmitFilesService submitFilesService; + + /** + * The initial page of learner in Submission tool. This page will list all uploaded files and learn + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + // initial session Map + SessionMap sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + ((LearnerForm) form).setSessionMapID(sessionMap.getSessionID()); + + // get parameters from Request + ToolAccessMode mode = null; + try { + mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, LearnerAction.MODE_OPTIONAL); + } catch (Exception e) { + } + if (mode == null) { + mode = ToolAccessMode.LEARNER; + } + + Long sessionID = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID)); + + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + + Integer userID = null; + if (mode != null && mode.isTeacher()) { + // monitoring mode - user is specified in URL + userID = WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false); + } else { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + userID = user.getUserID(); + } + + ISubmitFilesService submitFilesService = getService(); + SubmitFilesSession session = submitFilesService.getSessionById(sessionID); + SubmitFilesContent content = session.getContent(); + + // this must before getFileUploadByUser() method becuase getCurrentLearner() + // will create session user if it does not exist. + SubmitUser learner = getCurrentLearner(sessionID, submitFilesService); + List filesUploaded = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), false); + + // check whehter finish lock is on/off + boolean lock = content.isLockOnFinished() && learner.isFinished(); + + sessionMap.put(AttributeNames.PARAM_MODE, mode); + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID); + sessionMap.put(SbmtConstants.ATTR_FINISH_LOCK, lock); + sessionMap.put(SbmtConstants.ATTR_LOCK_ON_FINISH, content.isLockOnFinished()); + sessionMap.put(SbmtConstants.ATTR_REFLECTION_ON, content.isReflectOnActivity()); + sessionMap.put(SbmtConstants.ATTR_REFLECTION_INSTRUCTION, content.getReflectInstructions()); + sessionMap.put(SbmtConstants.ATTR_TITLE, content.getTitle()); + sessionMap.put(SbmtConstants.ATTR_INSTRUCTION, content.getInstruction()); + sessionMap.put(SbmtConstants.ATTR_LIMIT_UPLOAD, content.isLimitUpload()); + sessionMap.put(SbmtConstants.ATTR_LIMIT_UPLOAD_NUMBER, content.getLimitUploadNumber()); + sessionMap.put(SbmtConstants.ATTR_USER_FINISHED, learner.isFinished()); + + sessionMap.put(SbmtConstants.ATTR_UPLOAD_MAX_FILE_SIZE, + FileValidatorUtil.formatSize(Configuration.getAsInt(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE))); + setLearnerDTO(request, sessionMap, learner, filesUploaded, mode); + + // if content in use, return special page. + if (content.isDefineLater()) { + return mapping.findForward("defineLater"); + } + + // set contentInUse flag to true! + content.setContentInUse(true); + content.setDefineLater(false); + submitFilesService.saveOrUpdateContent(content); + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionID, request, + getServlet().getServletContext()); + + // check if there is submission deadline + Date submissionDeadline = content.getSubmissionDeadline(); + if (submissionDeadline != null) { + // store submission deadline to sessionMap + sessionMap.put(SbmtConstants.ATTR_SUBMISSION_DEADLINE, submissionDeadline); + + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); + + // calculate whether submission deadline has passed, and if so forward to "submissionDeadline" + if (currentLearnerDate.after(tzSubmissionDeadline)) { + return mapping.findForward("submissionDeadline"); + } + } + + if (content.isNotifyLearnersOnMarkRelease()) { + boolean isHtmlFormat = false; + submitFilesService.getEventNotificationService().createEvent(SbmtConstants.TOOL_SIGNATURE, + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, content.getContentID(), + submitFilesService.getLocalisedMessage("event.mark.release.subject", null), + submitFilesService.getLocalisedMessage("event.mark.release.body", null), isHtmlFormat); + + submitFilesService.getEventNotificationService().subscribe(SbmtConstants.TOOL_SIGNATURE, + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, content.getContentID(), userID, + IEventNotificationService.DELIVERY_METHOD_MAIL); + } + + return mapping.findForward(SbmtConstants.SUCCESS); + } + + /** + * Implements learner upload submission function. This function also display the page again for learner uploading + * more submission use. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward uploadFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + LearnerForm learnerForm = (LearnerForm) form; + String sessionMapID = learnerForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + // set the mode into http session + Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionID, request, + getServlet().getServletContext()); + + if (validateUploadForm(learnerForm, request)) { + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Integer userID = user.getUserID(); + + ISubmitFilesService submitFilesService = getService(); + List filesUploaded = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), + false); + + SubmitUser learner = getCurrentLearner(sessionID, submitFilesService); + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + setLearnerDTO(request, sessionMap, learner, filesUploaded, mode); + + return mapping.getInputForward(); + } + + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Integer userID = user.getUserID(); + + FormFile uploadedFile = learnerForm.getFile(); + String fileDescription = learnerForm.getDescription(); + // reset fields and display a new form for next new file upload + learnerForm.setDescription(""); + + ISubmitFilesService submitFilesService = getService(); + + submitFilesService.uploadFileToSession(sessionID, uploadedFile, fileDescription, userID); + List filesUploaded = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), false); + SubmitUser learner = getCurrentLearner(sessionID, submitFilesService); + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + setLearnerDTO(request, sessionMap, learner, filesUploaded, mode); + + SubmitFilesContent content = submitFilesService.getSessionById(sessionID).getContent(); + if (content.isNotifyTeachersOnFileSubmit()) { + + String message = submitFilesService.getLocalisedMessage("event.file.submit.body", + new Object[] { learner.getFullName() }); + submitFilesService.getEventNotificationService().notifyLessonMonitors(sessionID, message, false); + } + + return mapping.getInputForward(); + } + + /** + * Learner choose finish upload button, will invoke this function. This function will mark the finished + * field by special toolSessionID and userID. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward finish(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + String sessionMapID = WebUtil.readStrParam(request, SbmtConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + if (mode == ToolAccessMode.LEARNER || mode.equals(ToolAccessMode.AUTHOR)) { + ToolSessionManager sessionMgrService = SubmitFilesServiceProxy + .getToolSessionManager(getServlet().getServletContext()); + ISubmitFilesService submitFilesService = getService(); + + // get back login user DTO + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Integer userID = user.getUserID(); + submitFilesService.finishSubmission(sessionID, userID); + + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(sessionID, new Long(userID.intValue())); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new SubmitFilesException(e); + } catch (ToolException e) { + throw new SubmitFilesException(e); + } catch (IOException e) { + throw new SubmitFilesException(e); + } + } + return null; + + } + + // ********************************************************************************************** + // Private mehtods + // ********************************************************************************************** + private ISubmitFilesService getService() { + ISubmitFilesService submitFilesService = SubmitFilesServiceProxy + .getSubmitFilesService(this.getServlet().getServletContext()); + return submitFilesService; + } + + // validate uploaded form + private boolean validateUploadForm(LearnerForm learnerForm, HttpServletRequest request) { + ActionMessages errors = new ActionMessages(); + Locale preferredLocale = (Locale) request.getSession().getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY); + if (learnerForm.getFile() == null || StringUtils.isBlank(learnerForm.getFile().getFileName())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required", + this.getResources(request).getMessage(preferredLocale, "learner.form.filepath.displayname"))); + } + if (StringUtils.isBlank(learnerForm.getDescription())) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.required", + this.getResources(request).getMessage(preferredLocale, "label.learner.fileDescription"))); + } else if (learnerForm.getDescription().length() > LearnerForm.DESCRIPTION_LENGTH) { + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("errors.maxdescsize", LearnerForm.DESCRIPTION_LENGTH)); + } + + FileValidatorUtil.validateFileSize(learnerForm.getFile(), false, errors); + + if (learnerForm.getFile() != null) { + LearnerAction.logger.debug("Learner submit file : " + learnerForm.getFile().getFileName()); + } + + if (learnerForm.getFile() != null && FileUtil.isExecutableFile(learnerForm.getFile().getFileName())) { + LearnerAction.logger.debug("File is executatable : " + learnerForm.getFile().getFileName()); + ActionMessage msg = new ActionMessage("error.attachment.executable"); + errors.add(ActionMessages.GLOBAL_MESSAGE, msg); + } + + if (!errors.isEmpty()) { + this.addErrors(request, errors); + return true; + } + return false; + } + + /** + * + * Set information into learner DTO object for page display. Fill file list uploaded by the special user into web + * form. Remove the unauthorized mark and comments. + * + * @param request + * @param sessionMap + * @param sessionID + * @param userID + * @param content + * @param filesUploaded + */ + private void setLearnerDTO(HttpServletRequest request, SessionMap sessionMap, SubmitUser currUser, + List filesUploaded, ToolAccessMode mode) { + + SubmitUserDTO dto = new SubmitUserDTO(currUser); + if (currUser != null) { + // if Monitoring does not release marks, then skip this mark and comment content. + if (filesUploaded != null) { + Iterator iter = filesUploaded.iterator(); + while (iter.hasNext()) { + FileDetailsDTO filedto = (FileDetailsDTO) iter.next(); + if (mode.isTeacher() || currUser.getUid().equals(filedto.getOwner().getUserUid())) { + filedto.setCurrentLearner(true); + } else { + filedto.setCurrentLearner(false); + } +// if (filedto.getDateMarksReleased() == null) { +// filedto.setComments(null); +// filedto.setMarks(null); +// } + } + } + dto.setFilesUploaded(filesUploaded); + } + + // preset + boolean limitUpload = (Boolean) sessionMap.get(SbmtConstants.ATTR_LIMIT_UPLOAD); + if (limitUpload && filesUploaded != null) { + int limit = (Integer) sessionMap.get(SbmtConstants.ATTR_LIMIT_UPLOAD_NUMBER); + if (limit == filesUploaded.size()) { + sessionMap.put(SbmtConstants.ATTR_ARRIVE_LIMIT, true); + } + int limitUploadLeft = limit - filesUploaded.size(); + dto.setLimitUploadLeft(limitUploadLeft); + } + + // retrieve notebook reflection entry. + ISubmitFilesService submitFilesService = getService(); + + NotebookEntry notebookEntry = submitFilesService.getEntry( + (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID), CoreNotebookConstants.NOTEBOOK_TOOL, + SbmtConstants.TOOL_SIGNATURE, currUser.getUserID()); + + if (notebookEntry != null) { + dto.setReflect(notebookEntry.getEntry()); + } + + request.setAttribute("learner", dto); + } + + private SubmitUser getCurrentLearner(Long sessionID, ISubmitFilesService submitFilesService) { + // get session from shared session. + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Integer userID = user.getUserID(); + + SubmitUser learner = submitFilesService.getSessionUser(sessionID, userID); + if (learner == null) { + learner = submitFilesService.createSessionUser(user, sessionID); + } + + return learner; + } + + private ISubmitFilesService getSubmitFilesService() { + return SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } + + public ActionForward deleteLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + HttpSession ss = SessionManager.getSession(); + + + UserDTO currentUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + Long detailID = WebUtil.readLongParam(request, "detailId"); + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + FileDetailsDTO fileDetail = submitFilesService.getFileDetails(detailID, request.getLocale()); + + if (fileDetail.getOwner().getUserID().equals(currentUser.getUserID()) && (StringUtils.isBlank(fileDetail.getMarks()))) { + + submitFilesService.removeLearnerFile(detailID,null); + + } else { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not allowed to delete this item"); + } + return null; + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MarkAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MarkAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MarkAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,214 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.contentrepository.InvalidParameterException; +import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.tool.sbmt.web.form.MarkForm; +import org.lamsfoundation.lams.util.NumberUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author lfoxton + * + * + * + * + * + * + * + * + * + */ +public class MarkAction extends LamsDispatchAction { + + private ISubmitFilesService submitFilesService; + + /** + * Update mark. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws RepositoryCheckedException + * @throws InvalidParameterException + */ + public ActionForward updateMark(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws InvalidParameterException, RepositoryCheckedException { + + MarkForm markForm = (MarkForm) form; + + ActionMessages errors = new ActionMessages(); + // Check whether the mark is valid. + Float marks = null; + String markStr = markForm.getMarks(); + try { + marks = NumberUtil.getLocalisedFloat(markStr, request.getLocale()); + } catch (Exception e) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.mark.invalid.number")); + } + + String comments = WebUtil.readStrParam(request, "comments", true); + if (!errors.isEmpty()) { + submitFilesService = getSubmitFilesService(); + List report = new ArrayList(); + FileDetailsDTO fileDetail = submitFilesService.getFileDetails(markForm.getDetailID(), request.getLocale()); + // echo back the input, even they are wrong. + fileDetail.setComments(comments); + fileDetail.setMarks(markStr); + report.add(fileDetail); + + request.setAttribute("report", report); + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, markForm.getToolSessionID()); + + saveErrors(request, errors); + return mapping.findForward("updateMark"); + } + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + + // Update the mark based on the form + submitFilesService.updateMarks(markForm.getReportID(), marks, comments, markForm.getMarkFile()); + + // Return to the appropriate screen based upon the updateMode + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, markForm.getToolSessionID()); + if (StringUtils.equals(markForm.getUpdateMode(), "listMark")) { + List report = submitFilesService.getFilesUploadedByUser(markForm.getUserID(), markForm.getToolSessionID(), + request.getLocale(), true); + request.setAttribute("report", report); + return mapping.findForward("listMark"); + } else { + Map report = submitFilesService.getFilesUploadedBySession(markForm.getToolSessionID(), request.getLocale()); + request.setAttribute("reports", report); + return mapping.findForward("listAllMarks"); + } + } + + /** + * Display update mark initial page. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward newMark(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + MarkForm markForm = (MarkForm) form; + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + + FileDetailsDTO fileDetailsDTO = submitFilesService.getFileDetails(markForm.getDetailID(), request.getLocale()); + updateMarkForm(markForm, fileDetailsDTO); + + List report = new ArrayList(); + report.add(submitFilesService.getFileDetails(markForm.getDetailID(), request.getLocale())); + + request.setAttribute("updateMode", markForm.getUpdateMode()); + request.setAttribute("toolSessionID", markForm.getToolSessionID()); + request.setAttribute("report", report); + + return mapping.findForward("updateMark"); + } + + /** + * Update the form + * + * @param markForm + * @param fileDetailsDTO + */ + private void updateMarkForm(MarkForm markForm, FileDetailsDTO fileDetailsDTO) { + + if (fileDetailsDTO.getMarks() != null) { + markForm.setMarks(fileDetailsDTO.getMarks().toString()); + } + markForm.setReportID(fileDetailsDTO.getReportID()); + markForm.setComments(fileDetailsDTO.getComments()); + markForm.setMarkFileUUID(fileDetailsDTO.getMarkFileUUID()); + markForm.setMarkFileVersionID(fileDetailsDTO.getMarkFileVersionID()); + } + + /** + * Remove a mark file + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward removeMarkFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + MarkForm markForm = (MarkForm) form; + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + + submitFilesService.removeMarkFile(markForm.getReportID(), markForm.getMarkFileUUID(), + markForm.getMarkFileVersionID()); + + FileDetailsDTO fileDetailsDTO = submitFilesService.getFileDetails(markForm.getDetailID(), request.getLocale()); + updateMarkForm(markForm, fileDetailsDTO); + + List report = new ArrayList(); + report.add(submitFilesService.getFileDetails(markForm.getDetailID(), request.getLocale())); + + request.setAttribute("updateMode", markForm.getUpdateMode()); + request.setAttribute("toolSessionID", markForm.getToolSessionID()); + request.setAttribute("report", report); + + return mapping.findForward("updateMark"); + } + + private ISubmitFilesService getSubmitFilesService() { + return SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MonitoringAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MonitoringAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MonitoringAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,631 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Comparator; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; +import java.util.TimeZone; +import java.util.TreeSet; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.DynaActionForm; +import org.apache.tomcat.util.json.JSONArray; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; +import org.lamsfoundation.lams.tool.sbmt.SubmissionDetails; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesSession; +import org.lamsfoundation.lams.tool.sbmt.SubmitUser; +import org.lamsfoundation.lams.tool.sbmt.dto.AuthoringDTO; +import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; +import org.lamsfoundation.lams.tool.sbmt.dto.SessionDTO; +import org.lamsfoundation.lams.tool.sbmt.dto.StatisticDTO; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * @author Manpreet Minhas + */ +public class MonitoringAction extends LamsDispatchAction { + + public ISubmitFilesService submitFilesService; + + private class SessionComparator implements Comparator { + @Override + public int compare(SessionDTO o1, SessionDTO o2) { + if (o1 != null && o2 != null) { + return o1.getSessionName().compareTo(o2.getSessionName()); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } + } + + private class StatisticComparator implements Comparator { + @Override + public int compare(StatisticDTO o1, StatisticDTO o2) { + if (o1 != null && o2 != null) { + return o1.getSessionName().compareTo(o2.getSessionName()); + } else if (o1 != null) { + return 1; + } else { + return -1; + } + } + } + + /** + * Default ActionForward for Monitor + */ + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + Long contentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + submitFilesService = getSubmitFilesService(); + + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); + request.setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID, contentID); + + List submitFilesSessionList = submitFilesService.getSubmitFilesSessionByContentID(contentID); + summary(request, submitFilesSessionList); + statistic(request, contentID); + + // instruction + SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(contentID); + // if this content does not exist, then reset the contentID to current value to keep it on HTML page. + persistContent.setContentID(contentID); + + AuthoringDTO authorDto = new AuthoringDTO(persistContent); + request.setAttribute(SbmtConstants.AUTHORING_DTO, authorDto); + request.setAttribute(SbmtConstants.PAGE_EDITABLE, !persistContent.isContentInUse()); + request.setAttribute(SbmtConstants.ATTR_IS_GROUPED_ACTIVITY, submitFilesService.isGroupedActivity(contentID)); + request.setAttribute(SbmtConstants.ATTR_REFLECTION_ON, persistContent.isReflectOnActivity()); + + // set SubmissionDeadline, if any + if (persistContent.getSubmissionDeadline() != null) { + Date submissionDeadline = persistContent.getSubmissionDeadline(); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline); + request.setAttribute(SbmtConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); + request.setAttribute(SbmtConstants.ATTR_SUBMISSION_DEADLINE_DATESTRING, + DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale())); + } + + DynaActionForm smbtMonitoringForm = (DynaActionForm) form; + // smbtMonitoringForm.set("currentTab", WebUtil.readStrParam(request, AttributeNames.PARAM_CURRENT_TAB,true)); + + return mapping.findForward("success"); + } + + /** Ajax call to populate the tablesorter */ + public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + Long contentId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer sortByName = WebUtil.readIntParam(request, "column[0]", true); + Integer sortByNumFiles = WebUtil.readIntParam(request, "column[1]", true); + Integer sortByMarked = WebUtil.readIntParam(request, "column[2]", true); + String searchString = request.getParameter("fcol[0]"); + + int sorting = SbmtConstants.SORT_BY_NO; + if (sortByName != null) { + sorting = sortByName.equals(0) ? SbmtConstants.SORT_BY_USERNAME_ASC : SbmtConstants.SORT_BY_USERNAME_DESC; + } else if (sortByNumFiles != null) { + sorting = sortByNumFiles.equals(0) ? SbmtConstants.SORT_BY_NUM_FILES_ASC + : SbmtConstants.SORT_BY_NUM_FILES_DESC; + } else if (sortByMarked != null) { + sorting = sortByMarked.equals(0) ? SbmtConstants.SORT_BY_MARKED_ASC : SbmtConstants.SORT_BY_MARKED_DESC; + } + + // return user list according to the given sessionID + ISubmitFilesService service = getSubmitFilesService(); + SubmitFilesContent spreadsheet = service.getSubmitFilesContent(contentId); + List users = service.getUsersForTablesorter(sessionID, page, size, sorting, searchString, + spreadsheet.isReflectOnActivity()); + + JSONArray rows = new JSONArray(); + JSONObject responsedata = new JSONObject(); + responsedata.put("total_rows", service.getCountUsersBySession(sessionID, searchString)); + + for (Object[] userAndReflection : users) { + + JSONObject responseRow = new JSONObject(); + + SubmitUser user = (SubmitUser) userAndReflection[0]; + responseRow.put(SbmtConstants.ATTR_USER_UID, user.getUid()); + responseRow.put(SbmtConstants.USER_ID, user.getUserID()); + responseRow.put(SbmtConstants.ATTR_USER_FULLNAME, StringEscapeUtils.escapeHtml(user.getFullName())); + + if (userAndReflection.length > 2) { + responseRow.put(SbmtConstants.ATTR_USER_NUM_FILE, + (Integer)userAndReflection[1] - (Integer)userAndReflection[2]); + } + + if (userAndReflection.length > 3) { + responseRow.put(SbmtConstants.ATTR_USER_FILE_MARKED, (Integer) userAndReflection[3] > 0); + } + + if (userAndReflection.length > 4) { + responseRow.put(SbmtConstants.ATTR_USER_REFLECTION, userAndReflection[4]); + } + + rows.put(responseRow); + } + + responsedata.put("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(new String(responsedata.toString())); + return null; + + } + + /** + * AJAX call to refresh statistic page. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward doStatistic(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long contentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + submitFilesService = getSubmitFilesService(); + statistic(request, contentID); + request.setAttribute(SbmtConstants.ATTR_IS_GROUPED_ACTIVITY, submitFilesService.isGroupedActivity(contentID)); + return mapping.findForward("statistic"); + } + + private void statistic(HttpServletRequest request, Long contentID) { + SortedSet statistics = new TreeSet(new StatisticComparator()); + statistics.addAll(submitFilesService.getStatisticsBySession(contentID)); + request.setAttribute("statisticList", statistics); + } + + /** + * Release mark + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward releaseMarks(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // get service then update report table + submitFilesService = getSubmitFilesService(); + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + submitFilesService.releaseMarksForSession(sessionID); + + try { + response.setContentType("text/html;charset=utf-8"); + PrintWriter out = response.getWriter(); + SubmitFilesSession session = submitFilesService.getSessionById(sessionID); + String sessionName = ""; + if (session != null) { + sessionName = session.getSessionName(); + } + out.write(getMessageService().getMessage("msg.mark.released", new String[] { sessionName })); + out.flush(); + } catch (IOException e) { + } + return null; + } + + /** + * Download submit file marks by MS Excel file format. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward downloadMarks(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + submitFilesService = getSubmitFilesService(); + // return FileDetailsDTO list according to the given sessionID + Map userFilesMap = submitFilesService.getFilesUploadedBySession(sessionID, request.getLocale()); + // construct Excel file format and download + String errors = null; + try { + // create an empty excel file + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("Marks"); + sheet.setColumnWidth(0, 5000); + HSSFRow row; + HSSFCell cell; + + Iterator iter = userFilesMap.values().iterator(); + Iterator dtoIter; + + int idx = 0; + + row = sheet.createRow(idx++); + cell = row.createCell(2); + cell.setCellValue(getMessageService().getMessage("label.learner.fileName")); + + cell = row.createCell(3); + cell.setCellValue(getMessageService().getMessage("label.learner.fileDescription")); + + cell = row.createCell(4); + cell.setCellValue(getMessageService().getMessage("label.learner.marks")); + + cell = row.createCell(5); + cell.setCellValue(getMessageService().getMessage("label.learner.comments")); + + while (iter.hasNext()) { + List list = (List) iter.next(); + dtoIter = list.iterator(); + + while (dtoIter.hasNext()) { + FileDetailsDTO dto = (FileDetailsDTO) dtoIter.next(); + if (!dto.isRemoved()) { + row = sheet.createRow(idx++); + + int count = 0; + + cell = row.createCell(count++); + cell.setCellValue(dto.getOwner().getFullName()); + + ++count; + + sheet.setColumnWidth(count, 8000); + + cell = row.createCell(count++); + cell.setCellValue(dto.getFilePath()); + + cell = row.createCell(count++); + cell.setCellValue(dto.getFileDescription()); + + cell = row.createCell(count++); + + String marks = dto.getMarks(); + cell.setCellValue(marks != null ? marks : ""); + + cell = row.createCell(count++); + cell.setCellValue(dto.getComments()); + } + } + } + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + wb.write(bos); + + // construct download file response header + String fileName = "marks" + sessionID + ".xls"; + String mineType = "application/vnd.ms-excel"; + String header = "attachment; filename=\"" + fileName + "\";"; + response.setContentType(mineType); + response.setHeader("Content-Disposition", header); + + byte[] data = bos.toByteArray(); + response.getOutputStream().write(data, 0, data.length); + response.getOutputStream().flush(); + } catch (Exception e) { + LamsDispatchAction.log.error(e); + errors = new ActionMessage("monitoring.download.error", e.toString()).toString(); + } + + if (errors != null) { + try { + PrintWriter out = response.getWriter(); + out.write(errors); + out.flush(); + } catch (IOException e) { + } + } + + return null; + } + + /** + * Set Submission Deadline + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + */ + public ActionForward setSubmissionDeadline(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + submitFilesService = getSubmitFilesService(); + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + SubmitFilesContent content = submitFilesService.getSubmitFilesContent(contentID); + + Long dateParameter = WebUtil.readLongParam(request, SbmtConstants.ATTR_SUBMISSION_DEADLINE, true); + Date tzSubmissionDeadline = null; + String formattedDate = ""; + if (dateParameter != null) { + Date submissionDeadline = new Date(dateParameter); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline); + formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale()); + } + content.setSubmissionDeadline(tzSubmissionDeadline); + submitFilesService.saveOrUpdateContent(content); + + response.setContentType("text/plain;charset=utf-8"); + response.getWriter().print(formattedDate); + return null; + } + + // ********************************************************** + // Mark udpate/view methods + // ********************************************************** + /** + * Display special user's marks information. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward listMark(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + Integer userID = WebUtil.readIntParam(request, "userID"); + + submitFilesService = getSubmitFilesService(); + // return FileDetailsDTO list according to the given userID and sessionID + List files = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), true); + + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID); + request.setAttribute("report", files); + return mapping.findForward("listMark"); + } + + /** + * View mark of all learner from same tool content ID. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward listAllMarks(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + submitFilesService = getSubmitFilesService(); + // return FileDetailsDTO list according to the given sessionID + Map userFilesMap = submitFilesService.getFilesUploadedBySession(sessionID, request.getLocale()); + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID); + // request.setAttribute("user",submitFilesService.getUserDetails(userID)); + request.setAttribute("reports", userFilesMap); + + return mapping.findForward("listAllMarks"); + + } + + /** + * Remove the original file created by the learner. Does not actually remove it from the content repository - merely + * makes it as removed. + */ + public ActionForward removeLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws ServletException { + return removeRestoreLearnerFile(mapping, form, request, response, true); + } + + /** + * Remove the original file created by the learner. Does not actually remove it from the content repository - merely + * makes it as removed. + */ + public ActionForward restoreLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws ServletException { + return removeRestoreLearnerFile(mapping, form, request, response, false); + } + + private ActionForward removeRestoreLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, boolean remove) throws ServletException { + + UserDTO currentUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + + Long sessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + Integer learnerUserID = WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID); + Long detailID = WebUtil.readLongParam(request, "detailID"); + + SubmissionDetails fileToProcess = submitFilesService.getSubmissionDetail(detailID); + + if (fileToProcess == null) { + StringBuilder builder = new StringBuilder("Unable to ").append(remove ? "remove" : "restore") + .append("file as file does not exist. Requested by user ").append(currentUser.getUserID()) + .append(" for file ").append(detailID).append(" for user ").append(learnerUserID); + log.error(builder.toString()); + throw new ServletException("Invalid call to "+(remove ? "remove" : "restore")+" file. See the server log for more details."); + } else { + + if (!fileToProcess.getSubmitFileSession().getSessionID().equals(sessionID) + || !fileToProcess.getLearner().getUserID().equals(learnerUserID)) { + StringBuilder builder = new StringBuilder("Unable to ").append(remove ? "remove" : "restore") + .append("file as values in database do not match values in request. Requested by user ") + .append(currentUser.getUserID()).append(" for file ").append(detailID).append(" for user ") + .append(learnerUserID).append(" in session ").append(sessionID); + log.error(builder.toString()); + throw new ServletException("Invalid call to "+(remove ? "remove" : "restore")+" file. See the server log for more details."); + } else { + + if (remove) { + submitFilesService.removeLearnerFile(detailID, currentUser); + notifyRemoveRestore(fileToProcess, "event.file.restore.subject", "event.file.restore.body", "restore file"); + + + } else { + submitFilesService.restoreLearnerFile(detailID, currentUser); + notifyRemoveRestore(fileToProcess, "event.file.delete.subject", "event.file.delete.body", "delete file"); + } + + } + } + + List files = submitFilesService.getFilesUploadedByUser(learnerUserID, sessionID, request.getLocale(), true); + + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionID); + request.setAttribute("report", files); + return mapping.findForward("listMark"); + } + + /** Notify the user by email of the file change. Need to do it here rather than in the service so that any issues are caught and logged + * without stuffing up the transaction. + */ + public void notifyRemoveRestore(SubmissionDetails detail, String i18nSubjectKey, String i18nBodyKey, String errorSubject) { + Long contentID = detail.getSubmitFileSession().getContent().getContentID(); + Integer learnerID = detail.getLearner().getUserID(); + + // Can't just create a new subscription then call triggerForSingleUser() as + // it needs a subscription id, which doesn't exist for a subscription created in the same + // transaction. So reuse the existing RELEASE MARKS event and subscription (created when + // a file is uploaded) and override both the subject and the message. + + try { + boolean eventExists = submitFilesService.getEventNotificationService().eventExists(SbmtConstants.TOOL_SIGNATURE, + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, contentID); + + if (eventExists) { + submitFilesService.getEventNotificationService().triggerForSingleUser(SbmtConstants.TOOL_SIGNATURE, + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, contentID, learnerID, + submitFilesService.getLocalisedMessage(i18nSubjectKey, null), + submitFilesService.getLocalisedMessage(i18nBodyKey, new Object[] { detail.getFilePath() })); + } else { + log.error("Unable to notify user of "+errorSubject+". contentID="+contentID+" learner="+learnerID+" file "+detail.getFilePath()+" as "+SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE+" event is missing"); + } + } catch ( Exception e) { + log.error("Unable to notify user of "+errorSubject+". contentID="+contentID+" learner="+learnerID+" file "+detail.getFilePath()+" due to exception "+e.getMessage(),e); + } + } + + + // ********************************************************** + // Private methods + // ********************************************************** + + private ISubmitFilesService getSubmitFilesService() { + return SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } + + /** + * Return ResourceService bean. + */ + private MessageService getMessageService() { + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); + return (MessageService) wac.getBean("sbmtMessageService"); + } + + /** + * Save file mark information into HttpRequest + * + * @param request + * @param sessionID + * @param userID + * @param detailID + * @param updateMode + */ + private void setMarkPage(HttpServletRequest request, Long sessionID, Long userID, Long detailID, + String updateMode) { + + } + + /** + * Save Summary information into HttpRequest. + * + * @param request + * @param submitFilesSessionList + */ + private void summary(HttpServletRequest request, List submitFilesSessionList) { + SortedSet sessions = new TreeSet(this.new SessionComparator()); + + // build a map with all users in the submitFilesSessionList + Iterator it = submitFilesSessionList.iterator(); + while (it.hasNext()) { + SessionDTO sessionDto = new SessionDTO(); + SubmitFilesSession sfs = (SubmitFilesSession) it.next(); + + Long sessionID = sfs.getSessionID(); + sessionDto.setSessionID(sessionID); + sessionDto.setSessionName(sfs.getSessionName()); + sessions.add(sessionDto); + } + + // request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); + request.setAttribute("sessions", sessions); + } + +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ReflectAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ReflectAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ReflectAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,165 @@ +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.util.Date; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.tool.sbmt.web.form.ReflectionForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * + * @author steven + * + */ +public class ReflectAction extends Action { + + @Override + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + String param = mapping.getParameter(); + //================ Reflection ======================= + if (param.equals("newReflection")) { + return newReflection(mapping, form, request, response); + } + if (param.equals("submitReflection")) { + return submitReflection(mapping, form, request, response); + } + + return mapping.findForward(SbmtConstants.SUCCESS); + } + + /** + * Display empty reflection form. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward newReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + +// ISubmitFilesService submitFilesService = getService(); +// ActionErrors errors = validateBeforeFinish(request,submitFilesService); +// if(!errors.isEmpty()){ +// this.addErrors(request,errors); +// return mapping.getInputForward(); +// } + + //get session value + String sessionMapID = WebUtil.readStrParam(request, SbmtConstants.ATTR_SESSION_MAP_ID); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + ReflectionForm refForm = (ReflectionForm) form; + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + refForm.setUserID(user.getUserID()); + refForm.setSessionMapID(sessionMapID); + + // get the existing reflection entry + ISubmitFilesService submitFilesService = getService(); + + SessionMap map = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long toolSessionID = (Long) map.get(AttributeNames.PARAM_TOOL_SESSION_ID); + NotebookEntry entry = submitFilesService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + SbmtConstants.TOOL_SIGNATURE, user.getUserID()); + + if (entry != null) { + refForm.setEntryText(entry.getEntry()); + } + + return mapping.findForward(SbmtConstants.SUCCESS); + } + + /** + * Submit reflection form input database. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + ReflectionForm refForm = (ReflectionForm) form; + Integer userId = refForm.getUserID(); + + String sessionMapID = WebUtil.readStrParam(request, SbmtConstants.ATTR_SESSION_MAP_ID); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + ISubmitFilesService submitFilesService = getService(); + + // check for existing notebook entry + NotebookEntry entry = submitFilesService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + SbmtConstants.TOOL_SIGNATURE, userId); + + if (entry == null) { + // create new entry + submitFilesService.createNotebookEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + SbmtConstants.TOOL_SIGNATURE, userId, refForm.getEntryText()); + } else { + // update existing entry + entry.setEntry(refForm.getEntryText()); + entry.setLastModified(new Date()); + submitFilesService.updateEntry(entry); + } + + return mapping.findForward(SbmtConstants.SUCCESS); + } + + //********************************************************************************************** + // Private mehtods + //********************************************************************************************** + private ISubmitFilesService getService() { + ISubmitFilesService submitFilesService = SubmitFilesServiceProxy + .getSubmitFilesService(this.getServlet().getServletContext()); + return submitFilesService; + } + + public static ActionErrors validateBeforeFinish(HttpServletRequest request, + ISubmitFilesService submitFilesService) { + ActionErrors errors = new ActionErrors(); + String sessionMapID = WebUtil.readStrParam(request, SbmtConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + Integer userID = user.getUserID(); + + List list = submitFilesService.getFilesUploadedByUser(userID, sessionId, request.getLocale(), false); + int minUpload = (Integer) sessionMap.get(SbmtConstants.PARAM_MIN_UPLOAD); + if (minUpload > 0) { + errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.learning.minimum.upload.number.less")); + } + + return errors; + } +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/SubmitFilesPedagogicalPlannerAction.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/SubmitFilesPedagogicalPlannerAction.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/SubmitFilesPedagogicalPlannerAction.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,104 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.action; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +import org.lamsfoundation.lams.tool.sbmt.service.SubmitFilesServiceProxy; +import org.lamsfoundation.lams.tool.sbmt.web.form.SubmitFilesPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author + * @version + * + * + * + * + * + */ +public class SubmitFilesPedagogicalPlannerAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerAction.class); + + public ISubmitFilesService submitFilesService; + + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + if (submitFilesService == null) { + submitFilesService = SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } + return initPedagogicalPlannerForm(mapping, form, request, response); + } + + public ActionForward initPedagogicalPlannerForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + SubmitFilesPedagogicalPlannerForm plannerForm = (SubmitFilesPedagogicalPlannerForm) form; + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + SubmitFilesContent submitFiles = getSubmitFilesService().getSubmitFilesContent(toolContentID); + plannerForm.fillForm(submitFiles); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return mapping.findForward(SbmtConstants.SUCCESS); + } + + public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws IOException { + SubmitFilesPedagogicalPlannerForm plannerForm = (SubmitFilesPedagogicalPlannerForm) form; + ActionMessages errors = plannerForm.validate(); + if (errors.isEmpty()) { + String content = plannerForm.getInstruction(); + Long toolContentID = plannerForm.getToolContentID(); + SubmitFilesContent submitFiles = getSubmitFilesService().getSubmitFilesContent(toolContentID); + submitFiles.setInstruction(content); + getSubmitFilesService().saveOrUpdateContent(submitFiles); + } else { + saveErrors(request, errors); + } + return mapping.findForward(SbmtConstants.SUCCESS); + } + + private ISubmitFilesService getSubmitFilesService() { + if (submitFilesService == null) { + submitFilesService = SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } + return submitFilesService; + } +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,180 @@ +package org.lamsfoundation.lams.tool.sbmt.web.form; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.struts.action.ActionMapping; +import org.apache.struts.validator.ValidatorForm; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; + +/** + * + * @author Dapeng.Ni + * + */ +public class AuthoringForm extends ValidatorForm { + + private Long toolContentID; + + private String contentFolderID; + + // control fields + private String sessionMapID; + + private String currentTab; + + // basic input fields + private String title; + + private String instructions; + + private boolean lockOnFinished; + + // file and display fields + + private boolean limitUpload; + + private int limitUploadNumber; + + private boolean reflectOnActivity; + + private String reflectInstructions; + + private boolean notifyLearnersOnMarkRelease; + + private boolean notifyTeachersOnFileSubmit; + + @Override + public void reset(ActionMapping mapping, HttpServletRequest request) { + lockOnFinished = false; + limitUpload = false; + reflectOnActivity = false; + + } + + public void initContentValue(SubmitFilesContent content) { + if (content == null) { + return; + } + + // copy attribute + toolContentID = content.getContentID(); + title = content.getTitle(); + instructions = content.getInstruction(); + lockOnFinished = content.isLockOnFinished(); + + limitUpload = content.isLimitUpload(); + limitUploadNumber = content.getLimitUploadNumber(); + + reflectOnActivity = content.isReflectOnActivity(); + reflectInstructions = content.getReflectInstructions(); + setNotifyLearnersOnMarkRelease(content.isNotifyLearnersOnMarkRelease()); + setNotifyTeachersOnFileSubmit(content.isNotifyTeachersOnFileSubmit()); + } + + // ************************************************** + // Get / Set method + // ************************************************** + public String getCurrentTab() { + return currentTab; + } + + public void setCurrentTab(String currentTab) { + this.currentTab = currentTab; + } + + public Long getToolContentID() { + return toolContentID; + } + + public void setToolContentID(Long toolContentID) { + this.toolContentID = toolContentID; + } + + public String getSessionMapID() { + return sessionMapID; + } + + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } + + public String getInstructions() { + return instructions; + } + + public void setInstructions(String instructions) { + this.instructions = instructions; + } + + public boolean isLockOnFinished() { + return lockOnFinished; + } + + public void setLockOnFinished(boolean lockOnFinished) { + this.lockOnFinished = lockOnFinished; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getReflectInstructions() { + return reflectInstructions; + } + + public void setReflectInstructions(String reflectInstructions) { + this.reflectInstructions = reflectInstructions; + } + + public boolean isReflectOnActivity() { + return reflectOnActivity; + } + + public void setReflectOnActivity(boolean reflectOnActivity) { + this.reflectOnActivity = reflectOnActivity; + } + + public String getContentFolderID() { + return contentFolderID; + } + + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + public boolean isLimitUpload() { + return limitUpload; + } + + public void setLimitUpload(boolean limitUpload) { + this.limitUpload = limitUpload; + } + + public int getLimitUploadNumber() { + return limitUploadNumber; + } + + public void setLimitUploadNumber(int limitUploadNumber) { + this.limitUploadNumber = limitUploadNumber; + } + + public boolean isNotifyLearnersOnMarkRelease() { + return notifyLearnersOnMarkRelease; + } + + public void setNotifyLearnersOnMarkRelease(boolean notifyLearnersOnMarkRelease) { + this.notifyLearnersOnMarkRelease = notifyLearnersOnMarkRelease; + } + + public boolean isNotifyTeachersOnFileSubmit() { + return notifyTeachersOnFileSubmit; + } + + public void setNotifyTeachersOnFileSubmit(boolean notifyTeachersOnFileSubmit) { + this.notifyTeachersOnFileSubmit = notifyTeachersOnFileSubmit; + } +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,45 @@ +package org.lamsfoundation.lams.tool.sbmt.web.form; + +import org.apache.struts.upload.FormFile; +import org.apache.struts.validator.ValidatorForm; + +/** + * + * Learner Form. + * + * + */ +public class LearnerForm extends ValidatorForm { + + public static int DESCRIPTION_LENGTH = 5000; + + private String description; + private FormFile file; + + private String sessionMapID; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public FormFile getFile() { + return file; + } + + public void setFile(FormFile file) { + this.file = file; + } + + public String getSessionMapID() { + return sessionMapID; + } + + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,131 @@ +/**************************************************************** + * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.form; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.upload.FormFile; + +/** + * @author lfoxton + * + * + */ +public class MarkForm extends ActionForm { + + private static final long serialVersionUID = -8680214759155659983L; + + private Long toolSessionID; + private Integer userID; + private Long detailID; + private Long reportID; + private String marks; + private FormFile markFile; + private String comments; + private String updateMode; + private Long markFileUUID; + private Long markFileVersionID; + + public MarkForm() { + } + + public Long getToolSessionID() { + return toolSessionID; + } + + public void setToolSessionID(Long toolSessionID) { + this.toolSessionID = toolSessionID; + } + + public Integer getUserID() { + return userID; + } + + public void setUserID(Integer userID) { + this.userID = userID; + } + + public Long getDetailID() { + return detailID; + } + + public void setDetailID(Long detailID) { + this.detailID = detailID; + } + + public Long getReportID() { + return reportID; + } + + public void setReportID(Long reportID) { + this.reportID = reportID; + } + + public String getMarks() { + return marks; + } + + public void setMarks(String marks) { + this.marks = marks; + } + + public FormFile getMarkFile() { + return markFile; + } + + public void setMarkFile(FormFile markFile) { + this.markFile = markFile; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + public String getUpdateMode() { + return updateMode; + } + + public void setUpdateMode(String updateMode) { + this.updateMode = updateMode; + } + + public Long getMarkFileUUID() { + return markFileUUID; + } + + public void setMarkFileUUID(Long markFileUUID) { + this.markFileUUID = markFileUUID; + } + + public Long getMarkFileVersionID() { + return markFileVersionID; + } + + public void setMarkFileVersionID(Long markFileVersionID) { + this.markFileVersionID = markFileVersionID; + } +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,87 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.form; + +import org.apache.log4j.Logger; +import org.apache.struts.validator.ValidatorForm; + +/** + * + * Reflection Form. + * + * + */ +public class ReflectionForm extends ValidatorForm { + private static final long serialVersionUID = -9054365604649146735L; + private static Logger logger = Logger.getLogger(ReflectionForm.class.getName()); + + private Integer userID; + private String sessionMapID; + private String entryText; + +// /** +// * MessageForm validation method from STRUCT interface. +// * +// */ +// public ActionErrors validate(ActionMapping mapping, +// javax.servlet.http.HttpServletRequest request) { +// ActionErrors errors = new ActionErrors(); +// try{ +// if (StringUtils.isBlank(entryText)) { +// ActionMessage error = new ActionMessage("error.reflection.emtpy"); +// errors.add(ActionMessages.GLOBAL_MESSAGE, error); +// } +// +// } catch (Exception e) { +// logger.error(e); +// } +// return errors; +// } + + public String getEntryText() { + return entryText; + } + + public void setEntryText(String entryText) { + this.entryText = entryText; + } + + public Integer getUserID() { + return userID; + } + + public void setUserID(Integer userUid) { + this.userID = userUid; + } + + public String getSessionMapID() { + return sessionMapID; + } + + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -0,0 +1,60 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.sbmt.web.form; + +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; + +/** + * + * + */ +public class SubmitFilesPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { + String instruction; + String contentFolderID; + + public String getContentFolderID() { + return contentFolderID; + } + + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + public String getInstruction() { + return instruction; + } + + public void setInstruction(String instructions) { + instruction = instructions; + } + + public void fillForm(SubmitFilesContent content) { + if (content != null) { + String instruction = content.getInstruction(); + setInstruction(instruction); + setToolContentID(content.getContentID()); + } + } +} \ No newline at end of file Index: lams_tool_sbmt/web/WEB-INF/struts-config.xml =================================================================== diff -u -rd41150b5c329af3aa1823fdcc9cc89b0c9a54416 -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision d41150b5c329af3aa1823fdcc9cc89b0c9a54416) +++ lams_tool_sbmt/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -15,23 +15,23 @@ @@ -70,7 +70,7 @@ - + Index: lams_tool_sbmt/web/authoring/authoring.jsp =================================================================== diff -u -r6cfcb91c5526d4bbb22cd98dbd9d04c175cba1eb -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision 6cfcb91c5526d4bbb22cd98dbd9d04c175cba1eb) +++ lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -8,7 +8,7 @@ -<%@ page import="org.lamsfoundation.lams.tool.sbmt.util.SbmtConstants"%> +<%@ page import="org.lamsfoundation.lams.tool.sbmt.SbmtConstants"%> Index: lams_tool_sbmt/web/monitoring/monitoring.jsp =================================================================== diff -u -rc721962a681e5569a45f46cff42a0e2df989dbfd -rf98151f6d4d6f66f3d8e482481aa198076133e71 --- lams_tool_sbmt/web/monitoring/monitoring.jsp (.../monitoring.jsp) (revision c721962a681e5569a45f46cff42a0e2df989dbfd) +++ lams_tool_sbmt/web/monitoring/monitoring.jsp (.../monitoring.jsp) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) @@ -1,7 +1,7 @@ <%@include file="/common/taglibs.jsp"%> -<%@ page import="org.lamsfoundation.lams.tool.sbmt.util.SbmtConstants"%> +<%@ page import="org.lamsfoundation.lams.tool.sbmt.SbmtConstants"%>