Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml 30 Sep 2008 05:54:57 -0000 1.1 +++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml 4 Oct 2008 02:45:44 -0000 1.2 @@ -8,6 +8,7 @@ name="org.lamsfoundation.lams.tool.qa.QaCondition" table="tl_laqa11_conditions" extends="org.lamsfoundation.lams.learningdesign.TextSearchCondition" + lazy="false" > Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java 30 Sep 2008 05:54:57 -0000 1.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaCondition.java 4 Oct 2008 02:45:44 -0000 1.2 @@ -27,6 +27,7 @@ import java.util.SortedSet; import java.util.TreeSet; +import org.lamsfoundation.lams.learningdesign.LearningDesign; import org.lamsfoundation.lams.learningdesign.TextSearchCondition; import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO; import org.lamsfoundation.lams.tool.OutputType; @@ -101,4 +102,22 @@ public void setQuestions(Set questions) { this.questions = questions; } + + @Override + public Object clone() { + Set questionsCopy = new TreeSet(new QaQueContentComparator()); + questionsCopy.addAll(questions); + return new QaCondition(null, null, orderId, name, displayName, type, null, null, null, allWords, phrase, + anyWords, excludedWords, questionsCopy); + } + + @Override + public QaCondition clone(int uiidOffset) { + Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset); + Set questionsCopy = new TreeSet(new QaQueContentComparator()); + questionsCopy.addAll(questions); + return new QaCondition(null, newConditionUIID, orderId, name, displayName, type, startValue, endValue, + exactMatchValue, allWords, phrase, anyWords, excludedWords, questionsCopy); + } + } \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java,v diff -u -r1.18 -r1.19 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java 30 Sep 2008 05:54:57 -0000 1.18 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java 4 Oct 2008 02:45:44 -0000 1.19 @@ -42,17 +42,15 @@ /** * @author Ozgur Demirtas * - * TODO To change the template for this generated type comment go to Window - - * Preferences - Java - Code Style - Code Templates + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates */ /** - * QaContent Value Object The value object that maps to our model database - * table: tl_laqa11_content The relevant hibernate mapping resides in: - * QaContent.hbm.xml + * QaContent Value Object The value object that maps to our model database table: tl_laqa11_content The relevant + * hibernate mapping resides in: QaContent.hbm.xml * - * Holds content representation for the tool. Default content is made available - * to the tool by the database. + * Holds content representation for the tool. Default content is made available to the tool by the database. */ public class QaContent implements Serializable { static Logger logger = Logger.getLogger(QaContent.class.getName()); @@ -127,25 +125,20 @@ /** persistent field */ private Set qaUploadedFiles; /** persistent field */ - private Set conditions = new TreeSet( - new QaConditionComparator()); + private Set conditions = new TreeSet(new QaConditionComparator()); private String nonHTMLtitle; public QaContent() { }; /** full constructor */ - public QaContent(Long qaContentId, String content, String title, - String instructions, String reportTitle, - String monitoringReportTitle, String offlineInstructions, - String onlineInstructions, long createdBy, boolean defineLater, - boolean runOffline, boolean questionsSequenced, - boolean usernameVisible, boolean synchInMonitor, - boolean lockWhenFinished, boolean contentLocked, - boolean showOtherAnswers, boolean reflect, - String reflectionSubject, Date creationDate, Date updateDate, - Set qaQueContents, Set qaSessions, Set qaUploadedFiles) { + public QaContent(Long qaContentId, String content, String title, String instructions, String reportTitle, + String monitoringReportTitle, String offlineInstructions, String onlineInstructions, long createdBy, + boolean defineLater, boolean runOffline, boolean questionsSequenced, boolean usernameVisible, + boolean synchInMonitor, boolean lockWhenFinished, boolean contentLocked, boolean showOtherAnswers, + boolean reflect, String reflectionSubject, Date creationDate, Date updateDate, Set qaQueContents, + Set qaSessions, Set qaUploadedFiles, Set conditions) { this.qaContentId = qaContentId; this.content = content; this.title = title; @@ -170,76 +163,76 @@ this.qaQueContents = qaQueContents; this.qaSessions = qaSessions; this.qaUploadedFiles = qaUploadedFiles; - QaContent.logger.debug(QaContent.logger + " " - + this.getClass().getName() - + "in full constructor: QaContent()"); + this.conditions = conditions; + QaContent.logger.debug(QaContent.logger + " " + this.getClass().getName() + "in full constructor: QaContent()"); } /** - * Copy Construtor to create a new qa content instance. Note that we don't - * copy the qa session data here because the qa session will be created - * after we copied tool content. + * Copy Construtor to create a new qa content instance. Note that we don't copy the qa session data here because the + * qa session will be created after we copied tool content. * * @param qa * the original qa content. * @param newContentId * the new qa content id. * @return the new qa content object. */ - public static QaContent newInstance(IToolContentHandler toolContentHandler, - QaContent qa, Long newContentId) throws ItemNotFoundException, - RepositoryCheckedException { - QaContent newContent = new QaContent(newContentId, qa.getContent(), qa - .getTitle(), qa.getInstructions(), qa.getReportTitle(), qa - .getMonitoringReportTitle(), qa.getOfflineInstructions(), qa - .getOnlineInstructions(), qa.getCreatedBy(), - qa.isDefineLater(), qa.isRunOffline(), qa - .isQuestionsSequenced(), qa.isUsernameVisible(), qa - .isSynchInMonitor(), qa.isLockWhenFinished(), qa - .isContentLocked(), qa.isShowOtherAnswers(), qa - .isReflect(), qa.getReflectionSubject(), qa - .getCreationDate(), qa.getUpdateDate(), new TreeSet(), - new TreeSet(), new TreeSet()); + public static QaContent newInstance(IToolContentHandler toolContentHandler, QaContent qa, Long newContentId) + throws ItemNotFoundException, RepositoryCheckedException { + QaContent newContent = new QaContent(newContentId, qa.getContent(), qa.getTitle(), qa.getInstructions(), qa + .getReportTitle(), qa.getMonitoringReportTitle(), qa.getOfflineInstructions(), qa + .getOnlineInstructions(), qa.getCreatedBy(), qa.isDefineLater(), qa.isRunOffline(), qa + .isQuestionsSequenced(), qa.isUsernameVisible(), qa.isSynchInMonitor(), qa.isLockWhenFinished(), qa + .isContentLocked(), qa.isShowOtherAnswers(), qa.isReflect(), qa.getReflectionSubject(), qa + .getCreationDate(), qa.getUpdateDate(), new TreeSet(), new TreeSet(), new TreeSet(), + new TreeSet(new QaConditionComparator())); newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent)); - QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " - + "after doing deepCopyQaQueContent"); + QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " + "after doing deepCopyQaQueContent"); - newContent.setQaUploadedFiles(qa.deepCopyQaAttachments( - toolContentHandler, newContent)); - + newContent.setQaUploadedFiles(qa.deepCopyQaAttachments(toolContentHandler, newContent)); + newContent.setConditions(qa.deepCopyConditions(newContent)); return newContent; } public Set deepCopyQaQueContent(QaContent newQaContent) { - QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " - + "start of deepCopyQaQueContent"); + QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " + "start of deepCopyQaQueContent"); Set newQaQueContent = new TreeSet(); for (Iterator i = this.getQaQueContents().iterator(); i.hasNext();) { QaQueContent queContent = (QaQueContent) i.next(); - newQaQueContent.add(QaQueContent.newInstance(queContent, - newQaContent, null)); + newQaQueContent.add(QaQueContent.newInstance(queContent, newQaContent)); } - QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " - + "returning newQaQueContent: " + newQaQueContent); + QaContent.logger.debug(QaContent.logger + " " + "QaContent" + " " + "returning newQaQueContent: " + + newQaQueContent); return newQaQueContent; } - public Set deepCopyQaAttachments(IToolContentHandler toolContentHandler, - QaContent newQaContent) throws ItemNotFoundException, - RepositoryCheckedException { + public Set deepCopyQaAttachments(IToolContentHandler toolContentHandler, QaContent newQaContent) + throws ItemNotFoundException, RepositoryCheckedException { Set attachments = new TreeSet(); for (Iterator i = this.getQaUploadedFiles().iterator(); i.hasNext();) { QaUploadedFile qaUploadedFile = (QaUploadedFile) i.next(); if (qaUploadedFile.getQaContent() != null) { - QaUploadedFile newQaUploadedFile = QaUploadedFile.newInstance( - toolContentHandler, qaUploadedFile, newQaContent); + QaUploadedFile newQaUploadedFile = QaUploadedFile.newInstance(toolContentHandler, qaUploadedFile, + newQaContent); attachments.add(newQaUploadedFile); } } return attachments; } + public Set deepCopyConditions(QaContent newQaContent) { + + Set newConditions = new TreeSet(new QaConditionComparator()); + if (getConditions() != null) { + for (QaCondition condition : getConditions()) { + newConditions.add((QaCondition) condition.clone()); + } + } + + return newConditions; + } + public Set deepCopyQaSession(QaContent newQaSession) { return new TreeSet(); } @@ -298,16 +291,13 @@ @Override public String toString() { - return new ToStringBuilder(this).append("qaContentId:", - getQaContentId()).append("qa title:", getTitle()).append( - "qa instructions:", getInstructions()).append( - "creator user id", getCreatedBy()).append("username_visible:", - isUsernameVisible()).append("defineLater", isDefineLater()) - .append("offline_instructions:", getOfflineInstructions()) - .append("online_instructions:", getOnlineInstructions()) - .append("report_title: ", getReportTitle()).append( - "reflection subject: ", getReflectionSubject()).append( - "synch_in_monitor: ", isSynchInMonitor()).toString(); + return new ToStringBuilder(this).append("qaContentId:", getQaContentId()).append("qa title:", getTitle()) + .append("qa instructions:", getInstructions()).append("creator user id", getCreatedBy()).append( + "username_visible:", isUsernameVisible()).append("defineLater", isDefineLater()).append( + "offline_instructions:", getOfflineInstructions()).append("online_instructions:", + getOnlineInstructions()).append("report_title: ", getReportTitle()).append( + "reflection subject: ", getReflectionSubject()) + .append("synch_in_monitor: ", isSynchInMonitor()).toString(); } @Override @@ -316,8 +306,7 @@ return false; } QaContent castOther = (QaContent) other; - return new EqualsBuilder().append(this.getQaContentId(), - castOther.getQaContentId()).isEquals(); + return new EqualsBuilder().append(this.getQaContentId(), castOther.getQaContentId()).isEquals(); } @Override Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java,v diff -u -r1.11 -r1.12 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java 20 Sep 2006 15:15:44 -0000 1.11 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java 4 Oct 2008 02:45:44 -0000 1.12 @@ -20,7 +20,7 @@ * http://www.gnu.org/licenses/gpl.txt * **************************************************************** */ -/* $$Id$$ */ +/* $$Id$$ */ package org.lamsfoundation.lams.tool.qa; import java.io.Serializable; @@ -36,42 +36,40 @@ /** * * @author Ozgur Demirtas - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates */ /** - * QaQueContent Value Object - * The value object that maps to our model database table: tl_laqa11_que_content - * The relevant hibernate mapping resides in: QaQueContent.hbm.xml - * - * Holds question content within a particular content + * QaQueContent Value Object The value object that maps to our model database table: tl_laqa11_que_content The relevant + * hibernate mapping resides in: QaQueContent.hbm.xml + * + * Holds question content within a particular content */ -public class QaQueContent implements Serializable,Comparable, Nullable -{ - static Logger logger = Logger.getLogger(QaQueContent.class.getName()); - - /** identifier field */ +public class QaQueContent implements Serializable, Comparable, Nullable { + static Logger logger = Logger.getLogger(QaQueContent.class.getName()); + + /** identifier field */ private Long uid; /** nullable persistent field */ private String question; /** nullable persistent field */ private int displayOrder; - + private String feedback; - + /** nullable persistent field */ private org.lamsfoundation.lams.tool.qa.QaContent qaContent; - + /** persistent field */ - private Set qaUsrResps; - + private Set qaUsrResps; + /** persistent field */ - private Set qaQueUsers; - + private Set qaQueUsers; + /** Struts form convenience field */ private String[] userResponses = {}; @@ -83,331 +81,300 @@ /** nullable persistent field */ private Long qaContentId; - + /** default constructor */ - public QaQueContent() - { - logger.debug(logger + " " + this.getClass().getName() + "in constructor: QaQueContent()"); + public QaQueContent() { + QaQueContent.logger.debug(QaQueContent.logger + " " + this.getClass().getName() + + "in constructor: QaQueContent()"); } - - - public QaQueContent(String question, - int displayOrder, - org.lamsfoundation.lams.tool.qa.QaContent qaContent, - Set qaQueUsers, - Set qaUsrResps) - { - this.question = question; - this.displayOrder = displayOrder; - this.qaContent = qaContent; - this.qaQueUsers=qaQueUsers; - this.qaUsrResps=qaUsrResps; + + public QaQueContent(String question, int displayOrder, org.lamsfoundation.lams.tool.qa.QaContent qaContent, + Set qaQueUsers, Set qaUsrResps) { + this.question = question; + this.displayOrder = displayOrder; + this.qaContent = qaContent; + this.qaQueUsers = qaQueUsers; + this.qaUsrResps = qaUsrResps; } - - public QaQueContent(String question, - int displayOrder, - String feedback, - org.lamsfoundation.lams.tool.qa.QaContent qaContent, - Set qaQueUsers, - Set qaUsrResps) - { - this.question = question; - this.displayOrder = displayOrder; - this.feedback = feedback; - this.qaContent = qaContent; - this.qaQueUsers=qaQueUsers; - this.qaUsrResps=qaUsrResps; - } - - - public QaQueContent(String question, - int displayOrder, - Set qaQueUsers, - Set qaUsrResps) - { - this.question = question; - this.displayOrder = displayOrder; - this.qaQueUsers=qaQueUsers; - this.qaUsrResps=qaUsrResps; - } - - + public QaQueContent(String question, int displayOrder, String feedback, + org.lamsfoundation.lams.tool.qa.QaContent qaContent, Set qaQueUsers, Set qaUsrResps) { + this.question = question; + this.displayOrder = displayOrder; + this.feedback = feedback; + this.qaContent = qaContent; + this.qaQueUsers = qaQueUsers; + this.qaUsrResps = qaUsrResps; + } + + public QaQueContent(String question, int displayOrder, Set qaQueUsers, Set qaUsrResps) { + this.question = question; + this.displayOrder = displayOrder; + this.qaQueUsers = qaQueUsers; + this.qaUsrResps = qaUsrResps; + } + /** minimal constructor */ - public QaQueContent(Set qaQueUsers, - Set qaUsrResps) - { - this.qaQueUsers = qaQueUsers; - this.qaUsrResps = qaUsrResps; + public QaQueContent(Set qaQueUsers, Set qaUsrResps) { + this.qaQueUsers = qaQueUsers; + this.qaUsrResps = qaUsrResps; } - - + /* - public static QaQueContent newInstance(QaQueContent queContent, - QaContent newQaContent, - QaQueContent parentQuestion) - { - QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(), - queContent.getDisplayOrder(), - newQaContent, - new TreeSet(), - new TreeSet()); - logger.debug(logger + " " + "QaQueContent" + " " + "returning newQueContent: " + newQueContent); - return newQueContent; + * public static QaQueContent newInstance(QaQueContent queContent, QaContent newQaContent, QaQueContent + * parentQuestion) { QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(), + * queContent.getDisplayOrder(), newQaContent, new TreeSet(), new TreeSet()); logger.debug(logger + " " + + * "QaQueContent" + " " + "returning newQueContent: " + newQueContent); return newQueContent; } + * + */ + public static QaQueContent newInstance(QaQueContent queContent, QaContent newQaContent) { + QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(), queContent.getDisplayOrder(), + queContent.getFeedback(), newQaContent, new TreeSet(), new TreeSet()); + QaQueContent.logger.debug(QaQueContent.logger + " " + "QaQueContent" + " " + "returning newQueContent: " + + newQueContent); + return newQueContent; } - - */ - public static QaQueContent newInstance(QaQueContent queContent, - QaContent newQaContent, - QaQueContent parentQuestion) - { - QaQueContent newQueContent = new QaQueContent(queContent.getQuestion(), - queContent.getDisplayOrder(), - queContent.getFeedback(), - newQaContent, - new TreeSet(), - new TreeSet()); - logger.debug(logger + " " + "QaQueContent" + " " + "returning newQueContent: " + newQueContent); - return newQueContent; - } - - + @Override public String toString() { - return new ToStringBuilder(this) - .append("qaQueContentId: ", getUid()) - .append("question: ", getQuestion()) - .append("displayOrder: ", getDisplayOrder()) - .toString(); + return new ToStringBuilder(this).append("qaQueContentId: ", getUid()).append("question: ", getQuestion()) + .append("displayOrder: ", getDisplayOrder()).toString(); } + @Override public boolean equals(Object other) { - if ( !(other instanceof QaQueContent) ) return false; - QaQueContent castOther = (QaQueContent) other; - return new EqualsBuilder() - .append(this.getUid(), castOther.getUid()) - .isEquals(); + if (!(other instanceof QaQueContent)) { + return false; + } + QaQueContent castOther = (QaQueContent) other; + return new EqualsBuilder().append(this.getUid(), castOther.getUid()).isEquals(); } + @Override public int hashCode() { - return new HashCodeBuilder() - .append(getUid()) - .toHashCode(); + return new HashCodeBuilder().append(getUid()).toHashCode(); } - - - /** - * @return Returns the displayOrder. - */ - public int getDisplayOrder() { - return displayOrder; + + /** + * @return Returns the displayOrder. + */ + public int getDisplayOrder() { + return displayOrder; + } + + /** + * @param displayOrder + * The displayOrder to set. + */ + public void setDisplayOrder(int displayOrder) { + this.displayOrder = displayOrder; + } + + /** + * @return Returns the qaContent. + */ + public org.lamsfoundation.lams.tool.qa.QaContent getQaContent() { + return qaContent; + } + + /** + * @param qaContent + * The qaContent to set. + */ + public void setQaContent(org.lamsfoundation.lams.tool.qa.QaContent qaContent) { + this.qaContent = qaContent; + } + + /** + * @return Returns the qaQueUsers. + */ + public Set getQaQueUsers() { + if (qaQueUsers == null) { + setQaQueUsers(new TreeSet()); } - /** - * @param displayOrder The displayOrder to set. - */ - public void setDisplayOrder(int displayOrder) { - this.displayOrder = displayOrder; + return qaQueUsers; + } + + /** + * @param qaQueUsers + * The qaQueUsers to set. + */ + public void setQaQueUsers(Set qaQueUsers) { + this.qaQueUsers = qaQueUsers; + } + + /** + * @return Returns the qaUsrResps. + */ + public Set getQaUsrResps() { + if (qaUsrResps == null) { + setQaUsrResps(new TreeSet()); } - /** - * @return Returns the qaContent. - */ - public org.lamsfoundation.lams.tool.qa.QaContent getQaContent() { - return qaContent; - } - /** - * @param qaContent The qaContent to set. - */ - public void setQaContent(org.lamsfoundation.lams.tool.qa.QaContent qaContent) { - this.qaContent = qaContent; - } - - /** - * @return Returns the qaQueUsers. - */ - public Set getQaQueUsers() { - if (this.qaQueUsers == null) - setQaQueUsers(new TreeSet()); - return qaQueUsers; - } - /** - * @param qaQueUsers The qaQueUsers to set. - */ - public void setQaQueUsers(Set qaQueUsers) { - this.qaQueUsers = qaQueUsers; - } - /** - * @return Returns the qaUsrResps. - */ - public Set getQaUsrResps() { - if (this.qaUsrResps == null) - setQaUsrResps(new TreeSet()); - return qaUsrResps; - } - /** - * @param qaUsrResps The qaUsrResps to set. - */ - public void setQaUsrResps(Set qaUsrResps) { - this.qaUsrResps = qaUsrResps; - } - /** - * @return Returns the question. - */ - public String getQuestion() { - return question; - } - /** - * @param question The question to set. - */ - public void setQuestion(String question) { - this.question = question; - } - - - public String[] getUserResponses() - { - return userResponses; + return qaUsrResps; } /** - * @param userResponse The userResponse to set. + * @param qaUsrResps + * The qaUsrResps to set. */ - public void setUserResponses(String[] userResponse) - { - this.userResponses = userResponse; + public void setQaUsrResps(Set qaUsrResps) { + this.qaUsrResps = qaUsrResps; } /** + * @return Returns the question. + */ + public String getQuestion() { + return question; + } + + /** + * @param question + * The question to set. + */ + public void setQuestion(String question) { + this.question = question; + } + + public String[] getUserResponses() { + return userResponses; + } + + /** + * @param userResponse + * The userResponse to set. + */ + public void setUserResponses(String[] userResponse) { + userResponses = userResponse; + } + + /** * @return Returns the otherResponse. */ - public String getOtherResponse() - { - return otherResponse == null ? null : otherResponse.trim(); + public String getOtherResponse() { + return otherResponse == null ? null : otherResponse.trim(); } /** - * @param otherResponse The otherResponse to set. + * @param otherResponse + * The otherResponse to set. */ - public void setOtherResponse(String otherResponse) - { - this.otherResponse = otherResponse; + public void setOtherResponse(String otherResponse) { + this.otherResponse = otherResponse; } - - /** + /** * @hibernate.property column="isOptional" length="1" - * + * */ - public boolean getIsOptional() - { - return this.isOptional; + public boolean getIsOptional() { + return isOptional; } - public void setIsOptional(boolean isOptional) - { - this.isOptional = isOptional; + public void setIsOptional(boolean isOptional) { + this.isOptional = isOptional; } - /** - * Validate whether there is a response available for current question. - * This method only validate struts convient field at the moment. + * Validate whether there is a response available for current question. This method only validate struts convient + * field at the moment. + * * @return whether the resonse is available or not. */ - private boolean isResponseAvailable() - { - if (this.getUserResponses().length == 0 - && this.getOtherResponse() == null) - return false; - return this.getUserResponses().length != 0 - || !this.getOtherResponse().equals(""); + private boolean isResponseAvailable() { + if (this.getUserResponses().length == 0 && this.getOtherResponse() == null) { + return false; + } + return this.getUserResponses().length != 0 || !this.getOtherResponse().equals(""); } - - public void setUpOtherResponse(String username) - { - for (Iterator i = this.getQaQueUsers().iterator(); i.hasNext();) - { - QaQueUsr qUser = (QaQueUsr) i.next(); - if ((qUser.getUsername().trim()).equals(username)) - this.setOtherResponse(qUser.getOtherResponse()); - } + public void setUpOtherResponse(String username) { + for (Iterator i = this.getQaQueUsers().iterator(); i.hasNext();) { + QaQueUsr qUser = (QaQueUsr) i.next(); + + if (qUser.getUsername().trim().equals(username)) { + this.setOtherResponse(qUser.getOtherResponse()); + } + } } - - + /** * Convenient method to check out the response for other field. - * @return true if other response field is not null and is not equals to - * empty String + * + * @return true if other response field is not null and is not equals to empty String */ - public boolean isOtherResponseAvailable() - { - if (this.otherResponse != null && !this.otherResponse.equals("")) - return true; - return false; + public boolean isOtherResponseAvailable() { + if (otherResponse != null && !otherResponse.equals("")) { + return true; + } + return false; } - - public boolean isNull() - { - return false; + + public boolean isNull() { + return false; } - - public int compareTo(Object o) - { - QaQueContent queContent = (QaQueContent) o; - - //if the object does not exist yet, then just return any one of 0, -1, 1. Should not make a difference. - /* - if (uid == null) - return 1; - else - return (int) (uid.longValue() - queContent.uid.longValue()); - */ - return 1; - } - - /** - * @return Returns the qaContentId. + public int compareTo(Object o) { + QaQueContent queContent = (QaQueContent) o; + + // if the object does not exist yet, then just return any one of 0, -1, 1. Should not make a difference. + /* + * if (uid == null) return 1; else return (int) (uid.longValue() - queContent.uid.longValue()); */ - public Long getQaContentId() { - return qaContentId; - } - /** - * @param qaContentId The qaContentId to set. - */ - public void setQaContentId(Long qaContentId) { - this.qaContentId = qaContentId; - } - /** - * @return Returns the uid. - */ - public Long getUid() { - return uid; - } - /** - * @param uid The uid to set. - */ - public void setUid(Long uid) { - this.uid = uid; - } - + return 1; + } + /** - * @param isOptional The isOptional to set. + * @return Returns the qaContentId. */ + public Long getQaContentId() { + return qaContentId; + } + + /** + * @param qaContentId + * The qaContentId to set. + */ + public void setQaContentId(Long qaContentId) { + this.qaContentId = qaContentId; + } + + /** + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @param isOptional + * The isOptional to set. + */ public void setOptional(boolean isOptional) { - this.isOptional = isOptional; + this.isOptional = isOptional; } + /** * @return Returns the feedback. */ public String getFeedback() { - return feedback; + return feedback; } + /** - * @param feedback The feedback to set. + * @param feedback + * The feedback to set. */ public void setFeedback(String feedback) { - this.feedback = feedback; + this.feedback = feedback; } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java,v diff -u -r1.2 -r1.3 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 1 Oct 2008 06:02:21 -0000 1.2 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 4 Oct 2008 02:45:44 -0000 1.3 @@ -39,6 +39,7 @@ import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaUsrResp; /** @@ -137,12 +138,15 @@ Set questions = taskList.getQaQueContents(); String[] answers = new String[questions.size()]; for (QaQueContent question : questions) { - List attempts = qaService.getAttemptsForUserAndQuestionContent(learnerId, question - .getQaContentId()); + QaQueUsr user = qaService.getQaQueUsrById(learnerId); + List attempts = null; + if (user != null) { + attempts = qaService.getAttemptsForUserAndQuestionContent(user.getUid(), question.getQaContentId()); + } if (attempts != null && !attempts.isEmpty()) { // only the last attempt is taken into consideration String answer = attempts.get(attempts.size() - 1).getAnswer(); - answers[question.getDisplayOrder()] = answer; + answers[question.getDisplayOrder() - 1] = answer; } } return new ToolOutput(name, getI18NText(QaAppConstants.TEXT_SEARCH_DEFINITION_NAME, true), answers, false); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java 30 Sep 2008 05:54:57 -0000 1.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAuthoringConditionAction.java 4 Oct 2008 02:45:44 -0000 1.2 @@ -351,7 +351,7 @@ HttpServletRequest request) { form.populateForm(condition); if (orderId >= 0) { - form.setOrderId(new Integer(orderId)); + form.setOrderId(orderId + 1); } Integer[] selectedItems = new Integer[condition.temporaryQuestionDTOSet.size()]; @@ -423,7 +423,8 @@ conditionSet.add(condition); } else { // edit List conditionList = new ArrayList(conditionSet); - condition = conditionList.get(orderId); + condition = conditionList.get(orderId - 1); + form.extractCondition(condition); } Integer[] selectedItems = form.getSelectedItems(); @@ -437,6 +438,7 @@ } } } + } /** @@ -461,7 +463,7 @@ SortedSet conditionSet = getQaConditionSet(sessionMap); for (QaCondition condition : conditionSet) { if (formConditionName.equals(condition.getDisplayName()) - && !formConditionOrderId.equals(condition.getOrderId() - 1)) { + && !formConditionOrderId.equals(condition.getOrderId())) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.condition.duplicated.name")); break; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaConditionForm.java,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java 30 Sep 2008 05:54:57 -0000 1.1 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaConditionForm.java 4 Oct 2008 02:45:44 -0000 1.2 @@ -104,4 +104,13 @@ return new QaCondition(null, null, getOrderId(), null, getDisplayName(), "OUTPUT_COMPLEX", null, null, null, getAllWords(), getPhrase(), getAnyWords(), getExcludedWords(), null); } + + public void extractCondition(QaCondition condition) { + condition.setOrderId(getOrderId()); + condition.setDisplayName(getDisplayName()); + condition.setAllWords(getAllWords()); + condition.setPhrase(getPhrase()); + condition.setAnyWords(getAnyWords()); + condition.setExcludedWords(getExcludedWords()); + } } \ No newline at end of file Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java,v diff -u -r1.65 -r1.66 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 30 Sep 2008 05:54:57 -0000 1.65 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 4 Oct 2008 02:45:44 -0000 1.66 @@ -165,35 +165,32 @@ * * @author Ozgur Demirtas * - * TODO To change the template for this generated type comment go to Window - - * Preferences - Java - Code Style - Code Templates + * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code + * Templates * * A Map data structure is used to present the UI. */ public class QaStarterAction extends Action implements QaAppConstants { static Logger logger = Logger.getLogger(QaStarterAction.class.getName()); @Override - public ActionForward execute(ActionMapping mapping, ActionForm form, - HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, QaApplicationException { + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, QaApplicationException { QaUtils.cleanUpSessionAbsolute(request); QaStarterAction.logger.debug("init authoring mode."); QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; QaStarterAction.logger.debug("qaAuthoringForm: " + qaAuthoringForm); - String contentFolderID = WebUtil.readStrParam(request, - AttributeNames.PARAM_CONTENT_FOLDER_ID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); QaStarterAction.logger.debug("contentFolderID: " + contentFolderID); qaAuthoringForm.setContentFolderID(contentFolderID); QaGeneralAuthoringDTO qaGeneralAuthoringDTO = new QaGeneralAuthoringDTO(); qaGeneralAuthoringDTO.setContentFolderID(contentFolderID); Map mapQuestionContent = new TreeMap(new QaComparator()); - QaStarterAction.logger.debug("mapQuestionContent: " - + mapQuestionContent); + QaStarterAction.logger.debug("mapQuestionContent: " + mapQuestionContent); qaAuthoringForm.resetRadioBoxes(); @@ -203,45 +200,36 @@ qaService = qaAuthoringForm.getQaService(); } else { QaStarterAction.logger.debug("obtaining qaService via proxy"); - qaService = QaServiceProxy.getQaService(getServlet() - .getServletContext()); + qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); } QaStarterAction.logger.debug("qaService: " + qaService); qaGeneralAuthoringDTO.setCurrentTab("1"); QaStarterAction.logger.debug("setting currrent tab to 1:"); - qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean( - false).toString()); + qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(false).toString()); String servletPath = request.getServletPath(); QaStarterAction.logger.debug("getServletPath: " + servletPath); String requestedModule = null; if (servletPath.indexOf("authoringStarter") > 0) { QaStarterAction.logger.debug("request is for authoring module"); qaGeneralAuthoringDTO.setActiveModule(QaAppConstants.AUTHORING); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true) - .toString()); - qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(true) - .toString()); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(true).toString()); qaAuthoringForm.setActiveModule(QaAppConstants.AUTHORING); requestedModule = QaAppConstants.AUTHORING; } else { QaStarterAction.logger .debug("request is for define later module either direcly from define later url or monitoring url"); qaGeneralAuthoringDTO.setActiveModule(QaAppConstants.DEFINE_LATER); - qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true) - .toString()); - qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(false) - .toString()); + qaGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + qaGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(false).toString()); qaAuthoringForm.setActiveModule(QaAppConstants.DEFINE_LATER); requestedModule = QaAppConstants.DEFINE_LATER; if (servletPath.indexOf("monitoring") > 0) { - QaStarterAction.logger - .debug("request is from monitoring url."); - qaGeneralAuthoringDTO - .setMonitoringOriginatedDefineLater(new Boolean(true) - .toString()); + QaStarterAction.logger.debug("request is from monitoring url."); + qaGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(true).toString()); } } QaStarterAction.logger.debug("requestedModule: " + requestedModule); @@ -250,40 +238,33 @@ /* in development this needs to be called only once. */ /* QaUtils.configureContentRepository(request); */ - String sourceMcStarter = (String) request - .getAttribute(QaAppConstants.SOURCE_MC_STARTER); + String sourceMcStarter = (String) request.getAttribute(QaAppConstants.SOURCE_MC_STARTER); QaStarterAction.logger.debug("sourceMcStarter: " + sourceMcStarter); - boolean validateSignature = readSignature(request, mapping, qaService, - qaGeneralAuthoringDTO, qaAuthoringForm); - QaStarterAction.logger - .debug("validateSignature: " + validateSignature); + boolean validateSignature = readSignature(request, mapping, qaService, qaGeneralAuthoringDTO, qaAuthoringForm); + QaStarterAction.logger.debug("validateSignature: " + validateSignature); if (validateSignature == false) { QaStarterAction.logger.debug("error during validation"); } /* mark the http session as an authoring activity */ - qaGeneralAuthoringDTO - .setTargetMode(QaAppConstants.TARGET_MODE_AUTHORING); + qaGeneralAuthoringDTO.setTargetMode(QaAppConstants.TARGET_MODE_AUTHORING); /* - * find out whether the request is coming from monitoring module for - * EditActivity tab or from authoring environment url + * find out whether the request is coming from monitoring module for EditActivity tab or from authoring + * environment url */ - QaStarterAction.logger - .debug("no problems getting the default content, will render authoring screen"); + QaStarterAction.logger.debug("no problems getting the default content, will render authoring screen"); String strToolContentID = ""; /* the authoring url must be passed a tool content id */ - strToolContentID = request - .getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); QaStarterAction.logger.debug("strToolContentID: " + strToolContentID); qaGeneralAuthoringDTO.setToolContentID(strToolContentID); SessionMap sessionMap = new SessionMap(); List sequentialCheckedCa = new LinkedList(); sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, new ArrayList()); - sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, - new ArrayList()); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, ""); sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, ""); qaAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); @@ -294,51 +275,41 @@ // request.getSession().getAttribute(TOOL_CONTENT_ID); if (strToolContentID == null) { /* - * it is possible that the original request for authoring module is - * coming from monitoring url which keeps the TOOL_CONTENT_ID in the - * session + * it is possible that the original request for authoring module is coming from monitoring url which keeps + * the TOOL_CONTENT_ID in the session */ - QaStarterAction.logger - .debug("strToolContentID is null, handle this"); + QaStarterAction.logger.debug("strToolContentID is null, handle this"); - Long toolContentID = (Long) request.getSession().getAttribute( - QaAppConstants.TOOL_CONTENT_ID); + Long toolContentID = (Long) request.getSession().getAttribute(QaAppConstants.TOOL_CONTENT_ID); QaStarterAction.logger.debug("toolContentID: " + toolContentID); if (toolContentID != null) { strToolContentID = toolContentID.toString(); - QaStarterAction.logger - .debug("cached strToolContentID from the session: " - + strToolContentID); + QaStarterAction.logger.debug("cached strToolContentID from the session: " + strToolContentID); } else { QaStarterAction.logger .debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available from the url or the session."); /* use default content instead of giving a warning */ defaultContentId = qaAuthoringForm.getDefaultContentIdStr(); - QaStarterAction.logger.debug("using MCQ defaultContentId: " - + defaultContentId); + QaStarterAction.logger.debug("using MCQ defaultContentId: " + defaultContentId); strToolContentID = defaultContentId; } } - QaStarterAction.logger.debug("final strToolContentID: " - + strToolContentID); + QaStarterAction.logger.debug("final strToolContentID: " + strToolContentID); if (strToolContentID == null || strToolContentID.equals("")) { QaUtils.cleanUpSessionAbsolute(request); - QaStarterAction.logger.debug("forwarding to: " - + QaAppConstants.ERROR_LIST); + QaStarterAction.logger.debug("forwarding to: " + QaAppConstants.ERROR_LIST); return mapping.findForward(QaAppConstants.ERROR_LIST); } qaAuthoringForm.setToolContentID(strToolContentID); /* - * find out if the passed tool content id exists in the db present user - * either a first timer screen with default content data or fetch the - * existing content. + * find out if the passed tool content id exists in the db present user either a first timer screen with default + * content data or fetch the existing content. * - * if the toolcontentid does not exist in the db, create the default - * Map, there is no need to check if the content is locked in this case. - * It is always unlocked since it is the default content. + * if the toolcontentid does not exist in the db, create the default Map, there is no need to check if the + * content is locked in this case. It is always unlocked since it is the default content. */ String defaultContentIdStr = null; @@ -347,110 +318,80 @@ QaStarterAction.logger.debug("getting default content"); /* fetch default content */ defaultContentIdStr = qaAuthoringForm.getDefaultContentIdStr(); - QaStarterAction.logger.debug("defaultContentIdStr:" - + defaultContentIdStr); - qaContent = retrieveContent(request, mapping, qaAuthoringForm, - mapQuestionContent, new Long(defaultContentIdStr) - .longValue(), true, qaService, - qaGeneralAuthoringDTO, sessionMap); + QaStarterAction.logger.debug("defaultContentIdStr:" + defaultContentIdStr); + qaContent = retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, new Long( + defaultContentIdStr).longValue(), true, qaService, qaGeneralAuthoringDTO, sessionMap); QaStarterAction.logger.debug("post retrive content :" + sessionMap); } else { QaStarterAction.logger.debug("getting existing content"); /* it is possible that the content is in use by learners. */ - qaContent = qaService - .loadQa(new Long(strToolContentID).longValue()); + qaContent = qaService.loadQa(new Long(strToolContentID).longValue()); QaStarterAction.logger.debug("qaContent: " + qaContent); if (qaService.studentActivityOccurredGlobal(qaContent)) { QaUtils.cleanUpSessionAbsolute(request); - QaStarterAction.logger - .debug("student activity occurred on this content:" - + qaContent); + QaStarterAction.logger.debug("student activity occurred on this content:" + qaContent); persistError(request, "error.content.inUse"); - QaStarterAction.logger - .debug("add error.content.inUse to ActionMessages."); + QaStarterAction.logger.debug("add error.content.inUse to ActionMessages."); return mapping.findForward(QaAppConstants.ERROR_LIST); } - qaContent = retrieveContent(request, mapping, qaAuthoringForm, - mapQuestionContent, new Long(strToolContentID).longValue(), - false, qaService, qaGeneralAuthoringDTO, sessionMap); + qaContent = retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, new Long( + strToolContentID).longValue(), false, qaService, qaGeneralAuthoringDTO, sessionMap); QaStarterAction.logger.debug("post retrive content :" + sessionMap); } - QaStarterAction.logger - .debug("qaGeneralAuthoringDTO.getOnlineInstructions() :" - + qaGeneralAuthoringDTO.getOnlineInstructions()); - QaStarterAction.logger - .debug("qaGeneralAuthoringDTO.getOfflineInstructions():" - + qaGeneralAuthoringDTO.getOfflineInstructions()); + QaStarterAction.logger.debug("qaGeneralAuthoringDTO.getOnlineInstructions() :" + + qaGeneralAuthoringDTO.getOnlineInstructions()); + QaStarterAction.logger.debug("qaGeneralAuthoringDTO.getOfflineInstructions():" + + qaGeneralAuthoringDTO.getOfflineInstructions()); if (qaGeneralAuthoringDTO.getOnlineInstructions() == null || qaGeneralAuthoringDTO.getOnlineInstructions().length() == 0) { - qaGeneralAuthoringDTO - .setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); - qaAuthoringForm - .setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); - sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, - QaAppConstants.DEFAULT_ONLINE_INST); + qaGeneralAuthoringDTO.setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); + qaAuthoringForm.setOnlineInstructions(QaAppConstants.DEFAULT_ONLINE_INST); + sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, QaAppConstants.DEFAULT_ONLINE_INST); } if (qaGeneralAuthoringDTO.getOfflineInstructions() == null || qaGeneralAuthoringDTO.getOfflineInstructions().length() == 0) { - qaGeneralAuthoringDTO - .setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); - qaAuthoringForm - .setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); - sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, - QaAppConstants.DEFAULT_OFFLINE_INST); + qaGeneralAuthoringDTO.setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); + qaAuthoringForm.setOfflineInstructions(QaAppConstants.DEFAULT_OFFLINE_INST); + sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, QaAppConstants.DEFAULT_OFFLINE_INST); } - SortedSet conditionList = getTaskListConditionList(sessionMap); + SortedSet conditionList = getQaConditionList(sessionMap); conditionList.clear(); conditionList.addAll(qaContent.getConditions()); sessionMap.put(QaAppConstants.ATTR_QA_AUTHORING_FORM, qaAuthoringForm); - QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " - + qaGeneralAuthoringDTO); - QaStarterAction.logger.debug("will return to jsp with: " - + sourceMcStarter); - String destination = QaUtils.getDestination(sourceMcStarter, - requestedModule); + QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + QaStarterAction.logger.debug("will return to jsp with: " + sourceMcStarter); + String destination = QaUtils.getDestination(sourceMcStarter, requestedModule); QaStarterAction.logger.debug("destination: " + destination); - Map mapQuestionContentLocal = qaGeneralAuthoringDTO - .getMapQuestionContent(); - QaStarterAction.logger.debug("mapQuestionContentLocal: " - + mapQuestionContentLocal); + Map mapQuestionContentLocal = qaGeneralAuthoringDTO.getMapQuestionContent(); + QaStarterAction.logger.debug("mapQuestionContentLocal: " + mapQuestionContentLocal); - QaStarterAction.logger.debug("mapQuestionContent: " - + mapQuestionContent); - sessionMap.put(QaAppConstants.MAP_QUESTION_CONTENT_KEY, - mapQuestionContent); + QaStarterAction.logger.debug("mapQuestionContent: " + mapQuestionContent); + sessionMap.put(QaAppConstants.MAP_QUESTION_CONTENT_KEY, mapQuestionContent); - QaStarterAction.logger.debug("persisting sessionMap into session: " - + sessionMap); - request.getSession() - .setAttribute(sessionMap.getSessionID(), sessionMap); + QaStarterAction.logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - QaStarterAction.logger.debug("before fwding to jsp, qaAuthoringForm : " - + qaAuthoringForm); - QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " - + qaGeneralAuthoringDTO); - request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, - qaGeneralAuthoringDTO); + QaStarterAction.logger.debug("before fwding to jsp, qaAuthoringForm : " + qaAuthoringForm); + QaStarterAction.logger.debug("final qaGeneralAuthoringDTO: " + qaGeneralAuthoringDTO); + request.setAttribute(QaAppConstants.QA_GENERAL_AUTHORING_DTO, qaGeneralAuthoringDTO); return mapping.findForward(destination); } /** - * retrives the existing content information from the db and prepares the - * data for presentation purposes. ActionForward - * retrieveExistingContent(HttpServletRequest request, ActionMapping - * mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long - * toolContentID) + * retrives the existing content information from the db and prepares the data for presentation purposes. + * ActionForward retrieveExistingContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm + * qaAuthoringForm, Map mapQuestionContent, long toolContentID) * * @param request * @param mapping @@ -459,66 +400,50 @@ * @param toolContentID * @return ActionForward */ - protected QaContent retrieveContent(HttpServletRequest request, - ActionMapping mapping, QaAuthoringForm qaAuthoringForm, - Map mapQuestionContent, long toolContentID, - boolean isDefaultContent, IQaService qaService, - QaGeneralAuthoringDTO qaGeneralAuthoringDTO, SessionMap sessionMap) { + protected QaContent retrieveContent(HttpServletRequest request, ActionMapping mapping, + QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentID, boolean isDefaultContent, + IQaService qaService, QaGeneralAuthoringDTO qaGeneralAuthoringDTO, SessionMap sessionMap) { QaStarterAction.logger.debug("starting retrieveContent: " + qaService); QaStarterAction.logger.debug("toolContentID: " + toolContentID); QaStarterAction.logger.debug("isDefaultContent: " + isDefaultContent); - QaStarterAction.logger - .debug("getting content with id:" + toolContentID); + QaStarterAction.logger.debug("getting content with id:" + toolContentID); QaContent qaContent = qaService.retrieveQa(toolContentID); QaStarterAction.logger.debug("QaContent: " + qaContent); QaUtils.populateAuthoringDTO(request, qaContent, qaGeneralAuthoringDTO); - qaAuthoringForm.setUsernameVisible(qaContent.isUsernameVisible() ? "1" - : "0"); - qaAuthoringForm - .setShowOtherAnswers(qaContent.isShowOtherAnswers() ? "1" : "0"); - qaAuthoringForm.setSynchInMonitor(qaContent.isSynchInMonitor() ? "1" - : "0"); - qaAuthoringForm - .setQuestionsSequenced(qaContent.isQuestionsSequenced() ? "1" - : "0"); - qaAuthoringForm - .setLockWhenFinished(qaContent.isLockWhenFinished() ? "1" : "0"); + qaAuthoringForm.setUsernameVisible(qaContent.isUsernameVisible() ? "1" : "0"); + qaAuthoringForm.setShowOtherAnswers(qaContent.isShowOtherAnswers() ? "1" : "0"); + qaAuthoringForm.setSynchInMonitor(qaContent.isSynchInMonitor() ? "1" : "0"); + qaAuthoringForm.setQuestionsSequenced(qaContent.isQuestionsSequenced() ? "1" : "0"); + qaAuthoringForm.setLockWhenFinished(qaContent.isLockWhenFinished() ? "1" : "0"); qaGeneralAuthoringDTO.setReflect(qaContent.isReflect() ? "1" : "0"); - QaStarterAction.logger.debug("QaContent isReflect: " - + qaContent.isReflect()); + QaStarterAction.logger.debug("QaContent isReflect: " + qaContent.isReflect()); qaAuthoringForm.setReflect(qaContent.isReflect() ? "1" : "0"); qaAuthoringForm.setReflectionSubject(qaContent.getReflectionSubject()); - qaGeneralAuthoringDTO.setReflectionSubject(qaContent - .getReflectionSubject()); + qaGeneralAuthoringDTO.setReflectionSubject(qaContent.getReflectionSubject()); List attachmentList = qaService.retrieveQaUploadedFiles(qaContent); qaGeneralAuthoringDTO.setAttachmentList(attachmentList); qaGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); sessionMap.put(QaAppConstants.ATTACHMENT_LIST_KEY, attachmentList); - sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, - new ArrayList()); + sessionMap.put(QaAppConstants.DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); - qaGeneralAuthoringDTO.setIsDefineLater(new Boolean(qaContent - .isDefineLater()).toString()); + qaGeneralAuthoringDTO.setIsDefineLater(new Boolean(qaContent.isDefineLater()).toString()); qaGeneralAuthoringDTO.setActivityTitle(qaContent.getTitle()); qaAuthoringForm.setTitle(qaContent.getTitle()); - qaGeneralAuthoringDTO.setActivityInstructions(qaContent - .getInstructions()); + qaGeneralAuthoringDTO.setActivityInstructions(qaContent.getInstructions()); qaAuthoringForm.setInstructions(qaContent.getInstructions()); - sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaGeneralAuthoringDTO - .getActivityTitle()); - sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, - qaGeneralAuthoringDTO.getActivityInstructions()); + sessionMap.put(QaAppConstants.ACTIVITY_TITLE_KEY, qaGeneralAuthoringDTO.getActivityTitle()); + sessionMap.put(QaAppConstants.ACTIVITY_INSTRUCTIONS_KEY, qaGeneralAuthoringDTO.getActivityInstructions()); List listQuestionContentDTO = new LinkedList(); @@ -529,180 +454,136 @@ mapQuestionContent.clear(); Iterator queIterator = qaContent.getQaQueContents().iterator(); Long mapIndex = new Long(1); - QaStarterAction.logger.debug("mapQuestionContent: " - + mapQuestionContent); + QaStarterAction.logger.debug("mapQuestionContent: " + mapQuestionContent); while (queIterator.hasNext()) { QaQuestionContentDTO qaQuestionContentDTO = new QaQuestionContentDTO(); QaQueContent qaQueContent = (QaQueContent) queIterator.next(); if (qaQueContent != null) { - QaStarterAction.logger.debug("question: " - + qaQueContent.getQuestion()); - QaStarterAction.logger.debug("displayorder: " - + new Integer(qaQueContent.getDisplayOrder()) - .toString()); - QaStarterAction.logger.debug("feedback: " - + qaQueContent.getFeedback()); + QaStarterAction.logger.debug("question: " + qaQueContent.getQuestion()); + QaStarterAction.logger.debug("displayorder: " + new Integer(qaQueContent.getDisplayOrder()).toString()); + QaStarterAction.logger.debug("feedback: " + qaQueContent.getFeedback()); - mapQuestionContent.put(mapIndex.toString(), qaQueContent - .getQuestion()); + mapQuestionContent.put(mapIndex.toString(), qaQueContent.getQuestion()); qaQuestionContentDTO.setQuestion(qaQueContent.getQuestion()); - qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent - .getDisplayOrder()).toString()); + qaQuestionContentDTO.setDisplayOrder(new Integer(qaQueContent.getDisplayOrder()).toString()); qaQuestionContentDTO.setFeedback(qaQueContent.getFeedback()); listQuestionContentDTO.add(qaQuestionContentDTO); /** * make the first entry the default(first) one for jsp */ if (mapIndex.longValue() == 1) { - qaGeneralAuthoringDTO - .setDefaultQuestionContent(qaQueContent - .getQuestion()); + qaGeneralAuthoringDTO.setDefaultQuestionContent(qaQueContent.getQuestion()); } mapIndex = new Long(mapIndex.longValue() + 1); } } - QaStarterAction.logger - .debug("Map initialized with existing contentid to: " - + mapQuestionContent); + QaStarterAction.logger.debug("Map initialized with existing contentid to: " + mapQuestionContent); - request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer( - mapQuestionContent.size())); + request.setAttribute(QaAppConstants.TOTAL_QUESTION_COUNT, new Integer(mapQuestionContent.size())); - QaStarterAction.logger.debug("listQuestionContentDTO: " - + listQuestionContentDTO); - request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, - listQuestionContentDTO); - sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, - listQuestionContentDTO); + QaStarterAction.logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(QaAppConstants.LIST_QUESTION_CONTENT_DTO, listQuestionContentDTO); + sessionMap.put(QaAppConstants.LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - SortedSet conditionSet = new TreeSet( - new QaConditionComparator()); + SortedSet conditionSet = new TreeSet(new QaConditionComparator()); for (QaCondition condition : qaContent.getConditions()) { conditionSet.add(condition); for (QaQuestionContentDTO dto : (List) listQuestionContentDTO) { - if (dto.getDisplayOrder().equals( - String.valueOf(condition.getOrderId()))) { - condition.temporaryQuestionDTOSet.add(dto); + for (QaQueContent question : condition.getQuestions()) { + if (dto.getDisplayOrder().equals(String.valueOf(question.getDisplayOrder()))) { + condition.temporaryQuestionDTOSet.add(dto); + } } } } sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, conditionSet); if (isDefaultContent) { QaStarterAction.logger.debug("overwriting default question."); - qaGeneralAuthoringDTO - .setDefaultQuestionContent("Sample Question 1?"); + qaGeneralAuthoringDTO.setDefaultQuestionContent("Sample Question 1?"); } - QaStarterAction.logger.debug("mapQuestionContent is:" - + mapQuestionContent); + QaStarterAction.logger.debug("mapQuestionContent is:" + mapQuestionContent); qaGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - QaStarterAction.logger.debug("qaContent.getOnlineInstructions():" - + qaContent.getOnlineInstructions()); - QaStarterAction.logger.debug("qaContent.getOfflineInstructions():" - + qaContent.getOfflineInstructions()); - qaGeneralAuthoringDTO.setOnlineInstructions(qaContent - .getOnlineInstructions()); - qaGeneralAuthoringDTO.setOfflineInstructions(qaContent - .getOfflineInstructions()); + QaStarterAction.logger.debug("qaContent.getOnlineInstructions():" + qaContent.getOnlineInstructions()); + QaStarterAction.logger.debug("qaContent.getOfflineInstructions():" + qaContent.getOfflineInstructions()); + qaGeneralAuthoringDTO.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaGeneralAuthoringDTO.setOfflineInstructions(qaContent.getOfflineInstructions()); - qaAuthoringForm - .setOnlineInstructions(qaContent.getOnlineInstructions()); - qaAuthoringForm.setOfflineInstructions(qaContent - .getOfflineInstructions()); - sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, qaContent - .getOnlineInstructions()); - sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, qaContent - .getOfflineInstructions()); + qaAuthoringForm.setOnlineInstructions(qaContent.getOnlineInstructions()); + qaAuthoringForm.setOfflineInstructions(qaContent.getOfflineInstructions()); + sessionMap.put(QaAppConstants.ONLINE_INSTRUCTIONS_KEY, qaContent.getOnlineInstructions()); + sessionMap.put(QaAppConstants.OFFLINE_INSTRUCTIONS_KEY, qaContent.getOfflineInstructions()); - QaStarterAction.logger.debug("ACTIVITY_TITLE_KEY set to:" - + sessionMap.get(QaAppConstants.ACTIVITY_TITLE_KEY)); + QaStarterAction.logger.debug("ACTIVITY_TITLE_KEY set to:" + sessionMap.get(QaAppConstants.ACTIVITY_TITLE_KEY)); qaAuthoringForm.resetUserAction(); QaStarterAction.logger.debug("returning qaContent:" + qaContent); return qaContent; } /** - * each tool has a signature. QA tool's signature is stored in MY_SIGNATURE. - * The default tool content id and other depending content ids are obtained - * in this method. if all the default content has been setup properly the - * method persists DEFAULT_CONTENT_ID in the session. + * each tool has a signature. QA tool's signature is stored in MY_SIGNATURE. The default tool content id and other + * depending content ids are obtained in this method. if all the default content has been setup properly the method + * persists DEFAULT_CONTENT_ID in the session. * * readSignature(HttpServletRequest request, ActionMapping mapping) * * @param request * @param mapping * @return ActionForward */ - public boolean readSignature(HttpServletRequest request, - ActionMapping mapping, IQaService qaService, - QaGeneralAuthoringDTO qaGeneralAuthoringDTO, - QaAuthoringForm qaAuthoringForm) { + public boolean readSignature(HttpServletRequest request, ActionMapping mapping, IQaService qaService, + QaGeneralAuthoringDTO qaGeneralAuthoringDTO, QaAuthoringForm qaAuthoringForm) { QaStarterAction.logger.debug("qaService: " + qaService); /* * retrieve the default content id based on tool signature */ long defaultContentID = 0; try { - QaStarterAction.logger - .debug("attempt retrieving tool with signatute : " - + QaAppConstants.MY_SIGNATURE); - defaultContentID = qaService - .getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); - QaStarterAction.logger.debug("retrieved tool default contentId: " - + defaultContentID); + QaStarterAction.logger.debug("attempt retrieving tool with signatute : " + QaAppConstants.MY_SIGNATURE); + defaultContentID = qaService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE); + QaStarterAction.logger.debug("retrieved tool default contentId: " + defaultContentID); if (defaultContentID == 0) { - QaStarterAction.logger - .debug("default content id has not been setup"); + QaStarterAction.logger.debug("default content id has not been setup"); return false; } } catch (Exception e) { - QaStarterAction.logger - .debug("error getting the default content id: " - + e.getMessage()); + QaStarterAction.logger.debug("error getting the default content id: " + e.getMessage()); persistError(request, "error.defaultContent.notSetup"); return false; } /* - * retrieve uid of the content based on default content id determined - * above + * retrieve uid of the content based on default content id determined above */ long contentUID = 0; try { - QaStarterAction.logger - .debug("retrieve uid of the content based on default content id determined above: " - + defaultContentID); + QaStarterAction.logger.debug("retrieve uid of the content based on default content id determined above: " + + defaultContentID); QaContent qaContent = qaService.loadQa(defaultContentID); if (qaContent == null) { - QaStarterAction.logger - .debug("Exception occured: No default content"); + QaStarterAction.logger.debug("Exception occured: No default content"); persistError(request, "error.defaultContent.notSetup"); return false; } QaStarterAction.logger.debug("using qaContent: " + qaContent); - QaStarterAction.logger.debug("using qaContent uid: " - + qaContent.getUid()); + QaStarterAction.logger.debug("using qaContent uid: " + qaContent.getUid()); contentUID = qaContent.getUid().longValue(); QaStarterAction.logger.debug("contentUID: " + contentUID); } catch (Exception e) { - QaStarterAction.logger - .debug("Exception occured: No default question content"); + QaStarterAction.logger.debug("Exception occured: No default question content"); persistError(request, "error.defaultContent.notSetup"); return false; } - QaStarterAction.logger.debug("QA tool has the default content id: " - + defaultContentID); - qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID) - .toString()); - qaAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID) - .toString()); + QaStarterAction.logger.debug("QA tool has the default content id: " + defaultContentID); + qaGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + qaAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID).toString()); return true; } @@ -712,8 +593,7 @@ * * @param long * toolContentID - * @return boolean determine whether a specific toolContentID exists in the - * db + * @return boolean determine whether a specific toolContentID exists in the db */ protected boolean existsContent(long toolContentID, IQaService qaService) { QaContent qaContent = qaService.loadQa(toolContentID); @@ -727,9 +607,8 @@ /** * bridges define later url request to authoring functionality * - * executeDefineLater(ActionMapping mapping, ActionForm form, - * HttpServletRequest request, HttpServletResponse response, IQaService - * qaService) throws IOException, ServletException, QaApplicationException + * executeDefineLater(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse + * response, IQaService qaService) throws IOException, ServletException, QaApplicationException * * @param mapping * @param form @@ -741,12 +620,10 @@ * @throws ServletException * @throws QaApplicationException */ - public ActionForward executeDefineLater(ActionMapping mapping, - QaAuthoringForm qaAuthoringForm, HttpServletRequest request, - HttpServletResponse response, IQaService qaService) - throws IOException, ServletException, QaApplicationException { - QaStarterAction.logger - .debug("calling execute..., qaService will be needed next."); + public ActionForward executeDefineLater(ActionMapping mapping, QaAuthoringForm qaAuthoringForm, + HttpServletRequest request, HttpServletResponse response, IQaService qaService) throws IOException, + ServletException, QaApplicationException { + QaStarterAction.logger.debug("calling execute..., qaService will be needed next."); return execute(mapping, qaAuthoringForm, request, response); } @@ -763,10 +640,8 @@ saveErrors(request, errors); } - private SortedSet getTaskListConditionList( - SessionMap sessionMap) { - SortedSet list = (SortedSet) sessionMap - .get(QaAppConstants.ATTR_CONDITION_SET); + private SortedSet getQaConditionList(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(QaAppConstants.ATTR_CONDITION_SET); if (list == null) { list = new TreeSet(new QaConditionComparator()); sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, list);