Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.109 -r1.110
--- lams_central/conf/language/lams/ApplicationResources.properties 19 Dec 2012 13:58:07 -0000 1.109
+++ lams_central/conf/language/lams/ApplicationResources.properties 7 Jan 2013 13:03:52 -0000 1.110
@@ -2,7 +2,7 @@
#language code: en
#locale code: AU
- # CVS ID: $Id$ Exported from the LAMS Community by Ernie Ghiglione on Wed Dec 19 07:57:25 CST 2012
+ # CVS ID: $Id$ Exported from the LAMS Community by Ernie Ghiglione on Wed Dec 05 10:31:17 CST 2012
#=================== labels for LAMS Central =================#
@@ -354,5 +354,36 @@
index.remove.lesson.confirm1 =You are about to remove this lesson. Are you sure?
index.remove.lesson.confirm2 =Once you remove this lesson you CANNOT bring it back. Are you positive that you want to remove this lesson?
+button.add.now =Add now
+label.tab.lesson =Lesson
+label.tab.class =Class
+label.tab.advanced =Advanced
+label.tab.lesson.title =Select the sequence to add a lesson, and click on Add now
+label.tab.class.title =Please use drag n' drop to select or unselect monitors and learners
+label.tab.lesson.name =Lesson name:
+label.tab.lesson.size.full =(show full size)
+label.tab.lesson.size.fit =(fit to window)
+error.tab.lesson.sequence =A valid sequence must be selected
+label.tab.class.monitors.unselected =Monitors unselected
+label.tab.class.monitors.selected =Monitors selected
+label.tab.class.learners.unselected =Learners unselected
+label.tab.class.learners.selected =Learners selected
+error.tab.class.learners =There must be at least 1 learner selected
+error.tab.class.monitors =There must be at least 1 monitor selected
+label.tab.advanced.details =Details
+label.tab.advanced.intro.enable =Enable lesson intro
+label.tab.advanced.intro.description =Description:
+label.tab.advanced.intro.image =Display design image
+label.tab.advanced.section.advanced =Advanced Options
+label.tab.advanced.field.monitor =Start in Monitor
+label.tab.advanced.field.liveedit =Enable Live Edit
+label.tab.advanced.field.notification =Enable lesson notification
+label.tab.advanced.field.export =Enable export portfolio for leaner
+label.tab.advanced.field.presence =Allow learners to see who is online
+label.tab.advanced.field.im =Enable Instant Messaging
+label.tab.advanced.field.split =Split learners into separate copies of this lesson
+label.tab.advanced.field.split.number =No. learners per lesson
+label.tab.advanced.field.scheduling =Enable scheduling
+label.tab.advanced.split.desc =[0] instances of this lesson will be created
and approximately [1] will be allocated to each lesson
-#======= End labels: Exported 347 labels for en AU =====
+#======= End labels: Exported 345 labels for en AU =====
Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java,v
diff -u -r1.40 -r1.41
--- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 30 Oct 2012 17:46:54 -0000 1.40
+++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 7 Jan 2013 13:03:52 -0000 1.41
@@ -23,22 +23,31 @@
/* $$Id$$ */
package org.lamsfoundation.lams.web;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Vector;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.batik.transcoder.TranscoderException;
+import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
+import org.apache.tomcat.util.json.JSONException;
+import org.apache.tomcat.util.json.JSONObject;
+import org.jdom.JDOMException;
+import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.learningdesign.GroupUser;
import org.lamsfoundation.lams.learningdesign.dao.IGroupUserDAO;
import org.lamsfoundation.lams.learningdesign.service.ILearningDesignService;
@@ -47,20 +56,29 @@
import org.lamsfoundation.lams.usermanagement.Organisation;
import org.lamsfoundation.lams.usermanagement.Role;
import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.WorkspaceFolder;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.usermanagement.dto.UserFlashDTO;
+import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.CentralConstants;
import org.lamsfoundation.lams.util.Configuration;
import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.util.svg.SVGGenerator;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.lamsfoundation.lams.workspace.dto.FolderContentDTO;
+import org.lamsfoundation.lams.workspace.service.IWorkspaceManagementService;
+import org.lamsfoundation.lams.workspace.service.WorkspaceManagementService;
+import org.lamsfoundation.lams.workspace.web.WorkspaceAction;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
- * this is an action where all lams client environments launch. initial
- * configuration of the individual environment setting is done here.
+ * this is an action where all lams client environments launch. initial configuration of the individual environment
+ * setting is done here.
*
* @struts:action path="/home" validate="false" parameter="method"
* @struts:action-forward name="sysadmin" path="/sysadmin.jsp"
@@ -69,6 +87,7 @@
* @struts:action-forward name="author" path="/author.jsp"
* @struts:action-forward name="monitorLesson" path="/monitorLesson.jsp"
* @struts:action-forward name="addLesson" path="/addLesson.jsp"
+ * @struts:action-forward name="newLesson" path="/newLesson.jsp"
* @struts:action-forward name="error" path=".error"
* @struts:action-forward name="message" path=".message"
* @struts:action-forward name="passwordChange" path=".passwordChange"
@@ -83,6 +102,7 @@
private static ILessonService lessonService;
private static ILearningDesignService learningDesignService;
private static IGroupUserDAO groupUserDAO;
+ private static IWorkspaceManagementService workspaceManagementService;
/**
* request for sysadmin environment
@@ -91,23 +111,23 @@
HttpServletResponse res) throws IOException, ServletException {
try {
- log.debug("request sysadmin");
+ HomeAction.log.debug("request sysadmin");
int orgId = new Integer(req.getParameter("orgId")).intValue();
UserDTO user = getUser();
if (user == null) {
- log.error("admin: User missing from session. ");
+ HomeAction.log.error("admin: User missing from session. ");
return mapping.findForward("error");
} else if (getService().isUserInRole(user.getUserID(), orgId, Role.SYSADMIN)) {
- log.debug("user is sysadmin");
+ HomeAction.log.debug("user is sysadmin");
return mapping.findForward("sysadmin");
} else {
- log.error("User " + user.getLogin()
+ HomeAction.log.error("User " + user.getLogin()
+ " tried to get sysadmin screen but isn't sysadmin in organisation: " + orgId);
return displayMessage(mapping, req, "error.authorisation");
}
} catch (Exception e) {
- log.error("Failed to load sysadmin", e);
+ HomeAction.log.error("Failed to load sysadmin", e);
return mapping.findForward("error");
}
}
@@ -119,67 +139,68 @@
throws IOException, ServletException {
try {
- log.debug("request learner");
+ HomeAction.log.debug("request learner");
Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID);
String mode = WebUtil.readStrParam(req, AttributeNames.PARAM_MODE, true);
UserDTO user = getUser();
if (user == null) {
- log.error("learner: User missing from session. ");
+ HomeAction.log.error("learner: User missing from session. ");
return mapping.findForward("error");
} else {
Lesson lesson = lessonId != null ? getLessonService().getLesson(lessonId) : null;
- if (lesson == null || !lesson.isLessonStarted()) {
+ if ((lesson == null) || !lesson.isLessonStarted()) {
return displayMessage(mapping, req, "message.lesson.not.started.cannot.participate");
}
if (!getLessonService().checkLessonReleaseConditions(lessonId, user.getUserID())) {
return displayMessage(mapping, req, "message.preceding.lessons.not.finished.cannot.participate");
}
-
- if (lesson.getLessonClass() == null
+ if ((lesson.getLessonClass() == null)
|| !lesson.getLessonClass().getLearners().contains(getRealUser(user))) {
- log.error("learner: User " + user.getLogin()
+ HomeAction.log.error("learner: User " + user.getLogin()
+ " is not a learner in the requested lesson. Cannot access the lesson.");
return displayMessage(mapping, req, "error.authorisation");
}
-
- //check if the lesson is scheduled to be finished to individual users
+
+ // check if the lesson is scheduled to be finished to individual users
if (lesson.isScheduledToCloseForIndividuals()) {
GroupUser groupUser = getGroupUserDAO().getGroupUser(lesson, user.getUserID());
- if ((groupUser != null) && (groupUser.getScheduledLessonEndDate() != null) && groupUser.getScheduledLessonEndDate().before(new Date())) {
- log.error("learner: User " + user.getLogin()
+ if ((groupUser != null) && (groupUser.getScheduledLessonEndDate() != null)
+ && groupUser.getScheduledLessonEndDate().before(new Date())) {
+ HomeAction.log.error("learner: User " + user.getLogin()
+ " cannot access the lesson due to lesson end date has passed.");
return displayMessage(mapping, req, "error.finish.date.passed");
}
}
- if (mode != null)
+ if (mode != null) {
req.setAttribute(AttributeNames.PARAM_MODE, mode);
+ }
req.setAttribute(AttributeNames.PARAM_EXPORT_PORTFOLIO_ENABLED,
lesson.getLearnerExportAvailable() != null ? lesson.getLearnerExportAvailable() : Boolean.TRUE);
req.setAttribute(AttributeNames.PARAM_PRESENCE_ENABLED, lesson.getLearnerPresenceAvailable());
req.setAttribute(AttributeNames.PARAM_PRESENCE_IM_ENABLED, lesson.getLearnerImAvailable());
req.setAttribute(AttributeNames.PARAM_TITLE, lesson.getLessonName());
-
+
/* Date Format for Chat room append */
DateFormat sfm = new SimpleDateFormat("yyyyMMdd_HHmmss");
req.setAttribute(AttributeNames.PARAM_CREATE_DATE_TIME, sfm.format(lesson.getCreateDateTime()));
-
+
String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL);
req.setAttribute("serverUrl", serverUrl);
req.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
-
- //show lesson intro page if required
+
+ // show lesson intro page if required
if (lesson.isEnableLessonIntro()) {
req.setAttribute("lesson", lesson);
req.setAttribute("displayDesignImage", lesson.isDisplayDesignImage());
req.setAttribute("isMonitor", lesson.getLessonClass().isStaffMember(getRealUser(user)));
-
- //check if we need to create learning design SVG
+
+ // check if we need to create learning design SVG
if (lesson.isDisplayDesignImage()) {
Long learningDesignId = lesson.getLearningDesign().getLearningDesignId();
req.setAttribute(AttributeNames.PARAM_LEARNINGDESIGN_ID, learningDesignId);
@@ -190,17 +211,17 @@
SVGGenerator.OUTPUT_FORMAT_SVG);
getLearningDesignService().createLearningDesignSVG(learningDesignId,
SVGGenerator.OUTPUT_FORMAT_PNG);
- }
+ }
}
return mapping.findForward("lessonIntro");
} else {
return mapping.findForward("learner");
}
-
+
}
} catch (Exception e) {
- log.error("Failed to load learner", e);
+ HomeAction.log.error("Failed to load learner", e);
return mapping.findForward("error");
}
}
@@ -212,10 +233,10 @@
throws IOException, ServletException {
try {
- log.debug("request author");
+ HomeAction.log.debug("request author");
UserDTO user = getUser();
if (user == null) {
- log.error("admin: User missing from session. ");
+ HomeAction.log.error("admin: User missing from session. ");
return mapping.findForward("error");
} else {
Long learningDesignID = null;
@@ -229,20 +250,25 @@
String customCSV = req.getParameter(AttributeNames.PARAM_CUSTOM_CSV);
String extLmsId = req.getParameter(AttributeNames.PARAM_EXT_LMS_ID);
- if (req.getParameter("learningDesignID") != null)
+ if (req.getParameter("learningDesignID") != null) {
learningDesignID = WebUtil.readLongParam(req, "learningDesignID");
+ }
- if (req.getParameter("layout") != null)
+ if (req.getParameter("layout") != null) {
layout = WebUtil.readStrParam(req, "layout");
+ }
- if (layout != null)
+ if (layout != null) {
req.setAttribute("layout", layout);
+ }
- if (req.getParameter("learningDesignID") != null)
+ if (req.getParameter("learningDesignID") != null) {
learningDesignID = WebUtil.readLongParam(req, "learningDesignID");
+ }
- if (learningDesignID != null)
+ if (learningDesignID != null) {
req.setAttribute("learningDesignID", learningDesignID);
+ }
req.setAttribute("requestSrc", requestSrc);
req.setAttribute("notifyCloseURL", notifyCloseURL);
@@ -254,7 +280,7 @@
}
} catch (Exception e) {
- log.error("Failed to load author", e);
+ HomeAction.log.error("Failed to load author", e);
return mapping.findForward("error");
}
}
@@ -266,34 +292,36 @@
HttpServletResponse res) throws IOException, ServletException {
try {
- log.debug("request monitorLesson");
+ HomeAction.log.debug("request monitorLesson");
Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID);
UserDTO user = getUser();
if (user == null) {
- log.error("admin: User missing from session. ");
+ HomeAction.log.error("admin: User missing from session. ");
return mapping.findForward("error");
} else {
Lesson lesson = lessonId != null ? getLessonService().getLesson(lessonId) : null;
if (lesson == null) {
- log.error("monitorLesson: Lesson " + lessonId + " does not exist. Unable to monitor lesson");
+ HomeAction.log.error("monitorLesson: Lesson " + lessonId
+ + " does not exist. Unable to monitor lesson");
return mapping.findForward("error");
}
- if (lesson.getLessonClass() == null || !lesson.getLessonClass().isStaffMember(getRealUser(user))
- && !req.isUserInRole(Role.GROUP_MANAGER)) {
- log.error("learner: User " + user.getLogin()
+ if ((lesson.getLessonClass() == null)
+ || (!lesson.getLessonClass().isStaffMember(getRealUser(user)) && !req
+ .isUserInRole(Role.GROUP_MANAGER))) {
+ HomeAction.log.error("learner: User " + user.getLogin()
+ " is not a learner in the requested lesson. Cannot access the lesson.");
return displayMessage(mapping, req, "error.authorisation");
}
- log.debug("user is staff");
+ HomeAction.log.debug("user is staff");
String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL);
req.setAttribute("serverUrl", serverUrl);
req.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
return mapping.findForward("monitorLesson");
}
} catch (Exception e) {
- log.error("Failed to load monitor lesson", e);
+ HomeAction.log.error("Failed to load monitor lesson", e);
return mapping.findForward("error");
}
}
@@ -305,60 +333,187 @@
HttpServletResponse res) throws IOException, ServletException {
try {
- log.debug("request addLesson");
-
+ HomeAction.log.debug("request addLesson");
+
Integer courseId = WebUtil.readIntParam(req, AttributeNames.PARAM_COURSE_ID, false);
Integer classId = WebUtil.readIntParam(req, AttributeNames.PARAM_CLASS_ID, true);
-
+
UserDTO user = getUser();
if (user == null) {
- log.error("admin: User missing from session. ");
+ HomeAction.log.error("admin: User missing from session. ");
return mapping.findForward("error");
} else {
Integer orgId = classId != null ? classId : courseId;
if (getService().isUserInRole(user.getUserID(), orgId, Role.MONITOR)
|| getService().isUserInRole(user.getUserID(), orgId, Role.GROUP_MANAGER)) {
- log.debug("user is staff");
+ HomeAction.log.debug("user is staff");
String orgName = ((Organisation) getService().findById(Organisation.class, orgId)).getName();
-
+
req.setAttribute(AttributeNames.PARAM_ORGANISATION_ID, orgId);
req.setAttribute(AttributeNames.PARAM_ORGANISATION_NAME, orgName);
-
+
return mapping.findForward("addLesson");
} else {
- log.error("User " + user.getLogin()
+ HomeAction.log.error("User " + user.getLogin()
+ " tried to get staff screen but isn't staff in organisation: " + orgId);
return displayMessage(mapping, req, "error.authorisation");
}
}
} catch (Exception e) {
- log.error("Failed to load add lesson", e);
+ HomeAction.log.error("Failed to load add lesson", e);
return mapping.findForward("error");
}
}
+ public ActionForward newLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req,
+ HttpServletResponse res) throws IOException, UserAccessDeniedException, JSONException,
+ RepositoryCheckedException {
+ UserDTO userDTO = getUser();
+
+ // get all user accessible folders and LD descriptions as JSON
+ JSONObject learningDesigns = getDeepFolderContents(userDTO.getUserID(), null);
+ req.setAttribute("folderContents", learningDesigns.toString());
+
+ Integer organisationID = new Integer(WebUtil.readIntParam(req, "organisationID"));
+ JSONObject users = new JSONObject();
+
+ // get learners available for newly created lesson
+ Vector learners = getWorkspaceManagementService().getUsersFromOrganisationByRole(organisationID,
+ "LEARNER");
+ for (UserFlashDTO user : learners) {
+ JSONObject userJSON = new JSONObject();
+ userJSON.put("userID", user.getUserID());
+ userJSON.put("firstName", user.getFirstName());
+ userJSON.put("lastName", user.getLastName());
+ userJSON.put("login", user.getLogin());
+
+ users.append("selectedLearners", userJSON);
+ }
+
+ Vector monitors = getWorkspaceManagementService().getUsersFromOrganisationByRole(organisationID,
+ "MONITOR");
+ for (UserFlashDTO user : monitors) {
+ JSONObject userJSON = new JSONObject();
+ userJSON.put("userID", user.getUserID());
+ userJSON.put("firstName", user.getFirstName());
+ userJSON.put("lastName", user.getLastName());
+ userJSON.put("login", user.getLogin());
+
+ if (userDTO.getUserID().equals(user.getUserID())) {
+ // creator is always selected
+ users.append("selectedMonitors", userJSON);
+ } else {
+ users.append("unselectedMonitors", userJSON);
+ }
+ }
+
+ req.setAttribute("users", users.toString());
+
+ return mapping.findForward("newLesson");
+ }
+
+ public ActionForward createLearningDesignThumbnail(ActionMapping mapping, ActionForm form, HttpServletRequest req,
+ HttpServletResponse res) throws JDOMException, IOException, TranscoderException {
+ Long learningDesignId = WebUtil.readLongParam(req, CentralConstants.PARAM_LEARNING_DESIGN_ID);
+ String imagePath = getLearningDesignService().createLearningDesignSVG(learningDesignId,
+ SVGGenerator.OUTPUT_FORMAT_PNG);
+
+ res.setContentType("image/png");
+ OutputStream output = res.getOutputStream();
+ FileInputStream input = new FileInputStream(imagePath);
+ IOUtils.copy(input, output);
+ IOUtils.closeQuietly(input);
+ IOUtils.closeQuietly(output);
+
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ private JSONObject getDeepFolderContents(Integer userID, Integer folderID) throws JSONException, IOException,
+ UserAccessDeniedException, RepositoryCheckedException {
+ JSONObject result = new JSONObject();
+ Vector folderContents = null;
+
+ // get use accessible folders in the start
+ if (folderID == null) {
+ folderContents = new Vector(3);
+ MessageService msgService = getWorkspaceManagementService().getMessageService();
+
+ FolderContentDTO userFolder = getWorkspaceManagementService().getUserWorkspaceFolder(userID);
+ if (userFolder != null) {
+ folderContents.add(userFolder);
+ }
+
+ FolderContentDTO myGroupsFolder = new FolderContentDTO(msgService.getMessage("organisations"),
+ msgService.getMessage("folder"), null, null, FolderContentDTO.FOLDER,
+ WorkspaceAction.ORG_FOLDER_ID.longValue(), WorkspaceFolder.READ_ACCESS, null);
+
+ folderContents.add(myGroupsFolder);
+
+ FolderContentDTO publicFolder = getWorkspaceManagementService().getPublicWorkspaceFolder(userID);
+ if (publicFolder != null) {
+ folderContents.add(publicFolder);
+ }
+ // special behaviour for organisation folders
+ } else if (folderID.equals(WorkspaceAction.ORG_FOLDER_ID)) {
+ folderContents = getWorkspaceManagementService().getAccessibleOrganisationWorkspaceFolders(userID);
+
+ if (folderContents.size() == 1) {
+ FolderContentDTO folder = folderContents.firstElement();
+ if (folder.getResourceID().equals(WorkspaceAction.ROOT_ORG_FOLDER_ID)) {
+ return getDeepFolderContents(userID, WorkspaceAction.ROOT_ORG_FOLDER_ID);
+ }
+ }
+ } else {
+ WorkspaceFolder folder = getWorkspaceManagementService().getWorkspaceFolder(folderID);
+ folderContents = getWorkspaceManagementService().getFolderContents(userID, folder,
+ WorkspaceManagementService.AUTHORING);
+ }
+
+ // recursively check folders, building a tree
+ for (FolderContentDTO folderContent : folderContents) {
+ String contentType = folderContent.getResourceType();
+ if (FolderContentDTO.FOLDER.equals(contentType)) {
+ JSONObject subfolder = getDeepFolderContents(userID, folderContent.getResourceID().intValue());
+ subfolder.put("name", folderContent.getName());
+ result.append("folders", subfolder);
+ } else if (FolderContentDTO.DESIGN.equals(contentType)) {
+ JSONObject learningDesign = new JSONObject();
+ learningDesign.put("learningDesignId", folderContent.getResourceID());
+ learningDesign.put("name", folderContent.getName());
+ result.append("learningDesigns", learningDesign);
+ } else {
+ if (HomeAction.log.isDebugEnabled()) {
+ HomeAction.log.debug("Unsupported folder content found, named \"" + folderContent.getName() + "\"");
+ }
+ }
+ }
+
+ return result;
+ }
+
public ActionForward logout(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
UserDTO userDTO = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
- if (userDTO.getLoggedIntoLamsCommunity() != null && userDTO.getLoggedIntoLamsCommunity()) {
- log.debug("Need to log out user from lamscoomunity");
+ if ((userDTO.getLoggedIntoLamsCommunity() != null) && userDTO.getLoggedIntoLamsCommunity()) {
+ HomeAction.log.debug("Need to log out user from lamscoomunity");
req.getSession().invalidate();
- //clear system shared session.
+ // clear system shared session.
SessionManager.getSession().invalidate();
-
+
// redirect to lamscommunity logout servlet to log out.
String url = "http://lamscommunity.org/register/logout?return_url=";
url += URLEncoder.encode(Configuration.get(ConfigurationKeys.SERVER_URL), "UTF8");
res.sendRedirect(url);
return null;
-
+
} else {
req.getSession().invalidate();
- //clear system shared session.
+ // clear system shared session.
SessionManager.getSession().invalidate();
return mapping.findForward("index");
@@ -369,43 +524,54 @@
req.setAttribute("messageKey", messageKey);
return mapping.findForward("message");
}
-
+
private IUserManagementService getService() {
- if (service == null) {
+ if (HomeAction.service == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- service = (IUserManagementService) ctx.getBean("userManagementService");
+ HomeAction.service = (IUserManagementService) ctx.getBean("userManagementService");
}
- return service;
+ return HomeAction.service;
}
private ILessonService getLessonService() {
- if (lessonService == null) {
+ if (HomeAction.lessonService == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- lessonService = (ILessonService) ctx.getBean("lessonService");
+ HomeAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
- return lessonService;
+ return HomeAction.lessonService;
}
-
+
private ILearningDesignService getLearningDesignService() {
- if (learningDesignService == null) {
+ if (HomeAction.learningDesignService == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
+ HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
- return learningDesignService;
+ return HomeAction.learningDesignService;
}
-
+
private IGroupUserDAO getGroupUserDAO() {
- if (groupUserDAO == null) {
+ if (HomeAction.groupUserDAO == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO");
+ HomeAction.groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO");
}
- return groupUserDAO;
+ return HomeAction.groupUserDAO;
}
+ private IWorkspaceManagementService getWorkspaceManagementService() {
+ if (HomeAction.workspaceManagementService == null) {
+ WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
+ .getServletContext());
+ HomeAction.workspaceManagementService = (IWorkspaceManagementService) webContext
+ .getBean("workspaceManagementService");
+ }
+
+ return HomeAction.workspaceManagementService;
+ }
+
private UserDTO getUser() {
HttpSession ss = SessionManager.getSession();
return (UserDTO) ss.getAttribute(AttributeNames.USER);
Index: lams_central/web/groupHeader.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/groupHeader.jsp,v
diff -u -r1.6 -r1.7
--- lams_central/web/groupHeader.jsp 11 Mar 2009 04:00:37 -0000 1.6
+++ lams_central/web/groupHeader.jsp 7 Jan 2013 13:03:52 -0000 1.7
@@ -18,7 +18,7 @@
-
+
@@ -50,5 +50,10 @@
+
+
+
+
+
Index: lams_central/web/main.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/main.jsp,v
diff -u -r1.54 -r1.55
--- lams_central/web/main.jsp 19 Dec 2012 13:44:32 -0000 1.54
+++ lams_central/web/main.jsp 7 Jan 2013 13:03:52 -0000 1.55
@@ -29,17 +29,39 @@
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ ![]()
+ 
+
+
+ |
+
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_central/web/css/newLesson.css
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/css/Attic/newLesson.css,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_central/web/css/newLesson.css 7 Jan 2013 13:03:52 -0000 1.1
@@ -0,0 +1,202 @@
+div#tabs {
+ width: 578px;
+ height: 450px;
+}
+
+div#tabs > div {
+ height: 420px;
+}
+
+.ui-tabs .ui-tabs-panel {
+ padding: 0px;
+}
+
+div#tabs ul li a, a.ygtvspacer, a#closeButton, a#addButton {
+ border-bottom: none;
+}
+
+a#closeButton {
+ position: absolute;
+ right: 10px;
+ top: 11px;
+ width: 19px;
+ height: 18px;
+}
+
+a#closeButton span {
+ background-color: #D0E5F5;
+}
+
+a#addButton {
+ position: absolute;
+ right: 60px;
+ top: 6px;
+ width: 80px;
+ padding: 5px 0 5px 25px;
+ vertical-align: center;
+ font-weight:bolder;
+ border: thin solid #2E6E9E;
+ background-color: #D0E5F5;
+}
+
+table.tabTable {
+ height: 393px;
+ table-layout: fixed;
+ border-top: thin dotted #2E6E9E;
+}
+
+div.tabTitle {
+ padding: 5px 0px 5px 0px;
+ font-size: small;
+ font-weight: bold;
+ text-align: center;
+}
+
+.errorMessage {
+ font-weight: bold;
+ color: red;
+}
+
+.errorField {
+ border: thick solid red;
+}
+
+
+td#learningDesignTreeCell {
+ padding: 2px 2px 0px 5px;
+ vertical-align: top;
+ width: 30%;
+ border-right: thin dotted #2E6E9E;
+}
+
+.ygtv-highlight1, .ygtv-highlight1 .ygtvlabel {
+ background-color: #dfeffc;
+}
+
+td#canvasControlCell {
+ padding: 2px 0px 0px 10px;
+ height: 15px;
+}
+
+td#canvasControlCell a {
+ color: #47BC23;
+}
+
+td#canvasCell {
+ text-align: center;
+ padding: 10px 0px 0px 10px;
+}
+
+div#canvasDiv {
+ overflow: visible;
+ height: 330px;
+}
+
+.ldChoiceDependentCanvasElement {
+ display: none;
+}
+
+td#lessonNameCell {
+ height: 20px;
+ padding: 0px 0px 5px 10px;
+}
+
+#lessonNameInput {
+ width: 250px;
+ margin-left: 10px;
+}
+
+
+table#classTable td {
+ width: 50%;
+ vertical-align: top;
+ padding: 5px 10px 0px 10px;
+}
+
+.draggableUser {
+ padding: 3px 0px 3px 0px;
+ cursor: default;
+}
+
+.userContainer {
+ height: 150px;
+ overflow: auto;
+ border: thin solid black;
+ padding : 5px;
+}
+
+.userContainerTitle {
+ padding: 0px 0px 5px 0px;
+ height: 15px;
+ font-size: small;
+ font-weight: bold;
+ text-align: center;
+}
+
+.droppableHighlight {
+ padding : 1px;
+ border: 5px solid #5c9ccc;
+}
+
+.draggableUserSelected {
+ background-color: #5c9ccc !important;
+ color: white !important;
+}
+
+
+div#tabAdvanced {
+ padding-left: 30px;
+}
+
+div#tabAdvanced input[type="checkbox"] {
+ margin: 5px 5px 0px 0px;
+ border: none;
+}
+
+.fieldSectionTitle {
+ padding: 15px 0px 5px 15px;
+ font-size: small;
+ font-weight: bold;
+}
+
+.fieldInnerSection {
+ padding-left: 30px;
+}
+
+div#introSection {
+ padding-top: 5px;
+}
+
+div#introSection span {
+ vertical-align: top;
+}
+
+textarea#introDescriptionField {
+ width: 200px;
+}
+
+table#splitLearnersTable {
+ height: 40px;
+}
+
+td#splitLearnersCell {
+ padding: 0px 0px 0px 30px;
+}
+
+#splitLearnersCountField {
+ width: 50px;
+ margin: 0px 0px 0px 5px !important;
+}
+
+td#splitLearnersDescriptionCell {
+ padding: 0px;
+}
+
+span#splitLearnersDescription {
+ font-style: italic;
+ display: none;
+}
+
+#schedulingDatetimeField {
+ margin-left: 40px;
+}
\ No newline at end of file
Index: lams_central/web/includes/javascript/newLesson.js
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/Attic/newLesson.js,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_central/web/includes/javascript/newLesson.js 7 Jan 2013 13:03:52 -0000 1.1
@@ -0,0 +1,392 @@
+// ********** MAIN FUNCTIONS **********
+
+function initLessonTab(){
+ $('#ldScreenshotAuthor').load(function(){
+ // hide "loading" animation
+ $('.ldChoiceDependentCanvasElement').css('display', 'none');
+ // show the thumbnail
+ $('#ldScreenshotAuthor').css('display', 'inline');
+ // resize if needed
+ var resized = resizeImage('ldScreenshotAuthor', 400, null);
+ toggleCanvasResize(resized ? CANVAS_RESIZE_OPTION_FIT
+ : CANVAS_RESIZE_OPTION_NONE);
+ });
+
+ // generate LD tree; folderContents is declared in newLesson.jsp
+ var treeNodes = parseFolderTreeNode(folderContents);
+ // there should be no focus, just highlight
+ YAHOO.widget.TreeView.FOCUS_CLASS_NAME = null;
+ tree = new YAHOO.widget.TreeView('learningDesignTreeCell', treeNodes);
+ tree.singleNodeHighlight = true;
+ tree.subscribe('clickEvent', function(event){
+ if (!event.node.data.learningDesignId){
+ // it is a folder
+ return false;
+ }
+
+ $('#lessonNameInput').val(event.node.label);
+
+ // display "loading" animation and finally LD thumbnail
+ $('.ldChoiceDependentCanvasElement').css('display', 'none');
+ if (event.node.highlightState == 0) {
+ $('#ldScreenshotLoading').css('display', 'inline');
+ $('#ldScreenshotAuthor').attr('src', LD_THUMBNAIL_URL_BASE + event.node.data.learningDesignId);
+ $('#ldScreenshotAuthor').css('width', 'auto').css('height', 'auto');
+ }
+ });
+ tree.subscribe('clickEvent',tree.onEventToggleHighlight);
+ tree.render();
+
+ // if empty folders were empty in the start, they would have been displayed as leafs
+ // instead, there is a dummy element in the start which is removed
+ // when user opens the folder
+ var emptyFolderNodes = tree.getNodesBy(function(node){
+ var firstNode = node.children[0];
+ return firstNode && firstNode.data.isDummy;
+ });
+
+ $.each(emptyFolderNodes, function(){
+ this.setDynamicLoad(function(node, callback){
+ tree.removeChildren(node);
+ callback();
+ });
+ });
+
+ tree.getRoot().children[0].expand();
+}
+
+
+function initClassTab(){
+ // users variable is declared in newLesson.jsp
+ fillUserContainer(users.selectedLearners, 'selected-learners');
+ fillUserContainer(users.unselectedLearners, 'unselected-learners');
+ fillUserContainer(users.selectedMonitors, 'selected-monitors');
+ fillUserContainer(users.unselectedMonitors, 'unselected-monitors');
+
+ $('.draggableUser').each(function(){
+ $(this).draggable({ 'scope' : getDraggableScope($(this).parents('.userContainer').attr('id')),
+ 'appendTo' : 'body',
+ 'containment' : '#classTable',
+ 'revert' : 'invalid',
+ 'distance' : 20,
+ 'scroll' : false,
+ 'cursor' : 'move',
+ 'helper' : function(event){
+ // include the user from which dragging started
+ $(this).addClass('draggableUserSelected');
+
+ // copy selected users
+ var helperContainer = $('');
+ $(this).siblings('.draggableUserSelected').andSelf().each(function(){
+ $(this).clone().appendTo(helperContainer);
+ });
+ return helperContainer;
+ }
+ }).click(function(event){
+ var wasSelected = $(this).hasClass('draggableUserSelected');
+ var parentId = $(this).parent().attr('id');
+ // this is needed for shift+click
+ var lastSelectedUser = lastSelectedUsers[parentId];
+
+ if (event.shiftKey && lastSelectedUser && lastSelectedUser != this) {
+ // clear current selection
+ $(this).siblings().andSelf().removeClass('draggableUserSelected');
+
+ // find range of users to select
+ var lastSelectedIndex = $(lastSelectedUser).index();
+ var index = $(this).index();
+
+ var startingElem = lastSelectedIndex > index ? this : lastSelectedUser;
+ var endingElem = lastSelectedIndex > index ? lastSelectedUser : this;
+
+ $(startingElem).nextUntil(endingElem).andSelf().add(endingElem)
+ .addClass('draggableUserSelected');
+ } else {
+ if (!event.ctrlKey) {
+ // clear current sleection
+ $(this).siblings().andSelf().removeClass('draggableUserSelected');
+ }
+
+ if (wasSelected && !event.shiftKey){
+ $(this).removeClass('draggableUserSelected');
+ lastSelectedUsers[parentId] = null;
+ } else {
+ $(this).addClass('draggableUserSelected');
+ lastSelectedUsers[parentId] = this;
+ }
+ }
+ });
+ });
+
+ $('.userContainer').each(function(){
+ colorDraggableUsers(this);
+
+ $(this).droppable({'scope' : $(this).attr('id'),
+ 'activeClass' : 'droppableHighlight',
+ 'tolerance' : 'touch',
+ 'accept' : function (draggable) {
+ // forbid current user from being removed from monitors
+ return $(this).attr('id') != 'unselected-monitors'
+ || $(draggable).attr('userId') != userId;
+ },
+ 'drop' : function (event, ui) {
+ // remove error message, if exists
+ $(this).children('.errorMessage').remove();
+
+ // move the selected users
+ var previousContainer = ui.draggable.parent();
+ previousContainer.children('.draggableUserSelected')
+ .css({'top' : '0px',
+ 'left' : '0px',
+ })
+ .draggable('option', 'scope', getDraggableScope($(this).attr('id')))
+ .appendTo(this);
+
+ // recolour both containers
+ $(this).children().removeClass('draggableUserSelected');
+ colorDraggableUsers(this);
+ colorDraggableUsers(previousContainer);
+
+ if ($(this).attr('id').indexOf('learners') > 0) {
+ // number of selected learners changed, so update this control too
+ updateSplitLearnersFields();
+ }
+ }
+ });
+ });
+}
+
+
+function initAdvancedTab(){
+ $('#splitLearnersCountField').spinner({
+ 'disabled' : true,
+ 'incremental' : false,
+ 'min' : 1,
+ 'max' : users.selectedLearners ? users.selectedLearners.length : 1,
+ 'stop' : updateSplitLearnersFields
+ }).spinner('value', 1);
+
+ $('#splitLearnersField').change(function(){
+ updateSplitLearnersFields();
+ });
+
+ $('#introEnableField').change(function(){
+ $('#introSection input, #introSection textarea').prop('disabled', !$(this).is(':checked'));
+ });
+
+ $('#presenceEnableField').change(function(){
+ $('#imEnableField').prop('disabled', !$(this).is(':checked'));
+ });
+
+ $('#schedulingEnableField').change(function(){
+ $('#schedulingDatetimeField').prop('disabled', !$(this).is(':checked'));
+ });
+
+ $('#startMonitorField').change(function(){
+ var checked = !$(this).is(':checked');
+ var schedulingEnableField = $('#schedulingEnableField');
+ if (!checked) {
+ schedulingEnableField.attr('checked', false);
+ $('#schedulingDatetimeField').prop('disabled', true);
+ }
+ schedulingEnableField.prop('disabled', !checked);
+ });
+
+ $('#schedulingDatetimeField').datetimepicker();
+}
+
+
+function addLesson(){
+ // some validation at first
+ var lessonName = $('#lessonNameInput').val();
+ if (lessonName){
+ $('#lessonNameInput').removeClass('errorField');
+ }
+
+ var ldNode = tree.getHighlightedNode();
+ if (!ldNode || !ldNode.data.learningDesignId) {
+ $('#ldNotChosenError').show();
+ $('#tabs').tabs('option', 'selected', 0);
+ return;
+ }
+ $('#ldIdField').val(ldNode.data.learningDesignId);
+
+ if (!lessonName){
+ $('#lessonNameInput').addClass('errorField');
+ $('#tabs').tabs('option', 'selected', 0);
+ return;
+ }
+ $('#lessonNameField').val(lessonName);
+
+
+ var learners = getSelectedUserList('selected-learners');
+ if (learners == ''){
+ $('').addClass('errorMessage')
+ .text(LABEL_MISSING_LEARNERS)
+ .appendTo('#selected-learners');
+ $('#tabs').tabs('option', 'selected', 1);
+ return;
+ }
+ $('#learnersField').val(learners);
+
+ var monitors = getSelectedUserList('selected-monitors');
+ if (monitors == ''){
+ $('').addClass('errorMessage')
+ .text(LABEL_MISSING_MONITORS)
+ .appendTo('#selected-monitors');
+ $('#tabs').tabs('option', 'selected', 1);
+ return;
+ }
+ $('#monitorsField').val(learners);
+
+ if ($('#splitLearnersField').is(':checked')) {
+ var maxLearnerCount = $('#selected-learners div.draggableUser').length;
+ var learnerCount = $('#splitLearnersCountField').spinner('value');
+ var instances = Math.ceil(maxLearnerCount/learnerCount);
+ $('#splitNumberLessonsField').val(instances);
+ }
+
+ $('#lessonForm').ajaxSubmit({
+ 'success' : function(){
+ window.parent.closeAddLessonDialog(true);
+ }});
+}
+
+// ********** LESSON TAB FUNCTIONS **********
+
+function resizeImage(id, width, height) {
+ var resized = false;
+ var elem = $('#' + id);
+
+ if (width != null && elem.width() > width) {
+ elem.css('width', width);
+ resized = true;
+ }
+ if (height != null && elem.height() > height) {
+ elem.css('height', height);
+ resized = true;
+ }
+ return resized;
+}
+
+
+function toggleCanvasResize(mode) {
+ var toggleCanvasResizeLink = $('#toggleCanvasResizeLink');
+ switch (mode) {
+ case CANVAS_RESIZE_OPTION_NONE:
+ toggleCanvasResizeLink.css('display', 'none');
+ $('#canvasDiv').css('overflow', 'visible');
+ break;
+ case CANVAS_RESIZE_OPTION_FIT:
+ toggleCanvasResizeLink.html(CANVAS_RESIZE_LABEL_FULL).one('click',
+ function() {
+ toggleCanvasResize(CANVAS_RESIZE_OPTION_FULL)
+ });
+ toggleCanvasResizeLink.css('display', 'inline');
+ resizeImage('ldScreenshotAuthor', 385, null);
+ $('#canvasDiv').css('overflow', 'visible');
+ break;
+ case CANVAS_RESIZE_OPTION_FULL:
+ toggleCanvasResizeLink.html(CANVAS_RESIZE_LABEL_FIT).one('click',
+ function() {
+ toggleCanvasResize(CANVAS_RESIZE_OPTION_FIT)
+ });
+ toggleCanvasResizeLink.css('display', 'inline');
+ $('#ldScreenshotAuthor').css('width', 'auto').css('height', 'auto');
+ $('#canvasDiv').css('overflow', 'auto');
+ break;
+ }
+}
+
+
+function parseFolderTreeNode(nodeJSON) {
+ var result = [];
+
+ if (!nodeJSON.folders && !nodeJSON.learningDesigns) {
+ // add dummy node, otherwise empty folder is displayed as a leaf
+ result.push({'type' : 'text',
+ 'label' : '(dummy)',
+ 'isDummy' : true
+ });
+ } else {
+ if (nodeJSON.folders) {
+ $.each(nodeJSON.folders, function(){
+ result.push({'type' : 'text',
+ 'label' : this.name,
+ 'children' : parseFolderTreeNode(this)
+ });
+ });
+ }
+ if (nodeJSON.learningDesigns) {
+ $.each(nodeJSON.learningDesigns, function(){
+ result.push({'type' : 'text',
+ 'label' : this.name,
+ 'learningDesignId' : this.learningDesignId
+ });
+ });
+ }
+ }
+
+ return result;
+}
+
+// ********** CLASS TAB FUNCTIONS **********
+
+function fillUserContainer(users, containerID) {
+ if (users) {
+ // create user DIVs
+ $.each(users, function(index, userJSON) {
+ $('#' + containerID).append($('').attr('userId', userJSON.userID)
+ .addClass('draggableUser')
+ .text(userJSON.firstName + ' ' + userJSON.lastName
+ + ' (' + userJSON.login + ')')
+ );
+ });
+ }
+}
+
+
+function getDraggableScope(containerId) {
+ // switch scope to opposite after drop, so user can be dragged back if needed
+ var scopeParts = containerId.split('-');
+ return (scopeParts[0] == 'selected' ? 'unselected' : 'selected') + '-' + scopeParts[1];
+}
+
+
+function colorDraggableUsers(container) {
+ // every second line is different
+ $(container).find('div').each(function(index, userDiv){
+ // exact colour should be defined in CSS, but it's easier this way...
+ $(this).css('background-color', index % 2 ? '#dfeffc' : 'inherit');
+ });
+}
+
+
+function getSelectedUserList(containerId) {
+ var list = '';
+ $('#' + containerId).children('div.draggableUser').each(function(){
+ list += $(this).attr('userId') + ',';
+ });
+ return list;
+}
+
+// ********** ADVANCED TAB FUNCTIONS **********
+
+function updateSplitLearnersFields(){
+ var splitEnabled = $('#splitLearnersField').is(':checked');
+ if (splitEnabled) {
+ $('#splitLearnersCountField').spinner('enable');
+
+ // put users into groups
+ var maxLearnerCount = $('#selected-learners div.draggableUser').length;
+ var learnerCount = $('#splitLearnersCountField').spinner('option', 'max', maxLearnerCount < 1 ? 1 : maxLearnerCount)
+ .spinner('value');
+ var instances = Math.ceil(maxLearnerCount/learnerCount);
+ learnerCount = Math.ceil(maxLearnerCount/instances);
+ var description = SPLIT_LEARNERS_DESCRIPTION.replace('[0]', instances).replace('[1]', learnerCount);
+ $('#splitLearnersDescription').html(description).show();
+ } else {
+ $('#splitLearnersCountField').spinner('disable');
+ $('#splitLearnersDescription').hide();
+ }
+}
\ No newline at end of file
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java,v
diff -u -r1.5 -r1.6
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java 17 Sep 2006 06:19:29 -0000 1.5
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringServiceProxy.java 7 Jan 2013 13:03:48 -0000 1.6
@@ -27,6 +27,7 @@
import javax.servlet.ServletContext;
import org.lamsfoundation.lams.learning.service.ICoreLearnerService;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
@@ -67,6 +68,11 @@
{
return (ICoreLearnerService)getDomainService(servletContext,"learnerService");
}
+
+ public static final IUserManagementService getUserManagementService(ServletContext servletContext) {
+ return (IUserManagementService) getDomainService(servletContext, "userManagementService");
+ }
+
/**
* Retrieve the proper Spring bean from bean factory.
* @param servletContext the servletContext for current application
Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java,v
diff -u -r1.77 -r1.78
--- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 19 Dec 2012 13:44:17 -0000 1.77
+++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 7 Jan 2013 13:03:48 -0000 1.78
@@ -26,8 +26,12 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -36,6 +40,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.commons.lang.StringUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
@@ -47,8 +52,10 @@
import org.lamsfoundation.lams.timezone.service.ITimezoneService;
import org.lamsfoundation.lams.tool.exception.LamsToolServiceException;
import org.lamsfoundation.lams.usermanagement.Organisation;
+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.DateUtil;
import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.WebUtil;
@@ -72,7 +79,7 @@
* @since 2005-4-15
* @version 1.1
*
- * ----------------XDoclet Tags--------------------
+ * ----------------XDoclet Tags--------------------
*
* @struts:action path="/monitoring" parameter="method" validate="false"
* @struts.action-forward name = "previewdeleted" path = "/previewdeleted.jsp"
@@ -94,6 +101,7 @@
private static final String NOT_SUPPORTED_SCREEN = "notsupported";
private static final String TIME_CHART_SCREEN = "timeChart";
private static final String ERROR = "error";
+ private static final DateFormat LESSON_SCHEDULING_DATETIME_FORMAT = new SimpleDateFormat("MM/dd/yy HH:mm");
/** See deleteOldPreviewLessons */
public static final String NUM_DELETED = "numDeleted";
@@ -109,9 +117,9 @@
}
private FlashMessage handleException(Exception e, String methodKey, IMonitoringService monitoringService) {
- log.error("Exception thrown " + methodKey, e);
- auditService = getAuditService();
- auditService.log(MonitoringAction.class.getName() + ":" + methodKey, e.toString());
+ LamsDispatchAction.log.error("Exception thrown " + methodKey, e);
+ MonitoringAction.auditService = getAuditService();
+ MonitoringAction.auditService.log(MonitoringAction.class.getName() + ":" + methodKey, e.toString());
if (e instanceof UserAccessDeniedException) {
return new FlashMessage(methodKey, monitoringService.getMessageService().getMessage(
@@ -126,9 +134,9 @@
private FlashMessage handleCriticalError(String methodKey, String messageKey, IMonitoringService monitoringService) {
String message = monitoringService.getMessageService().getMessage(messageKey);
- log.error("Error occured " + methodKey + " error ");
- auditService = getAuditService();
- auditService.log(MonitoringAction.class.getName() + ":" + methodKey, message);
+ LamsDispatchAction.log.error("Error occured " + methodKey + " error ");
+ MonitoringAction.auditService = getAuditService();
+ MonitoringAction.auditService.log(MonitoringAction.class.getName() + ":" + methodKey, message);
return new FlashMessage(methodKey, message, FlashMessage.CRITICAL_ERROR);
}
@@ -140,7 +148,7 @@
response.sendRedirect(response.encodeRedirectURL(fullURL));
return null;
} else {
- return mapping.findForward(NOT_SUPPORTED_SCREEN);
+ return mapping.findForward(MonitoringAction.NOT_SUPPORTED_SCREEN);
}
}
@@ -178,11 +186,13 @@
try {
String title = WebUtil.readStrParam(request, "lessonName");
- if (title == null)
+ if (title == null) {
title = "lesson";
+ }
String desc = WebUtil.readStrParam(request, "lessonDescription", true);
- if (desc == null)
+ if (desc == null) {
desc = "description";
+ }
Integer organisationId = WebUtil.readIntParam(request, "organisationID", true);
long ldId = WebUtil.readLongParam(request, AttributeNames.PARAM_LEARNINGDESIGN_ID);
Boolean learnerExportAvailable = WebUtil.readBooleanParam(request, "learnerExportPortfolio", false);
@@ -247,6 +257,104 @@
return null;
}
+ public ActionForward newLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException, ParseException {
+ String lessonName = request.getParameter("lessonName");
+ int organisationId = WebUtil.readIntParam(request, AttributeNames.PARAM_ORGANISATION_ID);
+ long ldId = WebUtil.readLongParam(request, AttributeNames.PARAM_LEARNINGDESIGN_ID);
+ boolean introEnable = WebUtil.readBooleanParam(request, "introEnable", false);
+ String introDescription = request.getParameter("introDescription");
+ boolean introImage = WebUtil.readBooleanParam(request, "introImage", false);
+ boolean startMonitor = WebUtil.readBooleanParam(request, "startMonitor", false);
+ boolean enableLiveEdit = WebUtil.readBooleanParam(request, "enableLiveEdit", false);
+ boolean notificationsEnable = WebUtil.readBooleanParam(request, "notificationsEnable", false);
+ boolean portfolioEnable = WebUtil.readBooleanParam(request, "portfolioEnable", false);
+ boolean presenceEnable = WebUtil.readBooleanParam(request, "presenceEnable", false);
+ boolean imEnable = WebUtil.readBooleanParam(request, "imEnable", false);
+ Integer splitNumberLessons = WebUtil.readIntParam(request, "splitNumberLessons", true);
+ boolean schedulingEnable = WebUtil.readBooleanParam(request, "schedulingEnable", false);
+ Date schedulingDatetime = schedulingEnable ? MonitoringAction.LESSON_SCHEDULING_DATETIME_FORMAT.parse(request
+ .getParameter("schedulingDatetime")) : null;
+
+ IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet()
+ .getServletContext());
+
+ IUserManagementService userManagementService = MonitoringServiceProxy.getUserManagementService(getServlet()
+ .getServletContext());
+
+ Organisation organisation = (Organisation) userManagementService.findById(Organisation.class, organisationId);
+ Integer userId = getUserId();
+ User user = (User) userManagementService.findById(User.class, userId);
+
+ // parse comma delimited learner list and get the real users objects
+ String learnersParam = request.getParameter("learners");
+ List learners = new ArrayList();
+ for (String learnerID : learnersParam.split(",")) {
+ // last one will be blank
+ if (!StringUtils.isBlank(learnerID)) {
+ User learner = (User) userManagementService.findById(User.class, Integer.valueOf(learnerID));
+ learners.add(learner);
+ }
+ }
+ String learnerGroupName = organisation.getName() + " learners";
+
+ String staffParam = request.getParameter("monitors");
+ List staff = new ArrayList();
+ for (String staffMemberID : staffParam.split(",")) {
+ if (!StringUtils.isBlank(staffMemberID)) {
+ User staffMemeber = (User) userManagementService.findById(User.class, Integer.valueOf(staffMemberID));
+ staff.add(staffMemeber);
+ }
+ }
+ // add the creator as staff, if not already done
+ if (!staff.contains(user)) {
+ staff.add(user);
+ }
+ String staffGroupName = organisation.getName() + " staff";
+
+ // either all users participate in a lesson, or we split them among instances
+ List lessonInstanceLearners = splitNumberLessons == null ? learners : new ArrayList(
+ (learners.size() / splitNumberLessons) + 1);
+ for (int lessonIndex = 1; lessonIndex <= (splitNumberLessons == null ? 1 : splitNumberLessons); lessonIndex++) {
+ String lessonInstanceName = lessonName;
+ String learnerGroupInstanceName = learnerGroupName;
+ String staffGroupInstanceName = staffGroupName;
+
+ if (splitNumberLessons != null) {
+ // prepare data for lesson split
+ lessonInstanceName += " " + lessonIndex;
+ learnerGroupInstanceName += " " + lessonIndex;
+ staffGroupInstanceName += " " + lessonIndex;
+ lessonInstanceLearners.clear();
+ for (int learnerIndex = lessonIndex - 1; learnerIndex < learners.size(); learnerIndex += splitNumberLessons) {
+ lessonInstanceLearners.add(learners.get(learnerIndex));
+ }
+ }
+
+ if (LamsDispatchAction.log.isDebugEnabled()) {
+ LamsDispatchAction.log.debug("Creating lesson "
+ + (splitNumberLessons == null ? "" : "(" + lessonIndex + "/" + splitNumberLessons + ") ")
+ + "\"" + lessonInstanceName + "\"");
+ }
+ Lesson lesson = monitoringService.initializeLesson(lessonInstanceName, introDescription, ldId,
+ organisationId, userId, null, introEnable, introImage, portfolioEnable, presenceEnable, imEnable,
+ enableLiveEdit, notificationsEnable, null, null);
+
+ monitoringService.createLessonClassForLesson(lesson.getLessonId(), organisation, learnerGroupInstanceName,
+ lessonInstanceLearners, staffGroupInstanceName, staff, userId);
+
+ if (!startMonitor) {
+ if (schedulingDatetime == null) {
+ monitoringService.startLesson(lesson.getLessonId(), userId);
+ } else {
+ monitoringService.startLessonOnSchedule(lesson.getLessonId(), schedulingDatetime, userId);
+ }
+ }
+ }
+
+ return null;
+ }
+
/**
* The Struts dispatch method that starts a lesson on schedule that has been created beforehand.
*
@@ -562,7 +670,7 @@
response.getWriter().print(jsonObject);
return null;
}
-
+
/**
*
*
@@ -588,21 +696,23 @@
// get parameters
Long activityId = null;
String actId = request.getParameter(AttributeNames.PARAM_ACTIVITY_ID);
- if (actId != null)
+ if (actId != null) {
try {
activityId = new Long(Long.parseLong(actId));
} catch (Exception e) {
activityId = null;
}
+ }
// force complete
try {
long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID);
Integer learnerId = new Integer(WebUtil.readIntParam(request, MonitoringConstants.PARAM_LEARNER_ID));
Integer requesterId = getUserId();
String message = monitoringService.forceCompleteLessonByUser(learnerId, requesterId, lessonId, activityId);
- if (log.isDebugEnabled()) {
- log.debug("Force complete for learner " + learnerId + " lesson " + lessonId + ". " + message);
+ if (LamsDispatchAction.log.isDebugEnabled()) {
+ LamsDispatchAction.log.debug("Force complete for learner " + learnerId + " lesson " + lessonId + ". "
+ + message);
}
flashMessage = new FlashMessage("forceComplete", message);
} catch (Exception e) {
@@ -1083,8 +1193,8 @@
IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet()
.getServletContext());
int numDeleted = monitoringService.deleteAllOldPreviewLessons();
- request.setAttribute(NUM_DELETED, Integer.toString(numDeleted));
- return mapping.findForward(PREVIEW_DELETED_REPORT_SCREEN);
+ request.setAttribute(MonitoringAction.NUM_DELETED, Integer.toString(numDeleted));
+ return mapping.findForward(MonitoringAction.PREVIEW_DELETED_REPORT_SCREEN);
}
/**
@@ -1093,12 +1203,12 @@
* @return
*/
private IAuditService getAuditService() {
- if (auditService == null) {
+ if (MonitoringAction.auditService == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- auditService = (IAuditService) ctx.getBean("auditService");
+ MonitoringAction.auditService = (IAuditService) ctx.getBean("auditService");
}
- return auditService;
+ return MonitoringAction.auditService;
}
/**
@@ -1107,12 +1217,12 @@
* @return
*/
private ITimezoneService getTimezoneService() {
- if (timezoneService == null) {
+ if (MonitoringAction.timezoneService == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- timezoneService = (ITimezoneService) ctx.getBean("timezoneService");
+ MonitoringAction.timezoneService = (ITimezoneService) ctx.getBean("timezoneService");
}
- return timezoneService;
+ return MonitoringAction.timezoneService;
}
/**
@@ -1246,9 +1356,9 @@
request.setAttribute("errorName", "MonitoringAction");
request.setAttribute("errorMessage", e.getMessage());
- return mapping.findForward(ERROR);
+ return mapping.findForward(MonitoringAction.ERROR);
}
- return mapping.findForward(TIME_CHART_SCREEN);
+ return mapping.findForward(MonitoringAction.TIME_CHART_SCREEN);
}
}