Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r193fb7d45f2b7b2194675895a118cf1d9530bda2 -r5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6 --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 193fb7d45f2b7b2194675895a118cf1d9530bda2) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6) @@ -517,6 +517,11 @@ sysadmin.maintain.session.delete =Delete config.display.portrait =Display learner's portrait in a progress bar config.kumalive.enable =Enable Kumalive - - +admin.delete.lessons =Delete all lessons +msg.delete.all.lesson.confirm.1 =You are about to PERMANENTLY delete ALL lessons from course "{0}". Are you ABSOLUTELY sure that you want to do this? There will be no turning back! +msg.delete.all.lesson.confirm.2 =ALL lessons will be deleted, including active ones with learners in them. NO lessons will be left in the course. Are you sure you want to continue? +msg.delete.all.lesson.error =Error while deleting course lessons lessons +label.delete.all.lesson.count =Number of remaining / total lessons: +label.delete.all.lesson.progress =Deleting... +sysadmin.lesson.delete.title =Delete all lessons from course #======= End labels: Exported 511 labels for en AU ===== Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrganisationAction.java =================================================================== diff -u -r85ef8aca5722a36582117db1e8b988e2c16b6369 -r5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrganisationAction.java (.../OrganisationAction.java) (revision 85ef8aca5722a36582117db1e8b988e2c16b6369) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/OrganisationAction.java (.../OrganisationAction.java) (revision 5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6) @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -36,7 +37,9 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.DynaActionForm; +import org.apache.tomcat.util.json.JSONException; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; import org.lamsfoundation.lams.usermanagement.OrganisationType; @@ -149,23 +152,71 @@ return null; } + public ActionForward deleteAllLessonsInit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + if (!AdminServiceProxy.getSecurityService(getServlet().getServletContext()).isSysadmin(getUserID(), + "display cleanup preview lessons", false)) { + response.sendError(HttpServletResponse.SC_FORBIDDEN, "User is not a sysadmin"); + return null; + } + + if (!(request.isUserInRole(Role.SYSADMIN))) { + request.setAttribute("errorName", "OrganisationAction"); + request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()) + .getMessage("error.need.sysadmin")); + return mapping.findForward("error"); + } + + Integer organisationId = WebUtil.readIntParam(request, "orgId"); + Organisation organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext()) + .findById(Organisation.class, organisationId); + int lessonCount = organisation.getLessons().size(); + request.setAttribute("lessonCount", lessonCount); + request.setAttribute("courseName", organisation.getName()); + + return mapping.findForward("deleteAllLessons"); + } + + @SuppressWarnings("unchecked") + public ActionForward deleteAllLessons(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, JSONException { + Integer userID = getUserID(); + Integer limit = WebUtil.readIntParam(request, "limit", true); + Integer organisationId = WebUtil.readIntParam(request, "orgId"); + Organisation organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext()) + .findById(Organisation.class, organisationId); + for (Lesson lesson : (Set) organisation.getLessons()) { + log.info("Deleting lesson: " + lesson.getLessonId()); + // role is checked in this method + AdminServiceProxy.getMonitoringService(getServlet().getServletContext()) + .removeLessonPermanently(lesson.getLessonId(), userID); + if (limit != null) { + limit--; + if (limit == 0) { + break; + } + } + } + + organisation = (Organisation) AdminServiceProxy.getService(getServlet().getServletContext()) + .findById(Organisation.class, organisationId); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(organisation.getLessons().size()); + return null; + } + private ActionForward error(ActionMapping mapping, HttpServletRequest request) { OrganisationAction.messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext()); request.setAttribute("errorName", "OrganisationAction"); request.setAttribute("errorMessage", OrganisationAction.messageService.getMessage("error.authorisation")); return mapping.findForward("error"); } - /* - * public ActionForward remove(ActionMapping mapping, ActionForm form,HttpServletRequest request, - * HttpServletResponse response){ - * Integer orgId = WebUtil.readIntParam(request,"orgId"); - * getService().deleteById(Organisation.class,orgId); - * Integer parentId = WebUtil.readIntParam(request,"parentId"); - * request.setAttribute("org",parentId); - * return mapping.findForward("orglist"); - * } - */ + private Integer getUserID() { + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + return user == null ? null : user.getUserID(); + } @SuppressWarnings("unchecked") private void initLocalesAndStatus() { Index: lams_admin/web/WEB-INF/struts-config.xml =================================================================== diff -u -ra4fd7ba340a2beac7436660039f13b9c8708f172 -r5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6 --- lams_admin/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision a4fd7ba340a2beac7436660039f13b9c8708f172) +++ lams_admin/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6) @@ -307,6 +307,11 @@ path="/orgmanage.do" redirect="false" /> + + + + + + Index: lams_admin/web/organisation/deleteAllLessons.jsp =================================================================== diff -u --- lams_admin/web/organisation/deleteAllLessons.jsp (revision 0) +++ lams_admin/web/organisation/deleteAllLessons.jsp (revision 5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6) @@ -0,0 +1,76 @@ +<%@ include file="/taglibs.jsp"%> + + + + +

+ + : +

+ + + + ${lessonCount} / ${lessonCount} + + +
+ +
\ No newline at end of file Index: lams_admin/web/organisation/list.jsp =================================================================== diff -u -r7dce137f52dd2664abf689e18789fab2a79b4407 -r5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6 --- lams_admin/web/organisation/list.jsp (.../list.jsp) (revision 7dce137f52dd2664abf689e18789fab2a79b4407) +++ lams_admin/web/organisation/list.jsp (.../list.jsp) (revision 5f626596bbeb5bbbbd800be3ddf6ff7f1bdaeaa6) @@ -154,7 +154,7 @@ <% if (request.isUserInRole(Role.SYSADMIN)) { %> " class="btn btn-default"> - " class="btn btn-default"> + " class="btn btn-default"> <% } %> @@ -228,18 +228,19 @@
- - - -
- -  " onclick=javascript:document.location='organisation.do?method=edit&orgId=' /> - - " onclick=javascript:document.location='usermanage.do?org=' /> - <% if (request.isUserInRole(Role.SYSADMIN)) { %> - " onclick="javascript:document.location='clone.do?groupId=';"> - <% } %> +
+ +
+ +  " onclick=javascript:document.location='organisation.do?method=edit&orgId=' /> + + " onclick=javascript:document.location='usermanage.do?org=' /> + <% if (request.isUserInRole(Role.SYSADMIN)) { %> + " onclick="javascript:document.location='clone.do?groupId=';"> + " class="btn btn-default"> + <% } %>
+