Index: lams_tool_vote/conf/language/lams/ApplicationResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/conf/language/lams/ApplicationResources.properties,v
diff -u -r1.5 -r1.6
--- lams_tool_vote/conf/language/lams/ApplicationResources.properties 7 Mar 2008 07:14:40 -0000 1.5
+++ lams_tool_vote/conf/language/lams/ApplicationResources.properties 20 Mar 2008 04:30:57 -0000 1.6
@@ -151,3 +151,4 @@
#======= End labels: Exported 142 labels for en AU =====
+output.desc.learner.selection=Learner selection
\ No newline at end of file
Index: lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties,v
diff -u -r1.5 -r1.6
--- lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties 7 Mar 2008 07:14:40 -0000 1.5
+++ lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties 20 Mar 2008 04:30:57 -0000 1.6
@@ -151,3 +151,4 @@
#======= End labels: Exported 142 labels for en AU =====
+output.desc.learner.selection=Learner selection
\ No newline at end of file
Index: lams_tool_vote/db/sql/tool_insert.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/db/sql/tool_insert.sql,v
diff -u -r1.12 -r1.13
--- lams_tool_vote/db/sql/tool_insert.sql 8 Jan 2008 01:32:12 -0000 1.12
+++ lams_tool_vote/db/sql/tool_insert.sql 20 Mar 2008 04:31:07 -0000 1.13
@@ -49,7 +49,8 @@
classpath_addition,
context_file,
create_date_time,
-modified_date_time
+modified_date_time,
+supports_outputs
)
VALUES
(
@@ -79,6 +80,7 @@
'lams-tool-lavote11.jar',
'/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml',
NOW(),
-NOW()
+NOW(),
+1
)
Index: lams_tool_vote/db/sql/updatescripts/updateTo20080108.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/db/sql/updatescripts/Attic/updateTo20080108.sql,v
diff -u -r1.2 -r1.3
--- lams_tool_vote/db/sql/updatescripts/updateTo20080108.sql 10 Jan 2008 23:16:21 -0000 1.2
+++ lams_tool_vote/db/sql/updatescripts/updateTo20080108.sql 20 Mar 2008 04:31:07 -0000 1.3
@@ -11,6 +11,8 @@
UPDATE lams_tool SET modified_date_time = NOW() WHERE tool_signature = 'lavote11';
+update lams_tool set supports_outputs = 1 where tool_signature = "lavote11";
+
-- update the tool version - special code that should only be executed if the upgrade is being done manually.
-- if it is being done via the tool deployer then it will update the version automatically.
-- UPDATE lams_tool SET tool_version = "20080108" WHERE tool_signature = "lavote11";
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml,v
diff -u -r1.7 -r1.8
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml 26 Sep 2006 02:26:47 -0000 1.7
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/voteApplicationContext.xml 20 Mar 2008 04:29:24 -0000 1.8
@@ -63,7 +63,12 @@
-
+
+
+
+ org.lamsfoundation.lams.tool.vote.ApplicationResources
+
+
@@ -81,6 +86,7 @@
+
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java,v
diff -u -r1.37 -r1.38
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java 9 May 2007 00:52:26 -0000 1.37
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java 20 Mar 2008 04:29:24 -0000 1.38
@@ -25,13 +25,15 @@
import java.io.InputStream;
import java.util.List;
import java.util.Set;
+import java.util.SortedMap;
import org.lamsfoundation.lams.contentrepository.ITicket;
import org.lamsfoundation.lams.contentrepository.NodeKey;
import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.tool.IToolVO;
+import org.lamsfoundation.lams.tool.ToolOutputDefinition;
import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
@@ -288,5 +290,6 @@
public void persistFile(VoteContent content, VoteUploadedFile file) throws VoteApplicationException;
public List retrieveVoteUploadedFiles(VoteContent Vote) throws VoteApplicationException;
+
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java 20 Mar 2008 04:29:24 -0000 1.1
@@ -0,0 +1,153 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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: VoteOutputFactory.java,v 1.1 2008/03/20 04:29:24 fmalikoff Exp $ */
+package org.lamsfoundation.lams.tool.vote.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import org.lamsfoundation.lams.learningdesign.BranchCondition;
+import org.lamsfoundation.lams.tool.OutputFactory;
+import org.lamsfoundation.lams.tool.OutputType;
+import org.lamsfoundation.lams.tool.ToolOutput;
+import org.lamsfoundation.lams.tool.ToolOutputDefinition;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteSession;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt;
+
+public class VoteOutputFactory extends OutputFactory {
+
+ protected static final String OUTPUT_NAME_NOMINATION_SELECTION = "learner.selection";
+
+ /**
+ * @see org.lamsfoundation.lams.tool.OutputDefinitionFactory#getToolOutputDefinitions(java.lang.Object)
+ */
+ public SortedMap getToolOutputDefinitions(Object toolContentObject) {
+
+ TreeMap definitionMap = new TreeMap();
+
+ if ( toolContentObject != null ) {
+
+ VoteContent content = (VoteContent) toolContentObject;
+
+ if ( content.getMaxNominationCount() != null && ! content.getMaxNominationCount().equals("1") ) {
+ log.error("Unable to build output definitions for Voting if the user can have more than one nomination. Vote "+content);
+ } else if ( content.isAllowText() ) {
+ log.error("Unable to build output definitions for Voting if the user can enter free text. Vote "+content);
+ } else {
+
+ ToolOutputDefinition definition = buildLongOutputDefinition(OUTPUT_NAME_NOMINATION_SELECTION);
+ if ( definition.getDefaultConditions() == null )
+ definition.setDefaultConditions(new ArrayList());
+
+ List defaultConditions = definition.getDefaultConditions();
+ int min = 1;
+ int max = 1;
+
+ Iterator iter = content.getVoteQueContents().iterator();
+ while ( iter.hasNext() ) {
+ VoteQueContent nomination = (VoteQueContent) iter.next();
+ int displayOrder = nomination.getDisplayOrder();
+ if ( displayOrder < min ) min = displayOrder;
+ if ( displayOrder > max ) max = displayOrder;
+ String displayOrderAsString = new Long(displayOrder).toString();
+ defaultConditions.add(new BranchCondition(null, null, new Integer(1), OUTPUT_NAME_NOMINATION_SELECTION,
+ nomination.getQuestion(),
+ OutputType.OUTPUT_LONG.toString(),
+ displayOrderAsString,
+ displayOrderAsString,
+ null));
+ }
+ definition.setStartValue(new Long(min));
+ definition.setEndValue(new Long(max));
+
+ definitionMap.put(OUTPUT_NAME_NOMINATION_SELECTION, definition);
+
+ }
+ } else {
+ log.error("Unable to build output definitions for Vote as no tool content object supplied.");
+ }
+
+ return definitionMap;
+ }
+
+ public SortedMap getToolOutput(List names, IVoteService voteService, Long toolSessionId, Long learnerId) {
+
+ VoteSession session = voteService.findVoteSessionById(toolSessionId);
+ VoteQueUsr queUser = voteService.getVoteUserBySession(learnerId, session.getUid());
+
+ TreeMap output = new TreeMap();
+ if ( names == null || names.contains(OUTPUT_NAME_NOMINATION_SELECTION) ) {
+ output.put(OUTPUT_NAME_NOMINATION_SELECTION, getDisplayOrderOfVoteQueContent(queUser) );
+ }
+ return output;
+ }
+
+ public ToolOutput getToolOutput(String name, IVoteService voteService, Long toolSessionId, Long learnerId) {
+ if ( name != null ) {
+ VoteSession session = voteService.findVoteSessionById(toolSessionId);
+ VoteQueUsr queUser = voteService.getVoteUserBySession(learnerId, session.getUid());
+
+ if ( name.equals(OUTPUT_NAME_NOMINATION_SELECTION) ) {
+ return getDisplayOrderOfVoteQueContent(queUser);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get the selected nomination for this user.
+ */
+ private ToolOutput getDisplayOrderOfVoteQueContent(VoteQueUsr queUser) {
+
+ if ( queUser != null ) {
+ Set voteAttempts = queUser.getVoteUsrAttempts();
+ if ( voteAttempts.size() > 0 ) {
+ if ( voteAttempts.size() > 1)
+ log.error("Attempting to match on nomination, but more than one nomination selected for this user. Taking first nomination which isn't a free text entry. User "+queUser);
+
+ Iterator iter = voteAttempts.iterator();
+ while ( iter.hasNext() ) {
+ VoteUsrAttempt attempt = (VoteUsrAttempt) iter.next();
+ // VoteQueContentId == 1 indicates that it is a free text entry
+ if ( attempt.getVoteQueContentId().longValue() != 1) {
+ VoteQueContent nomination = attempt.getVoteQueContent();
+ return new ToolOutput(OUTPUT_NAME_NOMINATION_SELECTION, getDescription(OUTPUT_NAME_NOMINATION_SELECTION), new Long(nomination.getDisplayOrder()));
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java,v
diff -u -r1.58 -r1.59
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java 5 Sep 2007 08:05:12 -0000 1.58
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java 20 Mar 2008 04:29:24 -0000 1.59
@@ -62,7 +62,6 @@
import org.lamsfoundation.lams.tool.ToolOutputDefinition;
import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
import org.lamsfoundation.lams.tool.ToolSessionManager;
-import org.lamsfoundation.lams.tool.vote.util.VoteToolContentHandler;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
import org.lamsfoundation.lams.tool.exception.LamsToolServiceException;
import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
@@ -128,8 +127,9 @@
private ILamsToolService toolService;
private IExportToolContentService exportContentService;
- private ICoreNotebookService coreNotebookService;
- private IToolContentHandler voteToolContentHandler = null;
+ private ICoreNotebookService coreNotebookService;
+ private IToolContentHandler voteToolContentHandler = null;
+ private VoteOutputFactory voteOutputFactory;
public VoteServicePOJO(){}
@@ -1695,15 +1695,6 @@
}
}
- /** 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
- */
- public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException {
- return new TreeMap();
- }
-
/**
* Implemented as part of the tool contract. Sets the defineLater to true on this content.
* setAsDefineLater(Long toolContentID) throws DataMissingException, ToolException
@@ -2007,24 +1998,6 @@
}
- /**
- * Get the tool output for the given tool output names.
- * @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();
- }
-
- /**
- * 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 IToolVO getToolBySignature(String toolSignature) throws VoteApplicationException
{
logger.debug("attempt retrieving tool with signature : " + toolSignature);
@@ -2223,6 +2196,37 @@
+ /** Get the definitions for possible output for an activity, based on the toolContentId. Currently we have one definition, which is whether
+ * or not the user has selected a particular answer
+ */
+ public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException {
+ VoteContent content = retrieveVote(toolContentId);
+ if ( content == null ) {
+ long defaultToolContentId = getToolDefaultContentIdBySignature(MY_SIGNATURE);
+ content = retrieveVote(defaultToolContentId);
+ }
+ return getVoteOutputFactory().getToolOutputDefinitions(content);
+ }
+
+ /**
+ * Get the tool output for the given tool output names.
+ * @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 voteOutputFactory.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 voteOutputFactory.getToolOutput(name, this, toolSessionId, learnerId);
+ }
+
+
/* ===============Methods implemented from ToolContentImport102Manager =============== */
@@ -2363,9 +2367,8 @@
e);
}
}
+
-
-
/**
* @return Returns the logger.
*/
@@ -2649,4 +2652,12 @@
public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
this.coreNotebookService = coreNotebookService;
}
+
+ public VoteOutputFactory getVoteOutputFactory() {
+ return voteOutputFactory;
+ }
+
+ public void setVoteOutputFactory(VoteOutputFactory voteOutputFactory) {
+ this.voteOutputFactory = voteOutputFactory;
+ }
}