Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r7b9b1931a178ac9bac070531b53731383df0a187 -r7a038b413299c10aa5b3dd168e35811597f44173 --- lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7b9b1931a178ac9bac070531b53731383df0a187) +++ lams_admin/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -417,6 +417,28 @@ label.html.flashTheme =Flash Theme config.profile.edit.enable = Enable Profile Editing config.profile.partial.edit.enable = Enable Partial Profile Editing +# clone lessons +title.clone.lessons = Clone Lessons +label.ok = OK +title.clone.lessons.for = Clone Lessons for {0} +title.choose.group = Choose group to clone lessons from +label.choose = Choose +title.select.lessons = Select lessons +title.select.staff = Select staff +message.add.all.monitors = Add all monitors in this group to each lesson? +label.configure.staff = Configure staff +title.select.learners = Select learners +message.add.all.learners = Add all learners in this group to each lesson? +label.configure.learners = Configure Learners +label.clone = Clone +message.cloned.lessons = Cloned {0} lessons. +message.no.lessons = There are no lessons to clone. +message.check.to.clone.lesson = Check the box for each lesson to clone it. +message.no.lesson.description = No lesson description +message.no.learners = This group has no learners! Please add some via the Add/Remove users screen. +message.check.to.add.learner = Check the box of each learner to add to each of the new lessons. +message.no.monitors = This group has no monitors! Please add some via the Add/Remove users screen. +message.check.to.add.monitor = Check the box of each monitor to add as staff to each of the new lessons. +label.return.to.group = Return to group - #======= End labels: Exported 409 labels for en AU ===== Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rdd62cae1f15490353a067f3f42752bb177868d0b -r7a038b413299c10aa5b3dd168e35811597f44173 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision dd62cae1f15490353a067f3f42752bb177868d0b) +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -415,6 +415,28 @@ label.html.htmlTheme =HTML Theme label.html.flashTheme =Flash Theme msg.ldap.synchronise.wait =Please wait while synchronisation completes... +# clone lessons +title.clone.lessons = Clone Lessons +label.ok = OK +title.clone.lessons.for = Clone Lessons for {0} +title.choose.group = Choose group to clone lessons from +label.choose = Choose +title.select.lessons = Select lessons +title.select.staff = Select staff +message.add.all.monitors = Add all monitors in this group to each lesson? +label.configure.staff = Configure staff +title.select.learners = Select learners +message.add.all.learners = Add all learners in this group to each lesson? +label.configure.learners = Configure Learners +label.clone = Clone +message.cloned.lessons = Cloned {0} lessons. +message.no.lessons = There are no lessons to clone. +message.check.to.clone.lesson = Check the box for each lesson to clone it. +message.no.lesson.description = No lesson description +message.no.learners = This group has no learners! Please add some via the Add/Remove users screen. +message.check.to.add.learner = Check the box of each learner to add to each of the new lessons. +message.no.monitors = This group has no monitors! Please add some via the Add/Remove users screen. +message.check.to.add.monitor = Check the box of each monitor to add as staff to each of the new lessons. +label.return.to.group = Return to group - #======= End labels: Exported 409 labels for en AU ===== Fisheye: Tag 7a038b413299c10aa5b3dd168e35811597f44173 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneGroupAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java =================================================================== diff -u --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (revision 0) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -0,0 +1,330 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.admin.web.action; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.Action; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.service.ILessonService; +import org.lamsfoundation.lams.monitoring.service.IMonitoringService; +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.OrganisationState; +import org.lamsfoundation.lams.usermanagement.OrganisationType; +import org.lamsfoundation.lams.usermanagement.Role; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author jliew + * + * @struts:action path="/clone" scope="request" validate="false" + * + * @struts:action-forward name="start" path=".clone-start" + * @struts:action-forward name="availableLessonsPart" path="/organisation/parts/availableLessons.jsp" + * @struts:action-forward name="selectStaffPart" path="/organisation/parts/selectStaff.jsp" + * @struts:action-forward name="selectLearnersPart" path="/organisation/parts/selectLearners.jsp" + * @struts:action-forward name="result" path=".clone-result" + */ +public class CloneLessonsAction extends Action { + + private static final Logger log = Logger.getLogger(CloneLessonsAction.class); + private static IUserManagementService userManagementService; + private static ILessonService lessonService; + private static IMonitoringService monitoringService; + + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws UserAccessDeniedException { + + if (!(request.isUserInRole(Role.SYSADMIN))) { + throw new UserAccessDeniedException(); + } + + List errors = new ArrayList(); + try { + userManagementService = AdminServiceProxy.getService(getServlet().getServletContext()); + + String method = WebUtil.readStrParam(request, "method", true); + if (StringUtils.equals(method, "getGroups")) { + return getGroups(mapping, form, request, response); + } else if (StringUtils.equals(method, "getSubgroups")) { + return getSubgroups(mapping, form, request, response); + } else if (StringUtils.equals(method, "availableLessons")) { + return availableLessons(mapping, form, request, response); + } else if (StringUtils.equals(method, "selectStaff")) { + return selectStaff(mapping, form, request, response); + } else if (StringUtils.equals(method, "selectLearners")) { + return selectLearners(mapping, form, request, response); + } else if (StringUtils.equals(method, "clone")) { + return clone(mapping, form, request, response); + } + } catch (Exception e) { + e.printStackTrace(); + errors.add(e.getMessage()); + } + request.setAttribute("errors", errors); + + // default action + Integer groupId = WebUtil.readIntParam(request, "groupId", false); + request.setAttribute("org", userManagementService.findById(Organisation.class, groupId)); + + return mapping.findForward("start"); + } + + // ajax + public ActionForward getGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + response.addHeader("Cache-Control", "no-cache"); + + List groups = userManagementService.getOrganisationsByTypeAndStatus(OrganisationType.COURSE_TYPE, + OrganisationState.ACTIVE); + for (Object o : groups) { + Organisation org = (Organisation) o; + response.getWriter().println( + ""); + } + + return null; + } + + // ajax + public ActionForward getSubgroups(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + Integer groupId = WebUtil.readIntParam(request, "groupId", true); + + response.addHeader("Cache-Control", "no-cache"); + + if (groupId != null) { + HashMap properties = new HashMap(); + properties.put("parentOrganisation.organisationId", groupId); + properties.put("organisationType.organisationTypeId", OrganisationType.CLASS_TYPE); + properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE); + + response.getWriter().println(""); + List groups = userManagementService.findByProperties(Organisation.class, properties); + for (Object o : groups) { + Organisation org = (Organisation) o; + response.getWriter().println( + ""); + } + } + + return null; + } + + // ajax + public ActionForward availableLessons(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + Integer sourceGroupId = WebUtil.readIntParam(request, "sourceGroupId", true); + + if (sourceGroupId != null) { + lessonService = AdminServiceProxy.getLessonService(getServlet().getServletContext()); + + List lessons = lessonService.getLessonsByGroup(sourceGroupId); + request.setAttribute("lessons", lessons); + } + + response.addHeader("Cache-Control", "no-cache"); + return mapping.findForward("availableLessonsPart"); + } + + // ajax + public ActionForward selectStaff(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + Integer groupId = WebUtil.readIntParam(request, "groupId", false); + + Vector monitors = userManagementService.getUsersFromOrganisationByRole(groupId, Role.MONITOR, false, true); + request.setAttribute("monitors", monitors); + + response.addHeader("Cache-Control", "no-cache"); + return mapping.findForward("selectStaffPart"); + } + + // ajax + public ActionForward selectLearners(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + Integer groupId = WebUtil.readIntParam(request, "groupId", false); + + Vector learners = userManagementService.getUsersFromOrganisationByRole(groupId, Role.LEARNER, false, true); + request.setAttribute("learners", learners); + + response.addHeader("Cache-Control", "no-cache"); + return mapping.findForward("selectLearnersPart"); + } + + public ActionForward clone(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws UserAccessDeniedException { + + Integer groupId = WebUtil.readIntParam(request, "groupId", false); + String lessons = request.getParameter("lessons"); + String staff = request.getParameter("staff"); + String learners = request.getParameter("learners"); + Boolean addAllStaff = WebUtil.readBooleanParam(request, "addAllStaff", false); + Boolean addAllLearners = WebUtil.readBooleanParam(request, "addAllLearners", false); + + String[] lessonIds = new String[0], staffIds = new String[0], learnerIds = new String[0]; + if (StringUtils.isNotEmpty(lessons)) { + lessonIds = lessons.split(","); + } + if (StringUtils.isNotEmpty(staff)) { + staffIds = staff.split(","); + } + if (StringUtils.isNotEmpty(learners)) { + learnerIds = learners.split(","); + } + + monitoringService = AdminServiceProxy.getMonitoringService(getServlet().getServletContext()); + String error = null; + List errors = new ArrayList(); + int result = 0; + + Organisation group = (Organisation) userManagementService.findById(Organisation.class, groupId); + if (group != null) { + for (String l : lessonIds) { + Lesson lesson = lessonService.getLesson(Long.valueOf(l)); + if (lesson != null) { + HttpSession ss = SessionManager.getSession(); + if (ss != null) { + UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (userDto != null) { + if ((!addAllStaff && staffIds.length > 0) || addAllStaff) { + // create staff LessonClass + String staffGroupName = group.getName() + " Staff"; + List staffUsers = createStaffGroup(groupId, addAllStaff, staffIds); + + if ((!addAllLearners && learnerIds.length > 0) || addAllLearners) { + // create learner LessonClass for lesson + String learnerGroupName = group.getName() + " Learners"; + List learnerUsers = createLearnerGroup(groupId, addAllLearners, learnerIds); + + // init Lesson with user as creator + Lesson newLesson = monitoringService.initializeLesson(lesson.getLessonName(), + lesson.getLessonDescription(), lesson.getLearnerExportAvailable(), lesson + .getLearningDesign().getLearningDesignId(), groupId, userDto + .getUserID(), null, lesson.getLearnerPresenceAvailable(), lesson + .getLearnerImAvailable(), lesson.getLiveEditEnabled()); + + // save LessonClasses + newLesson = monitoringService.createLessonClassForLesson(newLesson.getLessonId(), + group, learnerGroupName, learnerUsers, staffGroupName, staffUsers, userDto + .getUserID()); + + // start Lessons + // TODO user-specified creator; must be someone in staff group + monitoringService + .startLesson(newLesson.getLessonId(), staffUsers.get(0).getUserId()); + + result++; + } else { + error = "No learners specified, can't create any Lessons."; + } + } else { + error = "No staff specified, can't create any Lessons."; + } + } else { + error = "No UserDTO in session, can't create any Lessons."; + } + } + } else { + error = "Couldn't find Lesson based on id=" + l; + } + } + } else { + error = "Couldn't find Organisation based on id=" + groupId; + } + + if (error != null) { + log.error(error); + errors.add(error); + } + request.setAttribute("errors", errors); + request.setAttribute("org", group); + request.setAttribute("result", result); + + return mapping.findForward("result"); + } + + private List createLearnerGroup(Integer groupId, Boolean addAllLearners, String[] learnerIds) { + List learnerUsers = new ArrayList(); + if (addAllLearners) { + Vector learnerVector = userManagementService.getUsersFromOrganisationByRole(groupId, Role.LEARNER, false, + true); + learnerUsers.addAll(learnerVector); + } else { + User user = null; + for (String l : learnerIds) { + user = (User) userManagementService.findById(User.class, Integer.parseInt(l)); + if (user != null) { + learnerUsers.add(user); + } else { + log.error("Couldn't find User based on id=" + l); + } + } + } + return learnerUsers; + } + + private List createStaffGroup(Integer groupId, Boolean addAllStaff, String[] staffIds) { + List staffUsers = new ArrayList(); + if (addAllStaff) { + Vector staffVector = userManagementService.getUsersFromOrganisationByRole(groupId, Role.MONITOR, false, + true); + staffUsers.addAll(staffVector); + } else { + User user = null; + for (String s : staffIds) { + user = (User) userManagementService.findById(User.class, Integer.parseInt(s)); + if (user != null) { + staffUsers.add(user); + } else { + log.error("Couldn't find User based on id=" + s); + } + } + } + return staffUsers; + } +} Index: lams_admin/web/WEB-INF/tiles/tiles-defs.xml =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -r7a038b413299c10aa5b3dd168e35811597f44173 --- lams_admin/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_admin/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -2,7 +2,7 @@ - + @@ -11,7 +11,7 @@ - + Index: lams_admin/web/organisation/cloneResult.jsp =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -r7a038b413299c10aa5b3dd168e35811597f44173 --- lams_admin/web/organisation/cloneResult.jsp (.../cloneResult.jsp) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_admin/web/organisation/cloneResult.jsp (.../cloneResult.jsp) (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -2,7 +2,7 @@ -

Clone Lessons for

+

@@ -12,3 +12,12 @@

+

+ +

+ +

+ " + onclick="document.location='orgmanage.do?org=';" + > +

\ No newline at end of file Index: lams_admin/web/organisation/cloneStart.jsp =================================================================== diff -u -r109a71a895d44a4bb8294b9b4c127e741cb2f772 -r7a038b413299c10aa5b3dd168e35811597f44173 --- lams_admin/web/organisation/cloneStart.jsp (.../cloneStart.jsp) (revision 109a71a895d44a4bb8294b9b4c127e741cb2f772) +++ lams_admin/web/organisation/cloneStart.jsp (.../cloneStart.jsp) (revision 7a038b413299c10aa5b3dd168e35811597f44173) @@ -16,6 +16,9 @@ -

Clone Lessons for

+

@@ -109,21 +128,21 @@

-

Choose group to clone lessons from

+

- Group: + :

- Subgroup: + :

- + " onclick="javascript:loadGroupAttributes(chosenGroup());">

@@ -135,40 +154,40 @@ -