Index: lams_tool_sbmt/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7e5ebaceffd43ff691062c0de86f16125d3c3425 -ra71bf2630935c6bc8b907ca22801208a2d3bd657 --- lams_tool_sbmt/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7e5ebaceffd43ff691062c0de86f16125d3c3425) +++ lams_tool_sbmt/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) @@ -145,7 +145,7 @@ label.deleted =Deleted label.monitoring.original.learner.file.delete =Delete label.monitoring.original.learner.file.restore =Restore -message.monitor.confirm.original.learner.file.delete =Are you sure you want to delete the original file {0} uploaded by the learner? +message.monitor.confirm.original.learner.file.delete =Are you sure you want to delete the original file uploaded by the learner? message.monitor.confirm.original.learner.file.restore =Are you sure you want to restore the original file {0} uploaded by the learner? event.file.delete.subject =LAMS: File was deleted. event.file.delete.body =An instructor deleted your file ''''{0}'''' in a Submit Files activity in LAMS. This message was send automatically, please do not reply to it. Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -r2abc3485dc2d24ea02044a64271f3ee0d3b8c11b -ra71bf2630935c6bc8b907ca22801208a2d3bd657 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision 2abc3485dc2d24ea02044a64271f3ee0d3b8c11b) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) @@ -750,8 +750,10 @@ SubmissionDetails detail = submissionDetailsDAO.getSubmissionDetailsByID(detailID); if (detail != null) { + if(monitor != null){ auditRemoveRestore(monitor, detail, "audit.file.delete"); + } detail.setRemoved(true); submissionDetailsDAO.update(detail); Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java =================================================================== diff -u -rc594c716c5d793a4a86c95161a6b3be7ebd70af7 -ra71bf2630935c6bc8b907ca22801208a2d3bd657 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java (.../LearnerAction.java) (revision c594c716c5d793a4a86c95161a6b3be7ebd70af7) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/LearnerAction.java (.../LearnerAction.java) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) @@ -32,6 +32,7 @@ import java.util.Locale; import java.util.TimeZone; +import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; @@ -84,6 +85,7 @@ private static final boolean MODE_OPTIONAL = false; public static Logger logger = Logger.getLogger(LearnerAction.class); + public ISubmitFilesService submitFilesService; /** * The initial page of learner in Submission tool. This page will list all uploaded files and learn @@ -151,7 +153,7 @@ 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, + sessionMap.put(SbmtConstants.ATTR_UPLOAD_MAX_FILE_SIZE, FileValidatorUtil.formatSize(Configuration.getAsInt(ConfigurationKeys.UPLOAD_FILE_MAX_SIZE))); setLearnerDTO(request, sessionMap, learner, filesUploaded, mode); @@ -232,7 +234,8 @@ Integer userID = user.getUserID(); ISubmitFilesService submitFilesService = getService(); - List filesUploaded = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), false); + List filesUploaded = submitFilesService.getFilesUploadedByUser(userID, sessionID, request.getLocale(), + false); SubmitUser learner = getCurrentLearner(sessionID, submitFilesService); ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); @@ -390,10 +393,10 @@ } else { filedto.setCurrentLearner(false); } - if (filedto.getDateMarksReleased() == null) { - filedto.setComments(null); - filedto.setMarks(null); - } +// if (filedto.getDateMarksReleased() == null) { +// filedto.setComments(null); +// filedto.setMarks(null); +// } } } dto.setFilesUploaded(filesUploaded); @@ -439,4 +442,31 @@ return learner; } + private ISubmitFilesService getSubmitFilesService() { + return SubmitFilesServiceProxy.getSubmitFilesService(this.getServlet().getServletContext()); + } + + public ActionForward deleteLearnerFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws ServletException, IOException { + HttpSession ss = SessionManager.getSession(); + + + UserDTO currentUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + Long detailID = WebUtil.readLongParam(request, "detailId"); + + if (submitFilesService == null) { + submitFilesService = getSubmitFilesService(); + } + FileDetailsDTO fileDetail = submitFilesService.getFileDetails(detailID, request.getLocale()); + + if (fileDetail.getOwner().getUserID().equals(currentUser.getUserID()) && (StringUtils.isBlank(fileDetail.getMarks()))) { + + submitFilesService.removeLearnerFile(detailID,null); + + } else { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "You are not allowed to delete this item"); + } + return null; + } + } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java =================================================================== diff -u -r718eb0168ce2c27cac7cc4ec0fbce603d24dda49 -ra71bf2630935c6bc8b907ca22801208a2d3bd657 --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java (.../MonitoringAction.java) (revision 718eb0168ce2c27cac7cc4ec0fbce603d24dda49) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/MonitoringAction.java (.../MonitoringAction.java) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) @@ -197,8 +197,8 @@ responseRow.put(SbmtConstants.ATTR_USER_FULLNAME, StringEscapeUtils.escapeHtml(user.getFullName())); if (userAndReflection.length > 2) { - responseRow.put(SbmtConstants.ATTR_USER_NUM_FILE, - (Integer) userAndReflection[1] - (Integer) userAndReflection[2]); + responseRow.put(SbmtConstants.ATTR_USER_NUM_FILE, + (Integer)userAndReflection[1] - (Integer)userAndReflection[2]); } if (userAndReflection.length > 3) { @@ -509,8 +509,7 @@ .append("file as file does not exist. Requested by user ").append(currentUser.getUserID()) .append(" for file ").append(detailID).append(" for user ").append(learnerUserID); log.error(builder.toString()); - throw new ServletException("Invalid call to " + (remove ? "remove" : "restore") - + " file. See the server log for more details."); + throw new ServletException("Invalid call to "+(remove ? "remove" : "restore")+" file. See the server log for more details."); } else { if (!fileToProcess.getSubmitFileSession().getSessionID().equals(sessionID) @@ -520,19 +519,17 @@ .append(currentUser.getUserID()).append(" for file ").append(detailID).append(" for user ") .append(learnerUserID).append(" in session ").append(sessionID); log.error(builder.toString()); - throw new ServletException("Invalid call to " + (remove ? "remove" : "restore") - + " file. See the server log for more details."); + 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"); + 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"); + notifyRemoveRestore(fileToProcess, "event.file.delete.subject", "event.file.delete.body", "delete file"); } } @@ -545,40 +542,36 @@ return mapping.findForward("listMark"); } - /** - * Notify the user by email of the file change. Need to do it here rather than in the service so that any issues are - * caught and logged without stuffing up the transaction. + /** 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. */ - private void notifyRemoveRestore(SubmissionDetails detail, String i18nSubjectKey, String i18nBodyKey, - String errorSubject) { + 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 + // 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); + boolean eventExists = submitFilesService.getEventNotificationService().eventExists(SbmtConstants.TOOL_SIGNATURE, + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, contentID); if (eventExists) { submitFilesService.getEventNotificationService().triggerForSingleUser(SbmtConstants.TOOL_SIGNATURE, SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE, contentID, learnerID, submitFilesService.getLocalisedMessage(i18nSubjectKey, null), submitFilesService.getLocalisedMessage(i18nBodyKey, new Object[] { detail.getFilePath() })); } else { - log.error("Unable to notify user of " + errorSubject + ". contentID=" + contentID + " learner=" - + learnerID + " file " + detail.getFilePath() + " as " - + SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE + " event is missing"); + log.error("Unable to notify user of "+errorSubject+". contentID="+contentID+" learner="+learnerID+" file "+detail.getFilePath()+" as "+SbmtConstants.EVENT_NAME_NOTIFY_LEARNERS_ON_MARK_RELEASE+" event is missing"); } - } catch (Exception e) { - log.error("Unable to notify user of " + errorSubject + ". contentID=" + contentID + " learner=" + learnerID - + " file " + detail.getFilePath() + " due to exception " + e.getMessage(), e); - } + } catch ( Exception e) { + log.error("Unable to notify user of "+errorSubject+". contentID="+contentID+" learner="+learnerID+" file "+detail.getFilePath()+" due to exception "+e.getMessage(),e); + } } + // ********************************************************** // Private methods // ********************************************************** @@ -597,6 +590,20 @@ } /** + * Save file mark information into HttpRequest + * + * @param request + * @param sessionID + * @param userID + * @param detailID + * @param updateMode + */ + private void setMarkPage(HttpServletRequest request, Long sessionID, Long userID, Long detailID, + String updateMode) { + + } + + /** * Save Summary information into HttpRequest. * * @param request @@ -620,5 +627,5 @@ // request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID,sessionID); request.setAttribute("sessions", sessions); } - + } \ No newline at end of file Index: lams_tool_sbmt/web/learner/sbmtlearner.jsp =================================================================== diff -u -r07ace0e41d113321756cbe1d75ab04d8c9cb5841 -ra71bf2630935c6bc8b907ca22801208a2d3bd657 --- lams_tool_sbmt/web/learner/sbmtlearner.jsp (.../sbmtlearner.jsp) (revision 07ace0e41d113321756cbe1d75ab04d8c9cb5841) +++ lams_tool_sbmt/web/learner/sbmtlearner.jsp (.../sbmtlearner.jsp) (revision a71bf2630935c6bc8b907ca22801208a2d3bd657) @@ -96,6 +96,24 @@ div.style.display = ''; } } + + function deleteLearnerFile(detailId) { + var msg = ''; + var answer = confirm(msg); + if (answer) { + $.ajax({ + url: '', + data: 'method=deleteLearnerFile&detailId=' + detailId, + success: function () { + document.location.href = ""; + }, + error: function(error){ + alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); + alert("responseText: "+xhr.responseText); + } + }); + } + } @@ -182,11 +200,16 @@ + + + "> + + " class="btn btn-default btn-disable-on-submit pull-right"> - + @@ -204,7 +227,7 @@ - + @@ -214,7 +237,7 @@ - +