Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.93 -r1.94 --- lams_central/conf/language/lams/ApplicationResources.properties 1 Feb 2012 10:41:54 -0000 1.93 +++ lams_central/conf/language/lams/ApplicationResources.properties 2 Feb 2012 08:13:47 -0000 1.94 @@ -282,6 +282,9 @@ index.conditions =Conditions index.conditions.tooltip =Conditions of participation in lesson label.conditions.box.title =Lesson "{0}" will only be available after these lesson(s) are completed: +label.conditions.box.no.dependency =There are no dependencies for this lesson. +label.conditions.box.add.dependency =Select lesson that will need to be completed first: +label.conditions.box.remove.dependency =Remove lesson dependency label.portrait.please.wait =Please wait label.portrait.take.snapshot.from.webcamera =Take portrait using Webcam label.portrait.configure =Configure Index: lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java,v diff -u -r1.28 -r1.29 --- lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java 1 Feb 2012 10:41:54 -0000 1.28 +++ lams_central/src/java/org/lamsfoundation/lams/web/DisplayGroupAction.java 2 Feb 2012 08:13:47 -0000 1.29 @@ -382,9 +382,9 @@ log.error("Error while encoding course name, skipping gradebook lesson monitor link", e); } } - - // Add lesson conditions thickbox if it has dependencies - if (isGroupManagerOrMonitor && bean.isDependent()) { + + // Add lesson conditions thickbox + if (isGroupManagerOrMonitor) { String conditionsLink = Configuration.get(ConfigurationKeys.SERVER_URL) + "/lessonConditions.do?method=getIndexLessonConditions&" + CentralConstants.PARAM_LESSON_ID + "=" + bean.getId() + "&KeepThis=true&TB_iframe=true&height=480&width=610"; Index: lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java,v diff -u -r1.1 -r1.2 --- lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java 1 Feb 2012 10:41:54 -0000 1.1 +++ lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java 2 Feb 2012 08:13:47 -0000 1.2 @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -45,6 +46,7 @@ /** * This Action takes care of operations on lesson conditional release based on preceding lesson completion. + * * @author Marcin Cieslak * * @struts.action path="/lessonConditions" parameter="method" validate="false" @@ -57,12 +59,14 @@ private static final String PARAM_PRECEDING_LESSONS = "precedingLessons"; private static final String PARAM_PRECEDING_LESSON_ID = "precedingLessonId"; + private static final String PARAM_AVAILABLE_LESSONS = "availableLessons"; private static LessonService lessonService; /** * Prepares data for thickbox displayed on Index page. */ + @SuppressWarnings("unchecked") public ActionForward getIndexLessonConditions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { @@ -78,6 +82,18 @@ request.setAttribute(CentralConstants.PARAM_TITLE, lesson.getLessonName()); request.setAttribute(LessonConditionsAction.PARAM_PRECEDING_LESSONS, precedingLessons); + Set organisationLessons = lesson.getOrganisation().getLessons(); + List availableLessons = new ArrayList(organisationLessons.size()); + for (Lesson organisationLesson : organisationLessons) { + if (!lessonId.equals(organisationLesson.getLessonId()) + && !lesson.getPrecedingLessons().contains(organisationLesson)) { + IndexLessonBean availableLessonBean = new IndexLessonBean(organisationLesson.getLessonId(), + organisationLesson.getLessonName()); + availableLessons.add(availableLessonBean); + } + } + request.setAttribute(LessonConditionsAction.PARAM_AVAILABLE_LESSONS, availableLessons); + return mapping.findForward(LessonConditionsAction.FORWARD_INDEX_LESSON_CONDITION); } @@ -87,7 +103,8 @@ public ActionForward removeLessonDependency(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false); - Long removedPrecedingLessonId = WebUtil.readLongParam(request, PARAM_PRECEDING_LESSON_ID, false); + Long removedPrecedingLessonId = WebUtil.readLongParam(request, + LessonConditionsAction.PARAM_PRECEDING_LESSON_ID, false); Lesson lesson = getLessonService().getLesson(lessonId); Iterator precedingLessonIter = lesson.getPrecedingLessons().iterator(); @@ -97,11 +114,28 @@ break; } } - + // after operation, display contents again return getIndexLessonConditions(mapping, form, request, response); } + /** + * Adds given lesson to dependecies and displays updated list in thickbox. + */ + public ActionForward addLessonDependency(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false); + Long addedPrecedingLessonId = WebUtil.readLongParam(request, LessonConditionsAction.PARAM_PRECEDING_LESSON_ID, + false); + + Lesson lesson = getLessonService().getLesson(lessonId); + Lesson addedPrecedingLesson = getLessonService().getLesson(addedPrecedingLessonId); + lesson.getPrecedingLessons().add(addedPrecedingLesson); + + // after operation, display contents again + return getIndexLessonConditions(mapping, form, request, response); + } + private LessonService getLessonService() { if (LessonConditionsAction.lessonService == null) { WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() Index: lams_central/web/indexLessonConditions.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/indexLessonConditions.jsp,v diff -u -r1.1 -r1.2 --- lams_central/web/indexLessonConditions.jsp 1 Feb 2012 10:41:54 -0000 1.1 +++ lams_central/web/indexLessonConditions.jsp 2 Feb 2012 08:13:47 -0000 1.2 @@ -6,7 +6,21 @@ + + + + + +