completedLearnerProgresses = learnerProgressDAO
+ .getCompletedLearnerProgressForLesson(lessonId);
for (LearnerProgress learnerProgress : completedLearnerProgresses) {
usersCompletedLesson.add(learnerProgress.getUser());
}
return usersCompletedLesson;
}
-
+
/**
* (non-Javadoc)
*
@@ -1797,42 +1842,44 @@
Vector progressData = new Vector();
Iterator iterator = lesson.getLearnerProgresses().iterator();
while (iterator.hasNext()) {
- LearnerProgress learnerProgress = (LearnerProgress) iterator.next();
- if(!completedDataOnly)
- progressData.add(learnerProgress.getLearnerProgressData());
- else
- progressData.add(learnerProgress.getLearnerProgressCompletedData());
+ LearnerProgress learnerProgress = (LearnerProgress) iterator.next();
+ if (!completedDataOnly) {
+ progressData.add(learnerProgress.getLearnerProgressData());
+ } else {
+ progressData.add(learnerProgress.getLearnerProgressCompletedData());
+ }
}
flashMessage = (!completedDataOnly) ? new FlashMessage("getAllLearnersProgress", progressData)
- : new FlashMessage("getAllCompletedActivities", progressData);
+ : new FlashMessage("getAllCompletedActivities", progressData);
} else {
flashMessage = new FlashMessage("getAllLearnersProgress", messageService.getMessage("NO.SUCH.LESSON",
new Object[] { lessonID }), FlashMessage.ERROR);
}
return flashMessage.serializeMessage();
}
-
+
public String getAllCompletedActivities(Long lessonID, Long learnerID, Integer userID) throws IOException {
- Lesson lesson = lessonDAO.getLesson(lessonID);
- FlashMessage flashMessage;
+ Lesson lesson = lessonDAO.getLesson(lessonID);
+ FlashMessage flashMessage;
- if (lesson != null) {
- checkOwnerOrStaffMember(userID, lesson, "get all learners progress");
- Vector progressData = new Vector();
-
- if(learnerID != null) {
- LearnerProgress learnerProgress = learnerService.getProgress(new Integer(learnerID.intValue()), lessonID);
- progressData.add(learnerProgress.getLearnerProgressCompletedData());
- flashMessage = new FlashMessage("getAllCompletedActivities", progressData);
- } else {
- return getAllLearnersProgress(lessonID, userID, true);
- }
-
- } else {
- flashMessage = new FlashMessage("getAllCompletedActivities", messageService.getMessage("NO.SUCH.LESSON",
- new Object[] { lessonID }), FlashMessage.ERROR);
- }
- return flashMessage.serializeMessage();
+ if (lesson != null) {
+ checkOwnerOrStaffMember(userID, lesson, "get all learners progress");
+ Vector progressData = new Vector();
+
+ if (learnerID != null) {
+ LearnerProgress learnerProgress = learnerService.getProgress(new Integer(learnerID.intValue()),
+ lessonID);
+ progressData.add(learnerProgress.getLearnerProgressCompletedData());
+ flashMessage = new FlashMessage("getAllCompletedActivities", progressData);
+ } else {
+ return getAllLearnersProgress(lessonID, userID, true);
+ }
+
+ } else {
+ flashMessage = new FlashMessage("getAllCompletedActivities", messageService.getMessage("NO.SUCH.LESSON",
+ new Object[] { lessonID }), FlashMessage.ERROR);
+ }
+ return flashMessage.serializeMessage();
}
/**
@@ -1912,8 +1959,7 @@
}
/**
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityById(Long,
- * Class)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#getActivityById(Long, Class)
*/
public Activity getActivityById(Long activityId, Class clasz) {
return activityDAO.getActivityByActivityId(activityId, clasz);
@@ -1986,7 +2032,7 @@
User learner = (User) baseDAO.find(User.class, learnerUserID);
String url = null;
- if (activity == null || learner == null) {
+ if ((activity == null) || (learner == null)) {
MonitoringService.log.error("getLearnerActivityURL activity or user missing. Activity ID " + activityID
+ " activity " + activity + " userID " + learnerUserID + " user " + learner);
} else if (activity.isToolActivity()) {
@@ -2050,8 +2096,8 @@
/**
* (non-Javadoc)
*
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#moveLesson(java.lang.Long,
- * java.lang.Integer, java.lang.Integer)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#moveLesson(java.lang.Long, java.lang.Integer,
+ * java.lang.Integer)
*/
public String moveLesson(Long lessonID, Integer targetWorkspaceFolderID, Integer userID) throws IOException {
Lesson lesson = lessonDAO.getLesson(lessonID);
@@ -2083,8 +2129,8 @@
/**
* (non-Javadoc)
*
- * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#renameLesson(java.lang.Long,
- * java.lang.String, java.lang.Integer)
+ * @see org.lamsfoundation.lams.monitoring.service.IMonitoringService#renameLesson(java.lang.Long, java.lang.String,
+ * java.lang.Integer)
*/
public String renameLesson(Long lessonID, String newName, Integer userID) throws IOException {
Lesson lesson = lessonDAO.getLesson(lessonID);
@@ -2116,7 +2162,7 @@
Lesson lesson = lessonDAO.getLesson(lessonID); // used to calculate the
// total learners.
- if (gate == null || lesson == null) {
+ if ((gate == null) || (lesson == null)) {
flashMessage = new FlashMessage("checkGateStatus", messageService.getMessage("INVALID.ACTIVITYID.LESSONID",
new Object[] { activityID, lessonID }), FlashMessage.ERROR);
} else {
@@ -2208,8 +2254,7 @@
// Helper Methods - create lesson
// ---------------------------------------------------------------------
/**
- * Create a new lesson and setup all the staffs and learners who will be
- * participating this less.
+ * Create a new lesson and setup all the staffs and learners who will be participating this less.
*
* @param organisation
* the organization this lesson belongs to.
@@ -2270,14 +2315,13 @@
precedingLessons.add(precedingLesson);
newLesson.setPrecedingLessons(precedingLessons);
}
-
+
lessonDAO.saveLesson(newLesson);
return newLesson;
}
/**
- * Setup the empty lesson class according to the run-time learning design
- * copy.
+ * Setup the empty lesson class according to the run-time learning design copy.
*
* @param copiedLearningDesign
* the run-time learning design instance.
@@ -2298,11 +2342,10 @@
// ---------------------------------------------------------------------
/**
- * If the activity is not grouped and not in a branch, then it create lams
- * tool session for all the learners in the lesson. After the creation of
- * lams tool session, it delegates to the tool instances to create tool's
- * own tool session. Can't create it for a grouped activity or an activity
- * in a branch as it may not be applicable to all users.
+ * If the activity is not grouped and not in a branch, then it create lams tool session for all the learners in the
+ * lesson. After the creation of lams tool session, it delegates to the tool instances to create tool's own tool
+ * session. Can't create it for a grouped activity or an activity in a branch as it may not be applicable to all
+ * users.
*
*
* @param activity
@@ -2313,7 +2356,7 @@
* the exception when lams is talking to tool.
*/
public void initToolSessionIfSuitable(ToolActivity activity, Lesson lesson) {
- if (activity.getApplyGrouping().equals(Boolean.FALSE) && activity.getParentBranch() == null) {
+ if (activity.getApplyGrouping().equals(Boolean.FALSE) && (activity.getParentBranch() == null)) {
activity.setToolSessions(new HashSet());
try {
@@ -2426,11 +2469,9 @@
}
/**
- * Delete a preview lesson and all its contents. Warning: can only delete
- * preview lessons. Can't guarentee data integrity if it is done to any
- * other type of lesson. See removeLesson() for hiding lessons from a
- * teacher's view without removing them from the database. TODO remove the
- * related tool data.
+ * Delete a preview lesson and all its contents. Warning: can only delete preview lessons. Can't guarentee data
+ * integrity if it is done to any other type of lesson. See removeLesson() for hiding lessons from a teacher's view
+ * without removing them from the database. TODO remove the related tool data.
*/
public void deletePreviewLesson(long lessonID) {
Lesson lesson = lessonDAO.getLesson(new Long(lessonID));
@@ -2444,7 +2485,7 @@
// get all the tool sessions for this lesson and remove all the
// tool session data
List toolSessions = lamsCoreToolService.getToolSessionsByLesson(lesson);
- if (toolSessions != null && toolSessions.size() > 0) {
+ if ((toolSessions != null) && (toolSessions.size() > 0)) {
Iterator iter = toolSessions.iterator();
while (iter.hasNext()) {
ToolSession toolSession = (ToolSession) iter.next();
@@ -2516,19 +2557,16 @@
/**
* Get all the active learners in the lesson who are not in a group/branch
*
- * If the activity is a grouping activity, then set useCreatingGrouping =
- * true to base the list on the create grouping. Otherwise leave it false
- * and it will use the grouping applied to the activity - this is used for
+ * If the activity is a grouping activity, then set useCreatingGrouping = true to base the list on the create
+ * grouping. Otherwise leave it false and it will use the grouping applied to the activity - this is used for
* branching activities.
*
- * TODO Optimise the database query. Do a single query rather then large
- * collection access
+ * TODO Optimise the database query. Do a single query rather then large collection access
*
* @param activityID
* @param lessonID
* @param useCreateGrouping
- * true/false for GroupingActivities, always false for
- * non-GroupingActivities
+ * true/false for GroupingActivities, always false for non-GroupingActivities
* @return Sorted set of Users, sorted by surname
*/
public SortedSet getClassMembersNotGrouped(Long lessonID, Long activityID, boolean useCreateGrouping) {
@@ -2575,16 +2613,14 @@
/**
* Get the grouping appropriate for this activity.
*
- * If the activity is a grouping activity, then set useCreatingGrouping =
- * true to base the list on the create grouping. Otherwise leave it false
- * and it will use the grouping applied to the activity - this is used for
+ * If the activity is a grouping activity, then set useCreatingGrouping = true to base the list on the create
+ * grouping. Otherwise leave it false and it will use the grouping applied to the activity - this is used for
* branching activities.
*
- * If it is a teacher chosen branching activity and the grouping doesn't
- * exist, it creates one.
+ * If it is a teacher chosen branching activity and the grouping doesn't exist, it creates one.
*/
private Grouping getGroupingForActivity(Activity activity, boolean useCreateGrouping, String methodName) {
- if (useCreateGrouping && (activity == null || !activity.isGroupingActivity())) {
+ if (useCreateGrouping && ((activity == null) || !activity.isGroupingActivity())) {
String error = methodName
+ ": Trying to use the create grouping option but the activity isn't a grouping activity. Activity was "
+ activity;
@@ -2610,14 +2646,12 @@
}
/**
- * Add a new group to a grouping activity. If name already exists or the
- * name is blank, does not add a new group. If the activity is a grouping
- * activity, then set useCreatingGrouping = true to base the list on the
- * create grouping. Otherwise leave it false and it will use the grouping
- * applied to the activity - this is used for branching activities.
+ * Add a new group to a grouping activity. If name already exists or the name is blank, does not add a new group. If
+ * the activity is a grouping activity, then set useCreatingGrouping = true to base the list on the create grouping.
+ * Otherwise leave it false and it will use the grouping applied to the activity - this is used for branching
+ * activities.
*
- * If it is a teacher chosen branching activity and the grouping doesn't
- * exist, it creates one.
+ * If it is a teacher chosen branching activity and the grouping doesn't exist, it creates one.
*
* @param activityID
* id of the grouping activity
@@ -2634,8 +2668,9 @@
// Is this grouping used for branching. If it is, must honour the
// groups
// set in authoring or some groups won't have a branch.
- if (grouping.getMaxNumberOfGroups() != null && grouping.getMaxNumberOfGroups() > 0
- && grouping.getGroups() != null && grouping.getGroups().size() >= grouping.getMaxNumberOfGroups()) {
+ if ((grouping.getMaxNumberOfGroups() != null) && (grouping.getMaxNumberOfGroups() > 0)
+ && (grouping.getGroups() != null)
+ && (grouping.getGroups().size() >= grouping.getMaxNumberOfGroups())) {
boolean usedForBranching = grouping.isUsedForBranching();
if (!usedForBranching) {
MonitoringService.log
@@ -2660,17 +2695,14 @@
}
/**
- * Remove a group to from a grouping activity. If the group does not exists
- * then nothing happens. If the group is already used (e.g. a tool session
- * exists) then it throws a LessonServiceException.
+ * Remove a group to from a grouping activity. If the group does not exists then nothing happens. If the group is
+ * already used (e.g. a tool session exists) then it throws a LessonServiceException.
*
- * If the activity is a grouping activity, then set useCreatingGrouping =
- * true to base the list on the create grouping. Otherwise leave it false
- * and it will use the grouping applied to the activity - this is used for
+ * If the activity is a grouping activity, then set useCreatingGrouping = true to base the list on the create
+ * grouping. Otherwise leave it false and it will use the grouping applied to the activity - this is used for
* branching activities.
*
- * If it is a teacher chosen branching activity and the grouping doesn't
- * exist, it creates one.
+ * If it is a teacher chosen branching activity and the grouping doesn't exist, it creates one.
*
* @param activityID
* id of the grouping activity
@@ -2685,8 +2717,7 @@
}
/**
- * Add learners to a group. Doesn't necessarily check if the user is already
- * in another group.
+ * Add learners to a group. Doesn't necessarily check if the user is already in another group.
*/
public void addUsersToGroup(Long activityID, Long groupId, String learnerIDs[]) throws LessonServiceException {
Activity activity = getActivityById(activityID);
@@ -2719,10 +2750,9 @@
}
/**
- * Add learners to a branch. Doesn't necessarily check if the user is
- * already in another branch. Assumes there should only be one group for
- * this branch. Use for Teacher Chosen Branching. Don't use for Group Based
- * Branching as there could be more than one group for the branch.
+ * Add learners to a branch. Doesn't necessarily check if the user is already in another branch. Assumes there
+ * should only be one group for this branch. Use for Teacher Chosen Branching. Don't use for Group Based Branching
+ * as there could be more than one group for the branch.
*
* @param sequenceActivityID
* Activity id of the sequenceActivity representing this branch
@@ -2743,7 +2773,7 @@
if (group == null) {
// create a new group and a matching mapping entry
Activity parentActivity = branch.getParentActivity();
- if (parentActivity == null || !parentActivity.isBranchingActivity()) {
+ if ((parentActivity == null) || !parentActivity.isBranchingActivity()) {
String error = "addUsersToBranch: Branching activity missing or not a branching activity. Branch was "
+ branch + " parent activity was " + parentActivity;
MonitoringService.log.error(error);
@@ -2778,8 +2808,7 @@
}
/**
- * Remove a user to a group. If the user is not in the group, then nothing
- * is changed.
+ * Remove a user to a group. If the user is not in the group, then nothing is changed.
*
* @throws LessonServiceException
*/
@@ -2791,9 +2820,8 @@
}
/**
- * Remove learners from a branch. Assumes there should only be one group for
- * this branch. Use for Teacher Chosen Branching. Don't use for Group Based
- * Branching as there could be more than one group for the branch.
+ * Remove learners from a branch. Assumes there should only be one group for this branch. Use for Teacher Chosen
+ * Branching. Don't use for Group Based Branching as there could be more than one group for the branch.
*
* @param sequenceActivityID
* Activity id of the sequenceActivity representing this branch
@@ -2823,9 +2851,8 @@
}
/**
- * Match group(s) to a branch. Doesn't necessarily check if the group is
- * already assigned to another branch. Use for Group Based Branching and
- * define later.
+ * Match group(s) to a branch. Doesn't necessarily check if the group is already assigned to another branch. Use for
+ * Group Based Branching and define later.
*
* @param sequenceActivityID
* Activity id of the sequenceActivity representing this branch
@@ -2842,7 +2869,7 @@
}
Activity parentActivity = branch.getParentActivity();
- if (parentActivity == null || !parentActivity.isBranchingActivity()) {
+ if ((parentActivity == null) || !parentActivity.isBranchingActivity()) {
String error = "addUsersToBranch: Branching activity missing or not a branching activity. Branch was "
+ branch + " parent activity was " + parentActivity;
MonitoringService.log.error(error);
@@ -2859,7 +2886,7 @@
Group group = null;
Iterator groupIterator = grouping.getGroups().iterator();
- while (groupIterator.hasNext() && group == null) {
+ while (groupIterator.hasNext() && (group == null)) {
Group obj = (Group) groupIterator.next();
if (obj.getGroupId().equals(groupID)) {
group = obj;
@@ -2881,8 +2908,8 @@
}
/**
- * Remove group / branch mapping. Cannot be done if any users in the group
- * have started the branch. Used for group based branching in define later.
+ * Remove group / branch mapping. Cannot be done if any users in the group have started the branch. Used for group
+ * based branching in define later.
*
* @param sequenceActivityID
* Activity id of the sequenceActivity representing this branch
@@ -2899,7 +2926,7 @@
}
Activity parentActivity = branch.getParentActivity();
- if (parentActivity == null || !parentActivity.isBranchingActivity()) {
+ if ((parentActivity == null) || !parentActivity.isBranchingActivity()) {
String error = "addUsersToBranch: Branching activity missing or not a branching activity. Branch was "
+ branch + " parent activity was " + parentActivity;
MonitoringService.log.error(error);
@@ -2913,7 +2940,7 @@
Group group = null;
Iterator groupIterator = grouping.getGroups().iterator();
- while (groupIterator.hasNext() && group == null) {
+ while (groupIterator.hasNext() && (group == null)) {
Group obj = (Group) groupIterator.next();
if (obj.getGroupId().equals(groupID)) {
group = obj;
@@ -2940,21 +2967,20 @@
}
/**
- * Has anyone started this branch / branching activity ? Irrespective of the
- * groups. Used to determine if a branch mapping can be removed.
+ * Has anyone started this branch / branching activity ? Irrespective of the groups. Used to determine if a branch
+ * mapping can be removed.
*/
public boolean isActivityAttempted(Activity activity) {
Integer numAttempted = lessonService.getCountLearnersHaveAttemptedActivity(activity);
if (MonitoringService.log.isDebugEnabled()) {
MonitoringService.log.debug("isActivityAttempted: num attempts for activity " + activity.getActivityId()
+ " is " + numAttempted);
}
- return numAttempted != null && numAttempted.intValue() > 0;
+ return (numAttempted != null) && (numAttempted.intValue() > 0);
}
/**
- * Get all the groups that exist for the related grouping activity that have
- * not been allocated to a branch.
+ * Get all the groups that exist for the related grouping activity that have not been allocated to a branch.
*
* @param branchingActivityID
* Activity id of the branchingActivity
@@ -2975,7 +3001,7 @@
Iterator groupIterator = grouping.getGroups().iterator();
while (groupIterator.hasNext()) {
Group group = (Group) groupIterator.next();
- if (group.getBranchActivities() == null || group.getBranchActivities().size() == 0) {
+ if ((group.getBranchActivities() == null) || (group.getBranchActivities().size() == 0)) {
unassignedGroups.add(group);
}
}
@@ -2985,11 +3011,9 @@
}
/**
- * Get the list of users who have attempted an activity. This is based on
- * the progress engine records. This will give the users in all tool
- * sessions for an activity (if it is a tool activity) or it will give all
- * the users who have attempted an activity that doesn't have any tool
- * sessions, i.e. system activities such as branching.
+ * Get the list of users who have attempted an activity. This is based on the progress engine records. This will
+ * give the users in all tool sessions for an activity (if it is a tool activity) or it will give all the users who
+ * have attempted an activity that doesn't have any tool sessions, i.e. system activities such as branching.
*/
public List getLearnersHaveAttemptedActivity(Activity activity) throws LessonServiceException {
return lessonService.getLearnersHaveAttemptedActivity(activity);
@@ -2998,21 +3022,21 @@
public LearnerProgress getLearnerProgress(Integer learnerId, Long lessonId) {
return learnerService.getProgress(learnerId, lessonId);
}
-
+
/**
* Set a group's name
*/
- public void setGroupName(Long groupID, String name) {
- Group group = groupDAO.getGroupById(groupID);
- group.setGroupName(name);
- groupDAO.saveGroup(group);
- }
-
- public Organisation getOrganisation(Integer organisationId) {
- return (Organisation) baseDAO.find(Organisation.class, organisationId);
- }
-
- /**
+ public void setGroupName(Long groupID, String name) {
+ Group group = groupDAO.getGroupById(groupID);
+ group.setGroupName(name);
+ groupDAO.saveGroup(group);
+ }
+
+ public Organisation getOrganisation(Integer organisationId) {
+ return (Organisation) baseDAO.find(Organisation.class, organisationId);
+ }
+
+ /**
* Used in admin to clone lessons using the given lesson Ids (from another group) into the given group. Given staff
* and learner ids should already be members of the group.
*
@@ -3035,12 +3059,12 @@
if (ss != null) {
UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
if (userDto != null) {
- if ((!addAllStaff && staffIds.length > 0) || addAllStaff) {
+ if ((!addAllStaff && (staffIds.length > 0)) || addAllStaff) {
// create staff LessonClass
String staffGroupName = group.getName() + " Staff";
List staffUsers = createStaffGroup(group.getOrganisationId(), addAllStaff, staffIds);
- if ((!addAllLearners && learnerIds.length > 0) || addAllLearners) {
+ if ((!addAllLearners && (learnerIds.length > 0)) || addAllLearners) {
// create learner LessonClass for lesson
String learnerGroupName = group.getName() + " Learners";
List learnerUsers = createLearnerGroup(group.getOrganisationId(), addAllLearners,
@@ -3098,7 +3122,7 @@
if (user != null) {
learnerUsers.add(user);
} else {
- log.error("Couldn't find User based on id=" + l);
+ MonitoringService.log.error("Couldn't find User based on id=" + l);
}
}
}
@@ -3121,7 +3145,7 @@
if (user != null) {
staffUsers.add(user);
} else {
- log.error("Couldn't find User based on id=" + s);
+ MonitoringService.log.error("Couldn't find User based on id=" + s);
}
}
}
Index: lams_monitoring/web/includes/javascript/monitorLesson.js
===================================================================
diff -u -rc26bfcb6f8502515eef2c55bba123cb39ce1ccb7 -r1880a97b5b0f4069139be31a76a710740ba992bd
--- lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision c26bfcb6f8502515eef2c55bba123cb39ce1ccb7)
+++ lams_monitoring/web/includes/javascript/monitorLesson.js (.../monitorLesson.js) (revision 1880a97b5b0f4069139be31a76a710740ba992bd)
@@ -494,35 +494,16 @@
executeForceComplete = confirm(FORCE_COMPLETE_END_LESSON_CONFIRM_LABEL
.replace('[0]',learnerName));
} else {
- var targetActivityId = act.parent().attr('id');
+ var transitionLine = $('line[id$="to_'
+ + act.parent().attr('id') + '"]:not([id^="arrow"])'
+ , sequenceCanvas);
+ // if move to start of sequence, the value is -1
+ previousActivityId = transitionLine.length == 1 ?
+ transitionLine.attr('id').split('_')[0] : -1;
+
var targetActivityName = act.siblings('text[id^="TextElement"]').text();
-
- // find if it is not already completed/current activity - it is forbidden
- var precedingActivityId = targetActivityId;
- // move step by step to the sequence beginning
- // if current activity is found, it is a activity still in front, so it's OK
- do {
- // find transition line and extract activity IDs from them
- var transitionLine = $('line[id$="to_'
- + precedingActivityId + '"]:not([id^="arrow"])'
- , sequenceCanvas);
- precedingActivityId = transitionLine.length == 1 ?
- transitionLine.attr('id').split('_')[0] : null;
- if (previousActivityId == null) {
- previousActivityId = precedingActivityId;
- }
- if (precedingActivityId == currentActivityId) {
- break;
- }
- } while (precedingActivityId);
-
- if (precedingActivityId) {
- executeForceComplete = confirm(FORCE_COMPLETE_ACTIVITY_CONFIRM_LABEL
+ executeForceComplete = confirm(FORCE_COMPLETE_ACTIVITY_CONFIRM_LABEL
.replace('[0]', learnerName).replace('[1]', targetActivityName));
- } else {
- alert(FORCE_COMPLETE_DROP_FAIL_LABEL
- .replace('[0]', learnerName).replace('[1]', targetActivityName));
- }
}
if (executeForceComplete) {