Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/TaskListItemVisitDAO.java =================================================================== diff -u -r0e7e464ded505f35e6ade3811f3f74658668e13a -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/TaskListItemVisitDAO.java (.../TaskListItemVisitDAO.java) (revision 0e7e464ded505f35e6ade3811f3f74658668e13a) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/TaskListItemVisitDAO.java (.../TaskListItemVisitDAO.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -53,5 +53,15 @@ * @return list of taskListItemVisitLogs which corresponds to specified sessionId and itemUid */ public List getTaskListItemLogBySession(Long sessionId,Long itemUid); + + /** + * + * + * @param toolSessionId + * @param userUid + * @return + */ + public int getTasksCompletedCountByUser(Long toolSessionId ,Long userUid); + } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/hibernate/TaskListItemVisitDAOHibernate.java =================================================================== diff -u -r0e7e464ded505f35e6ade3811f3f74658668e13a -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/hibernate/TaskListItemVisitDAOHibernate.java (.../TaskListItemVisitDAOHibernate.java) (revision 0e7e464ded505f35e6ade3811f3f74658668e13a) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/dao/hibernate/TaskListItemVisitDAOHibernate.java (.../TaskListItemVisitDAOHibernate.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -46,9 +46,9 @@ private static final String FIND_BY_ITEM_BYSESSION = "from " + TaskListItemVisitLog.class.getName() + " as r where r.sessionId = ? and r.taskListItem.uid=?"; -// private static final String FIND_VIEW_COUNT_BY_USER = "select count(*) from " + TaskListItemVisitLog.class.getName() -// + " as r where r.sessionId=? and r.user.userId =?"; -// + private static final String FIND_TASKS_COMPLETED_COUNT_BY_USER = "select count(*) from " + TaskListItemVisitLog.class.getName() + + " as r where r.complete=true and r.sessionId=? and r.user.userId =?"; + // private static final String FIND_SUMMARY = "select v.taskListItem.uid, count(v.taskListItem) from " // + TaskListItemVisitLog.class.getName() + " as v , " // + TaskListSession.class.getName() + " as s, " @@ -68,13 +68,16 @@ return (TaskListItemVisitLog) list.get(0); } -// public int getUserViewLogCount(Long toolSessionId ,Long userUid) { -// List list = getHibernateTemplate().find(FIND_VIEW_COUNT_BY_USER,new Object[]{toolSessionId, userUid}); -// if(list == null || list.size() ==0) -// return 0; -// return ((Number) list.get(0)).intValue(); -// } -// + /** + * {@inheritDoc} + */ + public int getTasksCompletedCountByUser(Long toolSessionId ,Long userUid) { + List list = getHibernateTemplate().find(FIND_TASKS_COMPLETED_COUNT_BY_USER, new Object[]{toolSessionId, userUid}); + if(list == null || list.size() ==0) + return 0; + return ((Number) list.get(0)).intValue(); + } + // public Map getSummary(Long contentId) { // // // Note: Hibernate 3.1 query.uniqueResult() returns Integer, Hibernate 3.2 query.uniqueResult() returns Long Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java =================================================================== diff -u -rfe31f08d68bebdde45fb5597de931d532ce7aace -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java (.../TaskList.java) (revision fe31f08d68bebdde45fb5597de931d532ce7aace) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskList.java (.../TaskList.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -137,6 +137,7 @@ } taskList.taskListItems = set; } + //clone attachment if(attachments != null){ Iterator iter = attachments.iterator(); @@ -157,8 +158,23 @@ while(iter.hasNext()){ TaskListCondition condition = (TaskListCondition)iter.next(); TaskListCondition newCondition = (TaskListCondition) condition.clone(); - //just clone old file without duplicate it in repository + //picking up all the taskListItems that condition had + if(condition.getTaskListItems() != null){ + Set set2 = new HashSet(); + newCondition.setTaskListItems(set2); +// Iterator iter2 = taskListItems.iterator(); +// while(iter.hasNext()){ +// TaskListItem item = (TaskListItem)iter.next(); +// TaskListItem newItem = (TaskListItem) item.clone(); +// //just clone old file without duplicate it in repository +// set.add(newItem); +// } + + } + + + set.add(newCondition); } taskList.conditions = set; Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.hbm.xml =================================================================== diff -u -ra457e8ec1d345e4e9d956e0ad2fff971f76daebf -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.hbm.xml (.../TaskListCondition.hbm.xml) (revision a457e8ec1d345e4e9d956e0ad2fff971f76daebf) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.hbm.xml (.../TaskListCondition.hbm.xml) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -38,7 +38,7 @@ table="tl_latask10_condition_tl_item" lazy="true" inverse="false" - cascade="none" + cascade="all" sort="unsorted" > Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.java =================================================================== diff -u -ra457e8ec1d345e4e9d956e0ad2fff971f76daebf -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.java (.../TaskListCondition.java) (revision a457e8ec1d345e4e9d956e0ad2fff971f76daebf) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/model/TaskListCondition.java (.../TaskListCondition.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -116,27 +116,15 @@ */ public Object clone(){ - TaskListCondition taskList = null; + TaskListCondition condition = null; try{ - taskList = (TaskListCondition) super.clone(); - taskList.setUid(null); - //clone taskListItems - if(taskListItems != null){ - Iterator iter = taskListItems.iterator(); - Set set = new HashSet(); - while(iter.hasNext()){ - TaskListItem item = (TaskListItem)iter.next(); - TaskListItem newItem = (TaskListItem) item.clone(); - //just clone old file without duplicate it in repository - set.add(newItem); - } - taskList.taskListItems = set; - } + condition = (TaskListCondition) super.clone(); + condition.setUid(null); } catch (CloneNotSupportedException e) { log.error("When clone " + TaskListCondition.class + " failed"); } - return taskList; + return condition; } //********************************************************** @@ -196,6 +184,8 @@ * @hibernate.collection-key column="condition_uid" * @hibernate.collection-many-to-many column="uid" class="org.lamsfoundation.lams.tool.taskList.model.TaskListItem" */ + + //TODO maybe th reason of a problem cascade="all"!!! public Set getTaskListItems() { return taskListItems; } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java =================================================================== diff -u -r1ef27bf016b647ea0c2803d22f2bb4d4b3cde650 -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java (.../ITaskListService.java) (revision 1ef27bf016b647ea0c2803d22f2bb4d4b3cde650) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/ITaskListService.java (.../ITaskListService.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -26,10 +26,14 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedMap; import java.util.SortedSet; +import java.util.TreeMap; import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.ToolOutputDefinition; +import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.taskList.dto.ReflectDTO; import org.lamsfoundation.lams.tool.taskList.dto.Summary; import org.lamsfoundation.lams.tool.taskList.dto.TaskSummary; @@ -47,9 +51,17 @@ * @author Dapeng.Ni * @author Andrey Balan */ -public interface ITaskListService -{ +public interface ITaskListService { + + /** + * @param toolSessionId + * @param userUid + * @return + */ + public int getNumTasksCompletedByUser(Long toolSessionId, Long userUid); + + /** * Get TaskList by toolContentID. * * @param contentId @@ -63,9 +75,9 @@ * * @param contentId * @return - * @throws TaskListApplicationException + * @throws TaskListException */ - TaskList getDefaultContent(Long contentId) throws TaskListApplicationException; + TaskList getDefaultContent(Long contentId) throws TaskListException; /** * Get list of taskList items by given taskListUid. These taskList items must be created by author. @@ -143,9 +155,9 @@ * * @param fileUuid * @param fileVersionId - * @throws TaskListApplicationException + * @throws TaskListException */ - void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListApplicationException ; + void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListException ; /** * Save or update taskList into database. @@ -257,7 +269,7 @@ * @param userId * @return */ - String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException; + String finishToolSession(Long toolSessionId, Long userId) throws TaskListException; /** * Create refection entry into notebook tool. @@ -331,6 +343,6 @@ * @return */ TaskSummary getTaskSummary(Long contentId, Long taskListItemUid); - + } Fisheye: Tag 12a0e5152335f664f19ad5b1449633f7fec6b8a9 refers to a dead (removed) revision in file `lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListApplicationException.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListException.java =================================================================== diff -u --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListException.java (revision 0) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListException.java (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -0,0 +1,47 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * 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. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.taskList.service; + +/** + * @author Andrey Balan + */ +public class TaskListException extends RuntimeException{ + + public TaskListException() { + super(); + } + + public TaskListException(String message, Throwable cause) { + super(message, cause); + } + + public TaskListException(String message) { + super(message); + } + + public TaskListException(Throwable cause) { + super(cause); + } + +} Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java =================================================================== diff -u -ra457e8ec1d345e4e9d956e0ad2fff971f76daebf -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java (.../TaskListOutputFactory.java) (revision a457e8ec1d345e4e9d956e0ad2fff971f76daebf) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListOutputFactory.java (.../TaskListOutputFactory.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -23,22 +23,61 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.taskList.service; +import java.util.List; import java.util.SortedMap; +import java.util.TreeMap; import org.lamsfoundation.lams.tool.OutputFactory; +import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.ToolOutputDefinition; import org.lamsfoundation.lams.tool.exception.ToolException; /** + * Creates the output definitions for forum. Eventually there will be a definition + * that outputs some or all of the forum queries, but for now there are just a couple of + * simple definitions so that we can try various features of the tool output based + * branching. + * * @author Andrey Balan */ public class TaskListOutputFactory extends OutputFactory{ - @Override + /** The number of posts the learner has made in one forum activity. */ + protected final static String OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED = "learner.number.of.tasks.completed"; + + /** + * {@inheritDoc} + */ public SortedMap getToolOutputDefinitions(Object toolContentObject) throws ToolException { + TreeMap definitionMap = new TreeMap(); + + ToolOutputDefinition definition = buildRangeDefinition(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, new Long(0), null); + definitionMap.put(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, definition); + return definitionMap; + } + + public SortedMap getToolOutput(List names, ITaskListService taskListService, Long toolSessionId, Long learnerId) { + + TreeMap map = new TreeMap(); + if ( names == null || names.contains(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED)) { + map.put(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED,getNumTasksCompleted(taskListService, learnerId, toolSessionId)); + } + return map; + + } + + public ToolOutput getToolOutput(String name, ITaskListService taskListService, Long toolSessionId, Long learnerId) { + + if ( name != null && name.equals(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED)) { + return getNumTasksCompleted(taskListService, learnerId, toolSessionId); + } return null; + } + private ToolOutput getNumTasksCompleted(ITaskListService taskListService, Long learnerId, Long toolSessionId) { + int num = taskListService.getNumTasksCompletedByUser(toolSessionId, learnerId); + return new ToolOutput(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, getI18NText(OUTPUT_NAME_LEARNER_NUM_TASKS_COMPLETED, true), new Long(num)); + } } - \ No newline at end of file Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java =================================================================== diff -u -ra457e8ec1d345e4e9d956e0ad2fff971f76daebf -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java (.../TaskListServiceImpl.java) (revision a457e8ec1d345e4e9d956e0ad2fff971f76daebf) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/service/TaskListServiceImpl.java (.../TaskListServiceImpl.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -126,7 +126,7 @@ //tool service private TaskListToolContentHandler taskListToolContentHandler; private MessageService messageService; - TaskListOutputFactory taskListOutputFactory; + private TaskListOutputFactory taskListOutputFactory; //system services private IRepositoryService repositoryService; private ILamsToolService toolService; @@ -154,12 +154,12 @@ /** * {@inheritDoc} */ - public TaskList getDefaultContent(Long contentId) throws TaskListApplicationException { + public TaskList getDefaultContent(Long contentId) throws TaskListException { if (contentId == null) { String error=messageService.getMessage("error.msg.default.content.not.find"); log.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } TaskList defaultContent = getDefaultTaskList(); @@ -249,12 +249,12 @@ /** * {@inheritDoc} */ - public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListApplicationException { + public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws TaskListException { ITicket ticket = getRepositoryLoginTicket(); try { repositoryService.deleteVersion(ticket, fileUuid,fileVersionId); } catch (Exception e) { - throw new TaskListApplicationException( + throw new TaskListException( "Exception occured while deleting files from" + " the repository " + e.getMessage()); } @@ -357,7 +357,7 @@ /** * {@inheritDoc} */ - public String finishToolSession(Long toolSessionId, Long userId) throws TaskListApplicationException { + public String finishToolSession(Long toolSessionId, Long userId) throws TaskListException { TaskListUser user = taskListUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); taskListUserDao.saveObject(user); @@ -370,9 +370,9 @@ try { nextUrl = this.leaveToolSession(toolSessionId,userId); } catch (DataMissingException e) { - throw new TaskListApplicationException(e); + throw new TaskListException(e); } catch (ToolException e) { - throw new TaskListApplicationException(e); + throw new TaskListException(e); } return nextUrl; } @@ -427,11 +427,6 @@ } } - - - - - /** * {@inheritDoc} */ @@ -488,6 +483,13 @@ /** * {@inheritDoc} */ + public int getNumTasksCompletedByUser(Long toolSessionId, Long userUid) { + return getTaskListItemVisitDao().getTasksCompletedCountByUser(toolSessionId, userUid); + } + + /** + * {@inheritDoc} + */ public TaskSummary getTaskSummary(Long contentId, Long taskListItemUid) { TaskListItem taskListItem = taskListItemDao.getByUid(taskListItemUid); @@ -771,7 +773,7 @@ if(toolContentObj == null) { try { toolContentObj = getDefaultTaskList(); - } catch (TaskListApplicationException e) { + } catch (TaskListException e) { throw new DataMissingException(e.getMessage()); } } @@ -834,14 +836,24 @@ throw new ToolException(e); } } - - /** Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are always - * available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular activity - * such as the answer to the third question contains the word Koala and hence the need for the toolContentId - * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition - */ + + /** + * Get the definitions for possible output for an activity, based on the + * toolContentId. These may be definitions that are always available for the + * tool (e.g. number of marks for Multiple Choice) or a custom definition + * created for a particular activity such as the answer to the third + * question contains the word Koala and hence the need for the toolContentId + * + * @return SortedMap of ToolOutputDefinitions with the key being the name of + * each definition + * @throws TaskListException + */ public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException { - return new TreeMap(); + TaskList taskList = getTaskListByContentId(toolContentId); + if ( taskList == null ) { + taskList = getDefaultTaskList(); + } + return getTaskListOutputFactory().getToolOutputDefinitions(taskList); } /** @@ -859,7 +871,7 @@ if ( taskList == null ) { try { taskList = getDefaultTaskList(); - } catch (TaskListApplicationException e) { + } catch (TaskListException e) { throw new ToolException(e); } } @@ -980,16 +992,15 @@ * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long) */ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) { - return new TreeMap(); + return taskListOutputFactory.getToolOutput(names, this, toolSessionId, learnerId); } /** * Get the tool output for the given tool output name. * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long) */ - public ToolOutput getToolOutput(String name, Long toolSessionId, - Long learnerId) { - return null; + public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { + return taskListOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); } //******************************************************************************* @@ -1020,35 +1031,34 @@ // Private methods //***************************************************************************** - private TaskList getDefaultTaskList() throws TaskListApplicationException { + private TaskList getDefaultTaskList() throws TaskListException { Long defaultTaskListId = getToolDefaultContentIdBySignature(TaskListConstants.TOOL_SIGNATURE); TaskList defaultTaskList = getTaskListByContentId(defaultTaskListId); - if(defaultTaskList == null) - { + if(defaultTaskList == null) { String error=messageService.getMessage("error.msg.default.content.not.find"); log.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } return defaultTaskList; } - private Long getToolDefaultContentIdBySignature(String toolSignature) throws TaskListApplicationException { + private Long getToolDefaultContentIdBySignature(String toolSignature) throws TaskListException { Long contentId = null; contentId=new Long(toolService.getToolDefaultContentIdBySignature(toolSignature)); if (contentId == null) { String error=messageService.getMessage("error.msg.default.content.not.find"); log.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } return contentId; } /** * Process an uploaded file. * - * @throws TaskListApplicationException + * @throws TaskListException * @throws FileNotFoundException * @throws IOException * @throws RepositoryCheckedException @@ -1140,7 +1150,7 @@ * @return file node * @throws ImscpApplicationException */ - private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListApplicationException { + private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws TaskListException { ITicket tic = getRepositoryLoginTicket(); @@ -1154,7 +1164,7 @@ error = error+"AccessDeniedException: "+e.getMessage()+" Unable to retry further."; log.error(error); - throw new TaskListApplicationException(error,e); + throw new TaskListException(error,e); } catch (Exception e) { @@ -1163,7 +1173,7 @@ +" path " + relativePath+"." +" Exception: "+e.getMessage(); log.error(error); - throw new TaskListApplicationException(error,e); + throw new TaskListException(error,e); } } @@ -1177,19 +1187,19 @@ * upload/download files from the content repository. * * @return ITicket The ticket for repostory access - * @throws TaskListApplicationException + * @throws TaskListException */ - private ITicket getRepositoryLoginTicket() throws TaskListApplicationException { + private ITicket getRepositoryLoginTicket() throws TaskListException { ICredentials credentials = new SimpleCredentials(taskListToolContentHandler.getRepositoryUser(), taskListToolContentHandler.getRepositoryId()); try { ITicket ticket = repositoryService.login(credentials, taskListToolContentHandler.getRepositoryWorkspaceName()); return ticket; } catch (AccessDeniedException ae) { - throw new TaskListApplicationException("Access Denied to repository." + ae.getMessage()); + throw new TaskListException("Access Denied to repository." + ae.getMessage()); } catch (WorkspaceNotFoundException we) { - throw new TaskListApplicationException("Workspace not found." + we.getMessage()); + throw new TaskListException("Workspace not found." + we.getMessage()); } catch (LoginException e) { - throw new TaskListApplicationException("Login failed." + e.getMessage()); + throw new TaskListException("Login failed." + e.getMessage()); } } } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/taskListApplicationContext.xml =================================================================== diff -u -ra457e8ec1d345e4e9d956e0ad2fff971f76daebf -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/taskListApplicationContext.xml (.../taskListApplicationContext.xml) (revision a457e8ec1d345e4e9d956e0ad2fff971f76daebf) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/taskListApplicationContext.xml (.../taskListApplicationContext.xml) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -145,6 +145,7 @@ PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception + PROPAGATION_REQUIRED, -java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception @@ -153,7 +154,7 @@ PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception - PROPAGATION_REQUIRED,+java.lang.Exception + PROPAGATION_REQUIRED,+java.lang.Exception PROPAGATION_REQUIRED,+java.lang.Exception PROPAGATION_REQUIRED,+java.lang.Exception PROPAGATION_REQUIRED,+java.lang.Exception Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringAction.java =================================================================== diff -u -rb8ae37f22fe25050991655635d042758f1fe5c89 -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision b8ae37f22fe25050991655635d042758f1fe5c89) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -62,7 +62,7 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListItem; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; import org.lamsfoundation.lams.tool.taskList.service.ITaskListService; -import org.lamsfoundation.lams.tool.taskList.service.TaskListApplicationException; +import org.lamsfoundation.lams.tool.taskList.service.TaskListException; import org.lamsfoundation.lams.tool.taskList.service.UploadTaskListFileException; import org.lamsfoundation.lams.tool.taskList.util.TaskListConditionComparator; import org.lamsfoundation.lams.tool.taskList.util.TaskListItemComparator; @@ -387,6 +387,24 @@ iter.remove(); } + + + //Handle taskList items + Set itemList = new LinkedHashSet(); + SortedSet topics = getTaskListItemList(sessionMap); + iter = topics.iterator(); + while(iter.hasNext()){ + TaskListItem item = (TaskListItem) iter.next(); + if(item != null){ + //This flushs user UID info to message if this user is a new user. + item.setCreateBy(taskListUser); + itemList.add(item); + } + } + taskListPO.setTaskListItems(itemList); + + + //Handle taskList conditions. Also delete conditions that don't contain any taskLIstItems. SortedSet conditionList = getTaskListConditionList(sessionMap); SortedSet conditionListWithoutEmptyElements = new TreeSet(conditionList); @@ -406,24 +424,40 @@ while(iter.hasNext()){ TaskListCondition condition = (TaskListCondition) iter.next(); iter.remove(); + if(condition.getUid() != null) service.deleteTaskListCondition(condition.getUid()); } + //Handle taskList items - Set itemList = new LinkedHashSet(); - SortedSet topics = getTaskListItemList(sessionMap); - iter = topics.iterator(); - while(iter.hasNext()){ - TaskListItem item = (TaskListItem) iter.next(); - if(item != null){ - //This flushs user UID info to message if this user is a new user. - item.setCreateBy(taskListUser); - itemList.add(item); - } + SortedSet conditions = getTaskListConditionList(sessionMap); + for (TaskListCondition condition:conditions) { + + + Set itemList2 = new LinkedHashSet(); + Set topics2 = condition.getTaskListItems(); + iter = topics2.iterator(); + while(iter.hasNext()){ + TaskListItem item2 = (TaskListItem) iter.next(); + if(item2 != null){ + //This flushs user UID info to message if this user is a new user. + item2.setCreateBy(taskListUser); + itemList2.add(item2); + } + } + condition.setTaskListItems(itemList2); + + } - taskListPO.setTaskListItems(itemList); + + + + + + + // delete TaskListItems from database. This should be done after // TaskListConditions have been deleted from the database. This is due // to prevent errors with foreign keys. @@ -907,7 +941,7 @@ * Extract web from content to taskList item. * @param request * @param itemForm - * @throws TaskListApplicationException + * @throws TaskListException */ private void extractFormToTaskListItem(HttpServletRequest request, TaskListItemForm itemForm) throws Exception { Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringTaskListConditionAction.java =================================================================== diff -u -r1ef27bf016b647ea0c2803d22f2bb4d4b3cde650 -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringTaskListConditionAction.java (.../AuthoringTaskListConditionAction.java) (revision 1ef27bf016b647ea0c2803d22f2bb4d4b3cde650) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/AuthoringTaskListConditionAction.java (.../AuthoringTaskListConditionAction.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -53,7 +53,7 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListCondition; import org.lamsfoundation.lams.tool.taskList.model.TaskListItem; import org.lamsfoundation.lams.tool.taskList.service.ITaskListService; -import org.lamsfoundation.lams.tool.taskList.service.TaskListApplicationException; +import org.lamsfoundation.lams.tool.taskList.service.TaskListException; import org.lamsfoundation.lams.tool.taskList.util.TaskListConditionComparator; import org.lamsfoundation.lams.tool.taskList.util.TaskListItemComparator; import org.lamsfoundation.lams.tool.taskList.web.form.TaskListConditionForm; @@ -435,7 +435,7 @@ * Extract form content to taskListContent. * @param request * @param form - * @throws TaskListApplicationException + * @throws TaskListException */ private void extractFormToTaskListCondition(HttpServletRequest request, TaskListConditionForm form) throws Exception { /* BE CAREFUL: This method will copy necessary info from request form to a old or new TaskListItem instance. Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/LearningAction.java =================================================================== diff -u -ra370ee2f7fe049337ac7b342e0218bdde3f3ee68 -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/LearningAction.java (.../LearningAction.java) (revision a370ee2f7fe049337ac7b342e0218bdde3f3ee68) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/action/LearningAction.java (.../LearningAction.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -58,7 +58,7 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListSession; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; import org.lamsfoundation.lams.tool.taskList.service.ITaskListService; -import org.lamsfoundation.lams.tool.taskList.service.TaskListApplicationException; +import org.lamsfoundation.lams.tool.taskList.service.TaskListException; import org.lamsfoundation.lams.tool.taskList.util.TaskListItemComparator; import org.lamsfoundation.lams.tool.taskList.web.form.ReflectionForm; import org.lamsfoundation.lams.tool.taskList.web.form.TaskListItemForm; @@ -291,7 +291,7 @@ nextActivityUrl = service.finishToolSession(sessionId,userID); request.setAttribute(TaskListConstants.ATTR_NEXT_ACTIVITY_URL,nextActivityUrl); - } catch (TaskListApplicationException e) { + } catch (TaskListException e) { log.error("Failed get next activity url:" + e.getMessage()); } Index: lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java =================================================================== diff -u -ra3da609771f1cedff31c3af15d26d6b69308fe97 -r12a0e5152335f664f19ad5b1449633f7fec6b8a9 --- lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision a3da609771f1cedff31c3af15d26d6b69308fe97) +++ lams_tool_task/src/java/org/lamsfoundation/lams/tool/taskList/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision 12a0e5152335f664f19ad5b1449633f7fec6b8a9) @@ -49,7 +49,7 @@ import org.lamsfoundation.lams.tool.taskList.model.TaskListSession; import org.lamsfoundation.lams.tool.taskList.model.TaskListUser; import org.lamsfoundation.lams.tool.taskList.service.ITaskListService; -import org.lamsfoundation.lams.tool.taskList.service.TaskListApplicationException; +import org.lamsfoundation.lams.tool.taskList.service.TaskListException; import org.lamsfoundation.lams.tool.taskList.service.TaskListServiceProxy; import org.lamsfoundation.lams.tool.taskList.util.TaskListToolContentHandler; import org.lamsfoundation.lams.util.FileUtil; @@ -92,7 +92,7 @@ sessionMap.put(AttributeNames.ATTR_MODE,ToolAccessMode.TEACHER); teacher(request, response, directoryName, cookies,sessionMap); } - } catch (TaskListApplicationException e) { + } catch (TaskListException e) { logger.error("Cannot perform export for taskList tool."); } @@ -135,33 +135,33 @@ * @param directoryName * @param cookies * @param sessionMap - * @throws TaskListApplicationException + * @throws TaskListException * @throws IOException */ - private void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListApplicationException{ + private void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListException{ ITaskListService service = TaskListServiceProxy.getTaskListService(getServletContext()); if (userID == null || toolSessionID == null) { String error = "Tool session Id or user Id is null. Unable to continue"; logger.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } TaskListUser learner = service.getUserByIDAndSession(userID,toolSessionID); if (learner == null) { String error = "The user with user id " + userID + " does not exist."; logger.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } TaskList content = service.getTaskListBySessionId(toolSessionID); if (content == null) { String error = "The content for this activity has not been defined yet."; logger.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } List taskSummaries = service.exportForLearner(toolSessionID, learner); @@ -180,25 +180,25 @@ * @param directoryName * @param cookies * @param sessionMap - * @throws TaskListApplicationException + * @throws TaskListException * @throws IOException */ - private void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListApplicationException { + private void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) throws TaskListException { ITaskListService service = TaskListServiceProxy.getTaskListService(getServletContext()); // check if toolContentId exists in db or not if (toolContentID == null) { String error = "Tool Content Id is missing. Unable to continue"; logger.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } TaskList content = service.getTaskListByContentId(toolContentID); if (content == null) { String error = "Data is missing from the database. Unable to Continue"; logger.error(error); - throw new TaskListApplicationException(error); + throw new TaskListException(error); } List taskSummaries = service.exportForTeacher(toolContentID);