Index: lams_tool_laqa/.classpath
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/.classpath,v
diff -u -r1.11 -r1.12
--- lams_tool_laqa/.classpath 1 Jul 2009 14:16:33 -0000 1.11
+++ lams_tool_laqa/.classpath 18 Mar 2011 17:14:25 -0000 1.12
@@ -15,5 +15,5 @@
-
+
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.3 -r1.4
--- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml 21 Oct 2008 02:25:35 -0000 1.3
+++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaCondition.hbm.xml 18 Mar 2011 17:13:44 -0000 1.4
@@ -30,7 +30,7 @@
Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml,v
diff -u -r1.13 -r1.14
--- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 28 Feb 2011 12:21:58 -0000 1.13
+++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaContent.hbm.xml 18 Mar 2011 17:13:44 -0000 1.14
@@ -190,7 +190,7 @@
Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaQueContent.hbm.xml'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml,v
diff -u -r1.4 -r1.5
--- lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml 14 Feb 2007 11:17:21 -0000 1.4
+++ lams_tool_laqa/conf/hibernate/mappings/org/lamsfoundation/lams/tool/qa/QaQueUsr.hbm.xml 18 Mar 2011 17:13:44 -0000 1.5
@@ -55,15 +55,6 @@
access="property"
column="learnerFinished"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
questions = new TreeSet(new QaQueContentComparator());
+ private Set questions = new TreeSet(new QaQueContentComparator());
private static Logger log = Logger.getLogger(QaCondition.class);
- public SortedSet temporaryQuestionDTOSet = new TreeSet(
+ public SortedSet temporaryQuestionDTOSet = new TreeSet(
new QaQuestionContentDTOComparator());
public QaCondition() {
@@ -63,15 +65,15 @@
public QaCondition(QaConditionDTO conditionDTO) {
super(conditionDTO);
- for (QaQueContent question : conditionDTO.getQuestions()) {
- QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null,
- question.isRequired(), null, null, null);
+ for (QaQuestion question : conditionDTO.getQuestions()) {
+ QaQuestion questionCopy = new QaQuestion(question.getQuestion(), question.getDisplayOrder(), null,
+ question.isRequired(), null, null);
getQuestions().add(questionCopy);
}
}
public QaCondition(Long conditionId, Integer conditionUIID, Integer orderId, String name, String displayName,
- String allWords, String phrase, String anyWords, String excludedWords, Set questions) {
+ String allWords, String phrase, String anyWords, String excludedWords, Set questions) {
super(conditionId, conditionUIID, orderId, name, displayName, BranchCondition.OUTPUT_TYPE_COMPLEX, null, null,
null, allWords, phrase, anyWords, excludedWords);
setQuestions(questions);
@@ -87,7 +89,7 @@
// the condition "knows" it's an array of strings, i.e. user's answers
String[] answers = (String[]) value.getValue();
result = true;
- for (QaQueContent question : questions) {
+ for (QaQuestion question : questions) {
String textToMatch = answers[question.getDisplayOrder() - 1];
textToMatch = WebUtil.removeHTMLtags(textToMatch);
result &= matches(textToMatch);
@@ -104,11 +106,11 @@
return result;
}
- public Set getQuestions() {
+ public Set getQuestions() {
return questions;
}
- public void setQuestions(Set questions) {
+ public void setQuestions(Set questions) {
this.questions = questions;
}
@@ -117,7 +119,7 @@
*/
@Override
public Object clone() {
- Set questionsCopy = new TreeSet(new QaQueContentComparator());
+ Set questionsCopy = new TreeSet(new QaQueContentComparator());
questionsCopy.addAll(questions);
return new QaCondition(null, null, orderId, name, displayName, allWords, phrase, anyWords, excludedWords,
questionsCopy);
@@ -132,11 +134,11 @@
@Override
public QaCondition clone(int uiidOffset) {
Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset);
- Set questionsCopy = new TreeSet(new QaQueContentComparator());
+ Set questionsCopy = new TreeSet(new QaQueContentComparator());
- for (QaQueContent question : getQuestions()) {
- QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null,
- question.isRequired(), null, null, null);
+ for (QaQuestion question : getQuestions()) {
+ QaQuestion questionCopy = new QaQuestion(question.getQuestion(), question.getDisplayOrder(), null,
+ question.isRequired(), null, null);
questionsCopy.add(questionCopy);
}
return new QaCondition(null, newConditionUIID, orderId, name, displayName, allWords, phrase, anyWords,
@@ -150,9 +152,9 @@
*/
public QaCondition clone(QaContent qaContent) {
- Set questionsCopy = new TreeSet(new QaQueContentComparator());
- for (QaQueContent conditionQuestion : getQuestions()) {
- for (QaQueContent contentQuestion : (Set) qaContent.getQaQueContents()) {
+ Set questionsCopy = new TreeSet(new QaQueContentComparator());
+ for (QaQuestion conditionQuestion : getQuestions()) {
+ for (QaQuestion contentQuestion : (Set) qaContent.getQaQuestions()) {
if (conditionQuestion.getDisplayOrder() == contentQuestion.getDisplayOrder()) {
questionsCopy.add(contentQuestion);
}
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaConditionDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
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.24 -r1.25
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java 28 Feb 2011 12:21:57 -0000 1.24
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaContent.java 18 Mar 2011 17:11:39 -0000 1.25
@@ -124,7 +124,7 @@
private Date updateDate;
/** persistent field */
- private Set qaQueContents;
+ private Set qaQuestions;
/** persistent field */
private Set qaSessions;
@@ -166,7 +166,7 @@
this.reflectionSubject = reflectionSubject;
this.creationDate = creationDate;
this.updateDate = updateDate;
- this.qaQueContents = qaQueContents;
+ this.qaQuestions = qaQueContents;
this.qaSessions = qaSessions;
this.qaUploadedFiles = qaUploadedFiles;
this.conditions = conditions;
@@ -195,7 +195,7 @@
qa.getReflectionSubject(), qa.getCreationDate(), qa.getUpdateDate(), new TreeSet(), new TreeSet(),
new TreeSet(), new TreeSet(new TextSearchConditionComparator()), qa.isAllowRichEditor());
- newContent.setQaQueContents(qa.deepCopyQaQueContent(newContent));
+ newContent.setQaQuestions(qa.deepCopyQaQueContent(newContent));
newContent.setQaUploadedFiles(qa.deepCopyQaAttachments(toolContentHandler, newContent));
newContent.setConditions(qa.deepCopyConditions(newContent));
@@ -204,9 +204,9 @@
public Set deepCopyQaQueContent(QaContent newQaContent) {
Set newQaQueContent = new TreeSet();
- for (Iterator i = this.getQaQueContents().iterator(); i.hasNext();) {
- QaQueContent queContent = (QaQueContent) i.next();
- newQaQueContent.add(QaQueContent.newInstance(queContent, newQaContent));
+ for (Iterator i = this.getQaQuestions().iterator(); i.hasNext();) {
+ QaQuestion queContent = (QaQuestion) i.next();
+ newQaQueContent.add(QaQuestion.newInstance(queContent, newQaContent));
}
return newQaQueContent;
}
@@ -241,15 +241,15 @@
return new TreeSet();
}
- public Set getQaQueContents() {
- if (qaQueContents == null) {
- setQaQueContents(new TreeSet());
+ public Set getQaQuestions() {
+ if (qaQuestions == null) {
+ setQaQuestions(new TreeSet());
}
- return qaQueContents;
+ return qaQuestions;
}
- public void setQaQueContents(Set qaQueContents) {
- this.qaQueContents = qaQueContents;
+ public void setQaQuestions(Set qaQueContents) {
+ this.qaQuestions = qaQueContents;
}
public Set getQaSessions() {
Fisheye: Tag 1.10 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaGeneralAuthoringDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.8 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaMonitoredAnswersDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.11 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaMonitoredUserDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.16 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueContent.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java,v
diff -u -r1.12 -r1.13
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java 19 Feb 2009 04:25:01 -0000 1.12
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQueUsr.java 18 Mar 2011 17:11:39 -0000 1.13
@@ -24,10 +24,6 @@
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@@ -40,20 +36,15 @@
*
* @author Ozgur Demirtas
*
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
- */
-
-/**
- *
- * QaQueUsr Value Object The value object that maps to our model database table:
+ * The value object that maps to our model database table:
* tl_laqa11_que_usr The relevant hibernate mapping resides in: QaQueUsr.hbm.xml
*
* Represents tool users.
*/
-public class QaQueUsr implements Serializable, Comparable, Nullable {
- static Logger logger = Logger.getLogger(QaQueUsr.class.getName());
+public class QaQueUsr implements Serializable, Nullable {
+ private static final long serialVersionUID = -6768077344827699440L;
+
/** identifier field */
private Long uid;
@@ -74,57 +65,23 @@
private QaSession qaSession;
/** persistent field */
- private Long qaSessionId;
-
- /** persistent field */
- private QaQueContent qaQueContent;
-
- /** persistent field */
private Set qaUsrResps;
public QaQueUsr() {
};
/** full constructor */
- public QaQueUsr(Long queUsrId, String username, String fullname, QaQueContent qaQueContent, QaSession qaSession,
+ public QaQueUsr(Long queUsrId, String username, String fullname, QaSession qaSession,
Set qaUsrResps)
{
this.queUsrId = queUsrId;
this.username = username;
this.fullname = fullname;
- this.qaQueContent = qaQueContent;
this.qaSession = qaSession;
this.qaUsrResps = qaUsrResps;
}
- /** minimal constructor */
- public QaQueUsr(QaQueContent qaQueContent, QaSession qaSession, Set qaUsrResps)
-
- {
- this.qaQueContent = qaQueContent;
- this.qaSession = qaSession;
- this.qaUsrResps = qaUsrResps;
- }
-
- public QaQueUsr(Long queUsrId, String username, String fullname, QaQueContent qaQueContent, QaSession qaSession) {
- this.queUsrId = queUsrId;
- this.username = username;
- this.fullname = fullname;
- this.qaQueContent = qaQueContent;
- this.qaSession = qaSession;
- }
-
- public QaQueUsr(String username, String fullname, QaQueContent qaQueContent, QaSession qaSession, Set qaUsrResps)
-
- {
- this.username = username;
- this.fullname = fullname;
- this.qaQueContent = qaQueContent;
- this.qaSession = qaSession;
- this.qaUsrResps = qaUsrResps;
- }
-
/**
* Copy construtor; We copy all data except the hibernate id field.
*
@@ -133,8 +90,8 @@
* @return the survey question user object.
*/
public QaQueUsr newInstance(QaQueUsr queUsr) {
- return new QaQueUsr(queUsr.getQueUsrId(), queUsr.getUsername(), queUsr.getFullname(), queUsr.getQaQueContent(),
- queUsr.getQaSession(), queUsr.getQaUsrResps());
+ return new QaQueUsr(queUsr.getQueUsrId(), queUsr.getUsername(), queUsr.getFullname(), queUsr.getQaSession(),
+ queUsr.getQaUsrResps());
}
/**
@@ -153,21 +110,6 @@
}
/**
- * @return Returns the qaQueContent.
- */
- public QaQueContent getQaQueContent() {
- return qaQueContent;
- }
-
- /**
- * @param qaQueContent
- * The qaQueContent to set.
- */
- public void setQaQueContent(QaQueContent qaQueContent) {
- this.qaQueContent = qaQueContent;
- }
-
- /**
* @return Returns the qaSession.
*/
public QaSession getQaSession() {
@@ -238,192 +180,18 @@
if (!(other instanceof QaQueUsr))
return false;
QaQueUsr castOther = (QaQueUsr) other;
- return new EqualsBuilder().append(this.getQueUsrId(), castOther.getQueUsrId())
- //.append(this.getUserId(),castOther.getUserId())
- //.append(this.getQaQueContent(),castOther.getQaQueContent())
- .isEquals();
+ return new EqualsBuilder().append(this.getQueUsrId(), castOther.getQueUsrId()).isEquals();
}
public int hashCode() {
- return new HashCodeBuilder().append(getQueUsrId())
- //.append(getUserId())
- .toHashCode();
+ return new HashCodeBuilder().append(getQueUsrId()).toHashCode();
}
- //---------------------------------------------------------------------
- // Convenient Service Methods
- //---------------------------------------------------------------------
- /**
- * Check up question responsed by current user against a list user
- * responses. Return true
if
- *
- * @param responses
- * @return the validation result
- */
- public boolean checkUpQueUsrHas(List responses) {
- if (responses == null)
- throw new IllegalArgumentException("Invalid responses from " + this.getFullname()
- + ": Can't validate null responses" + "against current survey questions");
-
- //make defensive copy to avoid list mutation outside this class.
- ArrayList resps = new ArrayList(responses);
-
- for (Iterator i = resps.iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if (doesQueUserHas(resp))
- return true;
- }
- return false;
- }
-
- /**
- * The helper function to validate the availability of a user response for
- * this question user. The condition to return true is:
- * the requested response has a reference to a question user object and
- * reference id is the same as current question user object.
- *
- * @param response
- * the user response
- * @return the validation result
- */
- public boolean doesQueUserHas(QaUsrResp response) {
- if (response.getQaQueUser() == null)
- throw new IllegalArgumentException("Invalid response :" + " Can't validate the availability"
- + " of a response without the reference to a user");
-
- if (response.getQaQueUser().getQueUsrId() == null || this.getQueUsrId() == null)
- return false;
-
- if (this.getQueUsrId().equals(response.getQaQueUser().getQueUsrId()))
- return true;
- return false;
- }
-
- /**
- * @param responses
- * @param responseSet
- */
- public void removeResponseBy(ArrayList responses) {
- Set responseSet = new TreeSet(this.getQaUsrResps());
- //remove responses no longer exist.
- for (Iterator i = responseSet.iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if (!resp.doesRespExistIn(responses))
- this.getQaUsrResps().remove(resp);
- }
- }
-
- /**
- * Update the user responses of this question user object against a list of
- * new user responses.
- *
- * @param responses
- */
- public void updateQueUsr(List responses) {
- if (responses == null)
- throw new IllegalArgumentException("Invalid responses from " + this.getFullname()
- + ": Can't update null responses" + "against current survey questions");
-
- //make defensive copy to avoid list mutation outside this class.
- ArrayList resps = new ArrayList(responses);
- //clean up all the existing reponses
- removeResponseBy(resps);
- addNewResponsesBy(resps);
- updateExistingResp(resps);
- }
-
- /**
- * @param resps
- * @param responseList
- */
- public void addNewResponsesBy(ArrayList resps) {
- ArrayList responseList = new ArrayList(this.getQaUsrResps());
- //add all associated new responses into the current question user.
- for (Iterator i = resps.iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if (!resp.doesRespExistIn(responseList) && doesQueUserHas(resp))
- addUserResponse(resp);
- }
- }
-
- /**
- * @param responses
- * @param responseSet
- */
- public void updateExistingResp(ArrayList responses) {
- //update existing responses
- for (Iterator i = this.getQaUsrResps().iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if (resp.doesRespExistIn(responses))
- resp.updateResponseBy(responses);
- }
- }
-
- /**
- * @param resp
- */
- public void addUserResponse(QaUsrResp resp) {
- if (resp != null && !resp.isResponseValid())
- throw new IllegalArgumentException("Invalid response for update ");
-
- this.getQaUsrResps().add(resp);
- }
-
- /**
- * Get a list of user response Strings that are correspondent to the
- * authored defined candidate answers. Currently, we include the free text
- * answer to this category as well.
- *
- * @return the list of String user responses
- */
- public List getPredefinedResponse() {
- LinkedList responses = new LinkedList();
-
- for (Iterator i = this.getQaUsrResps().iterator(); i.hasNext();) {
- QaUsrResp res = (QaUsrResp) i.next();
- if (res.isPredefinedResponse()) {
- responses.add(res.getAnswer());
- }
- }
- return responses;
- }
-
- public String getOtherResponse() {
- for (Iterator i = this.getQaUsrResps().iterator(); i.hasNext();) {
- QaUsrResp res = (QaUsrResp) i.next();
- if (!res.isPredefinedResponse())
- return res.getAnswer();
- }
-
- return "";
- }
-
- public int compareTo(Object o) {
-
- QaQueUsr qUser = (QaQueUsr) o;
- return this.getQaQueContent().compareTo(qUser.getQaQueContent());
- }
-
public boolean isNull() {
return false;
}
/**
- * @return Returns the qaSessionId.
- */
- public Long getQaSessionId() {
- return qaSessionId;
- }
-
- /**
- * @param qaSessionId
- * The qaSessionId to set.
- */
- public void setQaSessionId(Long qaSessionId) {
- this.qaSessionId = qaSessionId;
- }
-
- /**
* @return Returns the uid.
*/
public Long getUid() {
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQuestion.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.4 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaQuestionContentDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java,v
diff -u -r1.12 -r1.13
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java 19 Feb 2009 04:25:01 -0000 1.12
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaSession.java 18 Mar 2011 17:11:38 -0000 1.13
@@ -75,9 +75,6 @@
/** persistent field */
private Set qaQueUsers;
- /** persistent field */
- private Long qaContentId;
-
public QaSession() {
};
@@ -185,14 +182,6 @@
return false;
}
- public Long getQaContentId() {
- return qaContentId;
- }
-
- public void setQaContentId(Long qaContentId) {
- this.qaContentId = qaContentId;
- }
-
public Long getUid() {
return uid;
}
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaStatsDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.8 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaStringComparator.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Attic/QaUploadedFile.java,v
diff -u -r1.15 -r1.16
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.java 19 Feb 2009 04:25:01 -0000 1.15
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUploadedFile.java 18 Mar 2011 17:11:39 -0000 1.16
@@ -31,7 +31,6 @@
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.contentrepository.ItemNotFoundException;
-import org.lamsfoundation.lams.contentrepository.NodeKey;
import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
@@ -44,9 +43,9 @@
*/
/**
- * QaQueContent Value Object The value object that maps to our model database
+ * QaQuestion 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
+ * QaQuestion.hbm.xml
*
* Holds question content within a particular content
*/
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java,v
diff -u -r1.10 -r1.11
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java 19 Feb 2009 04:25:01 -0000 1.10
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java 18 Mar 2011 17:11:39 -0000 1.11
@@ -25,8 +25,6 @@
import java.io.Serializable;
import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
@@ -52,77 +50,49 @@
private String answer;
/** nullable persistent field */
- private boolean hidden;
-
- /** nullable persistent field */
private Date attemptTime;
/** nullable persistent field */
- private QaQueContent qaQueContent;
+ private QaQuestion qaQuestion;
private boolean visible;
/** nullable persistent field */
- private Long qaQueContentId; //added to enable deletion by the resp dao
-
- /** nullable persistent field */
- private Long queUsrId; //added to enable deletion by the resp dao
-
- /** nullable persistent field */
private QaQueUsr qaQueUser;
/** nullable persistent field */
private String timezone;
/** full constructor */
- public QaUsrResp(Long responseId, String answer, boolean hidden, Date attemptTime, String timezone,
- QaQueContent qaQueContent, QaQueUsr qaQueUser) {
+ public QaUsrResp(Long responseId, String answer, Date attemptTime, String timezone,
+ QaQuestion qaQuestion, QaQueUsr qaQueUser) {
this.responseId = responseId;
this.answer = answer;
- this.hidden = hidden;
this.attemptTime = attemptTime;
this.timezone = timezone;
- this.qaQueContent = qaQueContent;
+ this.qaQuestion = qaQuestion;
this.qaQueUser = qaQueUser;
}
- public QaUsrResp(String answer, boolean hidden, Date attemptTime, String timezone, QaQueContent qaQueContent,
+ public QaUsrResp(String answer, Date attemptTime, String timezone, QaQuestion qaQuestion,
QaQueUsr qaQueUser) {
this.answer = answer;
- this.hidden = hidden;
this.attemptTime = attemptTime;
this.timezone = timezone;
- this.qaQueContent = qaQueContent;
+ this.qaQuestion = qaQuestion;
this.qaQueUser = qaQueUser;
}
- public QaUsrResp(String answer, boolean hidden, Date attemptTime, String timezone, QaQueContent qaQueContent,
+ public QaUsrResp(String answer, Date attemptTime, String timezone, QaQuestion qaQuestion,
QaQueUsr qaQueUser, boolean visible) {
this.answer = answer;
- this.hidden = hidden;
this.attemptTime = attemptTime;
this.timezone = timezone;
- this.qaQueContent = qaQueContent;
+ this.qaQuestion = qaQuestion;
this.qaQueUser = qaQueUser;
this.visible = visible;
}
- public QaUsrResp(String answer, boolean hidden, Date attemptTime, String timezone, QaQueContent qaQueContent,
- Long qaQueUsrUid) {
- this.answer = answer;
- this.hidden = hidden;
- this.attemptTime = attemptTime;
- this.timezone = timezone;
- this.qaQueContent = qaQueContent;
- this.queUsrId = qaQueUsrUid;
- }
-
- public QaUsrResp(String answer, Date attemptTime, QaQueContent question) {
- this.answer = answer;
- this.attemptTime = attemptTime;
- this.qaQueContent = question;
- }
-
/** default constructor */
public QaUsrResp() {
}
@@ -136,8 +106,8 @@
* @return the new qa user response cloned from original object
*/
public static QaUsrResp newInstance(QaUsrResp response) {
- return new QaUsrResp(response.getResponseId(), response.getAnswer(), response.isHidden(), response
- .getAttemptTime(), response.getTimezone(), response.getQaQueContent(), response.qaQueUser);
+ return new QaUsrResp(response.getResponseId(), response.getAnswer(), response
+ .getAttemptTime(), response.getTimezone(), response.getQaQuestion(), response.qaQueUser);
}
public String toString() {
@@ -187,18 +157,18 @@
}
/**
- * @return Returns the qaQueContent.
+ * @return Returns the qaQuestion.
*/
- public QaQueContent getQaQueContent() {
- return qaQueContent;
+ public QaQuestion getQaQuestion() {
+ return qaQuestion;
}
/**
- * @param qaQueContent
- * The qaQueContent to set.
+ * @param qaQuestion
+ * The qaQuestion to set.
*/
- public void setQaQueContent(QaQueContent qaQueContent) {
- this.qaQueContent = qaQueContent;
+ public void setQaQuestion(QaQuestion qaQuestion) {
+ this.qaQuestion = qaQuestion;
}
/**
@@ -231,74 +201,6 @@
this.responseId = responseId;
}
- /**
- * @param responses
- * @return
- */
- public boolean doesRespExistIn(List responses) {
- for (Iterator i = responses.iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if ((resp.getAnswer().trim()).equals(this.getAnswer().trim())
- && resp.getQaQueUser().getQueUsrId() == this.getQaQueUser().getQueUsrId())
- return true;
- }
- return false;
- }
-
- /**
- * @param responses
- */
- public void updateResponseBy(List responses) {
- for (Iterator i = responses.iterator(); i.hasNext();) {
- QaUsrResp resp = (QaUsrResp) i.next();
- if (resp.getQaQueUser().getQueUsrId() == this.getQaQueUser().getQueUsrId())
- // && resp.getQaAnsContent().getDisplayOrder()==this.getQaAnsContent().getDisplayOrder())
- this.updateResponse(resp);
-
- }
- }
-
- /**
- * The response is not valid if it doesn't have a reference to question
- * object and question user object.
- *
- * @param resp
- * the response to be validated
- * @return the validation result.
- */
- public boolean isResponseValid() {
- return this.getQaQueUser() != null && this.getQaQueContent() != null;
- // &&this.getQaAnsContent()!=null;
- }
-
- /**
- * Update current object according to the new response object.
- *
- * @param resp
- */
- public void updateResponse(QaUsrResp resp) {
- if (!resp.isResponseValid())
- throw new IllegalArgumentException("Invalid response for update ");
-
- this.setAnswer(resp.getAnswer());
- this.setAttemptTime(resp.getAttemptTime());
- this.setQaQueContent(resp.getQaQueContent());
-
- this.setQaQueUser(resp.getQaQueUser());
-
- }
-
- /**
- * Validate whether the current response is correspondent to an author
- * defined answer.
- *
- * @return boolean value
- */
- public boolean isPredefinedResponse() {
- //may need to add more logic here
- return false;
- }
-
public int compareTo(Object o) {
QaUsrResp response = (QaUsrResp) o;
@@ -311,51 +213,6 @@
}
/**
- * @return Returns the qaQueContentId.
- */
- public Long getQaQueContentId() {
- return qaQueContentId;
- }
-
- /**
- * @param qaQueContentId
- * The qaQueContentId to set.
- */
- public void setQaQueContentId(Long qaQueContentId) {
- this.qaQueContentId = qaQueContentId;
- }
-
- /**
- * @return Returns the queUsrId.
- */
- public Long getQueUsrId() {
- return queUsrId;
- }
-
- /**
- * @param queUsrId
- * The queUsrId to set.
- */
- public void setQueUsrId(Long queUsrId) {
- this.queUsrId = queUsrId;
- }
-
- /**
- * @return Returns the hidden.
- */
- public boolean isHidden() {
- return hidden;
- }
-
- /**
- * @param hidden
- * The hidden to set.
- */
- public void setHidden(boolean hidden) {
- this.hidden = hidden;
- }
-
- /**
* @return Returns the timezone.
*/
public String getTimezone() {
Fisheye: Tag 1.62 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java,v
diff -u -r1.3 -r1.4
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java 19 Feb 2009 04:25:01 -0000 1.3
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java 18 Mar 2011 17:11:39 -0000 1.4
@@ -24,8 +24,6 @@
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java,v
diff -u -r1.3 -r1.4
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java 19 Feb 2009 04:25:01 -0000 1.3
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java 18 Mar 2011 17:11:39 -0000 1.4
@@ -24,8 +24,6 @@
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
-import java.util.Set;
-import java.util.TreeSet;
import org.apache.log4j.Logger;
Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/ReflectionDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml,v
diff -u -r1.25 -r1.26
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml 28 Feb 2011 12:21:57 -0000 1.25
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/qaApplicationContext.xml 18 Mar 2011 17:11:39 -0000 1.26
@@ -41,7 +41,7 @@
-
+
@@ -80,7 +80,7 @@
-
+
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java,v
diff -u -r1.13 -r1.14
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java 9 Dec 2008 05:38:15 -0000 1.13
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaContentDAO.java 18 Mar 2011 17:11:39 -0000 1.14
@@ -32,12 +32,8 @@
*
*/
public interface IQaContentDAO {
- public QaContent getQaById(long qaId);
+ public QaContent getQaByContentId(long qaId);
- public QaContent loadQaById(long qaId);
-
- public QaContent getQaContentByUID(Long uid);
-
public QaContent getQaBySession(Long sessionId);
public void saveOrUpdateQa(QaContent qa);
@@ -54,8 +50,6 @@
public void removeAllQaSession(QaContent content);
- public int countUserResponsed(QaContent content);
-
public void deleteCondition(QaCondition condition);
public void removeQuestionsFromCache(QaContent qaContent);
Fisheye: Tag 1.19 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueContentDAO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java,v
diff -u -r1.16 -r1.17
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java 19 Feb 2009 04:04:31 -0000 1.16
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQueUsrDAO.java 18 Mar 2011 17:11:39 -0000 1.17
@@ -35,7 +35,6 @@
*
*/
public interface IQaQueUsrDAO {
- public QaQueUsr getQaUserByUID(Long uid);
public QaQueUsr getQaQueUsrById(long qaQueUsrId);
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaQuestionDAO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java,v
diff -u -r1.14 -r1.15
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java 19 Feb 2009 04:19:24 -0000 1.14
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaSessionDAO.java 18 Mar 2011 17:11:39 -0000 1.15
@@ -34,20 +34,11 @@
*
*/
public interface IQaSessionDAO {
- public int countSessionIncomplete();
- public int countSessionComplete();
-
public int countSessionComplete(QaContent qa);
public QaSession getQaSessionById(long qaSessionId);
- public List getToolSessionsForContent(QaContent qa);
-
- public QaSession getQaSessionOrNullById(long qaSessionId);
-
- public int studentActivityOccurred(QaContent qa);
-
public void CreateQaSession(QaSession session);
public void UpdateQaSession(QaSession session);
@@ -56,7 +47,5 @@
public List getSessionsFromContent(QaContent qaContent);
- public String getSessionNameById(long qaSessionId);
-
public List getSessionNamesFromContent(QaContent qaContent);
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java,v
diff -u -r1.13 -r1.14
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java 19 Feb 2009 04:19:24 -0000 1.13
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java 18 Mar 2011 17:11:39 -0000 1.14
@@ -23,8 +23,6 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.dao;
-import java.util.List;
-
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
/**
@@ -33,21 +31,16 @@
*
*/
public interface IQaUsrRespDAO {
- public void saveUserResponse(QaUsrResp resp);
- public QaUsrResp getAttemptByUID(Long uid);
-
public void updateUserResponse(QaUsrResp resp);
public void createUserResponse(QaUsrResp resp);
public void removeUserResponse(QaUsrResp resp);
- public void removeUserResponseByQaQueId(Long qaQueId);
+ public QaUsrResp getResponseById(Long responseId);
- public QaUsrResp retrieveQaUsrResp(long responseId);
-
- public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId);
-
- public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId);
+ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long questionId);
+
+ int getCountResponsesByQaContent(final Long qaContentId);
}
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/QaQueUsrDAO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaConfigItemDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaConfigItemDAO.java,v
diff -u -r1.1 -r1.2
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaConfigItemDAO.java 4 Nov 2008 00:41:19 -0000 1.1
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaConfigItemDAO.java 18 Mar 2011 17:11:38 -0000 1.2
@@ -26,8 +26,8 @@
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.lamsfoundation.lams.dao.hibernate.BaseDAO;
-import org.lamsfoundation.lams.tool.qa.dao.IQaConfigItemDAO;
import org.lamsfoundation.lams.tool.qa.QaConfigItem;
+import org.lamsfoundation.lams.tool.qa.dao.IQaConfigItemDAO;
import org.springframework.orm.hibernate3.HibernateCallback;
public class QaConfigItemDAO extends BaseDAO implements IQaConfigItemDAO {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java,v
diff -u -r1.20 -r1.21
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java 19 Feb 2009 23:59:13 -0000 1.20
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaContentDAO.java 18 Mar 2011 17:11:38 -0000 1.21
@@ -32,7 +32,7 @@
import org.hibernate.Session;
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.QaQuestion;
import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
@@ -41,8 +41,6 @@
/**
* @author Ozgur Demirtas
*
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
*/
public class QaContentDAO extends HibernateDaoSupport implements IQaContentDAO {
@@ -51,17 +49,7 @@
private static final String LOAD_QA_BY_SESSION = "select qa from QaContent qa left join fetch "
+ "qa.qaSessions session where session.qaSessionId=:sessionId";
- private static final String COUNT_USER_RESPONSED = "select distinct u.userId from QaQueUsr u left join fetch"
- + " u.qaQueContent as ques where ques.qaContent = :qa group by u.userId";
-
- public QaContentDAO() {
- }
-
- public QaContent getQaById(long qaId) {
- return loadQaById(qaId);
- }
-
- public QaContent loadQaById(long qaId) {
+ public QaContent getQaByContentId(long qaId) {
String query = "from QaContent as qa where qa.qaContentId = ?";
HibernateTemplate templ = this.getHibernateTemplate();
List list = getSession().createQuery(query).setLong(0, qaId).list();
@@ -73,10 +61,6 @@
return null;
}
- public QaContent getQaContentByUID(Long uid) {
- return (QaContent) this.getHibernateTemplate().get(QaContent.class, uid);
- }
-
public void updateQa(QaContent qa) {
this.getSession().setFlushMode(FlushMode.AUTO);
this.getHibernateTemplate().update(qa);
@@ -112,10 +96,6 @@
this.getHibernateTemplate().update(qa);
}
- public int countUserResponsed(QaContent qa) {
- return getHibernateTemplate().findByNamedParam(QaContentDAO.COUNT_USER_RESPONSED, "qa", qa).size();
- }
-
public void removeAllQaSession(QaContent qaContent) {
this.getHibernateTemplate().deleteAll(qaContent.getQaSessions());
}
@@ -153,7 +133,7 @@
public void removeQuestionsFromCache(QaContent qaContent) {
if (qaContent != null) {
- for (QaQueContent question : (Set) qaContent.getQaQueContents()) {
+ for (QaQuestion question : (Set) qaContent.getQaQuestions()) {
getHibernateTemplate().evict(question);
}
getHibernateTemplate().evict(qaContent);
Fisheye: Tag 1.23 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueContentDAO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java,v
diff -u -r1.23 -r1.24
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java 2 Jul 2009 08:19:22 -0000 1.23
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQueUsrDAO.java 18 Mar 2011 17:11:38 -0000 1.24
@@ -38,28 +38,19 @@
/**
* @author Ozgur Demirtas
*
- * TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code
- * Templates
*/
public class QaQueUsrDAO extends HibernateDaoSupport implements IQaQueUsrDAO {
static Logger logger = Logger.getLogger(QaQueUsrDAO.class.getName());
- private static final String COUNT_SESSION_USER = "select qaQueUsr.queUsrId from QaQueUsr qaQueUsr where qaQueUsr.qaSessionId= :qaSession";
- private static final String LOAD_USER_FOR_SESSION = "from qaQueUsr in class QaQueUsr where qaQueUsr.qaSessionId= :qaSessionId";
+ private static final String COUNT_SESSION_USER = "select qaQueUsr.queUsrId from QaQueUsr qaQueUsr where qaQueUsr.qaSession.qaSessionId= :qaSession";
+ private static final String LOAD_USER_FOR_SESSION = "from qaQueUsr in class QaQueUsr where qaQueUsr.qaSession.qaSessionId= :qaSessionId";
- private static final String GET_USER_COUNT_FOR_CONTENT = "select count(*) from QaQueUsr quser, QaSession qses, QaQueContent qcon where "
+ private static final String GET_USER_COUNT_FOR_CONTENT = "select count(*) from QaQueUsr quser, QaSession qses, QaQuestion qcon where "
+ "quser.qaSession=qses and " + "qses.qaContent=qcon and " + "qcon.uid=:uid";
- // select count(*) from tl_laqa11_que_usr quser, tl_laqa11_session qses where quser.qa_session_id=qses.uid and
- // qses.qa_content_id=5378;
-
- public QaQueUsr getQaUserByUID(Long uid) {
- return (QaQueUsr) this.getHibernateTemplate().get(QaQueUsr.class, uid);
- }
-
public int countSessionUser(QaSession qaSession) {
- return getHibernateTemplate().findByNamedParam(QaQueUsrDAO.COUNT_SESSION_USER, "qaSession", qaSession).size();
+ return (getHibernateTemplate().findByNamedParam(COUNT_SESSION_USER, "qaSession", qaSession)).size();
}
public QaQueUsr getQaQueUsrById(long qaQueUsrId) {
@@ -77,7 +68,7 @@
public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) {
- String strGetUser = "from qaQueUsr in class QaQueUsr where qaQueUsr.queUsrId=:queUsrId and qaQueUsr.qaSessionId=:qaSessionId";
+ String strGetUser = "from qaQueUsr in class QaQueUsr where qaQueUsr.queUsrId=:queUsrId and qaQueUsr.qaSession.qaSessionId=:qaSessionId";
HibernateTemplate templ = this.getHibernateTemplate();
List list = getSession().createQuery(strGetUser).setLong("queUsrId", queUsrId.longValue()).setLong(
"qaSessionId", qaSessionId.longValue()).list();
@@ -91,8 +82,8 @@
public List getUserBySessionOnly(final QaSession qaSession) {
HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(QaQueUsrDAO.LOAD_USER_FOR_SESSION).setLong("qaSessionId",
- qaSession.getUid().longValue()).list();
+ List list = getSession().createQuery(LOAD_USER_FOR_SESSION).setLong("qaSessionId",
+ qaSession.getQaSessionId().longValue()).list();
return list;
}
@@ -119,14 +110,13 @@
int returnInt = 0;
if (qa != null && qa.getUid() != null) {
- List result = getSession().createQuery(QaQueUsrDAO.GET_USER_COUNT_FOR_CONTENT).setLong("uid", qa.getUid())
- .list();
- Long resultLong = result.get(0) != null ? (Long) result.get(0) : new Long(0);
+ List result = getSession().createQuery(GET_USER_COUNT_FOR_CONTENT).setLong("uid", qa.getUid()).list();
+ Long resultLong = (result.get(0) != null) ? (Long) result.get(0) : new Long(0);
returnInt = resultLong.intValue();
} else {
- QaQueUsrDAO.logger.error("Attempt to count users from null content");
+ logger.error("Attempt to count users from null content");
}
- return returnInt;
+ return returnInt;
}
}
\ No newline at end of file
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaQuestionDAO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java,v
diff -u -r1.18 -r1.19
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java 19 Feb 2009 23:59:13 -0000 1.18
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java 18 Mar 2011 17:11:38 -0000 1.19
@@ -37,24 +37,10 @@
*
*/
public class QaSessionDAO extends HibernateDaoSupport implements IQaSessionDAO {
- private static final String COUNT_SESSION_INCOMPLITE = "select qaSession.session_status from QaSession qaSession where qaSession.session_status='INCOMPLETE' and qaSession.qaContentId = :qa";
- private static final String COUNT_SESSION_ACTIVITY = "select qaSession.session_status from QaSession qaSession where qaSession.qaContentId = :qa";
- private static final String GET_SESSION_IDS_FOR_CONTENT = "select qaSession.qaSessionId from QaSession qaSession where qaSession.qaContentId = :qa";
private static final String COUNT_SESSION_COMPLETE = "from qaSession in class QaSession where qaSession.session_status='COMPLETE'";
- private static final String COUNT_SESSION_INCOMPLETE = "from qaSession in class QaSession where qaSession.session_status='INCOMPLETE'";
private static final String GET_SESSIONS_FROM_CONTENT = "select qas.qaSessionId from QaSession qas where qas.qaContent=:qaContent order by qas.qaSessionId";
private static final String GET_SESSIONNAMES_FROM_CONTENT = "select qas.session_name from QaSession qas where qas.qaContent=:qaContent order by qas.qaSessionId";
- public int countSessionComplete() {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(COUNT_SESSION_COMPLETE).list();
-
- if (list != null && list.size() > 0) {
- return list.size();
- } else
- return 0;
- }
-
public int countSessionComplete(QaContent qa) {
HibernateTemplate templ = this.getHibernateTemplate();
List list = getSession().createQuery(COUNT_SESSION_COMPLETE).list();
@@ -66,30 +52,9 @@
++sessionCount;
}
}
- logger.debug("sessionCount: " + sessionCount);
return sessionCount;
}
- public int countSessionIncomplete() {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(COUNT_SESSION_INCOMPLETE).list();
-
- if (list != null && list.size() > 0) {
- return list.size();
- } else
- return 0;
- }
-
- public int studentActivityOccurred(QaContent qa) {
- return (getHibernateTemplate().findByNamedParam(COUNT_SESSION_ACTIVITY, "qa", qa)).size();
- }
-
- public List getToolSessionsForContent(QaContent qa) {
-
- List lisToolSessionIds = (getHibernateTemplate().findByNamedParam(GET_SESSION_IDS_FOR_CONTENT, "qa", qa));
- return lisToolSessionIds;
- }
-
/**
* @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#getSurveySessionById(long)
*/
@@ -105,22 +70,6 @@
return null;
}
- public String getSessionNameById(long qaSessionId) {
- String query = "from QaSession as qus where qus.qaSessionId = ?";
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(query).setLong(0, qaSessionId).list();
-
- if (list != null && list.size() > 0) {
- QaSession qus = (QaSession) list.get(0);
- return qus.getSession_name();
- }
- return null;
- }
-
- public QaSession getQaSessionOrNullById(long qaSessionId) {
- return getQaSessionById(qaSessionId);
- }
-
/**
* @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#CreateSurveySession(com.lamsinternational.tool.survey.domain.SurveySession)
*/
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/Attic/QaUploadedFileDAO.java,v
diff -u -r1.14 -r1.15
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java 19 Feb 2009 04:04:31 -0000 1.14
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUploadedFileDAO.java 18 Mar 2011 17:11:38 -0000 1.15
@@ -23,27 +23,21 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.dao.hibernate;
-import java.util.Iterator;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.FlushMode;
import org.lamsfoundation.lams.tool.qa.QaContent;
import org.lamsfoundation.lams.tool.qa.QaUploadedFile;
import org.lamsfoundation.lams.tool.qa.dao.IQaUploadedFileDAO;
-import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
* @author Ozgur Demirtas
*
- * TODO To change the template for this generated type comment go to Window -
- * Preferences - Java - Code Style - Code Templates
*/
public class QaUploadedFileDAO extends HibernateDaoSupport implements IQaUploadedFileDAO {
- static Logger logger = Logger.getLogger(QaUploadedFileDAO.class.getName());
-
private static final String GET_UPLOADED_FILES = "from QaUploadedFile qaUploadedFile where qaUploadedFile.qaContent.qaContentId = :contentId";
public QaUploadedFile getUploadedFileById(long submissionId) {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java,v
diff -u -r1.16 -r1.17
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java 19 Feb 2009 03:12:53 -0000 1.16
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java 18 Mar 2011 17:11:38 -0000 1.17
@@ -23,14 +23,11 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.dao.hibernate;
-import java.util.Iterator;
import java.util.List;
import org.hibernate.FlushMode;
-import org.lamsfoundation.lams.tool.qa.QaQueUsr;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO;
-import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
/**
@@ -39,44 +36,21 @@
*
*/
public class QaUsrRespDAO extends HibernateDaoSupport implements IQaUsrRespDAO {
- private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from qaUsrResp in class QaUsrResp where qaUsrResp.queUsrId=:queUsrId and qaUsrResp.qaQueContentId=:qaQueContentId";
+ private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION = "from qaUsrResp in class QaUsrResp where qaUsrResp.qaQueUser.queUsrId=:queUsrId and qaUsrResp.qaQuestion.uid=:questionId";
+
+ private static final String GET_COUNT_RESPONSES_BY_QACONTENT = "SELECT COUNT(*) from "
+ + QaUsrResp.class.getName() + " as r where r.qaQuestion.qaContent.qaContentId=?";
- public QaQueUsr getUserById(long userId) {
- return (QaQueUsr) this.getHibernateTemplate().load(QaQueUsr.class, new Long(userId));
-
- }
-
public void createUserResponse(QaUsrResp qaUsrResp) {
this.getSession().setFlushMode(FlushMode.AUTO);
this.getHibernateTemplate().save(qaUsrResp);
}
- public QaUsrResp retrieveQaUsrResp(long responseId) {
- return (QaUsrResp) this.getHibernateTemplate().get(QaUsrResp.class, new Long(responseId));
+ public QaUsrResp getResponseById(Long responseId) {
+ return (QaUsrResp) this.getHibernateTemplate().get(QaUsrResp.class, responseId);
}
- public QaUsrResp getAttemptByUID(Long uid) {
- String query = "from QaUsrResp attempt where attempt.responseId=?";
-
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(query).setLong(0, uid.longValue()).list();
-
- if (list != null && list.size() > 0) {
- QaUsrResp attempt = (QaUsrResp) list.get(0);
- return attempt;
- }
- return null;
- }
-
/**
- * @see org.lamsfoundation.lams.tool.qa.dao.interfaces.IQaUsrRespDAO#saveUserResponse(com.lamsinternational.tool.qa.domain.QaUsrResp)
- */
- public void saveUserResponse(QaUsrResp resp) {
- this.getSession().setFlushMode(FlushMode.AUTO);
- this.getHibernateTemplate().save(resp);
- }
-
- /**
* @see org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO#updateUserResponse(org.lamsfoundation.lams.tool.qa.QaUsrResp)
*/
public void updateUserResponse(QaUsrResp resp) {
@@ -89,40 +63,23 @@
this.getHibernateTemplate().delete(resp);
}
- public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT).setLong("queUsrId",
- queUsrId.longValue()).setLong("qaQueContentId", qaQueContentId.longValue()).list();
-
- return list;
- }
-
- public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId) {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT).setLong("queUsrId",
- queUsrId.longValue()).setLong("qaQueContentId", qaQueContentId.longValue()).list();
-
- if (list != null && list.size() > 0) {
- Iterator listIterator = list.iterator();
- while (listIterator.hasNext()) {
- QaUsrResp qaUsrResp = (QaUsrResp) listIterator.next();
- this.getSession().setFlushMode(FlushMode.AUTO);
- templ.delete(qaUsrResp);
- templ.flush();
- }
+ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long questionId) {
+ List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER_AND_QUESTION)
+ .setLong("queUsrId", queUsrId.longValue()).setLong("questionId", questionId.longValue()).list();
+ if (list == null || list.size() == 0) {
+ return null;
+ } else {
+ return (QaUsrResp) list.get(list.size() - 1);
}
}
-
- public void removeUserResponseByQaQueId(Long qaQueId) {
- if (qaQueId != null) {
- String query = "from resp in class org.lamsfoundation.lams.tool.qa.QaUsrResp"
- + " where resp.qaQueContentId = ?";
- Object obj = getSession().createQuery(query).setLong(0, qaQueId.longValue()).uniqueResult();
- if (obj != null) {
- this.getSession().setFlushMode(FlushMode.AUTO);
- getHibernateTemplate().delete(obj);
- }
+
+ public int getCountResponsesByQaContent(final Long qaContentId) {
+
+ List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_BY_QACONTENT, new Object[] { qaContentId });
+ if (list == null || list.size() == 0) {
+ return 0;
}
+ return ((Number) list.get(0)).intValue();
}
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20110217_updateTo236.sql
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20110217_updateTo236.sql,v
diff -u -r1.2 -r1.3
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20110217_updateTo236.sql 28 Feb 2011 12:21:58 -0000 1.2
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20110217_updateTo236.sql 18 Mar 2011 17:12:40 -0000 1.3
@@ -22,6 +22,8 @@
REFERENCES tl_laqa11_usr_resp (uid)
)TYPE=InnoDB;
+-- LDEV-2653 autosave feature
+ALTER TABLE tl_laqa11_usr_resp DROP COLUMN hidden;
UPDATE lams_tool SET tool_version = "20110217" WHERE tool_signature = "laqa11";
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/EditActivityDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralMonitoringDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaAllGroupsDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaMonitoredAnswersDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaMonitoredUserDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaStatsDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaWizardDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/ReflectionDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java,v
diff -u -r1.56 -r1.57
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 28 Feb 2011 12:21:57 -0000 1.56
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java 18 Mar 2011 17:12:41 -0000 1.57
@@ -33,18 +33,17 @@
import org.lamsfoundation.lams.tool.IToolVO;
import org.lamsfoundation.lams.tool.exception.DataMissingException;
import org.lamsfoundation.lams.tool.exception.ToolException;
-import org.lamsfoundation.lams.tool.qa.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.QaCondition;
import org.lamsfoundation.lams.tool.qa.QaConfigItem;
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.QaQuestion;
import org.lamsfoundation.lams.tool.qa.QaSession;
import org.lamsfoundation.lams.tool.qa.QaUploadedFile;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
import org.lamsfoundation.lams.tool.qa.QaWizardCategory;
import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO;
-import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.tool.qa.util.QaApplicationException;
import org.lamsfoundation.lams.util.audit.IAuditService;
/**
@@ -61,66 +60,49 @@
* @return the qa object
*/
- public QaContent retrieveQa(long toolContentId) throws QaApplicationException;
+ public QaContent getQa(long toolContentId) throws QaApplicationException;
- /**
- * Return the qa object according to the requested content id.
- *
- * @param toolContentId
- * the tool content id
- * @return the qa object or null
- */
-
- public QaContent loadQa(long toolContentId) throws QaApplicationException;
-
public void saveOrUpdateQa(QaContent qa) throws QaApplicationException;
- public QaContent getQaContentByUID(Long uid) throws QaApplicationException;
-
public int getTotalNumberOfUsers(QaContent qa) throws QaApplicationException;
public int countSessionComplete(QaContent qa) throws QaApplicationException;
- public int countSessionComplete() throws QaApplicationException;
-
public void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException;
+ public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException;
+
+ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId)
+ throws QaApplicationException;
+
/**
- * Return the question content object according to the requested question
- * content id.
+ * Creates or updates response with answer submitted by user.
*
- * @param qaQueContentId
- * qa question content id
- * @return the qa question object
+ * @param newAnswer
+ * @param toolSessionID
+ * @param questionDisplayOrder
*/
- public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException;
+ void updateResponseWithNewAnswer(String newAnswer, String toolSessionID, Long questionDisplayOrder);
- public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException;
+ public void createQaQue(QaQuestion qaQuestion) throws QaApplicationException;
- public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId)
- throws QaApplicationException;
+ public void removeQaQueContent(QaQuestion qaQuestion) throws QaApplicationException;
- public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException;
-
- public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException;
-
public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException;
public void updateUserResponse(QaUsrResp resp) throws QaApplicationException;
- public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException;
+ public QaUsrResp getResponseById(Long responseId) throws QaApplicationException;
- public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException;
-
- public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid)
+ public QaQuestion getQuestionContentByQuestionText(final String question, Long contentUid)
throws QaApplicationException;
- public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid)
+ public QaQuestion getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid)
throws QaApplicationException;
public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException;
- public void saveOrUpdateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException;
+ public void saveOrUpdateQaQueContent(QaQuestion qaQuestion) throws QaApplicationException;
/**
* Return the qa session object according to the requested session id.
@@ -131,65 +113,38 @@
*/
public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException;
- public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException;
+ public QaSession getSessionById(long qaSessionId) throws QaApplicationException;
public void createQaSession(QaSession qaSession) throws QaApplicationException;
public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException;
- public String getSessionNameById(long qaSessionId) throws QaApplicationException;
-
public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException;
public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException;
- public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException;
+ public QaQueUsr createUser(Long toolSessionID) throws QaApplicationException;
public void updateQaSession(QaSession qaSession) throws QaApplicationException;
- /**
- * Return the qa que user object according to the requested usr id.
- *
- * @param qaQaUsrId
- * qa usr id
- * @return the qa que usr object
- */
- public QaQueUsr retrieveQaQueUsr(long qaQaUsrId) throws QaApplicationException;
-
public QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException;
public void updateQa(QaContent qa) throws QaApplicationException;
public void createQa(QaContent qa) throws QaApplicationException;
- public QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException;
-
- public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId);
-
public void hideResponse(QaUsrResp qaUsrResp) throws QaApplicationException;
public void showResponse(QaUsrResp qaUsrResp) throws QaApplicationException;
- public void deleteQa(QaContent qa) throws QaApplicationException;
-
- public void deleteQaSession(QaSession QaSession) throws QaApplicationException;
-
public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException;
- public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException;
+ public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException;
- public void deleteQaById(Long qaId) throws QaApplicationException;
-
- public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException;
-
- public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException;
-
public void removeUserResponse(QaUsrResp resp) throws QaApplicationException;
public List getAllQuestionEntries(final Long uid) throws QaApplicationException;
- public User getCurrentUserData(String username) throws QaApplicationException;
-
public List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException;
/**
@@ -204,22 +159,9 @@
public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException;
- public void setAsForceComplete(Long userId) throws QaApplicationException;
+ public boolean isStudentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException;
- public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException;
-
- public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException;
-
- public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException;
-
/**
- * removeToolContent(Long toolContentId) return void
- *
- * @param toolContentId
- */
- public void removeToolContent(Long toolContentId) throws QaApplicationException;
-
- /**
* createToolSession(Long toolSessionId,String toolSessionName, Long
* toolContentId)
*
@@ -246,14 +188,6 @@
public long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException;
- public int countSessionUser(QaSession qaSession) throws QaApplicationException;
-
- public List getToolSessionsForContent(QaContent qa) throws QaApplicationException;
-
- public QaQueContent getToolDefaultQuestionContent(long contentId) throws QaApplicationException;
-
- public void configureContentRepository() throws QaApplicationException;
-
public ITicket getRepositoryLoginTicket() throws QaApplicationException;
public void deleteFromRepository(Long uuid, Long versionID) throws QaApplicationException;
@@ -269,8 +203,6 @@
public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException;
- public List retrieveQaQueContentsByToolContentId(long toolContentId);
-
public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry);
public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID);
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java,v
diff -u -r1.5 -r1.6
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java 24 Nov 2010 14:11:01 -0000 1.5
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java 18 Mar 2011 17:12:41 -0000 1.6
@@ -24,7 +24,7 @@
import org.lamsfoundation.lams.learningdesign.service.ToolContentVersionFilter;
import org.lamsfoundation.lams.tool.qa.QaContent;
-import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQuestion;
/**
* Import filter class for different versions of Q&A content.
@@ -42,7 +42,7 @@
}
public void up20081126To20101022() {
- this.removeField(QaQueContent.class, "isOptional");
- this.addField(QaQueContent.class, "required", new Boolean(false));
+ this.removeField(QaQuestion.class, "isOptional");
+ this.addField(QaQuestion.class, "required", new Boolean(false));
}
}
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.12 -r1.13
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 2 Aug 2009 20:14:02 -0000 1.12
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java 18 Mar 2011 17:12:40 -0000 1.13
@@ -41,8 +41,8 @@
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
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.QaQuestion;
import org.lamsfoundation.lams.tool.qa.QaSession;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
@@ -75,7 +75,7 @@
// adding all existing conditions
userAnswersDefinition.setDefaultConditions(new ArrayList(qaContent.getConditions()));
// if no conditions were created in the tool instance, a default condition is added;
- if (userAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQueContents().isEmpty()) {
+ if (userAnswersDefinition.getDefaultConditions().isEmpty() && !qaContent.getQaQuestions().isEmpty()) {
QaCondition defaultCondition = createDefaultComplexUserAnswersCondition(qaContent);
qaContent.getConditions().add(defaultCondition);
@@ -156,27 +156,22 @@
QaSession session = qaService.retrieveQaSession(toolSessionId);
QaContent qaContent = session.getQaContent();
- Set questions = qaContent.getQaQueContents();
+ Set questions = qaContent.getQaQuestions();
String[] answers = new String[questions.size()];
- QaQueUsr user = qaService.getQaUserBySession(learnerId, session.getUid());
- for (QaQueContent question : questions) {
- List attempts = null;
- if (user != null) {
- attempts = qaService.getAttemptsForUserAndQuestionContent(user.getUid(), question.getUid());
+ QaQueUsr user = qaService.getUserByIdAndSession(learnerId, session.getQaSessionId());
+ for (QaQuestion question : questions) {
+ QaUsrResp response = qaService.getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid());
+ if (response != null) {
+ answers[question.getDisplayOrder() - 1] = response.getAnswer();
}
- if (attempts != null && !attempts.isEmpty()) {
- // only the last attempt is taken into consideration
- String answer = attempts.get(attempts.size() - 1).getAnswer();
- answers[question.getDisplayOrder() - 1] = answer;
- }
}
return new ToolOutput(name, getI18NText(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, true), answers, false);
} else if (QaAppConstants.GROUP_ANSWERS_DEFINITION_NAME.equals(nameParts[0])) {
// all users' answers are loaded from the DB and array of strings is created
QaSession session = qaService.retrieveQaSession(toolSessionId);
QaContent qaContent = session.getQaContent();
- Set questions = qaContent.getQaQueContents();
+ Set questions = qaContent.getQaQuestions();
Set users = session.getQaQueUsers();
String[] dummyStringArray = new String[] {};
@@ -186,22 +181,19 @@
if (user != null) {
List answers = new LinkedList();
long lastAttemptTime = Long.MAX_VALUE;
- for (QaQueContent question : questions) {
+ for (QaQuestion question : questions) {
- List attempts = qaService.getAttemptsForUserAndQuestionContent(user.getUid(),
- question.getUid());
+ QaUsrResp response = qaService.getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid());
- if (attempts != null && !attempts.isEmpty()) {
- // only the last attempt is taken into consideration
- QaUsrResp attempt = attempts.get(attempts.size() - 1);
+ if (response != null) {
// we get the time of the attempt - the "lastAttemptTime" will the time of the whole answer
// set given
- long timeOfAttempt = attempt.getAttemptTime().getTime();
+ long timeOfAttempt = response.getAttemptTime().getTime();
if (timeOfAttempt < lastAttemptTime) {
lastAttemptTime = timeOfAttempt;
}
- String answer = attempt.getAnswer();
+ String answer = response.getAnswer();
if (!StringUtils.isBlank(answer)) {
// check for duplicate answers
boolean duplicate = false;
@@ -242,10 +234,10 @@
// Questions asked in this Q&A activity
QaSession session = qaService.retrieveQaSession(toolSessionId);
QaContent qaContent = session.getQaContent();
- Set questions = qaContent.getQaQueContents();
+ Set questions = qaContent.getQaQuestions();
String[] questionArray = new String[questions.size()];
int questionIndex = 0;
- for (QaQueContent question : questions) {
+ for (QaQuestion question : questions) {
questionArray[questionIndex++] = question.getQuestion();
}
return new ToolOutput(name, getI18NText(QaAppConstants.QUESTIONS_DEFINITION_NAME, true), questionArray,
@@ -271,11 +263,11 @@
* @return default Q&A condition
*/
protected QaCondition createDefaultComplexUserAnswersCondition(QaContent qaContent) {
- if (qaContent.getQaQueContents().isEmpty()) {
+ if (qaContent.getQaQuestions().isEmpty()) {
return null;
}
- Set questions = new HashSet();
- questions.add((QaQueContent) qaContent.getQaQueContents().iterator().next());
+ Set questions = new HashSet();
+ questions.add((QaQuestion) qaContent.getQaQuestions().iterator().next());
String name = buildConditionName(QaAppConstants.USER_ANSWERS_DEFINITION_NAME, qaContent.getQaContentId()
.toString());
// Default condition checks if the first answer contains word "LAMS"
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java,v
diff -u -r1.92 -r1.93
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 28 Feb 2011 12:21:57 -0000 1.92
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 18 Mar 2011 17:12:40 -0000 1.93
@@ -36,13 +36,14 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import javax.servlet.http.HttpSession;
+
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.contentrepository.AccessDeniedException;
import org.lamsfoundation.lams.contentrepository.FileException;
import org.lamsfoundation.lams.contentrepository.ICredentials;
import org.lamsfoundation.lams.contentrepository.ITicket;
import org.lamsfoundation.lams.contentrepository.IVersionedNode;
-import org.lamsfoundation.lams.contentrepository.ItemExistsException;
import org.lamsfoundation.lams.contentrepository.ItemNotFoundException;
import org.lamsfoundation.lams.contentrepository.LoginException;
import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
@@ -67,35 +68,36 @@
import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
-import org.lamsfoundation.lams.tool.qa.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.QaCondition;
import org.lamsfoundation.lams.tool.qa.QaConfigItem;
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.QaQuestion;
import org.lamsfoundation.lams.tool.qa.QaSession;
import org.lamsfoundation.lams.tool.qa.QaUploadedFile;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
import org.lamsfoundation.lams.tool.qa.QaWizardCategory;
import org.lamsfoundation.lams.tool.qa.ResponseRating;
import org.lamsfoundation.lams.tool.qa.dao.IQaConfigItemDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaContentDAO;
-import org.lamsfoundation.lams.tool.qa.dao.IQaQueContentDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaQueUsrDAO;
+import org.lamsfoundation.lams.tool.qa.dao.IQaQuestionDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaSessionDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaUploadedFileDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO;
import org.lamsfoundation.lams.tool.qa.dao.IQaWizardDAO;
import org.lamsfoundation.lams.tool.qa.dao.IResponseRatingDAO;
import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO;
+import org.lamsfoundation.lams.tool.qa.util.QaApplicationException;
import org.lamsfoundation.lams.tool.service.ILamsToolService;
-import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.util.audit.IAuditService;
import org.lamsfoundation.lams.util.wddx.WDDXProcessor;
import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
import org.springframework.dao.DataAccessException;
/**
@@ -114,9 +116,7 @@
*/
public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager,
- QaAppConstants
-
-{
+ QaAppConstants {
static Logger logger = Logger.getLogger(QaServicePOJO.class.getName());
private final String repositoryUser = "laqa11";
@@ -126,7 +126,7 @@
private ICredentials cred;
private IQaContentDAO qaDAO;
- private IQaQueContentDAO qaQueContentDAO;
+ private IQaQuestionDAO qaQuestionDAO;
private IQaSessionDAO qaSessionDAO;
private IQaQueUsrDAO qaQueUsrDAO;
@@ -148,26 +148,6 @@
private Random generator = new Random();
- public void configureContentRepository() throws QaApplicationException {
- cred = new SimpleCredentials(repositoryUser, repositoryId);
- QaServicePOJO.logger.debug("retrieved cred: " + cred);
- try {
- repositoryService.createCredentials(cred);
- repositoryService.addWorkspace(cred, repositoryWorkspace);
- } catch (ItemExistsException ie) {
- QaServicePOJO.logger.warn("Tried to configure repository but it "
- + " appears to be already configured. Exception thrown by repository being ignored. ", ie);
- } catch (RepositoryCheckedException e) {
- String error = "Error occured while trying to configure repository." + " Unable to recover from error: "
- + e.getMessage();
- QaServicePOJO.logger.error(error, e);
- throw new QaApplicationException(error, e);
- }
- }
-
- public QaServicePOJO() {
- }
-
public void createQa(QaContent qaContent) throws QaApplicationException {
try {
qaDAO.saveQa(qaContent);
@@ -176,20 +156,10 @@
}
}
- public QaContent getQaContentByUID(Long uid) throws QaApplicationException {
+ public QaContent getQa(long toolContentID) throws QaApplicationException {
try {
- return qaDAO.getQaContentByUID(uid);
+ return qaDAO.getQaByContentId(toolContentID);
} catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting qa content by uid: "
- + e.getMessage(), e);
- }
-
- }
-
- public QaContent retrieveQa(long toolContentID) throws QaApplicationException {
- try {
- return qaDAO.getQaById(toolContentID);
- } catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is loading qa content: " + e.getMessage(), e);
}
}
@@ -204,42 +174,31 @@
}
- /**
- * returns null if not found
- */
- public QaContent loadQa(long toolContentID) throws QaApplicationException {
- try {
- return qaDAO.loadQaById(toolContentID);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa content: " + e.getMessage(), e);
- }
- }
-
- public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid)
+ public QaQuestion getQuestionContentByQuestionText(final String question, Long contentUid)
throws QaApplicationException {
try {
- return qaQueContentDAO.getQuestionContentByQuestionText(question, contentUid);
+ return qaQuestionDAO.getQuestionContentByQuestionText(question, contentUid);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is getting qa content by question text: "
+ e.getMessage(), e);
}
}
- public QaQueContent getQuestionContentByDisplayOrder(Long displayOrder, Long contentUid)
+ public QaQuestion getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid)
throws QaApplicationException {
try {
- return qaQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, contentUid);
+ return qaQuestionDAO.getQuestionByDisplayOrder(displayOrder, contentUid);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is getting qa content by question text: "
+ e.getMessage(), e);
}
}
- public void saveOrUpdateQaQueContent(QaQueContent qaQueContent) throws QaApplicationException {
+ public void saveOrUpdateQaQueContent(QaQuestion qaQuestion) throws QaApplicationException {
try {
- qaQueContentDAO.saveOrUpdateQaQueContent(qaQueContent);
+ qaQuestionDAO.saveOrUpdateQaQueContent(qaQuestion);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is updating qa content by question: "
@@ -248,9 +207,9 @@
}
- public void createQaQue(QaQueContent qaQueContent) throws QaApplicationException {
+ public void createQaQue(QaQuestion qaQuestion) throws QaApplicationException {
try {
- qaQueContentDAO.createQueContent(qaQueContent);
+ qaQuestionDAO.createQueContent(qaQuestion);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is creating qa content: " + e.getMessage(), e);
}
@@ -273,15 +232,6 @@
}
}
- public String getSessionNameById(long qaSessionId) throws QaApplicationException {
- try {
- return qaSessionDAO.getSessionNameById(qaSessionId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting session name: " + e.getMessage(),
- e);
- }
- }
-
public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException {
try {
return qaSessionDAO.getSessionsFromContent(qaContent);
@@ -291,15 +241,25 @@
}
}
- public void createQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException {
+ public QaQueUsr createUser(Long toolSessionID) throws QaApplicationException {
try {
- qaQueUsrDAO.createUsr(qaQueUsr);
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = toolUser.getUserID().longValue();
+ String userName = toolUser.getLogin();
+ String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
+ QaSession qaSession = getSessionById(toolSessionID.longValue());
+
+ QaQueUsr user = new QaQueUsr(userId, userName, fullName, qaSession, new TreeSet());
+ qaQueUsrDAO.createUsr(user);
+
+ return user;
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is creating qa QueUsr: " + e.getMessage(), e);
}
}
- public QaQueUsr getQaUserBySession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException {
+ public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException {
try {
return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId);
} catch (DataAccessException e) {
@@ -325,42 +285,54 @@
}
}
- public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId)
+ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId)
throws QaApplicationException {
try {
- return qaUsrRespDAO.getAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId);
+ return qaUsrRespDAO.getResponseByUserAndQuestion(queUsrId, qaQueContentId);
} catch (DataAccessException e) {
throw new QaApplicationException(
"Exception occured when lams is getting qa qaUsrRespDAO by user id and que content id: "
+ e.getMessage(), e);
}
}
- public QaUsrResp getAttemptByUID(Long uid) throws QaApplicationException {
+ public void updateUserResponse(QaUsrResp resp) throws QaApplicationException {
try {
- return qaUsrRespDAO.getAttemptByUID(uid);
+ qaUsrRespDAO.updateUserResponse(resp);
} catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting response by uid: "
- + e.getMessage(), e);
+ throw new QaApplicationException("Exception occured when lams is updating response" + e.getMessage(), e);
}
}
+
+ public void updateResponseWithNewAnswer(String newAnswer, String toolSessionID, Long questionDisplayOrder) {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = new Long(toolUser.getUserID().longValue());
+ QaQueUsr user = getUserByIdAndSession(userId, new Long(toolSessionID));
- public void removeAttemptsForUserAndQuestionContent(final Long queUsrId, final Long qaQueContentId)
- throws QaApplicationException {
- try {
- qaUsrRespDAO.removeAttemptsForUserAndQuestionContent(queUsrId, qaQueContentId);
- } catch (DataAccessException e) {
- throw new QaApplicationException(
- "Exception occured when lams is removing attempts by queUsrId and qaQueContentId: "
- + e.getMessage(), e);
+ QaSession session = getSessionById(new Long(toolSessionID));
+ QaContent qaContent = session.getQaContent();
+ //set content in use
+ if (!qaContent.isContentLocked()) {
+ qaContent.setContentLocked(true);
+ updateQa(qaContent);
}
- }
+
+ QaQuestion question = getQuestionByContentAndDisplayOrder(new Long(questionDisplayOrder),
+ qaContent.getUid());
- public void updateUserResponse(QaUsrResp resp) throws QaApplicationException {
- try {
- qaUsrRespDAO.updateUserResponse(resp);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating response" + e.getMessage(), e);
+ QaUsrResp response = getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid());
+ // if response doesn't exist
+ if (response == null) {
+ response = new QaUsrResp(newAnswer, new Date(System.currentTimeMillis()), "", question, user, true);
+ createQaUsrResp(response);
+
+ // if answer has changed
+ } else if (!newAnswer.equals(response.getAnswer())) {
+ response.setAnswer(newAnswer);
+ response.setAttemptTime(new Date(System.currentTimeMillis()));
+ response.setTimezone("");
+ updateUserResponse(response);
}
}
@@ -389,25 +361,15 @@
}
}
- public QaUsrResp retrieveQaUsrResp(long responseId) throws QaApplicationException {
+ public QaUsrResp getResponseById(Long responseId) throws QaApplicationException {
try {
- QaUsrResp qaUsrResp = qaUsrRespDAO.retrieveQaUsrResp(responseId);
- return qaUsrResp;
+ return qaUsrRespDAO.getResponseById(responseId);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is loading qa qaUsrResp: " + e.getMessage(),
e);
}
-
}
- public void updateQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException {
- try {
- qaUsrRespDAO.updateUserResponse(qaUsrResp);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating qa UsrResp: " + e.getMessage(), e);
- }
- }
-
public int countSessionComplete(QaContent qa) throws QaApplicationException {
try {
return qaSessionDAO.countSessionComplete(qa);
@@ -417,24 +379,6 @@
}
}
- public int countSessionComplete() throws QaApplicationException {
- try {
- return qaSessionDAO.countSessionComplete();
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is counting complete sessions"
- + e.getMessage(), e);
- }
- }
-
- public QaQueContent retrieveQaQue(long qaQueContentId) throws QaApplicationException {
- try {
- return qaQueContentDAO.getQaQueById(qaQueContentId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa question content: "
- + e.getMessage(), e);
- }
- }
-
public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException {
try {
return qaSessionDAO.getQaSessionById(qaSessionId);
@@ -443,9 +387,9 @@
}
}
- public QaSession retrieveQaSessionOrNullById(long qaSessionId) throws QaApplicationException {
+ public QaSession getSessionById(long qaSessionId) throws QaApplicationException {
try {
- return qaSessionDAO.getQaSessionOrNullById(qaSessionId);
+ return qaSessionDAO.getQaSessionById(qaSessionId);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is loading qa session : " + e.getMessage(), e);
}
@@ -459,14 +403,6 @@
}
}
- public List retrieveQaQueContentsByToolContentId(long qaContentId) throws QaApplicationException {
- try {
- return qaQueContentDAO.getQaQueContentsByContentId(qaContentId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa que usr: " + e.getMessage(), e);
- }
- }
-
public void updateQa(QaContent qa) throws QaApplicationException {
try {
qaDAO.updateQa(qa);
@@ -485,33 +421,6 @@
}
}
- public void deleteQa(QaContent qa) throws QaApplicationException {
- try {
- qaDAO.deleteQa(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is deleting" + " the qa content: "
- + e.getMessage(), e);
- }
- }
-
- public void deleteQaById(Long qaId) throws QaApplicationException {
- try {
- qaDAO.removeQaById(qaId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is deleting" + " the qa content: "
- + e.getMessage(), e);
- }
- }
-
- public void deleteQaSession(QaSession QaSession) throws QaApplicationException {
- try {
- qaSessionDAO.deleteQaSession(QaSession);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is deleting" + " the qa session: "
- + e.getMessage(), e);
- }
- }
-
public void removeUserResponse(QaUsrResp resp) throws QaApplicationException {
try {
auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), resp.getQaQueUser()
@@ -527,36 +436,18 @@
* logs hiding of a user entered vote
*/
public void hideResponse(QaUsrResp qaUsrResp) throws QaApplicationException {
- auditService.logHideEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQueUsrId(), qaUsrResp.getQaQueUser()
+ auditService.logHideEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQaQueUser().getQueUsrId(), qaUsrResp.getQaQueUser()
.getUsername(), qaUsrResp.getAnswer());
}
/**
* logs showing of a user entered vote
*/
public void showResponse(QaUsrResp qaUsrResp) throws QaApplicationException {
- auditService.logShowEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQueUsrId(), qaUsrResp.getQaQueUser()
+ auditService.logShowEntry(QaAppConstants.MY_SIGNATURE, qaUsrResp.getQaQueUser().getQueUsrId(), qaUsrResp.getQaQueUser()
.getUsername(), qaUsrResp.getAnswer());
}
- public void deleteUsrRespByQueId(Long qaQueId) throws QaApplicationException {
- try {
- qaUsrRespDAO.removeUserResponseByQaQueId(qaQueId);
- } catch (DataAccessException e) {
- throw new QaApplicationException(
- "Exception occured when lams is deleting" + " the resp: " + e.getMessage(), e);
- }
- }
-
- public void deleteQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException {
- try {
- qaQueUsrDAO.deleteQaQueUsr(qaQueUsr);
- } catch (DataAccessException e) {
- throw new QaApplicationException(
- "Exception occured when lams is deleting" + " the user: " + e.getMessage(), e);
- }
- }
-
public List retrieveQaUploadedFiles(QaContent qa) throws QaApplicationException {
try {
return qaUploadedFileDAO.retrieveQaUploadedFiles(qa);
@@ -575,153 +466,60 @@
}
}
- public int countTotalNumberOfUserResponsed(QaContent qa) throws QaApplicationException {
- try {
- return qaDAO.countUserResponsed(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured in [countTotalNumberOfUserResponsed]: "
- + e.getMessage(), e);
- }
- }
-
public List getAllQuestionEntries(final Long uid) throws QaApplicationException {
try {
- return qaQueContentDAO.getAllQuestionEntries(uid.longValue());
+ return qaQuestionDAO.getAllQuestionEntries(uid.longValue());
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is getting by uid qa question content: "
+ e.getMessage(), e);
}
}
- public List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException {
+ public List getAllQuestionEntriesSorted(final long contentUid) throws QaApplicationException {
try {
- return qaQueContentDAO.getAllQuestionEntriesSorted(qaContentId);
+ return qaQuestionDAO.getAllQuestionEntriesSorted(contentUid);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is getting all question entries: "
+ e.getMessage(), e);
}
}
- public void removeQaQueContent(QaQueContent qaQueContent) throws QaApplicationException {
+ public void removeQaQueContent(QaQuestion qaQuestion) throws QaApplicationException {
try {
- qaQueContentDAO.removeQaQueContent(qaQueContent);
+ qaQuestionDAO.removeQaQueContent(qaQuestion);
} catch (DataAccessException e) {
throw new QaApplicationException("Exception occured when lams is removing question content: "
+ e.getMessage(), e);
}
}
- public User getCurrentUserData(String username) throws QaApplicationException {
- try {
- QaServicePOJO.logger.debug("getCurrentUserData: " + username);
- /*
- * this will return null if the username not found
- */
- User user = userManagementService.getUserByLogin(username);
- if (user == null) {
- QaServicePOJO.logger.debug("No user with the username: " + username + " exists.");
- throw new QaApplicationException("No user with that username exists.");
- }
- return user;
- } catch (DataAccessException e) {
- throw new QaApplicationException("Unable to find current user information" + " Root Cause: ["
- + e.getMessage() + "]", e);
- }
- }
-
- public void saveQaContent(QaContent qa) throws QaApplicationException {
- try {
- qaDAO.saveQa(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is saving" + " the qa content: "
- + e.getMessage(), e);
- }
- }
-
- public QaQueUsr retrieveQaQueUsr(long qaQaQueUsrId) throws QaApplicationException {
- try {
- return qaQueUsrDAO.getQaQueUsrById(qaQaQueUsrId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa que usr: " + e.getMessage(), e);
- }
- }
-
- public int countSessionUser(QaSession qaSession) throws QaApplicationException {
- try {
- return qaQueUsrDAO.countSessionUser(qaSession);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is counting users in the session "
- + e.getMessage(), e);
- }
- }
-
/**
- * checks the paramter content in the user responses table boolean studentActivityOccurredGlobal(QaContent
- * qaContent) throws QaApplicationException
+ * checks the paramter content in the user responses table
*
* @param qa
* @return boolean
* @throws QaApplicationException
*/
- public boolean studentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException {
+ public boolean isStudentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException {
+ int countResponses = 0;
if (qaContent != null) {
- Iterator questionIterator = qaContent.getQaQueContents().iterator();
- while (questionIterator.hasNext()) {
- QaQueContent qaQueContent = (QaQueContent) questionIterator.next();
- Iterator responsesIterator = qaQueContent.getQaUsrResps().iterator();
- while (responsesIterator.hasNext()) {
- return true;
- }
- }
+ countResponses = qaUsrRespDAO.getCountResponsesByQaContent(qaContent.getQaContentId());
}
- return false;
+ return countResponses > 0;
}
/**
- * counts the number of sessions marked INCOMPLETE for a content int countIncompleteSession(QaContent qa) throws
- * QaApplicationException
+ * gets called ONLY when a lesson is being created in monitoring mode.
+ * Should create the new content(toContent) based on what the author has
+ * created her content with. In q/a tool's case that is content + question's
+ * content but not user responses. The deep copy should go only as far as
+ * default content (or author created content) already goes.
+ * ToolContentManager CONTRACT
*
- * @param qa
- * @return int
- * @throws QaApplicationException
- */
- public int countIncompleteSession(QaContent qa) throws QaApplicationException {
- QaServicePOJO.logger.debug("qaContentId: " + qa.getQaContentId());
- int countIncompleteSession = qaSessionDAO.countSessionIncomplete();
- QaServicePOJO.logger.debug("countIncompleteSession: " + countIncompleteSession);
- return countIncompleteSession;
- }
-
- /**
- * checks the parameter content in the tool sessions table. find out if any student has ever used (logged in through
- * the url and replied) to this content return true even if you have only one content passed as parameter referenced
- * in the tool sessions table
+ * similar to public void removeToolContent(Long toolContentID) gets called
+ * by Container+Flash
*
- * boolean studentActivityOccurred(QaContent qa) throws QaApplicationException
- *
- * @param qa
- * @return boolean
- * @throws QaApplicationException
*/
- public boolean studentActivityOccurred(QaContent qa) throws QaApplicationException {
- QaServicePOJO.logger.debug("qaContentId: " + qa.getQaContentId());
- int countStudentActivity = qaSessionDAO.studentActivityOccurred(qa);
- QaServicePOJO.logger.debug("countIncompleteSession: " + countStudentActivity);
- if (countStudentActivity > 0) {
- return true;
- }
- return false;
- }
-
- /**
- * gets called ONLY when a lesson is being created in monitoring mode. Should create the new content(toContent)
- * based on what the author has created her content with. In q/a tool's case that is content + question's content
- * but not user responses. The deep copy should go only as far as default content (or author created content)
- * already goes. ToolContentManager CONTRACT
- *
- * similar to public void removeToolContent(Long toolContentID) gets called by Container+Flash
- *
- */
public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException
{
@@ -750,7 +548,7 @@
QaServicePOJO.logger.debug("final - copyToolContent using ids: " + fromContentId + " and " + toContentId);
try {
- QaContent fromContent = qaDAO.loadQaById(fromContentId.longValue());
+ QaContent fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
if (fromContent == null) {
QaServicePOJO.logger.debug("fromContent is null.");
@@ -766,7 +564,7 @@
+ QaAppConstants.MY_SIGNATURE + " Can't continue!");
}
- fromContent = qaDAO.loadQaById(fromContentId.longValue());
+ fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
}
if (fromContentId.equals(defaultContentId) && fromContent != null && fromContent.getConditions().isEmpty()) {
fromContent.getConditions().add(
@@ -793,65 +591,9 @@
}
/**
- * setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException update the tool session status to
- * COMPLETE for this tool session
+ * setAsDefineLater(Long toolContentID) throws DataMissingException,
+ * ToolException
*
- * @param Long
- * toolSessionId
- */
- public void setAsForceCompleteSession(Long toolSessionId) throws QaApplicationException {
- QaServicePOJO.logger
- .debug("Request for setAsForceCompleteSession has come for toolSessionId: " + toolSessionId);
-
- QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue());
- qaSession.setSession_status(QaSession.COMPLETED);
- updateQaSession(qaSession);
- QaServicePOJO.logger.debug("updated qaSession to COMPLETED : ");
- }
-
- /**
- * setAsForceComplete(Long userId) throws QaApplicationException update the tool session status to COMPLETE for this
- * user
- *
- * @param userId
- */
- public void setAsForceComplete(Long userId) throws QaApplicationException {
- QaServicePOJO.logger.debug("request for setAsForceComplete has come for userId: " + userId);
- QaQueUsr qaQueUsr = loadQaQueUsr(userId);
-
- if (qaQueUsr != null) {
- QaSession qaSession = qaQueUsr.getQaSession();
- if (qaSession != null) {
- Long usersToolSessionId = qaSession.getQaSessionId();
- QaServicePOJO.logger.debug("retrieved tool session has tool session id : " + usersToolSessionId);
-
- qaSession = retrieveQaSessionOrNullById(usersToolSessionId.longValue());
- qaSession.setSession_status(QaSession.COMPLETED);
- updateQaSession(qaSession);
- QaServicePOJO.logger.debug("updated qaSession to COMPLETED");
- QaContent qaContent = qaSession.getQaContent();
- QaServicePOJO.logger.debug("qaSession uses qaContentId : " + qaContent.getQaContentId());
-
- int countIncompleteSession = countIncompleteSession(qaContent);
- QaServicePOJO.logger.debug("qaSession countIncompleteSession : " + countIncompleteSession);
-
- if (countIncompleteSession == 0) {
- qaContent.setContentLocked(false);
- updateQa(qaContent);
- }
- } else {
- QaServicePOJO.logger.debug("WARNING!: retrieved qaSession is null.");
- throw new QaApplicationException("Fail to setAsForceComplete" + " based on null qaSession.");
- }
- } else {
- QaServicePOJO.logger.debug("WARNING!: retrieved qaQueUsr is null.");
- throw new QaApplicationException("Fail to setAsForceComplete" + " based on null qaQueUsr.");
- }
- }
-
- /**
- * setAsDefineLater(Long toolContentID) throws DataMissingException, ToolException
- *
* @param toolContentID
* return void
*/
@@ -861,7 +603,7 @@
QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null.");
throw new DataMissingException("toolContentID is missing");
}
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
+ QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
if (qaContent == null) {
QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null.");
throw new DataMissingException("qaContent is missing");
@@ -883,7 +625,7 @@
QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved toolContentID is null.");
throw new DataMissingException("toolContentID is missing");
}
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
+ QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
if (qaContent == null) {
QaServicePOJO.logger.debug("throwing DataMissingException: WARNING!: retrieved qaContent is null.");
throw new DataMissingException("qaContent is missing");
@@ -893,83 +635,18 @@
}
/**
+ * removeToolContent(Long toolContentID, boolean removeSessionData) throws
+ * SessionDataExistsException, ToolException Will need an update on the core
+ * tool signature: reason : when qaContent is null throw an exception
*
- * removeToolContent(Long toolContentID) gets automatically called only in monitoring mode when the author chooses
- * to delete a lesson.
- *
- * The idea is to remove content + its relevant sessions + in q/a tools's case the question's content from the db.
- * ToolContentManager CONTRACT this gets called automatically by Flash when a deletion is detected in the tool
- * interface.
*/
- public void removeToolContent(Long toolContentID) {
- QaServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID);
-
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
-
- if (qaContent != null) {
- Iterator sessionIterator = qaContent.getQaSessions().iterator();
- while (sessionIterator.hasNext()) {
- QaSession qaSession = (QaSession) sessionIterator.next();
-
- Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator();
- while (sessionUsersIterator.hasNext()) {
- QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next();
-
- Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator();
- while (sessionUsersResponsesIterator.hasNext()) {
- QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next();
- removeUserResponse(qaUsrResp);
- QaServicePOJO.logger.debug("removed qaUsrResp : " + qaUsrResp.getQueUsrId());
- }
- }
- }
-
- QaServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentID:"
- + toolContentID);
- qaDAO.removeQa(toolContentID);
- }
- }
-
- public void removeQuestions(Long toolContentID) throws QaApplicationException {
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
- qaContent.setQaQueContents(new TreeSet());
-
- if (qaContent != null) {
- Iterator sessionIterator = qaContent.getQaSessions().iterator();
- while (sessionIterator.hasNext()) {
- QaSession qaSession = (QaSession) sessionIterator.next();
-
- Iterator sessionUsersIterator = qaSession.getQaQueUsers().iterator();
- while (sessionUsersIterator.hasNext()) {
- QaQueUsr qaQueUsr = (QaQueUsr) sessionUsersIterator.next();
-
- Iterator sessionUsersResponsesIterator = qaQueUsr.getQaUsrResps().iterator();
- while (sessionUsersResponsesIterator.hasNext()) {
- QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next();
- removeUserResponse(qaUsrResp);
- }
- }
- }
- }
- }
-
- /**
- * removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException, ToolException
- * Will need an update on the core tool signature: reason : when qaContent is null throw an exception
- *
- */
public void removeToolContent(Long toolContentID, boolean removeSessionData) throws SessionDataExistsException,
ToolException {
- QaServicePOJO.logger.debug("start of: removeToolContent(Long toolContentID, boolean removeSessionData");
- QaServicePOJO.logger.debug("start of removeToolContent with toolContentID: " + toolContentID
- + "removeSessionData: " + removeSessionData);
-
if (toolContentID == null) {
- QaServicePOJO.logger.debug("toolContentID is null");
throw new ToolException("toolContentID is missing");
}
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
+ QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
if (qaContent != null) {
Iterator sessionIterator = qaContent.getQaSessions().iterator();
@@ -989,13 +666,11 @@
while (sessionUsersResponsesIterator.hasNext()) {
QaUsrResp qaUsrResp = (QaUsrResp) sessionUsersResponsesIterator.next();
removeUserResponse(qaUsrResp);
- QaServicePOJO.logger.debug("removed qaUsrResp : " + qaUsrResp.getResponseId());
}
}
}
- QaServicePOJO.logger.debug("removed all existing responses of toolContent with toolContentID:"
- + toolContentID);
+ //removed all existing responses of toolContent with toolContentID
qaDAO.removeQa(toolContentID);
} else {
QaServicePOJO.logger.debug("Warning!!!, We should have not come here. qaContent is null.");
@@ -1004,9 +679,9 @@
}
public AverageRatingDTO rateResponse(Long responseId, Long userId, Long toolSessionID, float rating) {
- QaQueUsr imageGalleryUser = this.getQaUserBySession(userId, toolSessionID);
+ QaQueUsr imageGalleryUser = this.getUserByIdAndSession(userId, toolSessionID);
ResponseRating responseRating = qaResponseRatingDAO.getRatingByResponseAndUser(responseId, userId);
- QaUsrResp response = qaUsrRespDAO.getAttemptByUID(responseId);
+ QaUsrResp response = qaUsrRespDAO.getResponseById(responseId);
//persist ResponseRating changes in DB
if (responseRating == null) { // add
@@ -1035,10 +710,10 @@
*/
public void exportToolContent(Long toolContentID, String rootPath) throws DataMissingException, ToolException {
- QaContent toolContentObj = qaDAO.getQaById(toolContentID);
+ QaContent toolContentObj = qaDAO.getQaByContentId(toolContentID);
if (toolContentObj == null) {
long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- toolContentObj = retrieveQa(defaultToolContentId);
+ toolContentObj = getQa(defaultToolContentId);
if (toolContentObj != null && toolContentObj.getConditions().isEmpty()) {
toolContentObj.getConditions().add(
getQaOutputFactory().createDefaultComplexUserAnswersCondition(toolContentObj));
@@ -1055,12 +730,10 @@
// don't export following fields value
toolContentObj.setQaSessions(null);
- Set questions = toolContentObj.getQaQueContents();
- for (QaQueContent question : questions) {
+ Set questions = toolContentObj.getQaQuestions();
+ for (QaQuestion question : questions) {
question.setQaQueUsers(null);
question.setQaContent(null);
- question.setQaUsrResps(null);
- question.setUserResponses(null);
}
Set files = toolContentObj.getQaUploadedFiles();
for (QaUploadedFile file : files) {
@@ -1106,8 +779,8 @@
toolContentObj.setCreatedBy(newUserUid);
// set back the tool content
- Set questions = toolContentObj.getQaQueContents();
- for (QaQueContent question : questions) {
+ Set questions = toolContentObj.getQaQuestions();
+ for (QaQuestion question : questions) {
question.setQaContent(toolContentObj);
}
Set files = toolContentObj.getQaUploadedFiles();
@@ -1130,10 +803,10 @@
*/
public SortedMap getToolOutputDefinitions(Long toolContentId, int definitionType)
throws ToolException {
- QaContent qaContent = qaDAO.getQaById(toolContentId);
+ QaContent qaContent = qaDAO.getQaByContentId(toolContentId);
if (qaContent == null) {
long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- qaContent = retrieveQa(defaultToolContentId);
+ qaContent = getQa(defaultToolContentId);
if (qaContent != null && qaContent.getConditions().isEmpty()) {
qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent));
}
@@ -1150,7 +823,7 @@
*/
protected boolean existsSession(long toolSessionId) {
QaServicePOJO.logger.debug("toolSessionId: " + toolSessionId);
- QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId);
+ QaSession qaSession = getSessionById(toolSessionId);
QaServicePOJO.logger.debug("qaSession: " + qaSession);
if (qaSession == null) {
@@ -1197,7 +870,7 @@
}
QaServicePOJO.logger.debug("final toolSessionId and toolContentID: " + toolSessionId + " " + toolContentID);
- QaContent qaContent = qaDAO.loadQaById(toolContentID.longValue());
+ QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
if (qaContent == null) {
QaServicePOJO.logger.debug("qaContent is null.");
@@ -1215,7 +888,7 @@
+ QaAppConstants.MY_SIGNATURE + " Can't continue!");
}
- qaContent = qaDAO.loadQaById(toolContentID.longValue());
+ qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
if (qaContent.getConditions().isEmpty()) {
qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent));
}
@@ -1245,7 +918,7 @@
QaSession qaSession = null;
try {
- qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue());
+ qaSession = getSessionById(toolSessionId.longValue());
} catch (QaApplicationException e) {
throw new DataMissingException("error retrieving qaSession: " + e);
} catch (Exception e) {
@@ -1259,7 +932,7 @@
try {
qaSessionDAO.deleteQaSession(qaSession);
- QaServicePOJO.logger.debug("qaSession " + qaSession.getUid() + " has been deleted successfully.");
+ QaServicePOJO.logger.debug("qaSession " + qaSession.getQaSessionId() + " has been deleted successfully.");
} catch (QaApplicationException e) {
throw new ToolException("error deleting qaSession:" + e);
}
@@ -1286,11 +959,11 @@
throw new DataMissingException("learnerId is missing");
}
- QaSession qaSession = retrieveQaSessionOrNullById(toolSessionId.longValue());
+ QaSession qaSession = getSessionById(toolSessionId.longValue());
qaSession.setSession_end_date(new Date(System.currentTimeMillis()));
qaSession.setSession_status(QaAppConstants.COMPLETED);
updateQaSession(qaSession);
- QaServicePOJO.logger.debug("tool session has been marked COMPLETE: " + qaSession.getUid());
+ QaServicePOJO.logger.debug("tool session has been marked COMPLETE: " + qaSession.getQaSessionId());
try {
String nextUrl = learnerService.completeToolSession(toolSessionId, learnerId);
@@ -1355,17 +1028,6 @@
return contentId;
}
- public QaQueContent getToolDefaultQuestionContent(long contentId) throws QaApplicationException {
- QaServicePOJO.logger.debug("before attempting retrieving QaQueContent with contentId : " + contentId);
- QaQueContent qaQueContent = qaQueContentDAO.getToolDefaultQuestionContent(contentId);
- return qaQueContent;
- }
-
- public List getToolSessionsForContent(QaContent qa) {
- List listToolSessionIds = qaSessionDAO.getToolSessionsForContent(qa);
- return listToolSessionIds;
- }
-
/**
* This method verifies the credentials of the SubmitFiles Tool and gives it the Ticket
to login and
* access the Content Repository.
@@ -1524,10 +1186,10 @@
}
/**
- * @return Returns the qaQueContentDAO.
+ * @return Returns the qaQuestionDAO.
*/
- public IQaQueContentDAO getQaQueContentDAO() {
- return qaQueContentDAO;
+ public IQaQuestionDAO getQaQuestionDAO() {
+ return qaQuestionDAO;
}
/**
@@ -1563,8 +1225,8 @@
this.qaDAO = qaDAO;
}
- public void setQaQueContentDAO(IQaQueContentDAO qaQueContentDAO) {
- this.qaQueContentDAO = qaQueContentDAO;
+ public void setQaQuestionDAO(IQaQuestionDAO qaQuestionDAO) {
+ this.qaQuestionDAO = qaQuestionDAO;
}
public void setQaSessionDAO(IQaSessionDAO qaSessionDAO) {
@@ -1717,12 +1379,12 @@
// setQaSessions(Set qaSessions);
// set up question from body
- QaQueContent question = new QaQueContent();
+ QaQuestion question = new QaQuestion();
String content = WebUtil.convertNewlines((String) importValues.get(ToolContentImport102Manager.CONTENT_BODY));
question.setQuestion(content);
question.setDisplayOrder(1);
question.setQaContent(toolContentObj);
- toolContentObj.getQaQueContents().add(question);
+ toolContentObj.getQaQuestions().add(question);
qaDAO.saveOrUpdateQa(toolContentObj);
@@ -1736,7 +1398,7 @@
QaContent qaContent = null;
if (toolContentId != null) {
- qaContent = loadQa(toolContentId.longValue());
+ qaContent = getQa(toolContentId.longValue());
}
if (qaContent == null) {
throw new DataMissingException("Unable to set reflective data titled " + title
@@ -1792,10 +1454,10 @@
}
public QaContent getQaContentBySessionId(Long sessionId) {
- QaSession session = qaSessionDAO.getQaSessionOrNullById(sessionId);
+ QaSession session = qaSessionDAO.getQaSessionById(sessionId);
// to skip CGLib problem
Long contentId = session.getQaContent().getQaContentId();
- QaContent qaContent = qaDAO.getQaById(contentId);
+ QaContent qaContent = qaDAO.getQaByContentId(contentId);
return qaContent;
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java,v
diff -u -r1.11 -r1.12
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java 19 Feb 2009 04:25:02 -0000 1.11
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServiceProxy.java 18 Mar 2011 17:12:40 -0000 1.12
@@ -24,6 +24,7 @@
package org.lamsfoundation.lams.tool.qa.service;
import javax.servlet.ServletContext;
+
import org.lamsfoundation.lams.tool.ToolContentManager;
import org.lamsfoundation.lams.tool.ToolSessionManager;
import org.springframework.web.context.WebApplicationContext;
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaApplicationException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaComparator.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java,v
diff -u -r1.2 -r1.3
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java 19 Feb 2009 04:25:02 -0000 1.2
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQueContentComparator.java 18 Mar 2011 17:12:40 -0000 1.3
@@ -2,20 +2,20 @@
import java.util.Comparator;
-import org.lamsfoundation.lams.tool.qa.QaQueContent;
+import org.lamsfoundation.lams.tool.qa.QaQuestion;
/**
- * Comparator for QaQueContent
. Only the display order is
+ * Comparator for QaQuestion
. Only the display order is
* compared.
*
* @author Marcin Cieslak
*/
-public class QaQueContentComparator implements Comparator {
+public class QaQueContentComparator implements Comparator {
/**
* {@inheritDoc}
*/
- public int compare(QaQueContent o1, QaQueContent o2) {
+ public int compare(QaQuestion o1, QaQuestion o2) {
if (o1 != null && o2 != null) {
return o1.getDisplayOrder() - o2.getDisplayOrder();
} else if (o1 != null) {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java,v
diff -u -r1.2 -r1.3
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java 19 Feb 2009 04:25:02 -0000 1.2
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaQuestionContentDTOComparator.java 18 Mar 2011 17:12:40 -0000 1.3
@@ -2,20 +2,20 @@
import java.util.Comparator;
-import org.lamsfoundation.lams.tool.qa.QaQuestionContentDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO;
/**
- * Comparator for QaQuestionContentDTO
. Only the display order
+ * Comparator for QaQuestionDTO
. Only the display order
* is compared.
*
* @author Marcin Cieslak
*/
-public class QaQuestionContentDTOComparator implements Comparator {
+public class QaQuestionContentDTOComparator implements Comparator {
/**
* {@inheritDoc}
*/
- public int compare(QaQuestionContentDTO o1, QaQuestionContentDTO o2) {
+ public int compare(QaQuestionDTO o1, QaQuestionDTO o2) {
if (o1 != null && o2 != null) {
return Integer.parseInt(o1.getDisplayOrder()) - Integer.parseInt(o2.getDisplayOrder());
} else if (o1 != null) {
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaStringComparator.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java,v
diff -u -r1.54 -r1.55
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 28 Feb 2011 12:21:57 -0000 1.54
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 18 Mar 2011 17:13:10 -0000 1.55
@@ -41,14 +41,15 @@
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
-import org.lamsfoundation.lams.tool.qa.QaComparator;
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.QaQuestionContentDTO;
+import org.lamsfoundation.lams.tool.qa.QaQuestion;
+import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.util.QaComparator;
import org.lamsfoundation.lams.tool.qa.util.QaQueContentComparator;
import org.lamsfoundation.lams.tool.qa.util.QaQuestionContentDTOComparator;
+import org.lamsfoundation.lams.tool.qa.web.form.QaAuthoringForm;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
@@ -83,9 +84,9 @@
AuthoringUtil.logger.debug("replacedNodeIndex:" + replacedNodeIndex);
AuthoringUtil.logger.debug("replacing nodes:" + intOriginalQuestionIndex + " and " + replacedNodeIndex);
- QaQuestionContentDTO mainNode = extractNodeAtDisplayOrder(listQuestionContentDTO, intOriginalQuestionIndex);
+ QaQuestionDTO mainNode = extractNodeAtDisplayOrder(listQuestionContentDTO, intOriginalQuestionIndex);
- QaQuestionContentDTO replacedNode = extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex);
+ QaQuestionDTO replacedNode = extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex);
List listFinalQuestionContentDTO = new LinkedList();
@@ -96,31 +97,31 @@
}
protected static List reorderSwappedListQuestionContentDTO(List listQuestionContentDTO,
- int intOriginalQuestionIndex, int replacedNodeIndex, QaQuestionContentDTO mainNode,
- QaQuestionContentDTO replacedNode, Set conditions) {
+ int intOriginalQuestionIndex, int replacedNodeIndex, QaQuestionDTO mainNode,
+ QaQuestionDTO replacedNode, Set conditions) {
AuthoringUtil.logger.debug("reorderSwappedListQuestionContentDTO:");
List listFinalQuestionContentDTO = new LinkedList();
int queIndex = 0;
Iterator listIterator = listQuestionContentDTO.iterator();
while (listIterator.hasNext()) {
- QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next();
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
queIndex++;
- QaQuestionContentDTO tempNode = null;
+ QaQuestionDTO tempNode = null;
- if (!qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())
- && !qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
+ if (!qaQuestionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())
+ && !qaQuestionDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
AuthoringUtil.logger.debug("normal copy ");
- tempNode = new QaQuestionContentDTO(qaQuestionContentDTO.getQuestion(),
- qaQuestionContentDTO.getDisplayOrder(), qaQuestionContentDTO.getFeedback(), qaQuestionContentDTO.isRequired());
- } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) {
+ tempNode = new QaQuestionDTO(qaQuestionDTO.getQuestion(),
+ qaQuestionDTO.getDisplayOrder(), qaQuestionDTO.getFeedback(), qaQuestionDTO.isRequired());
+ } else if (qaQuestionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) {
AuthoringUtil.logger.debug("move type 1 ");
- tempNode = new QaQuestionContentDTO(replacedNode.getQuestion(),
+ tempNode = new QaQuestionDTO(replacedNode.getQuestion(),
replacedNode.getDisplayOrder(),replacedNode.getFeedback(), replacedNode.isRequired());
- } else if (qaQuestionContentDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
+ } else if (qaQuestionDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
AuthoringUtil.logger.debug("move type 1 ");
- tempNode = new QaQuestionContentDTO(mainNode.getQuestion(),
+ tempNode = new QaQuestionDTO(mainNode.getQuestion(),
mainNode.getDisplayOrder(), mainNode.getFeedback(), mainNode.isRequired());
}
@@ -129,9 +130,9 @@
// references in conditions also need to be changed
if (conditions != null) {
for (QaCondition condition : conditions) {
- SortedSet newQuestionDTOSet = new TreeSet(
+ SortedSet newQuestionDTOSet = new TreeSet(
new QaQuestionContentDTOComparator());
- for (QaQuestionContentDTO dto : (List) listFinalQuestionContentDTO) {
+ for (QaQuestionDTO dto : (List) listFinalQuestionContentDTO) {
if (condition.temporaryQuestionDTOSet.contains(dto)) {
newQuestionDTOSet.add(dto);
}
@@ -142,18 +143,18 @@
return listFinalQuestionContentDTO;
}
- protected static QaQuestionContentDTO extractNodeAtDisplayOrder(List listQuestionContentDTO,
+ protected static QaQuestionDTO extractNodeAtDisplayOrder(List listQuestionContentDTO,
int intOriginalQuestionIndex) {
AuthoringUtil.logger.debug("intOriginalQuestionIndex:" + intOriginalQuestionIndex);
Iterator listIterator = listQuestionContentDTO.iterator();
while (listIterator.hasNext()) {
- QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next();
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
AuthoringUtil.logger.debug("intOriginalQuestionIndex versus displayOrder:"
+ new Integer(intOriginalQuestionIndex).toString() + " versus "
- + qaQuestionContentDTO.getDisplayOrder());
- if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionContentDTO.getDisplayOrder())) {
- return qaQuestionContentDTO;
+ + qaQuestionDTO.getDisplayOrder());
+ if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionDTO.getDisplayOrder())) {
+ return qaQuestionDTO;
}
}
return null;
@@ -185,15 +186,15 @@
int queIndex = 0;
Iterator listIterator = listQuestionContentDTO.iterator();
while (listIterator.hasNext()) {
- QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next();
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
- String question = qaQuestionContentDTO.getQuestion();
+ String question = qaQuestionDTO.getQuestion();
- String displayOrder = qaQuestionContentDTO.getDisplayOrder();
+ String displayOrder = qaQuestionDTO.getDisplayOrder();
AuthoringUtil.logger.debug("displayOrder:" + displayOrder);
- String feedback = qaQuestionContentDTO.getFeedback();
- boolean required = qaQuestionContentDTO.isRequired();
+ String feedback = qaQuestionDTO.getFeedback();
+ boolean required = qaQuestionDTO.isRequired();
AuthoringUtil.logger.debug("displayOrder versus excludeQuestionIndex :" + displayOrder + " versus "
+ excludeQuestionIndex);
@@ -202,12 +203,12 @@
if (!displayOrder.equals(excludeQuestionIndex)) {
++queIndex;
- qaQuestionContentDTO.setQuestion(question);
- qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString());
- qaQuestionContentDTO.setFeedback(feedback);
- qaQuestionContentDTO.setRequired(required);
+ qaQuestionDTO.setQuestion(question);
+ qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString());
+ qaQuestionDTO.setFeedback(feedback);
+ qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionContentDTO);
+ listFinalQuestionContentDTO.add(qaQuestionDTO);
}
}
}
@@ -221,29 +222,29 @@
int queIndex = 0;
Iterator listIterator = listQuestionContentDTO.iterator();
while (listIterator.hasNext()) {
- QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next();
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
- String question = qaQuestionContentDTO.getQuestion();
- String displayOrder = qaQuestionContentDTO.getDisplayOrder();
- String feedback = qaQuestionContentDTO.getFeedback();
- boolean required = qaQuestionContentDTO.isRequired();
+ String question = qaQuestionDTO.getQuestion();
+ String displayOrder = qaQuestionDTO.getDisplayOrder();
+ String feedback = qaQuestionDTO.getFeedback();
+ boolean required = qaQuestionDTO.isRequired();
if (question != null && !question.equals("")) {
++queIndex;
- qaQuestionContentDTO.setQuestion(question);
- qaQuestionContentDTO.setDisplayOrder(new Integer(queIndex).toString());
- qaQuestionContentDTO.setFeedback(feedback);
- qaQuestionContentDTO.setRequired(required);
+ qaQuestionDTO.setQuestion(question);
+ qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString());
+ qaQuestionDTO.setFeedback(feedback);
+ qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionContentDTO);
+ listFinalQuestionContentDTO.add(qaQuestionDTO);
}
}
return listFinalQuestionContentDTO;
}
protected static List reorderUpdateListQuestionContentDTO(List listQuestionContentDTO,
- QaQuestionContentDTO qaQuestionContentDTONew, String editableQuestionIndex) {
+ QaQuestionDTO qaQuestionContentDTONew, String editableQuestionIndex) {
AuthoringUtil.logger.debug("reorderUpdateListQuestionContentDTO");
AuthoringUtil.logger.debug("editableQuestionIndex:" + editableQuestionIndex);
@@ -252,29 +253,29 @@
int queIndex = 0;
Iterator listIterator = listQuestionContentDTO.iterator();
while (listIterator.hasNext()) {
- QaQuestionContentDTO qaQuestionContentDTO = (QaQuestionContentDTO) listIterator.next();
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
++queIndex;
- String question = qaQuestionContentDTO.getQuestion();
- String displayOrder = qaQuestionContentDTO.getDisplayOrder();
- String feedback = qaQuestionContentDTO.getFeedback();
- boolean required = qaQuestionContentDTO.isRequired();
+ String question = qaQuestionDTO.getQuestion();
+ String displayOrder = qaQuestionDTO.getDisplayOrder();
+ String feedback = qaQuestionDTO.getFeedback();
+ boolean required = qaQuestionDTO.isRequired();
if (displayOrder.equals(editableQuestionIndex)) {
- qaQuestionContentDTO.setQuestion(qaQuestionContentDTONew.getQuestion());
- qaQuestionContentDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder());
- qaQuestionContentDTO.setFeedback(qaQuestionContentDTONew.getFeedback());
- qaQuestionContentDTO.setRequired(required);
+ qaQuestionDTO.setQuestion(qaQuestionContentDTONew.getQuestion());
+ qaQuestionDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder());
+ qaQuestionDTO.setFeedback(qaQuestionContentDTONew.getFeedback());
+ qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionContentDTO);
+ listFinalQuestionContentDTO.add(qaQuestionDTO);
} else {
- qaQuestionContentDTO.setQuestion(question);
- qaQuestionContentDTO.setDisplayOrder(displayOrder);
- qaQuestionContentDTO.setFeedback(feedback);
- qaQuestionContentDTO.setRequired(required);
+ qaQuestionDTO.setQuestion(question);
+ qaQuestionDTO.setDisplayOrder(displayOrder);
+ qaQuestionDTO.setFeedback(feedback);
+ qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionContentDTO);
+ listFinalQuestionContentDTO.add(qaQuestionDTO);
}
}
@@ -305,7 +306,7 @@
}
}
- public QaContent saveOrUpdateQaContent(List listQuestionContentDTO, IQaService qaService,
+ public QaContent saveOrUpdateQaContent(List listQuestionContentDTO, IQaService qaService,
QaAuthoringForm qaAuthoringForm, HttpServletRequest request, QaContent qaContent, String strToolContentID,
Set conditions) {
UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
@@ -431,15 +432,15 @@
qaService.updateQa(qaContent);
}
- qaContent = qaService.loadQa(new Long(strToolContentID).longValue());
+ qaContent = qaService.getQa(new Long(strToolContentID).longValue());
qaContent = createQuestionContent(listQuestionContentDTO, qaService, qaContent);
- qaContent = qaService.loadQa(new Long(strToolContentID).longValue());
+ qaContent = qaService.getQa(new Long(strToolContentID).longValue());
for (QaCondition condition : conditions) {
- condition.setQuestions(new TreeSet(new QaQueContentComparator()));
- for (QaQuestionContentDTO dto : condition.temporaryQuestionDTOSet) {
- for (QaQueContent queContent : (Set) qaContent.getQaQueContents()) {
+ condition.setQuestions(new TreeSet(new QaQueContentComparator()));
+ for (QaQuestionDTO dto : condition.temporaryQuestionDTOSet) {
+ for (QaQuestion queContent : (Set) qaContent.getQaQuestions()) {
if (dto.getDisplayOrder().equals(String.valueOf(queContent.getDisplayOrder()))) {
condition.getQuestions().add(queContent);
}
@@ -452,23 +453,17 @@
}
/**
- * removes unused question entries from db removeRedundantQuestions (Map
- * mapQuestionContent, IQaService qaService, QaAuthoringForm
- * qaAuthoringForm)
+ * removes unused question entries from db
*
* @param mapQuestionContent
* @param qaService
* @param qaAuthoringForm
*/
- public void removeRedundantQuestions(ListlistQuestionContentDTO, IQaService qaService, QaAuthoringForm qaAuthoringForm,
+ public void removeRedundantQuestions(ListlistQuestionContentDTO, IQaService qaService, QaAuthoringForm qaAuthoringForm,
HttpServletRequest request, String toolContentID) {
- AuthoringUtil.logger.debug("removing unused entries... ");
- AuthoringUtil.logger.debug("toolContentID: " + toolContentID);
- QaContent qaContent = qaService.loadQa(new Long(toolContentID).longValue());
-
+ QaContent qaContent = qaService.getQa(new Long(toolContentID).longValue());
if (qaContent != null) {
- AuthoringUtil.logger.debug("qaContent uid: " + qaContent.getUid());
List allQuestions = qaService.getAllQuestionEntries(qaContent.getUid());
Iterator listIterator = allQuestions.iterator();
@@ -477,12 +472,12 @@
while (listIterator.hasNext()) {
++mapIndex;
- QaQueContent queContent = (QaQueContent) listIterator.next();
+ QaQuestion queContent = (QaQuestion) listIterator.next();
- AuthoringUtil.logger.info("Checking whether to remove question with id=" + queContent.getUid() + ", displayOrder=" + queContent.getDisplayOrder() + ", question=" + queContent.getQuestion());
+ //Checking whether to remove question with id queContent.getUid()
entryUsed = false;
int displayOrder = 0;
- for ( QaQuestionContentDTO questionDTO : listQuestionContentDTO ) {
+ for ( QaQuestionDTO questionDTO : listQuestionContentDTO ) {
++displayOrder;
if (StringUtils.equals(queContent.getQuestion(), questionDTO.getQuestion())) {
entryUsed = true;
@@ -492,11 +487,10 @@
if (entryUsed == false) {
- QaQueContent removeableQaQueContent = qaService.getQuestionContentByQuestionText(queContent
+ QaQuestion removeableQaQueContent = qaService.getQuestionContentByQuestionText(queContent
.getQuestion(), qaContent.getUid());
if (removeableQaQueContent != null) {
- // qaContent.getQaQueContents().remove(removeableQaQueContent);
- AuthoringUtil.logger.info("Removing question with id=" + removeableQaQueContent.getUid() + ", displayOrder=" + removeableQaQueContent.getDisplayOrder() + ", question=" + removeableQaQueContent.getQuestion());
+ //Removing question with id removeableQaQueContent.getUid()
qaService.removeQaQueContent(removeableQaQueContent);
}
@@ -507,21 +501,16 @@
}
/**
- * createQuestionContent(TreeMap mapQuestionContent, HttpServletRequest
- * request) return void
- *
* persist the questions in the Map the user has submitted
*
* LDEV-2526 note that questions have already been removed before this method is called, but
* their displayOrder fields haven't been updated yet. Note also that the given
* mapQuestionContent maps question numbers to question strings.
*/
- protected QaContent createQuestionContent(List listQuestionContentDTO, IQaService qaService,
+ protected QaContent createQuestionContent(List listQuestionContentDTO, IQaService qaService,
QaContent qaContent) {
- AuthoringUtil.logger.debug("createQuestionContent: content uid is: " + qaContent.getUid());
-
int displayOrder = 0;
- for ( QaQuestionContentDTO questionContentDTO : listQuestionContentDTO ) {
+ for ( QaQuestionDTO questionContentDTO : listQuestionContentDTO ) {
// LDEV-2526 Assuming here that removed questions exist in mapQuestionContent, but that the value is empty
// (this whole thing needs a rewrite). If empty, do not attempt to persist it.
@@ -533,11 +522,11 @@
++displayOrder;
- QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(questionText, qaContent.getUid());
+ QaQuestion existingQaQueContent = qaService.getQuestionContentByQuestionText(questionText, qaContent.getUid());
if (existingQaQueContent == null) {
- QaQueContent queContent = new QaQueContent(questionText, displayOrder, questionContentDTO.getFeedback(),
- questionContentDTO.isRequired(), qaContent, null, null);
- qaContent.getQaQueContents().add(queContent);
+ QaQuestion queContent = new QaQuestion(questionText, displayOrder, questionContentDTO.getFeedback(),
+ questionContentDTO.isRequired(), qaContent, null);
+ qaContent.getQaQuestions().add(queContent);
queContent.setQaContent(qaContent);
AuthoringUtil.logger.info("Creating new question with question=" + queContent.getQuestion() + ", displayOrder=" + queContent.getDisplayOrder());
@@ -557,9 +546,9 @@
return qaContent;
}
- public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) {
+ public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) {
AuthoringUtil.logger.debug("checkDuplicateQuestions: ");
- for (QaQuestionContentDTO questionDTO : listQuestionContentDTO ) {
+ for (QaQuestionDTO questionDTO : listQuestionContentDTO ) {
if ( questionDTO.getQuestion() != null && questionDTO.getQuestion().equals(newQuestion) ) {
return true;
}
@@ -568,9 +557,7 @@
}
/**
- * sorts the questions by the display order reOrganizeDisplayOrder(Map
- * mapQuestionContent, IQaService qaService, QaAuthoringForm
- * qaAuthoringForm, QaContent qaContent)
+ * sorts the questions by the display order
*
* @param mapQuestionContent
* @param qaService
@@ -580,26 +567,20 @@
public void reOrganizeDisplayOrder(IQaService qaService, QaAuthoringForm qaAuthoringForm,
QaContent qaContent) {
if (qaContent != null) {
- AuthoringUtil.logger.debug("content uid: " + qaContent.getUid());
List sortedQuestions = qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue());
Iterator listIterator = sortedQuestions.iterator();
int displayOrder = 1;
while (listIterator.hasNext()) {
- QaQueContent queContent = (QaQueContent) listIterator.next();
- AuthoringUtil.logger.debug("queContent: " + queContent.getQuestion() + " "
- + queContent.getDisplayOrder());
+ QaQuestion queContent = (QaQuestion) listIterator.next();
- QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(
+ QaQuestion existingQaQueContent = qaService.getQuestionContentByQuestionText(
queContent.getQuestion(), qaContent.getUid());
- AuthoringUtil.logger.debug("Changing the displayOrder from=" + existingQaQueContent.getDisplayOrder() + " to=" + displayOrder
- + " for existing question with id=" + existingQaQueContent.getUid() + ", contentId=" + existingQaQueContent.getQaContentId());
existingQaQueContent.setDisplayOrder(displayOrder);
qaService.saveOrUpdateQaQueContent(existingQaQueContent);
displayOrder++;
}
}
- AuthoringUtil.logger.debug("done with reOrganizeDisplayOrder...");
}
/**
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ClearSessionAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ClearSessionAction.java,v
diff -u -r1.6 -r1.7
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ClearSessionAction.java 19 Feb 2009 04:25:02 -0000 1.6
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ClearSessionAction.java 18 Mar 2011 17:13:09 -0000 1.7
@@ -28,7 +28,6 @@
import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction;
import org.lamsfoundation.lams.tool.ToolAccessMode;
-import org.lamsfoundation.lams.web.util.AttributeNames;
/**
* This class give a chance to clear HttpSession when user save/close authoring
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java,v
diff -u -r1.19 -r1.20
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java 7 Mar 2011 22:33:52 -0000 1.19
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java 18 Mar 2011 17:13:09 -0000 1.20
@@ -30,14 +30,14 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.tool.ToolAccessMode;
-import org.lamsfoundation.lams.tool.qa.GeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
-import org.lamsfoundation.lams.tool.qa.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.QaContent;
import org.lamsfoundation.lams.tool.qa.QaQueUsr;
import org.lamsfoundation.lams.tool.qa.QaSession;
+import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+import org.lamsfoundation.lams.tool.qa.util.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.util.QaBundler;
import org.lamsfoundation.lams.web.servlet.AbstractExportPortfolioServlet;
@@ -89,7 +89,7 @@
IQaService service = QaServiceProxy.getQaService(getServletContext());
QaContent content = null;
if (toolContentID != null) {
- content = service.retrieveQa(toolContentID);
+ content = service.getQa(toolContentID);
} else {
QaSession session = service.retrieveQaSession(toolSessionID);
if (session != null)
@@ -103,29 +103,21 @@
}
public void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) {
- logger.debug("starting learner mode...");
-
IQaService qaService = QaServiceProxy.getQaService(getServletContext());
- logger.debug("userID:" + userID);
- logger.debug("toolSessionID:" + toolSessionID);
-
if (userID == null || toolSessionID == null) {
String error = "Tool session Id or user Id is null. Unable to continue";
logger.error(error);
throw new QaApplicationException(error);
}
- QaSession qaSession = qaService.retrieveQaSessionOrNullById(toolSessionID.longValue());
+ QaSession qaSession = qaService.getSessionById(toolSessionID.longValue());
// If the learner hasn't answered yet, then they won't exist in the session.
// Yet we might be asked for their page, as the activity has been commenced.
// So need to do a "blank" page in that case
- QaQueUsr learner = qaService.getQaUserBySession(userID, qaSession.getUid());
- logger.debug("UserID: " + learner.getUid());
-
+ QaQueUsr learner = qaService.getUserByIdAndSession(userID, qaSession.getQaSessionId());
QaContent content = qaSession.getQaContent();
- logger.debug("content id: " + content.getQaContentId());
if (content == null) {
String error = "The content for this activity has not been defined yet.";
@@ -138,7 +130,7 @@
logger.debug("start refreshSummaryData for learner mode.");
GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(content);
- generalLearnerFlowDTO.setUserUid(learner != null ? learner.getUid().toString() : null);
+ generalLearnerFlowDTO.setUserUid(learner != null ? learner.getQueUsrId().toString() : null);
// if learner is null, don't want to show other people's answers
if (learner != null) {
@@ -170,7 +162,7 @@
throw new QaApplicationException(error);
}
- QaContent content = qaService.loadQa(toolContentID.longValue());
+ QaContent content = qaService.getQa(toolContentID.longValue());
if (content == null) {
String error = "Data is missing from the database. Unable to Continue";
@@ -184,8 +176,6 @@
GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(content);
qaMonitoringAction.refreshSummaryData(request, content, qaService, true, false, null, null,
generalLearnerFlowDTO, false, "All");
- logger.debug("end refreshSummaryData for teacher mode.");
- logger.debug("teacher uses content id: " + content.getQaContentId());
generalLearnerFlowDTO = (GeneralLearnerFlowDTO) request.getAttribute(GENERAL_LEARNER_FLOW_DTO);
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java,v
diff -u -r1.43 -r1.44
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 28 Feb 2011 12:21:57 -0000 1.43
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 18 Mar 2011 17:13:09 -0000 1.44
@@ -24,27 +24,27 @@
package org.lamsfoundation.lams.tool.qa.web;
import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.Map;
+import java.util.Set;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
-import org.lamsfoundation.lams.tool.qa.GeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
-import org.lamsfoundation.lams.tool.qa.QaComparator;
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.QaQuestionContentDTO;
+import org.lamsfoundation.lams.tool.qa.QaQuestion;
import org.lamsfoundation.lams.tool.qa.QaSession;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
-import org.lamsfoundation.lams.tool.qa.QaUtils;
+import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.util.QaComparator;
+import org.lamsfoundation.lams.tool.qa.web.form.QaLearningForm;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
@@ -60,8 +60,7 @@
static Logger logger = Logger.getLogger(LearningUtil.class.getName());
public static void saveFormRequestData(HttpServletRequest request, QaLearningForm qaLearningForm) {
- logger.debug("saving form request data...");
- String toolSessionID = request.getParameter("toolSessionID");
+ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
qaLearningForm.setToolSessionID(toolSessionID);
String userID = request.getParameter("userID");
@@ -72,12 +71,9 @@
String totalQuestionCount = request.getParameter("totalQuestionCount");
qaLearningForm.setTotalQuestionCount(totalQuestionCount);
-
- logger.debug("done saving form request data.");
}
public static GeneralLearnerFlowDTO buildGeneralLearnerFlowDTO(QaContent qaContent) {
- logger.debug("starting buildMcGeneralLearnerFlowDTO: " + qaContent.getUid());
GeneralLearnerFlowDTO generalLearnerFlowDTO = new GeneralLearnerFlowDTO();
generalLearnerFlowDTO.setActivityTitle(qaContent.getTitle());
generalLearnerFlowDTO.setActivityInstructions(qaContent.getInstructions());
@@ -94,157 +90,80 @@
generalLearnerFlowDTO.setAllowRichEditor(new Boolean(qaContent.isAllowRichEditor()).toString());
generalLearnerFlowDTO.setAllowRateAnswers(new Boolean(qaContent.isAllowRateAnswers()).toString());
- generalLearnerFlowDTO.setTotalQuestionCount(new Integer(qaContent.getQaQueContents().size()));
+ generalLearnerFlowDTO.setTotalQuestionCount(new Integer(qaContent.getQaQuestions().size()));
- Map mapQuestions = new TreeMap();
-
- Iterator contentIterator = qaContent.getQaQueContents().iterator();
- while (contentIterator.hasNext()) {
- QaQueContent qaQueContent = (QaQueContent) contentIterator.next();
- if (qaQueContent != null) {
- int displayOrder = qaQueContent.getDisplayOrder();
- if (displayOrder != 0) {
- /*
- * add the question to the questions Map in the displayOrder
- */
- QaQuestionContentDTO questionDTO = new QaQuestionContentDTO(qaQueContent);
- mapQuestions.put(questionDTO.getDisplayOrder(), questionDTO );
- }
+ //create mapQuestions
+ Map mapQuestions = new TreeMap();
+ for (QaQuestion question : qaContent.getQaQuestions()) {
+ int displayOrder = question.getDisplayOrder();
+ if (displayOrder != 0) {
+ //add the question to the questions Map in the displayOrder
+ QaQuestionDTO questionDTO = new QaQuestionDTO(question);
+ mapQuestions.put(questionDTO.getDisplayOrder(), questionDTO);
}
}
-
generalLearnerFlowDTO.setMapQuestionContentLearner(mapQuestions);
+
return generalLearnerFlowDTO;
}
- /**
- * createUsersAndResponses(Map mapAnswers, HttpServletRequest request)
- * create users of the responses
- *
- * @param mapAnswers,
- * request return void
- *
- */
- protected void createUsersAndResponses(Map mapAnswers, HttpServletRequest request, IQaService qaService,
- Long toolContentID, Long toolSessionID) {
- logger.debug("toolContentID: " + toolContentID);
- logger.debug("toolSessionID: " + toolSessionID);
+// /**
+// * Create users of the responses
+// *
+// * @param mapAnswers
+// *
+// */
+// public static void storeResponses(Map mapAnswers, IQaService qaService, Long toolContentID, Long toolSessionID) {
+//
+// // get back login user DTO
+// HttpSession ss = SessionManager.getSession();
+// UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+// Long userId = new Long(toolUser.getUserID().longValue());
+//
+// // obtain QaContent to be used in creating QaQueUsr
+// QaContent qaContent = qaService.getQa(toolContentID.longValue());
+//
+// QaQueUsr user = qaService.getUserByIdAndSession(userId, toolSessionID);
+//
+// // check if Attempt to Entry is allowed, if so create the responses
+// if (!user.isResponseFinalized() || !qaContent.isLockWhenFinished()) {
+//
+// Set questionsToStore;
+// if (qaContent.isQuestionsSequenced()) {
+// String currentQuestionIndex = qaLearningForm.getCurrentQuestionIndex();
+// QaQuestion currentQuestion = qaService.getQuestionContentByDisplayOrder(new Long(currentQuestionIndex), qaContent.getQaContentId());
+// questionsToStore = new LinkedHashSet();
+// questionsToStore.add(currentQuestion);
+//
+// } else {
+// questionsToStore = qaContent.getQaQuestions();
+// }
+//
+// for (QaQuestion question : questionsToStore) {
+//
+// String displayOrder = new Long(question.getDisplayOrder()).toString();
+// String answer = (String) mapAnswers.get(displayOrder);
+//
+// QaUsrResp response = qaService.getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid());
+// // if response doesn't exist
+// if (response == null) {
+// response = new QaUsrResp(answer, new Date(System.currentTimeMillis()), "", question, user, true);
+// qaService.createQaUsrResp(response);
+//
+// //if answer has changed
+// } else if (! answer.equals(response.getAnswer())) {
+// response.setAnswer(answer);
+// response.setAttemptTime(new Date(System.currentTimeMillis()));
+// response.setTimezone("");
+// qaService.updateUserResponse(response);
+// }
+// }
+//
+// }
+// }
- HttpSession ss = SessionManager.getSession();
- /* get back login user DTO */
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
- logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
-
- String userName = toolUser.getLogin();
- String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
-
- Long userId = new Long(toolUser.getUserID().longValue());
-
- /*
- * obtain QaContent to be used in creating QaQueUsr
- */
- QaContent qaContent = qaService.retrieveQa(toolContentID.longValue());
-
- QaSession qaSession = qaService.retrieveQaSessionOrNullById(toolSessionID.longValue());
-
- Iterator contentIterator = qaContent.getQaQueContents().iterator();
-
- QaQueUsr qaQueUsr = new QaQueUsr(userId, userName, fullName, null, qaSession, new TreeSet());
-
-
- logger.debug("session uid: " + qaSession.getUid());
- /*note that it is possible for a user to already exist from another tool session. In this case don't add any more user record*/
- QaQueUsr qaQueUsrLocal = qaService.getQaUserBySession(userId, qaSession.getUid());
-
- if ((qaQueUsr != null) && (qaQueUsrLocal == null)) {
- qaQueUsr = createUser(request, toolSessionID, qaService);
- } else {
- qaQueUsr = qaQueUsrLocal;
- }
-
- boolean isResponseFinalized = qaQueUsr.isResponseFinalized();
-
- boolean lockWhenFinished = qaContent.isLockWhenFinished();
-
- boolean enableAttemptEntry = false;
- boolean userAttemptExist = false;
-
- if (!isResponseFinalized) {
- enableAttemptEntry = true;
- }
-
- if (isResponseFinalized && (!lockWhenFinished)) {
- userAttemptExist = true;
- enableAttemptEntry = true;
- }
-
- if (enableAttemptEntry) {
- logger.debug("enableAttemptEntry is true, so creating the responses: ");
- while (contentIterator.hasNext()) {
- QaQueContent qaQueContent = (QaQueContent) contentIterator.next();
- if (qaQueContent != null) {
-
- String displayOrder = new Long(qaQueContent.getDisplayOrder()).toString();
- String answer = (String) mapAnswers.get(displayOrder);
-
-
-
- String timezoneId = "";
-
- List attempts = qaService.getAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), qaQueContent
- .getUid());
-
- if (userAttemptExist) {
- qaService.removeAttemptsForUserAndQuestionContent(qaQueUsr.getUid(), qaQueContent.getUid());
-
- QaUsrResp qaUsrResp = new QaUsrResp(answer, false, new Date(System.currentTimeMillis()),
- timezoneId, qaQueContent, qaQueUsr, true);
-
- if (qaUsrResp != null) {
- qaService.createQaUsrResp(qaUsrResp);
- }
- } else {
- if ((attempts != null) && (attempts.size() > 0)) {
- } else {
- QaUsrResp qaUsrResp = new QaUsrResp(answer, false, new Date(System.currentTimeMillis()),
- timezoneId, qaQueContent, qaQueUsr, true);
-
- if (qaUsrResp != null) {
- qaService.createQaUsrResp(qaUsrResp);
- }
- }
- }
- }
- }
-
- }
- if (qaQueUsr != null) {
- qaQueUsr.setResponseFinalized(true);
- logger.debug("finalized user input");
- qaService.updateQaQueUsr(qaQueUsr);
- }
- }
-
- public static QaQueUsr createUser(HttpServletRequest request, Long toolSessionID, IQaService qaService) {
- logger.debug("creating a new user in the tool db, toolSessionID: " + toolSessionID);
-
- Long queUsrId = QaUtils.getUserId();
- String username = QaUtils.getUserName();
- String fullname = QaUtils.getUserFullName();
-
- QaSession qaSession = qaService.retrieveQaSessionOrNullById(toolSessionID.longValue());
-
- QaQueUsr qaQueUsr = new QaQueUsr(queUsrId, username, fullname, null, qaSession, new TreeSet());
-
- qaService.createQaQueUsr(qaQueUsr);
- return qaQueUsr;
- }
-
- protected String getRemainingQuestionCount(int currentQuestionIndex, String totalQuestionCount) {
- logger.debug("totalQuestionCount: " + totalQuestionCount);
+ public static String getRemainingQuestionCount(int currentQuestionIndex, String totalQuestionCount) {
int remainingQuestionCount = new Long(totalQuestionCount).intValue() - currentQuestionIndex + 1;
- logger.debug("remainingQuestionCount: " + remainingQuestionCount);
-
return new Integer(remainingQuestionCount).toString();
}
@@ -255,26 +174,54 @@
* @param qaLearningForm
* return void
*/
- protected String feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex,
+ public static String feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex,
String totalQuestionCount) {
- logger.debug("totalQuestionCount: " + totalQuestionCount);
int remainingQuestionCount = new Long(totalQuestionCount).intValue() - currentQuestionIndex + 1;
- logger.debug("remainingQuestionCount: " + remainingQuestionCount);
String userFeedback = "";
- if (remainingQuestionCount != 0)
+ if (remainingQuestionCount != 0) {
userFeedback = "Remaining question count: " + remainingQuestionCount;
- else
+ } else {
userFeedback = "End of the questions.";
+ }
return userFeedback;
}
-
- public void setContentInUse(long toolContentID, IQaService qaService) {
- QaContent qaContent = qaService.loadQa(toolContentID);
-
- qaContent.setContentLocked(true);
- logger.debug("content with id : " + toolContentID + "has been marked LOCKED");
- qaService.updateQa(qaContent);
- logger.debug("content with id : " + toolContentID + "has been marked LOCKED and updated in the db");
+
+ /**
+ */
+ public static void populateAnswers(Map sessionMap, QaContent qaContent, QaQueUsr qaQueUsr,
+ Map mapQuestions, GeneralLearnerFlowDTO generalLearnerFlowDTO,
+ IQaService qaService) {
+
+ //create mapAnswers
+ Map mapAnswers = (Map) sessionMap.get(MAP_ALL_RESULTS_KEY);
+ if (mapAnswers == null) {
+ mapAnswers = new TreeMap(new QaComparator());
+
+ // get responses from DB
+ Map mapAnswersFromDb = new TreeMap();
+ for (QaQuestion question : qaContent.getQaQuestions()) {
+ Long questionUid = question.getUid();
+ QaUsrResp dbResponse = qaService.getResponseByUserAndQuestion(qaQueUsr.getQueUsrId(), questionUid);
+ if (dbResponse != null) {
+ mapAnswersFromDb.put(String.valueOf(question.getDisplayOrder()), dbResponse.getAnswer());
+ }
+ }
+
+ // maybe we have come in from the review screen, if so get the answers from db.
+ if (mapAnswersFromDb.size() > 0) {
+ mapAnswers.putAll(mapAnswersFromDb);
+ } else {
+ for (Map.Entry pairs : mapQuestions.entrySet()) {
+ mapAnswers.put(pairs.getKey().toString(), "");
+ }
+ }
+ }
+ String currentAnswer = (String) mapAnswers.get("1");
+ generalLearnerFlowDTO.setCurrentQuestionIndex(new Integer(1));
+ generalLearnerFlowDTO.setCurrentAnswer(currentAnswer);
+ sessionMap.put(MAP_SEQUENTIAL_ANSWERS_KEY, mapAnswers);
+ generalLearnerFlowDTO.setMapAnswers(mapAnswers);
+ sessionMap.put(MAP_ALL_RESULTS_KEY, mapAnswers);
}
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/MonitoringUtil.java,v
diff -u -r1.44 -r1.45
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 28 Feb 2011 12:21:57 -0000 1.44
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 18 Mar 2011 17:13:09 -0000 1.45
@@ -35,20 +35,20 @@
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
-import org.lamsfoundation.lams.tool.qa.QaAllGroupsDTO;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
import org.lamsfoundation.lams.tool.qa.QaContent;
-import org.lamsfoundation.lams.tool.qa.QaMonitoredAnswersDTO;
-import org.lamsfoundation.lams.tool.qa.QaMonitoredUserDTO;
-import org.lamsfoundation.lams.tool.qa.QaQueContent;
import org.lamsfoundation.lams.tool.qa.QaQueUsr;
+import org.lamsfoundation.lams.tool.qa.QaQuestion;
import org.lamsfoundation.lams.tool.qa.QaSession;
-import org.lamsfoundation.lams.tool.qa.QaStatsDTO;
-import org.lamsfoundation.lams.tool.qa.QaStringComparator;
import org.lamsfoundation.lams.tool.qa.QaUsrResp;
-import org.lamsfoundation.lams.tool.qa.QaUtils;
import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaAllGroupsDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredAnswersDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredUserDTO;
+import org.lamsfoundation.lams.tool.qa.dto.QaStatsDTO;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.util.QaStringComparator;
+import org.lamsfoundation.lams.tool.qa.util.QaUtils;
/**
*
@@ -61,123 +61,46 @@
static Logger logger = Logger.getLogger(MonitoringUtil.class.getName());
/**
- * determine whether all the tool sessions for a particular content has been
- * COMPLETED boolean isSessionsSync(HttpServletRequest request, long
- * toolContentId)
- *
- * @param toolContentId
- * @return boolean
- */
- public boolean isSessionsSync(QaContent qaContent) {
- /*
- * iterate all the tool sessions, if even one session is INCOMPLETE, the function returns false
- */
- if (qaContent != null) {
- Iterator sessionIterator = qaContent.getQaSessions().iterator();
- while (sessionIterator.hasNext()) {
- QaSession qaSession = (QaSession) sessionIterator.next();
- if (qaSession.getSession_status().equalsIgnoreCase(QaSession.INCOMPLETE))
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * updateResponse(HttpServletRequest request, String responseId, String
- * updatedResponse)
- *
- * @param qaService
- * @param responseId
- * @param updatedResponse
- */
- public void updateResponse(IQaService qaService, String responseId, String updatedResponse) {
- logger.debug("load response with responseId: " + new Long(responseId).longValue());
- QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue());
- qaUsrResp.setAnswer(updatedResponse);
- qaService.updateQaUsrResp(qaUsrResp);
- }
-
- /**
- * hideResponse(HttpServletRequest request, String responseId)
- *
- * @param qaService
- * @param responseId
- */
- public void hideResponse(IQaService qaService, String responseId) {
- logger.debug("load response with responseId for hiding: " + new Long(responseId).longValue());
- QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue());
- qaUsrResp.setHidden(true);
- qaService.updateQaUsrResp(qaUsrResp);
- }
-
- /**
- * unHideResponse(HttpServletRequest request, String responseId)
- *
- * @param request
- * @param responseId
- */
- public void unHideResponse(IQaService qaService, String responseId) {
- logger.debug("load response with responseId for un-hiding: " + new Long(responseId).longValue());
- QaUsrResp qaUsrResp = qaService.retrieveQaUsrResp(new Long(responseId).longValue());
- qaUsrResp.setHidden(false);
- qaService.updateQaUsrResp(qaUsrResp);
- }
-
- /**
* populates all the tool sessions in a map
- * populateToolSessions(HttpServletRequest request, McContent mcContent)
*
* @param request
* @param mcContent
* @return Map
*/
public static Map populateToolSessions(HttpServletRequest request, QaContent qaContent, IQaService qaService) {
List sessionsList = qaService.getSessionNamesFromContent(qaContent);
- logger.debug("sessionsList size is:..." + sessionsList.size());
-
+
Map sessionsMap = QaUtils.convertToStringMap(sessionsList, "String");
-
if (sessionsMap.isEmpty()) {
- logger.debug("sessionsMap size is 0:");
sessionsMap.put(new Long(1).toString(), "None");
} else {
- logger.debug("sessionsMap has some entries: " + sessionsMap.size());
sessionsMap.put(new Long(sessionsMap.size() + 1).toString(), "All");
}
return sessionsMap;
}
/**
* populates all the tool sessions in a map
- * populateToolSessions(HttpServletRequest request, McContent mcContent)
*
* @param request
* @param mcContent
* @return Map
*/
public static Map populateToolSessionsId(HttpServletRequest request, QaContent qaContent, IQaService qaService) {
List sessionsList = qaService.getSessionsFromContent(qaContent);
- logger.debug("sessionsList size is:..." + sessionsList.size());
Map sessionsMap = QaUtils.convertToStringMap(sessionsList, "Long");
- logger.debug("sessionsMap size:..." + sessionsMap.size());
-
if (sessionsMap.isEmpty()) {
- logger.debug("sessionsMap size is 0:");
sessionsMap.put(new Long(1).toString(), "None");
} else {
- logger.debug("sessionsMap has some entries: " + sessionsMap.size());
sessionsMap.put(new Long(sessionsMap.size() + 1).toString(), "All");
}
return sessionsMap;
}
/**
* ends up populating the attempt history for all the users of all the tool
- * sessions for a content buildGroupsQuestionData(HttpServletRequest
- * request, McContent mcContent)
+ * sessions for a content
*
* User id is needed if isUserNamesVisible is false && is learnerRequest =
* true, as it is required to work out if the data being analysed is the
@@ -189,14 +112,11 @@
*/
public static List buildGroupsQuestionData(HttpServletRequest request, QaContent qaContent, IQaService qaService,
boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId) {
- logger.debug("buildGroupsQuestionData: " + currentSessionId);
-
List listQuestions = qaService.getAllQuestionEntries(qaContent.getUid());
String sessionName = "";
if ((currentSessionId != null) && (!currentSessionId.equals("All"))) {
- QaSession qaSession = qaService.retrieveQaSessionOrNullById(new Long(currentSessionId).longValue());
-
+ QaSession qaSession = qaService.getSessionById(new Long(currentSessionId).longValue());
sessionName = qaSession.getSession_name();
}
request.setAttribute(CURRENT_SESSION_NAME, sessionName);
@@ -205,18 +125,17 @@
Iterator itListQuestions = listQuestions.iterator();
while (itListQuestions.hasNext()) {
- QaQueContent qaQueContent = (QaQueContent) itListQuestions.next();
+ QaQuestion qaQuestion = (QaQuestion) itListQuestions.next();
- if (qaQueContent != null) {
+ if (qaQuestion != null) {
QaMonitoredAnswersDTO qaMonitoredAnswersDTO = new QaMonitoredAnswersDTO();
- qaMonitoredAnswersDTO.setQuestionUid(qaQueContent.getUid().toString());
- qaMonitoredAnswersDTO.setQuestion(qaQueContent.getQuestion());
- qaMonitoredAnswersDTO.setFeedback(qaQueContent.getFeedback());
+ qaMonitoredAnswersDTO.setQuestionUid(qaQuestion.getUid().toString());
+ qaMonitoredAnswersDTO.setQuestion(qaQuestion.getQuestion());
+ qaMonitoredAnswersDTO.setFeedback(qaQuestion.getFeedback());
qaMonitoredAnswersDTO.setSessionName(sessionName);
- logger.debug("using allUsersData to retrieve users data: " + isUserNamesVisible);
- Map questionAttemptData = buildGroupsAttemptData(request, qaContent, qaService, qaQueContent,
- qaQueContent.getUid().toString(), isUserNamesVisible, isLearnerRequest, currentSessionId,
+ Map questionAttemptData = buildGroupsAttemptData(request, qaContent, qaService,
+ qaQuestion.getUid().toString(), isUserNamesVisible, isLearnerRequest, currentSessionId,
userId);
qaMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData);
listMonitoredAnswersContainerDTO.add(qaMonitoredAnswersDTO);
@@ -232,13 +151,10 @@
* or to work out which is the user's answers (for not show all answers).
*/
public static Map buildGroupsAttemptData(HttpServletRequest request, QaContent qaContent, IQaService qaService,
- QaQueContent qaQueContent, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest,
- String currentSessionId, String userId) {
- logger.debug("doing buildGroupsAttemptData...");
+ String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId,
+ String userId) {
+ List
-
+
Index: lams_tool_laqa/web/WEB-INF/struts-config.xml
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/web/WEB-INF/struts-config.xml,v
diff -u -r1.46 -r1.47
--- lams_tool_laqa/web/WEB-INF/struts-config.xml 9 Dec 2008 05:38:15 -0000 1.46
+++ lams_tool_laqa/web/WEB-INF/struts-config.xml 18 Mar 2011 17:14:26 -0000 1.47
@@ -13,13 +13,13 @@
-
-
-
-
-
+
+
+
+
+
-
+
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/web/includes/javascript/jquery.blockUI.js'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_laqa/web/includes/javascript/jquery.form.js'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_laqa/web/learning/AnswersContent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/web/learning/AnswersContent.jsp,v
diff -u -r1.30 -r1.31
--- lams_tool_laqa/web/learning/AnswersContent.jsp 1 Nov 2010 12:22:25 -0000 1.30
+++ lams_tool_laqa/web/learning/AnswersContent.jsp 18 Mar 2011 17:14:25 -0000 1.31
@@ -34,12 +34,38 @@
-
+
+
+
+
+
+
+