Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java =================================================================== diff -u -rc2388b4c760cc0a05554b831b3205e4831f6e17b -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java (.../SbmtConstants.java) (revision c2388b4c760cc0a05554b831b3205e4831f6e17b) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/SbmtConstants.java (.../SbmtConstants.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -25,7 +25,7 @@ package org.lamsfoundation.lams.tool.sbmt; -public class SbmtConstants { +public interface SbmtConstants { public static final String TOOL_SIGNATURE = "lasbmt11"; Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java =================================================================== diff -u -r309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision 309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -21,8 +21,6 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.sbmt.service; import java.util.List; @@ -44,6 +42,7 @@ import org.lamsfoundation.lams.tool.sbmt.dto.StatisticDTO; import org.lamsfoundation.lams.tool.sbmt.util.SubmitFilesException; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.springframework.web.multipart.MultipartFile; /** * @author Manpreet Minhas @@ -88,16 +87,17 @@ * * @throws SubmitFilesException */ - public void uploadFileToSession(Long sessionID, FormFile uploadFile, String fileDescription, Integer userID) + public void uploadFileToSession(Long sessionID, MultipartFile file, String fileDescription, Integer userID) throws SubmitFilesException; - /** + /** * Get a the details for a single file uploaded by a learner + * * @param detailId * @return SubmissionDetails */ public SubmissionDetails getSubmissionDetail(Long detailId); - + /** * This method returns a list of files that were uploaded by the given * User for given contentID. @@ -111,10 +111,11 @@ * @param sessionID * The session_id to be looked up * @param includeRemovedFiles - * Should files removed in monitor be included. + * Should files removed in monitor be included. * @return List The list of required objects. */ - public List getFilesUploadedByUser(Integer userID, Long sessionID, Locale currentLocale, boolean includeRemovedFiles); + public List getFilesUploadedByUser(Integer userID, Long sessionID, Locale currentLocale, + boolean includeRemovedFiles); /** * This method returns a SortedMap of all files that were submitted users within a given sessionID. @@ -134,7 +135,7 @@ * @param marksFileInputStream * @param marksFileName */ - public void updateMarks(Long reportID, Float marks, String comments, FormFile file, Long SessionID) + public void updateMarks(Long reportID, Float marks, String comments, FormFile file, Long SessionID) throws InvalidParameterException, RepositoryCheckedException; /** @@ -149,16 +150,18 @@ /** * Mark the original file uploaded by a learner as deleted. Does not delete the file * from the content repository. + * * @param detailID */ public void removeLearnerFile(Long detailID, UserDTO monitor); /** * Mark a deleted original file as not deleted. Undoes what removeLearnerFile(). + * * @param detailID */ public void restoreLearnerFile(Long detailID, UserDTO monitor); - + public FileDetailsDTO getFileDetails(Long detailID, Locale currentLocale); /** @@ -300,7 +303,7 @@ * [SubmitUser, Integer1, Integer2, String]> * where Integer1 is the number of files uploaded, Integer2 is the number of files marked * and String is the notebook entry. No notebook entries needed? Will return null in their place. - * + * * @return */ List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, @@ -309,22 +312,22 @@ /** * Get the number of users that would be returned by getUsersForTablesorter() if it was not paged. Supports * filtering. - * + * * @return */ int getCountUsersBySession(Long sessionId, String searchString); /** * Get the basic statistics for all the sessions for one activity. - * + * * @param contentId * @return */ - List getStatisticsBySession(final Long contentId); - + List getStatisticsBySession(final Long contentId); + /** * Get the leader statistics for all the sessions for one activity. - * + * * @param contentId * @return */ @@ -350,35 +353,34 @@ * @return */ boolean isGroupedActivity(long toolContentID); - + /** * Audit log the teacher has started editing activity in monitor. - * + * * @param toolContentID */ void auditLogStartEditingActivityInMonitor(long toolContentID); - + /** * Set specified user as a leader. Also the previous leader (if any) is marked as non-leader. * * @param userId * @param toolSessionID */ SubmitUser checkLeaderSelectToolForSessionLeader(SubmitUser user, Long toolSessionID); - + /** * Create a new user in database. */ void createUser(SubmitUser submitUser); - + /** * @param user * @param toolSessionId * @return */ boolean isUserGroupLeader(SubmitUser user, Long toolSessionId); - void copyLearnerContent(SubmitUser fromUser, SubmitUser toUser); - + } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -rf2c0865cbb95219b30d59d6152b20dff389dc7b0 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision f2c0865cbb95219b30d59d6152b20dff389dc7b0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -101,6 +101,7 @@ import org.lamsfoundation.lams.util.JsonUtil; import org.lamsfoundation.lams.util.MessageService; import org.springframework.dao.DataAccessException; +import org.springframework.web.multipart.MultipartFile; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -607,29 +608,29 @@ } @Override - public void uploadFileToSession(Long sessionID, FormFile uploadFile, String fileDescription, Integer userID) + public void uploadFileToSession(Long sessionID, MultipartFile file, String fileDescription, Integer userID) throws SubmitFilesException { - if ((uploadFile == null) || StringUtils.isEmpty(uploadFile.getFileName())) { - throw new SubmitFilesException("Could not find upload file: " + uploadFile); + if ((file == null) || StringUtils.isEmpty(file.getName())) { + throw new SubmitFilesException("Could not find upload file: " + file); } SubmitFilesSession session = submitFilesSessionDAO.getSessionByID(sessionID); if (session == null) { throw new SubmitFilesException("No such session with a sessionID of: " + sessionID + " found."); } - NodeKey nodeKey = processFile(uploadFile); +// NodeKey nodeKey = processFile(file); SubmissionDetails details = new SubmissionDetails(); details.setFileDescription(fileDescription); - details.setFilePath(uploadFile.getFileName()); + details.setFilePath(file.getName()); details.setDateOfSubmission(new Date()); SubmitUser learner = submitUserDAO.getLearner(sessionID, userID); details.setLearner(learner); - details.setUuid(nodeKey.getUuid()); - details.setVersionID(nodeKey.getVersion()); +// details.setUuid(nodeKey.getUuid()); +// details.setVersionID(nodeKey.getVersion()); SubmitFilesReport report = new SubmitFilesReport(); details.setReport(report); details.setSubmitFileSession(session); @@ -1504,4 +1505,5 @@ return (groupLeader != null) && user.getUserID().equals(groupLeader.getUserID()); } + } \ No newline at end of file Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/AuthoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/LearnerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MarkAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/ReflectAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a8328bd7083a98162fe2ea19193a08ca16de51d4 refers to a dead (removed) revision in file `lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/action/SubmitFilesPedagogicalPlannerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/AuthoringController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/AuthoringController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,219 @@ +/**************************************************************** + * 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.controller; + +import java.lang.reflect.InvocationTargetException; +import java.util.Date; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.commons.beanutils.PropertyUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +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.web.form.AuthoringForm; +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; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author Manpreet Minhas + * @author Steve Ni + */ +@Controller +@RequestMapping("/authoring") +public class AuthoringController { + private Logger log = Logger.getLogger(AuthoringController.class); + + @Autowired + @Qualifier("submitFilesService") + private 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) + */ + + @RequestMapping("/authoring") + public String unspecified(@ModelAttribute AuthoringForm authoringForm, HttpServletRequest request) { + + 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 + + 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.initContentValue(persistContent); + // session map + authoringForm.setSessionMapID(sessionMap.getSessionID()); + authoringForm.setContentFolderID(contentFolderID); + + return "authoring/authoring"; + } + + /** + * Update all content for submit tool except online/offline instruction files list. + * + * @param request + * @param response + * @return + * @throws IllegalAccessException + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws Exception + */ + @RequestMapping("/updateContent") + public String updateContent(@ModelAttribute AuthoringForm authoringForm, Errors errors, HttpServletRequest request) + throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { + + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(authoringForm.getSessionMapID()); + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.PARAM_MODE); + + validate(authoringForm, errors, request); + if (errors.hasErrors()) { + return "redirect:/"; + } + + SubmitFilesContent content = getContent(authoringForm); + + 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 = authoringForm.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 "authoring/authoring"; + } + + // *********************************************************** + // Private/protected methods + // *********************************************************** + /** + * The private method to get content from ActionForm parameters (web page). + * + * @param form + * @return + */ + private SubmitFilesContent getContent(AuthoringForm authoringForm) { + Long contentId = authoringForm.getToolContentID(); + + SubmitFilesContent content = new SubmitFilesContent(); + content.setContentID(contentId); + content.setInstruction(authoringForm.getInstructions()); + content.setTitle(authoringForm.getTitle()); + content.setLockOnFinished(authoringForm.isLockOnFinished()); + content.setReflectInstructions(authoringForm.getReflectInstructions()); + content.setReflectOnActivity(authoringForm.isReflectOnActivity()); + content.setLimitUpload(authoringForm.isLimitUpload()); + content.setUseSelectLeaderToolOuput(authoringForm.isUseSelectLeaderToolOuput()); + content.setLimitUploadNumber(authoringForm.getLimitUploadNumber()); + content.setNotifyLearnersOnMarkRelease(authoringForm.isNotifyLearnersOnMarkRelease()); + content.setNotifyTeachersOnFileSubmit(authoringForm.isNotifyTeachersOnFileSubmit()); + return content; + } + + private void validate(AuthoringForm authoringForm, Errors errors, HttpServletRequest request) { + + // 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())) { + errors.reject("error.title.blank"); + } + + } + +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/ClearSessionController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,69 @@ +/**************************************************************** + * 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.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishController; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.sbmt.SbmtConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.WebApplicationContext; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + * + * @version $Revision$ + */ +@Controller +public class ClearSessionController extends LamsAuthoringFinishController implements SbmtConstants { + private static Logger logger = Logger.getLogger(ClearSessionController.class.getName()); + + @Autowired + private WebApplicationContext applicationContext; + + @RequestMapping("/clearsession") + public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException { + super.execute(request, response, applicationContext); + } + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + session.removeAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG); + if (mode.isAuthor()) { + ClearSessionController.logger.debug("In Author mode"); + session.removeAttribute(customiseSessionID); + } + } +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/LearnerController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/LearnerController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/LearnerController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,525 @@ +/**************************************************************** + * 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.controller; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.SortedMap; +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.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.ToolContentManager; +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.FileValidatorSpringUtil; +import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.MessageService; +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; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.multipart.MultipartFile; + +/** + * @author Manpreet Minhas + * @author Steve.Ni + */ +@Controller +@RequestMapping("/learner") +public class LearnerController implements SbmtConstants { + + private static final boolean MODE_OPTIONAL = false; + + public static Logger logger = Logger.getLogger(LearnerController.class); + + @Autowired + @Qualifier("submitFilesService") + private ISubmitFilesService submitFilesService; + + @Autowired + @Qualifier("sbmtMessageService") + private MessageService messageService; + + @Autowired + private WebApplicationContext applicationContext; + + /** + * The initial page of learner in Submission tool. This page will list all uploaded files and learn + */ + @RequestMapping("/learner") + public String unspecified(@ModelAttribute LearnerForm learnerForm, HttpServletRequest request) { + // initial session Map + SessionMap sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + + learnerForm.setSessionMapID(sessionMap.getSessionID()); + + // get parameters from Request + ToolAccessMode mode = null; + try { + mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, LearnerController.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(); + } + + ToolContentManager contentManager = getContentManager(); + 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_USE_SEL_LEADER, content.isUseSelectLeaderToolOuput()); + 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 "learner/definelater"; + } + + // set contentInUse flag to true! + content.setContentInUse(true); + content.setDefineLater(false); + submitFilesService.saveOrUpdateContent(content); + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionID, request, + applicationContext.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 "learner/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); + } + + SortedMap submittedFilesMap = submitFilesService.getFilesUploadedBySession(sessionID, request.getLocale()); + // support for leader select feature + SubmitUser groupLeader = content.isUseSelectLeaderToolOuput() + ? submitFilesService.checkLeaderSelectToolForSessionLeader(learner, new Long(sessionID).longValue()) + : null; + + if (content.isUseSelectLeaderToolOuput() && !mode.isTeacher()) { + + // forwards to the leaderSelection page + if (groupLeader == null) { + List groupUsers = submitFilesService.getUsersBySession(new Long(sessionID).longValue()); + request.setAttribute(SbmtConstants.ATTR_GROUP_USERS, groupUsers); + request.setAttribute(SbmtConstants.ATTR_SUBMIT_FILES, submittedFilesMap); + return "learner/waitForLeaderTimeLimit"; + } + + // forwards to the waitForLeader pages + boolean isNonLeader = !userID.equals(groupLeader.getUserID()); + + if (isNonLeader && !learner.isFinished()) { + List filesUploadedByLeader = submitFilesService.getFilesUploadedByUser(groupLeader.getUserID(), + sessionID, request.getLocale(), false); + + if (filesUploadedByLeader == null) { + request.setAttribute(SbmtConstants.PARAM_WAITING_MESSAGE_KEY, + "label.waiting.for.leader.launch.time.limit"); + return "learner/waitForLeaderTimeLimit"; + } + + //if the time is up and leader hasn't submitted response - show waitForLeaderFinish page + if (!groupLeader.isFinished()) { + request.setAttribute(SbmtConstants.PARAM_WAITING_MESSAGE_KEY, "label.waiting.for.leader.finish"); + return "learner/waitForLeaderTimeLimit"; + } + } + + // check if leader has submitted all answers + if (groupLeader.isFinished()) { + submitFilesService.copyLearnerContent(groupLeader, learner); + filesUploaded = submitFilesService.getFilesUploadedByUser(learner.getUserID(), learner.getSessionID(), + request.getLocale(), false); + setLearnerDTO(request, sessionMap, learner, filesUploaded, mode); + } + } + + sessionMap.put(SbmtConstants.ATTR_GROUP_LEADER, groupLeader); + boolean isUserLeader = submitFilesService.isUserGroupLeader(learner, sessionID); + sessionMap.put(SbmtConstants.ATTR_IS_USER_LEADER, isUserLeader); + + boolean hasEditRight = !content.isUseSelectLeaderToolOuput() + || content.isUseSelectLeaderToolOuput() && isUserLeader; + sessionMap.put(SbmtConstants.ATTR_HAS_EDIT_RIGHT, hasEditRight); + + return "learner/sbmtlearner"; + } + + /** + * Loads the main learner page with the details currently in the session map + */ + @RequestMapping("/refresh") + public String refresh(@ModelAttribute LearnerForm learnerForm, HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, SbmtConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + learnerForm.setSessionMapID(sessionMap.getSessionID()); + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + // 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(); + Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + 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 "learner/sbmtlearner"; + } + + /** + * Implements learner upload submission function. This function also display the page again for learner uploading + * more submission use. + */ + public String uploadFile(@ModelAttribute LearnerForm learnerForm, @RequestParam("file") MultipartFile file, + Errors errors, HttpServletRequest request) { + + 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, + applicationContext.getServletContext()); + + if (validateUploadForm(learnerForm, errors, 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(); + + 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 "redirect:/"; + } + + // 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(); + + file = learnerForm.getFile(); + String fileDescription = learnerForm.getDescription(); + // reset fields and display a new form for next new file upload + learnerForm.setDescription(""); + + submitFilesService.uploadFileToSession(sessionID, file, fileDescription, userID); + SubmitUser learner = getCurrentLearner(sessionID, submitFilesService); + + 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); + } + + request.setAttribute(SbmtConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "learner/redirectAfterSubmit"; + } + + /** + * Learner choose finish upload button, will invoke this function. This function will mark the finished + * field by special toolSessionID and userID. + */ + public void finish(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(applicationContext.getServletContext()); + + // 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); + } + } + } + + // ********************************************************************************************** + // Private mehtods + // ********************************************************************************************** + + private ToolContentManager getContentManager() { + ToolContentManager contentManager = SubmitFilesServiceProxy + .getSubmitFilesContentManager(this.applicationContext.getServletContext()); + return contentManager; + } + + // validate uploaded form + private boolean validateUploadForm(LearnerForm learnerForm, Errors errors, HttpServletRequest request) { + Locale preferredLocale = (Locale) request.getSession().getAttribute(LocaleFilter.PREFERRED_LOCALE_KEY); + List messages = new ArrayList<>(); + if (learnerForm.getFile() == null || StringUtils.isBlank(learnerForm.getFile().getName())) { + messages.add(this.messageService.getMessage("learner.form.filepath.displayname")); + } + if (StringUtils.isBlank(learnerForm.getDescription())) { + messages.add(this.messageService.getMessage("label.learner.fileDescription")); + } else if (learnerForm.getDescription().length() > LearnerForm.DESCRIPTION_LENGTH) { + messages.add("errors.maxdescsize"); + } + + FileValidatorSpringUtil.validateFileSize(learnerForm.getFile(), false, errors); + + if (learnerForm.getFile() != null) { + LearnerController.logger.debug("Learner submit file : " + learnerForm.getFile().getName()); + } + + if (learnerForm.getFile() != null && FileUtil.isExecutableFile(learnerForm.getFile().getName())) { + LearnerController.logger.debug("File is executatable : " + learnerForm.getFile().getName()); + messages.add("error.attachment.executable"); + } + + if (messages != null && !messages.isEmpty()) { + request.setAttribute("messages", messages); + 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. + */ + 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 + // Monitor can edit the activity and set a limit / decreased the limit with + // the learner having already uploaded more files so ensure code handles that case. + boolean limitUpload = (Boolean) sessionMap.get(SbmtConstants.ATTR_LIMIT_UPLOAD); + if (limitUpload && filesUploaded != null) { + int limit = (Integer) sessionMap.get(SbmtConstants.ATTR_LIMIT_UPLOAD_NUMBER); + int limitUploadLeft = 0; + if (limit <= filesUploaded.size()) { + sessionMap.put(SbmtConstants.ATTR_ARRIVE_LIMIT, true); + } else { + limitUploadLeft = limit - filesUploaded.size(); + } + dto.setLimitUploadLeft(limitUploadLeft); + } + + // retrieve notebook reflection entry. + + 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; + } + + public void deleteLearnerFile(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"); + + 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"); + } + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MarkController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MarkController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MarkController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,171 @@ +/**************************************************************** + * 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.controller; + +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.lamsfoundation.lams.contentrepository.exception.InvalidParameterException; +import org.lamsfoundation.lams.contentrepository.exception.RepositoryCheckedException; +import org.lamsfoundation.lams.tool.sbmt.dto.FileDetailsDTO; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +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.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author lfoxton + * + * + * + * + * + * + * + * + * + */ +@Controller +@RequestMapping("/mark") +public class MarkController { + + @Autowired + @Qualifier("submitFilesService") + private ISubmitFilesService submitFilesService; + + /** + * Update mark. + */ + public String updateMark(@ModelAttribute MarkForm markForm, HttpServletRequest request) + throws InvalidParameterException, RepositoryCheckedException { + + // Check whether the mark is valid. + Float marks = null; + String markStr = markForm.getMarks(); + List messages = new ArrayList<>(); + try { + marks = NumberUtil.getLocalisedFloat(markStr, request.getLocale()); + } catch (Exception e) { + messages.add("errors.mark.invalid.number"); + } + + String comments = WebUtil.readStrParam(request, "comments", true); + if (messages != null && !messages.isEmpty()) { + 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()); + + request.setAttribute("messages", messages); + return "monitoring/mark/updatemark"; + } + + // Update the mark based on the form + submitFilesService.updateMarks(markForm.getReportID(), marks, comments, markForm.getMarkFile(), + markForm.getToolSessionID()); + + // 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 "monitoring/mark/mark"; + } else { + Map report = submitFilesService.getFilesUploadedBySession(markForm.getToolSessionID(), request.getLocale()); + request.setAttribute("reports", report); + return "monitoring/mark/allmarks"; + } + } + + /** + * Display update mark initial page. + */ + public String newMark(@ModelAttribute MarkForm markForm, HttpServletRequest request) { + + 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 "monitoring/mark/updatemark"; + } + + /** + * Update the form + */ + 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 + */ + public String removeMarkFile(@ModelAttribute MarkForm markForm, HttpServletRequest request, + HttpServletResponse response) { + + submitFilesService.removeMarkFile(markForm.getReportID(), markForm.getMarkFileUUID(), + markForm.getMarkFileVersionID(), markForm.getToolSessionID()); + + 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 "monitoring/mark/updatemark"; + } + +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MonitoringController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/MonitoringController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,580 @@ +/**************************************************************** + * 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.controller; + +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.log4j.Logger; +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.ActionMessage; +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.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.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.util.HtmlUtils; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +/** + * @author Manpreet Minhas + */ +@Controller +@RequestMapping("/monitoring") +public class MonitoringController { + + public static Logger logger = Logger.getLogger(MonitoringController.class); + + @Autowired + @Qualifier("submitFilesService") + private ISubmitFilesService submitFilesService; + + @Autowired + @Qualifier("sbmtMessageService") + private MessageService messageService; + + 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 + */ + @RequestMapping("/monitoring") + public String unspecified(HttpServletRequest request) { + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + Long contentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + 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.CONTENT_IN_USE, 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())); + } + + // smbtMonitoringForm.set("currentTab", WebUtil.readStrParam(request, AttributeNames.PARAM_CURRENT_TAB,true)); + + return "monitoring/monitoring"; + } + + /** Ajax call to populate the tablesorter */ + @RequestMapping(produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + public String getUsers(HttpServletRequest request, HttpServletResponse response) { + + 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 + SubmitFilesContent spreadsheet = submitFilesService.getSubmitFilesContent(contentId); + List users = submitFilesService.getUsersForTablesorter(sessionID, page, size, sorting, searchString, + spreadsheet.isReflectOnActivity()); + + ArrayNode rows = JsonNodeFactory.instance.arrayNode(); + ObjectNode responsedata = JsonNodeFactory.instance.objectNode(); + responsedata.put("total_rows", submitFilesService.getCountUsersBySession(sessionID, searchString)); + SubmitUser groupLeader = new SubmitUser(); + if (spreadsheet.isUseSelectLeaderToolOuput()) { + SubmitFilesSession session = submitFilesService.getSessionById(sessionID); + groupLeader = session.getGroupLeader(); + } + for (Object[] userAndReflection : users) { + + ObjectNode responseRow = JsonNodeFactory.instance.objectNode(); + + 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, HtmlUtils.htmlEscape(user.getFullName())); + + if (userAndReflection.length > 2) { + responseRow.put(SbmtConstants.ATTR_PORTRAIT_ID, (Integer) userAndReflection[1]); + } + + if (userAndReflection.length > 3) { + responseRow.put(SbmtConstants.ATTR_USER_NUM_FILE, + (Integer) userAndReflection[2] - (Integer) userAndReflection[3]); + } + + if (userAndReflection.length > 4) { + responseRow.put(SbmtConstants.ATTR_USER_FILE_MARKED, (Integer) userAndReflection[4] > 0); + } + + if (userAndReflection.length > 5) { + responseRow.put(SbmtConstants.ATTR_USER_REFLECTION, (String) userAndReflection[5]); + } + if (!spreadsheet.isUseSelectLeaderToolOuput() + || (spreadsheet.isUseSelectLeaderToolOuput() && groupLeader == user)) { + rows.add(responseRow); + } + } + + responsedata.set("rows", rows); + + return responsedata.toString(); + + } + + /** + * AJAX call to refresh statistic page. + */ + public String doStatistic(HttpServletRequest request) { + + Long contentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + statistic(request, contentID); + request.setAttribute(SbmtConstants.ATTR_IS_GROUPED_ACTIVITY, submitFilesService.isGroupedActivity(contentID)); + return "monitoring/parts/statisticpart"; + } + + private void statistic(HttpServletRequest request, Long contentID) { + SortedSet statistics = new TreeSet<>(new StatisticComparator()); + SubmitFilesContent spreadsheet = submitFilesService.getSubmitFilesContent(contentID); + if (spreadsheet.isUseSelectLeaderToolOuput()) { + statistics.addAll(submitFilesService.getLeaderStatisticsBySession(contentID)); + request.setAttribute("statisticList", statistics); + } else { + statistics.addAll(submitFilesService.getStatisticsBySession(contentID)); + request.setAttribute("statisticList", statistics); + } + } + + /** + * Release mark + */ + public void releaseMarks(HttpServletRequest request, HttpServletResponse response) { + + // get service then update report table + 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(messageService.getMessage("msg.mark.released", new String[] { sessionName })); + out.flush(); + } catch (IOException e) { + } + } + + /** + * Download submit file marks by MS Excel file format. + */ + public void downloadMarks(HttpServletRequest request, HttpServletResponse response) { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + // 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(messageService.getMessage("label.learner.fileName")); + + cell = row.createCell(3); + cell.setCellValue(messageService.getMessage("label.learner.fileDescription")); + + cell = row.createCell(4); + cell.setCellValue(messageService.getMessage("label.learner.marks")); + + cell = row.createCell(5); + cell.setCellValue(messageService.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) { + } + } + } + + /** + * Set Submission Deadline + */ + @RequestMapping(produces = MediaType.TEXT_PLAIN_VALUE) + @ResponseBody + public String setSubmissionDeadline(HttpServletRequest request, HttpServletResponse response) throws IOException { + + 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); + + return formattedDate; + } + + // ********************************************************** + // Mark udpate/view methods + // ********************************************************** + /** + * Display special user's marks information. + */ + public String listMark(HttpServletRequest request) { + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + Integer userID = WebUtil.readIntParam(request, "userID"); + + // 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 "monitoring/mark/mark"; + } + + /** + * View mark of all learner from same tool content ID. + */ + public String listAllMarks(HttpServletRequest request) { + + Long sessionID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + // 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 "monitoring/mark/allmarks"; + + } + + /** + * Remove the original file created by the learner. Does not actually remove it from the content repository - merely + * makes it as removed. + */ + public String removeLearnerFile(HttpServletRequest request) throws ServletException { + return removeRestoreLearnerFile(request, true); + } + + /** + * Remove the original file created by the learner. Does not actually remove it from the content repository - merely + * makes it as removed. + */ + public String restoreLearnerFile(HttpServletRequest request) throws ServletException { + return removeRestoreLearnerFile(request, false); + } + + public String removeRestoreLearnerFile(HttpServletRequest request, boolean remove) throws ServletException { + + UserDTO currentUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + 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); + logger.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); + logger.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 "monitoring/mark/mark"; + } + + /** + * 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 { + logger.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) { + logger.error("Unable to notify user of " + errorSubject + ". contentID=" + contentID + " learner=" + + learnerID + " file " + detail.getFilePath() + " due to exception " + e.getMessage(), e); + } + } + + // ********************************************************** + // Private methods + // ********************************************************** + + /** + * Save file mark information into HttpRequest + */ + private void setMarkPage(HttpServletRequest request, Long sessionID, Long userID, Long detailID, + String updateMode) { + + } + + /** + * Save Summary information into HttpRequest. + */ + 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/controller/ReflectController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/ReflectController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/ReflectController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,129 @@ +package org.lamsfoundation.lams.tool.sbmt.web.controller; + +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.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.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; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.validation.Errors; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * + * @author steven + * + */ +@Controller +@RequestMapping("/learning") +public class ReflectController { + + @Autowired + @Qualifier("submitFilesService") + private ISubmitFilesService submitFilesService; + + /** + * Display empty reflection form. + */ + @RequestMapping("/newReflection") + public String newReflection(@ModelAttribute ReflectionForm refForm, 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); + + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + refForm.setUserID(user.getUserID()); + refForm.setSessionMapID(sessionMapID); + + // get the existing reflection entry + + 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 "learner/notebook"; + } + + /** + * Submit reflection form input database. + */ + @RequestMapping("/submitReflection") + public String submitReflection(@ModelAttribute ReflectionForm refForm, HttpServletRequest request) { + 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); + + // 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 "redirect:/learner.do?method=finish"; + } + + //********************************************************************************************** + // Private mehtods + //********************************************************************************************** + + public static void validateBeforeFinish(Errors errors, HttpServletRequest request, + ISubmitFilesService submitFilesService) { + 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.reject("error.learning.minimum.upload.number.less"); + } + } +} Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/SubmitFilesPedagogicalPlannerController.java =================================================================== diff -u --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/SubmitFilesPedagogicalPlannerController.java (revision 0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/controller/SubmitFilesPedagogicalPlannerController.java (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,91 @@ +/**************************************************************** + * 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.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; +import org.lamsfoundation.lams.tool.sbmt.service.ISubmitFilesService; +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; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author + * @version + * + * + * + * + * + */ +@Controller +@RequestMapping("/pedagogicalPlanner") +public class SubmitFilesPedagogicalPlannerController { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerAction.class); + + @Autowired + @Qualifier("submitFilesService") + private ISubmitFilesService submitFilesService; + + protected String unspecified(SubmitFilesPedagogicalPlannerForm plannerForm, HttpServletRequest request) { + return initPedagogicalPlannerForm(plannerForm, request); + } + + public String initPedagogicalPlannerForm(@ModelAttribute SubmitFilesPedagogicalPlannerForm plannerForm, + HttpServletRequest request) { + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + SubmitFilesContent submitFiles = submitFilesService.getSubmitFilesContent(toolContentID); + plannerForm.fillForm(submitFiles); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return "authoring/pedagogicalPlannerForm"; + } + + public String saveOrUpdatePedagogicalPlannerForm(@ModelAttribute SubmitFilesPedagogicalPlannerForm plannerForm, + HttpServletRequest request) { + List messages = (List) plannerForm.validate(); + if (messages == null && messages.isEmpty()) { + String content = plannerForm.getInstruction(); + Long toolContentID = plannerForm.getToolContentID(); + SubmitFilesContent submitFiles = submitFilesService.getSubmitFilesContent(toolContentID); + submitFiles.setInstruction(content); + submitFilesService.saveOrUpdateContent(submitFiles); + } else { + request.setAttribute("messages", messages); + } + return "authoring/pedagogicalPlannerForm"; + } +} \ No newline at end of file Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java =================================================================== diff -u -r1688016bbb43db756bca9b93361c2a3833089d12 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java (.../AuthoringForm.java) (revision 1688016bbb43db756bca9b93361c2a3833089d12) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/AuthoringForm.java (.../AuthoringForm.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -11,7 +11,7 @@ * @author Dapeng.Ni * */ -public class AuthoringForm extends ValidatorForm { +public class AuthoringForm { private Long toolContentID; @@ -45,13 +45,11 @@ private boolean notifyTeachersOnFileSubmit; - @Override - public void reset(ActionMapping mapping, HttpServletRequest request) { + public void reset(HttpServletRequest request) { lockOnFinished = false; useSelectLeaderToolOuput = false; limitUpload = false; reflectOnActivity = false; - } public void initContentValue(SubmitFilesContent content) { Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java =================================================================== diff -u -rf98151f6d4d6f66f3d8e482481aa198076133e71 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java (.../LearnerForm.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/LearnerForm.java (.../LearnerForm.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,20 +1,19 @@ package org.lamsfoundation.lams.tool.sbmt.web.form; -import org.apache.struts.upload.FormFile; -import org.apache.struts.validator.ValidatorForm; +import org.springframework.web.multipart.MultipartFile; /** * * Learner Form. * * */ -public class LearnerForm extends ValidatorForm { +public class LearnerForm { public static int DESCRIPTION_LENGTH = 5000; private String description; - private FormFile file; + private MultipartFile file; private String sessionMapID; @@ -26,11 +25,11 @@ this.description = description; } - public FormFile getFile() { + public MultipartFile getFile() { return file; } - public void setFile(FormFile file) { + public void setFile(MultipartFile file) { this.file = file; } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java =================================================================== diff -u -rf98151f6d4d6f66f3d8e482481aa198076133e71 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java (.../MarkForm.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/MarkForm.java (.../MarkForm.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -31,7 +31,7 @@ * * */ -public class MarkForm extends ActionForm { +public class MarkForm { private static final long serialVersionUID = -8680214759155659983L; Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java =================================================================== diff -u -rf98151f6d4d6f66f3d8e482481aa198076133e71 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -33,7 +33,7 @@ * * */ -public class ReflectionForm extends ValidatorForm { +public class ReflectionForm { private static final long serialVersionUID = -9054365604649146735L; private static Logger logger = Logger.getLogger(ReflectionForm.class.getName()); Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java =================================================================== diff -u -rf98151f6d4d6f66f3d8e482481aa198076133e71 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java (.../SubmitFilesPedagogicalPlannerForm.java) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/form/SubmitFilesPedagogicalPlannerForm.java (.../SubmitFilesPedagogicalPlannerForm.java) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -25,12 +25,13 @@ import org.lamsfoundation.lams.tool.sbmt.SubmitFilesContent; import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivityForm; +import org.lamsfoundation.lams.web.planner.PedagogicalPlannerActivitySpringForm; /** * * */ -public class SubmitFilesPedagogicalPlannerForm extends PedagogicalPlannerActivityForm { +public class SubmitFilesPedagogicalPlannerForm extends PedagogicalPlannerActivitySpringForm { String instruction; String contentFolderID; Index: lams_tool_sbmt/web/WEB-INF/spring-servlet.xml =================================================================== diff -u --- lams_tool_sbmt/web/WEB-INF/spring-servlet.xml (revision 0) +++ lams_tool_sbmt/web/WEB-INF/spring-servlet.xml (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -0,0 +1,17 @@ + + + + + + + + + + + \ No newline at end of file Index: lams_tool_sbmt/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r07ace0e41d113321756cbe1d75ab04d8c9cb5841 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 07ace0e41d113321756cbe1d75ab04d8c9cb5841) +++ lams_tool_sbmt/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -32,7 +32,7 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ attribute name="formID" required="true" rtexprvalue="true" %> @@ -123,11 +123,11 @@ } \ No newline at end of file Index: lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag =================================================================== diff -u -r540199b8a30f643c2ca5960c007e5bef74acd397 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision 540199b8a30f643c2ca5960c007e5bef74acd397) +++ lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingCriteria.tag =================================================================== diff -u -r5bdde98b1e94d44d239a50549987293714a5bef1 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision 5bdde98b1e94d44d239a50549987293714a5bef1) +++ lams_tool_sbmt/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -8,9 +8,9 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ attribute name="criterias" required="true" rtexprvalue="true" type="java.util.Collection" %> @@ -284,42 +284,42 @@ - - + + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + - - + + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + Index: lams_tool_sbmt/web/WEB-INF/tags/CommentsAuthor.tag =================================================================== diff -u -r500ae45f4243aa718eac7436bc903b4f137a3aa7 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision 500ae45f4243aa718eac7436bc903b4f137a3aa7) +++ lams_tool_sbmt/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,7 +1,7 @@ <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-html" prefix="html"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ attribute name="allowCommentsVariableName" required="false" rtexprvalue="true"%> <%@ attribute name="allowCommentLabelKey" required="false" rtexprvalue="true"%> @@ -42,23 +42,21 @@
-     -   +     +  
Index: lams_tool_sbmt/web/WEB-INF/tags/TextSearch.tag =================================================================== diff -u -rf21aa2ec355995ada05a1490b962235e75726d61 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision f21aa2ec355995ada05a1490b962235e75726d61) +++ lams_tool_sbmt/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -88,39 +88,39 @@
- +

- +
- +
- +
- +
Index: lams_tool_sbmt/web/WEB-INF/web.xml =================================================================== diff -u -rac280c8fb2043ec90a0b7756ede0c7ab64c089d8 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/WEB-INF/web.xml (.../web.xml) (revision ac280c8fb2043ec90a0b7756ede0c7ab64c089d8) +++ lams_tool_sbmt/web/WEB-INF/web.xml (.../web.xml) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -64,6 +64,14 @@ /* + + spring + + org.springframework.web.servlet.DispatcherServlet + + 1 + + org.springframework.web.context.ContextLoaderListener @@ -120,7 +128,7 @@ - action + spring *.do Index: lams_tool_sbmt/web/authoring/advance.jsp =================================================================== diff -u -r1688016bbb43db756bca9b93361c2a3833089d12 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/authoring/advance.jsp (.../advance.jsp) (revision 1688016bbb43db756bca9b93361c2a3833089d12) +++ lams_tool_sbmt/web/authoring/advance.jsp (.../advance.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -20,7 +20,7 @@
@@ -29,38 +29,38 @@
- - 1 - 2 - 3 - 4 - 5 - + + 1 + 2 + 3 + 4 + 5 +
@@ -70,20 +70,20 @@
- +
Index: lams_tool_sbmt/web/authoring/authoring.jsp =================================================================== diff -u -rf98151f6d4d6f66f3d8e482481aa198076133e71 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision f98151f6d4d6f66f3d8e482481aa198076133e71) +++ lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -23,16 +23,15 @@ - - - + + - - - - - + + + + + @@ -54,14 +53,14 @@ toolSignature="<%=SbmtConstants.TOOL_SIGNATURE%>" accessMode="${sessionMap.mode}" defineLater="${sessionMap.mode == 'teacher'}" - toolContentID="${formBean.toolContentID}" - customiseSessionID="${formBean.sessionMapID}" - contentFolderID="${formBean.contentFolderID}" /> + toolContentID="${authoringForm.toolContentID}" + customiseSessionID="${authoringForm.sessionMapID}" + contentFolderID="${authoringForm.contentFolderID}" /> - + \ No newline at end of file Index: lams_tool_sbmt/web/authoring/basic.jsp =================================================================== diff -u -r6bed0e62245e6c9ce454d4bc54920a0b41dac9bc -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/authoring/basic.jsp (.../basic.jsp) (revision 6bed0e62245e6c9ce454d4bc54920a0b41dac9bc) +++ lams_tool_sbmt/web/authoring/basic.jsp (.../basic.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,14 +1,13 @@ <%@ include file="/common/taglibs.jsp"%> - - +
- +
- +
\ No newline at end of file Index: lams_tool_sbmt/web/authoring/pedagogicalPlannerForm.jsp =================================================================== diff -u -r2fab2e212d7c46f61829635d0834821eb5484837 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/authoring/pedagogicalPlannerForm.jsp (.../pedagogicalPlannerForm.jsp) (revision 2fab2e212d7c46f61829635d0834821eb5484837) +++ lams_tool_sbmt/web/authoring/pedagogicalPlannerForm.jsp (.../pedagogicalPlannerForm.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -15,19 +15,18 @@

- - - - - + + + + + - - + Index: lams_tool_sbmt/web/common/messages.jsp =================================================================== diff -u -r129b9d294bcaafb1b0aafa5dc613b103bb084c66 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/common/messages.jsp (.../messages.jsp) (revision 129b9d294bcaafb1b0aafa5dc613b103bb084c66) +++ lams_tool_sbmt/web/common/messages.jsp (.../messages.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,10 +1,11 @@ <%@include file="/common/taglibs.jsp"%> <%-- Error Messages --%> - - - -
-
+ + + + + + -
\ No newline at end of file + \ No newline at end of file Index: lams_tool_sbmt/web/learner/notebook.jsp =================================================================== diff -u -rfc08800f7153cddd1f21d7a936cdd229133ec261 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/learner/notebook.jsp (.../notebook.jsp) (revision fc08800f7153cddd1f21d7a936cdd229133ec261) +++ lams_tool_sbmt/web/learner/notebook.jsp (.../notebook.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -26,10 +26,10 @@
- - - - + + + + - +
Index: lams_tool_sbmt/web/learner/redirectAfterSubmit.jsp =================================================================== diff -u -r309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/learner/redirectAfterSubmit.jsp (.../redirectAfterSubmit.jsp) (revision 309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203) +++ lams_tool_sbmt/web/learner/redirectAfterSubmit.jsp (.../redirectAfterSubmit.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,9 +1,4 @@ -<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> -<%@ taglib uri="tags-bean" prefix="bean"%> -<%@ taglib uri="tags-html" prefix="html"%> -<%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-fmt" prefix="fmt"%> -<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ include file="/common/taglibs.jsp"%> Index: lams_tool_sbmt/web/learner/sbmtlearner.jsp =================================================================== diff -u -r309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/learner/sbmtlearner.jsp (.../sbmtlearner.jsp) (revision 309d4e79cd4ea1ee0b3e4cf0e070dd5243e73203) +++ lams_tool_sbmt/web/learner/sbmtlearner.jsp (.../sbmtlearner.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -203,9 +203,9 @@ - + "> - + " class="btn btn-default btn-disable-on-submit pull-right"> @@ -286,11 +286,11 @@ - - + + - +
@@ -308,7 +308,7 @@ - +

*

@@ -322,7 +322,7 @@ -
+
@@ -359,10 +359,10 @@ - + @@ -372,9 +372,9 @@ - + - +
@@ -55,7 +55,7 @@ - + Index: lams_tool_sbmt/web/learner/waitForLeaderTimeLimit.jsp =================================================================== diff -u -rce8a7f3f69f079ff6052fa050af4183555d9e768 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/learner/waitForLeaderTimeLimit.jsp (.../waitForLeaderTimeLimit.jsp) (revision ce8a7f3f69f079ff6052fa050af4183555d9e768) +++ lams_tool_sbmt/web/learner/waitForLeaderTimeLimit.jsp (.../waitForLeaderTimeLimit.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -30,9 +30,9 @@ - + Index: lams_tool_sbmt/web/learner/waitforleader.jsp =================================================================== diff -u -rce8a7f3f69f079ff6052fa050af4183555d9e768 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/learner/waitforleader.jsp (.../waitforleader.jsp) (revision ce8a7f3f69f079ff6052fa050af4183555d9e768) +++ lams_tool_sbmt/web/learner/waitforleader.jsp (.../waitforleader.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -43,9 +43,9 @@ - + Index: lams_tool_sbmt/web/monitoring/mark/allmarks.jsp =================================================================== diff -u -raeba69e88ab1e8231f91f2b5908dda5edf03f84f -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/mark/allmarks.jsp (.../allmarks.jsp) (revision aeba69e88ab1e8231f91f2b5908dda5edf03f84f) +++ lams_tool_sbmt/web/monitoring/mark/allmarks.jsp (.../allmarks.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -36,9 +36,9 @@
- + - + Index: lams_tool_sbmt/web/monitoring/mark/fileinfo.jsp =================================================================== diff -u -r5831c6c974ca7fef986ffd207d708a2a56bf39f1 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/mark/fileinfo.jsp (.../fileinfo.jsp) (revision 5831c6c974ca7fef986ffd207d708a2a56bf39f1) +++ lams_tool_sbmt/web/monitoring/mark/fileinfo.jsp (.../fileinfo.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -27,28 +27,28 @@
- + "> - + - + download/?uuid=${fileInfo.uuID}&versionID=${fileInfo.versionID}&preferDownload=false - + "> - + - + download/?uuid=${fileInfo.uuID}&versionID=${fileInfo.versionID}&preferDownload=true - + "> - + - + "> - + Index: lams_tool_sbmt/web/monitoring/mark/filelist.jsp =================================================================== diff -u -raeba69e88ab1e8231f91f2b5908dda5edf03f84f -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/mark/filelist.jsp (.../filelist.jsp) (revision aeba69e88ab1e8231f91f2b5908dda5edf03f84f) +++ lams_tool_sbmt/web/monitoring/mark/filelist.jsp (.../filelist.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -11,10 +11,10 @@ @@ -50,17 +50,17 @@
- + download/?uuid=${fileInfo.markFileUUID}&versionID=${fileInfo.markFileVersionID}&preferDownload=false - + "> - + - + download/?uuid=${fileInfo.markFileUUID}&versionID=${fileInfo.markFileVersionID}&preferDownload=true - + "> - +
Index: lams_tool_sbmt/web/monitoring/mark/mark.jsp =================================================================== diff -u -raeba69e88ab1e8231f91f2b5908dda5edf03f84f -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/mark/mark.jsp (.../mark.jsp) (revision aeba69e88ab1e8231f91f2b5908dda5edf03f84f) +++ lams_tool_sbmt/web/monitoring/mark/mark.jsp (.../mark.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -54,9 +54,9 @@
- + - + Index: lams_tool_sbmt/web/monitoring/mark/updatemark.jsp =================================================================== diff -u -r07ace0e41d113321756cbe1d75ab04d8c9cb5841 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/mark/updatemark.jsp (.../updatemark.jsp) (revision 07ace0e41d113321756cbe1d75ab04d8c9cb5841) +++ lams_tool_sbmt/web/monitoring/mark/updatemark.jsp (.../updatemark.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -58,16 +58,16 @@ - + - - - - - - - - + + + + + + + + <%@include file="fileinfo.jsp"%> @@ -80,7 +80,7 @@ :
- +
@@ -102,22 +102,22 @@
- + download/?uuid=${fileInfo.markFileUUID}&versionID=${fileInfo.markFileVersionID}&preferDownload=false - + "> - + - + download/?uuid=${fileInfo.markFileUUID}&versionID=${fileInfo.markFileVersionID}&preferDownload=true - + "> - + - + "> - +
@@ -149,14 +149,14 @@ ?method=listAllMarks&toolSessionID=${toolSessionID} - + - +
-
+
Index: lams_tool_sbmt/web/monitoring/parts/activity.jsp =================================================================== diff -u -rc2388b4c760cc0a05554b831b3205e4831f6e17b -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/parts/activity.jsp (.../activity.jsp) (revision c2388b4c760cc0a05554b831b3205e4831f6e17b) +++ lams_tool_sbmt/web/monitoring/parts/activity.jsp (.../activity.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -1,7 +1,5 @@ <%@ include file="/common/taglibs.jsp"%> - - @@ -34,6 +32,6 @@ - + - + Index: lams_tool_sbmt/web/monitoring/parts/daterestriction.jsp =================================================================== diff -u -rd41150b5c329af3aa1823fdcc9cc89b0c9a54416 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/parts/daterestriction.jsp (.../daterestriction.jsp) (revision d41150b5c329af3aa1823fdcc9cc89b0c9a54416) +++ lams_tool_sbmt/web/monitoring/parts/daterestriction.jsp (.../daterestriction.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -10,9 +10,9 @@ - + - +
@@ -21,9 +21,9 @@ - + - + \ No newline at end of file Index: lams_tool_sbmt/web/monitoring/parts/summary.jsp =================================================================== diff -u -r1688016bbb43db756bca9b93361c2a3833089d12 -ra8328bd7083a98162fe2ea19193a08ca16de51d4 --- lams_tool_sbmt/web/monitoring/parts/summary.jsp (.../summary.jsp) (revision 1688016bbb43db756bca9b93361c2a3833089d12) +++ lams_tool_sbmt/web/monitoring/parts/summary.jsp (.../summary.jsp) (revision a8328bd7083a98162fe2ea19193a08ca16de51d4) @@ -189,21 +189,21 @@

- + + + + + + - - + +