Index: lams_central/.classpath
===================================================================
diff -u -r6ea112b9b57636ff8cf428beaf3e91df321aa0d9 -r3adcc4e312e804bf86c3598e3bc744b64a46c21f
--- lams_central/.classpath (.../.classpath) (revision 6ea112b9b57636ff8cf428beaf3e91df321aa0d9)
+++ lams_central/.classpath (.../.classpath) (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -17,5 +17,6 @@
+
Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -rff3bd28c7a274dd7d1bc46152ae5900166edac8c -r3adcc4e312e804bf86c3598e3bc744b64a46c21f
--- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision ff3bd28c7a274dd7d1bc46152ae5900166edac8c)
+++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -280,11 +280,18 @@
index.emailnotifications =Notifications
index.emailnotifications.tooltip =Email notifications
index.conditions =Conditions
-index.conditions.tooltip =Conditions of participation in lesson
+index.conditions.tooltip =Conditions of participation in the lesson
+index.conditions.flag.tooltip =Participation in the lesson depends on completion of other lessons
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.conditions.box.finish.date =Lesson finishes after {0} days from its start {1}
+label.conditions.box.no.finish.date =Lesson does not have a fixed number days to finish
+label.days =days
+label.set =Set
+error.conditions.box.finish.date.number =Finish date must be a positive number
+error.conditions.box.finish.date =Error while setting lesson finish date: {0}
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/LessonConditionsAction.java
===================================================================
diff -u -rf2cb56ddf4b6c4256e0fb0cb2be42510f4ee430d -r3adcc4e312e804bf86c3598e3bc744b64a46c21f
--- lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java (.../LessonConditionsAction.java) (revision f2cb56ddf4b6c4256e0fb0cb2be42510f4ee430d)
+++ lams_central/src/java/org/lamsfoundation/lams/web/LessonConditionsAction.java (.../LessonConditionsAction.java) (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -24,6 +24,7 @@
package org.lamsfoundation.lams.web;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -36,11 +37,16 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
-import org.lamsfoundation.lams.contentrepository.InvalidParameterException;
+import org.joda.time.Interval;
+import org.joda.time.Period;
+import org.joda.time.PeriodType;
import org.lamsfoundation.lams.index.IndexLessonBean;
import org.lamsfoundation.lams.lesson.Lesson;
-import org.lamsfoundation.lams.lesson.service.LessonService;
+import org.lamsfoundation.lams.lesson.service.ILessonService;
+import org.lamsfoundation.lams.monitoring.service.IMonitoringService;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.CentralConstants;
@@ -66,8 +72,11 @@
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 final String PARAM_LESSON_START_DATE = "lessonStartDate";
+ private static final String PARAM_LESSON_DAYS_TO_FINISH = "lessonDaysToFinish";
- private static LessonService lessonService;
+ private static ILessonService lessonService;
+ private static IMonitoringService monitoringService;
/**
* Prepares data for thickbox displayed on Index page.
@@ -76,12 +85,12 @@
*/
@SuppressWarnings("unchecked")
public ActionForward getIndexLessonConditions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws InvalidParameterException {
+ HttpServletResponse response) {
Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false);
Lesson lesson = getLessonService().getLesson(lessonId);
if (lesson == null) {
- throw new InvalidParameterException("Lesson with ID: " + lessonId + " does not exist.");
+ throw new IllegalArgumentException("Lesson with ID: " + lessonId + " does not exist.");
}
List precedingLessons = new ArrayList(lesson.getPrecedingLessons().size());
@@ -106,6 +115,17 @@
}
request.setAttribute(LessonConditionsAction.PARAM_AVAILABLE_LESSONS, availableLessons);
+ Date endDate = lesson.getScheduleEndDate();
+ if (endDate != null) {
+ Date startDate = (lesson.getStartDateTime() == null) ? lesson.getScheduleStartDate() : lesson
+ .getStartDateTime();
+ Interval interval = new Interval(startDate.getTime(), endDate.getTime());
+ Period daysToLessonFinish = interval.toPeriod(PeriodType.days());
+
+ request.setAttribute(LessonConditionsAction.PARAM_LESSON_START_DATE, startDate);
+ request.setAttribute(LessonConditionsAction.PARAM_LESSON_DAYS_TO_FINISH, daysToLessonFinish.getDays());
+ }
+
request.setAttribute(CentralConstants.PARAM_EDIT, canEdit(request, lesson));
return mapping.findForward(LessonConditionsAction.FORWARD_INDEX_LESSON_CONDITION);
@@ -117,19 +137,12 @@
* @throws InvalidParameterException
*/
public ActionForward removeLessonDependency(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws InvalidParameterException {
+ HttpServletResponse response) {
Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false);
Long removedPrecedingLessonId = WebUtil.readLongParam(request,
LessonConditionsAction.PARAM_PRECEDING_LESSON_ID, false);
- Lesson lesson = getLessonService().getLesson(lessonId);
- if (lesson == null) {
- throw new InvalidParameterException("Lesson with ID: " + lessonId + " does not exist.");
- }
- if (!canEdit(request, lesson)) {
- throw new SecurityException("Current user can not edit lesson conditions");
- }
-
+ Lesson lesson = getLessonAndCheckPermissions(request, lessonId);
Iterator precedingLessonIter = lesson.getPrecedingLessons().iterator();
while (precedingLessonIter.hasNext()) {
if (precedingLessonIter.next().getLessonId().equals(removedPrecedingLessonId)) {
@@ -148,21 +161,15 @@
* @throws InvalidParameterException
*/
public ActionForward addLessonDependency(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws InvalidParameterException {
+ 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);
- if (lesson == null) {
- throw new InvalidParameterException("Lesson with ID: " + lessonId + " does not exist.");
- }
- if (!canEdit(request, lesson)) {
- throw new SecurityException("Current user can not edit lesson conditions");
- }
+ Lesson lesson = getLessonAndCheckPermissions(request, lessonId);
Lesson addedPrecedingLesson = getLessonService().getLesson(addedPrecedingLessonId);
if (addedPrecedingLesson == null) {
- throw new InvalidParameterException("Preceding lesson with ID: " + lessonId + " does not exist.");
+ throw new IllegalArgumentException("Preceding lesson with ID: " + lessonId + " does not exist.");
}
lesson.getPrecedingLessons().add(addedPrecedingLesson);
@@ -172,6 +179,58 @@
}
/**
+ * Sets a new lesson scheduled finish date, based on give number of days.
+ */
+ public ActionForward setDaysToLessonFinish(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ Long lessonId = WebUtil.readLongParam(request, CentralConstants.PARAM_LESSON_ID, false);
+ Integer daysToLessonFinish = null;
+ ActionMessages errors = new ActionMessages();
+ try {
+ daysToLessonFinish = WebUtil.readIntParam(request, LessonConditionsAction.PARAM_LESSON_DAYS_TO_FINISH,
+ false);
+ if (daysToLessonFinish <= 0) {
+ throw new IllegalArgumentException("Number of days to lesson finish is a nonpositive number");
+ }
+ } catch (IllegalArgumentException e) {
+ LessonConditionsAction.logger.error(e);
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.conditions.box.finish.date.number"));
+ }
+
+ if (daysToLessonFinish != null) {
+ Lesson lesson = getLessonAndCheckPermissions(request, lessonId);
+ HttpSession session = SessionManager.getSession();
+ UserDTO currentUser = (UserDTO) session.getAttribute(AttributeNames.USER);
+ try {
+ // reschedule the lesson
+ getMonitoringService().finishLessonOnSchedule(lessonId, daysToLessonFinish, currentUser.getUserID());
+ } catch (IllegalArgumentException e) {
+ LessonConditionsAction.logger.error(e);
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.conditions.box.finish.date",
+ new Object[] { e.getMessage() }));
+ }
+ }
+
+ if (!errors.isEmpty()) {
+ saveErrors(request, errors);
+ }
+
+ // after operation, display contents again
+ return getIndexLessonConditions(mapping, form, request, response);
+ }
+
+ private Lesson getLessonAndCheckPermissions(HttpServletRequest request, Long lessonId) {
+ Lesson lesson = getLessonService().getLesson(lessonId);
+ if (lesson == null) {
+ throw new IllegalArgumentException("Lesson with ID: " + lessonId + " does not exist.");
+ }
+ if (!canEdit(request, lesson)) {
+ throw new SecurityException("Current user can not edit lesson conditions");
+ }
+ return lesson;
+ }
+
+ /**
* Checks if user is allowed to edit lesson conditions.
*/
private boolean canEdit(HttpServletRequest request, Lesson lesson) {
@@ -183,12 +242,21 @@
return currentUser.getUserID().equals(lesson.getUser().getUserId());
}
- private LessonService getLessonService() {
+ private ILessonService getLessonService() {
if (LessonConditionsAction.lessonService == null) {
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
- LessonConditionsAction.lessonService = (LessonService) ctx.getBean("lessonService");
+ LessonConditionsAction.lessonService = (ILessonService) ctx.getBean("lessonService");
}
return LessonConditionsAction.lessonService;
}
+
+ private IMonitoringService getMonitoringService() {
+ if (LessonConditionsAction.monitoringService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
+ .getServletContext());
+ LessonConditionsAction.monitoringService = (IMonitoringService) ctx.getBean("monitoringService");
+ }
+ return LessonConditionsAction.monitoringService;
+ }
}
Index: lams_central/web/ckeditor/.cvsignore
===================================================================
diff -u
--- lams_central/web/ckeditor/.cvsignore (revision 0)
+++ lams_central/web/ckeditor/.cvsignore (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -0,0 +1 @@
+_source
Index: lams_central/web/groupContents.jsp
===================================================================
diff -u -rcb6d628cd53fe3d51e4f67cbaff7390651a048da -r3adcc4e312e804bf86c3598e3bc744b64a46c21f
--- lams_central/web/groupContents.jsp (.../groupContents.jsp) (revision cb6d628cd53fe3d51e4f67cbaff7390651a048da)
+++ lams_central/web/groupContents.jsp (.../groupContents.jsp) (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -28,6 +28,7 @@
" >
" >
" >
+ " >
Index: lams_central/web/indexLessonConditions.jsp
===================================================================
diff -u -rf2cb56ddf4b6c4256e0fb0cb2be42510f4ee430d -r3adcc4e312e804bf86c3598e3bc744b64a46c21f
--- lams_central/web/indexLessonConditions.jsp (.../indexLessonConditions.jsp) (revision f2cb56ddf4b6c4256e0fb0cb2be42510f4ee430d)
+++ lams_central/web/indexLessonConditions.jsp (.../indexLessonConditions.jsp) (revision 3adcc4e312e804bf86c3598e3bc744b64a46c21f)
@@ -2,6 +2,8 @@
<%@ taglib uri="tags-fmt" prefix="fmt"%>
<%@ taglib uri="tags-core" prefix="c"%>
<%@ taglib uri="tags-lams" prefix="lams"%>
+<%@ taglib uri="tags-logic" prefix="logic" %>
+<%@ taglib uri="tags-html" prefix="html" %>
@@ -10,6 +12,10 @@
+
+
+
+