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.7 -r1.8 --- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 11 May 2006 06:59:15 -0000 1.7 +++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 25 May 2006 01:01:50 -0000 1.8 @@ -35,24 +35,21 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.actions.DispatchAction; - -import org.springframework.web.context.support.WebApplicationContextUtils; -import org.springframework.web.context.WebApplicationContext; - +import org.lamsfoundation.lams.usermanagement.Organisation; +import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.UserManagementService; -import org.lamsfoundation.lams.web.PasswordChangeActionForm; +import org.lamsfoundation.lams.usermanagement.util.AdminPreparer; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.HttpSessionManager; -import org.lamsfoundation.lams.usermanagement.Role; -import org.lamsfoundation.lams.usermanagement.Organisation; -import org.lamsfoundation.lams.usermanagement.util.AdminPreparer; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; -import org.lamsfoundation.lams.util.Configuration; -import org.lamsfoundation.lams.util.ConfigurationKeys; - /** * this is an action where all lams client environments launch. * initial configuration of the individual environment setting is done here. @@ -64,7 +61,8 @@ * @struts:action-forward name="admin" path="/admin.jsp" * @struts:action-forward name="learner" path="/learner.jsp" * @struts:action-forward name="author" path="/author.jsp" - * @struts:action-forward name="staff" path="/staff.jsp" + * @struts:action-forward name="monitorLesson" path="/monitorLesson.jsp" + * @struts:action-forward name="addLesson" path="/addLesson.jsp" * @struts:action-forward name="error" path=".error" * @struts:action-forward name="passwordChange" path=".passwordChange" * @@ -157,24 +155,18 @@ try { log.debug("request learner"); - int orgId = new Integer(req.getParameter("orgId")).intValue(); + Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID); UserDTO user = getUser(); if ( user == null ) { log.error("admin: User missing from session. "); return mapping.findForward("error"); - } else if ( isUserInRole(user.getUserID(),orgId,Role.LEARNER) ) { - log.debug("user is learner"); - + } else { + // TODO check that the user is in the learner group for the lesson String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); - req.setAttribute("serverUrl", serverUrl); + req.setAttribute(AttributeNames.PARAM_LESSON_ID,lessonId); return mapping.findForward("learner"); } - else - { - log.error("User "+user.getLogin()+" tried to get learner screen but isn't learner in organisation: "+orgId); - return mapping.findForward("error"); - } } catch (Exception e) { e.printStackTrace(); @@ -192,25 +184,16 @@ try { log.debug("request author"); - int orgId = new Integer(req.getParameter("orgId")).intValue(); UserDTO user = getUser(); if ( user == null ) { log.error("admin: User missing from session. "); return mapping.findForward("error"); - } else if ( isUserInRole(user.getUserID(),orgId,Role.AUTHOR) ) - { - log.debug("user is author"); - + } else { + // todo check user really does have authoring permission in some organisation. String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); - req.setAttribute("serverUrl", serverUrl); return mapping.findForward("author"); } - else - { - log.error("User "+user.getLogin()+" tried to get author screen but isn't author in organisation: "+orgId); - return mapping.findForward("error"); - } } catch (Exception e) { e.printStackTrace(); @@ -220,59 +203,67 @@ /** - * request for staff environment + * request for monitor environment */ - public ActionForward staff(ActionMapping mapping, ActionForm form, + public ActionForward monitorLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { try { - log.debug("request staff"); - int orgId = new Integer(req.getParameter("orgId")).intValue(); + log.debug("request monitorLesson"); + int lessonId = WebUtil.readIntParam(req, AttributeNames.PARAM_LESSON_ID); UserDTO user = getUser(); if ( user == null ) { log.error("admin: User missing from session. "); return mapping.findForward("error"); - } else if (isUserInRole(user.getUserID(), orgId, Role.STAFF) || isUserInRole(user.getUserID(), orgId, Role.TEACHER)) { + } else { + // TODO check that the user is in the staff group for the lesson log.debug("user is staff"); - - String serverUrl = Configuration - .get(ConfigurationKeys.SERVER_URL); - + String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); req.setAttribute("serverUrl", serverUrl); - return mapping.findForward("staff"); - } else { - log.error("User "+ user.getLogin() + " tried to get staff screen but isn't staff in organisation: " + orgId); - return mapping.findForward("error"); + req.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId); + return mapping.findForward("monitorLesson"); } - } catch (Exception e) { e.printStackTrace(); return mapping.findForward("error"); } } /** - * Loads up the user password change form - * @return screen reference name - "passwordChange" + * request for add lesson wizard */ - public ActionForward passwordChange( - ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + public ActionForward addLesson(ActionMapping mapping, ActionForm form, + HttpServletRequest req, HttpServletResponse res) + throws IOException, ServletException { - String login = request.getRemoteUser(); + try { + 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. "); + return mapping.findForward("error"); + } else { + Integer orgId = classId != null ? classId : courseId; + if (isUserInRole(user.getUserID(), orgId, Role.STAFF) || isUserInRole(user.getUserID(), orgId, Role.TEACHER)) { + log.debug("user is staff"); + String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); + req.setAttribute("serverUrl", serverUrl); + req.setAttribute(AttributeNames.PARAM_COURSE_ID, courseId); + req.setAttribute(AttributeNames.PARAM_CLASS_ID, classId); + return mapping.findForward("addLesson"); + } else { + log.error("User "+ user.getLogin() + " tried to get staff screen but isn't staff in organisation: " + orgId); + return mapping.findForward("error"); + } + } - PasswordChangeActionForm newForm = new PasswordChangeActionForm(); - newForm.setLogin(login); - - request.getSession(true).setAttribute( - PasswordChangeActionForm.formName, - newForm); - - return mapping.findForward("passwordChange"); + } catch (Exception e) { + e.printStackTrace(); + return mapping.findForward("error"); + } } } \ No newline at end of file Index: lams_central/web/addLesson.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/addLesson.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_central/web/addLesson.jsp 25 May 2006 01:01:50 -0000 1.1 @@ -0,0 +1,15 @@ +<%@ taglib uri="tags-lams" prefix="lams" %> +<%@ taglib uri="tags-core" prefix="c"%> + + +
+&classID=Loading Learner Environment.
+ + + Index: lams_central/web/indexContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/Attic/indexContent.jsp,v diff -u -r1.4 -r1.5 --- lams_central/web/indexContent.jsp 11 May 2006 06:58:57 -0000 1.4 +++ lams_central/web/indexContent.jsp 25 May 2006 01:01:50 -0000 1.5 @@ -5,20 +5,19 @@ <%@ page import="org.lamsfoundation.lams.usermanagement.service.UserManagementService" %> <%@ page import="org.lamsfoundation.lams.usermanagement.Role" %> <%@ page import="org.lamsfoundation.lams.usermanagement.User" %> +<%@ page import="org.lamsfoundation.lams.lesson.Lesson" %> <%@ page import="org.lamsfoundation.lams.usermanagement.dto.OrganisationDTO" %> +<%@ page import="org.apache.commons.collections.functors.WhileClosure" %> + <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> - - - - - +