Index: lams_learning/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r298ac30bd04d6cdffdbbc42d1ceec29831809dc7 -r9f4048209accdf9125561d81be16ad32c833c812 --- lams_learning/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 298ac30bd04d6cdffdbbc42d1ceec29831809dc7) +++ lams_learning/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 9f4048209accdf9125561d81be16ad32c833c812) @@ -16,8 +16,8 @@ message.activity.parallel.partialComplete =You have to complete the other task before progressing to the next activity.... message.activity.parallel.noFrames =Your browser does not handle frames! message.activity.options.noActivitySelected =Please select an activity from the list -message.activity.options.activityCount =You must complete at least {0} out of {1} activities to finish. -message.activity.options.note =Note: Once you finish any of the above activities you can revisit them by using the progress bar or by clicking or by clicking on the activity name shown above. +message.activity.options.activityCount =You must complete at least {0} activities to finish. +message.activity.options.note =Note: You can revisit started or finished activities by using the progress bar or by clicking on the activity name shown below. label.activity.options.choose =Choose label.synch.gate.title =Synch gate label.synch.gate.message =You have stopped at a gate. You cannot continue until all of your group/class reach this point. @@ -60,10 +60,10 @@ label.sequence.empty.message =There are no activities to complete in this part of the lesson. Click Next to continue. label.my.progress =My Progress label.resume =Resume -message.activity.options.note.maximum =Note: The maximum number of activities you may attempt is {0}. You can revisit started or finished activities by using the progress bar or by clicking on the activity name shown above. -message.activity.set.options.activityCount =You must complete at least {0} out of {1} sequences to finish. -message.activity.set.options.note =Note: Once you finish any of the above sequences you can revisit them by using the progress bar. -message.activity.set.options.note.maximum =Note: The maximum number of sequences you may attempt is {0}. You can revisit started or finished sequences by using the progress bar. +message.activity.options.note.maximum =The maximum number of activities you may attempt is {0}. +message.activity.set.options.activityCount =You must complete at least {0} sequences to finish. +message.activity.set.options.note =Note: You can revisit started or finished sequences by using the progress bar. +message.activity.set.options.note.maximum =The maximum number of sequences you may attempt is {0}. label.learner.choice.group.full =Group full label.learner.choice.group.message =Please select a group. Some groups may not be available if they reached the maximum number of members. label.choose.group.button =Choose Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/controller/DisplayOptionsActivityController.java =================================================================== diff -u -r9825c35880ec88587666a5cf32a6fad2de9b3bab -r9f4048209accdf9125561d81be16ad32c833c812 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/controller/DisplayOptionsActivityController.java (.../DisplayOptionsActivityController.java) (revision 9825c35880ec88587666a5cf32a6fad2de9b3bab) +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/controller/DisplayOptionsActivityController.java (.../DisplayOptionsActivityController.java) (revision 9f4048209accdf9125561d81be16ad32c833c812) @@ -32,6 +32,8 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; +import org.hibernate.Hibernate; +import org.hibernate.proxy.HibernateProxy; import org.lamsfoundation.lams.learning.service.ILearnerFullService; import org.lamsfoundation.lams.learning.web.form.OptionsActivityForm; import org.lamsfoundation.lams.learning.web.util.ActivityMapping; @@ -88,23 +90,33 @@ List activityURLs = new ArrayList<>(); Set optionsChildActivities = optionsActivity.getActivities(); Iterator i = optionsChildActivities.iterator(); - int completedCount = 0; + int completedActivitiesCount = 0; while (i.hasNext()) { Activity optionsChildActivity = i.next(); ActivityURL activityURL = activityMapping.getActivityURL(learnerProgress, optionsChildActivity, false, false); if (activityURL.isComplete()) { - completedCount++; + completedActivitiesCount++; //create list of activityURLs of all children activities - if (optionsChildActivity instanceof SequenceActivity) { + if (optionsChildActivity.isSequenceActivity()) { activityURL.setUrl(null); + // activity is loaded as proxy due to lazy loading and in order to prevent quering DB we just re-initialize + // it here again + SequenceActivity optionsChildActivityInit; + Hibernate.initialize(activity); + if (optionsChildActivity instanceof HibernateProxy) { + optionsChildActivityInit = (SequenceActivity) ((HibernateProxy) optionsChildActivity).getHibernateLazyInitializer() + .getImplementation(); + } else { + optionsChildActivityInit = (SequenceActivity) optionsChildActivity; + } + List childActivities = new ArrayList<>(); - Set sequenceChildActivities = ((SequenceActivity) optionsChildActivity).getActivities(); - for (Activity sequenceChildActivity : sequenceChildActivities) { - ActivityURL sequenceActivityURL = activityMapping.getActivityURL(learnerProgress, - sequenceChildActivity, false, false); + for (Activity sequenceChildActivity : optionsChildActivityInit.getActivities()) { + ActivityURL sequenceActivityURL = activityMapping.getActivityURL( + learnerProgress, sequenceChildActivity, false, false); childActivities.add(sequenceActivityURL); } activityURL.setChildActivities(childActivities); @@ -114,16 +126,22 @@ } form.setActivityURLs(activityURLs); - if (optionsActivity.getMinNumberOfOptionsNotNull().intValue() <= completedCount) { - form.setFinished(true); + if (completedActivitiesCount >= optionsActivity.getMinNumberOfOptionsNotNull().intValue()) { + form.setMinimumLimitReached(true); } + + if (completedActivitiesCount > 0) { + form.setHasCompletedActivities(true); + } - if (completedCount >= optionsActivity.getMaxNumberOfOptionsNotNull().intValue()) { + if (completedActivitiesCount >= optionsActivity.getMaxNumberOfOptionsNotNull().intValue()) { form.setMaxActivitiesReached(true); } - form.setMinimum(optionsActivity.getMinNumberOfOptionsNotNull().intValue()); - form.setMaximum(optionsActivity.getMaxNumberOfOptionsNotNull().intValue()); + int minNumberOfOptions = optionsActivity.getMinNumberOfOptions() == null ? 0 : optionsActivity.getMinNumberOfOptions(); + form.setMinimum(minNumberOfOptions); + int maxNumberOfOptions = optionsActivity.getMaxNumberOfOptions() == null ? 0 : optionsActivity.getMaxNumberOfOptions(); + form.setMaximum(maxNumberOfOptions); form.setDescription(optionsActivity.getDescription()); form.setTitle(optionsActivity.getTitle()); form.setLessonID(learnerProgress.getLesson().getLessonId());