Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r4ab4ba6ef63a831648ca63ca4d91edd4c0fba55f -ra3249210e9a22e8f54ece275f8243a8f3f3e7217 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== diff -u -r1367c68bda1ff51ded26c5220a9a059fa67235f5 -ra3249210e9a22e8f54ece275f8243a8f3f3e7217 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision 1367c68bda1ff51ded26c5220a9a059fa67235f5) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java (.../AuthoringService.java) (revision a3249210e9a22e8f54ece275f8243a8f3f3e7217) @@ -541,7 +541,7 @@ processor.parseLearningDesign(); - Activity lastReadOnlyActivity = processor.getLastReadOnlyActivity(); + Activity lastReadOnlyActivity = processor.lastReadOnlyActivity; // check if system gate already exists if ((lastReadOnlyActivity == null) || !lastReadOnlyActivity.isGateActivity() @@ -586,7 +586,9 @@ processor.parseLearningDesign(); - Activity lastReadOnlyActivity = processor.getLastReadOnlyActivity(); + Activity lastReadOnlyActivity = processor.lastReadOnlyActivity; + Long firstAddedActivityId = processor.firstAddedActivity == null ? null : processor.firstAddedActivity + .getActivityId(); // open and release waiting list on system gate if ((lastReadOnlyActivity != null) && lastReadOnlyActivity.isGateActivity() @@ -598,11 +600,11 @@ for (Lesson lesson : (Set) design.getLessons()) { lesson.setLockedForEdit(false); - // LDEV-1899 only mark learners uncompleted if a change was saved - if (!cancelled) { + // LDEV-1899 only mark learners uncompleted if a change was saved and an activity added + if (!cancelled && firstAddedActivityId != null) { // the lesson may now have additional activities on the end, // so clear any completed flags - lessonService.performMarkLessonUncompleted(lesson.getLessonId()); + lessonService.performMarkLessonUncompleted(lesson.getLessonId(), firstAddedActivityId); } initialiseToolActivityForRuntime(design, lesson); Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/EditOnFlyProcessor.java =================================================================== diff -u -r9bd21433617c6dbccfacfb09752344c640570966 -ra3249210e9a22e8f54ece275f8243a8f3f3e7217 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/EditOnFlyProcessor.java (.../EditOnFlyProcessor.java) (revision 9bd21433617c6dbccfacfb09752344c640570966) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/EditOnFlyProcessor.java (.../EditOnFlyProcessor.java) (revision a3249210e9a22e8f54ece275f8243a8f3f3e7217) @@ -34,12 +34,12 @@ import org.lamsfoundation.lams.learningdesign.exception.LearningDesignProcessorException; public class EditOnFlyProcessor extends LearningDesignProcessor { - private static Logger log = Logger.getLogger(EditOnFlyProcessor.class); - private Activity lastReadOnlyActivity = null; + public Activity lastReadOnlyActivity = null; + // were there any activities added after the Gate? + public Activity firstAddedActivity = null; - public EditOnFlyProcessor(LearningDesign design, IActivityDAO activityDAO) { super(design, activityDAO); } @@ -53,6 +53,8 @@ public void endComplexActivity(ComplexActivity activity) throws LearningDesignProcessorException { if (activity.isActivityReadOnly()) { lastReadOnlyActivity = activity; + } else if (firstAddedActivity == null) { + firstAddedActivity = activity; } } @@ -66,14 +68,8 @@ public void endSimpleActivity(SimpleActivity activity) throws LearningDesignProcessorException { if (activity.isActivityReadOnly()) { lastReadOnlyActivity = activity; + } else if (firstAddedActivity == null) { + firstAddedActivity = activity; } } - - /** - * Get the last activities in the sequence which are read-only, may contain more than one Activity due to branching - * paths - */ - public Activity getLastReadOnlyActivity() { - return lastReadOnlyActivity; - } -} +} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java =================================================================== diff -u -r5b633ecc884b7d321a5164af26bfe268629a2d3f -ra3249210e9a22e8f54ece275f8243a8f3f3e7217 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 5b633ecc884b7d321a5164af26bfe268629a2d3f) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision a3249210e9a22e8f54ece275f8243a8f3f3e7217) @@ -306,7 +306,7 @@ * @param lessonId * The lesson for which learner progress entries should be updated. */ - void performMarkLessonUncompleted(Long lessonId) throws LessonServiceException; + void performMarkLessonUncompleted(Long lessonId, Long firstAddedActivityId) throws LessonServiceException; /** * Get the list of users who have attempted an activity. This is based on the progress engine records. This will Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java =================================================================== diff -u -rc50361fcaf56092658960255cd7b17923c451e23 -ra3249210e9a22e8f54ece275f8243a8f3f3e7217 --- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision c50361fcaf56092658960255cd7b17923c451e23) +++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision a3249210e9a22e8f54ece275f8243a8f3f3e7217) @@ -374,7 +374,7 @@ LessonService.log.debug("Added " + numAdded + " learners to lessonClass " + lessonClass.getGroupingId()); } } - + @Override public void setLearners(Lesson lesson, Collection users) throws LessonServiceException { LessonClass lessonClass = lesson.getLessonClass(); @@ -450,7 +450,7 @@ + lessonClass.getGroupingId()); } } - + @Override public void setStaffMembers(Lesson lesson, Collection users) throws LessonServiceException { @@ -515,7 +515,7 @@ } } } - + /** * Completely removes learner progress as if the user has not started the lesson yet. */ @@ -527,24 +527,29 @@ } } + @SuppressWarnings("unchecked") @Override - public void performMarkLessonUncompleted(Long lessonId) throws LessonServiceException { - int count = 0; - if (lessonId != null) { + public void performMarkLessonUncompleted(Long lessonId, Long firstAddedActivityId) throws LessonServiceException { + if (log.isDebugEnabled()) { LessonService.log.debug("Setting learner progress to uncompleted for lesson " + lessonId); + } + int count = 0; + List progresses = learnerProgressDAO.getCompletedLearnerProgressForLesson(lessonId); + Activity firstAddedActivity = (Activity) baseDAO.find(Activity.class, firstAddedActivityId); - List progresses = learnerProgressDAO.getCompletedLearnerProgressForLesson(lessonId); - if (progresses != null && progresses.size() > 0) { - Iterator iter = progresses.iterator(); - while (iter.hasNext()) { - LearnerProgress progress = (LearnerProgress) iter.next(); - if (progress.getLessonComplete() == LearnerProgress.LESSON_END_OF_DESIGN_COMPLETE) { - progress.setLessonComplete(LearnerProgress.LESSON_NOT_COMPLETE); - } - count++; - } + for (LearnerProgress progress : progresses) { + if (progress.getLessonComplete() == LearnerProgress.LESSON_END_OF_DESIGN_COMPLETE) { + progress.setLessonComplete(LearnerProgress.LESSON_NOT_COMPLETE); + progress.setFinishDate(null); + // set the next activity user will take + // previous activity should also be set, but it is not vital + progress.setCurrentActivity(firstAddedActivity); + progress.setNextActivity(firstAddedActivity); + + count++; } } + if (LessonService.log.isDebugEnabled()) { LessonService.log.debug("Reset completed flag for " + count + " learners for lesson " + lessonId); } @@ -586,7 +591,8 @@ Boolean lessonCompleted = (Boolean) tuple[4]; lessonCompleted = lessonCompleted == null ? false : lessonCompleted.booleanValue(); Boolean enableLessonNotifications = (Boolean) tuple[5]; - enableLessonNotifications = enableLessonNotifications == null ? false : enableLessonNotifications.booleanValue(); + enableLessonNotifications = enableLessonNotifications == null ? false : enableLessonNotifications + .booleanValue(); Boolean dependent = (Boolean) tuple[6]; dependent = dependent == null ? false : dependent.booleanValue(); Boolean scheduledFinish = (Boolean) tuple[7]; @@ -603,7 +609,7 @@ List list = lessonDAO.getLessonsByGroupAndUser(userId, organisationId); return list; } - + @Override public List getLessonsByGroup(Integer organisationId) { List list = lessonDAO.getLessonsByGroup(organisationId); @@ -614,13 +620,13 @@ public LearnerProgress getUserProgressForLesson(Integer learnerId, Long lessonId) { return learnerProgressDAO.getLearnerProgressByLearner(learnerId, lessonId); } - + @Override public List getUserProgressForLesson(Long lessonId) { List list = learnerProgressDAO.getLearnerProgressForLesson(lessonId); return list; } - + @Override public List getLessonsByOriginalLearningDesign(Long ldId, Integer orgId) { return lessonDAO.getLessonsByOriginalLearningDesign(ldId, orgId); @@ -635,16 +641,16 @@ public List getActiveLessonsForLearner(Integer learnerId, Integer organisationId) { return lessonDAO.getActiveLessonsForLearner(learnerId, organisationId); } - + @Override public LessonDetailsDTO getLessonDetailsFromSessionID(Long toolSessionID) { Lesson lesson = this.lessonDAO.getLessonFromSessionID(toolSessionID); if (lesson != null) { - return lesson.getLessonDetails(); + return lesson.getLessonDetails(); } return null; } - + @Override public boolean checkLessonReleaseConditions(Long lessonId, Integer learnerId) { Lesson lesson = getLesson(lessonId); @@ -658,7 +664,7 @@ } return true; } - + @Override public Set getReleasedSucceedingLessons(Long completedLessonId, Integer learnerId) { Set releasedSucceedingLessons = new HashSet();