Index: lams_build/lib/lams/lams.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams.jar,v diff -u -r1.400 -r1.401 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java,v diff -u -r1.22 -r1.23 --- lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java 17 Jan 2014 22:37:08 -0000 1.22 +++ lams_common/src/java/org/lamsfoundation/lams/tool/ToolContentManager.java 2 Feb 2014 17:18:38 -0000 1.23 @@ -76,6 +76,11 @@ */ public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException; + + /** + * Removes content previously added by the given user. + */ + public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException; /** * Export the XML fragment for the tool's content, along with any files needed for the content. Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java,v diff -u -r1.25 -r1.26 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java 17 Jan 2014 22:37:09 -0000 1.25 +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/ILamsCoreToolService.java 2 Feb 2014 17:18:38 -0000 1.26 @@ -176,8 +176,13 @@ * @throws ToolException */ public void notifyToolToDeleteContent(ToolActivity toolActivity) throws ToolException; - + /** + * Ask a tool to delete content entered by the given user, if exists. + */ + public void notifyToolToDeleteLearnerContent(ToolActivity toolActivity, Integer userId) throws ToolException; + + /** * Ask a tool for its OutputDefinitions, based on the given toolContentId. If the tool doesn't have any content * matching the toolContentId then it should create the OutputDefinitions based on the tool's default content. * Index: lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java,v diff -u -r1.41 -r1.42 --- lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java 17 Jan 2014 22:37:09 -0000 1.41 +++ lams_common/src/java/org/lamsfoundation/lams/tool/service/LamsCoreToolService.java 2 Feb 2014 17:18:38 -0000 1.42 @@ -268,6 +268,19 @@ throw new ToolException(message, e); } } + + @Override + public void notifyToolToDeleteLearnerContent(ToolActivity toolActivity, Integer userId) throws ToolException { + try { + ToolContentManager contentManager = (ToolContentManager) findToolService(toolActivity.getTool()); + contentManager.removeLearnerContent(toolActivity.getToolContentId(), userId); + } catch (NoSuchBeanDefinitionException e) { + String message = "A tool which is defined in the database appears to missing from the classpath. Unable to delete learner content. ToolActivity " + + toolActivity; + LamsCoreToolService.log.error(message, e); + throw new ToolException(message, e); + } + } @Override public SortedMap getOutputDefinitionsFromTool(Long toolContentId, int definitionType) Index: lams_monitoring/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/conf/language/lams/ApplicationResources.properties,v diff -u -r1.61 -r1.62 --- lams_monitoring/conf/language/lams/ApplicationResources.properties 27 Dec 2013 13:40:26 -0000 1.61 +++ lams_monitoring/conf/language/lams/ApplicationResources.properties 2 Feb 2014 17:18:46 -0000 1.62 @@ -279,6 +279,9 @@ force.complete.click =Click on an activity to move learner "[0]" or outside any activity to cancel. force.complete.end.lesson.confirm =Are you sure you want to move learner "[0]" to the end of lesson? force.complete.activity.confirm =Are you sure you want to move learner "[0]" to activity "[1]"? +force.complete.remove.content =You are moving learner "[0]" to activity "[1]". You can opt to delete the content of activities that have been previously done, so the learner has to enter the content/answers again. +force.complete.remove.content.yes =Delete content +force.complete.remove.content.no =Keep content force.complete.drop.fail =You have dropped the learner "[0]" on either its current or on its completed activity "[1]". force.complete.end.lesson.tooltip =To move a learner to the end of lesson, drag the learner icon over to this bar. learner.group.list.title =Learners: Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringConstants.java,v diff -u -r1.19 -r1.20 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringConstants.java 27 Aug 2013 16:15:14 -0000 1.19 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringConstants.java 2 Feb 2014 17:18:46 -0000 1.20 @@ -41,6 +41,7 @@ public static final String PARAM_LESSON_START_DATE = "lessonStartDate"; public static final String PARAM_SCHEDULED_NUMBER_DAYS_TO_LESSON_FINISH = "scheduledNumberDaysToLessonFinish"; public static final String PARAM_LEARNER_ID = "learnerID"; + public static final String PARAM_REMOVE_LEARNER_CONTENT = "removeContent"; public static final String KEY_GROUPING_ACTIVITY = "groupingActivityID"; public static final String KEY_GROUPS = "groups"; public static final String KEY_GROUP_NAME = "groupName"; Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v diff -u -r1.108 -r1.109 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 27 Jan 2014 14:17:00 -0000 1.108 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 2 Feb 2014 17:18:47 -0000 1.109 @@ -75,8 +75,8 @@ public Lesson initializeLessonWithoutLDcopy(String lessonName, String lessonDescription, long learningDesignID, User user, String customCSV, Boolean enableLessonIntro, Boolean displayDesignImage, Boolean learnerExportAvailable, Boolean learnerPresenceAvailable, Boolean learnerImAvailable, - Boolean liveEditEnabled, Boolean enableLessonNotifications, Boolean learnerRestart, Integer scheduledNumberDaysToLessonFinish, - Lesson precedingLesson); + Boolean liveEditEnabled, Boolean enableLessonNotifications, Boolean learnerRestart, + Integer scheduledNumberDaysToLessonFinish, Lesson precedingLesson); /** * Initialize a new lesson so as to start the learning process. It needs to notify lams which learning design it @@ -281,7 +281,8 @@ */ public Boolean setLiveEditEnabled(long lessonId, Integer userId, Boolean liveEditEnabled); - public String forceCompleteActivitiesByUser(Integer learnerId, Integer requesterId, long lessonId, Long activityId); + public String forceCompleteActivitiesByUser(Integer learnerId, Integer requesterId, long lessonId, Long activityId, + boolean removeLearnerContent); /** * Archive the specified lesson. When archived, the data is retained but the learners cannot access the details. @@ -425,7 +426,7 @@ * @throws IOException */ public String getLearningDesignDetails(Long lessonID) throws IOException; - + public List getAllContributeActivityDTO(Long lessonID); /** Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v diff -u -r1.189 -r1.190 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 27 Jan 2014 14:17:00 -0000 1.189 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 2 Feb 2014 17:18:46 -0000 1.190 @@ -1274,7 +1274,8 @@ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#forceCompleteLessonByUser(Integer,long,long) */ @Override - public String forceCompleteActivitiesByUser(Integer learnerId, Integer requesterId, long lessonId, Long activityId) { + public String forceCompleteActivitiesByUser(Integer learnerId, Integer requesterId, long lessonId, Long activityId, + boolean removeLearnerContent) { Lesson lesson = lessonDAO.getLesson(new Long(lessonId)); checkOwnerOrStaffMember(requesterId, lesson, "force complete"); @@ -1308,7 +1309,7 @@ .getCompletedActivities().containsKey(parentActivity) || ((parentActivity .getParentActivity() != null) && learnerProgress.getCompletedActivities().containsKey( parentActivity.getParentActivity())))))) { - return forceUncompleteActivity(learnerProgress, stopActivity); + return forceUncompleteActivity(learnerProgress, stopActivity, removeLearnerContent); } } @@ -1496,20 +1497,23 @@ * achieve it. */ @SuppressWarnings("unchecked") - private String forceUncompleteActivity(LearnerProgress learnerProgress, Activity targetActivity) { + private String forceUncompleteActivity(LearnerProgress learnerProgress, Activity targetActivity, + boolean removeLearnerContent) { User learner = learnerProgress.getUser(); Activity currentActivity = learnerProgress.getCurrentActivity(); + // set of activities for which "attempted" and "completed" status will be removed + Set uncompleteActivities = new HashSet(); + uncompleteActivities.add(targetActivity); + if (currentActivity == null) { // Learner has finished the whole lesson. Find the last activity by traversing the transition. currentActivity = learnerProgress.getLesson().getLearningDesign().getFirstActivity(); while (currentActivity.getTransitionFrom() != null) { currentActivity = currentActivity.getTransitionFrom().getToActivity(); } + uncompleteActivities.add(currentActivity); } - // set of activities for which "attempted" and "completed" status will be removed - Set uncompleteActivities = new HashSet(); - // check if the target is a part of complex activity CompletedActivityProgress completedActivityProgress = learnerProgress.getCompletedActivities().get( targetActivity); @@ -1547,7 +1551,7 @@ Set groupings = new HashSet(); // remove completed activities step by step, all the way from current to target activity - do { + while (!currentActivity.equals(targetActivity)) { uncompleteActivities.add(currentActivity); if (currentActivity.isComplexActivity()) { @@ -1600,17 +1604,19 @@ groupings.add(currentActivity); } } + } - } while (!currentActivity.equals(targetActivity)); - // forget that user completed and attempted activiites for (Activity activity : uncompleteActivities) { learnerProgress.getAttemptedActivities().remove(activity); learnerProgress.getCompletedActivities().remove(activity); + if (removeLearnerContent && activity.isToolActivity()) { + // remove learner content from this activity + lamsCoreToolService.notifyToolToDeleteLearnerContent((ToolActivity) activity, learner.getUserId()); + } } // set target activity as attempted - learnerProgress.getCompletedActivities().remove(targetActivity); learnerProgress.getAttemptedActivities().put(targetActivity, completedActivityProgress.getStartDate()); if (targetParentActivity != null) { // set parent as attempted 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.111 -r1.112 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 27 Jan 2014 14:16:59 -0000 1.111 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 2 Feb 2014 17:18:46 -0000 1.112 @@ -201,8 +201,8 @@ Boolean liveEditEnabled = WebUtil.readBooleanParam(request, "liveEditEnabled", false); Boolean learnerRestart = WebUtil.readBooleanParam(request, "learnerRestart", false); Lesson newLesson = monitoringService.initializeLesson(title, desc, ldId, organisationId, getUserId(), null, - false, false, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, - liveEditEnabled, false, learnerRestart, null, null); + false, false, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, liveEditEnabled, + false, learnerRestart, null, null); PrintWriter writer = response.getWriter(); writer.println(newLesson.getLessonId()); @@ -549,8 +549,11 @@ long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); Integer learnerId = new Integer(WebUtil.readIntParam(request, MonitoringConstants.PARAM_LEARNER_ID)); Integer requesterId = getUserId(); + boolean removeLearnerContent = WebUtil.readBooleanParam(request, + MonitoringConstants.PARAM_REMOVE_LEARNER_CONTENT, false); - String message = monitoringService.forceCompleteActivitiesByUser(learnerId, requesterId, lessonId, activityId); + String message = monitoringService.forceCompleteActivitiesByUser(learnerId, requesterId, lessonId, activityId, + removeLearnerContent); if (LamsDispatchAction.log.isDebugEnabled()) { LamsDispatchAction.log.debug("Force complete for learner " + learnerId + " lesson " + lessonId + ". " Index: lams_monitoring/web/monitor.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/monitor.jsp,v diff -u -r1.23 -r1.24 --- lams_monitoring/web/monitor.jsp 17 Jan 2014 22:37:13 -0000 1.23 +++ lams_monitoring/web/monitor.jsp 2 Feb 2014 17:18:46 -0000 1.24 @@ -21,64 +21,69 @@