learners) throws GroupingException {
+ Set groups = grouping.getGroups();
+ Iterator iter = groups.iterator();
+ boolean groupFound = false;
- if ( groupID == null || groupID.equals(group.getGroupId()) ) {
-
- groupFound = groupID != null;
+ while (iter.hasNext() && !groupFound) {
+ Group group = (Group) iter.next();
- if ( group.mayBeDeleted() ) {
-
- boolean removed = group.getUsers().removeAll(learners);
- if ( removed ) {
- if ( log.isDebugEnabled() ) {
- log.debug("Removed "+learners.size()+" users from group "+group.getGroupName());
- }
- }
-
- } else {
- String error = "Tried to remove a group which cannot be removed (tool sessions probably exist). Group "+group+" grouping "+grouping+". Not removing the group.";
- log.error(error);
- throw new GroupingException(error);
- }
-
+ if (groupID == null || groupID.equals(group.getGroupId())) {
+
+ groupFound = groupID != null;
+
+ if (group.mayBeDeleted()) {
+
+ boolean removed = group.getUsers().removeAll(learners);
+ if (removed) {
+ if (log.isDebugEnabled()) {
+ log.debug("Removed " + learners.size() + " users from group " + group.getGroupName());
}
+ }
+
+ } else {
+ String error = "Tried to remove a group which cannot be removed (tool sessions probably exist). Group "
+ + group + " grouping " + grouping + ". Not removing the group.";
+ log.error(error);
+ throw new GroupingException(error);
}
+
+ }
+ }
}
- /**
- * Create an empty group for the given grouping. Trims the name of the group before creating the group.
- * If the group name group name already exists then it appends a datetime string to make the name unique. Gives
- * it 5 attempts to make it unique then gives up.
+ /**
+ * Create an empty group for the given grouping. Trims the name of the group before creating the group. If the group
+ * name group name already exists then it appends a datetime string to make the name unique. Gives it 5 attempts to
+ * make it unique then gives up.
*
* Throws a GroupingException if name is null or blank.
*
- * @param grouping (mandatory)
- * @param name (mandatory)
- * @param forceName (mandatory)
+ * @param grouping
+ * (mandatory)
+ * @param name
+ * (mandatory)
+ * @param forceName
+ * (mandatory)
*/
- public Group createGroup(Grouping grouping, String name) throws GroupingException
- {
- String trimmedName = name.trim();
- if ( trimmedName == null || trimmedName.length()==0 ) {
- log.warn("Tried to add a group with no name to grouping "+grouping+". Not creating group.");
- return null;
- }
- Set emptySet = new HashSet();
- Group newGroup = Group.createLearnerGroup(grouping,trimmedName,emptySet);
-
- if ( newGroup == null ) {
- trimmedName = trimmedName + " " + new Long(System.currentTimeMillis()).toString();
- newGroup = Group.createLearnerGroup(grouping, trimmedName, emptySet);
- }
+ public Group createGroup(Grouping grouping, String name) throws GroupingException {
+ String trimmedName = name.trim();
+ if (trimmedName == null || trimmedName.length() == 0) {
+ log.warn("Tried to add a group with no name to grouping " + grouping + ". Not creating group.");
+ return null;
+ }
+ Set emptySet = new HashSet();
+ Group newGroup = Group.createLearnerGroup(grouping, trimmedName, emptySet);
- if ( newGroup == null ) {
- // what, still not unique? Okay try sticking a number on the end. Try 5 times then give up
- log.warn("Having trouble creating a unique name for a group. Have tried "+trimmedName);
- int attempt = 1;
- while ( newGroup == null && attempt < 5) {
- newGroup = Group.createLearnerGroup(grouping, trimmedName+" "+new Integer(attempt).toString(), emptySet);
- }
- if ( newGroup == null ) {
- String error = "Unable to create a unique name for a group. Tried 5 variations on "+trimmedName+" now giving up.";
- log.error(error);
- throw new GroupingException(error);
+ if (newGroup == null) {
+ trimmedName = trimmedName + " " + new Long(System.currentTimeMillis()).toString();
+ newGroup = Group.createLearnerGroup(grouping, trimmedName, emptySet);
+ }
- }
- }
+ if (newGroup == null) {
+ // what, still not unique? Okay try sticking a number on the end. Try 5 times then give up
+ log.warn("Having trouble creating a unique name for a group. Have tried " + trimmedName);
+ int attempt = 1;
+ while (newGroup == null && attempt < 5) {
+ newGroup = Group.createLearnerGroup(grouping, trimmedName + " " + new Integer(attempt).toString(),
+ emptySet);
+ }
+ if (newGroup == null) {
+ String error = "Unable to create a unique name for a group. Tried 5 variations on " + trimmedName
+ + " now giving up.";
+ log.error(error);
+ throw new GroupingException(error);
- if ( newGroup != null )
- grouping.getGroups().add(newGroup);
-
- return newGroup;
-
+ }
}
- /**
- * Remove a group for the given grouping. If the group is already used (e.g. a tool session exists)
- * then it throws a GroupingException. If the group does not exist, nothing happens.
+ if (newGroup != null)
+ grouping.getGroups().add(newGroup);
+
+ return newGroup;
+
+ }
+
+ /**
+ * Remove a group for the given grouping. If the group is already used (e.g. a tool session exists) then it throws a
+ * GroupingException. If the group does not exist, nothing happens.
*
* Trims the name of the group before selecting the group.
*
* When a group is removed all the users in the group become ungrouped.
*
* Also throws a GroupingException if groupName is null or blank.
- *
- * @param grouping (mandatory)
- * @param groupID (mandatory)
+ *
+ * @param grouping
+ * (mandatory)
+ * @param groupID
+ * (mandatory)
*/
public void removeGroup(Grouping grouping, Long groupID) throws GroupingException {
-
- Iterator iter = grouping.getGroups().iterator();
- boolean groupDeleted = false;
-
- while (!groupDeleted && iter.hasNext()) {
- Group group = (Group) iter.next();
- if ( group.getGroupId().equals(groupID) ) {
-
- if ( group.mayBeDeleted() ) {
-
- // all okay so we can delete
- if ( log.isDebugEnabled() ) {
- log.warn("Deleting group "+group.getGroupName()+" for grouping "+grouping);
- }
- iter.remove();
- groupDeleted = true;
-
- } else {
- String error = "Tried to remove a group which cannot be removed (tool sessions probably exist). Group "+group+" grouping "+grouping+". Not removing the group.";
- log.error(error);
- throw new GroupingException(error);
- }
- }
+
+ Iterator iter = grouping.getGroups().iterator();
+ boolean groupDeleted = false;
+
+ while (!groupDeleted && iter.hasNext()) {
+ Group group = (Group) iter.next();
+ if (group.getGroupId().equals(groupID)) {
+
+ if (group.mayBeDeleted()) {
+
+ // all okay so we can delete
+ if (log.isDebugEnabled()) {
+ log.warn("Deleting group " + group.getGroupName() + " for grouping " + grouping);
+ }
+ iter.remove();
+ groupDeleted = true;
+
+ } else {
+ String error = "Tried to remove a group which cannot be removed (tool sessions probably exist). Group "
+ + group + " grouping " + grouping + ". Not removing the group.";
+ log.error(error);
+ throw new GroupingException(error);
}
-
- if ( !groupDeleted ) {
- log.warn("Tried to remove a group "+groupID+" but the group does not exist for grouping "+grouping+".");
- }
+ }
}
+ if (!groupDeleted) {
+ log.warn("Tried to remove a group " + groupID + " but the group does not exist for grouping " + grouping
+ + ".");
+ }
+ }
+
}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouper.java
===================================================================
diff -u -r62d0bb09a4512210d42ebd60885c7e1834c0cc5e -rc85eeb30f32d1551d97688e0153f5c81839f03d3
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouper.java (.../RandomGrouper.java) (revision 62d0bb09a4512210d42ebd60885c7e1834c0cc5e)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/RandomGrouper.java (.../RandomGrouper.java) (revision c85eeb30f32d1551d97688e0153f5c81839f03d3)
@@ -32,235 +32,236 @@
import org.lamsfoundation.lams.learningdesign.exception.GroupingException;
import org.lamsfoundation.lams.usermanagement.User;
-
/**
- * The random grouping algorithm implementation. It allocates user into the
- * groups according to the attributes accepted from user interface:
- * numberOfGroups
and learnersPerGroup
. If any of
- * these two attribute has be set, the random grouping will be done
- * correspondently.
+ *
+ * The random grouping algorithm implementation. It allocates user into the groups according to the attributes accepted
+ * from user interface: numberOfGroups
and learnersPerGroup
. If any of these two attribute has
+ * be set, the random grouping will be done correspondently.
+ *
*
- * In the case of random grouping by number of groups, the number of groups
- * will be fixed, and learners are evenly allocated into the groups. For
- * example, there are 10 users and numberOfGroups=3
, the number
- * of learners in three groups will 4,3,3. And if there are 1 user and
- * numberOfGroups=3
, all three groups still will be created
- * with learner number 1,0,0.
+ *
+ * In the case of random grouping by number of groups, the number of groups will be fixed, and learners are evenly
+ * allocated into the groups. For example, there are 10 users and numberOfGroups=3
, the number of learners
+ * in three groups will 4,3,3. And if there are 1 user and numberOfGroups=3
, all three groups still will be
+ * created with learner number 1,0,0.
+ *
*
- * In the case of random grouping by learners per group, groups are only
- * created if the total learner number exceeds the existing group capacity.
- * Learners are also evenly allocated into the groups.For example, if there is
- * 5 users and learnerPerGroup=3
, only 2 groups will be created.
+ *
+ * In the case of random grouping by learners per group, groups are only created if the total learner number exceeds the
+ * existing group capacity. Learners are also evenly allocated into the groups.For example, if there is 5 users and
+ * learnerPerGroup=3
, only 2 groups will be created.
*
*
* @author Jacky Fang
- * @since 2005-3-24
+ * @since 2005-3-24
* @version 1.1
*
*/
-public class RandomGrouper extends Grouper implements Serializable
-{
- private static final long serialVersionUID = -3696368461795411181L;
+public class RandomGrouper extends Grouper implements Serializable {
+ private static final long serialVersionUID = -3696368461795411181L;
- private static Logger log = Logger.getLogger(RandomGrouper.class);
-
- //---------------------------------------------------------------------
+ private static Logger log = Logger.getLogger(RandomGrouper.class);
+
+ // ---------------------------------------------------------------------
// Grouping algorithm Implementation Method
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
/**
* Do the grouping for single new learner.
- * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping, java.lang.String,org.lamsfoundation.lams.usermanagement.User)
+ *
+ * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping,
+ * java.lang.String,org.lamsfoundation.lams.usermanagement.User)
*/
- public void doGrouping(Grouping randomGrouping,String groupName, User learner)
- {
- //convert the single user into a list.
- List learners = new ArrayList();
- learners.add(learner);
- //delegate to do grouping for a list of learners.
- doGrouping(randomGrouping,groupName,learners);
+ @Override
+ public void doGrouping(Grouping randomGrouping, String groupName, User learner) {
+ // convert the single user into a list.
+ List learners = new ArrayList();
+ learners.add(learner);
+ // delegate to do grouping for a list of learners.
+ doGrouping(randomGrouping, groupName, learners);
}
/**
* Do the grouping for a list of new learners.
- * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping,java.lang.String, java.util.List)
+ *
+ * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping,java.lang.String,
+ * java.util.List)
*/
- public void doGrouping(Grouping randomGrouping, String groupName, List learners)
- {
- //calculate how many new groups needs to be created.
- int numOfGroupsTobeCreated =0;
- if(randomGrouping.getGroups().size()==0)
- numOfGroupsTobeCreated = calculateNumOfNewGroups((RandomGrouping)randomGrouping,
- learners,
- true);
- else
- numOfGroupsTobeCreated = calculateNumOfNewGroups((RandomGrouping)randomGrouping,
- learners,
- false);
- //create new groups
- createGroups((RandomGrouping)randomGrouping, numOfGroupsTobeCreated);
- //join the new learners into these groups.
- joinGroups(randomGrouping, learners);
+ @Override
+ public void doGrouping(Grouping randomGrouping, String groupName, List learners) {
+ // calculate how many new groups needs to be created.
+ int numOfGroupsTobeCreated = 0;
+ if (randomGrouping.getGroups().size() == 0) {
+ numOfGroupsTobeCreated = calculateNumOfNewGroups((RandomGrouping) randomGrouping, learners, true);
+ } else {
+ numOfGroupsTobeCreated = calculateNumOfNewGroups((RandomGrouping) randomGrouping, learners, false);
+ }
+ // create new groups
+ createGroups((RandomGrouping) randomGrouping, numOfGroupsTobeCreated);
+ // join the new learners into these groups.
+ joinGroups(randomGrouping, learners);
}
-
+
/**
- * Need to be able to force a user into a particular group for group based branching in preview.
- * So this is a non-random random. Bleah!
- * @throws GroupingException
- * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping,java.lang.Long, java.util.List)
+ * Need to be able to force a user into a particular group for group based branching in preview. So this is a
+ * non-random random. Bleah!
+ *
+ * @throws GroupingException
+ * @see org.lamsfoundation.lams.learningdesign.Grouper#doGrouping(org.lamsfoundation.lams.learningdesign.Grouping,java.lang.Long,
+ * java.util.List)
*/
- public void doGrouping(Grouping randomGrouping,Long groupId, List learners) throws GroupingException
- {
- if ( groupId != null ) {
- Iterator iter = randomGrouping.getGroups().iterator();
- Group selectedGroup = null;
- while (iter.hasNext() && selectedGroup==null) {
- Group group = (Group) iter.next();
- if ( group.getGroupId().equals(groupId) ) {
- selectedGroup = group;
- }
- }
- if ( selectedGroup == null ) {
- String error = "Tried to add users to group "+groupId+" but group cannot be found.";
- log.error(error);
- throw new GroupingException(error);
- }
- selectedGroup.getUsers().addAll(learners);
- } else {
- // normal random !!!
- doGrouping(randomGrouping, (String)null, learners);
- }
+ @Override
+ public void doGrouping(Grouping randomGrouping, Long groupId, List learners) throws GroupingException {
+ if (groupId != null) {
+ Iterator iter = randomGrouping.getGroups().iterator();
+ Group selectedGroup = null;
+ while (iter.hasNext() && (selectedGroup == null)) {
+ Group group = (Group) iter.next();
+ if (group.getGroupId().equals(groupId)) {
+ selectedGroup = group;
+ }
+ }
+ if (selectedGroup == null) {
+ String error = "Tried to add users to group " + groupId + " but group cannot be found.";
+ RandomGrouper.log.error(error);
+ throw new GroupingException(error);
+ }
+ selectedGroup.getUsers().addAll(learners);
+ } else {
+ // normal random !!!
+ doGrouping(randomGrouping, (String) null, learners);
+ }
}
-
- //---------------------------------------------------------------------
+
+ // ---------------------------------------------------------------------
// Helper Methods - doGrouping
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
/**
- * Compute the number of new groups needs to be created based on passed
- * in grouping. It figures out group by number of groups or group by
- * learner per group automatically.
+ * Compute the number of new groups needs to be created based on passed in grouping. It figures out group by number
+ * of groups or group by learner per group automatically.
*
- * @param randomGrouping the grouping we used to group learner
- * @param learners the list of learners need to be grouped
+ * @param randomGrouping
+ * the grouping we used to group learner
+ * @param learners
+ * the list of learners need to be grouped
* @return the number required new group.
*/
- private int calculateNumOfNewGroups(RandomGrouping randomGrouping,
- List learners,
- boolean isInitialization)
- {
- if(randomGrouping.getNumberOfGroups()!=null && randomGrouping.getNumberOfGroups().intValue()>0) {
- return getNewGroupsByNumberOfGroups(randomGrouping, randomGrouping.getNumberOfGroups(), isInitialization);
- } else if(randomGrouping.getLearnersPerGroup()!=null && randomGrouping.getLearnersPerGroup().intValue()>0) {
- return getNewGroupsByLearnerPerGroup(randomGrouping,learners);
- } else {
- log.warn("Random Grouping id="+randomGrouping.getGroupingId()+" is missing both the number of groups and learners per group. Defaulting to two groups.");
- return getNewGroupsByNumberOfGroups(randomGrouping, 2, isInitialization);
- }
+ private int calculateNumOfNewGroups(RandomGrouping randomGrouping, List learners, boolean isInitialization) {
+ if ((randomGrouping.getNumberOfGroups() != null) && (randomGrouping.getNumberOfGroups().intValue() > 0)) {
+ return getNewGroupsByNumberOfGroups(randomGrouping, randomGrouping.getNumberOfGroups(), isInitialization);
+ } else if ((randomGrouping.getLearnersPerGroup() != null)
+ && (randomGrouping.getLearnersPerGroup().intValue() > 0)) {
+ return getNewGroupsByLearnerPerGroup(randomGrouping, learners);
+ } else {
+ RandomGrouper.log.warn("Random Grouping id=" + randomGrouping.getGroupingId()
+ + " is missing both the number of groups and learners per group. Defaulting to two groups.");
+ return getNewGroupsByNumberOfGroups(randomGrouping, 2, isInitialization);
+ }
}
/**
- * Create new groups and insert them into the grouping. Group names
- * are Group 1, Group 2, etc.
- * @param randomGrouping the requested grouping.
- * @param numOfGroupsTobeCreated the number new groups need to be created.
+ * Create new groups and insert them into the grouping. Group names are Group 1, Group 2, etc.
+ *
+ * @param randomGrouping
+ * the requested grouping.
+ * @param numOfGroupsTobeCreated
+ * the number new groups need to be created.
*/
- private void createGroups(RandomGrouping randomGrouping,
- int numOfGroupsTobeCreated)
- {
- String prefix = getPrefix();
- int size = randomGrouping.getGroups().size();
- for(int numCreated=0,groupIndex=size+1;numCreated0?numberOfNewGroups:0;
- }
+ private int getNewGroupsByNumberOfGroups(RandomGrouping randomGrouping, int numberOfGroups,
+ boolean isInitialization) {
+ if (isInitialization) {
+ return numberOfGroups;
+ } else {
+ int numberOfNewGroups = numberOfGroups - randomGrouping.getGroups().size();
+
+ return numberOfNewGroups > 0 ? numberOfNewGroups : 0;
+ }
}
}
Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java
===================================================================
diff -u -r509d15bcc570bff483a13152ef8c45cbae767e78 -rc85eeb30f32d1551d97688e0153f5c81839f03d3
--- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision 509d15bcc570bff483a13152ef8c45cbae767e78)
+++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/ILessonDAO.java (.../ILessonDAO.java) (revision c85eeb30f32d1551d97688e0153f5c81839f03d3)
@@ -47,9 +47,6 @@
*/
Lesson getLesson(Long lessonId);
- /** Get all the lessons in the database. This includes the disabled lessons. */
- List getAllLessons();
-
Lesson getLessonWithJoinFetchedProgress(Long lessonId);
/**
@@ -62,17 +59,6 @@
List getActiveLessonsForLearner(User learner);
/**
- * Gets all lessons that are active for a learner, in a given organisation
- *
- * @param learnerId
- * a User that identifies the learner.
- * @param organisationId
- * the desired organisation .
- * @return a List with all active lessons in it.
- */
- List getActiveLessonsForLearner(Integer learnerId, Integer organisationID);
-
- /**
* Saves or Updates a Lesson.
*
* @param lesson
@@ -106,16 +92,6 @@
List getLessonsCreatedByUser(Integer userID);
/**
- * Gets all lessons in the given organisation, for which this user is in the staff group. Does not return disabled
- * lessons or preview lessons. This is the list of lessons that a user may monitor/moderate/manage.
- *
- * @param user
- * a User that identifies the teacher/staff member.
- * @return a List with all appropriate lessons in it.
- */
- List getLessonsForMonitoring(int userID, int organisationID);
-
- /**
* Returns the all the learners that have started the requested lesson.
*
* @param lessonId
@@ -216,12 +192,4 @@
* @return list of teachers that monitor the lesson which contains the tool with given session ID
*/
List getMonitorsByToolSessionId(Long sessionId);
-
- /**
- * Gets lesson for tools based on toolSessionID
- *
- * @param sessionID
- * @return
- */
- Lesson getLessonFromSessionID(Long toolSessionID);
-}
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java
===================================================================
diff -u -r509d15bcc570bff483a13152ef8c45cbae767e78 -rc85eeb30f32d1551d97688e0153f5c81839f03d3
--- lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision 509d15bcc570bff483a13152ef8c45cbae767e78)
+++ lams_common/src/java/org/lamsfoundation/lams/lesson/dao/hibernate/LessonDAO.java (.../LessonDAO.java) (revision c85eeb30f32d1551d97688e0153f5c81839f03d3)
@@ -59,6 +59,8 @@
+ "and lesson.startDateTime is not null and lesson.startDateTime < ?";
private final static String COUNT_ACTIVE_LEARNERS = "select count(distinct progress.user.id)" + " from "
+ LearnerProgress.class.getName() + " progress" + " where progress.lesson.id = :lessonId";
+ private final static String LOAD_ACTIVE_LEARNERS = "select distinct progress.user from "
+ + LearnerProgress.class.getName() + " progress where progress.lesson.id = :lessonId";
private final static String FIND_LESSON_FOR_ACTIVITY = "select lesson from " + Lesson.class.getName() + " lesson, "
+ Activity.class.getName() + " activity "
+ " where activity.activityId=:activityId and activity.learningDesign=lesson.learningDesign";
@@ -110,12 +112,6 @@
});
}
- /** Get all the lessons in the database. This includes the disabled lessons. */
- @Override
- public List getAllLessons() {
- return getHibernateTemplate().loadAll(Lesson.class);
- }
-
/**
* Gets all lessons that are active for a learner.
*
@@ -141,50 +137,17 @@
}
/**
- * Gets all lessons that are active for a learner, in a given organisation
- *
- * @param learnerId
- * a User that identifies the learner.
- * @param organisationId
- * the desired organisation.
- * @return a List with all active lessons in it.
- */
- @Override
- public List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId) {
- List lessons = null;
-
- HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory());
- lessons = (List) hibernateTemplate.execute(new HibernateCallback() {
- @Override
- public Object doInHibernate(Session session) throws HibernateException {
- Query query = session.getNamedQuery("activeLessons");
- query.setInteger("userId", learnerId);
- query.setInteger("organisationId", organisationId);
- List result = query.list();
- return result;
- }
- });
- return lessons;
- }
-
- /**
* @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getActiveLearnerByLesson(long)
*/
+ @SuppressWarnings("unchecked")
@Override
- public List getActiveLearnerByLesson(final long lessonId) {
- List learners = null;
-
- HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory());
- learners = (List) hibernateTemplate.execute(new HibernateCallback() {
+ public List getActiveLearnerByLesson(final long lessonId) {
+ return (List) new HibernateTemplate(this.getSessionFactory()).execute(new HibernateCallback() {
@Override
public Object doInHibernate(Session session) throws HibernateException {
- Query query = session.getNamedQuery("activeLearners");
- query.setLong("lessonId", lessonId);
- List result = query.list();
- return result;
+ return session.createQuery(LessonDAO.LOAD_ACTIVE_LEARNERS).setLong("lessonId", lessonId).list();
}
});
- return learners;
}
/**
@@ -309,32 +272,6 @@
}
/**
- * Gets all lessons in the given organisation, for which this user is in the staff group. Does not return disabled
- * lessons or preview lessons. This is the list of lessons that a user may monitor/moderate/manage.
- *
- * @param user
- * a User that identifies the teacher/staff member.
- * @return a List with all appropriate lessons in it.
- */
- @Override
- public List getLessonsForMonitoring(final int userID, final int organisationID) {
- List lessons = null;
-
- HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory());
- lessons = (List) hibernateTemplate.execute(new HibernateCallback() {
- @Override
- public Object doInHibernate(Session session) throws HibernateException {
- Query query = session.getNamedQuery("lessonsForMonitoring");
- query.setInteger("userId", userID);
- query.setInteger("organisationId", organisationID);
- List result = query.list();
- return result;
- }
- });
- return lessons;
- }
-
- /**
* Get all the preview lessons more with the creation date before the given date.
*
* @param startDate
@@ -436,29 +373,14 @@
/**
* @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getMonitorsByToolSessionId(Long)
*/
+ @SuppressWarnings("unchecked")
@Override
public List getMonitorsByToolSessionId(Long sessionId) {
return this.getHibernateTemplate().findByNamedQueryAndNamedParam("monitorsByToolSessionId", "sessionId",
sessionId);
}
/**
- * @see org.lamsfoundation.lams.lesson.dao.ILessonDAO#getLessonDetailsFromSessionID(java.lang.Long)
- */
- @Override
- public Lesson getLessonFromSessionID(final Long toolSessionID) {
- HibernateTemplate hibernateTemplate = new HibernateTemplate(this.getSessionFactory());
- return (Lesson) hibernateTemplate.execute(new HibernateCallback() {
- @Override
- public Object doInHibernate(Session session) throws HibernateException {
- Query query = session.createQuery(LessonDAO.LESSON_BY_SESSION_ID);
- query.setLong("toolSessionID", toolSessionID);
- return query.uniqueResult();
- }
- });
- }
-
- /**
* Maps users from an organisation with the given role to a boolean value saying whether they participate in the
* given lesson.
*/
Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java
===================================================================
diff -u -r509d15bcc570bff483a13152ef8c45cbae767e78 -rc85eeb30f32d1551d97688e0153f5c81839f03d3
--- lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision 509d15bcc570bff483a13152ef8c45cbae767e78)
+++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/ILessonService.java (.../ILessonService.java) (revision c85eeb30f32d1551d97688e0153f5c81839f03d3)
@@ -414,25 +414,6 @@
List getMonitorsByToolSessionId(Long sessionId);
/**
- * Gets all lessons that are active for a learner, in a given organisation
- *
- * @param learnerId
- * a User that identifies the learner.
- * @param organisationId
- * the desired organisation.
- * @return a List with all active lessons in it.
- */
- List getActiveLessonsForLearner(final Integer learnerId, final Integer organisationId);
-
- /**
- * Gets lesson details for tools based on toolSessionID
- *
- * @param sessionID
- * @return
- */
- LessonDetailsDTO getLessonDetailsFromSessionID(Long toolSessionID);
-
- /**
* Check if preceding lessons have been completed and the given lesson is available to the user.
*/
boolean checkLessonReleaseConditions(Long lessonId, Integer learnerId);
Index: lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java
===================================================================
diff -u -r509d15bcc570bff483a13152ef8c45cbae767e78 -rc85eeb30f32d1551d97688e0153f5c81839f03d3
--- lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision 509d15bcc570bff483a13152ef8c45cbae767e78)
+++ lams_common/src/java/org/lamsfoundation/lams/lesson/service/LessonService.java (.../LessonService.java) (revision c85eeb30f32d1551d97688e0153f5c81839f03d3)
@@ -672,20 +672,6 @@
}
@Override
- 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 null;
- }
-
- @Override
public boolean checkLessonReleaseConditions(Long lessonId, Integer learnerId) {
Lesson lesson = getLesson(lessonId);
if (lesson != null) {