Index: lams_learning/lib/lams/lams.jar =================================================================== RCS file: /usr/local/cvsroot/lams_learning/lib/lams/Attic/lams.jar,v diff -u -r1.3 -r1.4 Binary files differ Index: lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java,v diff -u -r1.12 -r1.13 --- lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 21 Feb 2005 05:59:20 -0000 1.12 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/service/LearnerService.java 22 Feb 2005 04:25:03 -0000 1.13 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_learning/test/java/WEB-INF/spring/Attic/learningApplicationContext.xml,v diff -u -r1.4 -r1.5 --- lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml 21 Feb 2005 05:31:40 -0000 1.4 +++ lams_learning/test/java/WEB-INF/spring/learningApplicationContext.xml 22 Feb 2005 04:25:03 -0000 1.5 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_learning/test/java/org/lamsfoundation/lams/learning/service/Attic/TestLearnerService.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_learning/test/java/org/lamsfoundation/lams/learning/service/TestLearnerService.java 22 Feb 2005 04:25:03 -0000 1.1 @@ -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() + { + } + +}