Index: lams_learning/lib/lams/lams.jar
===================================================================
diff -u -rbc763d05d201c39bc96c62620f9fb9f0712f759c -r11c5be112ae49dc43d2bd32e7d9556921a0cff64
Binary files differ
Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java
===================================================================
diff -u -r03dadd75db717405879b1760d0b393cc48bb55e2 -r11c5be112ae49dc43d2bd32e7d9556921a0cff64
--- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 03dadd75db717405879b1760d0b393cc48bb55e2)
+++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java (.../LearnerService.java) (revision 11c5be112ae49dc43d2bd32e7d9556921a0cff64)
@@ -1,4 +1,5 @@
-/*Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+/*
+Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -137,7 +138,12 @@
/**
- * @param learnerProgress
+ * This method navigate through all the tool activities included inside
+ * the next activity. For each tool activity, we look up the database
+ * to check up the existance of correspondent tool session. If the tool
+ * session doesn't exist, we create a new tool session instance.
+ *
+ * @param learnerProgress the learner progress we are processing.
*/
private void createToolSessionsIfNecessary(LearnerProgress learnerProgress)
{
@@ -152,12 +158,14 @@
{
ToolActivity toolActivity = (ToolActivity)i.next();
if(shouldCreateToolSession(learnerProgress,toolActivity))
- createToolSessionFor(toolActivity);
+ createToolSessionFor(toolActivity, learnerProgress.getUser());
}
}
/**
- * @return
+ * Check up the database to see whether there is an existing tool session
+ * has been created already.
+ * @return the check up result.
*/
private boolean shouldCreateToolSession(LearnerProgress learnerProgress,
ToolActivity toolActivity)
@@ -166,16 +174,30 @@
if(!toolActivity.getTool().getSupportsGrouping())
targetSession = toolSessionDAO.getToolSessionByLearner(learnerProgress.getUser(),
toolActivity);
-
+ else
+ targetSession = toolSessionDAO.getToolSessionByGroup(toolActivity.getGroupFor(learnerProgress.getUser()),
+ toolActivity);
return targetSession!=null?true:false;
}
+
/**
+ * Create a tool session for learner against a tool activity. This will
+ * have concurrency issues interms of grouped tool session because it might
+ * be inserting some tool session that has already been inserted by other
+ * member in the group. If the unique_check is broken, we need to query
+ * the database to get the instance instead of inserting it. It should be
+ * done in the Spring rollback strategy.
+ *
* @param toolActivity
+ * @param learner
*/
- private void createToolSessionFor(ToolActivity toolActivity)
+ private void createToolSessionFor(ToolActivity toolActivity,User learner)
{
- // TODO Auto-generated method stub
+ ToolSession toolSession = toolActivity.createToolSessionForActivity(learner);
+
+ toolActivity.getToolSessions().add(toolSession);
+ toolSessionDAO.saveToolSession(toolSession);
}
/**
Index: lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml
===================================================================
diff -u -r36c2ed010b8a3893b895d781be1a219f2380e62d -r11c5be112ae49dc43d2bd32e7d9556921a0cff64
--- lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 36c2ed010b8a3893b895d781be1a219f2380e62d)
+++ lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml (.../learningApplicationContext.xml) (revision 11c5be112ae49dc43d2bd32e7d9556921a0cff64)
@@ -11,13 +11,25 @@
-
+
+
+
+
+
+
+
+
+ PROPAGATION_REQUIRED,ISOLATION_READ_COMMITTED
+
+
+
+
@@ -28,4 +40,10 @@
+
+
+
+
+
+
Index: lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java
===================================================================
diff -u
--- lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java (revision 0)
+++ lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java (revision 11c5be112ae49dc43d2bd32e7d9556921a0cff64)
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA
+
+ http://www.gnu.org/licenses/gpl.txt
+*/
+package org.lamsfoundation.lams.learning.service;
+
+import org.lamsfoundation.lams.AbstractLamsTestCase;
+
+/**
+ *
+ * @author Jacky Fang 2005-2-22
+ *
+ */
+public class TestLearnerService extends AbstractLamsTestCase
+{
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /**
+ * Constructor for TestLearnerService.
+ * @param name
+ */
+ public TestLearnerService(String name)
+ {
+ super(name);
+ }
+ protected String[] getContextConfigLocation()
+ {
+ return new String[] { "/WEB-INF/spring/learningApplicationContext.xml",
+ "/WEB-INF/spring/applicationContext.xml"};
+ }
+ public void testJoinLesson()
+ {
+ }
+
+}