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