* DTO that holds export portfolio properties
Fisheye: Tag 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a refers to a dead (removed) revision in file `lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteAllGroupsDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralAuthoringDTO.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralAuthoringDTO.java (.../VoteGeneralAuthoringDTO.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralAuthoringDTO.java (.../VoteGeneralAuthoringDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -23,29 +23,17 @@
package org.lamsfoundation.lams.tool.vote.dto;
import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
/**
- *
dataFlowObjectNames;
@@ -134,36 +116,6 @@
}
/**
- * @return Returns the activeModule.
- */
- public String getActiveModule() {
- return activeModule;
- }
-
- /**
- * @return Returns the isMonitoredContentInUse.
- */
- public String getIsMonitoredContentInUse() {
- return isMonitoredContentInUse;
- }
-
- /**
- * @param isMonitoredContentInUse
- * The isMonitoredContentInUse to set.
- */
- public void setIsMonitoredContentInUse(String isMonitoredContentInUse) {
- this.isMonitoredContentInUse = isMonitoredContentInUse;
- }
-
- /**
- * @param activeModule
- * The activeModule to set.
- */
- public void setActiveModule(String activeModule) {
- this.activeModule = activeModule;
- }
-
- /**
* @return Returns the activityInstructions.
*/
public String getActivityInstructions() {
@@ -194,66 +146,6 @@
}
/**
- * @return Returns the defaultContentId.
- */
- public String getDefaultContentId() {
- return defaultContentId;
- }
-
- /**
- * @param defaultContentId
- * The defaultContentId to set.
- */
- public void setDefaultContentId(String defaultContentId) {
- this.defaultContentId = defaultContentId;
- }
-
- /**
- * @return Returns the defaultContentIdStr.
- */
- public String getDefaultContentIdStr() {
- return defaultContentIdStr;
- }
-
- /**
- * @param defaultContentIdStr
- * The defaultContentIdStr to set.
- */
- public void setDefaultContentIdStr(String defaultContentIdStr) {
- this.defaultContentIdStr = defaultContentIdStr;
- }
-
- /**
- * @return Returns the defaultOptionContent.
- */
- public String getDefaultOptionContent() {
- return defaultOptionContent;
- }
-
- /**
- * @param defaultOptionContent
- * The defaultOptionContent to set.
- */
- public void setDefaultOptionContent(String defaultOptionContent) {
- this.defaultOptionContent = defaultOptionContent;
- }
-
- /**
- * @return Returns the defineLaterInEditMode.
- */
- public String getDefineLaterInEditMode() {
- return defineLaterInEditMode;
- }
-
- /**
- * @param defineLaterInEditMode
- * The defineLaterInEditMode to set.
- */
- public void setDefineLaterInEditMode(String defineLaterInEditMode) {
- this.defineLaterInEditMode = defineLaterInEditMode;
- }
-
- /**
* @return Returns the exceptionMaxNominationInvalid.
*/
public String getExceptionMaxNominationInvalid() {
@@ -269,36 +161,6 @@
}
/**
- * @return Returns the isDefineLater.
- */
- public String getIsDefineLater() {
- return isDefineLater;
- }
-
- /**
- * @param isDefineLater
- * The isDefineLater to set.
- */
- public void setIsDefineLater(String isDefineLater) {
- this.isDefineLater = isDefineLater;
- }
-
- /**
- * @return Returns the maxOptionIndex.
- */
- public int getMaxOptionIndex() {
- return maxOptionIndex;
- }
-
- /**
- * @param maxOptionIndex
- * The maxOptionIndex to set.
- */
- public void setMaxOptionIndex(int maxOptionIndex) {
- this.maxOptionIndex = maxOptionIndex;
- }
-
- /**
* @return Returns the toolContentID.
*/
public String getToolContentID() {
@@ -359,21 +221,6 @@
}
/**
- * @return Returns the mapOptionsContent.
- */
- public Map getMapOptionsContent() {
- return mapOptionsContent;
- }
-
- /**
- * @param mapOptionsContent
- * The mapOptionsContent to set.
- */
- public void setMapOptionsContent(Map mapOptionsContent) {
- this.mapOptionsContent = mapOptionsContent;
- }
-
- /**
* @return Returns the userExceptionMaxNominationInvalid.
*/
public String getUserExceptionMaxNominationInvalid() {
@@ -419,21 +266,6 @@
}
/**
- * @return Returns the editActivityEditMode.
- */
- public String getEditActivityEditMode() {
- return editActivityEditMode;
- }
-
- /**
- * @param editActivityEditMode
- * The editActivityEditMode to set.
- */
- public void setEditActivityEditMode(String editActivityEditMode) {
- this.editActivityEditMode = editActivityEditMode;
- }
-
- /**
* @return Returns the userExceptionNoToolSessions.
*/
public String getUserExceptionNoToolSessions() {
@@ -472,30 +304,6 @@
return 0;
}
- public String toString() {
- return new ToStringBuilder(this).append("activeModule: ", activeModule)
- .append("contentFolderID: ", contentFolderID).append("editableQuestionText: ", editableQuestionText)
- .append("reflectionSubject: ", reflectionSubject)
- .append("mapNominationContent: ", mapNominationContent)
- .append("exceptionMaxNominationInvalid: ", exceptionMaxNominationInvalid)
- .append("toolContentID: ", toolContentID).append("defaultContentId: ", defaultContentId)
- .append("defaultContentIdStr: ", defaultContentIdStr).append("reflect: ", reflect)
- .append("allowText: ", allowText)
- .append("showResults: ", showResults).append("lockOnFinish: ", lockOnFinish)
- .append("maxNominationCount: ", maxNominationCount).append("minNominationCount: ", minNominationCount)
- .append("activityTitle: ", activityTitle).append("activityInstructions: ", activityInstructions)
- .append("maxOptionIndex: ", maxOptionIndex).append("defaultOptionContent: ", defaultOptionContent)
- .append("mapOptionsContent: ", mapOptionsContent)
- .append("userExceptionMaxNominationInvalid: ", userExceptionMaxNominationInvalid)
- .append("userExceptionFilenameEmpty: ", userExceptionFilenameEmpty)
- .append("isMonitoredContentInUse: ", isMonitoredContentInUse)
- .append("validationError: ", validationError)
- .append("userExceptionOptionsDuplicate: ", userExceptionOptionsDuplicate)
- .append("userExceptionNoToolSessions: ", userExceptionNoToolSessions)
- .append("httpSessionID: ", httpSessionID).append("editActivityEditMode: ", editActivityEditMode)
- .toString();
- }
-
/**
* @return Returns the contentFolderID.
*/
@@ -512,21 +320,6 @@
}
/**
- * @return Returns the editableQuestionFeedback.
- */
- public String getEditableQuestionFeedback() {
- return editableQuestionFeedback;
- }
-
- /**
- * @param editableQuestionFeedback
- * The editableQuestionFeedback to set.
- */
- public void setEditableQuestionFeedback(String editableQuestionFeedback) {
- this.editableQuestionFeedback = editableQuestionFeedback;
- }
-
- /**
* @return Returns the editableQuestionText.
*/
public String getEditableQuestionText() {
@@ -602,21 +395,6 @@
}
/**
- * @return Returns the editableNominationFeedback.
- */
- public String getEditableNominationFeedback() {
- return editableNominationFeedback;
- }
-
- /**
- * @param editableNominationFeedback
- * The editableNominationFeedback to set.
- */
- public void setEditableNominationFeedback(String editableNominationFeedback) {
- this.editableNominationFeedback = editableNominationFeedback;
- }
-
- /**
* @return Returns the editableNominationText.
*/
public String getEditableNominationText() {
@@ -632,21 +410,6 @@
}
/**
- * @return Returns the mapNominationContent.
- */
- public Map getMapNominationContent() {
- return mapNominationContent;
- }
-
- /**
- * @param mapNominationContent
- * The mapNominationContent to set.
- */
- public void setMapNominationContent(Map mapNominationContent) {
- this.mapNominationContent = mapNominationContent;
- }
-
- /**
* @return Returns the currentUid.
*/
public String getCurrentUid() {
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java (.../VoteGeneralMonitoringDTO.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java (.../VoteGeneralMonitoringDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -25,39 +25,28 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
/**
- *
* DTO that holds monitoring flow properties
- *
*
* @author Ozgur Demirtas
*/
public class VoteGeneralMonitoringDTO implements Comparable {
- protected String defineLaterInEditMode;
protected String requestLearningReport;
protected String userExceptionNoToolSessions;
protected String userExceptionContentInUse;
protected String userExceptionContentDoesNotExist;
protected String userExceptionNoStudentActivity;
- protected String isMonitoredContentInUse;
- protected String monitoredContentInUse;
- protected String activeModule;
protected String currentTab;
protected String activityTitle;
protected String activityInstructions;
- protected String defaultOptionContent;
protected String countAllUsers;
protected String countSessionComplete;
protected String isPortfolioExport;
protected String existsOpenVotes;
protected String responseId;
- protected String currentUid;
protected String toolContentID;
- protected Map mapOptionsContent;
protected List listMonitoredAnswersContainerDto;
protected List listUserEntries;
@@ -106,21 +95,6 @@
}
/**
- * @return Returns the activeModule.
- */
- public String getActiveModule() {
- return activeModule;
- }
-
- /**
- * @param activeModule
- * The activeModule to set.
- */
- public void setActiveModule(String activeModule) {
- this.activeModule = activeModule;
- }
-
- /**
* @return Returns the currentTab.
*/
public String getCurrentTab() {
@@ -136,21 +110,6 @@
}
/**
- * @return Returns the defaultOptionContent.
- */
- public String getDefaultOptionContent() {
- return defaultOptionContent;
- }
-
- /**
- * @param defaultOptionContent
- * The defaultOptionContent to set.
- */
- public void setDefaultOptionContent(String defaultOptionContent) {
- this.defaultOptionContent = defaultOptionContent;
- }
-
- /**
* @return Returns the userExceptionContentInUse.
*/
public String getUserExceptionContentInUse() {
@@ -196,21 +155,6 @@
}
/**
- * @return Returns the defineLaterInEditMode.
- */
- public String getDefineLaterInEditMode() {
- return defineLaterInEditMode;
- }
-
- /**
- * @param defineLaterInEditMode
- * The defineLaterInEditMode to set.
- */
- public void setDefineLaterInEditMode(String defineLaterInEditMode) {
- this.defineLaterInEditMode = defineLaterInEditMode;
- }
-
- /**
* @return Returns the requestLearningReport.
*/
public String getRequestLearningReport() {
@@ -241,36 +185,6 @@
}
/**
- * @return Returns the isMonitoredContentInUse.
- */
- public String getIsMonitoredContentInUse() {
- return isMonitoredContentInUse;
- }
-
- /**
- * @param isMonitoredContentInUse
- * The isMonitoredContentInUse to set.
- */
- public void setIsMonitoredContentInUse(String isMonitoredContentInUse) {
- this.isMonitoredContentInUse = isMonitoredContentInUse;
- }
-
- /**
- * @return Returns the mapOptionsContent.
- */
- public Map getMapOptionsContent() {
- return mapOptionsContent;
- }
-
- /**
- * @param mapOptionsContent
- * The mapOptionsContent to set.
- */
- public void setMapOptionsContent(Map mapOptionsContent) {
- this.mapOptionsContent = mapOptionsContent;
- }
-
- /**
* @return Returns the countAllUsers.
*/
public String getCountAllUsers() {
@@ -481,21 +395,6 @@
}
/**
- * @return Returns the currentUid.
- */
- public String getCurrentUid() {
- return currentUid;
- }
-
- /**
- * @param currentUid
- * The currentUid to set.
- */
- public void setCurrentUid(String currentUid) {
- this.currentUid = currentUid;
- }
-
- /**
* @return Returns the responseId.
*/
public String getResponseId() {
@@ -555,28 +454,6 @@
this.sessionUserCount = sessionUserCount;
}
- public String toString() {
- return new ToStringBuilder(this).append("toolContentID: ", toolContentID)
- .append("activeModule: ", activeModule).append("monitoredContentInUse: ", monitoredContentInUse)
- .append("currentTab: ", currentTab)
- .append("requestLearningReport: ", requestLearningReport)
- .append("userExceptionNoToolSessions: ", userExceptionNoToolSessions)
- .append("userExceptionContentDoesNotExist: ", userExceptionContentDoesNotExist)
- .append("userExceptionNoStudentActivity: ", userExceptionNoStudentActivity)
- .append("isMonitoredContentInUse: ", isMonitoredContentInUse).append("activityTitle: ", activityTitle)
- .append("activityInstructions: ", activityInstructions)
- .append("userExceptionContentInUse: ", userExceptionContentInUse)
- .append("defaultOptionContent: ", defaultOptionContent).append("countAllUsers: ", countAllUsers)
- .append("countSessionComplete: ", countSessionComplete)
- .append("isPortfolioExport: ", isPortfolioExport)
- .append("listMonitoredAnswersContainerDto: ", listMonitoredAnswersContainerDto)
- .append("listUserEntries: ", listUserEntries).append("existsOpenVotes: ", existsOpenVotes)
- .append("sessionDtos: ", sessionDTOs).append("mapStudentsVoted: ", mapStudentsVoted)
- .append("responseId: ", responseId).append("currentUid: ", currentUid)
- .append("sessionUserCount: ", sessionUserCount)
- .append("completedSessionUserCount: ", completedSessionUserCount).toString();
- }
-
public int compareTo(Object o) {
VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = (VoteGeneralMonitoringDTO) o;
@@ -587,21 +464,6 @@
}
/**
- * @return Returns the monitoredContentInUse.
- */
- public String getMonitoredContentInUse() {
- return monitoredContentInUse;
- }
-
- /**
- * @param monitoredContentInUse
- * The monitoredContentInUse to set.
- */
- public void setMonitoredContentInUse(String monitoredContentInUse) {
- this.monitoredContentInUse = monitoredContentInUse;
- }
-
- /**
* @return Returns the contentFolderID.
*/
public String getContentFolderID() {
Fisheye: Tag 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a refers to a dead (removed) revision in file `lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteNominationContentDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteQuestionDTO.java
===================================================================
diff -u
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteQuestionDTO.java (revision 0)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteQuestionDTO.java (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -0,0 +1,105 @@
+/****************************************************************
+ * 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.vote.dto;
+
+
+/**
+ * Votes dto
+ *
+ * @author Ozgur Demirtas
+ */
+public class VoteQuestionDTO implements Comparable {
+ private Long uid;
+ private String question;
+ private String displayOrder;
+
+ public int compareTo(Object o) {
+ VoteMonitoredUserDTO voteMonitoredUserDTO = (VoteMonitoredUserDTO) o;
+
+ if (voteMonitoredUserDTO == null)
+ return 1;
+ else
+ return 0;
+ }
+
+ /**
+ * @return Returns the uid.
+ */
+ public Long getUid() {
+ return uid;
+ }
+
+ /**
+ * @param uid
+ * The uid to set.
+ */
+ public void setUid(Long uid) {
+ this.uid = uid;
+ }
+
+ /**
+ * @return Returns the displayOrder.
+ */
+ public String getDisplayOrder() {
+ return displayOrder;
+ }
+
+ /**
+ * @param displayOrder
+ * The displayOrder to set.
+ */
+ public void setDisplayOrder(String displayOrder) {
+ this.displayOrder = displayOrder;
+ }
+
+ /**
+ * @return Returns the question.
+ */
+ public String getNomination() {
+ return question;
+ }
+
+ /**
+ * @param question
+ * The question to set.
+ */
+ public void setNomination(String question) {
+ this.question = question;
+ }
+
+ /**
+ * @return Returns the question.
+ */
+ public String getQuestion() {
+ return question;
+ }
+
+ /**
+ * @param question
+ * The question to set.
+ */
+ public void setQuestion(String question) {
+ this.question = question;
+ }
+}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java (.../VoteStatsDTO.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java (.../VoteStatsDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -26,59 +26,59 @@
import org.apache.commons.lang.builder.ToStringBuilder;
-
/**
- * DTO that holds stats data
+ *
+ * DTO that holds stats data
*
*
* @author Ozgur Demirtas
*/
-public class VoteStatsDTO implements Comparable
-{
- private String countAllUsers;
-
- private String countSessionComplete;
-
- public String toString() {
- return new ToStringBuilder(this)
- .append("question", countAllUsers)
- .append("countSessionComplete", countSessionComplete)
- .toString();
+public class VoteStatsDTO implements Comparable {
+ private String countAllUsers;
+
+ private String countSessionComplete;
+
+ public String toString() {
+ return new ToStringBuilder(this).append("question", countAllUsers)
+ .append("countSessionComplete", countSessionComplete).toString();
}
-
- public int compareTo(Object o)
- {
- VoteStatsDTO qaStatsDTO = (VoteStatsDTO) o;
-
- if (qaStatsDTO == null)
- return 1;
- else
- return 0;
+
+ public int compareTo(Object o) {
+ VoteStatsDTO qaStatsDTO = (VoteStatsDTO) o;
+
+ if (qaStatsDTO == null)
+ return 1;
+ else
+ return 0;
}
-
-
+
/**
* @return Returns the countAllUsers.
*/
public String getCountAllUsers() {
- return countAllUsers;
+ return countAllUsers;
}
+
/**
- * @param countAllUsers The countAllUsers to set.
+ * @param countAllUsers
+ * The countAllUsers to set.
*/
public void setCountAllUsers(String countAllUsers) {
- this.countAllUsers = countAllUsers;
+ this.countAllUsers = countAllUsers;
}
+
/**
* @return Returns the countSessionComplete.
*/
public String getCountSessionComplete() {
- return countSessionComplete;
+ return countSessionComplete;
}
+
/**
- * @param countSessionComplete The countSessionComplete to set.
+ * @param countSessionComplete
+ * The countSessionComplete to set.
*/
public void setCountSessionComplete(String countSessionComplete) {
- this.countSessionComplete = countSessionComplete;
+ this.countSessionComplete = countSessionComplete;
}
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java
===================================================================
diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java (.../VoteContent.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteContent.java (.../VoteContent.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -29,9 +29,6 @@
import java.util.TreeSet;
import org.apache.commons.lang.builder.ToStringBuilder;
-import org.lamsfoundation.lams.contentrepository.ItemNotFoundException;
-import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
-import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
/**
*
@@ -85,9 +82,6 @@
/** nullable persistent field */
private boolean lockOnFinish;
- /** nullable persistent field */
- private boolean contentInUse;
-
private boolean showResults;
/** persistent field */
@@ -113,8 +107,8 @@
public VoteContent(Long voteContentId, String content, String title, String instructions, boolean defineLater,
Date creationDate, Date updateDate, boolean allowText, boolean useSelectLeaderToolOuput, boolean reflect,
String reflectionSubject, String maxNominationCount, String minNominationCount, long createdBy,
- boolean lockOnFinish, boolean contentInUse, boolean showResults, Short maxExternalInputs,
- Short externalInputsAdded, Set voteQueContents, Set voteSessions) {
+ boolean lockOnFinish, boolean showResults, Short maxExternalInputs, Short externalInputsAdded,
+ Set voteQueContents, Set voteSessions) {
this.voteContentId = voteContentId;
this.content = content;
this.title = title;
@@ -130,7 +124,6 @@
this.reflectionSubject = reflectionSubject;
this.createdBy = createdBy;
this.lockOnFinish = lockOnFinish;
- this.contentInUse = contentInUse;
this.showResults = showResults;
this.voteQueContents = voteQueContents;
this.voteSessions = voteSessions;
@@ -161,14 +154,13 @@
* the new mc content id.
* @return the new mc content object.
*/
- public static VoteContent newInstance(IToolContentHandler toolContentHandler, VoteContent vote, Long newContentId)
- throws ItemNotFoundException, RepositoryCheckedException {
+ public static VoteContent newInstance(VoteContent vote, Long newContentId) {
VoteContent newContent = new VoteContent(newContentId, vote.getContent(), vote.getTitle(),
vote.getInstructions(), vote.isDefineLater(), vote.getCreationDate(), vote.getUpdateDate(),
vote.isAllowText(), vote.isUseSelectLeaderToolOuput(), vote.isReflect(), vote.getReflectionSubject(),
vote.getMaxNominationCount(), vote.getMinNominationCount(), vote.getCreatedBy(), vote.isLockOnFinish(),
- vote.isContentInUse(), vote.isShowResults(), vote.getMaxExternalInputs(),
- vote.getExternalInputsAdded(), new TreeSet(), new TreeSet());
+ vote.isShowResults(), vote.getMaxExternalInputs(), vote.getExternalInputsAdded(), new TreeSet(),
+ new TreeSet());
newContent.setVoteQueContents(vote.deepCopyMcQueContent(newContent));
newContent.setAssignedDataFlowObject(vote.getAssignedDataFlowObject());
@@ -243,14 +235,6 @@
this.createdBy = createdBy;
}
- public boolean isContentInUse() {
- return contentInUse;
- }
-
- public void setContentInUse(boolean contentInUse) {
- this.contentInUse = contentInUse;
- }
-
/**
* @return Returns the voteQueContents.
*/
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteQueContent.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteQueContent.java (.../VoteQueContent.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/pojos/VoteQueContent.java (.../VoteQueContent.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -20,22 +20,15 @@
* http://www.gnu.org/licenses/gpl.txt
* ***********************************************************************/
-
package org.lamsfoundation.lams.tool.vote.pojos;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
import org.apache.commons.lang.builder.ToStringBuilder;
-
/**
- *
Persistent object/bean that defines the question content for the Voting tool.
- * Provides accessors and mutators to get/set attributes
- * It maps to database table: tl_lavote11_nomination_content
- *
+ * Persistent object/bean that defines the question content for the Voting tool. Provides accessors and mutators to
+ * get/set attributes It maps to database table: tl_lavote11_nomination_content
*
* @author Ozgur Demirtas
*/
@@ -46,94 +39,72 @@
/** nullable persistent field */
private String question;
-
+
private int displayOrder;
-
/** non persistent field */
private Long voteContentId;
-
+
/** persistent field */
private org.lamsfoundation.lams.tool.vote.pojos.VoteContent voteContent;
-
- /** persistent field */
- private Set voteUsrAttempts;
-
- public VoteQueContent(String question, VoteContent voteContent, Set voteUsrAttempts) {
- this.question = question;
- this.voteContent=voteContent;
- this.voteUsrAttempts = voteUsrAttempts;
+
+ public VoteQueContent(String question, VoteContent voteContent) {
+ this.question = question;
+ this.voteContent = voteContent;
}
- public VoteQueContent(String question, int displayOrder, VoteContent voteContent, Set voteUsrAttempts) {
- this.question = question;
- this.displayOrder=displayOrder;
- this.voteContent=voteContent;
- this.voteUsrAttempts = voteUsrAttempts;
+ public VoteQueContent(String question, int displayOrder, VoteContent voteContent) {
+ this.question = question;
+ this.displayOrder = displayOrder;
+ this.voteContent = voteContent;
}
/** default constructor */
public VoteQueContent() {
}
-
-
+
/**
- * gets called by copyToolContent
+ * gets called by copyToolContent
*
* Copy constructor
- * @param queContent the original qa question content
+ *
+ * @param queContent
+ * the original qa question content
* @return the new qa question content object
*/
public static VoteQueContent newInstance(VoteQueContent queContent, int displayOrder, VoteContent newMcContent) {
- VoteQueContent newQueContent = new VoteQueContent(queContent.getQuestion(), displayOrder, newMcContent,
- new TreeSet());
+ VoteQueContent newQueContent = new VoteQueContent(queContent.getQuestion(), displayOrder, newMcContent);
return newQueContent;
}
-
-
+
public Long getUid() {
- return this.uid;
+ return this.uid;
}
public void setUid(Long uid) {
- this.uid = uid;
+ this.uid = uid;
}
public String getQuestion() {
- return this.question;
+ return this.question;
}
public void setQuestion(String question) {
- this.question = question;
+ this.question = question;
}
public org.lamsfoundation.lams.tool.vote.pojos.VoteContent getMcContent() {
- return this.voteContent;
+ return this.voteContent;
}
public void setMcContent(org.lamsfoundation.lams.tool.vote.pojos.VoteContent voteContent) {
- this.voteContent = voteContent;
+ this.voteContent = voteContent;
}
- public Set getVoteUsrAttempts() {
- if (this.voteUsrAttempts == null)
- setVoteUsrAttempts(new HashSet());
- return this.voteUsrAttempts;
- }
-
-
- public void setMcUsrAttempts(Set voteUsrAttempts) {
- this.voteUsrAttempts = voteUsrAttempts;
- }
-
-
public String toString() {
- return new ToStringBuilder(this)
- .append("uid", getUid())
- .toString();
+ return new ToStringBuilder(this).append("uid", getUid()).toString();
}
-
public int compareTo(Object o) {
VoteQueContent queContent = (VoteQueContent) o;
@@ -143,49 +114,49 @@
else
return (int) (uid.longValue() - queContent.uid.longValue());
}
-
+
/**
* @return Returns the voteContentId.
*/
public Long getVoteContentId() {
- return voteContentId;
+ return voteContentId;
}
+
/**
- * @param voteContentId The voteContentId to set.
+ * @param voteContentId
+ * The voteContentId to set.
*/
public void setVoteContentId(Long voteContentId) {
- this.voteContentId = voteContentId;
+ this.voteContentId = voteContentId;
}
+
/**
* @return Returns the voteContent.
*/
public org.lamsfoundation.lams.tool.vote.pojos.VoteContent getVoteContent() {
- return voteContent;
+ return voteContent;
}
+
/**
- * @param voteContent The voteContent to set.
+ * @param voteContent
+ * The voteContent to set.
*/
- public void setVoteContent(
- org.lamsfoundation.lams.tool.vote.pojos.VoteContent voteContent) {
- this.voteContent = voteContent;
+ public void setVoteContent(org.lamsfoundation.lams.tool.vote.pojos.VoteContent voteContent) {
+ this.voteContent = voteContent;
}
- /**
- * @param voteUsrAttempts The voteUsrAttempts to set.
- */
- public void setVoteUsrAttempts(Set voteUsrAttempts) {
- this.voteUsrAttempts = voteUsrAttempts;
- }
/**
* @return Returns the displayOrder.
*/
public int getDisplayOrder() {
- return displayOrder;
+ return displayOrder;
}
+
/**
- * @param displayOrder The displayOrder to set.
+ * @param displayOrder
+ * The displayOrder to set.
*/
public void setDisplayOrder(int displayOrder) {
- this.displayOrder = displayOrder;
+ this.displayOrder = displayOrder;
}
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -29,7 +29,6 @@
import javax.servlet.http.HttpServletRequest;
import org.lamsfoundation.lams.learningdesign.DataFlowObject;
-import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.tool.IToolVO;
import org.lamsfoundation.lams.tool.ToolOutput;
@@ -41,6 +40,7 @@
import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -51,33 +51,33 @@
/**
* @author Ozgur Demirtas
*
- * Interface that defines the contract Voting service provider must follow.
+ * Interface that defines the contract Voting service provider must follow.
*/
public interface IVoteService {
-
+
/**
* @param user
* @param toolSessionId
* @return
*/
boolean isUserGroupLeader(VoteQueUsr user, Long toolSessionId);
-
+
/**
* Set specified user as a leader. Also the previous leader (if any) is marked as non-leader.
*
* @param userId
* @param toolSessionID
*/
VoteQueUsr checkLeaderSelectToolForSessionLeader(VoteQueUsr user, Long toolSessionID);
-
+
/**
- * Check user has the same answers logs as group leader. If not - creates missing ones.
+ * Check user has the same answers logs as group leader. If not - creates missing ones.
*
* @param user
* @param leader
*/
void copyAnswersFromLeader(VoteQueUsr user, VoteQueUsr leader);
-
+
/**
* Generates chart data for the learner module and monitoring module Summary tab (Individual Sessions mode)
*
@@ -88,7 +88,7 @@
*/
VoteGeneralLearnerFlowDTO prepareChartData(HttpServletRequest request, Long toolContentID, Long toolSessionUid,
VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO);
-
+
/**
* Generates data for all sessions in the Monitoring Summary, including all sessions summary.
*
@@ -98,152 +98,127 @@
LinkedList getSessionDTOs(Long toolContentID);
List getOpenVotes(Long voteContentUid, Long currentSessionId, Long userId);
-
+
List getReflectionData(VoteContent voteContent, Long userID);
- void createVote(VoteContent voteContent) throws VoteApplicationException;
+ VoteContent getVoteContent(Long toolContentID);
- VoteContent retrieveVote(Long toolContentID) throws VoteApplicationException;
+ VoteUsrAttempt getAttemptByUID(Long uid);
- VoteUsrAttempt getAttemptByUID(Long uid) throws VoteApplicationException;
+ void createVoteQue(VoteQueContent voteQueContent);
- void createVoteQue(VoteQueContent voteQueContent) throws VoteApplicationException;
+ void createVoteSession(VoteSession voteSession);
- void createVoteSession(VoteSession voteSession) throws VoteApplicationException;
+ void createVoteQueUsr(VoteQueUsr voteQueUsr);
- void createVoteQueUsr(VoteQueUsr voteQueUsr) throws VoteApplicationException;
+ VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long sessionUid);
- VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long sessionUid)
- throws VoteApplicationException;
+ VoteQueUsr getUserByUserId(Long userId);
- VoteQueUsr retrieveVoteQueUsr(Long userId) throws VoteApplicationException;
+ List getVoteUserBySessionUid(final Long voteSessionUid);
- List getVoteUserBySessionUid(final Long voteSessionUid) throws VoteApplicationException;
+ int getCompletedVoteUserBySessionUid(final Long voteSessionUid);
- int getCompletedVoteUserBySessionUid(final Long voteSessionUid) throws VoteApplicationException;
+ VoteQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long voteContentUid);
- VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid)
- throws VoteApplicationException;
-
Set getAttemptsForUserAndSessionUseOpenAnswer(final Long userUid, final Long sessionUid);
- Set getSessionUserEntriesSet(final Long voteSessionUid) throws VoteApplicationException;
+ Set getSessionUserEntriesSet(final Long voteSessionUid);
- void createVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException;
+ void createVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt);
- void updateVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException;
+ void updateVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt);
- List getUserBySessionOnly(final VoteSession voteSession) throws VoteApplicationException;
+ List getUserBySessionOnly(final VoteSession voteSession);
- void hideOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException;
+ void hideOpenVote(VoteUsrAttempt voteUsrAttempt);
- void showOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException;
+ void showOpenVote(VoteUsrAttempt voteUsrAttempt);
- void updateVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException;
+ int getAttemptsForQuestionContent(final Long questionUid);
- int getAttemptsForQuestionContent(final Long questionUid) throws VoteApplicationException;
+ boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent);
- boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent) throws VoteApplicationException;
+ int getUserEnteredVotesCountForContent(final Long voteContentUid);
- int getUserEnteredVotesCountForContent(final Long voteContentUid) throws VoteApplicationException;
+ List getAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long voteSessionUid);
- List getAttemptsForQuestionContentAndSessionUid(final Long questionUid,
- final Long voteSessionUid);
+ int getStandardAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long voteSessionId);
- int getStandardAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long voteSessionId)
- throws VoteApplicationException;
+ int getSessionEntriesCount(final Long voteSessionId);
- int getSessionEntriesCount(final Long voteSessionId) throws VoteApplicationException;
+ List getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid);
- List getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid)
- throws VoteApplicationException;
+ VoteUsrAttempt getAttemptForUserAndQuestionContentAndSession(final Long queUsrId, final Long questionUid,
+ final Long toolSessionUid);
- VoteUsrAttempt getAttemptForUserAndQuestionContentAndSession(final Long queUsrId,
- final Long questionUid, final Long toolSessionUid) throws VoteApplicationException;
+ VoteQueContent getQuestionByUid(Long uid);
- List retrieveVoteQueContentsByToolContentId(long qaContentId) throws VoteApplicationException;
+ void removeVoteQueContent(VoteQueContent voteQueContent);
- VoteQueContent retrieveVoteQueContentByUID(Long uid) throws VoteApplicationException;
+ VoteQueContent getVoteQueContentByUID(Long uid);
- void removeVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException;
+ void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent);
- VoteQueContent getVoteQueContentByUID(Long uid) throws VoteApplicationException;
+ List getStandardAttemptsByQuestionUid(final Long questionUid);
+
+ VoteQueContent getDefaultVoteContentFirstQuestion();
- void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException;
+ VoteQueUsr getVoteUserByUID(Long uid);
- void removeQuestionContentByVoteUid(final Long voteContentUid) throws VoteApplicationException;
+ void updateVoteUser(VoteQueUsr voteUser);
- void cleanAllQuestionsSimple(final Long voteContentUid) throws VoteApplicationException;
+ void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid);
- void resetAllQuestions(final Long voteContentUid) throws VoteApplicationException;
+ VoteQueUsr getUserById(long voteQueUsrId);
- void cleanAllQuestions(final Long voteContentUid) throws VoteApplicationException;
+ VoteSession getSessionBySessionId(Long voteSessionId);
- List getStandardAttemptsForQuestionContentAndContentUid(final Long questionUid);
+ void updateVote(VoteContent vote);
- VoteQueContent getQuestionContentByQuestionText(final String question, final Long voteContentUid);
+ void updateVoteSession(VoteSession voteSession);
- void removeVoteQueContentByUID(Long uid) throws VoteApplicationException;
+ VoteSession getVoteSessionByUID(Long uid);
- VoteQueUsr getVoteUserByUID(Long uid) throws VoteApplicationException;
-
- void updateVoteUser(VoteQueUsr voteUser) throws VoteApplicationException;
-
- void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid)
- throws VoteApplicationException;
-
- List getAllQuestionEntries(final Long voteContentId) throws VoteApplicationException;
-
- VoteQueUsr getVoteQueUsrById(long voteQueUsrId) throws VoteApplicationException;
-
- VoteSession retrieveVoteSession(Long voteSessionId) throws VoteApplicationException;
-
- VoteContent retrieveVoteBySessionId(Long voteSessionId) throws VoteApplicationException;
-
- void updateVote(VoteContent vote) throws VoteApplicationException;
-
- void updateVoteSession(VoteSession voteSession) throws VoteApplicationException;
-
- VoteSession getVoteSessionByUID(Long uid) throws VoteApplicationException;
-
/**
* Get the count of all the potential learners for the vote session. This will include the people that have never
* logged into the lesson. Not great, but it is a better estimate of how many users there will be eventually than
* the number of people already known to the tool.
*
* @param voteSessionId
- * The tool session id
+ * The tool session id
*/
- int getVoteSessionPotentialLearnersCount(Long voteSessionId) throws VoteApplicationException;
+ int getVoteSessionPotentialLearnersCount(Long voteSessionId);
- void deleteVote(VoteContent vote) throws VoteApplicationException;
+ void deleteVote(VoteContent vote);
- void deleteVoteById(Long voteId) throws VoteApplicationException;
+ void deleteVoteById(Long voteId);
- void deleteVoteSession(VoteSession voteSession) throws VoteApplicationException;
+ void deleteVoteSession(VoteSession voteSession);
- List getSessionNamesFromContent(VoteContent voteContent) throws VoteApplicationException;
+ List getSessionNamesFromContent(VoteContent voteContent);
- void removeAttempt(VoteUsrAttempt attempt) throws VoteApplicationException;
+ void removeAttempt(VoteUsrAttempt attempt);
- void deleteVoteQueUsr(VoteQueUsr voteQueUsr) throws VoteApplicationException;
+ void deleteVoteQueUsr(VoteQueUsr voteQueUsr);
- User getCurrentUserData(String username) throws VoteApplicationException;
+ User getCurrentUserData(String username);
- int getTotalNumberOfUsers() throws VoteApplicationException;
+ int getTotalNumberOfUsers();
- Lesson getCurrentLesson(long lessonId) throws VoteApplicationException;
+ void saveVoteContent(VoteContent vote);
- void saveVoteContent(VoteContent vote) throws VoteApplicationException;
-
/**
* checks the parameter content in the user responses table
*
* @param voteContent
* @return boolean
* @throws VoteApplicationException
*/
- boolean studentActivityOccurredGlobal(VoteContent voteContent) throws VoteApplicationException;
+ boolean studentActivityOccurredGlobal(VoteContent voteContent);
+
+ void recalculateUserAnswers(VoteContent content, Set oldQuestions,
+ List questionDTOs, List deletedQuestions);
void copyToolContent(Long fromContentId, Long toContentId) throws ToolException;
@@ -258,33 +233,31 @@
ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException;
- ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
- ToolException;
+ ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException;
- IToolVO getToolBySignature(String toolSignature) throws VoteApplicationException;
+ IToolVO getToolBySignature(String toolSignature);
- long getToolDefaultContentIdBySignature(String toolSignature) throws VoteApplicationException;
+ long getToolDefaultContentIdBySignature(String toolSignature);
- VoteQueContent getToolDefaultQuestionContent(long contentId) throws VoteApplicationException;
-
List getToolSessionsForContent(VoteContent vote);
- List getAttemptsForUser(final Long userUid) throws VoteApplicationException;
+ List getAttemptsForUser(final Long userUid);
- int countSessionComplete() throws VoteApplicationException;
+ int countSessionComplete();
- List getAllQuestionEntriesSorted(final long voteContentId) throws VoteApplicationException;
+ List getAllQuestionsSorted(final long voteContentId);
- List getSessionsFromContent(VoteContent mcContent) throws VoteApplicationException;
+ List getSessionsFromContent(VoteContent mcContent);
- Set getAttemptsForUserAndSession(final Long queUsrId, final Long voteSessionUid)
- throws VoteApplicationException;
+ Set getAttemptsForUserAndSession(final Long queUsrId, final Long voteSessionUid);
Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry);
NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID);
- void removeNominationsFromCache(VoteContent voteContent);
+ void removeQuestionsFromCache(VoteContent voteContent);
+
+ void removeVoteContentFromCache(VoteContent voteContent);
ToolOutput getToolInput(Long requestingToolContentId, Integer learnerId);
@@ -293,10 +266,10 @@
void saveDataFlowObjectAssigment(DataFlowObject assignedDataFlowObject);
DataFlowObject getAssignedDataFlowObject(Long toolContentId);
-
+
/**
* Returns whether activity is grouped and therefore it is expected more than one tool session.
- *
+ *
* @param toolContentID
* @return
*/
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteImportContentVersionFilter.java
===================================================================
diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteImportContentVersionFilter.java (.../VoteImportContentVersionFilter.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteImportContentVersionFilter.java (.../VoteImportContentVersionFilter.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -59,4 +59,11 @@
this.removeField(VoteContent.class, "offlineInstructions");
this.removeField(VoteContent.class, "voteAttachments");
}
+
+ /**
+ * Import 20140102 version content to 20140520 version tool server.
+ */
+ public void up20140102To20140520() {
+ this.removeField(VoteContent.class, "contentInUse");
+ }
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java (.../VoteOutputFactory.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteOutputFactory.java (.../VoteOutputFactory.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -124,7 +124,7 @@
public ToolOutput getToolOutput(String name, IVoteService voteService, Long toolSessionId, Long learnerId) {
if (name != null && name.startsWith(VoteOutputFactory.OUTPUT_NAME_NOMINATION_SELECTION)) {
- VoteSession session = voteService.retrieveVoteSession(toolSessionId);
+ VoteSession session = voteService.getSessionBySessionId(toolSessionId);
VoteQueUsr queUser = voteService.getVoteUserBySession(learnerId, session.getUid());
return new ToolOutput(name, getI18NText(VoteOutputFactory.OUTPUT_NAME_NOMINATION_SELECTION, true),
@@ -194,7 +194,7 @@
TreeMap output = null;
- VoteSession session = voteService.retrieveVoteSession(toolSessionId);
+ VoteSession session = voteService.getSessionBySessionId(toolSessionId);
VoteContent content = session.getVoteContent();
VoteQueUsr queUser = voteService.getVoteUserBySession(learnerId, session.getUid());
String i18nDescription = getI18NText(VoteOutputFactory.OUTPUT_NAME_NOMINATION_SELECTION, true);
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java
===================================================================
diff -u -r5b6e51b5d96619f619209830fdab0ed1ef572c05 -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 5b6e51b5d96619f619209830fdab0ed1ef572c05)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -38,21 +38,13 @@
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
-import org.hibernate.Hibernate;
-import org.hibernate.proxy.HibernateProxy;
-import org.lamsfoundation.lams.contentrepository.ItemNotFoundException;
-import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
import org.lamsfoundation.lams.learning.service.ILearnerService;
-import org.lamsfoundation.lams.learningdesign.Activity;
import org.lamsfoundation.lams.learningdesign.DataFlowObject;
-import org.lamsfoundation.lams.learningdesign.ToolActivity;
-import org.lamsfoundation.lams.learningdesign.Transition;
import org.lamsfoundation.lams.learningdesign.dao.IDataFlowDAO;
import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException;
import org.lamsfoundation.lams.learningdesign.service.IExportToolContentService;
import org.lamsfoundation.lams.learningdesign.service.ImportToolContentException;
-import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.notebook.service.ICoreNotebookService;
@@ -61,11 +53,9 @@
import org.lamsfoundation.lams.tool.ToolContentManager;
import org.lamsfoundation.lams.tool.ToolOutput;
import org.lamsfoundation.lams.tool.ToolOutputDefinition;
-import org.lamsfoundation.lams.tool.ToolSession;
import org.lamsfoundation.lams.tool.ToolSessionExportOutputData;
import org.lamsfoundation.lams.tool.ToolSessionManager;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
-import org.lamsfoundation.lams.tool.exception.LamsToolServiceException;
import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.service.ILamsCoreToolService;
@@ -81,6 +71,7 @@
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -100,17 +91,14 @@
import org.springframework.dao.DataAccessException;
/**
+ * The POJO implementation of Voting service. All business logic of Voting tool is implemented in this class. It
+ * translates the request from presentation layer and performs appropriate database operation.
*
* @author Ozgur Demirtas
- *
- * The POJO implementation of Voting service. All business logic of Voting tool
- * is implemented in this class. It translates the request from presentation
- * layer and performs appropriate database operation.
- *
*/
public class VoteServicePOJO implements IVoteService, ToolContentManager, ToolSessionManager,
ToolContentImport102Manager, VoteAppConstants {
- static Logger logger = Logger.getLogger(VoteServicePOJO.class.getName());
+ private static Logger logger = Logger.getLogger(VoteServicePOJO.class.getName());
private IVoteContentDAO voteContentDAO;
private IVoteQueContentDAO voteQueContentDAO;
@@ -134,108 +122,53 @@
public VoteServicePOJO() {
}
-
+
@Override
public boolean isUserGroupLeader(VoteQueUsr user, Long toolSessionId) {
- VoteSession session = retrieveVoteSession(toolSessionId);
+ VoteSession session = getSessionBySessionId(toolSessionId);
VoteQueUsr groupLeader = session.getGroupLeader();
-
+
boolean isUserLeader = (groupLeader != null) && user.getUid().equals(groupLeader.getUid());
return isUserLeader;
}
-
+
@Override
public VoteQueUsr checkLeaderSelectToolForSessionLeader(VoteQueUsr user, Long toolSessionId) {
if (user == null || toolSessionId == null) {
return null;
}
- VoteSession session = retrieveVoteSession(toolSessionId);
+ VoteSession session = getSessionBySessionId(toolSessionId);
VoteQueUsr leader = session.getGroupLeader();
// check leader select tool for a leader only in case QA tool doesn't know it. As otherwise it will screw
// up previous scratches done
if (leader == null) {
- ToolSession toolSession = toolService.getToolSession(toolSessionId);
- ToolActivity voteActivity = toolSession.getToolActivity();
- Activity leaderSelectionActivity = getNearestLeaderSelectionActivity(voteActivity);
+ Long leaderUserId = toolService.getLeaderUserId(toolSessionId, user.getQueUsrId().intValue());
+ if (leaderUserId != null) {
- // check if there is leaderSelectionTool available
- if (leaderSelectionActivity != null) {
- User learner = (User) getUserManagementService().findById(User.class, user.getQueUsrId().intValue());
- String outputName = VoteAppConstants.LEADER_SELECTION_TOOL_OUTPUT_NAME_LEADER_USERID;
- ToolSession leaderSelectionSession = lamsCoreToolService.getToolSessionByLearner(learner,
- leaderSelectionActivity);
- ToolOutput output = lamsCoreToolService.getOutputFromTool(outputName, leaderSelectionSession, null);
+ leader = getVoteUserBySession(leaderUserId, session.getUid());
- // check if tool produced output
- if (output != null && output.getValue() != null) {
- Long userId = output.getValue().getLong();
- leader = this.getVoteUserBySession(userId, session.getUid());
-
- // create new user in a DB
- if (leader == null) {
- logger.debug("creating new user with userId: " + userId);
- User leaderDto = (User) getUserManagementService().findById(User.class, userId.intValue());
- String userName = leaderDto.getLogin();
- String fullName = leaderDto.getFirstName() + " " + leaderDto.getLastName();
- leader = new VoteQueUsr(userId, userName, fullName, session, new TreeSet());
- voteUserDAO.saveVoteUser(user);
- }
-
- // set group leader
- session.setGroupLeader(leader);
- this.updateVoteSession(session);
+ // create new user in a DB
+ if (leader == null) {
+ logger.debug("creating new user with userId: " + leaderUserId);
+ User leaderDto = (User) getUserManagementService().findById(User.class, leaderUserId.intValue());
+ String userName = leaderDto.getLogin();
+ String fullName = leaderDto.getFirstName() + " " + leaderDto.getLastName();
+ leader = new VoteQueUsr(leaderUserId, userName, fullName, session, new TreeSet());
+ voteUserDAO.saveVoteUser(user);
}
+
+ // set group leader
+ session.setGroupLeader(leader);
+ this.updateVoteSession(session);
}
}
return leader;
}
-
- /**
- * Finds the nearest Leader Select activity. Works recursively. Tries to find Leader Select activity in the previous activities set first,
- * and then inside the parent set.
- */
- private static Activity getNearestLeaderSelectionActivity(Activity activity) {
-
- //check if current activity is Leader Select one. if so - stop searching and return it.
- Class activityClass = Hibernate.getClass(activity);
- if (activityClass.equals(ToolActivity.class)) {
- ToolActivity toolActivity;
-
- // activity is loaded as proxy due to lazy loading and in order to prevent quering DB we just re-initialize
- // it here again
- Hibernate.initialize(activity);
- if (activity instanceof HibernateProxy) {
- toolActivity = (ToolActivity) ((HibernateProxy) activity).getHibernateLazyInitializer()
- .getImplementation();
- } else {
- toolActivity = (ToolActivity) activity;
- }
-
- if (VoteAppConstants.LEADER_SELECTION_TOOL_SIGNATURE.equals(toolActivity.getTool().getToolSignature())) {
- return activity;
- }
- }
-
- //check previous activity
- Transition transitionTo = activity.getTransitionTo();
- if (transitionTo != null) {
- Activity fromActivity = transitionTo.getFromActivity();
- return getNearestLeaderSelectionActivity(fromActivity);
- }
-
- //check parent activity
- Activity parent = activity.getParentActivity();
- if (parent != null) {
- return getNearestLeaderSelectionActivity(parent);
- }
-
- return null;
- }
-
+
@Override
public void copyAnswersFromLeader(VoteQueUsr user, VoteQueUsr leader) {
@@ -245,9 +178,9 @@
List leaderAttempts = this.getAttemptsForUser(leader.getUid());
List userAttempts = this.getAttemptsForUser(user.getUid());
-
+
for (VoteUsrAttempt leaderAttempt : leaderAttempts) {
-
+
VoteQueContent question = leaderAttempt.getVoteQueContent();
Date attempTime = leaderAttempt.getAttemptTime();
String timeZone = leaderAttempt.getTimeZone();
@@ -259,27 +192,27 @@
userAttempt = userAttemptDb;
}
}
-
+
// if response doesn't exist - create VoteUsrAttempt in the db
if (userAttempt == null) {
VoteUsrAttempt voteUsrAttempt = new VoteUsrAttempt(attempTime, timeZone, question, user, userEntry,
true);
this.createVoteUsrAttempt(voteUsrAttempt);
- // if it's been changed by the leader
+ // if it's been changed by the leader
} else if (leaderAttempt.getAttemptTime().compareTo(userAttempt.getAttemptTime()) != 0) {
userAttempt.setUserEntry(userEntry);
userAttempt.setAttemptTime(attempTime);
userAttempt.setTimeZone(timeZone);
this.updateVoteUsrAttempt(userAttempt);
-
+
// remove userAttempt from the list so we can know which one is redundant(presumably, leader has removed
// this one)
userAttempts.remove(userAttempt);
}
}
-
- //remove redundant ones
+
+ // remove redundant ones
for (VoteUsrAttempt redundantUserAttempt : userAttempts) {
this.removeAttempt(redundantUserAttempt);
}
@@ -288,16 +221,16 @@
@Override
public VoteGeneralLearnerFlowDTO prepareChartData(HttpServletRequest request, Long toolContentID,
Long toolSessionUid, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) {
-
- VoteContent voteContent = this.retrieveVote(toolContentID);
+ VoteContent voteContent = this.getVoteContent(toolContentID);
+
int entriesCount = 0;
Set userEntries = null;
if (toolSessionUid != null) {
entriesCount = this.getSessionEntriesCount(toolSessionUid);
userEntries = this.getSessionUserEntriesSet(toolSessionUid);
}
-
+
Long mapIndex = 1L;
int totalStandardVotesCount = 0;
@@ -307,7 +240,7 @@
Map mapStandardToolSessionUid = new TreeMap(new VoteComparator());
Map mapStandardNominationsContent = new TreeMap(new VoteComparator());
Map mapVoteRates = new TreeMap(new VoteComparator());
-
+
for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) {
mapStandardNominationsHTMLedContent.put(mapIndex, question.getQuestion());
@@ -323,11 +256,11 @@
Double voteRate = (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d;
mapVoteRates.put(mapIndex, voteRate);
-
+
// mapIndex++
mapIndex = new Long(mapIndex + 1);
}
-
+
// open votes
if (voteContent.isAllowText()) {
int userEnteredVotesCount = entriesCount - totalStandardVotesCount;
@@ -349,19 +282,19 @@
voteGeneralLearnerFlowDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid);
voteGeneralLearnerFlowDTO.setMapStandardQuestionUid(mapStandardQuestionUid);
request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
-
+
request.setAttribute(LIST_USER_ENTRIES_CONTENT, userEntries);
// return value is only used in VoteChartGeneratorAction
return voteGeneralLearnerFlowDTO;
}
-
+
@Override
public LinkedList getSessionDTOs(Long toolContentID) {
LinkedList sessionDTOs = new LinkedList();
- VoteContent voteContent = this.retrieveVote(toolContentID);
+ VoteContent voteContent = this.getVoteContent(toolContentID);
for (VoteSession session : (Set) voteContent.getVoteSessions()) {
SessionDTO sessionDTO = new SessionDTO();
@@ -495,7 +428,7 @@
double voteRate = (allSessionsVotesCount != 0) ? ((votesCount * 100) / allSessionsVotesCount) : 0d;
totalMapVoteRates.put(mapIndex, voteRate);
-
+
totalStandardVotesCount += votesCount;
// mapIndex++
@@ -526,7 +459,7 @@
if (userEntry == null || userEntry.length() == 0) {
continue;
}
-
+
VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO();
voteMonitoredAnswersDTO.setQuestion(userEntry);
@@ -598,7 +531,7 @@
return monitoredAnswersDTOs;
}
-
+
@Override
public List getReflectionData(VoteContent voteContent, Long userID) {
List reflectionsContainerDTO = new LinkedList();
@@ -620,7 +553,7 @@
reflectionDTO.setSessionId(voteSession.getVoteSessionId().toString());
reflectionDTO.setUserName(user.getFullname());
reflectionDTO.setReflectionUid(notebookEntry.getUid().toString());
- //String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry());
+ // String notebookEntryPresentable = VoteUtils.replaceNewLines(notebookEntry.getEntry());
reflectionDTO.setEntry(notebookEntry.getEntry());
reflectionsContainerDTO.add(reflectionDTO);
}
@@ -650,554 +583,220 @@
}
}
}
-
+
return reflectionsContainerDTO;
}
- public void createVote(VoteContent voteContent) throws VoteApplicationException {
- try {
- voteContentDAO.saveVoteContent(voteContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is creating vote content: "
- + e.getMessage(), e);
- }
+ public VoteContent getVoteContent(Long toolContentID) {
+ return voteContentDAO.getVoteContentByContentId(toolContentID);
}
- public VoteContent retrieveVote(Long toolContentID) throws VoteApplicationException {
- try {
- return voteContentDAO.findVoteContentById(toolContentID);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is loading vote content: " + e.getMessage(), e);
- }
+ public void updateVoteContent(VoteContent voteContent) {
+ voteContentDAO.updateVoteContent(voteContent);
}
- public void updateVoteContent(VoteContent voteContent) throws VoteApplicationException {
- try {
- voteContentDAO.updateVoteContent(voteContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote content: "
- + e.getMessage(), e);
- }
+ public VoteQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long voteContentUid) {
+ return voteQueContentDAO.getQuestionByDisplayOrder(displayOrder, voteContentUid);
}
- public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid)
- throws VoteApplicationException {
- try {
- return voteQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, voteContentUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting vote que content by display order: " + e.getMessage(), e);
- }
+ public VoteQueUsr getUserById(long voteQueUsrId) {
+ VoteQueUsr voteQueUsr = voteUserDAO.getVoteQueUsrById(voteQueUsrId);
+ return voteQueUsr;
}
- public VoteQueUsr getVoteQueUsrById(long voteQueUsrId) throws VoteApplicationException {
- try {
- VoteQueUsr voteQueUsr = voteUserDAO.getVoteQueUsrById(voteQueUsrId);
- return voteQueUsr;
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting vote QueUsr: " + e.getMessage(),
- e);
- }
+ public void createVoteQue(VoteQueContent voteQueContent) {
+ voteQueContentDAO.saveQuestion(voteQueContent);
}
- public List retrieveVoteQueContentsByToolContentId(long voteContentId) throws VoteApplicationException {
- try {
- return voteQueContentDAO.getVoteQueContentsByContentId(voteContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is loading vote que usr: " + e.getMessage(), e);
- }
- }
-
- public void createVoteQue(VoteQueContent voteQueContent) throws VoteApplicationException {
- try {
- voteQueContentDAO.saveVoteQueContent(voteQueContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is creating vote que content: "
- + e.getMessage(), e);
- }
- }
-
public List getAttemptsForQuestionContentAndSessionUid(final Long questionUid,
final Long voteSessionUid) {
- try {
- return voteUsrAttemptDAO.getAttemptsForQuestionContentAndSessionUid(questionUid,
- voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving usernames for votes: "
- + e.getMessage(), e);
- }
+ return voteUsrAttemptDAO.getAttemptsForQuestionContentAndSessionUid(questionUid, voteSessionUid);
}
public Set getAttemptsForUserAndSessionUseOpenAnswer(final Long userUid, final Long sessionUid) {
- try {
- return voteUsrAttemptDAO.getAttemptsForUserAndSessionUseOpenAnswer(userUid, sessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting all user entries, standard plus open text" + e.getMessage(),
- e);
- }
-
+ return voteUsrAttemptDAO.getAttemptsForUserAndSessionUseOpenAnswer(userUid, sessionUid);
}
- public Set getAttemptsForUserAndSession(final Long queUsrUid, final Long sessionUid)
- throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getAttemptsForUserAndSession(queUsrUid, sessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting user entries: "
- + e.getMessage(), e);
- }
-
+ public Set getAttemptsForUserAndSession(final Long queUsrUid, final Long sessionUid) {
+ return voteUsrAttemptDAO.getAttemptsForUserAndSession(queUsrUid, sessionUid);
}
- public Set getSessionUserEntriesSet(final Long voteSessionUid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getSessionUserEntriesSet(voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting session user entries: "
- + e.getMessage(), e);
- }
+ public Set getSessionUserEntriesSet(final Long voteSessionUid) {
+ return voteUsrAttemptDAO.getSessionUserEntriesSet(voteSessionUid);
}
- public VoteQueContent getVoteQueContentByUID(Long uid) throws VoteApplicationException {
- try {
- return voteQueContentDAO.getVoteQueContentByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting vote que content by uid: "
- + e.getMessage(), e);
+ public VoteQueContent getVoteQueContentByUID(Long uid) {
+ if (uid == null) {
+ return null;
}
- }
- public void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException {
- try {
- voteQueContentDAO.saveOrUpdateVoteQueContent(voteQueContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote que content: "
- + e.getMessage(), e);
- }
+ return voteQueContentDAO.getQuestionByUid(uid);
}
- public List getUserBySessionOnly(final VoteSession voteSession) throws VoteApplicationException {
- try {
- return voteUserDAO.getUserBySessionOnly(voteSession);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting vote QueUsr by vote session "
- + e.getMessage(), e);
- }
+ public void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent) {
+ voteQueContentDAO.saveOrUpdateQuestion(voteQueContent);
}
- public void removeQuestionContentByVoteUid(final Long voteContentUid) throws VoteApplicationException {
- try {
- voteQueContentDAO.removeQuestionContentByVoteUid(voteContentUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is removing vote que content by vote content id: " + e.getMessage(), e);
- }
+ public List getUserBySessionOnly(final VoteSession voteSession) {
+ return voteUserDAO.getUserBySessionOnly(voteSession);
}
- public void resetAllQuestions(final Long voteContentUid) throws VoteApplicationException {
- try {
- voteQueContentDAO.resetAllQuestions(voteContentUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is resetting all questions: "
- + e.getMessage(), e);
- }
+ public void createVoteSession(VoteSession voteSession) {
+ voteSessionDAO.saveVoteSession(voteSession);
}
- public void cleanAllQuestions(final Long voteContentUid) throws VoteApplicationException {
- try {
- voteQueContentDAO.cleanAllQuestions(voteContentUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is cleaning all questions: "
- + e.getMessage(), e);
- }
+ public VoteSession getVoteSessionByUID(Long uid) {
+ return voteSessionDAO.getVoteSessionByUID(uid);
}
- public void createVoteSession(VoteSession voteSession) throws VoteApplicationException {
- try {
- voteSessionDAO.saveVoteSession(voteSession);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is creating vote session: "
- + e.getMessage(), e);
+ public int getVoteSessionPotentialLearnersCount(Long sessionUid) {
+ VoteSession session = voteSessionDAO.getVoteSessionByUID(sessionUid);
+ if (session != null) {
+ Set potentialLearners = toolService.getAllPotentialLearners(session.getVoteSessionId().longValue());
+ return potentialLearners != null ? potentialLearners.size() : 0;
+ } else {
+ VoteServicePOJO.logger
+ .error("Unable to find vote session record id=" + sessionUid + ". Returning 0 users.");
+ return 0;
}
}
- public VoteSession getVoteSessionByUID(Long uid) throws VoteApplicationException {
- try {
- return voteSessionDAO.getVoteSessionByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting voteSession by uid: "
- + e.getMessage(), e);
- }
+ public void createVoteQueUsr(VoteQueUsr voteQueUsr) {
+ voteUserDAO.saveVoteUser(voteQueUsr);
}
- public int getVoteSessionPotentialLearnersCount(Long sessionUid) throws VoteApplicationException {
- try {
- VoteSession session = voteSessionDAO.getVoteSessionByUID(sessionUid);
- if (session != null) {
- Set potentialLearners = toolService.getAllPotentialLearners(session.getVoteSessionId().longValue());
- return potentialLearners != null ? potentialLearners.size() : 0;
- } else {
- VoteServicePOJO.logger.error("Unable to find vote session record id=" + sessionUid
- + ". Returning 0 users.");
- return 0;
- }
- } catch (LamsToolServiceException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting count of potential voteSession learners: " + e.getMessage(),
- e);
- }
+ public VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long sessionUid) {
+ return voteUserDAO.getVoteUserBySession(queUsrId, sessionUid);
}
- public void createVoteQueUsr(VoteQueUsr voteQueUsr) throws VoteApplicationException {
- try {
- voteUserDAO.saveVoteUser(voteQueUsr);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is creating vote QueUsr: " + e.getMessage(), e);
- }
+ public VoteQueUsr getVoteUserByUID(Long uid) {
+ return voteUserDAO.getVoteUserByUID(uid);
}
- public VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long sessionUid)
- throws VoteApplicationException {
- try {
- return voteUserDAO.getVoteUserBySession(queUsrId, sessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting vote QueUsr: " + e.getMessage(),
- e);
- }
+ public void updateVoteUser(VoteQueUsr voteUser) {
+ voteUserDAO.updateVoteUser(voteUser);
}
- public VoteQueUsr getVoteUserByUID(Long uid) throws VoteApplicationException {
- try {
- return voteUserDAO.getVoteUserByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting the vote QueUsr by uid."
- + e.getMessage(), e);
- }
+ public VoteQueUsr getUserByUserId(Long userID) {
+ VoteQueUsr voteQueUsr = voteUserDAO.getUserByUserId(userID);
+ return voteQueUsr;
}
- public void updateVoteUser(VoteQueUsr voteUser) throws VoteApplicationException {
- try {
- voteUserDAO.updateVoteUser(voteUser);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating VoteQueUsr: " + e.getMessage(),
- e);
- }
+ public void createVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) {
+ voteUsrAttemptDAO.saveVoteUsrAttempt(voteUsrAttempt);
}
- public VoteQueUsr retrieveVoteQueUsr(Long userID) throws VoteApplicationException {
- try {
- VoteQueUsr voteQueUsr = voteUserDAO.findVoteUserById(userID);
- return voteQueUsr;
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving VoteQueUsr: "
- + e.getMessage(), e);
- }
+ public List getStandardAttemptsByQuestionUid(final Long voteQueContentId) {
+ return voteUsrAttemptDAO.getStandardAttemptsByQuestionUid(voteQueContentId);
}
- public void createVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException {
- try {
- voteUsrAttemptDAO.saveVoteUsrAttempt(voteUsrAttempt);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is creating vote UsrAttempt: "
- + e.getMessage(), e);
- }
+ public int getSessionEntriesCount(final Long voteSessionUid) {
+ return voteUsrAttemptDAO.getSessionEntriesCount(voteSessionUid);
}
- public List getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId) {
- try {
- return voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndContentUid(voteQueContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting all standard attempts entries count: " + e.getMessage(), e);
- }
-
+ public VoteUsrAttempt getAttemptByUID(Long uid) {
+ return voteUsrAttemptDAO.getAttemptByUID(uid);
}
- public int getSessionEntriesCount(final Long voteSessionUid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getSessionEntriesCount(voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting all attempts session entries count: " + e.getMessage(), e);
- }
+ public int getAttemptsForQuestionContent(final Long voteQueContentId) {
+ return voteUsrAttemptDAO.getAttemptsForQuestionContent(voteQueContentId);
}
- public VoteUsrAttempt getAttemptByUID(Long uid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getAttemptByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting attemptby uid: "
- + e.getMessage(), e);
- }
+ public int getStandardAttemptsForQuestionContentAndSessionUid(final Long voteQueContentId, final Long voteSessionUid) {
+ return voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndSessionUid(voteQueContentId, voteSessionUid);
}
- public int getAttemptsForQuestionContent(final Long voteQueContentId) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getAttemptsForQuestionContent(voteQueContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting vote UsrAttempt by question content id only: "
- + e.getMessage(), e);
- }
- }
-
- public int getStandardAttemptsForQuestionContentAndSessionUid(final Long voteQueContentId, final Long voteSessionUid)
- throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndSessionUid(voteQueContentId,
- voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is getting vote UsrAttempt by question content id and session uid: "
- + e.getMessage(), e);
- }
- }
-
public VoteUsrAttempt getAttemptForUserAndQuestionContentAndSession(final Long queUsrId,
- final Long voteQueContentId, final Long toolSessionUid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getAttemptForUserAndQuestionContentAndSession(queUsrId, voteQueContentId,
- toolSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote UsrAttempt: "
- + e.getMessage(), e);
- }
+ final Long voteQueContentId, final Long toolSessionUid) {
+ return voteUsrAttemptDAO.getAttemptForUserAndQuestionContentAndSession(queUsrId, voteQueContentId,
+ toolSessionUid);
}
- public void updateVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException {
- try {
- voteUsrAttemptDAO.updateVoteUsrAttempt(voteUsrAttempt);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote UsrAttempt: "
- + e.getMessage(), e);
- }
+ public void updateVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) {
+ voteUsrAttemptDAO.updateVoteUsrAttempt(voteUsrAttempt);
}
- public void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid)
- throws VoteApplicationException {
- try {
- voteUsrAttemptDAO.removeAttemptsForUserandSession(queUsrId, sessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is removing by user and votesession id : "
- + e.getMessage(), e);
- }
+ public void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid) {
+ voteUsrAttemptDAO.removeAttemptsForUserandSession(queUsrId, sessionUid);
}
- public List getAttemptsForUser(final Long userUid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getAttemptsForUser(userUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting the attempts by user id: "
- + e.getMessage(), e);
- }
-
+ public List getAttemptsForUser(final Long userUid) {
+ return voteUsrAttemptDAO.getAttemptsForUser(userUid);
}
- public int getUserEnteredVotesCountForContent(final Long voteContentUid) throws VoteApplicationException {
- try {
- return voteUsrAttemptDAO.getUserEnteredVotesCountForContent(voteContentUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting the user entered votes count:"
- + e.getMessage(), e);
- }
-
+ public int getUserEnteredVotesCountForContent(final Long voteContentUid) {
+ return voteUsrAttemptDAO.getUserEnteredVotesCountForContent(voteContentUid);
}
- public VoteQueContent retrieveVoteQueContentByUID(Long uid) throws VoteApplicationException {
- try {
- return voteQueContentDAO.getVoteQueContentByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is retrieving by uid vote question content: " + e.getMessage(), e);
- }
+ public VoteQueContent getQuestionByUid(Long uid) {
+ return voteQueContentDAO.getQuestionByUid(uid);
}
- public void updateVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException {
- try {
- voteQueContentDAO.updateVoteQueContent(voteQueContent);
-
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote content by question: "
- + e.getMessage(), e);
- }
-
+ public void removeVoteQueContent(VoteQueContent voteQueContent) {
+ voteQueContentDAO.removeQuestion(voteQueContent);
}
- public void cleanAllQuestionsSimple(final Long voteContentId) throws VoteApplicationException {
- try {
- voteQueContentDAO.cleanAllQuestionsSimple(voteContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is cleaning vote question content by voteContentId : "
- + e.getMessage(), e);
- }
+ public VoteSession getSessionBySessionId(Long voteSessionId) {
+ return voteSessionDAO.getSessionBySessionId(voteSessionId);
}
- public List getAllQuestionEntries(final Long uid) throws VoteApplicationException {
- try {
- return voteQueContentDAO.getAllQuestionEntries(uid.longValue());
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting by uid vote question content: "
- + e.getMessage(), e);
- }
+ public int getCompletedVoteUserBySessionUid(final Long voteSessionUid) {
+ return voteUserDAO.getCompletedVoteUserBySessionUid(voteSessionUid);
}
- public void removeVoteQueContentByUID(Long uid) throws VoteApplicationException {
- try {
- voteQueContentDAO.removeVoteQueContentByUID(uid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is removing by uid vote question content: " + e.getMessage(), e);
- }
+ public List getVoteUserBySessionUid(final Long voteSessionUid) {
+ return voteUserDAO.getVoteUserBySessionUid(voteSessionUid);
}
- public void removeVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException {
- try {
- voteQueContentDAO.removeVoteQueContent(voteQueContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is removing vote question content: "
- + e.getMessage(), e);
- }
+ public List getSessionNamesFromContent(VoteContent voteContent) {
+ return voteSessionDAO.getSessionNamesFromContent(voteContent);
}
- public VoteQueContent getQuestionContentByQuestionText(final String question, final Long voteContentId) {
- try {
- return voteQueContentDAO.getQuestionContentByQuestionText(question, voteContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is retrieving question content by question text: " + e.getMessage(), e);
- }
+ public void updateVote(VoteContent vote) {
+ voteContentDAO.updateVoteContent(vote);
}
- public VoteSession retrieveVoteSession(Long voteSessionId) throws VoteApplicationException {
- try {
- return voteSessionDAO.findVoteSessionById(voteSessionId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving by id vote session : "
- + e.getMessage(), e);
- }
+ public void updateVoteSession(VoteSession voteSession) {
+ voteSessionDAO.updateVoteSession(voteSession);
}
- public int getCompletedVoteUserBySessionUid(final Long voteSessionUid) throws VoteApplicationException {
- try {
- return voteUserDAO.getCompletedVoteUserBySessionUid(voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException(
- "Exception occured when lams is retrieving completed users by session uid: " + e.getMessage(), e);
- }
+ public void deleteVote(VoteContent vote) {
+ voteContentDAO.removeVote(vote);
}
- public List getVoteUserBySessionUid(final Long voteSessionUid) throws VoteApplicationException {
- try {
- return voteUserDAO.getVoteUserBySessionUid(voteSessionUid);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving users by session uid: "
- + e.getMessage(), e);
- }
+ public void deleteVoteById(Long voteId) {
+ voteContentDAO.removeVoteById(voteId);
}
- public VoteContent retrieveVoteBySessionId(Long voteSessionId) throws VoteApplicationException {
- try {
- return voteContentDAO.getVoteContentBySession(voteSessionId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving vote by session id: "
- + e.getMessage(), e);
- }
+ public int countSessionComplete() {
+ return voteSessionDAO.countSessionComplete();
}
- public List getSessionNamesFromContent(VoteContent voteContent) throws VoteApplicationException {
- try {
- return voteSessionDAO.getSessionNamesFromContent(voteContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting session names from content: "
- + e.getMessage(), e);
- }
+ public void deleteVoteSession(VoteSession voteSession) {
+ voteSessionDAO.removeVoteSession(voteSession);
}
- public void updateVote(VoteContent vote) throws VoteApplicationException {
- try {
- voteContentDAO.updateVoteContent(vote);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating" + " the vote content: "
- + e.getMessage(), e);
- }
+ public void removeAttempt(VoteUsrAttempt attempt) {
+ voteUsrAttemptDAO.removeVoteUsrAttempt(attempt);
}
- public void updateVoteSession(VoteSession voteSession) throws VoteApplicationException {
- try {
- voteSessionDAO.updateVoteSession(voteSession);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is updating vote session : "
- + e.getMessage(), e);
- }
- }
-
- public void deleteVote(VoteContent vote) throws VoteApplicationException {
- try {
- voteContentDAO.removeVote(vote);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is removing" + " the vote content: "
- + e.getMessage(), e);
- }
- }
-
- public void deleteVoteById(Long voteId) throws VoteApplicationException {
- try {
- voteContentDAO.removeVoteById(voteId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is removing by id" + " the vote content: "
- + e.getMessage(), e);
- }
- }
-
- public int countSessionComplete() throws VoteApplicationException {
- try {
- return voteSessionDAO.countSessionComplete();
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is counting incomplete sessions"
- + e.getMessage(), e);
- }
- }
-
- public void deleteVoteSession(VoteSession voteSession) throws VoteApplicationException {
- try {
- voteSessionDAO.removeVoteSession(voteSession);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is deleting" + " the vote session: "
- + e.getMessage(), e);
- }
- }
-
- public void removeAttempt(VoteUsrAttempt attempt) throws VoteApplicationException {
- try {
- voteUsrAttemptDAO.removeVoteUsrAttempt(attempt);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is removing" + " the attempt: "
- + e.getMessage(), e);
- }
- }
-
/**
* logs hiding of a user entered vote
*/
- public void hideOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException {
+ public void hideOpenVote(VoteUsrAttempt voteUsrAttempt) {
auditService.logHideEntry(VoteAppConstants.MY_SIGNATURE, voteUsrAttempt.getQueUsrId(), voteUsrAttempt
.getVoteQueUsr().getUsername(), voteUsrAttempt.getUserEntry());
}
/**
* logs showing of a user entered vote
*/
- public void showOpenVote(VoteUsrAttempt voteUsrAttempt) throws VoteApplicationException {
+ public void showOpenVote(VoteUsrAttempt voteUsrAttempt) {
auditService.logShowEntry(VoteAppConstants.MY_SIGNATURE, voteUsrAttempt.getQueUsrId(), voteUsrAttempt
.getVoteQueUsr().getUsername(), voteUsrAttempt.getUserEntry());
}
- public void deleteVoteQueUsr(VoteQueUsr voteQueUsr) throws VoteApplicationException {
+ public void deleteVoteQueUsr(VoteQueUsr voteQueUsr) {
try {
voteUserDAO.removeVoteUser(voteQueUsr);
} catch (DataAccessException e) {
@@ -1206,75 +805,32 @@
}
}
- public void saveVoteContent(VoteContent vote) throws VoteApplicationException {
- try {
- voteContentDAO.saveVoteContent(vote);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is saving" + " the vote content: "
- + e.getMessage(), e);
- }
+ public void saveVoteContent(VoteContent vote) {
+ voteContentDAO.saveVoteContent(vote);
}
- public List getSessionsFromContent(VoteContent voteContent) throws VoteApplicationException {
- try {
- return voteSessionDAO.getSessionsFromContent(voteContent);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting" + " the vote sessions list: "
- + e.getMessage(), e);
- }
+ public List getSessionsFromContent(VoteContent voteContent) {
+ return voteSessionDAO.getSessionsFromContent(voteContent);
}
- public int getTotalNumberOfUsers() throws VoteApplicationException {
- try {
- return voteUserDAO.getTotalNumberOfUsers();
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is retrieving total number of VoteQueUsr: "
- + e.getMessage(), e);
- }
+ public int getTotalNumberOfUsers() {
+ return voteUserDAO.getTotalNumberOfUsers();
}
- public User getCurrentUserData(String username) throws VoteApplicationException {
- try {
- /**
- * this will return null if the username not found
- */
- User user = userManagementService.getUserByLogin(username);
- if (user == null) {
- VoteServicePOJO.logger.error("No user with the username: " + username + " exists.");
- throw new VoteApplicationException("No user with that username exists.");
- }
- return user;
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Unable to find current user information" + " Root Cause: ["
- + e.getMessage() + "]", e);
+ public User getCurrentUserData(String username) {
+ /**
+ * this will return null if the username not found
+ */
+ User user = userManagementService.getUserByLogin(username);
+ if (user == null) {
+ VoteServicePOJO.logger.error("No user with the username: " + username + " exists.");
+ throw new VoteApplicationException("No user with that username exists.");
}
+ return user;
}
- /**
- *
- * Unused method
- *
- * @param lessonId
- * @return
- * @throws VoteApplicationException
- */
- public Lesson getCurrentLesson(long lessonId) throws VoteApplicationException {
- try {
- /**
- * this is a mock implementation to make the project compile and work. When the Lesson service is ready, we
- * need to switch to real service implementation.
- */
- return new Lesson();
- /** return lsDAO.find(lsessionId); */
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is loading" + " learning session:"
- + e.getMessage(), e);
- }
- }
-
@Override
- public List getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid)
- throws VoteApplicationException {
+ public List getAttemptsForUserAndQuestionContent(final Long userUid, final Long questionUid) {
try {
return voteUsrAttemptDAO.getAttemptsForUserAndQuestionContent(userUid, questionUid);
} catch (DataAccessException e) {
@@ -1285,94 +841,118 @@
}
@Override
- public boolean studentActivityOccurredGlobal(VoteContent voteContent) throws VoteApplicationException {
- Iterator questionIterator = voteContent.getVoteQueContents().iterator();
-
- while (questionIterator.hasNext()) {
- VoteQueContent voteQueContent = (VoteQueContent) questionIterator.next();
- Iterator attemptsIterator = voteQueContent.getVoteUsrAttempts().iterator();
- while (attemptsIterator.hasNext()) {
- /**
- * proved the fact that there is at least one attempt for this content.
- */
- return true;
- }
- }
- return false;
+ public boolean studentActivityOccurredGlobal(VoteContent voteContent) {
+ return !voteContent.getVoteSessions().isEmpty();
}
@Override
- public boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent) throws VoteApplicationException {
+ public boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent) {
boolean studentActivityOccurredGlobal = studentActivityOccurredGlobal(voteContent);
int userEnteredVotesCount = getUserEnteredVotesCountForContent(voteContent.getUid());
if (studentActivityOccurredGlobal == true || userEnteredVotesCount > 0) {
return true;
}
- //there is no votes/nominations for this content
+ // there is no votes/nominations for this content
return false;
}
@Override
+ public void recalculateUserAnswers(VoteContent content, Set oldQuestions,
+ List questionDTOs, List deletedQuestions) {
+
+ // create list of modified questions
+ List modifiedQuestions = new ArrayList();
+ for (VoteQueContent oldQuestion : oldQuestions) {
+ for (VoteQuestionDTO questionDTO : questionDTOs) {
+ if (oldQuestion.getUid().equals(questionDTO.getUid())) {
+
+ // question is different
+ if (!oldQuestion.getQuestion().equals(questionDTO.getQuestion())) {
+ modifiedQuestions.add(questionDTO);
+ }
+ }
+ }
+ }
+
+ Set sessionList = content.getVoteSessions();
+ for (VoteSession session : sessionList) {
+ Long toolSessionId = session.getVoteSessionId();
+ Set sessionUsers = session.getVoteQueUsers();
+
+ for (VoteQueUsr user : sessionUsers) {
+
+ // get all finished user results
+ List userAttempts = this.getAttemptsForUser(user.getUid());
+ Iterator iter = userAttempts.iterator();
+ while (iter.hasNext()) {
+ VoteUsrAttempt userAttempt = iter.next();
+
+ VoteQueContent question = userAttempt.getVoteQueContent();
+
+ boolean isRemoveQuestionResult = false;
+
+ // [+] if the question is modified
+ for (VoteQuestionDTO modifiedQuestion : modifiedQuestions) {
+ if (question.getUid().equals(modifiedQuestion.getUid())) {
+ isRemoveQuestionResult = true;
+ break;
+ }
+ }
+
+ // [+] if the question was removed
+ for (VoteQuestionDTO deletedQuestion : deletedQuestions) {
+ if (question.getUid().equals(deletedQuestion.getUid())) {
+ isRemoveQuestionResult = true;
+ break;
+ }
+ }
+
+ if (isRemoveQuestionResult) {
+ iter.remove();
+ voteUsrAttemptDAO.removeVoteUsrAttempt(userAttempt);
+ }
+
+ // [+] doing nothing if the new question was added
+
+ }
+
+ }
+ }
+
+ }
+
+ @Override
public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException {
if (fromContentId == null) {
- //attempt retrieving tool's default content id with signatute VoteAppConstants.MY_SIGNATURE
- long defaultContentId = 0;
- try {
- defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- fromContentId = new Long(defaultContentId);
- } catch (Exception e) {
- VoteServicePOJO.logger.error("default content id has not been setup for signature: "
- + VoteAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + VoteAppConstants.MY_SIGNATURE + " Can't continue!");
- }
+ // attempt retrieving tool's default content id with signatute VoteAppConstants.MY_SIGNATURE
+ long defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
+ fromContentId = new Long(defaultContentId);
}
if (toContentId == null) {
VoteServicePOJO.logger.error("throwing ToolException: toContentId is null");
throw new ToolException("toContentId is missing");
}
- try {
- VoteContent fromContent = voteContentDAO.findVoteContentById(fromContentId);
+ VoteContent fromContent = voteContentDAO.getVoteContentByContentId(fromContentId);
- if (fromContent == null) {
- //attempt retrieving tool's default content id with signatute VoteAppConstants.MY_SIGNATURE
- long defaultContentId = 0;
- try {
- defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- fromContentId = new Long(defaultContentId);
- } catch (Exception e) {
- VoteServicePOJO.logger.error("default content id has not been setup for signature: "
- + VoteAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + VoteAppConstants.MY_SIGNATURE + " Can't continue!");
- }
+ if (fromContent == null) {
+ // attempt retrieving tool's default content id with signatute VoteAppConstants.MY_SIGNATURE
+ long defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
+ fromContentId = new Long(defaultContentId);
- fromContent = voteContentDAO.findVoteContentById(fromContentId);
- }
+ fromContent = voteContentDAO.getVoteContentByContentId(fromContentId);
+ }
- try {
- VoteContent toContent = VoteContent.newInstance(voteToolContentHandler, fromContent, toContentId);
- if (toContent == null) {
- VoteServicePOJO.logger.error("throwing ToolException: WARNING!, retrieved toContent is null.");
- throw new ToolException("WARNING! Fail to create toContent. Can't continue!");
- } else {
- voteContentDAO.saveVoteContent(toContent);
- }
-
- } catch (ItemNotFoundException e) {
- VoteServicePOJO.logger.error("exception occurred: " + e);
- } catch (RepositoryCheckedException e) {
- VoteServicePOJO.logger.error("exception occurred: " + e);
- }
- } catch (DataAccessException e) {
- VoteServicePOJO.logger
- .error("throwing ToolException: Exception occured when lams is copying content between content ids.");
- throw new ToolException("Exception occured when lams is copying content between content ids.");
+ VoteContent toContent = VoteContent.newInstance(fromContent, toContentId);
+ if (toContent == null) {
+ VoteServicePOJO.logger.error("throwing ToolException: WARNING!, retrieved toContent is null.");
+ throw new ToolException("WARNING! Fail to create toContent. Can't continue!");
+ } else {
+ voteContentDAO.saveVoteContent(toContent);
}
}
@@ -1385,7 +965,7 @@
throw new ToolException("toolContentID is missing");
}
- VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentID);
+ VoteContent voteContent = voteContentDAO.getVoteContentByContentId(toolContentID);
if (voteContent != null) {
Iterator sessionIterator = voteContent.getVoteSessions().iterator();
@@ -1408,7 +988,7 @@
}
}
}
- //removed all existing responses of toolContent with toolContentID
+ // removed all existing responses of toolContent with toolContentID
voteContentDAO.removeVoteById(toolContentID);
} else {
VoteServicePOJO.logger.error("Warning!!!, We should have not come here. voteContent is null.");
@@ -1423,7 +1003,7 @@
logger.debug("Removing Vote attempts for user ID " + userId + " and toolContentId " + toolContentId);
}
- VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentId);
+ VoteContent voteContent = voteContentDAO.getVoteContentByContentId(toolContentId);
if (voteContent == null) {
logger.warn("Did not find activity with toolContentId: " + toolContentId + " to remove learner content");
return;
@@ -1447,10 +1027,10 @@
@Override
public void exportToolContent(Long toolContentID, String rootPath) throws DataMissingException, ToolException {
- VoteContent toolContentObj = voteContentDAO.findVoteContentById(toolContentID);
+ VoteContent toolContentObj = voteContentDAO.getVoteContentByContentId(toolContentID);
if (toolContentObj == null) {
long defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- toolContentObj = voteContentDAO.findVoteContentById(defaultContentId);
+ toolContentObj = voteContentDAO.getVoteContentByContentId(defaultContentId);
}
if (toolContentObj == null) {
@@ -1459,21 +1039,13 @@
try {
// set ToolContentHandler as null to avoid copy file node in repository again.
- toolContentObj = VoteContent.newInstance(null, toolContentObj, toolContentID);
+ toolContentObj = VoteContent.newInstance(toolContentObj, toolContentID);
// clear unnecessary information attach
toolContentObj.setVoteSessions(null);
- Set ques = toolContentObj.getVoteQueContents();
- for (VoteQueContent que : ques) {
- que.setMcUsrAttempts(null);
- }
exportContentService.exportToolContent(toolContentID, toolContentObj, voteToolContentHandler, rootPath);
} catch (ExportToolContentException e) {
throw new ToolException(e);
- } catch (ItemNotFoundException e) {
- throw new ToolException(e);
- } catch (RepositoryCheckedException e) {
- throw new ToolException(e);
}
}
@@ -1507,13 +1079,13 @@
* group have the same toolSessionID.
*
* @param toolSessionID
- * the generated tool session id.
+ * the generated tool session id.
* @param toolSessionName
- * the tool session name.
+ * the tool session name.
* @param toolContentID
- * the tool content id specified.
+ * the tool content id specified.
* @throws ToolException
- * if an error occurs e.g. defaultContent is missing.
+ * if an error occurs e.g. defaultContent is missing.
*
*/
public void createToolSession(Long toolSessionID, String toolSessionName, Long toolContentID) throws ToolException {
@@ -1523,41 +1095,12 @@
throw new ToolException("toolSessionID is missing");
}
- long defaultContentId = 0;
- if (toolContentID == null) {
+ VoteContent voteContent = voteContentDAO.getVoteContentByContentId(toolContentID);
- try {
- defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- toolContentID = new Long(defaultContentId);
- } catch (Exception e) {
- VoteServicePOJO.logger.error("default content id has not been setup for signature: "
- + VoteAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + VoteAppConstants.MY_SIGNATURE + " Can't continue!");
- }
- }
-
- VoteContent voteContent = voteContentDAO.findVoteContentById(toolContentID);
-
- if (voteContent == null) {
-
- try {
- defaultContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- toolContentID = new Long(defaultContentId);
- } catch (Exception e) {
- VoteServicePOJO.logger.error("default content id has not been setup for signature: "
- + VoteAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + VoteAppConstants.MY_SIGNATURE + " Can't continue!");
- }
-
- voteContent = voteContentDAO.findVoteContentById(toolContentID);
- }
-
/*
* create a new a new tool session if it does not already exist in the tool session table
*/
- VoteSession voteSession = retrieveVoteSession(toolSessionID);
+ VoteSession voteSession = getSessionBySessionId(toolSessionID);
if (voteSession == null) {
try {
voteSession = new VoteSession(toolSessionID, new Date(System.currentTimeMillis()),
@@ -1573,11 +1116,11 @@
}
/**
- * Implemented as part of the tool contract.
+ * Implemented as part of the tool contract.
*
* @param toolSessionID
* @param toolContentID
- * return
+ * return
* @throws ToolException
*/
public void removeToolSession(Long toolSessionID) throws DataMissingException, ToolException {
@@ -1588,7 +1131,7 @@
VoteSession voteSession = null;
try {
- voteSession = retrieveVoteSession(toolSessionID);
+ voteSession = getSessionBySessionId(toolSessionID);
} catch (VoteApplicationException e) {
throw new DataMissingException("error retrieving voteSession: " + e);
} catch (Exception e) {
@@ -1608,11 +1151,11 @@
}
/**
- * Implemtented as part of the tool contract.
+ * Implemtented as part of the tool contract.
*
* @param toolSessionID
* @param learnerId
- * return String
+ * return String
* @throws ToolException
*
*/
@@ -1634,7 +1177,7 @@
VoteSession voteSession = null;
try {
- voteSession = retrieveVoteSession(toolSessionID);
+ voteSession = getSessionBySessionId(toolSessionID);
} catch (VoteApplicationException e) {
throw new DataMissingException("error retrieving voteSession: " + e);
} catch (Exception e) {
@@ -1655,7 +1198,7 @@
* exportToolSession(Long toolSessionID) throws DataMissingException, ToolException
*
* @param toolSessionID
- * return ToolSessionExportOutputData
+ * return ToolSessionExportOutputData
* @throws ToolException
*/
public ToolSessionExportOutputData exportToolSession(Long toolSessionID) throws DataMissingException, ToolException {
@@ -1666,7 +1209,7 @@
* exportToolSession(Long toolSessionID) throws DataMissingException, ToolException
*
* @param toolSessionIDs
- * return ToolSessionExportOutputData
+ * return ToolSessionExportOutputData
* @throws ToolException
*/
public ToolSessionExportOutputData exportToolSession(List toolSessionIDs) throws DataMissingException,
@@ -1675,27 +1218,28 @@
}
- public IToolVO getToolBySignature(String toolSignature) throws VoteApplicationException {
+ public IToolVO getToolBySignature(String toolSignature) {
IToolVO tool = toolService.getToolBySignature(toolSignature);
return tool;
}
- public long getToolDefaultContentIdBySignature(String toolSignature) throws VoteApplicationException {
+ public long getToolDefaultContentIdBySignature(String toolSignature) {
long contentId = 0;
contentId = toolService.getToolDefaultContentIdBySignature(toolSignature);
return contentId;
}
- public VoteQueContent getToolDefaultQuestionContent(long contentId) throws VoteApplicationException {
- VoteQueContent voteQueContent = voteQueContentDAO.getToolDefaultQuestionContent(contentId);
+ @Override
+ public VoteQueContent getDefaultVoteContentFirstQuestion() {
+ VoteQueContent voteQueContent = voteQueContentDAO.getDefaultVoteContentFirstQuestion();
return voteQueContent;
}
-
+
public List getToolSessionsForContent(VoteContent vote) {
List listToolSessionIds = voteSessionDAO.getSessionsFromContent(vote);
return listToolSessionIds;
}
-
+
public boolean isGroupedActivity(long toolContentID) {
return toolService.isGroupedActivity(toolContentID);
}
@@ -1706,22 +1250,22 @@
*/
public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType)
throws ToolException {
- VoteContent content = retrieveVote(toolContentId);
+ VoteContent content = getVoteContent(toolContentId);
if (content == null) {
long defaultToolContentId = getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- content = retrieveVote(defaultToolContentId);
+ content = getVoteContent(defaultToolContentId);
}
return getVoteOutputFactory().getToolOutputDefinitions(content, definitionType);
}
-
+
public String getToolContentTitle(Long toolContentId) {
- return retrieveVote(toolContentId).getTitle();
+ return getVoteContent(toolContentId).getTitle();
}
-
+
public boolean isContentEdited(Long toolContentId) {
- return retrieveVote(toolContentId).isDefineLater();
+ return getVoteContent(toolContentId).isDefineLater();
}
-
+
/**
* Get the tool output for the given tool output names.
*
@@ -1750,7 +1294,6 @@
public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) {
Date now = new Date();
VoteContent toolContentObj = new VoteContent();
- toolContentObj.setContentInUse(false);
toolContentObj.setCreatedBy(user.getUserID().longValue());
toolContentObj.setCreationDate(now);
toolContentObj.setDefineLater(false);
@@ -1778,10 +1321,10 @@
Integer maxCount = WDDXProcessor.convertToInteger(importValues,
ToolContentImport102Manager.CONTENT_VOTE_MAXCHOOSE);
toolContentObj.setMaxNominationCount(maxCount != null ? maxCount.toString() : "1");
-
+
Integer minCount = WDDXProcessor.convertToInteger(importValues,
- ToolContentImport102Manager.CONTENT_VOTE_MINCHOOSE);
- toolContentObj.setMinNominationCount(minCount != null ? minCount.toString() : "1");
+ ToolContentImport102Manager.CONTENT_VOTE_MINCHOOSE);
+ toolContentObj.setMinNominationCount(minCount != null ? minCount.toString() : "1");
} catch (WDDXProcessorConversionException e) {
VoteServicePOJO.logger.error("Unable to content for activity " + toolContentObj.getTitle()
@@ -1802,7 +1345,7 @@
int order = 1;
while (iter.hasNext()) {
String element = (String) iter.next();
- VoteQueContent nomination = new VoteQueContent(element, toolContentObj, null);
+ VoteQueContent nomination = new VoteQueContent(element, toolContentObj);
nomination.setDisplayOrder(order++);
toolContentObj.getVoteQueContents().add(nomination);
}
@@ -1819,7 +1362,7 @@
VoteContent toolContentObj = null;
if (toolContentId != null) {
- toolContentObj = retrieveVote(toolContentId);
+ toolContentObj = getVoteContent(toolContentId);
}
if (toolContentObj == null) {
throw new DataMissingException("Unable to set reflective data titled " + title
@@ -1844,13 +1387,8 @@
}
}
- public List getAllQuestionEntriesSorted(final long voteContentId) throws VoteApplicationException {
- try {
- return voteQueContentDAO.getAllQuestionEntriesSorted(voteContentId);
- } catch (DataAccessException e) {
- throw new VoteApplicationException("Exception occured when lams is getting all question entries: "
- + e.getMessage(), e);
- }
+ public List getAllQuestionsSorted(final long voteContentId) {
+ return voteQueContentDAO.getAllQuestionsSorted(voteContentId);
}
/**
@@ -1876,7 +1414,7 @@
/**
* @param voteSessionDAO
- * The voteSessionDAO to set.
+ * The voteSessionDAO to set.
*/
public void setvoteSessionDAO(IVoteSessionDAO voteSessionDAO) {
this.voteSessionDAO = voteSessionDAO;
@@ -1891,7 +1429,7 @@
/**
* @param voteUserDAO
- * The voteUserDAO to set.
+ * The voteUserDAO to set.
*/
public void setvoteUserDAO(IVoteUserDAO voteUserDAO) {
this.voteUserDAO = voteUserDAO;
@@ -1906,7 +1444,7 @@
/**
* @param voteUsrAttemptDAO
- * The voteUsrAttemptDAO to set.
+ * The voteUsrAttemptDAO to set.
*/
public void setvoteUsrAttemptDAO(IVoteUsrAttemptDAO voteUsrAttemptDAO) {
this.voteUsrAttemptDAO = voteUsrAttemptDAO;
@@ -1929,7 +1467,7 @@
/**
* @param voteToolContentHandler
- * The voteToolContentHandler to set.
+ * The voteToolContentHandler to set.
*/
public void setVoteToolContentHandler(IToolContentHandler voteToolContentHandler) {
this.voteToolContentHandler = voteToolContentHandler;
@@ -1944,7 +1482,7 @@
/**
* @param learnerService
- * The learnerService to set.
+ * The learnerService to set.
*/
public void setLearnerService(ILearnerService learnerService) {
this.learnerService = learnerService;
@@ -1959,7 +1497,7 @@
/**
* @param voteContentDAO
- * The voteContentDAO to set.
+ * The voteContentDAO to set.
*/
public void setvoteContentDAO(IVoteContentDAO voteContentDAO) {
this.voteContentDAO = voteContentDAO;
@@ -1974,7 +1512,7 @@
/**
* @param voteQueContentDAO
- * The voteQueContentDAO to set.
+ * The voteQueContentDAO to set.
*/
public void setvoteQueContentDAO(IVoteQueContentDAO voteQueContentDAO) {
this.voteQueContentDAO = voteQueContentDAO;
@@ -1989,7 +1527,7 @@
/**
* @param voteContentDAO
- * The voteContentDAO to set.
+ * The voteContentDAO to set.
*/
public void setVoteContentDAO(IVoteContentDAO voteContentDAO) {
this.voteContentDAO = voteContentDAO;
@@ -2004,7 +1542,7 @@
/**
* @param voteQueContentDAO
- * The voteQueContentDAO to set.
+ * The voteQueContentDAO to set.
*/
public void setVoteQueContentDAO(IVoteQueContentDAO voteQueContentDAO) {
this.voteQueContentDAO = voteQueContentDAO;
@@ -2019,7 +1557,7 @@
/**
* @param voteSessionDAO
- * The voteSessionDAO to set.
+ * The voteSessionDAO to set.
*/
public void setVoteSessionDAO(IVoteSessionDAO voteSessionDAO) {
this.voteSessionDAO = voteSessionDAO;
@@ -2034,7 +1572,7 @@
/**
* @param voteUserDAO
- * The voteUserDAO to set.
+ * The voteUserDAO to set.
*/
public void setVoteUserDAO(IVoteUserDAO voteUserDAO) {
this.voteUserDAO = voteUserDAO;
@@ -2049,7 +1587,7 @@
/**
* @param voteUsrAttemptDAO
- * The voteUsrAttemptDAO to set.
+ * The voteUsrAttemptDAO to set.
*/
public void setVoteUsrAttemptDAO(IVoteUsrAttemptDAO voteUsrAttemptDAO) {
this.voteUsrAttemptDAO = voteUsrAttemptDAO;
@@ -2064,7 +1602,7 @@
/**
* @param auditService
- * The auditService to set.
+ * The auditService to set.
*/
public void setAuditService(IAuditService auditService) {
this.auditService = auditService;
@@ -2087,7 +1625,7 @@
/**
* @param coreNotebookService
- * The coreNotebookService to set.
+ * The coreNotebookService to set.
*/
public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
this.coreNotebookService = coreNotebookService;
@@ -2110,20 +1648,24 @@
/**
* @param messageService
- * The MessageService to set.
+ * The MessageService to set.
*/
public void setMessageService(MessageService messageService) {
this.messageService = messageService;
}
-
+
public void setLamsCoreToolService(ILamsCoreToolService lamsCoreToolService) {
this.lamsCoreToolService = lamsCoreToolService;
}
- public void removeNominationsFromCache(VoteContent voteContent) {
- voteContentDAO.removeNominationsFromCache(voteContent);
+ public void removeQuestionsFromCache(VoteContent voteContent) {
+ voteContentDAO.removeQuestionsFromCache(voteContent);
}
+ public void removeVoteContentFromCache(VoteContent voteContent) {
+ voteContentDAO.removeVoteContentFromCache(voteContent);
+ }
+
public void setDataFlowDAO(IDataFlowDAO dataFlowDAO) {
this.dataFlowDAO = dataFlowDAO;
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/util/VoteUtils.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/util/VoteUtils.java (.../VoteUtils.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/util/VoteUtils.java (.../VoteUtils.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -22,157 +22,19 @@
package org.lamsfoundation.lams.tool.vote.util;
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-import java.util.TreeMap;
-
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralAuthoringDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
-import org.lamsfoundation.lams.tool.vote.pojos.VoteSession;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
-import org.lamsfoundation.lams.tool.vote.service.VoteApplicationException;
-import org.lamsfoundation.lams.tool.vote.web.form.VoteAuthoringForm;
-import org.lamsfoundation.lams.usermanagement.User;
-import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
-import org.lamsfoundation.lams.web.session.SessionManager;
-import org.lamsfoundation.lams.web.util.AttributeNames;
-import org.lamsfoundation.lams.web.util.SessionMap;
/**
- *
* Common Voting utility functions live here.
- *
*
* @author Ozgur Demirtas
*/
public abstract class VoteUtils implements VoteAppConstants {
- public static String replaceNewLines(String text) {
- String newText = "";
- if (text != null) {
- newText = text.replaceAll("\n", "
");
- }
-
- return newText;
- }
-
- public static String getCurrentLearnerID() {
- String userID = "";
- HttpSession ss = SessionManager.getSession();
-
- if (ss != null) {
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if ((user != null) && (user.getUserID() != null)) {
- userID = user.getUserID().toString();
- }
- }
- return userID;
- }
-
- /**
- *
- * getGMTDateTime(HttpServletRequest request)
- *
- * @param request
- * @return
- */
- /* fix this */
- public static Date getGMTDateTime() {
- Date date = new Date(System.currentTimeMillis());
- return date;
- }
-
- public static String getFormattedDateString(Date date) {
- return (DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date));
- }
-
- public static void saveTimeZone(HttpServletRequest request) {
- TimeZone timeZone = TimeZone.getDefault();
- }
-
- public static String getCurrentTimeZone() {
- TimeZone timeZone = TimeZone.getDefault();
- return timeZone.getDisplayName();
- }
-
- /**
- * existsContent(long toolContentId)
- *
- * @param long toolContentId
- * @return boolean determine whether a specific toolContentId exists in the db
- */
- public static boolean existsContent(Long toolContentId, HttpServletRequest request, IVoteService voteService) {
-
- VoteContent voteContent = voteService.retrieveVote(toolContentId);
- if (voteContent == null)
- return false;
-
- return true;
- }
-
- /**
- * it is expected that the tool session id already exists in the tool sessions table existsSession(long
- * toolSessionId)
- *
- * @param toolSessionId
- * @return boolean
- */
- public static boolean existsSession(Long toolSessionId, HttpServletRequest request, IVoteService voteService) {
-
- VoteSession voteSession = voteService.retrieveVoteSession(toolSessionId);
-
- if (voteSession == null)
- return false;
-
- return true;
- }
-
- public static void readContentValues(HttpServletRequest request, VoteContent defaultVoteContent,
- VoteAuthoringForm voteAuthoringForm, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) {
- /* should never be null anyway as default content MUST exist in the db */
- if (defaultVoteContent == null)
- throw new NullPointerException("Default VoteContent cannot be null");
-
- voteGeneralAuthoringDTO.setActivityTitle(defaultVoteContent.getTitle());
- voteGeneralAuthoringDTO.setActivityInstructions(defaultVoteContent.getInstructions());
-
- voteAuthoringForm.setUseSelectLeaderToolOuput(defaultVoteContent.isUseSelectLeaderToolOuput() ? "1" : "0");
- voteAuthoringForm.setAllowText(defaultVoteContent.isAllowText() ? "1" : "0");
- voteAuthoringForm.setAllowTextEntry(defaultVoteContent.isAllowText() ? "1" : "0");
-
- voteAuthoringForm.setShowResults(defaultVoteContent.isShowResults() ? "1" : "0");
-
- voteAuthoringForm.setLockOnFinish(defaultVoteContent.isLockOnFinish() ? "1" : "0");
- voteAuthoringForm.setReflect(defaultVoteContent.isReflect() ? "1" : "0");
-
- voteGeneralAuthoringDTO
- .setUseSelectLeaderToolOuput(defaultVoteContent.isUseSelectLeaderToolOuput() ? "1" : "0");
- voteGeneralAuthoringDTO.setAllowText(defaultVoteContent.isAllowText() ? "1" : "0");
- voteGeneralAuthoringDTO.setLockOnFinish(defaultVoteContent.isLockOnFinish() ? "1" : "0");
- voteAuthoringForm.setReflect(defaultVoteContent.isReflect() ? "1" : "0");
-
- String maxNomcount = defaultVoteContent.getMaxNominationCount();
- if (maxNomcount.equals(""))
- maxNomcount = "0";
- voteAuthoringForm.setMaxNominationCount(maxNomcount);
- voteGeneralAuthoringDTO.setMaxNominationCount(maxNomcount);
-
- String minNomcount = defaultVoteContent.getMinNominationCount();
- if ((minNomcount == null) || minNomcount.equals(""))
- minNomcount = "0";
- voteAuthoringForm.setMinNominationCount(minNomcount);
- voteGeneralAuthoringDTO.setMinNominationCount(minNomcount);
- }
-
public static String stripHTML(String htmlText) {
String noHTMLText = htmlText.replaceAll("\\<.*?\\>", "").replaceAll(" ", "")
.replaceAll("[0-9][0-9][0-9][0-9];", "");
@@ -219,137 +81,7 @@
return noHtmlNoNewLineStr;
}
- public static void saveRichText(HttpServletRequest request, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO,
- SessionMap sessionMap) {
- String richTextTitle = request.getParameter(TITLE);
- String richTextInstructions = request.getParameter(INSTRUCTIONS);
-
- if (richTextTitle != null) {
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- }
- String noHTMLTitle = stripHTML(richTextTitle);
-
- if (richTextInstructions != null) {
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- }
- }
-
/**
- * temporary function
- *
- * @return
- */
- public static int getCurrentUserId(HttpServletRequest request) throws VoteApplicationException {
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- return user.getUserID().intValue();
- }
-
- /**
- * temporary function
- *
- * @return
- */
- public static User createSimpleUser(Integer userId) {
- User user = new User();
- user.setUserId(userId);
- return user;
- }
-
- /**
- * temporary function
- *
- * @return
- */
- public static boolean getDefineLaterStatus() {
- return false;
- }
-
- /**
- * builds a map from a list convertToMap(List sessionsList)
- *
- * @param sessionsList
- * @return Map
- */
- public static Map convertToMap(List sessionsList, String listType) {
- Map map = new TreeMap(new VoteComparator());
-
- Iterator listIterator = sessionsList.iterator();
- Long mapIndex = new Long(1);
-
- while (listIterator.hasNext()) {
- if (listType.equals("String")) {
- String text = (String) listIterator.next();
- map.put(mapIndex.toString(), text);
- } else if (listType.equals("Long")) {
- Long LongValue = (Long) listIterator.next();
- map.put(mapIndex.toString(), LongValue);
- }
- mapIndex = new Long(mapIndex.longValue() + 1);
- }
- return map;
- }
-
- /**
- * find out if the content is in use or not. If it is in use, the author can not modify it. The idea of content
- * being in use is, once any one learner starts using a particular content that content should become unmodifiable.
- *
- * isContentInUse(VoteContent voteContent)
- *
- * @param voteContent
- * @return boolean
- */
- public static boolean isContentInUse(VoteContent voteContent) {
- return voteContent.isContentInUse();
- }
-
- /**
- * find out if the content is being edited in monitoring interface or not. If it is, the author can not modify it.
- *
- * isDefineLater(VoteContent voteContent)
- *
- * @param voteContent
- * @return boolean
- */
- public static boolean isDefineLater(VoteContent voteContent) {
- return voteContent.isDefineLater();
- }
-
- public static String getDestination(String sourceVoteStarter) {
-
- if ((sourceVoteStarter != null) && !sourceVoteStarter.equals("monitoring")) {
- // request is from authoring or define Later url. return to: LOAD_QUESTIONS
- return LOAD_QUESTIONS;
- } else if (sourceVoteStarter == null) {
- // request is from authoring url. return to: LOAD_QUESTIONS
- return LOAD_QUESTIONS;
- } else {
- // request is from monitoring url. return to: LOAD_MONITORING_CONTENT_EDITACTIVITY
- return LOAD_MONITORING_CONTENT_EDITACTIVITY;
- }
- }
-
- public static void setDefineLater(HttpServletRequest request, boolean value, IVoteService voteService,
- String toolContentID) {
-
- VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID));
- if (voteContent != null) {
- voteContent.setDefineLater(value);
- voteService.updateVote(voteContent);
- }
- }
-
- /**
- *
- * cleanUpSessionAbsolute(HttpServletRequest request)
- *
- * @param request
- */
- public static void cleanUpSessionAbsolute(HttpServletRequest request) {
- cleanUpUserExceptions(request);
- }
-
- /**
* removes attributes except USER_EXCEPTION_NO_STUDENT_ACTIVITY
*/
public static void cleanUpUserExceptions(HttpServletRequest request) {
@@ -363,9 +95,6 @@
request.getSession().removeAttribute(USER_EXCEPTION_CONTENTID_REQUIRED);
request.getSession().removeAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED);
request.getSession().removeAttribute(USER_EXCEPTION_TOOLSESSIONID_INCONSISTENT);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTOPTIONSCONTENT_NOT_AVAILABLE);
request.getSession().removeAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE);
request.getSession().removeAttribute(USER_EXCEPTION_USERID_NOTNUMERIC);
request.getSession().removeAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS);
@@ -389,55 +118,10 @@
request.getSession().removeAttribute(USER_EXCEPTION_SINGLE_OPTION);
}
- public static void setFormProperties(HttpServletRequest request, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, VoteGeneralAuthoringDTO voteGeneralAuthoringDTO,
- String strToolContentID, String defaultContentIdStr, String activeModule, SessionMap sessionMap,
- String httpSessionID) {
-
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
-
- voteAuthoringForm.setToolContentID(strToolContentID);
-
- if ((defaultContentIdStr != null) && (defaultContentIdStr.length() > 0))
- voteAuthoringForm.setDefaultContentIdStr(new Long(defaultContentIdStr).toString());
-
- voteAuthoringForm.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
-
- String lockOnFinish = request.getParameter("lockOnFinish");
- voteAuthoringForm.setLockOnFinish(lockOnFinish);
- voteGeneralAuthoringDTO.setLockOnFinish(lockOnFinish);
-
- String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput");
- voteAuthoringForm.setUseSelectLeaderToolOuput(useSelectLeaderToolOuput);;
- voteGeneralAuthoringDTO.setAllowText(useSelectLeaderToolOuput);
-
- String allowText = request.getParameter("allowText");
- voteAuthoringForm.setAllowText(allowText);
- voteGeneralAuthoringDTO.setAllowText(allowText);
-
- String showResults = request.getParameter("showResults");
- voteAuthoringForm.setShowResults(showResults);
- voteGeneralAuthoringDTO.setShowResults(showResults);
-
- String maxNominationCount = request.getParameter("maxNominationCount");
- voteAuthoringForm.setMaxNominationCount(maxNominationCount);
- voteGeneralAuthoringDTO.setMaxNominationCount(maxNominationCount);
-
- String reflect = request.getParameter("reflect");
- voteAuthoringForm.setReflect(reflect);
- voteGeneralAuthoringDTO.setReflect(reflect);
-
- String reflectionSubject = request.getParameter("reflectionSubject");
- voteAuthoringForm.setReflectionSubject(reflectionSubject);
- voteGeneralAuthoringDTO.setReflectionSubject(reflectionSubject);
- }
-
public static void setDefineLater(HttpServletRequest request, boolean value, String strToolContentID,
IVoteService voteService) {
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
+ VoteContent voteContent = voteService.getVoteContent(new Long(strToolContentID));
if (voteContent != null) {
voteContent.setDefineLater(value);
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -33,9 +33,8 @@
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
-import org.lamsfoundation.lams.learningdesign.DataFlowObject;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.VoteNominationContentDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
@@ -44,701 +43,164 @@
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
-import org.lamsfoundation.lams.web.util.SessionMap;
/**
- *
- *
* Keeps all operations needed for Authoring mode.
- *
*
* @author Ozgur Demirtas
- *
*/
public class AuthoringUtil implements VoteAppConstants {
- static private Logger logger = Logger.getLogger(AuthoringUtil.class.getName());
-
- /**
- * checks if there are any duplicate entries
- *
- * @param mapOptionsContent
- * @returnboolean
- */
- public static boolean verifyDuplicateNominations(Map mapOptionsContent) {
- Map originalMapOptionsContent = mapOptionsContent;
- Map backupMapOptionsContent = mapOptionsContent;
+ private static Logger logger = Logger.getLogger(AuthoringUtil.class.getName());
- int optionCount = 0;
- for (long i = 1; i <= VoteAppConstants.MAX_OPTION_COUNT; i++) {
- String currentOption = (String) originalMapOptionsContent.get(new Long(i).toString());
+ protected static List swapQuestions(List questionDTOs, String questionIndex,
+ String direction) {
- optionCount = 0;
- for (long j = 1; j <= VoteAppConstants.MAX_OPTION_COUNT; j++) {
- String backedOption = (String) backupMapOptionsContent.get(new Long(j).toString());
+ int intQuestionIndex = new Integer(questionIndex).intValue();
+ int intOriginalQuestionIndex = intQuestionIndex;
- if (currentOption != null && backedOption != null) {
- if (currentOption.equals(backedOption)) {
- optionCount++;
- }
-
- if (optionCount > 1) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- /**
- * checks if the map is empty or not
- *
- * @param map
- * @return boolean
- */
- public static boolean verifyMapNoEmptyString(Map map) {
- Iterator itMap = map.entrySet().iterator();
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
-
- if (pairs.getValue() != null && pairs.getValue().toString().length() == 0) {
- return false;
- }
-
- }
- return true;
- }
-
- public static boolean validateNominationsNotEmpty(Map mapNominationsContent) {
- Iterator itMap = mapNominationsContent.entrySet().iterator();
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
-
- if (pairs.getValue() != null && pairs.getValue().toString().length() == 0) {
- return false;
- }
-
- }
- return true;
- }
-
- public static Map repopulateMap(HttpServletRequest request, String parameterType) {
- Map mapTempNominationsContent = new TreeMap(new VoteComparator());
-
- long mapCounter = 0;
- String optionContent0 = request.getParameter("optionContent0");
- mapCounter++;
- mapTempNominationsContent.put(new Long(mapCounter).toString(), optionContent0);
-
- for (long i = 1; i <= VoteAppConstants.MAX_QUESTION_COUNT; i++) {
- String candidateEntry = request.getParameter(parameterType + i);
- if (candidateEntry != null && candidateEntry.length() > 0) {
- mapCounter++;
- mapTempNominationsContent.put(new Long(mapCounter).toString(), candidateEntry);
- }
- }
- return mapTempNominationsContent;
- }
-
- public static Map shiftMap(Map mapOptionsContent, String optIndex, String movableOptionEntry, String direction) {
- Map mapTempOptionsContent = new TreeMap(new VoteComparator());
-
- String shiftableEntry = null;
-
- int shiftableIndex = 0;
+ int replacedQuestionIndex = 0;
if (direction.equals("down")) {
- //moving map down");
- shiftableIndex = new Integer(optIndex).intValue() + 1;
+ replacedQuestionIndex = ++intQuestionIndex;
} else {
- //moving map up
- shiftableIndex = new Integer(optIndex).intValue() - 1;
+ replacedQuestionIndex = --intQuestionIndex;
}
- shiftableEntry = (String) mapOptionsContent.get(new Integer(shiftableIndex).toString());
+ VoteQuestionDTO mainQuestion = getQuestionAtDisplayOrder(questionDTOs, intOriginalQuestionIndex);
- if (shiftableEntry != null) {
- Iterator itNominationsMap = mapOptionsContent.entrySet().iterator();
- long mapCounter = 0;
- while (itNominationsMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itNominationsMap.next();
- mapCounter++;
+ VoteQuestionDTO replacedQuestion = getQuestionAtDisplayOrder(questionDTOs, replacedQuestionIndex);
- if (!pairs.getKey().equals(optIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString())) {
- //normal copy
- mapTempOptionsContent.put(new Long(mapCounter).toString(), pairs.getValue());
- } else if (pairs.getKey().equals(optIndex)) {
- //move type 1
- mapTempOptionsContent.put(new Long(mapCounter).toString(), shiftableEntry);
- } else if (pairs.getKey().equals(new Integer(shiftableIndex).toString())) {
- mapTempOptionsContent.put(new Long(mapCounter).toString(), movableOptionEntry);
- }
- }
- } else {
- mapTempOptionsContent = mapOptionsContent;
- }
- return mapTempOptionsContent;
- }
+ List newQuestionDtos = new LinkedList();
- protected Map reconstructOptionContentMapForAdd(Map mapOptionsContent, HttpServletRequest request) {
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ VoteQuestionDTO questionDTO = iter.next();
+ VoteQuestionDTO tempQuestion = new VoteQuestionDTO();
- mapOptionsContent = repopulateMap(mapOptionsContent, request);
- mapOptionsContent.put(new Long(mapOptionsContent.size() + 1).toString(), "");
-
- return mapOptionsContent;
- }
-
- protected void reconstructOptionContentMapForRemove(Map mapOptionsContent, HttpServletRequest request,
- VoteAuthoringForm voteAuthoringForm) {
- String optIndex = voteAuthoringForm.getOptIndex();
-
- String defLater = voteAuthoringForm.getActiveModule();
-
- String removableOptIndex = null;
- if (defLater != null && defLater.equals(VoteAppConstants.MONITORING)) {
- removableOptIndex = (String) request.getSession().getAttribute(VoteAppConstants.REMOVABLE_QUESTION_INDEX);
- optIndex = removableOptIndex;
- }
-
- long longOptIndex = new Long(optIndex).longValue();
-
- repopulateMap(mapOptionsContent, request);
-
- mapOptionsContent.remove(new Long(longOptIndex).toString());
- }
-
- protected Map repopulateMap(Map mapOptionsContent, HttpServletRequest request) {
- int intOptionIndex = mapOptionsContent.size();
-
- /* if there is data in the Map remaining from previous session remove those */
- mapOptionsContent.clear();
-
- for (long i = 0; i < intOptionIndex; i++) {
- String candidateOptionEntry = request.getParameter("optionContent" + i);
- if (i == 0) {
- request.getSession().setAttribute("defaultOptionContent", candidateOptionEntry);
+ if (!questionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())
+ && !questionDTO.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) {
+ // normal copy
+ tempQuestion = questionDTO;
+
+ } else if (questionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) {
+ // move type 1
+ tempQuestion = replacedQuestion;
+
+ } else if (questionDTO.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) {
+ // move type 1
+ tempQuestion = mainQuestion;
}
- if (candidateOptionEntry != null && candidateOptionEntry.length() > 0) {
- mapOptionsContent.put(new Long(i + 1).toString(), candidateOptionEntry);
- }
- }
- return mapOptionsContent;
- }
- /**
- *
- * @param mapOptionsContent
- * @param request
- */
- protected Map reconstructOptionsContentMapForSubmit(Map mapOptionsContent, HttpServletRequest request) {
-
- repopulateMap(mapOptionsContent, request);
- Map mapFinalOptionsContent = new TreeMap(new VoteComparator());
-
- Iterator itMap = mapOptionsContent.entrySet().iterator();
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
- if (pairs.getValue() != null && !pairs.getValue().equals("")) {
- mapFinalOptionsContent.put(pairs.getKey(), pairs.getValue());
- }
+ newQuestionDtos.add(tempQuestion);
}
- mapOptionsContent = mapFinalOptionsContent;
- return mapOptionsContent;
+ return newQuestionDtos;
}
- public void removeRedundantOptions(Map mapOptionsContent, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, HttpServletRequest request) {
+ protected static VoteQuestionDTO getQuestionAtDisplayOrder(List questionDTOs, int intOriginalQuestionIndex) {
- String toolContentID = voteAuthoringForm.getToolContentID();
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ VoteQuestionDTO voteQuestionDTO = iter.next();
- VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID));
-
- if (voteContent != null) {
- List allNominations = voteService.getAllQuestionEntries(voteContent.getUid());
-
- Iterator listIterator = allNominations.iterator();
- boolean entryUsed = false;
- while (listIterator.hasNext()) {
- VoteQueContent queContent = (VoteQueContent) listIterator.next();
-
- entryUsed = false;
- Iterator itMap = mapOptionsContent.entrySet().iterator();
- while (itMap.hasNext()) {
- entryUsed = false;
- Map.Entry pairs = (Map.Entry) itMap.next();
- if (pairs.getValue().toString().length() != 0) {
- if (pairs.getValue().toString().equals(queContent.getQuestion())) {
- entryUsed = true;
- break;
- }
- }
- }
-
- if (entryUsed == false) {
-
- VoteQueContent removeableVoteQueContent = voteService.getQuestionContentByQuestionText(queContent
- .getQuestion(), voteContent.getUid());
-
- if (removeableVoteQueContent != null) {
- voteContent.getVoteQueContents().remove(removeableVoteQueContent);
-
- voteService.removeVoteQueContent(removeableVoteQueContent);
- }
-
- }
+ if (new Integer(intOriginalQuestionIndex).toString().equals(voteQuestionDTO.getDisplayOrder())) {
+ return voteQuestionDTO;
}
}
-
- }
-
- /**
- * persists the vote content
- *
- * @param mapOptionsContent
- * @param voteService
- * @param voteAuthoringForm
- * @param request
- * @return
- */
- public VoteContent saveOrUpdateVoteContent(Map mapOptionsContent, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, SessionMap sessionMap,
- DataFlowObject assignedDataFlowObject) {
- UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- String lockOnFinish = request.getParameter("lockOnFinish");
-
- String allowTextEntry = request.getParameter("allowText");
-
- String showResults = request.getParameter("showResults");
-
- String maxInputs = request.getParameter("maxInputs");
-
- String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput");
-
- String reflect = request.getParameter(VoteAppConstants.REFLECT);
-
- String reflectionSubject = voteAuthoringForm.getReflectionSubject();
-
- String maxNomcount = voteAuthoringForm.getMaxNominationCount();
-
- String minNomcount= voteAuthoringForm.getMinNominationCount();
-
- String activeModule = voteAuthoringForm.getActiveModule();
-
- boolean lockedOnFinishBoolean = false;
- boolean allowTextBoolean = false;
- boolean reflectBoolean = false;
- boolean showResultsBoolean = false;
- boolean useSelectLeaderToolOuputBoolean = false;
- short maxInputsShort = 0;
-
- if (lockOnFinish != null && lockOnFinish.equalsIgnoreCase("1")) {
- lockedOnFinishBoolean = true;
- }
-
- if (allowTextEntry != null && allowTextEntry.equalsIgnoreCase("1")) {
- allowTextBoolean = true;
- }
-
- if (reflect != null && reflect.equalsIgnoreCase("1")) {
- reflectBoolean = true;
- }
-
- if (showResults != null && showResults.equalsIgnoreCase("1")) {
- showResultsBoolean = true;
- }
-
- if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("1")) {
- useSelectLeaderToolOuputBoolean = true;
- }
-
- if (maxInputs != null && !"0".equals(maxInputs)) {
- maxInputsShort = Short.parseShort(maxInputs);
- }
-
- long userId = 0;
- if (toolUser != null) {
- userId = toolUser.getUserID().longValue();
- } else {
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if (user != null) {
- userId = user.getUserID().longValue();
- } else {
- userId = 0;
- }
- }
-
- String toolContentID = voteAuthoringForm.getToolContentID();
-
- VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID));
-
- boolean newContent = false;
- if (voteContent == null) {
- voteContent = new VoteContent();
- newContent = true;
- }
-
- voteContent.setVoteContentId(new Long(toolContentID));
- voteContent.setTitle(richTextTitle);
- voteContent.setInstructions(richTextInstructions);
- voteContent.setUpdateDate(new Date(System.currentTimeMillis()));
- /** keep updating this one */
- voteContent.setCreatedBy(userId);
- /** make sure we are setting the userId from the User object above */
-
- if (activeModule.equals(VoteAppConstants.AUTHORING)) {
- voteContent.setLockOnFinish(lockedOnFinishBoolean);
- voteContent.setAllowText(allowTextBoolean);
- voteContent.setShowResults(showResultsBoolean);
- voteContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean);
- voteContent.setReflect(reflectBoolean);
- voteContent.setReflectionSubject(reflectionSubject);
- voteContent.setMaxNominationCount(maxNomcount);
- voteContent.setMinNominationCount(minNomcount);
- voteContent.setMaxExternalInputs(maxInputsShort);
- }
-
- voteContent.setAssignedDataFlowObject(assignedDataFlowObject != null);
-
- if (newContent) {
- voteService.createVote(voteContent);
- } else {
- voteService.updateVote(voteContent);
- }
-
- voteContent = voteService.retrieveVote(new Long(toolContentID));
-
- voteContent = createOptionsContent(mapOptionsContent, voteService, voteContent);
-
- voteService.saveDataFlowObjectAssigment(assignedDataFlowObject);
-
- return voteContent;
- }
-
- /**
- * creates a new vote content
- *
- * @param mapOptionsContent
- * @param voteService
- * @param voteContent
- * @return
- */
- protected VoteContent createOptionsContent(Map mapOptionsContent, IVoteService voteService, VoteContent voteContent) {
-
- Iterator itMap = mapOptionsContent.entrySet().iterator();
- int diplayOrder = 0;
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
-
- if (pairs.getValue().toString().length() != 0) {
- diplayOrder = new Integer(pairs.getKey().toString()).intValue();
-
- VoteQueContent queContent = new VoteQueContent(pairs.getValue().toString(), diplayOrder, voteContent,
- null);
-
- /* checks if the question is already recorded */
-
- VoteQueContent existingVoteQueContent = voteService.getQuestionContentByQuestionText(pairs.getValue()
- .toString(), voteContent.getUid());
- if (existingVoteQueContent == null) {
- /* make sure a question with the same question text is not already saved */
- VoteQueContent duplicateVoteQueContent = voteService.getQuestionContentByQuestionText(pairs
- .getValue().toString(), voteContent.getUid());
- if (duplicateVoteQueContent == null) {
- voteContent.getVoteQueContents().add(queContent);
- queContent.setVoteContent(voteContent);
-
- voteService.createVoteQue(queContent);
- }
- } else {
- existingVoteQueContent.setQuestion(pairs.getValue().toString());
- existingVoteQueContent.setDisplayOrder(diplayOrder);
- voteService.updateVoteQueContent(existingVoteQueContent);
- }
- }
- }
- return voteContent;
- }
-
- protected static List swapNodes(List listNominationContentDTO, String questionIndex, String direction) {
-
- int intNominationIndex = new Integer(questionIndex).intValue();
- int intOriginalNominationIndex = intNominationIndex;
-
- int replacedNodeIndex = 0;
- if (direction.equals("down")) {
- replacedNodeIndex = ++intNominationIndex;
- } else {
- replacedNodeIndex = --intNominationIndex;
-
- }
-
- VoteNominationContentDTO mainNode = extractNodeAtDisplayOrder(listNominationContentDTO,
- intOriginalNominationIndex);
-
- VoteNominationContentDTO replacedNode = extractNodeAtDisplayOrder(listNominationContentDTO, replacedNodeIndex);
-
- List listFinalNominationContentDTO = new LinkedList();
-
- listFinalNominationContentDTO = reorderSwappedListNominationContentDTO(listNominationContentDTO,
- intOriginalNominationIndex, replacedNodeIndex, mainNode, replacedNode);
-
- return listFinalNominationContentDTO;
- }
-
- protected static VoteNominationContentDTO extractNodeAtDisplayOrder(List listNominationContentDTO,
- int intOriginalNominationIndex) {
-
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- if (new Integer(intOriginalNominationIndex).toString().equals(voteNominationContentDTO.getDisplayOrder())) {
- return voteNominationContentDTO;
- }
- }
return null;
}
- protected static List reorderSwappedListNominationContentDTO(List listNominationContentDTO,
- int intOriginalNominationIndex, int replacedNodeIndex, VoteNominationContentDTO mainNode,
- VoteNominationContentDTO replacedNode) {
+ protected static List reorderQuestionDTOs(List listQuestionDTO) {
+ List listFinalQuestionDTO = new LinkedList();
- List listFinalNominationContentDTO = new LinkedList();
-
int queIndex = 0;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
- queIndex++;
- VoteNominationContentDTO tempNode = new VoteNominationContentDTO();
+ Iterator iter = listQuestionDTO.iterator();
+ while (iter.hasNext()) {
+ VoteQuestionDTO voteQuestionDTO = (VoteQuestionDTO) iter.next();
- if (!voteNominationContentDTO.getDisplayOrder().equals(new Integer(intOriginalNominationIndex).toString())
- && !voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
- //normal copy
- tempNode.setNomination(voteNominationContentDTO.getNomination());
- tempNode.setDisplayOrder(voteNominationContentDTO.getDisplayOrder());
- tempNode.setFeedback(voteNominationContentDTO.getFeedback());
- } else if (voteNominationContentDTO.getDisplayOrder().equals(
- new Integer(intOriginalNominationIndex).toString())) {
- //move type 1
- tempNode.setNomination(replacedNode.getNomination());
- tempNode.setDisplayOrder(replacedNode.getDisplayOrder());
- tempNode.setFeedback(replacedNode.getFeedback());
- } else if (voteNominationContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
- //move type 1
- tempNode.setNomination(mainNode.getNomination());
- tempNode.setDisplayOrder(mainNode.getDisplayOrder());
- tempNode.setFeedback(mainNode.getFeedback());
- }
+ String question = voteQuestionDTO.getNomination();
- listFinalNominationContentDTO.add(tempNode);
- }
+ String displayOrder = voteQuestionDTO.getDisplayOrder();
- return listFinalNominationContentDTO;
- }
-
- protected static List reorderSimpleListNominationContentDTO(List listNominationContentDTO) {
- List listFinalNominationContentDTO = new LinkedList();
-
- int queIndex = 0;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- String question = voteNominationContentDTO.getNomination();
-
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- String feedback = voteNominationContentDTO.getFeedback();
-
if (question != null && !question.equals("")) {
++queIndex;
- voteNominationContentDTO.setNomination(question);
- voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString());
- voteNominationContentDTO.setFeedback(feedback);
+ voteQuestionDTO.setNomination(question);
+ voteQuestionDTO.setDisplayOrder(new Integer(queIndex).toString());
- listFinalNominationContentDTO.add(voteNominationContentDTO);
+ listFinalQuestionDTO.add(voteQuestionDTO);
}
}
- return listFinalNominationContentDTO;
+ return listFinalQuestionDTO;
}
- protected static List reorderListNominationContentDTO(List listNominationContentDTO, String excludeNominationIndex) {
+ public static boolean checkDuplicateNominations(List listQuestionDTO, String newQuestion) {
- List listFinalNominationContentDTO = new LinkedList();
+ Map mapQuestion = extractMapQuestion(listQuestionDTO);
- int queIndex = 0;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- String question = voteNominationContentDTO.getNomination();
-
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- String feedback = voteNominationContentDTO.getFeedback();
-
- if (question != null && !question.equals("")) {
- if (!displayOrder.equals(excludeNominationIndex)) {
- ++queIndex;
-
- voteNominationContentDTO.setNomination(question);
- voteNominationContentDTO.setDisplayOrder(new Integer(queIndex).toString());
- voteNominationContentDTO.setFeedback(feedback);
-
- listFinalNominationContentDTO.add(voteNominationContentDTO);
- }
- }
- }
-
- return listFinalNominationContentDTO;
- }
-
- public static boolean checkDuplicateNominations(List listNominationContentDTO, String newNomination) {
-
- Map mapNominationContent = extractMapNominationContent(listNominationContentDTO);
-
- Iterator itMap = mapNominationContent.entrySet().iterator();
+ Iterator itMap = mapQuestion.entrySet().iterator();
while (itMap.hasNext()) {
Map.Entry pairs = (Map.Entry) itMap.next();
if (pairs.getValue() != null && !pairs.getValue().equals("")) {
- if (pairs.getValue().equals(newNomination)) {
+ if (pairs.getValue().equals(newQuestion)) {
return true;
}
}
}
return false;
}
- protected static Map extractMapNominationContent(List listNominationContentDTO) {
- Map mapNominationContent = new TreeMap(new VoteComparator());
+ protected static Map extractMapQuestion(List listQuestionDTO) {
+ Map mapQuestion = new TreeMap(new VoteComparator());
- Iterator listIterator = listNominationContentDTO.iterator();
+ Iterator iter = listQuestionDTO.iterator();
int queIndex = 0;
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
+ while (iter.hasNext()) {
+ VoteQuestionDTO voteQuestionDTO = (VoteQuestionDTO) iter.next();
queIndex++;
- mapNominationContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getNomination());
+ mapQuestion.put(new Integer(queIndex).toString(), voteQuestionDTO.getNomination());
}
- return mapNominationContent;
+ return mapQuestion;
}
- protected static List reorderUpdateListNominationContentDTO(List listNominationContentDTO,
- VoteNominationContentDTO voteNominationContentDTONew, String editableNominationIndex) {
+ protected static List reorderUpdateListQuestionDTO(List listQuestionDTO, VoteQuestionDTO voteQuestionDTONew,
+ String editableQuestionIndex) {
- List listFinalNominationContentDTO = new LinkedList();
+ List listFinalQuestionDTO = new LinkedList();
int queIndex = 0;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
+ Iterator iter = listQuestionDTO.iterator();
+ while (iter.hasNext()) {
+ VoteQuestionDTO voteQuestionDTO = (VoteQuestionDTO) iter.next();
++queIndex;
- String question = voteNominationContentDTO.getNomination();
+ String question = voteQuestionDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
+ String displayOrder = voteQuestionDTO.getDisplayOrder();
- String feedback = voteNominationContentDTO.getFeedback();
+ if (displayOrder.equals(editableQuestionIndex)) {
+ voteQuestionDTO.setNomination(voteQuestionDTONew.getNomination());
+ voteQuestionDTO.setDisplayOrder(voteQuestionDTONew.getDisplayOrder());
- if (displayOrder.equals(editableNominationIndex)) {
- voteNominationContentDTO.setNomination(voteNominationContentDTONew.getNomination());
- voteNominationContentDTO.setDisplayOrder(voteNominationContentDTONew.getDisplayOrder());
- voteNominationContentDTO.setFeedback(voteNominationContentDTONew.getFeedback());
-
- listFinalNominationContentDTO.add(voteNominationContentDTO);
+ listFinalQuestionDTO.add(voteQuestionDTO);
} else {
- voteNominationContentDTO.setNomination(question);
- voteNominationContentDTO.setDisplayOrder(displayOrder);
- voteNominationContentDTO.setFeedback(feedback);
+ voteQuestionDTO.setNomination(question);
+ voteQuestionDTO.setDisplayOrder(displayOrder);
- listFinalNominationContentDTO.add(voteNominationContentDTO);
+ listFinalQuestionDTO.add(voteQuestionDTO);
}
}
- return listFinalNominationContentDTO;
+ return listFinalQuestionDTO;
}
- protected static Map extractMapFeedback(List listNominationContentDTO) {
- Map mapFeedbackContent = new TreeMap(new VoteComparator());
-
- Iterator listIterator = listNominationContentDTO.iterator();
- int queIndex = 0;
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- queIndex++;
- mapFeedbackContent.put(new Integer(queIndex).toString(), voteNominationContentDTO.getFeedback());
- }
- return mapFeedbackContent;
- }
-
- public void removeRedundantNominations(Map mapNominationContent, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, String toolContentID) {
-
- VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID));
-
- if (voteContent != null) {
- List allNominations = voteService.getAllQuestionEntries(voteContent.getUid());
-
- Iterator listIterator = allNominations.iterator();
- int mapIndex = 0;
- boolean entryUsed = false;
- while (listIterator.hasNext()) {
- ++mapIndex;
-
- VoteQueContent queContent = (VoteQueContent) listIterator.next();
-
- entryUsed = false;
- Iterator itMap = mapNominationContent.entrySet().iterator();
- int displayOrder = 0;
- while (itMap.hasNext()) {
- ++displayOrder;
- entryUsed = false;
- Map.Entry pairs = (Map.Entry) itMap.next();
-
- if (pairs.getValue().toString().length() != 0) {
-
- if (mapIndex == displayOrder) {
- entryUsed = true;
- break;
- }
-
- }
- }
-
- if (entryUsed == false) {
-
- VoteQueContent removeableVoteQueContent = voteService.getQuestionContentByQuestionText(queContent
- .getQuestion(), voteContent.getUid());
- if (removeableVoteQueContent != null) {
- voteService.removeVoteQueContent(removeableVoteQueContent);
- }
-
- }
- }
- }
-
- }
-
- public VoteContent saveOrUpdateVoteContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, HttpServletRequest request, VoteContent voteContent,
- String strToolContentID, DataFlowObject assignedDataFlowObject) {
+ public static VoteContent saveOrUpdateVoteContent(IVoteService voteService, VoteAuthoringForm voteAuthoringForm,
+ HttpServletRequest request, VoteContent voteContent, String strToolContentID) {
UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
- boolean isLockOnFinish = false;
- boolean isAllowTextEntry = false;
- boolean isReflect = false;
-
String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
@@ -749,27 +211,17 @@
String showResults = request.getParameter("showResults");
String maxInputs = request.getParameter("maxInputs");
-
+
String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput");
String reflect = request.getParameter(VoteAppConstants.REFLECT);
String reflectionSubject = voteAuthoringForm.getReflectionSubject();
String maxNomcount = voteAuthoringForm.getMaxNominationCount();
-
- String minNomcount= voteAuthoringForm.getMinNominationCount();
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
+ String minNomcount = voteAuthoringForm.getMinNominationCount();
- boolean setCommonContent = true;
- if (lockOnFinish == null || allowTextEntry == null || showResults == null || reflect == null
- || reflectionSubject == null || maxNomcount == null || minNomcount == null)
-
- {
- setCommonContent = false;
- }
-
boolean lockOnFinishBoolean = false;
boolean allowTextEntryBoolean = false;
boolean useSelectLeaderToolOuputBoolean = false;
@@ -784,7 +236,7 @@
if (allowTextEntry != null && allowTextEntry.equalsIgnoreCase("1")) {
allowTextEntryBoolean = true;
}
-
+
if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("1")) {
useSelectLeaderToolOuputBoolean = true;
}
@@ -828,94 +280,64 @@
voteContent.setCreatedBy(userId);
/** make sure we are setting the userId from the User object above */
- if (activeModule.equals(VoteAppConstants.AUTHORING)) {
- voteContent.setLockOnFinish(lockOnFinishBoolean);
- voteContent.setAllowText(allowTextEntryBoolean);
- voteContent.setShowResults(showResultsBoolean);
- voteContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean);
- voteContent.setReflect(reflectBoolean);
- voteContent.setMaxNominationCount(maxNomcount);
- voteContent.setMinNominationCount(minNomcount);
+ voteContent.setLockOnFinish(lockOnFinishBoolean);
+ voteContent.setAllowText(allowTextEntryBoolean);
+ voteContent.setShowResults(showResultsBoolean);
+ voteContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean);
+ voteContent.setReflect(reflectBoolean);
+ voteContent.setMaxNominationCount(maxNomcount);
+ voteContent.setMinNominationCount(minNomcount);
- voteContent.setReflectionSubject(reflectionSubject);
+ voteContent.setReflectionSubject(reflectionSubject);
- voteContent.setMaxExternalInputs(maxInputsShort);
- }
+ voteContent.setMaxExternalInputs(maxInputsShort);
if (newContent) {
- voteService.createVote(voteContent);
+ voteService.saveVoteContent(voteContent);
} else {
voteService.updateVote(voteContent);
}
- voteContent = voteService.retrieveVote(new Long(strToolContentID));
+ voteContent = voteService.getVoteContent(new Long(strToolContentID));
- voteContent = createQuestionContent(mapQuestionContent, mapFeedback, voteService, voteContent);
-
- voteService.saveDataFlowObjectAssigment(assignedDataFlowObject);
-
return voteContent;
}
- protected VoteContent createQuestionContent(Map mapQuestionContent, Map mapFeedback, IVoteService voteService,
+ protected static VoteContent createQuestions(List questionDTOs, IVoteService voteService,
VoteContent voteContent) {
- List questions = voteService.retrieveVoteQueContentsByToolContentId(voteContent.getUid().longValue());
- Iterator itMap = mapQuestionContent.entrySet().iterator();
int displayOrder = 0;
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
+ for (VoteQuestionDTO questionDTO : questionDTOs) {
+ String currentQuestionText = questionDTO.getQuestion();
- if (pairs.getValue().toString().length() != 0) {
+ // skip empty questions
+ if (currentQuestionText.isEmpty()) {
+ continue;
+ }
- ++displayOrder;
- String currentFeedback = (String) mapFeedback.get(new Integer(displayOrder).toString());
+ ++displayOrder;
- VoteQueContent queContent = new VoteQueContent(pairs.getValue().toString(), displayOrder, voteContent,
- null);
+ VoteQueContent question = voteService.getVoteQueContentByUID(questionDTO.getUid());
- /* checks if the question is already recorded */
- VoteQueContent existingVoteQueContent = voteService.getQuestionContentByDisplayOrder(new Long(
- displayOrder), voteContent.getUid());
+ // in case question doesn't exist
+ if (question == null) {
- if (existingVoteQueContent == null) {
- /* make sure a question with the same question text is not already saved */
- VoteQueContent duplicateVoteQueContent = voteService.getQuestionContentByQuestionText(pairs
- .getValue().toString(), voteContent.getUid());
- voteContent.getVoteQueContents().add(queContent);
- queContent.setVoteContent(voteContent);
+ question = new VoteQueContent(currentQuestionText, displayOrder, voteContent);
+ // adding a new question to content
+ voteContent.getVoteQueContents().add(question);
+ question.setVoteContent(voteContent);
- voteService.createVoteQue(queContent);
- } else {
+ // in case question exists already
+ } else {
- String existingQuestion = existingVoteQueContent.getQuestion();
-
- existingVoteQueContent.setQuestion(pairs.getValue().toString());
- // existingVoteQueContent.setFeedback(currentFeedback);
- existingVoteQueContent.setDisplayOrder(displayOrder);
- voteService.updateVoteQueContent(existingVoteQueContent);
- }
+ question.setQuestion(currentQuestionText);
+ question.setDisplayOrder(displayOrder);
}
+
+ voteService.saveOrUpdateVoteQueContent(question);
}
+
return voteContent;
}
- public void reOrganizeDisplayOrder(Map mapQuestionContent, IVoteService voteService,
- VoteAuthoringForm voteAuthoringForm, VoteContent voteContent) {
- if (voteContent != null) {
- List sortedQuestions = voteService.getAllQuestionEntriesSorted(voteContent.getUid().longValue());
-
- Iterator listIterator = sortedQuestions.iterator();
- int displayOrder = 1;
- while (listIterator.hasNext()) {
- VoteQueContent queContent = (VoteQueContent) listIterator.next();
-
- VoteQueContent existingVoteQueContent = voteService.getQuestionContentByQuestionText(queContent
- .getQuestion(), voteContent.getUid());
- voteService.updateVoteQueContent(existingVoteQueContent);
- displayOrder++;
- }
- }
- }
-
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ClearSessionAction.java
===================================================================
diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ClearSessionAction.java (.../ClearSessionAction.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ClearSessionAction.java (.../ClearSessionAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -33,40 +33,28 @@
/**
* This class give a chance to clear HttpSession when user save/close authoring page.
- * @author Steve.Ni
*
- * @version $Revision$
- * @author Ozgur Demirtas
+ * @author Steve.Ni, Ozgur Demirtas
*/
public class ClearSessionAction extends LamsAuthoringFinishAction implements VoteAppConstants {
-
- public void clearSession(String customiseSessionID,HttpSession session, ToolAccessMode mode) {
- session.removeAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG);
- if(mode.isAuthor()){
- session.removeAttribute(TOOL_SERVICE);
- session.removeAttribute(ACTIVE_MODULE);
- session.removeAttribute(DEFINE_LATER_IN_EDIT_MODE);
- session.removeAttribute(TOOL_CONTENT_ID);
- session.removeAttribute(DEFAULT_CONTENT_ID);
- session.removeAttribute(DEFAULT_CONTENT_ID_STR);
- session.removeAttribute(IS_DEFINE_LATER);
- session.removeAttribute(REMOVABLE_QUESTION_INDEX);
- session.removeAttribute(ACTIVITY_TITLE);
- session.removeAttribute(ACTIVITY_INSTRUCTIONS);
- session.removeAttribute(DEFAULT_OPTION_CONTENT);
- session.removeAttribute(MAP_OPTIONS_CONTENT);
- session.removeAttribute(MAX_OPTION_INDEX);
- session.removeAttribute(EDITACTIVITY_EDITMODE);
- session.removeAttribute(IS_MONITORED_CONTENT_IN_USE);
- session.removeAttribute(OPT_INDEX);
- session.removeAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP);
- session.removeAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS);
- session.removeAttribute(USER_EXCEPTION_CONTENT_IN_USE);
- session.removeAttribute(USER_EXCEPTION_CONTENTID_REQUIRED);
- session.removeAttribute(USER_EXCEPTION_NUMBERFORMAT);
- }
+ public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) {
+ session.removeAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG);
+ if (mode.isAuthor()) {
+ session.removeAttribute(TOOL_SERVICE);
+ session.removeAttribute(TOOL_CONTENT_ID);
+ session.removeAttribute(IS_DEFINE_LATER);
+ session.removeAttribute(REMOVABLE_QUESTION_INDEX);
+ session.removeAttribute(ACTIVITY_TITLE);
+ session.removeAttribute(ACTIVITY_INSTRUCTIONS);
+ session.removeAttribute(IS_MONITORED_CONTENT_IN_USE);
+ session.removeAttribute(OPT_INDEX);
+ session.removeAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP);
+ session.removeAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS);
+ session.removeAttribute(USER_EXCEPTION_CONTENT_IN_USE);
+ session.removeAttribute(USER_EXCEPTION_CONTENTID_REQUIRED);
+ session.removeAttribute(USER_EXCEPTION_NUMBERFORMAT);
}
+ }
-
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java (.../ExportServlet.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java (.../ExportServlet.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -25,13 +25,10 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.TreeMap;
-import java.util.Map.Entry;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@@ -41,13 +38,10 @@
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.tool.ToolAccessMode;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.EditActivityDTO;
import org.lamsfoundation.lams.tool.vote.dto.ExportPortfolioDTO;
import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO;
import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -56,9 +50,6 @@
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
import org.lamsfoundation.lams.tool.vote.service.VoteApplicationException;
import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy;
-import org.lamsfoundation.lams.tool.vote.util.VoteComparator;
-import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
-import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.servlet.AbstractExportPortfolioServlet;
@@ -99,7 +90,7 @@
throw new VoteApplicationException(error);
}
- VoteSession voteSession = voteService.retrieveVoteSession(toolSessionID);
+ VoteSession voteSession = voteService.getSessionBySessionId(toolSessionID);
// If the learner hasn't voted yet, then they won't exist in the session.
// Yet we might be asked for their page, as the activity has been commenced.
@@ -148,7 +139,7 @@
throw new VoteApplicationException(error);
}
- VoteContent content = voteService.retrieveVote(toolContentID);
+ VoteContent content = voteService.getVoteContent(toolContentID);
if (content == null) {
String error = "Data is missing from the database. Unable to Continue";
ExportServlet.logger.error(error);
@@ -179,7 +170,7 @@
if (currentSessionId == null) {
sessions = (Set) voteContent.getVoteSessions();
} else {
- VoteSession voteSession = voteService.retrieveVoteSession(currentSessionId);
+ VoteSession voteSession = voteService.getSessionBySessionId(currentSessionId);
sessions.add(voteSession);
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java (.../LearningUtil.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/LearningUtil.java (.../LearningUtil.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -26,14 +26,13 @@
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
+import java.util.TimeZone;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
-import org.lamsfoundation.lams.learningdesign.DataFlowObject;
import org.lamsfoundation.lams.tool.SimpleURL;
import org.lamsfoundation.lams.tool.ToolOutput;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
@@ -44,8 +43,6 @@
import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
import org.lamsfoundation.lams.tool.vote.util.VoteComparator;
-import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
-import org.lamsfoundation.lams.tool.vote.web.form.VoteLearningForm;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
@@ -72,338 +69,241 @@
* collection of String display IDs to which to restrict the map (optional)
* @return Map of display id -> nomination text.
*/
- public static Map buildQuestionContentMap(HttpServletRequest request, IVoteService voteService,
+ public static Map buildQuestionMap(HttpServletRequest request, IVoteService voteService,
VoteContent voteContent, Collection checkedOptions) {
- Map mapQuestionsContent = new TreeMap(new VoteComparator());
- Set nominations = voteContent.getVoteQueContents();
- // should we add nominations from data flow from other activities?
+ Map mapQuestionsContent = new TreeMap(new VoteComparator());
+ Set questions = voteContent.getVoteQueContents();
+
+ // should we add questions from data flow from other activities?
if (Boolean.TRUE.equals(voteContent.getAssignedDataFlowObject())
&& (voteContent.getMaxExternalInputs() == null || voteContent.getExternalInputsAdded() == null || voteContent
.getExternalInputsAdded() < voteContent.getMaxExternalInputs())) {
// If we are using tool input, we need to get it now and
// create questions. Once they are created, they will be not altered, no matter if another learner gets to
// this point and the tool input changed
- createQuestionsFromToolInput(voteContent, voteService);
- nominations = voteContent.getVoteQueContents();
- }
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ long userId = toolUser.getUserID().longValue();
- Iterator contentIterator = nominations.iterator();
- while (contentIterator.hasNext()) {
- VoteQueContent voteQueContent = contentIterator.next();
- if (voteQueContent != null) {
- String displayOrder = (new Integer(voteQueContent.getDisplayOrder())).toString();
- if ((checkedOptions == null || checkedOptions.contains(displayOrder)) && !displayOrder.equals("0")) {
- /* add the question to the questions Map in the displayOrder */
- mapQuestionsContent.put(displayOrder.toString(), voteQueContent.getQuestion());
- }
- }
- }
+ // We get whatever the source tool provides us with and try to create questions out of it
+ ToolOutput toolInput = voteService
+ .getToolInput(voteContent.getVoteContentId(), new Long(userId).intValue());
- return mapQuestionsContent;
- }
-
- public static VoteQueUsr getUser(IVoteService voteService) {
- /* get back login user DTO */
- HttpSession ss = SessionManager.getSession();
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
- long userId = toolUser.getUserID().longValue();
- VoteQueUsr voteQueUsr = voteService.retrieveVoteQueUsr(userId);
- return voteQueUsr;
- }
-
- /**
- * creates a new vote record in the database
- *
- * @param request
- * @param voteQueUsr
- * @param mapGeneralCheckedOptionsContent
- * @param userEntry
- * @param voteSession
- */
- public static void createAttempt(IVoteService voteService, VoteQueUsr voteQueUsr,
- Map mapGeneralCheckedOptionsContent, String userEntry, VoteSession voteSession, Long toolContentUID) {
-
- Date attempTime = VoteUtils.getGMTDateTime();
- String timeZone = VoteUtils.getCurrentTimeZone();
-
- if (mapGeneralCheckedOptionsContent.size() == 0) {
- VoteQueContent localVoteQueContent = voteService.getToolDefaultQuestionContent(1);
- createIndividualOptions(voteService, localVoteQueContent, voteQueUsr, attempTime, timeZone, userEntry,
- voteSession);
-
- } else {
- if (toolContentUID != null) {
- Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator();
- while (itCheckedMap.hasNext()) {
- Map.Entry checkedPairs = (Map.Entry) itCheckedMap.next();
- Long questionDisplayOrder = new Long(checkedPairs.getKey().toString());
-
- VoteQueContent voteQueContent = voteService.getQuestionContentByDisplayOrder(questionDisplayOrder,
- toolContentUID);
- if (voteQueContent != null) {
- createIndividualOptions(voteService, voteQueContent, voteQueUsr, attempTime, timeZone,
- userEntry, voteSession);
+ Object value = toolInput.getValue().getComplex();
+ short inputsAdded = voteContent.getExternalInputsAdded() == null ? 0 : voteContent.getExternalInputsAdded();
+ Short maxInputs = voteContent.getMaxExternalInputs();
+ Set existingNominations = voteContent.getVoteQueContents();
+ // The input is an array (users) of arrays of strings (their answers)
+ if (value instanceof String[][]) {
+ if (value != null) {
+ String[][] usersAndAnswers = (String[][]) value;
+ int nominationIndex = voteContent.getVoteQueContents().size() + 1;
+ for (String[] userAnswers : usersAndAnswers) {
+ if (userAnswers != null) {
+ if (maxInputs != null && inputsAdded >= maxInputs) {
+ // if we reached the maximum number of inputs, i.e. number of students that will be
+ // taken
+ // into account
+ break;
+ }
+ boolean anyAnswersAdded = false;
+ for (String questionText : userAnswers) {
+ if (!StringUtils.isBlank(questionText)) {
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
+ nomination.setMcContent(voteContent);
+ nomination.setQuestion(questionText);
+ if (!nominationExists(nomination, existingNominations)) {
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
+ nominationIndex++;
+ anyAnswersAdded = true;
+ }
+ }
+ }
+ if (anyAnswersAdded) {
+ inputsAdded++;
+ }
+ }
}
}
- }
- }
+ } else if (value instanceof String[]) {
+ // the input is a list of strings (questions, for example)
+ int nominationIndex = voteContent.getVoteQueContents().size() + 1;
+ String[] userAnswers = (String[]) value;
+ for (String questionText : userAnswers) {
+ if (maxInputs != null && inputsAdded >= maxInputs) {
+ // if we reached the maximum number of inputs, i.e. number of students that will be taken
+ // into account
+ break;
+ }
- }
-
- public static void createIndividualOptions(IVoteService voteService, VoteQueContent voteQueContent,
- VoteQueUsr voteQueUsr, Date attempTime, String timeZone, String userEntry, VoteSession voteSession) {
-
- if (voteQueContent != null) {
- VoteUsrAttempt existingVoteUsrAttempt = voteService.getAttemptForUserAndQuestionContentAndSession(
- voteQueUsr.getQueUsrId(), voteQueContent.getVoteContentId(), voteSession.getUid());
-
- if (existingVoteUsrAttempt != null) {
- existingVoteUsrAttempt.setUserEntry(userEntry);
- existingVoteUsrAttempt.setAttemptTime(attempTime);
- existingVoteUsrAttempt.setTimeZone(timeZone);
- voteService.updateVoteUsrAttempt(existingVoteUsrAttempt);
- } else {
- VoteUsrAttempt voteUsrAttempt = new VoteUsrAttempt(attempTime, timeZone, voteQueContent, voteQueUsr,
- userEntry, true);
- voteService.createVoteUsrAttempt(voteUsrAttempt);
- }
- }
- }
-
- public static void readParameters(HttpServletRequest request, VoteLearningForm voteLearningForm) {
- String optionCheckBoxSelected = request.getParameter("optionCheckBoxSelected");
- if (optionCheckBoxSelected != null && optionCheckBoxSelected.equals("1")) {
- voteLearningForm.setOptionCheckBoxSelected("1");
- }
-
- String questionIndex = request.getParameter("questionIndex");
- if (questionIndex != null) {
- voteLearningForm.setQuestionIndex(questionIndex);
- }
-
- String optionIndex = request.getParameter("optionIndex");
- if (optionIndex != null) {
- voteLearningForm.setOptionIndex(optionIndex);
- }
-
- String optionValue = request.getParameter("optionValue");
- if (optionValue != null) {
- voteLearningForm.setOptionValue(optionValue);
- }
-
- String checked = request.getParameter("checked");
- if (checked != null) {
- voteLearningForm.setChecked(checked);
- }
- }
-
- public static Map selectOptionsCheckBox(HttpServletRequest request, VoteLearningForm voteLearningForm,
- String questionIndex, Map mapGeneralCheckedOptionsContent, Map mapQuestionContentLearner) {
-
- String selectedNomination = (String) mapQuestionContentLearner.get(voteLearningForm.getQuestionIndex());
-
- Map mapFinal = new TreeMap(new VoteComparator());
-
- if (mapGeneralCheckedOptionsContent.size() == 0) {
- Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator());
-
- if (voteLearningForm.getChecked().equals("true")) {
- mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination);
- } else {
- mapLeanerCheckedOptionsContent.remove(voteLearningForm.getQuestionIndex());
- }
-
- mapFinal = mapLeanerCheckedOptionsContent;
- } else {
- Map mapCurrentOptions = mapGeneralCheckedOptionsContent;
-
- if (mapCurrentOptions != null) {
- if (voteLearningForm.getChecked().equals("true")) {
- mapCurrentOptions.put(voteLearningForm.getQuestionIndex(), selectedNomination);
- } else {
- mapCurrentOptions.remove(voteLearningForm.getQuestionIndex());
+ if (!StringUtils.isBlank(questionText)) {
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
+ nomination.setMcContent(voteContent);
+ nomination.setQuestion(questionText);
+ if (!nominationExists(nomination, existingNominations)) {
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
+ nominationIndex++;
+ inputsAdded++;
+ }
+ }
}
-
- mapFinal = mapCurrentOptions;
- } else {
- //no options for this questions has been selected yet
- Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator());
-
- if (voteLearningForm.getChecked().equals("true")) {
- mapLeanerCheckedOptionsContent.put(voteLearningForm.getQuestionIndex(), selectedNomination);
- } else {
- mapLeanerCheckedOptionsContent.remove(voteLearningForm.getOptionIndex());
+ } else if (value instanceof String && !StringUtils.isBlank((String) value)) {
+ int nominationIndex = voteContent.getVoteQueContents().size() + 1;
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
+ nomination.setMcContent(voteContent);
+ nomination.setQuestion((String) value);
+ if (!nominationExists(nomination, existingNominations)) {
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
}
-
- mapFinal = mapLeanerCheckedOptionsContent;
}
- }
+ if (value instanceof SimpleURL[][]) {
+ if (value != null) {
+ SimpleURL[][] usersAndUrls = (SimpleURL[][]) value;
+ int nominationIndex = voteContent.getVoteQueContents().size() + 1;
+ for (SimpleURL[] userUrls : usersAndUrls) {
+ if (userUrls != null) {
+ if (maxInputs != null && inputsAdded >= maxInputs) {
+ // if we reached the maximum number of inputs, i.e. number of students that will be
+ // taken
+ // into account
+ break;
+ }
+ boolean anyAnswersAdded = false;
+ for (SimpleURL url : userUrls) {
+ if (url != null) {
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
+ nomination.setMcContent(voteContent);
- return mapFinal;
- }
-
- private static void createQuestionsFromToolInput(VoteContent voteContent, IVoteService voteService) {
-
- /* get back login user DTO */
- HttpSession ss = SessionManager.getSession();
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
- long userId = toolUser.getUserID().longValue();
-
- // We get whatever the source tool provides us with and try to create questions out of it
- ToolOutput toolInput = voteService.getToolInput(voteContent.getVoteContentId(), new Long(userId).intValue());
-
- Object value = toolInput.getValue().getComplex();
- short inputsAdded = voteContent.getExternalInputsAdded() == null ? 0 : voteContent.getExternalInputsAdded();
- Short maxInputs = voteContent.getMaxExternalInputs();
- Set existingNominations = voteContent.getVoteQueContents();
- // The input is an array (users) of arrays of strings (their answers)
- if (value instanceof String[][]) {
- if (value != null) {
- String[][] usersAndAnswers = (String[][]) value;
- int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- for (String[] userAnswers : usersAndAnswers) {
- if (userAnswers != null) {
- if (maxInputs != null && inputsAdded >= maxInputs) {
- // if we reached the maximum number of inputs, i.e. number of students that will be taken
- // into account
- break;
- }
- boolean anyAnswersAdded = false;
- for (String questionText : userAnswers) {
- if (!StringUtils.isBlank(questionText)) {
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
- nomination.setMcContent(voteContent);
- nomination.setQuestion(questionText);
- if (!nominationExists(nomination, existingNominations)) {
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
- nominationIndex++;
- anyAnswersAdded = true;
+ String link = "" + url.getNameToDisplay() + "";
+ nomination.setQuestion(link);
+ if (!nominationExists(nomination, existingNominations)) {
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
+ nominationIndex++;
+ anyAnswersAdded = true;
+ }
}
}
+ if (anyAnswersAdded) {
+ inputsAdded++;
+ }
}
- if (anyAnswersAdded) {
- inputsAdded++;
- }
}
}
}
- } else if (value instanceof String[]) {
- // the input is a list of strings (questions, for example)
- int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- String[] userAnswers = (String[]) value;
- for (String questionText : userAnswers) {
- if (maxInputs != null && inputsAdded >= maxInputs) {
- // if we reached the maximum number of inputs, i.e. number of students that will be taken
- // into account
- break;
- }
- if (!StringUtils.isBlank(questionText)) {
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
- nomination.setMcContent(voteContent);
- nomination.setQuestion(questionText);
- if (!nominationExists(nomination, existingNominations)) {
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
- nominationIndex++;
- inputsAdded++;
- }
- }
- }
- } else if (value instanceof String && !StringUtils.isBlank((String) value)) {
- int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
- nomination.setMcContent(voteContent);
- nomination.setQuestion((String) value);
- if (!nominationExists(nomination, existingNominations)) {
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
- }
- }
- if (value instanceof SimpleURL[][]) {
- if (value != null) {
- SimpleURL[][] usersAndUrls = (SimpleURL[][]) value;
+ else if (value instanceof SimpleURL[]) {
+ // the input is a list of strings (questions, for example)
int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- for (SimpleURL[] userUrls : usersAndUrls) {
- if (userUrls != null) {
- if (maxInputs != null && inputsAdded >= maxInputs) {
- // if we reached the maximum number of inputs, i.e. number of students that will be taken
- // into account
- break;
- }
- boolean anyAnswersAdded = false;
- for (SimpleURL url : userUrls) {
- if (url != null) {
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
- nomination.setMcContent(voteContent);
+ SimpleURL[] userUrls = (SimpleURL[]) value;
+ for (SimpleURL url : userUrls) {
+ if (maxInputs != null && inputsAdded >= maxInputs) {
+ // if we reached the maximum number of inputs, i.e. number of students that will be taken
+ // into account
+ break;
+ }
+ if (url != null) {
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
+ nomination.setMcContent(voteContent);
- String link = "" + url.getNameToDisplay() + "";
- nomination.setQuestion(link);
- if (!nominationExists(nomination, existingNominations)) {
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
- nominationIndex++;
- anyAnswersAdded = true;
- }
- }
- }
- if (anyAnswersAdded) {
+ String link = "" + url.getNameToDisplay() + "";
+ nomination.setQuestion(link);
+ if (!nominationExists(nomination, existingNominations)) {
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
+ nominationIndex++;
inputsAdded++;
}
}
}
- }
- }
+ } else if (value instanceof SimpleURL) {
+ int nominationIndex = voteContent.getVoteQueContents().size() + 1;
+ VoteQueContent nomination = new VoteQueContent();
+ nomination.setDisplayOrder(nominationIndex);
- else if (value instanceof SimpleURL[]) {
- // the input is a list of strings (questions, for example)
- int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- SimpleURL[] userUrls = (SimpleURL[]) value;
- for (SimpleURL url : userUrls) {
- if (maxInputs != null && inputsAdded >= maxInputs) {
- // if we reached the maximum number of inputs, i.e. number of students that will be taken
- // into account
- break;
- }
- if (url != null) {
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
+ SimpleURL url = (SimpleURL) value;
+ String link = "" + url.getNameToDisplay() + "";
+ nomination.setQuestion(link);
+ if (!nominationExists(nomination, existingNominations)) {
nomination.setMcContent(voteContent);
-
- String link = "" + url.getNameToDisplay() + "";
- nomination.setQuestion(link);
- if (!nominationExists(nomination, existingNominations)) {
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
- nominationIndex++;
- inputsAdded++;
- }
+ voteService.saveOrUpdateVoteQueContent(nomination);
+ voteContent.getVoteQueContents().add(nomination);
}
}
- } else if (value instanceof SimpleURL) {
- int nominationIndex = voteContent.getVoteQueContents().size() + 1;
- VoteQueContent nomination = new VoteQueContent();
- nomination.setDisplayOrder(nominationIndex);
- SimpleURL url = (SimpleURL) value;
- String link = "" + url.getNameToDisplay() + "";
- nomination.setQuestion(link);
- if (!nominationExists(nomination, existingNominations)) {
- nomination.setMcContent(voteContent);
- voteService.saveOrUpdateVoteQueContent(nomination);
- voteContent.getVoteQueContents().add(nomination);
+ voteContent.setExternalInputsAdded(inputsAdded);
+ voteService.saveVoteContent(voteContent);
+ questions = voteContent.getVoteQueContents();
+ }
+
+ for (VoteQueContent question : questions) {
+ String displayOrder = "" + question.getDisplayOrder();
+ if ((checkedOptions == null || checkedOptions.contains(displayOrder)) && !displayOrder.equals("0")) {
+ /* add the question to the questions Map in the displayOrder */
+ mapQuestionsContent.put(displayOrder.toString(), question.getQuestion());
}
}
- voteContent.setExternalInputsAdded(inputsAdded);
- voteService.saveVoteContent(voteContent);
+ return mapQuestionsContent;
}
+ /**
+ * creates a new vote record in the database
+ */
+ public static void createAttempt(IVoteService voteService, VoteQueUsr voteQueUsr,
+ Map mapGeneralCheckedOptionsContent, String userEntry, VoteSession voteSession, Long voteContentUid) {
+
+ Date attempTime = new Date(System.currentTimeMillis());
+ String timeZone = TimeZone.getDefault().getDisplayName();
+
+ //in case of free entry
+ if (mapGeneralCheckedOptionsContent.size() == 0) {
+ VoteQueContent defaultContentFirstQuestion = voteService.getDefaultVoteContentFirstQuestion();
+ createAttempt(voteService, defaultContentFirstQuestion, voteQueUsr, attempTime, timeZone, userEntry,
+ voteSession);
+
+ //if the question is selected
+ } else if (voteContentUid != null) {
+ Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator();
+ while (itCheckedMap.hasNext()) {
+ Map.Entry checkedPairs = (Map.Entry) itCheckedMap.next();
+ Long questionDisplayOrder = new Long(checkedPairs.getKey().toString());
+
+ VoteQueContent question = voteService.getQuestionByDisplayOrder(questionDisplayOrder, voteContentUid);
+ createAttempt(voteService, question, voteQueUsr, attempTime, timeZone, userEntry, voteSession);
+ }
+ }
+
+ }
+
+ public static void createAttempt(IVoteService voteService, VoteQueContent question,
+ VoteQueUsr user, Date attempTime, String timeZone, String userEntry, VoteSession session) {
+
+ if (question != null) {
+ VoteUsrAttempt existingAttempt = voteService.getAttemptForUserAndQuestionContentAndSession(
+ user.getQueUsrId(), question.getVoteContentId(), session.getUid());
+
+ if (existingAttempt != null) {
+ existingAttempt.setUserEntry(userEntry);
+ existingAttempt.setAttemptTime(attempTime);
+ existingAttempt.setTimeZone(timeZone);
+ voteService.updateVoteUsrAttempt(existingAttempt);
+ } else {
+ VoteUsrAttempt voteUsrAttempt = new VoteUsrAttempt(attempTime, timeZone, question, user,
+ userEntry, true);
+ voteService.createVoteUsrAttempt(voteUsrAttempt);
+ }
+ }
+ }
+
private static boolean nominationExists(VoteQueContent nomination, Set existingNominations) {
if (existingNominations != null && nomination != null) {
for (VoteQueContent existingNomination : existingNominations) {
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -22,76 +22,26 @@
package org.lamsfoundation.lams.tool.vote.web;
-import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TimeZone;
import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import org.lamsfoundation.lams.notebook.model.NotebookEntry;
-import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteAllGroupsDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO;
-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;
-import org.lamsfoundation.lams.tool.vote.service.IVoteService;
import org.lamsfoundation.lams.tool.vote.util.VoteComparator;
-import org.lamsfoundation.lams.tool.vote.util.VoteStringComparator;
-import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
import org.lamsfoundation.lams.tool.vote.web.form.VoteMonitoringForm;
-import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
-import org.lamsfoundation.lams.util.DateUtil;
-import org.lamsfoundation.lams.util.MessageService;
-import org.lamsfoundation.lams.web.session.SessionManager;
-import org.lamsfoundation.lams.web.util.AttributeNames;
/**
- *
- *
* More generic monitoring mode functions live here
- *
*
* @author Ozgur Demirtas
- *
*/
public class MonitoringUtil implements VoteAppConstants {
- public static Map populateToolSessionsId(VoteContent voteContent, IVoteService voteService) {
- List sessionIds = voteService.getSessionsFromContent(voteContent);
-
- Map sessionsMap = new TreeMap(new VoteComparator());
- int mapIndex = 1;
- for (Long sessionId : sessionIds) {
- sessionsMap.put("" + mapIndex, sessionId.toString());
- mapIndex++;
- }
-
- if (sessionsMap.isEmpty()) {
- sessionsMap.put(new Long(1).toString(), "None");
- } else {
- sessionsMap.put(new Long(sessionsMap.size() + 1).toString(), "All");
- }
-
- return sessionsMap;
- }
-
public static Map convertToVoteMonitoredUserDTOMap(List list) {
Map map = new TreeMap(new VoteComparator());
@@ -107,119 +57,19 @@
return map;
}
- public static Map convertToMap(List list) {
- Map map = new TreeMap(new VoteComparator());
-
- Iterator listIterator = list.iterator();
- Long mapIndex = new Long(1);
-
- while (listIterator.hasNext()) {
- Map data = (Map) listIterator.next();
- map.put(mapIndex.toString(), data);
- mapIndex = new Long(mapIndex.longValue() + 1);
- }
- return map;
- }
-
- public static boolean notebookEntriesExist(IVoteService voteService, VoteContent voteContent) {
- Iterator iteratorSession = voteContent.getVoteSessions().iterator();
- while (iteratorSession.hasNext()) {
- VoteSession voteSession = iteratorSession.next();
-
- if (voteSession != null) {
-
- Iterator iteratorUser = voteSession.getVoteQueUsers().iterator();
- while (iteratorUser.hasNext()) {
- VoteQueUsr voteQueUsr = (VoteQueUsr) iteratorUser.next();
-
- if (voteQueUsr != null) {
- NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(),
- CoreNotebookConstants.NOTEBOOK_TOOL, MY_SIGNATURE, new Integer(voteQueUsr.getQueUsrId()
- .intValue()));
-
- if (notebookEntry != null) {
- return true;
- }
-
- }
- }
- }
- }
- return false;
- }
-
- public static void buildVoteStatsDTO(HttpServletRequest request, IVoteService voteService, VoteContent voteContent) {
-
- int countSessionComplete = 0;
- int countAllUsers = 0;
- Iterator iteratorSession = voteContent.getVoteSessions().iterator();
- while (iteratorSession.hasNext()) {
- VoteSession voteSession = (VoteSession) iteratorSession.next();
-
- if (voteSession != null) {
- if (voteSession.getSessionStatus().equals(COMPLETED)) {
- ++countSessionComplete;
- }
-
- Iterator iteratorUser = voteSession.getVoteQueUsers().iterator();
- while (iteratorUser.hasNext()) {
- VoteQueUsr voteQueUsr = (VoteQueUsr) iteratorUser.next();
- if (voteQueUsr != null) {
- ++countAllUsers;
- }
- }
- }
- }
-
- VoteStatsDTO voteStatsDTO = new VoteStatsDTO();
- voteStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString());
- voteStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString());
- request.setAttribute(VOTE_STATS_DTO, voteStatsDTO);
-
- // setting up the advanced summary for LDEV-1662
- request.setAttribute("useSelectLeaderToolOuput", voteContent.isUseSelectLeaderToolOuput());
- request.setAttribute("lockOnFinish", voteContent.isLockOnFinish());
- request.setAttribute("allowText", voteContent.isAllowText());
- request.setAttribute("maxNominationCount", voteContent.getMaxNominationCount());
- request.setAttribute("minNominationCount", voteContent.getMinNominationCount());
- request.setAttribute("showResults", voteContent.isShowResults());
- request.setAttribute("reflect", voteContent.isReflect());
- request.setAttribute("reflectionSubject", voteContent.getReflectionSubject());
- request.setAttribute("toolContentID", voteContent.getVoteContentId());
-
- // setting up the SubmissionDeadline
- if (voteContent.getSubmissionDeadline() != null) {
- Date submissionDeadline = voteContent.getSubmissionDeadline();
- HttpSession ss = SessionManager.getSession();
- UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER);
- TimeZone teacherTimeZone = teacher.getTimeZone();
- Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline);
- request.setAttribute(VoteAppConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime());
- }
- }
-
public static void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm,
VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) {
String toolContentID = request.getParameter(VoteAppConstants.TOOL_CONTENT_ID);
voteMonitoringForm.setToolContentID(toolContentID);
voteGeneralMonitoringDTO.setToolContentID(toolContentID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
- voteMonitoringForm.setActiveModule(activeModule);
- voteGeneralMonitoringDTO.setActiveModule(activeModule);
-
- String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE);
- voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode);
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(defineLaterInEditMode);
-
String responseId = request.getParameter(VoteAppConstants.RESPONSE_ID);
voteMonitoringForm.setResponseId(responseId);
voteGeneralMonitoringDTO.setResponseId(responseId);
String currentUid = request.getParameter(VoteAppConstants.CURRENT_UID);
voteMonitoringForm.setCurrentUid(currentUid);
- voteGeneralMonitoringDTO.setCurrentUid(currentUid);
}
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -28,24 +28,25 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.lamsfoundation.lams.authoring.web.AuthoringConstants;
import org.lamsfoundation.lams.learningdesign.DataFlowObject;
-import org.lamsfoundation.lams.tool.exception.ToolException;
+import org.lamsfoundation.lams.tool.ToolAccessMode;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralAuthoringDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteNominationContentDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
@@ -61,7 +62,7 @@
* @author Ozgur Demirtas
*/
public class VoteAction extends LamsDispatchAction implements VoteAppConstants {
- static Logger logger = Logger.getLogger(VoteAction.class.getName());
+ private static Logger logger = Logger.getLogger(VoteAction.class.getName());
/**
*
@@ -77,93 +78,20 @@
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- SessionMap sessionMap = new SessionMap();
- VoteUtils.saveRichText(request, voteGeneralAuthoringDTO, sessionMap);
- voteAuthoringForm.resetUserAction();
- return null;
- }
+
+ String richTextTitle = request.getParameter(TITLE);
+ String richTextInstructions = request.getParameter(INSTRUCTIONS);
- /**
- * used in define later mode to switch from view-only to editable screen
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- * @throws ToolException
- */
- public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException, ToolException {
-
- VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
- voteAuthoringForm.setHttpSessionID(httpSessionID);
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = VoteAppConstants.DEFINE_LATER;
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
-
- voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle());
- voteAuthoringForm.setTitle(voteContent.getTitle());
-
- voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions());
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteContent.getTitle());
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions());
-
- voteAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString());
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- VoteUtils.setDefineLater(request, true, strToolContentID, voteService);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setCurrentTab("1");
-
- List listNominationContentDTO = new LinkedList();
-
- Iterator queIterator = voteContent.getVoteQueContents().iterator();
- while (queIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO();
-
- VoteQueContent voteQueContent = (VoteQueContent) queIterator.next();
- if (voteQueContent != null) {
-
- voteNominationContentDTO.setQuestion(voteQueContent.getQuestion());
- voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString());
- // voteNominationContentDTO.setFeedback(voteQueContent.getFeedback());
- listNominationContentDTO.add(voteNominationContentDTO);
- }
+ if (richTextTitle != null) {
+ voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
}
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
+ if (richTextInstructions != null) {
+ voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
+ }
+
+ voteAuthoringForm.resetUserAction();
+ return null;
}
/**
@@ -180,18 +108,10 @@
voteAuthoringForm.setToolContentID(toolContentID);
voteGeneralAuthoringDTO.setToolContentID(toolContentID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
- voteAuthoringForm.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
-
String httpSessionID = request.getParameter(VoteAppConstants.HTTP_SESSION_ID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE);
- voteAuthoringForm.setDefineLaterInEditMode(defineLaterInEditMode);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode);
-
String lockOnFinish = request.getParameter(VoteAppConstants.LOCK_ON_FINISH);
voteAuthoringForm.setLockOnFinish(lockOnFinish);
voteGeneralAuthoringDTO.setLockOnFinish(lockOnFinish);
@@ -229,55 +149,33 @@
maxInputs = "0";
}
voteAuthoringForm.setMaxInputs(new Short(maxInputs));
+
+ ToolAccessMode mode = getAccessMode(request);
+ request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());
}
/**
- * persists error messages to request scope
- *
- * @param request
- * @param message
- */
- public void persistInRequestError(HttpServletRequest request, String message) {
- ActionMessages errors = new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage(message));
- saveErrors(request, errors);
- }
-
- /**
- * moveNominationDown
- *
* moves a nomination down in the authoring list
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String questionIndex = request.getParameter("questionIndex");
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down");
- listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ questionDTOs = AuthoringUtil.swapQuestions(questionDTOs, questionIndex, "down");
+
+ questionDTOs = AuthoringUtil.reorderQuestionDTOs(questionDTOs);
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
@@ -297,65 +195,44 @@
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
request.getSession().setAttribute(httpSessionID, sessionMap);
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
/**
- * moveNominationUp
- *
* moves a nomination up in the authoring list
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String questionIndex = request.getParameter("questionIndex");
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up");
+ questionDTOs = AuthoringUtil.swapQuestions(questionDTOs, questionIndex, "up");
- listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO);
+ questionDTOs = AuthoringUtil.reorderQuestionDTOs(questionDTOs);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
@@ -375,75 +252,59 @@
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
request.getSession().setAttribute(httpSessionID, sessionMap);
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
/**
- * removeNomination
- *
* removes a nomination from the authoring list
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
- String questionIndex = request.getParameter("questionIndex");
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
+ String questionIndexToDelete = request.getParameter("questionIndex");
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
+ List listFinalQuestionDTO = new LinkedList();
+ int queIndex = 0;
+ for (VoteQuestionDTO questionDTO : questionDTOs) {
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
+ String questionText = questionDTO.getNomination();
+ String displayOrder = questionDTO.getDisplayOrder();
- if (displayOrder != null && !displayOrder.equals("")) {
- if (displayOrder.equals(questionIndex)) {
- break;
- }
-
+ if (questionText != null && !questionText.equals("") && (!displayOrder.equals(questionIndexToDelete))) {
+
+ ++queIndex;
+ questionDTO.setDisplayOrder(new Integer(queIndex).toString());
+ listFinalQuestionDTO.add(questionDTO);
}
+ if ((questionText != null) && (!questionText.isEmpty()) && displayOrder.equals(questionIndexToDelete)) {
+ List deletedQuestionDTOs = (List) sessionMap.get(LIST_DELETED_QUESTION_DTOS);;
+ deletedQuestionDTOs.add(questionDTO);
+ sessionMap.put(LIST_DELETED_QUESTION_DTOS, deletedQuestionDTOs);
+ }
}
- voteNominationContentDTO.setNomination("");
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, listFinalQuestionDTO);
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, listFinalQuestionDTO);
- listNominationContentDTO = AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO,
- questionIndex);
-
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
@@ -462,69 +323,46 @@
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
request.getSession().setAttribute(httpSessionID, sessionMap);
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
/**
- * newEditableNominationBox
- *
* enables editing a nomination
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String questionIndex = request.getParameter("questionIndex");
voteAuthoringForm.setEditableNominationIndex(questionIndex);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
String editableNomination = "";
- String editableFeedback = "";
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
- String question = voteNominationContentDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ VoteQuestionDTO voteQuestionDTO = (VoteQuestionDTO) iter.next();
+ String question = voteQuestionDTO.getNomination();
+ String displayOrder = voteQuestionDTO.getDisplayOrder();
if (displayOrder != null && !displayOrder.equals("")) {
if (displayOrder.equals(questionIndex)) {
- editableFeedback = voteNominationContentDTO.getFeedback();
- editableNomination = voteNominationContentDTO.getNomination();
+ editableNomination = voteQuestionDTO.getNomination();
break;
}
@@ -533,7 +371,6 @@
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
@@ -547,44 +384,26 @@
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
voteGeneralAuthoringDTO.setEditableNominationText(editableNomination);
- voteGeneralAuthoringDTO.setEditableNominationFeedback(editableFeedback);
- voteAuthoringForm.setFeedback(editableFeedback);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
return mapping.findForward("editNominationBox");
}
/**
- * newNominationBox
- *
* enables adding a new nomination
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
@@ -598,28 +417,13 @@
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
return mapping.findForward("newNominationBox");
}
/**
- * addSingleNomination
- *
* enables adding a new nomination to the authoring nominations list
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
@@ -629,45 +433,37 @@
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- AuthoringUtil authoringUtil = new AuthoringUtil();
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
String newNomination = request.getParameter("newNomination");
- String feedback = request.getParameter("feedback");
+ int listSize = questionDTOs.size();
- int listSize = listNominationContentDTO.size();
-
if (newNomination != null && newNomination.length() > 0) {
- boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination);
+ boolean duplicates = AuthoringUtil.checkDuplicateNominations(questionDTOs, newNomination);
if (!duplicates) {
- VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO();
- voteNominationContentDTO.setDisplayOrder(new Long(listSize + 1).toString());
- voteNominationContentDTO.setFeedback(feedback);
- voteNominationContentDTO.setNomination(newNomination);
+ VoteQuestionDTO voteQuestionDTO = new VoteQuestionDTO();
+ voteQuestionDTO.setDisplayOrder(new Long(listSize + 1).toString());
+ voteQuestionDTO.setNomination(newNomination);
- listNominationContentDTO.add(voteNominationContentDTO);
+ questionDTOs.add(voteQuestionDTO);
}
}
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
String richTextTitle = (String) sessionMap.get(VoteAppConstants.ACTIVITY_TITLE_KEY);
String richTextInstructions = (String) sessionMap.get(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY);
@@ -676,90 +472,65 @@
voteAuthoringForm.setTitle(richTextTitle);
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
request.getSession().setAttribute(httpSessionID, sessionMap);
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
request.getSession().setAttribute(httpSessionID, sessionMap);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
/**
- * saveSingleNomination saves a new or updated nomination in the authoring nominations list
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
+ * saves a new or updated nomination in the authoring nominations list
*/
public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
String editNominationBoxRequest = request.getParameter("editNominationBoxRequest");
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- AuthoringUtil authoringUtil = new AuthoringUtil();
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
String newNomination = request.getParameter("newNomination");
- String feedback = request.getParameter("feedback");
-
String editableNominationIndex = request.getParameter("editableNominationIndex");
if (newNomination != null && newNomination.length() > 0) {
if (editNominationBoxRequest != null && editNominationBoxRequest.equals("false")) {
- boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination);
+ boolean duplicates = AuthoringUtil.checkDuplicateNominations(questionDTOs, newNomination);
if (!duplicates) {
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
+ VoteQuestionDTO voteQuestionDTO = null;
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ voteQuestionDTO = (VoteQuestionDTO) iter.next();
- String question = voteNominationContentDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
+ String question = voteQuestionDTO.getNomination();
+ String displayOrder = voteQuestionDTO.getDisplayOrder();
if (displayOrder != null && !displayOrder.equals("")) {
if (displayOrder.equals(editableNominationIndex)) {
@@ -769,24 +540,23 @@
}
}
- voteNominationContentDTO.setQuestion(newNomination);
- voteNominationContentDTO.setFeedback(feedback);
- voteNominationContentDTO.setDisplayOrder(editableNominationIndex);
+ voteQuestionDTO.setQuestion(newNomination);
+ voteQuestionDTO.setDisplayOrder(editableNominationIndex);
- listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO(
- listNominationContentDTO, voteNominationContentDTO, editableNominationIndex);
+ questionDTOs = AuthoringUtil.reorderUpdateListQuestionDTO(
+ questionDTOs, voteQuestionDTO, editableNominationIndex);
} else {
//duplicate question entry, not adding
}
} else {
//request for edit and save
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
+ VoteQuestionDTO voteQuestionDTO = null;
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ voteQuestionDTO = (VoteQuestionDTO) iter.next();
- String question = voteNominationContentDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
+ String question = voteQuestionDTO.getNomination();
+ String displayOrder = voteQuestionDTO.getDisplayOrder();
if (displayOrder != null && !displayOrder.equals("")) {
if (displayOrder.equals(editableNominationIndex)) {
@@ -796,19 +566,18 @@
}
}
- voteNominationContentDTO.setNomination(newNomination);
- voteNominationContentDTO.setFeedback(feedback);
- voteNominationContentDTO.setDisplayOrder(editableNominationIndex);
+ voteQuestionDTO.setNomination(newNomination);
+ voteQuestionDTO.setDisplayOrder(editableNominationIndex);
- listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO(
- listNominationContentDTO, voteNominationContentDTO, editableNominationIndex);
+ questionDTOs = AuthoringUtil.reorderUpdateListQuestionDTO(
+ questionDTOs, voteQuestionDTO, editableNominationIndex);
}
} else {
//entry blank, not adding
}
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
String richTextTitle = (String) sessionMap.get(VoteAppConstants.ACTIVITY_TITLE_KEY);
String richTextInstructions = (String) sessionMap.get(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY);
@@ -817,43 +586,24 @@
voteAuthoringForm.setTitle(richTextTitle);
voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
-
request.getSession().setAttribute(httpSessionID, sessionMap);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
request.getSession().setAttribute(httpSessionID, sessionMap);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
/**
- * submitAllContent
- *
* persists the nominations list and other user selections in the db.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
*/
public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
@@ -864,88 +614,89 @@
String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
voteAuthoringForm.setContentFolderID(contentFolderID);
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
+ List questionDTOs = (List) sessionMap.get(VoteAppConstants.LIST_QUESTION_DTO);
- Map mapNominationContent = AuthoringUtil.extractMapNominationContent(listNominationContentDTO);
-
- Map mapFeedback = AuthoringUtil.extractMapFeedback(listNominationContentDTO);
-
ActionMessages errors = new ActionMessages();
-
- if (mapNominationContent.size() == 0
+ if (questionDTOs.isEmpty()
&& (voteAuthoringForm.getAssignedDataFlowObject() == null || voteAuthoringForm
.getAssignedDataFlowObject() == 0)) {
ActionMessage error = new ActionMessage("nominations.none.submitted");
errors.add(ActionMessages.GLOBAL_MESSAGE, error);
}
String maxNomCount = voteAuthoringForm.getMaxNominationCount();
+ if (maxNomCount != null) {
+ if (maxNomCount.equals("0") || maxNomCount.contains("-")) {
+ ActionMessage error = new ActionMessage("maxNomination.invalid");
+ errors.add(ActionMessages.GLOBAL_MESSAGE, error);
+ }
- if (activeModule != null) {
- if (activeModule.equals(VoteAppConstants.AUTHORING)) {
- if (maxNomCount != null) {
- if (maxNomCount.equals("0") || maxNomCount.contains("-")) {
- ActionMessage error = new ActionMessage("maxNomination.invalid");
- errors.add(ActionMessages.GLOBAL_MESSAGE, error);
+ try {
+ int intMaxNomCount = new Integer(maxNomCount).intValue();
+ } catch (NumberFormatException e) {
+ ActionMessage error = new ActionMessage("maxNomination.invalid");
+ errors.add(ActionMessages.GLOBAL_MESSAGE, error);
+ }
+ }
+
+ //verifyDuplicateNominations
+ Map mapQuestion = AuthoringUtil.extractMapQuestion(questionDTOs);
+ int optionCount = 0;
+ boolean isNominationsDuplicate = false;
+ for (long i = 1; i <= VoteAppConstants.MAX_OPTION_COUNT; i++) {
+ String currentOption = (String) mapQuestion.get(new Long(i).toString());
+
+ optionCount = 0;
+ for (long j = 1; j <= VoteAppConstants.MAX_OPTION_COUNT; j++) {
+ String backedOption = (String) mapQuestion.get(new Long(j).toString());
+
+ if (currentOption != null && backedOption != null) {
+ if (currentOption.equals(backedOption)) {
+ optionCount++;
}
- try {
- int intMaxNomCount = new Integer(maxNomCount).intValue();
- } catch (NumberFormatException e) {
- ActionMessage error = new ActionMessage("maxNomination.invalid");
- errors.add(ActionMessages.GLOBAL_MESSAGE, error);
+ if (optionCount > 1) {
+ isNominationsDuplicate = true;
}
}
}
}
- boolean nominationsDuplicate = AuthoringUtil.verifyDuplicateNominations(mapNominationContent);
-
- if (nominationsDuplicate == true) {
+ if (isNominationsDuplicate == true) {
ActionMessage error = new ActionMessage("nominations.duplicate");
errors.add(ActionMessages.GLOBAL_MESSAGE, error);
}
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
DataFlowObject assignedDataFlowObject = null;
- if (activeModule.equals(VoteAppConstants.AUTHORING)) {
-
- List dataFlowObjects = voteService.getDataFlowObjects(new Long(strToolContentID));
- List dataFlowObjectNames = null;
- if (dataFlowObjects != null) {
- dataFlowObjectNames = new ArrayList(dataFlowObjects.size());
- int objectIndex = 1;
- for (DataFlowObject dataFlowObject : dataFlowObjects) {
- dataFlowObjectNames.add(dataFlowObject.getDisplayName());
- if (VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID.equals(dataFlowObject.getToolAssigmentId())) {
- voteAuthoringForm.setAssignedDataFlowObject(objectIndex);
- }
- objectIndex++;
-
+ List dataFlowObjects = voteService.getDataFlowObjects(new Long(strToolContentID));
+ List dataFlowObjectNames = null;
+ if (dataFlowObjects != null) {
+ dataFlowObjectNames = new ArrayList(dataFlowObjects.size());
+ int objectIndex = 1;
+ for (DataFlowObject dataFlowObject : dataFlowObjects) {
+ dataFlowObjectNames.add(dataFlowObject.getDisplayName());
+ if (VoteAppConstants.DATA_FLOW_OBJECT_ASSIGMENT_ID.equals(dataFlowObject.getToolAssigmentId())) {
+ voteAuthoringForm.setAssignedDataFlowObject(objectIndex);
}
+ objectIndex++;
}
+ }
+ voteGeneralAuthoringDTO.setDataFlowObjectNames(dataFlowObjectNames);
- voteGeneralAuthoringDTO.setDataFlowObjectNames(dataFlowObjectNames);
-
- if (voteAuthoringForm.getAssignedDataFlowObject() != null
- && voteAuthoringForm.getAssignedDataFlowObject() != 0) {
- assignedDataFlowObject = dataFlowObjects.get(voteAuthoringForm.getAssignedDataFlowObject() - 1);
- }
+ if (voteAuthoringForm.getAssignedDataFlowObject() != null && voteAuthoringForm.getAssignedDataFlowObject() != 0) {
+ assignedDataFlowObject = dataFlowObjects.get(voteAuthoringForm.getAssignedDataFlowObject() - 1);
}
voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
@@ -961,78 +712,104 @@
sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
- voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent);
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- VoteContent voteContentTest = voteService.retrieveVote(new Long(strToolContentID));
+ VoteContent voteContentTest = voteService.getVoteContent(new Long(strToolContentID));
if (!errors.isEmpty()) {
saveErrors(request, errors);
VoteAction.logger.error("errors saved: " + errors);
}
- VoteContent voteContent = voteContentTest;
if (errors.isEmpty()) {
- /* to remove deleted entries in the questions table based on mapNominationContent */
- authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request,
- strToolContentID);
+ ToolAccessMode mode = getAccessMode(request);
+ request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());
- voteContent = authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService,
- voteAuthoringForm, request, voteContentTest, strToolContentID, assignedDataFlowObject);
+ List deletedQuestionDTOs = (List) sessionMap.get(LIST_DELETED_QUESTION_DTOS);
- long defaultContentID = 0;
- defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
-
- if (voteContent != null) {
- voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString());
+ // in case request is from monitoring module - recalculate User Answers
+ if (mode.isTeacher()) {
+ Set oldQuestions = voteContentTest.getVoteQueContents();
+ voteService.removeQuestionsFromCache(voteContentTest);
+ VoteUtils.setDefineLater(request, false, strToolContentID, voteService);
+
+ // recalculate User Answers
+ voteService.recalculateUserAnswers(voteContentTest, oldQuestions, questionDTOs, deletedQuestionDTOs);
}
+
+ // remove deleted questions
+ for (VoteQuestionDTO deletedQuestionDTO : deletedQuestionDTOs) {
+ VoteQueContent removeableQuestion = voteService.getVoteQueContentByUID(deletedQuestionDTO.getUid());
+ if (removeableQuestion != null) {
+// Set attempts = removeableQuestion.getMcUsrAttempts();
+// Iterator iter = attempts.iterator();
+// while (iter.hasNext()) {
+// McUsrAttempt attempt = iter.next();
+// iter.remove();
+// }
+// mcService.updateQuestion(removeableQuestion);
+ voteContentTest.getVoteQueContents().remove(removeableQuestion);
+ voteService.removeVoteQueContent(removeableQuestion);
+ }
+ }
- authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent);
+ // store content
+ VoteContent voteContent = AuthoringUtil.saveOrUpdateVoteContent(voteService, voteAuthoringForm, request,
+ voteContentTest, strToolContentID);
- VoteUtils.setDefineLater(request, false, strToolContentID, voteService);
+ //store questions
+ voteContent = AuthoringUtil.createQuestions(questionDTOs, voteService, voteContent);
- if (activeModule.equals(VoteAppConstants.AUTHORING)) {
- //standard authoring close
- request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
- } else {
- //go back to view only screen
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString());
- }
+ //store DataFlowObjectAssigment
+ voteService.saveDataFlowObjectAssigment(assignedDataFlowObject);
- } else {
+ //reOrganizeDisplayOrder
+ List sortedQuestions = voteService.getAllQuestionsSorted(voteContent.getUid().longValue());
+ Iterator iter = sortedQuestions.iterator();
+ while (iter.hasNext()) {
+ VoteQueContent question = (VoteQueContent) iter.next();
- if (voteContent != null) {
- long defaultContentID = 0;
- defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
+ VoteQueContent existingQuestion = voteService.getQuestionByUid(question.getUid());
+ voteService.saveOrUpdateVoteQueContent(existingQuestion);
+ }
- if (voteContent != null) {
- voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString());
- }
+ // standard authoring close
+ request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE);
- }
}
voteAuthoringForm.resetUserAction();
- voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent);
request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
+ sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, questionDTOs);
request.getSession().setAttribute(httpSessionID, sessionMap);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
voteAuthoringForm.setToolContentID(strToolContentID);
voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
voteAuthoringForm.setCurrentTab("1");
return mapping.findForward(VoteAppConstants.LOAD_QUESTIONS);
}
+
+ /**
+ * Get ToolAccessMode from HttpRequest parameters. Default value is AUTHOR mode.
+ *
+ * @param request
+ * @return
+ */
+ private ToolAccessMode getAccessMode(HttpServletRequest request) {
+ ToolAccessMode mode;
+ String modeStr = request.getParameter(AttributeNames.ATTR_MODE);
+ if (StringUtils.equalsIgnoreCase(modeStr, ToolAccessMode.TEACHER.toString())) {
+ mode = ToolAccessMode.TEACHER;
+ } else {
+ mode = ToolAccessMode.AUTHOR;
+ }
+ return mode;
+ }
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java (.../VoteChartGeneratorAction.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteChartGeneratorAction.java (.../VoteChartGeneratorAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -25,7 +25,6 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -37,16 +36,13 @@
import org.apache.struts.action.ActionMapping;
import org.apache.tomcat.util.json.JSONException;
import org.apache.tomcat.util.json.JSONObject;
-import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteSession;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy;
import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
-import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
import org.lamsfoundation.lams.web.util.AttributeNames;
@@ -89,7 +85,7 @@
//sessionId should not be blank
} else if (!StringUtils.isBlank(currentSessionId)) {
- VoteSession voteSession = getVoteService().retrieveVoteSession(new Long(currentSessionId));
+ VoteSession voteSession = getVoteService().getSessionBySessionId(new Long(currentSessionId));
VoteContent voteContent = voteSession.getVoteContent();
VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = getVoteService().prepareChartData(request,
Fisheye: Tag 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a refers to a dead (removed) revision in file `lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteDLStarterAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java
===================================================================
diff -u -r43437f9c52f60b4fe545162b3ed72e6ddf911777 -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision 43437f9c52f60b4fe545162b3ed72e6ddf911777)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java (.../VoteLearningAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -29,7 +29,6 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -52,7 +51,6 @@
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -120,16 +118,14 @@
String userID = request.getParameter(USER_ID);
voteLearningForm.setUserID(userID);
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
VoteContent voteContent = voteSession.getVoteContent();
voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
Long toolContentID = voteContent.getVoteContentId();
- setContentInUse(request, voteService, toolContentID);
-
Long toolSessionUid = voteSession.getUid();
VoteQueUsr existingVoteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
@@ -185,17 +181,18 @@
String revisitingUser = request.getParameter(REVISITING_USER);
voteLearningForm.setRevisitingUser(revisitingUser);
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
VoteContent voteContent = voteSession.getVoteContent();
voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
- Long toolContentID = voteContent.getVoteContentId();
- setContentInUse(request, voteService, toolContentID);
-
if (revisitingUser.equals("true")) {
- VoteQueUsr voteQueUsr = LearningUtil.getUser(voteService);
+ /* get back login user DTO */
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ long userId = toolUser.getUserID().longValue();
+ VoteQueUsr voteQueUsr = voteService.getUserByUserId(userId);
List attempts = voteService.getAttemptsForUser(voteQueUsr.getUid());
@@ -251,14 +248,11 @@
voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
voteGeneralLearnerFlowDTO.setMinNominationCountReached(new Boolean(false).toString());
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
VoteContent voteContent = voteSession.getVoteContent();
voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
- Long toolContentID = voteContent.getVoteContentId();
- setContentInUse(request, voteService, toolContentID);
-
voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
//String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject());
@@ -289,7 +283,7 @@
String toolSessionID = request.getParameter(TOOL_SESSION_ID);
voteLearningForm.setToolSessionID(toolSessionID);
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
String userID = request.getParameter(USER_ID);
voteLearningForm.setUserID(userID);
@@ -316,7 +310,7 @@
request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
String nextUrl = null;
try {
@@ -371,7 +365,7 @@
String userEntry = request.getParameter(USER_ENTRY);
voteLearningForm.setUserEntry(userEntry);
- VoteSession session = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession session = voteService.getSessionBySessionId(new Long(toolSessionID));
voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
voteLearningForm.setMinNominationCountReached(new Boolean(false).toString());
@@ -405,11 +399,8 @@
voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
Long toolContentID = voteContent.getVoteContentId();
+ Long voteContentUid = voteContent.getUid();
- Long toolContentUID = voteContent.getUid();
-
- setContentInUse(request, voteService, toolContentID);
-
boolean userEntryAvailable = false;
if ((userEntry != null) && (userEntry.length() > 0)) {
userEntryAvailable = true;
@@ -426,20 +417,20 @@
voteService.removeAttemptsForUserandSession(user.getUid(), session.getUid());
/* to minimize changes to working code, convert the String[] array to the mapGeneralCheckedOptionsContent structure */
- Map mapGeneralCheckedOptionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent,
+ Map mapGeneralCheckedOptionsContent = LearningUtil.buildQuestionMap(request, voteService, voteContent,
voteDisplayOrderIds);
if (mapGeneralCheckedOptionsContent.size() > 0) {
LearningUtil.createAttempt(voteService, user, mapGeneralCheckedOptionsContent, "", session,
- toolContentUID);
+ voteContentUid);
}
if ((mapGeneralCheckedOptionsContent.size() == 0 && (userEntryAvailable == true))) {
Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator());
if (userEntry.length() > 0) {
LearningUtil.createAttempt(voteService, user, mapLeanerCheckedOptionsContent, userEntry,
- session, toolContentUID);
+ session, voteContentUid);
}
}
@@ -448,7 +439,7 @@
if (userEntry.length() > 0) {
LearningUtil.createAttempt(voteService, user, mapLeanerCheckedOptionsContent, userEntry,
- session, toolContentUID);
+ session, voteContentUid);
}
}
@@ -491,7 +482,7 @@
String revisitingUser = request.getParameter(REVISITING_USER);
voteLearningForm.setRevisitingUser(revisitingUser);
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
VoteContent voteContent = voteSession.getVoteContent();
@@ -504,10 +495,7 @@
voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
- Long toolContentID = voteContent.getVoteContentId();
- Map mapQuestionsContent = new TreeMap(new VoteComparator());
- mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null);
-
+ Map mapQuestionsContent = LearningUtil.buildQuestionMap(request, voteService, voteContent, null);
request.setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
Map mapGeneralCheckedOptionsContent = new TreeMap(new VoteComparator());
@@ -523,12 +511,6 @@
return (mapping.findForward(LOAD_LEARNER));
}
- protected void setContentInUse(HttpServletRequest request, IVoteService voteService, Long toolContentID) {
- VoteContent voteContent = voteService.retrieveVote(toolContentID);
- voteContent.setContentInUse(true);
- voteService.saveVoteContent(voteContent);
- }
-
/**
* persists error messages to request scope
*
@@ -550,7 +532,7 @@
IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
Long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
- VoteSession session = voteService.retrieveVoteSession(toolSessionId);
+ VoteSession session = voteService.getSessionBySessionId(toolSessionId);
VoteQueUsr leader = session.getGroupLeader();
boolean isLeaderResponseFinalized = leader.isResponseFinalised();
@@ -591,7 +573,7 @@
IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
VoteContent voteContent = voteSession.getVoteContent();
VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java
===================================================================
diff -u -r43437f9c52f60b4fe545162b3ed72e6ddf911777 -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision 43437f9c52f60b4fe545162b3ed72e6ddf911777)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningStarterAction.java (.../VoteLearningStarterAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -25,7 +25,6 @@
import java.io.IOException;
import java.util.Date;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -53,7 +52,6 @@
import org.lamsfoundation.lams.tool.ToolAccessMode;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -94,14 +92,12 @@
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, VoteApplicationException {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
if (voteService == null) {
voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
}
- Map mapQuestionsContent = new TreeMap(new VoteComparator());
-
VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
VoteLearningForm voteLearningForm = (VoteLearningForm) form;
@@ -115,10 +111,6 @@
voteGeneralLearnerFlowDTO.setCastVoteCount("0");
voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
- /*
- * save time zone information to session scope.
- */
- VoteUtils.saveTimeZone(request);
ActionForward validateParameters = validateParameters(request, mapping, voteLearningForm);
if (validateParameters != null) {
return validateParameters;
@@ -131,10 +123,10 @@
* retrieve it and the relavent content
*/
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(toolSessionID));
if (voteSession == null) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
VoteLearningStarterAction.logger.error("error: The tool expects voteSession.");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
}
@@ -145,7 +137,7 @@
*/
VoteContent voteContent = voteSession.getVoteContent();
if (voteContent == null) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
VoteLearningStarterAction.logger.error("error: The tool expects voteContent.");
persistInRequestError(request, "error.content.doesNotExist");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
@@ -218,9 +210,8 @@
.getServletContext());
/* find out if the content is being modified at the moment. */
- boolean isDefineLater = VoteUtils.isDefineLater(voteContent);
- if (isDefineLater == true) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ if (voteContent.isDefineLater()) {
+ VoteUtils.cleanUpUserExceptions(request);
return mapping.findForward(VoteAppConstants.DEFINE_LATER);
}
@@ -281,9 +272,8 @@
/*
* fetch question content from content
*/
- mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null);
- request.setAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
- request.setAttribute(VoteAppConstants.MAP_OPTIONS_CONTENT, mapQuestionsContent);
+ Map mapQuestions = LearningUtil.buildQuestionMap(request, voteService, voteContent, null);
+ request.setAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER, mapQuestions);
/*
* the user's session id AND user id exists in the tool tables goto this screen if the OverAll Results scren has
@@ -382,7 +372,7 @@
*/
protected void commonContentSetup(HttpServletRequest request, IVoteService voteService, VoteContent voteContent,
VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO) {
- Map mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null);
+ Map mapQuestionsContent = LearningUtil.buildQuestionMap(request, voteService, voteContent, null);
request.setAttribute(VoteAppConstants.MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
voteGeneralLearnerFlowDTO.setTotalQuestionCount(new Long(mapQuestionsContent.size()).toString());
@@ -445,15 +435,15 @@
String strToolSessionId = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
long toolSessionID = 0;
if (strToolSessionId == null || strToolSessionId.length() == 0) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
// persistInRequestError(request, "error.toolSessionId.required");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
} else {
try {
toolSessionID = new Long(strToolSessionId).longValue();
voteLearningForm.setToolSessionID(new Long(toolSessionID).toString());
} catch (NumberFormatException e) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
// persistInRequestError(request, "error.sessionId.numberFormatException");
VoteLearningStarterAction.logger.error("add error.sessionId.numberFormatException to ActionMessages.");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
@@ -464,13 +454,13 @@
String mode = request.getParameter(VoteAppConstants.MODE);
if (mode == null || mode.length() == 0) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
VoteLearningStarterAction.logger.error("mode missing: ");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
}
if (!mode.equals("learner") && !mode.equals("teacher") && !mode.equals("author")) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
VoteLearningStarterAction.logger.error("mode invalid: ");
return mapping.findForward(VoteAppConstants.ERROR_LIST);
}
@@ -480,7 +470,7 @@
}
boolean isSessionCompleted(String userSessionId, IVoteService voteService) {
- VoteSession voteSession = voteService.retrieveVoteSession(new Long(userSessionId));
+ VoteSession voteSession = voteService.getSessionBySessionId(new Long(userSessionId));
if (voteSession.getSessionStatus() != null && voteSession.getSessionStatus().equals(VoteAppConstants.COMPLETED)) {
return true;
}
@@ -506,7 +496,7 @@
UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userId = new Long(toolUser.getUserID().longValue());
- VoteSession session = voteService.retrieveVoteSession(new Long(toolSessionId));
+ VoteSession session = voteService.getSessionBySessionId(new Long(toolSessionId));
VoteQueUsr user = voteService.getVoteUserBySession(userId, session.getUid());
if (user == null) {
String userName = toolUser.getLogin();
@@ -520,7 +510,7 @@
}
private VoteQueUsr getSpecifiedUser(String toolSessionId, Integer userId) {
- VoteSession session = voteService.retrieveVoteSession(new Long(toolSessionId));
+ VoteSession session = voteService.getSessionBySessionId(new Long(toolSessionId));
VoteQueUsr user = voteService.getVoteUserBySession(new Long(userId.intValue()), session.getUid());
if (user == null) {
logger.error("Unable to find specified user for Vote activity. Screens are likely to fail. SessionId="
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java
===================================================================
diff -u -r43437f9c52f60b4fe545162b3ed72e6ddf911777 -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 43437f9c52f60b4fe545162b3ed72e6ddf911777)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -27,10 +27,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import java.util.TimeZone;
-import java.util.TreeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -41,42 +38,25 @@
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.action.ActionMessages;
import org.apache.struts.action.ActionRedirect;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.EditActivityDTO;
-import org.lamsfoundation.lams.tool.vote.dto.ExportPortfolioDTO;
-import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO;
-import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteAllGroupsDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralAuthoringDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteNominationContentDTO;
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;
import org.lamsfoundation.lams.tool.vote.service.IVoteService;
import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy;
-import org.lamsfoundation.lams.tool.vote.util.VoteComparator;
-import org.lamsfoundation.lams.tool.vote.util.VoteStringComparator;
import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
import org.lamsfoundation.lams.tool.vote.web.form.VoteMonitoringForm;
import org.lamsfoundation.lams.util.DateUtil;
-import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
-import org.lamsfoundation.lams.web.util.SessionMap;
/**
* @author Ozgur Demirtas
@@ -158,7 +138,7 @@
//in case of All sessions
} else {
- userAttempts = voteService.getStandardAttemptsForQuestionContentAndContentUid(new Long(questionUid));
+ userAttempts = voteService.getStandardAttemptsByQuestionUid(new Long(questionUid));
}
List listVotedLearnersDTO = new LinkedList();
@@ -177,15 +157,8 @@
voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime());
listVotedLearnersDTO.add(voteMonitoredUserDTO);
}
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
voteGeneralMonitoringDTO.setMapStudentsVoted(listVotedLearnersDTO);
- voteGeneralMonitoringDTO.setIsMonitoredContentInUse(new Boolean(true).toString());
request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
return mapping.findForward(VoteAppConstants.VOTE_NOMINATION_VIEWER);
@@ -217,1368 +190,7 @@
return mapping.findForward(VoteAppConstants.LEARNER_NOTEBOOK);
}
- protected void repopulateRequestParameters(HttpServletRequest request, VoteMonitoringForm voteMonitoringForm,
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO) {
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteMonitoringForm.setContentFolderID(contentFolderID);
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- String toolContentID = request.getParameter(VoteAppConstants.TOOL_CONTENT_ID);
- voteMonitoringForm.setToolContentID(toolContentID);
- voteGeneralAuthoringDTO.setToolContentID(toolContentID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
- voteMonitoringForm.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
-
- String defineLaterInEditMode = request.getParameter(VoteAppConstants.DEFINE_LATER_IN_EDIT_MODE);
- voteMonitoringForm.setDefineLaterInEditMode(defineLaterInEditMode);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(defineLaterInEditMode);
-
- }
-
/**
- * used in define later mode to switch from view-only to editable screen
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- * @throws ToolException
- */
- public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException, ToolException {
-
- VoteMonitoringForm VoteMonitoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- VoteGeneralMonitoringDTO generalMonitoringDTO = new VoteGeneralMonitoringDTO();
-
- generalMonitoringDTO.setMonitoredContentInUse(new Boolean(false).toString());
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
-
- generalMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
- VoteMonitoringForm.setToolContentID(strToolContentID);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- VoteMonitoringForm.setContentFolderID(contentFolderID);
-
- String httpSessionID = request.getParameter("httpSessionID");
- VoteMonitoringForm.setHttpSessionID(httpSessionID);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteMonitoringForm.setTitle(voteContent.getTitle());
-
- VoteUtils.setDefineLater(request, true, strToolContentID, voteService);
-
- prepareEditActivityScreenData(request, voteContent);
-
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- generalMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, generalMonitoringDTO);
-
- List listNominationContentDTO = new LinkedList();
-
- Iterator queIterator = voteContent.getVoteQueContents().iterator();
- while (queIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO();
-
- VoteQueContent voteQueContent = (VoteQueContent) queIterator.next();
- if (voteQueContent != null) {
- voteNominationContentDTO.setQuestion(voteQueContent.getQuestion());
- voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString());
- listNominationContentDTO.add(voteNominationContentDTO);
- }
- }
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
-
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- VoteGeneralAuthoringDTO VoteGeneralAuthoringDTO = (VoteGeneralAuthoringDTO) request
- .getAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO);
- VoteGeneralAuthoringDTO.setActiveModule(VoteAppConstants.MONITORING);
-
- VoteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- VoteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
- VoteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, VoteGeneralAuthoringDTO);
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = generalMonitoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- List listQuestions = voteService.getAllQuestionEntries(voteContent.getUid());
- List listAllGroupsContainerDTO = new LinkedList();
-
- Iterator iteratorSession = voteContent.getVoteSessions().iterator();
- while (iteratorSession.hasNext()) {
- VoteSession voteSession = (VoteSession) iteratorSession.next();
- String currentSessionId = voteSession.getVoteSessionId().toString();
-
- String currentSessionName = voteSession.getSession_name();
-
- VoteAllGroupsDTO voteAllGroupsDTO = new VoteAllGroupsDTO();
- List listMonitoredAnswersContainerDTO = new LinkedList();
-
- if (voteSession != null) {
- Iterator itListQuestions = listQuestions.iterator();
- while (itListQuestions.hasNext()) {
- VoteQueContent voteQueContent = (VoteQueContent) itListQuestions.next();
-
- if (voteQueContent != null) {
- VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO();
- voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString());
- voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion());
- voteMonitoredAnswersDTO.setSessionId(currentSessionId);
- voteMonitoredAnswersDTO.setSessionName(currentSessionName);
-
- String questionUid = voteQueContent.getUid().toString();
-
- List listMonitoredAttemptsContainerDTO = new LinkedList();
-
- Map summaryToolSessions = MonitoringUtil.populateToolSessionsId(voteContent,
- voteService);
-
- Iterator itMap = summaryToolSessions.entrySet().iterator();
-
- /* request is for monitoring summary */
-
- if (currentSessionId != null) {
- if (currentSessionId.equals("All")) {
- // **summary request is for All**
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
- if (!(pairs.getValue().toString().equals("None"))
- && !(pairs.getValue().toString().equals("All"))) {
- VoteSession voteSession2 = voteService.retrieveVoteSession(new Long(pairs
- .getValue().toString()));
- if (voteSession2 != null) {
- List listUsers = voteService.getUserBySessionOnly(voteSession2);
- Map sessionUsersAttempts = VoteMonitoringAction.populateSessionUsersAttempts(
- request, voteService, voteSession2.getVoteSessionId(), listUsers,
- questionUid);
- listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts);
- }
- }
- }
- } else if (!currentSessionId.equals("All")) {
- // **summary request is for currentSessionId** currentSessionId
-
- List listUsers = voteService.getUserBySessionOnly(voteSession);
-
- Map sessionUsersAttempts = VoteMonitoringAction.populateSessionUsersAttempts(request,
- voteService, new Long(currentSessionId), listUsers, questionUid);
- listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts);
- }
- }
-
- Map questionAttemptData = MonitoringUtil.convertToMap(listMonitoredAttemptsContainerDTO);
-
-
- voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData);
-
- listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO);
- }
- }
- }
- voteAllGroupsDTO.setGroupData(listMonitoredAnswersContainerDTO);
- voteAllGroupsDTO.setSessionName(currentSessionName);
- voteAllGroupsDTO.setSessionId(currentSessionId);
-
- listAllGroupsContainerDTO.add(voteAllGroupsDTO);
-
- }
- request.setAttribute(LIST_ALL_GROUPS_DTO, listAllGroupsContainerDTO);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- private static Map populateSessionUsersAttempts(HttpServletRequest request, IVoteService voteService,
- Long sessionId, List users, String questionUid) {
-
- List listMonitoredUserContainerDTO = new LinkedList();
- Iterator itUsers = users.iterator();
-
- while (itUsers.hasNext()) {
- VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next();
-
- if (voteQueUsr != null) {
- List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(
- questionUid));
-
- Iterator itAttempts = listUserAttempts.iterator();
- while (itAttempts.hasNext()) {
- VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next();
-
- if (voteUsrResp != null) {
- VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO();
- voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime());
- // voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone());
- voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString());
- voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname());
- voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString());
- voteMonitoredUserDTO.setSessionId(sessionId.toString());
- voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry());
-
- // String responsePresentable = VoteUtils.replaceNewLines(voteUsrResp.getUserEntry());
- voteMonitoredUserDTO.setResponsePresentable(voteUsrResp.getUserEntry());
-
- voteMonitoredUserDTO.setQuestionUid(questionUid);
- voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString());
- listMonitoredUserContainerDTO.add(voteMonitoredUserDTO);
- }
- }
- }
- }
-
- //convertToMcMonitoredUserDTOMap
- Map mapMonitoredUserContainerDTO = new TreeMap(new VoteStringComparator());
- Iterator listIterator = listMonitoredUserContainerDTO.iterator();
- Long mapIndex = new Long(1);
- while (listIterator.hasNext()) {
- VoteMonitoredUserDTO data = (VoteMonitoredUserDTO) listIterator.next();
- mapMonitoredUserContainerDTO.put(mapIndex.toString(), data);
- mapIndex = new Long(mapIndex.longValue() + 1);
- }
- return mapMonitoredUserContainerDTO;
- }
-
- public void prepareEditActivityScreenData(HttpServletRequest request, VoteContent voteContent) {
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
-
- if (voteContent.getTitle() == null) {
- voteGeneralAuthoringDTO.setActivityTitle(VoteAppConstants.DEFAULT_VOTING_TITLE);
- } else {
- voteGeneralAuthoringDTO.setActivityTitle(voteContent.getTitle());
- }
-
- if (voteContent.getInstructions() == null) {
- voteGeneralAuthoringDTO.setActivityInstructions(VoteAppConstants.DEFAULT_VOTING_INSTRUCTIONS);
- } else {
- voteGeneralAuthoringDTO.setActivityInstructions(voteContent.getInstructions());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- }
-
- /**
- * submits content into the tool database
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
- Map mapNominationContent = AuthoringUtil.extractMapNominationContent(listNominationContentDTO);
-
- Map mapFeedback = AuthoringUtil.extractMapFeedback(listNominationContentDTO);
-
- ActionMessages errors = new ActionMessages();
-
- if (mapNominationContent.size() == 0) {
- ActionMessage error = new ActionMessage("nominations.none.submitted");
- errors.add(ActionMessages.GLOBAL_MESSAGE, error);
- }
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
-
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- VoteContent voteContentTest = voteService.retrieveVote(new Long(strToolContentID));
- if (!errors.isEmpty()) {
- saveErrors(request, errors);
- }
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
-
- VoteContent voteContent = voteContentTest;
- if (errors.isEmpty()) {
- /* to remove deleted entries in the questions table based on mapNominationContent */
- authoringUtil.removeRedundantNominations(mapNominationContent, voteService, voteAuthoringForm, request,
- strToolContentID);
-
- voteContent = authoringUtil.saveOrUpdateVoteContent(mapNominationContent, mapFeedback, voteService,
- voteAuthoringForm, request, voteContentTest, strToolContentID, null);
-
- long defaultContentID = 0;
- defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- if (voteContent != null) {
- voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString());
- }
-
- authoringUtil.reOrganizeDisplayOrder(mapNominationContent, voteService, voteAuthoringForm, voteContent);
-
- VoteUtils.setDefineLater(request, false, strToolContentID, voteService);
-
- // VoteUtils.setFormProperties(request, voteService,
- // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule,
- // sessionMap, httpSessionID);
-
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString());
- } else {
- if (voteContent != null) {
- long defaultContentID = 0;
- defaultContentID = voteService.getToolDefaultContentIdBySignature(VoteAppConstants.MY_SIGNATURE);
- if (voteContent != null) {
- voteGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString());
- }
-
- }
-
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
- }
-
- voteAuthoringForm.resetUserAction();
- voteGeneralAuthoringDTO.setMapNominationContent(mapNominationContent);
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
-
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
- * saveSingleNomination
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward saveSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
-
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- String editNominationBoxRequest = request.getParameter("editNominationBoxRequest");
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
-
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- String newNomination = request.getParameter("newNomination");
-
- String editableNominationIndex = request.getParameter("editableNominationIndex");
-
- if (newNomination != null && newNomination.length() > 0) {
- if (editNominationBoxRequest != null && editNominationBoxRequest.equals("false")) {
- boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination);
-
- if (!duplicates) {
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- String question = voteNominationContentDTO.getQuestion();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- if (displayOrder != null && !displayOrder.equals("")) {
- if (displayOrder.equals(editableNominationIndex)) {
- break;
- }
-
- }
- }
-
- voteNominationContentDTO.setQuestion(newNomination);
- voteNominationContentDTO.setDisplayOrder(editableNominationIndex);
-
- listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO(
- listNominationContentDTO, voteNominationContentDTO, editableNominationIndex);
- } else {
- //duplicate question entry, not adding
- }
- } else {
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- String question = voteNominationContentDTO.getQuestion();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- if (displayOrder != null && !displayOrder.equals("")) {
- if (displayOrder.equals(editableNominationIndex)) {
- break;
- }
-
- }
- }
-
- voteNominationContentDTO.setQuestion(newNomination);
- voteNominationContentDTO.setDisplayOrder(editableNominationIndex);
-
- listNominationContentDTO = AuthoringUtil.reorderUpdateListNominationContentDTO(
- listNominationContentDTO, voteNominationContentDTO, editableNominationIndex);
- }
- } else {
- //entry blank, not adding
- }
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- // VoteUtils.setFormProperties(request, voteService,
- // voteAuthoringForm, voteGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap,
- // httpSessionID);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
-
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
- * addSingleNomination
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward addSingleNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
-
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- String newNomination = request.getParameter("newNomination");
-
- int listSize = listNominationContentDTO.size();
-
- if (newNomination != null && newNomination.length() > 0) {
- boolean duplicates = AuthoringUtil.checkDuplicateNominations(listNominationContentDTO, newNomination);
-
- if (!duplicates) {
- VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO();
- voteNominationContentDTO.setDisplayOrder(new Long(listSize + 1).toString());
- voteNominationContentDTO.setNomination(newNomination);
-
- listNominationContentDTO.add(voteNominationContentDTO);
- }
- }
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
-
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
- }
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
- * opens up an new screen within the current page for adding a new question
- *
- * newNominationBox
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward newNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
- return mapping.findForward("newNominationBox");
- }
-
- /**
- * opens up an new screen within the current page for editing a question newEditableNominationBox
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward newEditableNominationBox(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String questionIndex = request.getParameter("questionIndex");
-
- voteAuthoringForm.setEditableNominationIndex(questionIndex);
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- String editableNomination = "";
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
- String question = voteNominationContentDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- if (displayOrder != null && !displayOrder.equals("")) {
- if (displayOrder.equals(questionIndex)) {
- editableNomination = voteNominationContentDTO.getNomination();
- break;
- }
-
- }
- }
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
- voteGeneralAuthoringDTO.setEditableNominationText(editableNomination);
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
- return mapping.findForward("editNominationBox");
- }
-
- /**
- * removes a question from the questions map
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward removeNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String questionIndex = request.getParameter("questionIndex");
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- VoteNominationContentDTO voteNominationContentDTO = null;
- Iterator listIterator = listNominationContentDTO.iterator();
- while (listIterator.hasNext()) {
- voteNominationContentDTO = (VoteNominationContentDTO) listIterator.next();
-
- String question = voteNominationContentDTO.getNomination();
- String displayOrder = voteNominationContentDTO.getDisplayOrder();
-
- if (displayOrder != null && !displayOrder.equals("")) {
- if (displayOrder.equals(questionIndex)) {
- break;
- }
-
- }
- }
-
- voteNominationContentDTO.setNomination("");
-
- listNominationContentDTO = AuthoringUtil.reorderListNominationContentDTO(listNominationContentDTO,
- questionIndex);
-
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
-
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- if (voteContent == null) {
- voteContent = voteService.retrieveVote(new Long(defaultContentIdStr));
- }
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
- * moves a question down in the list moveNominationDown
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward moveNominationDown(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String questionIndex = request.getParameter("questionIndex");
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "down");
-
- listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO);
-
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
-
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
-
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
- * moves a question up in the list moveNominationUp
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward moveNominationUp(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- VoteMonitoringForm voteAuthoringForm = (VoteMonitoringForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
-
- String httpSessionID = voteAuthoringForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- String questionIndex = request.getParameter("questionIndex");
-
- List listNominationContentDTO = (List) sessionMap.get(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY);
-
- listNominationContentDTO = AuthoringUtil.swapNodes(listNominationContentDTO, questionIndex, "up");
-
- listNominationContentDTO = AuthoringUtil.reorderSimpleListNominationContentDTO(listNominationContentDTO);
-
- sessionMap.put(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
-
- String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
- voteAuthoringForm.setContentFolderID(contentFolderID);
-
- String activeModule = request.getParameter(VoteAppConstants.ACTIVE_MODULE);
-
- String richTextTitle = request.getParameter(VoteAppConstants.TITLE);
-
- String richTextInstructions = request.getParameter(VoteAppConstants.INSTRUCTIONS);
-
- sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, richTextTitle);
- sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions);
-
- String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
-
- String defaultContentIdStr = request.getParameter(VoteAppConstants.DEFAULT_CONTENT_ID_STR);
-
- VoteContent voteContent = voteService.retrieveVote(new Long(strToolContentID));
-
- VoteGeneralAuthoringDTO voteGeneralAuthoringDTO = new VoteGeneralAuthoringDTO();
- voteGeneralAuthoringDTO.setContentFolderID(contentFolderID);
-
- voteGeneralAuthoringDTO.setActivityTitle(richTextTitle);
- voteAuthoringForm.setTitle(richTextTitle);
-
- voteGeneralAuthoringDTO.setActivityInstructions(richTextInstructions);
-
- AuthoringUtil authoringUtil = new AuthoringUtil();
-
- voteGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString());
-
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- voteGeneralAuthoringDTO.setToolContentID(strToolContentID);
- voteGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
- voteGeneralAuthoringDTO.setActiveModule(activeModule);
- voteGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setToolContentID(strToolContentID);
- voteAuthoringForm.setHttpSessionID(httpSessionID);
- voteAuthoringForm.setActiveModule(activeModule);
- voteAuthoringForm.setDefaultContentIdStr(defaultContentIdStr);
- voteAuthoringForm.setCurrentTab("2");
-
- request.setAttribute(VoteAppConstants.LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
-
- voteGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- repopulateRequestParameters(request, voteAuthoringForm, voteGeneralAuthoringDTO);
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_AUTHORING_DTO, voteGeneralAuthoringDTO);
-
- request.setAttribute(VoteAppConstants.TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- if (voteContent != null) {
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- EditActivityDTO editActivityDTO = new EditActivityDTO();
- boolean isContentInUse = VoteUtils.isContentInUse(voteContent);
- if (isContentInUse == true) {
- editActivityDTO.setMonitoredContentInUse(new Boolean(false).toString());
- }
- request.setAttribute(VoteAppConstants.EDIT_ACTIVITY_DTO, editActivityDTO);
- }
-
- /* find out if there are any reflection entries, from here */
- boolean notebookEntriesExist = MonitoringUtil.notebookEntriesExist(voteService, voteContent);
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(true).toString());
-
- if (voteService.studentActivityOccurredGlobal(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO);
-
- if (notebookEntriesExist) {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
-
- String userExceptionNoToolSessions = voteGeneralAuthoringDTO.getUserExceptionNoToolSessions();
- if (userExceptionNoToolSessions.equals("true")) {
- request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString());
- }
- } else {
- request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString());
- }
- /* ... till here */
-
- MonitoringUtil.buildVoteStatsDTO(request, voteService, voteContent);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- /**
* Set Submission Deadline
*
* @param mapping
@@ -1593,7 +205,7 @@
IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID);
- VoteContent voteContent = voteService.retrieveVote(contentID);
+ VoteContent voteContent = voteService.getVoteContent(contentID);
Long dateParameter = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SUBMISSION_DEADLINE, true);
Date tzSubmissionDeadline = null;
@@ -1608,12 +220,4 @@
voteService.updateVote(voteContent);
return null;
}
-
-
- /**
- * Return ResourceService bean.
- */
- private MessageService getMessageService() {
- return VoteServiceProxy.getMessageService(getServlet().getServletContext());
- }
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java
===================================================================
diff -u -r9afb93ea36dcedb5db374cacb84b3c4a3d30465c -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 9afb93ea36dcedb5db374cacb84b3c4a3d30465c)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a)
@@ -23,31 +23,35 @@
package org.lamsfoundation.lams.tool.vote.web;
import java.io.IOException;
+import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TimeZone;
import java.util.TreeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
-import org.lamsfoundation.lams.tool.vote.dto.EditActivityDTO;
import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO;
import org.lamsfoundation.lams.tool.vote.dto.SessionDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralAuthoringDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO;
import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO;
-import org.lamsfoundation.lams.tool.vote.dto.VoteNominationContentDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO;
+import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO;
import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
@@ -59,6 +63,9 @@
import org.lamsfoundation.lams.tool.vote.util.VoteComparator;
import org.lamsfoundation.lams.tool.vote.util.VoteUtils;
import org.lamsfoundation.lams.tool.vote.web.form.VoteMonitoringForm;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.util.DateUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
import org.lamsfoundation.lams.web.util.SessionMap;
@@ -72,7 +79,7 @@
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, VoteApplicationException {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
@@ -89,17 +96,14 @@
}
//initialiseMonitoringData
- voteGeneralMonitoringDTO.setDefineLaterInEditMode(new Boolean(false).toString());
voteGeneralMonitoringDTO.setRequestLearningReport(new Boolean(false).toString());
- VoteUtils.saveTimeZone(request);
-
/* we have made sure TOOL_CONTENT_ID is passed */
String toolContentID = voteMonitoringForm.getToolContentID();
- VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID));
+ VoteContent voteContent = voteService.getVoteContent(new Long(toolContentID));
if (voteContent == null) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
voteGeneralMonitoringDTO.setUserExceptionContentDoesNotExist(new Boolean(true).toString());
return (mapping.findForward(ERROR_LIST));
}
@@ -108,7 +112,7 @@
voteGeneralMonitoringDTO.setActivityInstructions(voteContent.getInstructions());
if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) {
- VoteUtils.cleanUpSessionAbsolute(request);
+ VoteUtils.cleanUpUserExceptions(request);
voteGeneralMonitoringDTO.setUserExceptionContentInUse(new Boolean(true).toString());
}
@@ -122,93 +126,24 @@
voteMonitoringForm.setHttpSessionID(sessionMap.getSessionID());
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
- List listNominationContentDTO = new LinkedList();
+ List listQuestionDTO = new LinkedList();
- Map mapOptionsContent = new TreeMap(new VoteComparator());
Iterator queIterator = voteContent.getVoteQueContents().iterator();
- Long mapIndex = new Long(1);
while (queIterator.hasNext()) {
- VoteNominationContentDTO voteNominationContentDTO = new VoteNominationContentDTO();
+ VoteQuestionDTO voteQuestionDTO = new VoteQuestionDTO();
VoteQueContent voteQueContent = (VoteQueContent) queIterator.next();
if (voteQueContent != null) {
- mapOptionsContent.put(mapIndex.toString(), voteQueContent.getQuestion());
- voteNominationContentDTO.setQuestion(voteQueContent.getQuestion());
- voteNominationContentDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString());
- listNominationContentDTO.add(voteNominationContentDTO);
-
- //make the first entry the default(first) one for jsp
- if (mapIndex.longValue() == 1) {
- voteGeneralAuthoringDTO.setDefaultOptionContent(voteQueContent.getQuestion());
- }
-
- mapIndex = new Long(mapIndex.longValue() + 1);
+ voteQuestionDTO.setQuestion(voteQueContent.getQuestion());
+ voteQuestionDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString());
+ listQuestionDTO.add(voteQuestionDTO);
}
}
- voteGeneralMonitoringDTO.setMapOptionsContent(mapOptionsContent);
- /* ends here */
- request.setAttribute(LIST_NOMINATION_CONTENT_DTO, listNominationContentDTO);
- sessionMap.put(LIST_NOMINATION_CONTENT_DTO_KEY, listNominationContentDTO);
+ request.setAttribute(LIST_QUESTION_DTO, listQuestionDTO);
+ sessionMap.put(LIST_QUESTION_DTO, listQuestionDTO);
- request.setAttribute(TOTAL_NOMINATION_COUNT, new Integer(listNominationContentDTO.size()));
-
- VoteMonitoringStarterAction.refreshSummaryData(request, voteContent, voteService, voteGeneralMonitoringDTO);
-
- voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(false).toString());
-
- voteMonitoringForm.setCurrentTab("1");
- voteGeneralMonitoringDTO.setCurrentTab("1");
-
- /* true means there is at least 1 response */
- if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString());
- } else {
- voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString());
- }
-
- voteMonitoringForm.setActiveModule(MONITORING);
- voteGeneralMonitoringDTO.setActiveModule(MONITORING);
-
- voteGeneralMonitoringDTO.setIsPortfolioExport(new Boolean(false).toString());
-
- // this section is needed for Edit Activity screen
- voteGeneralAuthoringDTO.setActivityTitle(voteGeneralMonitoringDTO.getActivityTitle());
- voteGeneralAuthoringDTO.setActivityInstructions(voteGeneralMonitoringDTO.getActivityInstructions());
- voteGeneralAuthoringDTO.setDefaultOptionContent(voteGeneralMonitoringDTO.getDefaultOptionContent());
- voteGeneralAuthoringDTO.setMapOptionsContent(voteGeneralMonitoringDTO.getMapOptionsContent());
- voteGeneralAuthoringDTO.setActiveModule(MONITORING);
- voteGeneralAuthoringDTO.setMaxOptionIndex(mapOptionsContent.size());
-
- MonitoringUtil.repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO);
-
- List sessionDTOs = voteService.getSessionDTOs(new Long(toolContentID));
- voteGeneralMonitoringDTO.setSessionDTOs(sessionDTOs);
-
- boolean isGroupedActivity = voteService.isGroupedActivity(new Long(toolContentID));
- request.setAttribute("isGroupedActivity", isGroupedActivity);
-
-
- //refreshStatsData
- /* it is possible that no users has ever logged in for the activity yet */
- int countAllUsers = voteService.getTotalNumberOfUsers();
- if (countAllUsers == 0) {
- voteGeneralMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString());
- }
- voteGeneralMonitoringDTO.setCountAllUsers(new Integer(countAllUsers).toString());
- int countSessionComplete = voteService.countSessionComplete();
- voteGeneralMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete).toString());
-
- List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null);
- request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO);
-
- return mapping.findForward(VoteAppConstants.LOAD_MONITORING);
- }
-
- public static void refreshSummaryData(HttpServletRequest request, VoteContent voteContent,
- IVoteService voteService, VoteGeneralMonitoringDTO voteGeneralMonitoringDTO) {
-
/* this section is related to summary tab. Starts here. */
if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) {
@@ -219,11 +154,11 @@
String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions();
- List listQuestions = voteService.getAllQuestionEntries(voteContent.getUid());
+ Set questions = voteContent.getVoteQueContents();
List listMonitoredAnswersContainerDTO = new LinkedList();
- Iterator itListQuestions = listQuestions.iterator();
+ Iterator itListQuestions = questions.iterator();
while (itListQuestions.hasNext()) {
VoteQueContent voteQueContent = (VoteQueContent) itListQuestions.next();
@@ -236,13 +171,24 @@
List