getAllQuestionEntries(final long contentUid) {
List list = getSession().createQuery(QaQuestionDAO.LOAD_QUESTION_BY_CONTENT_UID).setLong(
"uid", contentUid).list();
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java
===================================================================
diff -u -rbe07c35c372d904a65581d98660e73f3b13b69db -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java (.../QaSessionDAO.java) (revision be07c35c372d904a65581d98660e73f3b13b69db)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaSessionDAO.java (.../QaSessionDAO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -38,7 +38,6 @@
public class QaSessionDAO extends HibernateDaoSupport implements IQaSessionDAO {
private static final String COUNT_SESSION_COMPLETE = "from qaSession in class QaSession where qaSession.session_status='COMPLETE'";
private static final String GET_SESSION_IDS_FROM_CONTENT = "select qas.qaSessionId from QaSession qas where qas.qaContent=:qaContent order by qas.session_name asc";
- private static final String GET_SESSION_NAMES_FROM_CONTENT = "select qas.session_name from QaSession qas where qas.qaContent=:qaContent order by qas.session_name asc";
public int countSessionComplete(QaContent qa) {
List list = getSession().createQuery(COUNT_SESSION_COMPLETE).list();
@@ -70,7 +69,7 @@
/**
* @see org.lamsfoundation.lams.tool.survey.dao.interfaces.ISurveySessionDAO#CreateSurveySession(com.lamsinternational.tool.survey.domain.SurveySession)
*/
- public void CreateQaSession(QaSession session) {
+ public void createSession(QaSession session) {
this.getSession().setFlushMode(FlushMode.AUTO);
this.getHibernateTemplate().save(session);
}
@@ -95,8 +94,4 @@
return (getHibernateTemplate().findByNamedParam(GET_SESSION_IDS_FROM_CONTENT, "qaContent", qaContent));
}
- public List getSessionNamesFromContent(QaContent qaContent) {
- return (getHibernateTemplate().findByNamedParam(GET_SESSION_NAMES_FROM_CONTENT, "qaContent", qaContent));
- }
-
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20140527.sql
===================================================================
diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20140527.sql (.../patch20140527.sql) (revision c5457cc74f3986b393bc2947604b17168ba54dfb)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dbupdates/patch20140527.sql (.../patch20140527.sql) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -5,6 +5,7 @@
-- LDEV-3236 Ability to change, add, remove Q&A questions even after student have reached it
ALTER TABLE tl_laqa11_content DROP COLUMN content_inUse;
+ALTER TABLE tl_laqa11_content DROP COLUMN synch_in_monitor;
ALTER TABLE tl_laqa11_content ADD COLUMN notify_response_submit TINYINT(1) NOT NULL DEFAULT 0;
Fisheye: Tag a7661f206a3f21114f1c05f9a29f56e20f5e35f0 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?
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java
===================================================================
diff -u -r501ddb69e1c739b90388262f41b4927356cb0449 -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision 501ddb69e1c739b90388262f41b4927356cb0449)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaConditionDTO.java (.../QaConditionDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -38,7 +38,7 @@
super(condition, toolActivityUIID);
for (QaQueContent question : condition.getQuestions()) {
QaQueContent questionCopy = new QaQueContent(question.getQuestion(), question.getDisplayOrder(), null,
- question.isRequired(), null, null);
+ question.isRequired(), null);
getQuestions().add(questionCopy);
}
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java
===================================================================
diff -u -rdfbc0a5728344573bc1bcbf0095e4f2778d3ad8d -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java (.../QaGeneralAuthoringDTO.java) (revision dfbc0a5728344573bc1bcbf0095e4f2778d3ad8d)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaGeneralAuthoringDTO.java (.../QaGeneralAuthoringDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -24,7 +24,6 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.dto;
-import org.apache.commons.lang.builder.ToStringBuilder;
/**
*
@@ -36,21 +35,13 @@
public class QaGeneralAuthoringDTO implements Comparable {
protected String toolContentID;
protected String currentTab;
- protected String activeModule;
- protected String defineLaterInEditMode;
- protected String showAuthoringTabs;
- protected String monitoringOriginatedDefineLater;
- protected String targetMode;
- protected String defaultQuestionContent;
- protected String defaultContentIdStr;
protected String activityTitle;
protected String activityInstructions;
protected String usernameVisible;
protected String allowRateAnswers;
protected String showOtherAnswers;
protected String reflect;
- protected String synchInMonitor;
protected String questionsSequenced;
protected String lockWhenFinished;
protected String editActivityEditMode;
@@ -59,35 +50,13 @@
protected Boolean useSelectLeaderToolOuput;
protected String httpSessionID;
- protected String requestedModule;
- protected String isDefineLater;
- protected String sbmtSuccess;
protected String userExceptionQuestionsDuplicate;
protected String contentFolderID;
protected String editableQuestionText;
protected String editableQuestionFeedback;
- public String toString() {
- return new ToStringBuilder(this).append("toolContentID: ", toolContentID)
- .append("contentFolderID: ", contentFolderID).append("httpSessionID: ", httpSessionID)
- .append("currentTab: ", currentTab).append("activeModule: ", activeModule)
- .append("defineLaterInEditMode: ", defineLaterInEditMode)
- .append("showAuthoringTabs: ", showAuthoringTabs)
- .append("monitoringOriginatedDefineLater: ", monitoringOriginatedDefineLater)
- .append("targetMode: ", targetMode).append("defaultQuestionContent: ", defaultQuestionContent)
- .append("defaultContentIdStr: ", defaultContentIdStr).append("activityTitle: ", activityTitle)
- .append("activityInstructions: ", activityInstructions).append("reflect: ", reflect)
- .append("usernameVisible: ", usernameVisible).append("allowRateAnswers: ", allowRateAnswers)
- .append("showOtherAnswers: ", showOtherAnswers).append("synchInMonitor: ", synchInMonitor)
- .append("questionsSequenced: ", questionsSequenced).append("lockWhenFinished: ", lockWhenFinished)
- .append("editActivityEditMode: ", editActivityEditMode)
- .append("reflectionSubject: ", reflectionSubject).append("requestedModule: ", requestedModule)
- .append("isDefineLater: ", isDefineLater).append("sbmtSuccess: ", sbmtSuccess)
- .append("userExceptionQuestionsDuplicate: ", userExceptionQuestionsDuplicate).toString();
- }
-
/**
* @return Returns the userExceptionQuestionsDuplicate.
*/
@@ -134,21 +103,6 @@
}
/**
- * @return Returns the isDefineLater.
- */
- public String getIsDefineLater() {
- return isDefineLater;
- }
-
- /**
- * @param isDefineLater
- * The isDefineLater to set.
- */
- public void setIsDefineLater(String isDefineLater) {
- this.isDefineLater = isDefineLater;
- }
-
- /**
* @return Returns the toolContentID.
*/
public String getToolContentID() {
@@ -163,81 +117,6 @@
this.toolContentID = toolContentID;
}
- /**
- * @return Returns the targetMode.
- */
- public String getTargetMode() {
- return targetMode;
- }
-
- /**
- * @param targetMode
- * The targetMode to set.
- */
- public void setTargetMode(String targetMode) {
- this.targetMode = targetMode;
- }
-
- /**
- * @return Returns the monitoringOriginatedDefineLater.
- */
- public String getMonitoringOriginatedDefineLater() {
- return monitoringOriginatedDefineLater;
- }
-
- /**
- * @param monitoringOriginatedDefineLater
- * The monitoringOriginatedDefineLater to set.
- */
- public void setMonitoringOriginatedDefineLater(String monitoringOriginatedDefineLater) {
- this.monitoringOriginatedDefineLater = monitoringOriginatedDefineLater;
- }
-
- /**
- * @return Returns the activeModule.
- */
- public String getActiveModule() {
- return activeModule;
- }
-
- /**
- * @param activeModule
- * The activeModule to set.
- */
- public void setActiveModule(String activeModule) {
- this.activeModule = activeModule;
- }
-
- /**
- * @return Returns the defineLaterInEditMode.
- */
- public String getDefineLaterInEditMode() {
- return defineLaterInEditMode;
- }
-
- /**
- * @param defineLaterInEditMode
- * The defineLaterInEditMode to set.
- */
- public void setDefineLaterInEditMode(String defineLaterInEditMode) {
- this.defineLaterInEditMode = defineLaterInEditMode;
- }
-
- /**
- * @return Returns the showAuthoringTabs.
- */
- public String getShowAuthoringTabs() {
- return showAuthoringTabs;
- }
-
- /**
- * @param showAuthoringTabs
- * The showAuthoringTabs to set.
- */
- public void setShowAuthoringTabs(String showAuthoringTabs) {
- this.showAuthoringTabs = showAuthoringTabs;
- }
-
public int compareTo(Object o) {
QaGeneralAuthoringDTO qaGeneralAuthoringDTO = (QaGeneralAuthoringDTO) o;
@@ -248,51 +127,6 @@
}
/**
- * @return Returns the defaultContentIdStr.
- */
- public String getDefaultContentIdStr() {
- return defaultContentIdStr;
- }
-
- /**
- * @param defaultContentIdStr
- * The defaultContentIdStr to set.
- */
- public void setDefaultContentIdStr(String defaultContentIdStr) {
- this.defaultContentIdStr = defaultContentIdStr;
- }
-
- /**
- * @return Returns the defaultQuestionContent.
- */
- public String getDefaultQuestionContent() {
- return defaultQuestionContent;
- }
-
- /**
- * @param defaultQuestionContent
- * The defaultQuestionContent to set.
- */
- public void setDefaultQuestionContent(String defaultQuestionContent) {
- this.defaultQuestionContent = defaultQuestionContent;
- }
-
- /**
- * @return Returns the requestedModule.
- */
- public String getRequestedModule() {
- return requestedModule;
- }
-
- /**
- * @param requestedModule
- * The requestedModule to set.
- */
- public void setRequestedModule(String requestedModule) {
- this.requestedModule = requestedModule;
- }
-
- /**
* @return Returns the activityInstructions.
*/
public String getActivityInstructions() {
@@ -338,21 +172,6 @@
}
/**
- * @return Returns the synchInMonitor.
- */
- public String getSynchInMonitor() {
- return synchInMonitor;
- }
-
- /**
- * @param synchInMonitor
- * The synchInMonitor to set.
- */
- public void setSynchInMonitor(String synchInMonitor) {
- this.synchInMonitor = synchInMonitor;
- }
-
- /**
* @return Returns the usernameVisible.
*/
public String getUsernameVisible() {
@@ -398,21 +217,6 @@
}
/**
- * @return Returns the sbmtSuccess.
- */
- public String getSbmtSuccess() {
- return sbmtSuccess;
- }
-
- /**
- * @param sbmtSuccess
- * The sbmtSuccess to set.
- */
- public void setSbmtSuccess(String sbmtSuccess) {
- this.sbmtSuccess = sbmtSuccess;
- }
-
- /**
* @return Returns the contentFolderID.
*/
public String getContentFolderID() {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java
===================================================================
diff -u -r501ddb69e1c739b90388262f41b4927356cb0449 -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision 501ddb69e1c739b90388262f41b4927356cb0449)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/QaQuestionDTO.java (.../QaQuestionDTO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -23,33 +23,26 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.dto;
-import org.apache.commons.lang.builder.ToStringBuilder;
import org.lamsfoundation.lams.tool.qa.QaQueContent;
/**
- *
* DTO that holds users attempt history data for jsp purposes
- *
*
* @author Ozgur Demirtas
*/
public class QaQuestionDTO implements Comparable {
+ private Long uid;
private String question;
private String displayOrder;
private String feedback;
private boolean required;
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("question:", question).append("feedback:", feedback).append(
- "displayOrder:", displayOrder).append("required:", Boolean.toString(required)).toString();
- }
-
public QaQuestionDTO(QaQueContent que) {
this.question = que.getQuestion();
this.displayOrder = new Integer(que.getDisplayOrder()).toString();
this.feedback = que.getFeedback() != null ? que.getFeedback() : " ";
this.required = que.isRequired();
+ this.uid = que.getUid();
}
public QaQuestionDTO(String question, String displayOrder, String feedback, boolean required) {
@@ -68,8 +61,23 @@
return 0;
}
}
+
+ /**
+ * @return Returns the uid.
+ */
+ public Long getUid() {
+ return uid;
+ }
/**
+ * @param uid
+ * The uid to set.
+ */
+ public void setUid(Long uid) {
+ this.uid = uid;
+ }
+
+ /**
* @return Returns the displayOrder.
*/
public String getDisplayOrder() {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java
===================================================================
diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision c5457cc74f3986b393bc2947604b17168ba54dfb)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -25,6 +25,7 @@
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
@@ -40,8 +41,8 @@
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.tool.qa.dto.QaQuestionDTO;
import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO;
-import org.lamsfoundation.lams.tool.qa.util.QaApplicationException;
import org.lamsfoundation.lams.util.audit.IAuditService;
/**
@@ -50,61 +51,58 @@
* @author Ozgur Demirtas
*/
public interface IQaService {
-
+
/**
* @param user
* @param toolSessionId
* @return
*/
boolean isUserGroupLeader(QaQueUsr user, Long toolSessionId);
-
+
/**
* Set specified user as a leader. Also the previous leader (if any) is marked as non-leader.
*
* @param userId
* @param toolSessionID
*/
QaQueUsr checkLeaderSelectToolForSessionLeader(QaQueUsr user, Long toolSessionID);
-
+
/**
- * Check user has the same answers logs as group leader. If not - creates missing ones.
+ * Check user has the same answers logs as group leader. If not - creates missing ones.
*
* @param user
* @param leader
*/
void copyAnswersFromLeader(QaQueUsr user, QaQueUsr leader);
-
+
/**
* Get users by given toolSessionID.
*
* @param toolSessionID
* @return
*/
- List getUsersBySession(Long toolSessionID);
-
+ List getUsersBySessionId(Long toolSessionID);
+
/**
* Return the qa object according to the requested content id.
*
* @param toolContentId
- * the tool content id
+ * the tool content id
* @return the qa object
*/
- QaContent getQa(long toolContentId) throws QaApplicationException;
+ QaContent getQaContent(long toolContentId);
- void saveOrUpdateQa(QaContent qa) throws QaApplicationException;
+ void saveOrUpdateQaContent(QaContent qa);
- int getTotalNumberOfUsers(QaContent qa) throws QaApplicationException;
+ int getTotalNumberOfUsers(QaContent qa);
- int countSessionComplete(QaContent qa) throws QaApplicationException;
+ int countSessionComplete(QaContent qa);
- void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException;
+ void updateUser(QaQueUsr qaQueUsr);
- QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException;
+ QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId);
- QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId)
- throws QaApplicationException;
-
/**
* Creates or updates response with answer submitted by user.
*
@@ -114,66 +112,59 @@
*/
void updateResponseWithNewAnswer(String newAnswer, String toolSessionID, Long questionDisplayOrder);
- void createQaQue(QaQueContent qaQuestion) throws QaApplicationException;
+ void createQuestion(QaQueContent qaQuestion);
- void removeQaQueContent(QaQueContent qaQuestion) throws QaApplicationException;
+ void removeQuestion(QaQueContent qaQuestion);
- void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException;
+ void createUserResponse(QaUsrResp qaUsrResp);
- void updateUserResponse(QaUsrResp resp) throws QaApplicationException;
+ void updateUserResponse(QaUsrResp resp);
- QaUsrResp getResponseById(Long responseId) throws QaApplicationException;
+ QaUsrResp getResponseById(Long responseId);
- QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid)
- throws QaApplicationException;
+ QaQueContent getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid);
- QaQueContent getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid)
- throws QaApplicationException;
+ QaQueContent getQuestionByUid(Long questionUid);
- List getAllQuestionEntriesSorted(final long qaContentId) throws QaApplicationException;
+ List getAllQuestionEntriesSorted(final long qaContentId);
- void saveOrUpdateQaQueContent(QaQueContent qaQuestion) throws QaApplicationException;
+ void saveOrUpdateQuestion(QaQueContent qaQuestion);
/**
* Return the qa session object according to the requested session id.
*
* @param qaSessionId
- * qa session id
+ * qa session id
* @return the qa session object
*/
- QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException;
+ QaSession getSessionById(long qaSessionId);
- QaSession getSessionById(long qaSessionId) throws QaApplicationException;
+ void createSession(QaSession qaSession);
- void createQaSession(QaSession qaSession) throws QaApplicationException;
-
- List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException;
-
void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException;
- List getSessionsFromContent(QaContent qaContent) throws QaApplicationException;
+ List getSessionsFromContent(QaContent qaContent);
- QaQueUsr createUser(Long toolSessionID) throws QaApplicationException;
+ QaQueUsr createUser(Long toolSessionID);
- void updateQaSession(QaSession qaSession) throws QaApplicationException;
+ void updateSession(QaSession qaSession);
- QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException;
+ void updateQaContent(QaContent qa);
- void updateQa(QaContent qa) throws QaApplicationException;
+ void createQaContent(QaContent qa);
- void createQa(QaContent qa) throws QaApplicationException;
-
void updateResponseVisibility(Long responseUid, boolean visible);
- QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException;
+ QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId);
- QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException;
+ void removeUserResponse(QaUsrResp resp);
- void removeUserResponse(QaUsrResp resp) throws QaApplicationException;
+ List getAllQuestionEntries(final Long uid);
- List getAllQuestionEntries(final Long uid) throws QaApplicationException;
+ List getUserBySessionOnly(final QaSession qaSession);
- List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException;
+ void recalculateUserAnswers(QaContent content, Set oldQuestions, List questionDTOs,
+ List deletedQuestions);
/**
* copyToolContent(Long fromContentId, Long toContentId) return void
@@ -183,14 +174,13 @@
*/
void copyToolContent(Long fromContentId, Long toContentId) throws ToolException;
- boolean isStudentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException;
+ boolean isStudentActivityOccurredGlobal(QaContent qaContent);
/**
- * createToolSession(Long toolSessionId,String toolSessionName, Long
- * toolContentId)
+ * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentId)
*
- * It is also defined here since in development we want to be able call it
- * directly from the web-layer instead of it being called by the container.
+ * It is also defined here since in development we want to be able call it directly from the web-layer instead of it
+ * being called by the container.
*
* @param toolSessionId
* @param toolContentId
@@ -200,25 +190,25 @@
/**
* leaveToolSession(Long toolSessionId, Long learnerId)
*
- * It is also defined here since in development we want to be able call it
- * directly from our web-layer instead of it being called by the container.
+ * It is also defined here since in development we want to be able call it directly from our web-layer instead of it
+ * being called by the container.
*
* @param toolSessionId
* @param toolContentId
*/
String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException;
- IToolVO getToolBySignature(String toolSignature) throws QaApplicationException;
+ IToolVO getToolBySignature(String toolSignature);
- long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException;
+ long getToolDefaultContentIdBySignature(String toolSignature);
Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry);
NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID);
/**
- * Get the LAMS audit service. Needed as the web layer controls the staff
- * updating of an answer, so the log entry must be made by the web layer.
+ * Get the LAMS audit service. Needed as the web layer controls the staff updating of an answer, so the log entry
+ * must be made by the web layer.
*/
IAuditService getAuditService();
@@ -227,12 +217,11 @@
QaContent getQaContentBySessionId(Long sessionId);
/**
- * Creates an unique name for a QaCondition. It consists of the tool output
- * definition name and a unique positive integer number.
+ * Creates an unique name for a QaCondition. It consists of the tool output definition name and a unique positive
+ * integer number.
*
* @param existingConditions
- * existing conditions; required to check if a condition with
- * the same name does not exist.
+ * existing conditions; required to check if a condition with the same name does not exist.
* @return unique QaCondition name
*/
String createConditionName(Collection existingConditions);
@@ -264,8 +253,7 @@
SortedSet getWizardCategories();
/**
- * Saves the entire set of QaWizardCategories (including the child cognitive
- * skills and questions)
+ * Saves the entire set of QaWizardCategories (including the child cognitive skills and questions)
*
* @param categories
*/
@@ -298,29 +286,31 @@
void deleteAllWizardCategories();
void removeQuestionsFromCache(QaContent qaContent);
-
+
+ void removeQaContentFromCache(QaContent qaContent);
+
/**
* Returns whether activity is grouped and therefore it is expected more than one tool session.
*
* @param toolContentID
* @return
*/
boolean isGroupedActivity(long toolContentID);
-
+
/**
- * Return content folder (unique to each learner and lesson) which is used for storing user generated content.
- * It's been used by CKEditor.
+ * Return content folder (unique to each learner and lesson) which is used for storing user generated content. It's
+ * been used by CKEditor.
*
* @param toolSessionId
* @param userId
* @return
*/
String getLearnerContentFolder(Long toolSessionId, Long userId);
-
+
AverageRatingDTO rateResponse(Long responseId, Long userId, Long toolSessionID, float rating);
-
+
AverageRatingDTO getAverageRatingDTOByResponse(Long responseId);
-
+
/**
* Return reflection data for all sessions.
*
@@ -329,7 +319,7 @@
* @return
*/
List getReflectList(QaContent content, String userID);
-
+
/**
* notifyTeachersOnResponseSubmit
*
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java
===================================================================
diff -u -rdfbc0a5728344573bc1bcbf0095e4f2778d3ad8d -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java (.../QaImportContentVersionFilter.java) (revision dfbc0a5728344573bc1bcbf0095e4f2778d3ad8d)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaImportContentVersionFilter.java (.../QaImportContentVersionFilter.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -61,5 +61,6 @@
*/
public void up20140102To20140102() {
this.removeField(QaContent.class, "contentLocked");
+ this.removeField(QaContent.class, "synchInMonitor");
}
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java
===================================================================
diff -u -r629b2631320321b57015e15be850e7c6b747225f -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (.../QaOutputFactory.java) (revision 629b2631320321b57015e15be850e7c6b747225f)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaOutputFactory.java (.../QaOutputFactory.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -154,7 +154,7 @@
if (QaAppConstants.USER_ANSWERS_DEFINITION_NAME.equals(nameParts[0])) {
// user answers are loaded from the DB and array of strings is created
- QaSession session = qaService.retrieveQaSession(toolSessionId);
+ QaSession session = qaService.getSessionById(toolSessionId);
QaContent qaContent = session.getQaContent();
Set questions = qaContent.getQaQueContents();
String[] answers = new String[questions.size()];
@@ -169,7 +169,7 @@
} 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);
+ QaSession session = qaService.getSessionById(toolSessionId);
QaContent qaContent = session.getQaContent();
Set questions = qaContent.getQaQueContents();
Set users = session.getQaQueUsers();
@@ -232,7 +232,7 @@
usersAndAnswers, false);
} else if (QaAppConstants.QUESTIONS_DEFINITION_NAME.equals(nameParts[0])) {
// Questions asked in this Q&A activity
- QaSession session = qaService.retrieveQaSession(toolSessionId);
+ QaSession session = qaService.getSessionById(toolSessionId);
QaContent qaContent = session.getQaContent();
Set questions = qaContent.getQaQueContents();
String[] questionArray = new String[questions.size()];
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java
===================================================================
diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision c5457cc74f3986b393bc2947604b17168ba54dfb)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -24,6 +24,7 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.service;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
@@ -39,8 +40,6 @@
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
-import org.lamsfoundation.lams.contentrepository.ItemNotFoundException;
-import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler;
import org.lamsfoundation.lams.events.IEventNotificationService;
import org.lamsfoundation.lams.learning.service.ILearnerService;
@@ -79,6 +78,7 @@
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.dto.QaQuestionDTO;
import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO;
import org.lamsfoundation.lams.tool.qa.util.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.util.QaSessionComparator;
@@ -96,23 +96,14 @@
import org.springframework.dao.DataAccessException;
/**
- * The POJO implementation of Survey service. All business logics of survey tool are implemented in this class. It
- * translate the request from presentation layer and perform approporiate database operation.
+ * The POJO implementation of Qa service. All business logics of Qa tool are implemented in this class. It translate the
+ * request from presentation layer and perform approporiate database operation.
*
- * Two construtors are provided in this class. The constuctor with Hibernate session object allows survey tool to handle
- * long run application transaction. The developer can store Hibernate session in http session and pass across different
- * http request. This implementation also make the testing out side JBoss container much easier.
- *
- * Every method is implemented as a Hibernate session transaction. It open an new persistent session or connect to
- * existing persistent session in the begining and it close or disconnect to the persistent session in the end.
- *
* @author Ozgur Demirtas
- *
*/
-
public class QaServicePOJO implements IQaService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager,
QaAppConstants {
- static Logger logger = Logger.getLogger(QaServicePOJO.class.getName());
+ private static Logger logger = Logger.getLogger(QaServicePOJO.class.getName());
private IQaContentDAO qaDAO;
private IQaQuestionDAO qaQuestionDAO;
@@ -137,17 +128,17 @@
private MessageService messageService;
private Random generator = new Random();
-
+
@Override
public boolean isUserGroupLeader(QaQueUsr user, Long toolSessionId) {
QaSession session = this.getSessionById(toolSessionId);
QaQueUsr groupLeader = session.getGroupLeader();
-
+
boolean isUserLeader = (groupLeader != null) && user.getUid().equals(groupLeader.getUid());
return isUserLeader;
}
-
+
@Override
public QaQueUsr checkLeaderSelectToolForSessionLeader(QaQueUsr user, Long toolSessionId) {
if (user == null || toolSessionId == null) {
@@ -175,30 +166,31 @@
// set group leader
qaSession.setGroupLeader(leader);
- this.updateQaSession(qaSession);
+ this.updateSession(qaSession);
}
}
return leader;
}
-
+
@Override
public void copyAnswersFromLeader(QaQueUsr user, QaQueUsr leader) {
if ((user == null) || (leader == null) || user.getUid().equals(leader.getUid())) {
return;
}
- for (QaUsrResp leaderResponse : (Set)leader.getQaUsrResps()) {
+ for (QaUsrResp leaderResponse : (Set) leader.getQaUsrResps()) {
QaQueContent question = leaderResponse.getQaQuestion();
QaUsrResp response = qaUsrRespDAO.getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid());
// if response doesn't exist
if (response == null) {
- response = new QaUsrResp(leaderResponse.getAnswer(), leaderResponse.getAttemptTime(), "", question, user, true);
- createQaUsrResp(response);
+ response = new QaUsrResp(leaderResponse.getAnswer(), leaderResponse.getAttemptTime(), "", question,
+ user, true);
+ createUserResponse(response);
- // if it's been changed by the leader
+ // if it's been changed by the leader
} else if (leaderResponse.getAttemptTime().compareTo(response.getAttemptTime()) != 0) {
response.setAnswer(leaderResponse.getAnswer());
response.setAttemptTime(leaderResponse.getAttemptTime());
@@ -207,169 +199,79 @@
}
}
}
-
+
@Override
- public List getUsersBySession(Long toolSessionID) {
+ public List getUsersBySessionId(Long toolSessionID) {
QaSession session = qaSessionDAO.getQaSessionById(toolSessionID);
return qaQueUsrDAO.getUserBySessionOnly(session);
}
- public void createQa(QaContent qaContent) throws QaApplicationException {
- try {
- qaDAO.saveQa(qaContent);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is creating qa content: " + e.getMessage(), e);
- }
+ public void createQaContent(QaContent qaContent) {
+ qaDAO.saveQa(qaContent);
}
- public QaContent getQa(long toolContentID) throws QaApplicationException {
- try {
- return qaDAO.getQaByContentId(toolContentID);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa content: " + e.getMessage(), e);
- }
+ public QaContent getQaContent(long toolContentID) {
+ return qaDAO.getQaByContentId(toolContentID);
}
- public void saveOrUpdateQa(QaContent qa) throws QaApplicationException {
- try {
- qaDAO.saveOrUpdateQa(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is saveOrUpdating qa content: "
- + e.getMessage(), e);
- }
-
+ public void saveOrUpdateQaContent(QaContent qa) {
+ qaDAO.saveOrUpdateQa(qa);
}
- public QaQueContent getQuestionContentByQuestionText(final String question, Long contentUid)
- throws QaApplicationException {
- try {
- 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 getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid) {
+ return qaQuestionDAO.getQuestionByDisplayOrder(displayOrder, contentUid);
}
-
- public QaQueContent getQuestionByContentAndDisplayOrder(Long displayOrder, Long contentUid)
- throws QaApplicationException {
- try {
- 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 QaQueContent getQuestionByUid(Long questionUid) {
+ if (questionUid == null) {
+ return null;
}
+
+ return qaQuestionDAO.getQuestionByUid(questionUid);
}
- public void saveOrUpdateQaQueContent(QaQueContent qaQuestion) throws QaApplicationException {
- try {
- qaQuestionDAO.saveOrUpdateQaQueContent(qaQuestion);
-
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating qa content by question: "
- + e.getMessage(), e);
- }
-
+ public void saveOrUpdateQuestion(QaQueContent question) {
+ qaQuestionDAO.saveOrUpdateQaQueContent(question);
}
- public void createQaQue(QaQueContent qaQuestion) throws QaApplicationException {
- try {
- qaQuestionDAO.createQueContent(qaQuestion);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is creating qa content: " + e.getMessage(), e);
- }
+ public void createQuestion(QaQueContent question) {
+ qaQuestionDAO.createQueContent(question);
}
- public void createQaSession(QaSession qaSession) throws QaApplicationException {
- try {
- qaSessionDAO.CreateQaSession(qaSession);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is creating qa session: " + e.getMessage(), e);
- }
+ public void createSession(QaSession qaSession) {
+ qaSessionDAO.createSession(qaSession);
}
- public List getSessionNamesFromContent(QaContent qaContent) throws QaApplicationException {
- try {
- return qaSessionDAO.getSessionNamesFromContent(qaContent);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting session names from content: "
- + e.getMessage(), e);
- }
+ public List getSessionsFromContent(QaContent qaContent) {
+ return qaSessionDAO.getSessionsFromContent(qaContent);
}
- public List getSessionsFromContent(QaContent qaContent) throws QaApplicationException {
- try {
- return qaSessionDAO.getSessionsFromContent(qaContent);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting" + " the qa sessions list: "
- + e.getMessage(), e);
- }
- }
+ public QaQueUsr createUser(Long toolSessionID) {
+ 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());
- public QaQueUsr createUser(Long toolSessionID) throws QaApplicationException {
- try {
- 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);
- 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);
- }
+ return user;
}
- public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) throws QaApplicationException {
- try {
- return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " + e.getMessage(), e);
- }
+ public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) {
+ return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId);
}
- public QaQueUsr loadQaQueUsr(Long userId) throws QaApplicationException {
- try {
- QaQueUsr qaQueUsr = qaQueUsrDAO.loadQaQueUsrById(userId.longValue());
- return qaQueUsr;
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa QueUsr: " + e.getMessage(), e);
- }
+ public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId) {
+ return qaUsrRespDAO.getResponseByUserAndQuestion(queUsrId, qaQueContentId);
}
- public QaQueUsr getQaQueUsrById(long qaQueUsrId) throws QaApplicationException {
- try {
- QaQueUsr qaQueUsr = qaQueUsrDAO.getQaQueUsrById(qaQueUsrId);
- return qaQueUsr;
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting qa QueUsr: " + e.getMessage(), e);
- }
+ public void updateUserResponse(QaUsrResp resp) {
+ qaUsrRespDAO.updateUserResponse(resp);
}
- public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId)
- throws QaApplicationException {
- try {
- 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 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);
- }
- }
-
public void updateResponseWithNewAnswer(String newAnswer, String toolSessionID, Long questionDisplayOrder) {
HttpSession ss = SessionManager.getSession();
UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
@@ -378,17 +280,16 @@
QaSession session = getSessionById(new Long(toolSessionID));
QaContent qaContent = session.getQaContent();
-
- QaQueContent question = getQuestionByContentAndDisplayOrder(new Long(questionDisplayOrder),
- qaContent.getUid());
+ QaQueContent question = getQuestionByContentAndDisplayOrder(new Long(questionDisplayOrder), qaContent.getUid());
+
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);
+ createUserResponse(response);
- // if answer has changed
+ // if answer has changed
} else if (!newAnswer.equals(response.getAnswer())) {
response.setAnswer(newAnswer);
response.setAttemptTime(new Date(System.currentTimeMillis()));
@@ -397,105 +298,47 @@
}
}
- public List getUserBySessionOnly(final QaSession qaSession) throws QaApplicationException {
- try {
- return qaQueUsrDAO.getUserBySessionOnly(qaSession);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting qa QueUsr by qa session "
- + e.getMessage(), e);
- }
+ public List getUserBySessionOnly(final QaSession qaSession) {
+ return qaQueUsrDAO.getUserBySessionOnly(qaSession);
}
- public void createQaUsrResp(QaUsrResp qaUsrResp) throws QaApplicationException {
- try {
- qaUsrRespDAO.createUserResponse(qaUsrResp);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is creating qa UsrResp: " + e.getMessage(), e);
- }
+ public void createUserResponse(QaUsrResp qaUsrResp) {
+ qaUsrRespDAO.createUserResponse(qaUsrResp);
}
- public void updateQaQueUsr(QaQueUsr qaQueUsr) throws QaApplicationException {
- try {
- qaQueUsrDAO.updateUsr(qaQueUsr);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating qa QueUsr: " + e.getMessage(), e);
- }
+ public void updateUser(QaQueUsr qaQueUsr) {
+ qaQueUsrDAO.updateUsr(qaQueUsr);
}
- public QaUsrResp getResponseById(Long responseId) throws QaApplicationException {
- try {
- return qaUsrRespDAO.getResponseById(responseId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa qaUsrResp: " + e.getMessage(),
- e);
- }
+ public QaUsrResp getResponseById(Long responseId) {
+ return qaUsrRespDAO.getResponseById(responseId);
}
- public int countSessionComplete(QaContent qa) throws QaApplicationException {
- try {
- return qaSessionDAO.countSessionComplete(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is counting complete sessions"
- + e.getMessage(), e);
- }
+ public int countSessionComplete(QaContent qa) {
+ return qaSessionDAO.countSessionComplete(qa);
}
- public QaSession retrieveQaSession(long qaSessionId) throws QaApplicationException {
- try {
- return qaSessionDAO.getQaSessionById(qaSessionId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa session : " + e.getMessage(), e);
- }
+ public QaSession getSessionById(long qaSessionId) {
+ return qaSessionDAO.getQaSessionById(qaSessionId);
}
- public QaSession getSessionById(long qaSessionId) throws QaApplicationException {
- try {
- return qaSessionDAO.getQaSessionById(qaSessionId);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa session : " + e.getMessage(), e);
- }
+ public void updateQaContent(QaContent qa) {
+ qaDAO.updateQa(qa);
}
- public QaContent retrieveQaBySession(long qaSessionId) throws QaApplicationException {
- try {
- return qaDAO.getQaBySession(new Long(qaSessionId));
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is loading qa: " + e.getMessage(), e);
- }
+ public void updateSession(QaSession qaSession) {
+ qaSessionDAO.UpdateQaSession(qaSession);
}
- public void updateQa(QaContent qa) throws QaApplicationException {
- try {
- qaDAO.updateQa(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating" + " the qa content: "
- + e.getMessage(), e);
- }
+ public void removeUserResponse(QaUsrResp resp) {
+ auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), resp.getQaQueUser()
+ .getUsername(), resp.getAnswer(), null);
+ qaUsrRespDAO.removeUserResponse(resp);
}
- public void updateQaSession(QaSession qaSession) throws QaApplicationException {
- try {
- qaSessionDAO.UpdateQaSession(qaSession);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is updating qa session : " + e.getMessage(),
- e);
- }
- }
-
- public void removeUserResponse(QaUsrResp resp) throws QaApplicationException {
- try {
- auditService.logChange(QaAppConstants.MY_SIGNATURE, resp.getQaQueUser().getQueUsrId(), resp.getQaQueUser()
- .getUsername(), resp.getAnswer(), null);
- qaUsrRespDAO.removeUserResponse(resp);
- } catch (DataAccessException e) {
- throw new QaApplicationException(
- "Exception occured when lams is deleting" + " the resp: " + e.getMessage(), e);
- }
- }
-
@Override
public void updateResponseVisibility(Long responseUid, boolean isHideItem) {
-
+
QaUsrResp response = getResponseById(responseUid);
if (response != null) {
// createBy should be null for system default value.
@@ -516,134 +359,145 @@
}
public int getTotalNumberOfUsers(QaContent qa) {
- try {
- return qaQueUsrDAO.getTotalNumberOfUsers(qa);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is retrieving total number of QaQueUsr: "
- + e.getMessage(), e);
- }
+ return qaQueUsrDAO.getTotalNumberOfUsers(qa);
}
- public List getAllQuestionEntries(final Long uid) throws QaApplicationException {
- try {
- 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 getAllQuestionEntries(final Long uid) {
+ return qaQuestionDAO.getAllQuestionEntries(uid.longValue());
}
- public List getAllQuestionEntriesSorted(final long contentUid) throws QaApplicationException {
- try {
- return qaQuestionDAO.getAllQuestionEntriesSorted(contentUid);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is getting all question entries: "
- + e.getMessage(), e);
- }
+ public List getAllQuestionEntriesSorted(final long contentUid) {
+ return qaQuestionDAO.getAllQuestionEntriesSorted(contentUid);
}
- public void removeQaQueContent(QaQueContent qaQuestion) throws QaApplicationException {
- try {
- qaQuestionDAO.removeQaQueContent(qaQuestion);
- } catch (DataAccessException e) {
- throw new QaApplicationException("Exception occured when lams is removing question content: "
- + e.getMessage(), e);
- }
+ public void removeQuestion(QaQueContent question) {
+ qaQuestionDAO.removeQaQueContent(question);
}
/**
- * checks the paramter content in the user responses table
+ * checks the paramter content in the user responses table
*
* @param qa
* @return boolean
* @throws QaApplicationException
*/
- public boolean isStudentActivityOccurredGlobal(QaContent qaContent) throws QaApplicationException {
+ public boolean isStudentActivityOccurredGlobal(QaContent qaContent) {
int countResponses = 0;
if (qaContent != null) {
countResponses = qaUsrRespDAO.getCountResponsesByQaContent(qaContent.getQaContentId());
}
return countResponses > 0;
}
+
+ @Override
+ public void recalculateUserAnswers(QaContent content, Set oldQuestions,
+ List questionDTOs, List deletedQuestions) {
+ // create list of modified questions
+ List modifiedQuestions = new ArrayList();
+ for (QaQueContent oldQuestion : oldQuestions) {
+ for (QaQuestionDTO questionDTO : questionDTOs) {
+ if (oldQuestion.getUid().equals(questionDTO.getUid())) {
+
+ // question is different
+ if (!oldQuestion.getQuestion().equals(questionDTO.getQuestion())) {
+ modifiedQuestions.add(questionDTO);
+ }
+ }
+ }
+ }
+
+ Set sessionList = content.getQaSessions();
+ for (QaSession session : sessionList) {
+ Long toolSessionId = session.getQaSessionId();
+ Set sessionUsers = session.getQaQueUsers();
+
+ for (QaQueUsr user : sessionUsers) {
+
+ // get all finished user results
+ List userAttempts = qaUsrRespDAO.getResponsesByUserUid(user.getUid());
+ Iterator iter = userAttempts.iterator();
+ while (iter.hasNext()) {
+ QaUsrResp resp = iter.next();
+
+ QaQueContent question = resp.getQaQuestion();
+
+ boolean isRemoveQuestionResult = false;
+
+ // [+] if the question is modified
+ for (QaQuestionDTO modifiedQuestion : modifiedQuestions) {
+ if (question.getUid().equals(modifiedQuestion.getUid())) {
+ isRemoveQuestionResult = true;
+ break;
+ }
+ }
+
+ // [+] if the question was removed
+ for (QaQuestionDTO deletedQuestion : deletedQuestions) {
+ if (question.getUid().equals(deletedQuestion.getUid())) {
+ isRemoveQuestionResult = true;
+ break;
+ }
+ }
+
+ if (isRemoveQuestionResult) {
+ iter.remove();
+ qaUsrRespDAO.removeUserResponse(resp);
+ }
+
+ // [+] doing nothing if the new question was added
+
+ }
+
+ }
+ }
+
+ }
+
/**
- * 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
+ * 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
+ * similar to public void removeToolContent(Long toolContentID) gets called by Container+Flash
*
*/
- public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException
-
- {
+ public void copyToolContent(Long fromContentId, Long toContentId) {
long defaultContentId = 0;
if (fromContentId == null) {
-
- try {
- defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- fromContentId = new Long(defaultContentId);
- } catch (Exception e) {
- QaServicePOJO.logger.error("default content id has not been setup for signature: "
- + QaAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + QaAppConstants.MY_SIGNATURE + " Can't continue!");
- }
+ defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
+ fromContentId = new Long(defaultContentId);
}
if (toContentId == null) {
QaServicePOJO.logger.error("throwing ToolException: toContentId is null");
throw new ToolException("toContentId is missing");
}
- try {
- QaContent fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
+ QaContent fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
- if (fromContent == null) {
- try {
- defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- fromContentId = new Long(defaultContentId);
- } catch (Exception e) {
- QaServicePOJO.logger.error("default content id has not been setup for signature: "
- + QaAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + QaAppConstants.MY_SIGNATURE + " Can't continue!");
- }
+ if (fromContent == null) {
+ defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
+ fromContentId = new Long(defaultContentId);
- fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
- }
- if (fromContentId.equals(defaultContentId) && fromContent != null && fromContent.getConditions().isEmpty()) {
- fromContent.getConditions().add(
- getQaOutputFactory().createDefaultComplexUserAnswersCondition(fromContent));
- }
- QaContent toContent = QaContent.newInstance(fromContent, toContentId);
- if (toContent == null) {
- QaServicePOJO.logger.error("throwing ToolException: WARNING!, retrieved toContent is null.");
- throw new ToolException("WARNING! Fail to create toContent. Can't continue!");
- } else {
- qaDAO.saveQa(toContent);
- }
- } catch (DataAccessException e) {
- QaServicePOJO.logger
- .error("throwing ToolException: Exception occured when lams is copying content between content ids.");
- throw new ToolException("Exception occured when lams is copying content between content ids.");
- } catch (ItemNotFoundException e) {
- throw new ToolException("Exception occured when lams is copying content between content ids.");
- } catch (RepositoryCheckedException e) {
- throw new ToolException("Exception occured when lams is copying content between content ids.");
+ fromContent = qaDAO.getQaByContentId(fromContentId.longValue());
}
+ if (fromContentId.equals(defaultContentId) && fromContent != null && fromContent.getConditions().isEmpty()) {
+ fromContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(fromContent));
+ }
+ QaContent toContent = QaContent.newInstance(fromContent, toContentId);
+ if (toContent == null) {
+ QaServicePOJO.logger.error("throwing ToolException: WARNING!, retrieved toContent is null.");
+ throw new ToolException("WARNING! Fail to create toContent. Can't continue!");
+ } else {
+ qaDAO.saveQa(toContent);
+ }
}
/**
- * 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
- *
+ * 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 {
@@ -675,14 +529,14 @@
}
}
- //removed all existing responses of toolContent with toolContentID
+ // removed all existing responses of toolContent with toolContentID
qaDAO.removeQa(toolContentID);
} else {
QaServicePOJO.logger.error("Warning!!!, We should have not come here. qaContent is null.");
throw new ToolException("toolContentID is missing");
}
}
-
+
@SuppressWarnings("unchecked")
public void removeLearnerContent(Long toolContentId, Integer userId) throws ToolException {
if (logger.isDebugEnabled()) {
@@ -704,7 +558,7 @@
}
qaQueUsrDAO.deleteQaQueUsr(user);
-
+
NotebookEntry entry = getEntry(session.getQaSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL,
QaAppConstants.MY_SIGNATURE, userId);
if (entry != null) {
@@ -718,28 +572,28 @@
public AverageRatingDTO rateResponse(Long responseId, Long userId, Long toolSessionID, float rating) {
QaQueUsr imageGalleryUser = this.getUserByIdAndSession(userId, toolSessionID);
ResponseRating responseRating = qaResponseRatingDAO.getRatingByResponseAndUser(responseId, userId);
- QaUsrResp response = qaUsrRespDAO.getResponseById(responseId);
+ QaUsrResp response = qaUsrRespDAO.getResponseById(responseId);
- //persist ResponseRating changes in DB
+ // persist ResponseRating changes in DB
if (responseRating == null) { // add
responseRating = new ResponseRating();
responseRating.setUser(imageGalleryUser);
responseRating.setResponse(response);
}
responseRating.setRating(rating);
qaResponseRatingDAO.saveObject(responseRating);
-
- //to make available new changes be visible in jsp page
+
+ // to make available new changes be visible in jsp page
return qaResponseRatingDAO.getAverageRatingDTOByResponse(responseId);
}
-
+
public AverageRatingDTO getAverageRatingDTOByResponse(Long responseId) {
return qaResponseRatingDAO.getAverageRatingDTOByResponse(responseId);
}
-
+
public List getReflectList(QaContent content, String userID) {
- //reflection data for all sessions
+ // reflection data for all sessions
List reflectionDTOs = new LinkedList();
Set sessions = new TreeSet(new QaSessionComparator());
sessions.addAll(content.getQaSessions());
@@ -797,50 +651,51 @@
}
}
}
-
+
return reflectionDTOs;
}
-
+
@Override
public void notifyTeachersOnResponseSubmit(Long sessionId) {
final String NEW_LINE_CHARACTER = "
";
-
+
HttpSession ss = SessionManager.getSession();
UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userId = new Long(toolUser.getUserID().longValue());
QaQueUsr user = getUserByIdAndSession(userId, new Long(sessionId));
-
+
String fullName = user.getFullname();
- String message = NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + messageService.getMessage("label.user.has.answered.questions", new Object[] { fullName });
-
+ String message = NEW_LINE_CHARACTER + NEW_LINE_CHARACTER
+ + messageService.getMessage("label.user.has.answered.questions", new Object[] { fullName });
+
List responses = qaUsrRespDAO.getResponsesByUserUid(user.getUid());
for (QaUsrResp response : responses) {
String question = response.getQaQuestion().getQuestion();
String answer = response.getAnswer();
-
+
message += NEW_LINE_CHARACTER + NEW_LINE_CHARACTER + question + answer;
}
-
+
message += NEW_LINE_CHARACTER + NEW_LINE_CHARACTER;
-
+
eventNotificationService.notifyLessonMonitors(sessionId, message, true);
}
/**
* Export the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws DataMissingException
- * if no tool content matches the toolSessionId
+ * if no tool content matches the toolSessionId
* @throws ToolException
- * if any other error occurs
+ * if any other error occurs
*/
- public void exportToolContent(Long toolContentID, String rootPath) throws DataMissingException, ToolException {
+ public void exportToolContent(Long toolContentID, String rootPath) {
QaContent toolContentObj = qaDAO.getQaByContentId(toolContentID);
if (toolContentObj == null) {
long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- toolContentObj = getQa(defaultToolContentId);
+ toolContentObj = getQaContent(defaultToolContentId);
if (toolContentObj != null && toolContentObj.getConditions().isEmpty()) {
toolContentObj.getConditions().add(
getQaOutputFactory().createDefaultComplexUserAnswersCondition(toolContentObj));
@@ -859,25 +714,20 @@
toolContentObj.setQaSessions(null);
Set questions = toolContentObj.getQaQueContents();
for (QaQueContent question : questions) {
- question.setQaQueUsers(null);
question.setQaContent(null);
}
exportContentService.exportToolContent(toolContentID, toolContentObj, qaToolContentHandler, rootPath);
} catch (ExportToolContentException e) {
throw new ToolException(e);
- } catch (ItemNotFoundException e) {
- throw new ToolException(e);
- } catch (RepositoryCheckedException e) {
- throw new ToolException(e);
}
}
/**
* Import the XML fragment for the tool's content, along with any files needed for the content.
*
* @throws ToolException
- * if any other error occurs
+ * if any other error occurs
*/
public void importToolContent(Long toolContentID, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException {
@@ -921,7 +771,7 @@
QaContent qaContent = qaDAO.getQaByContentId(toolContentId);
if (qaContent == null) {
long defaultToolContentId = toolService.getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- qaContent = getQa(defaultToolContentId);
+ qaContent = getQaContent(defaultToolContentId);
if (qaContent != null && qaContent.getConditions().isEmpty()) {
qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent));
}
@@ -932,33 +782,11 @@
public String getToolContentTitle(Long toolContentId) {
return qaDAO.getQaByContentId(toolContentId).getTitle();
}
-
- public boolean isContentEdited(Long toolContentId) {
- return qaDAO.getQaByContentId(toolContentId).isDefineLater();
- }
-
- /**
- * it is possible that the tool session id already exists in the tool sessions table as the users from the same
- * session are involved. existsSession(long toolSessionId)
- *
- * @param toolSessionId
- * @return boolean
- */
- protected boolean existsSession(long toolSessionId) {
- QaSession qaSession = getSessionById(toolSessionId);
- if (qaSession == null) {
- return false;
- }
- return true;
- }
-
/**
- * createToolSession(Long toolSessionId,String toolSessionName, Long toolContentID) throws ToolException
* ToolSessionManager CONTRACT : creates a tool session with the incoming toolSessionId in the tool session table
*
* gets called only in the Learner mode. All the learners in the same group have the same toolSessionId.
- *
*/
public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentID) throws ToolException {
@@ -967,48 +795,17 @@
throw new ToolException("toolSessionId is missing");
}
- long defaultContentId = 0;
- if (toolContentID == null) {
-
- try {
- defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- toolContentID = new Long(defaultContentId);
- } catch (Exception e) {
- QaServicePOJO.logger.error("default content id has not been setup for signature: "
- + QaAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + QaAppConstants.MY_SIGNATURE + " Can't continue!");
- }
- }
-
QaContent qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
- if (qaContent == null) {
-
- try {
- defaultContentId = getToolDefaultContentIdBySignature(QaAppConstants.MY_SIGNATURE);
- toolContentID = new Long(defaultContentId);
- } catch (Exception e) {
- QaServicePOJO.logger.error("default content id has not been setup for signature: "
- + QaAppConstants.MY_SIGNATURE);
- throw new ToolException("WARNING! default content has not been setup for signature"
- + QaAppConstants.MY_SIGNATURE + " Can't continue!");
- }
-
- qaContent = qaDAO.getQaByContentId(toolContentID.longValue());
- if (qaContent.getConditions().isEmpty()) {
- qaContent.getConditions().add(getQaOutputFactory().createDefaultComplexUserAnswersCondition(qaContent));
- }
- }
-
/*
* create a new a new tool session if it does not already exist in the tool session table
*/
- if (!existsSession(toolSessionId.longValue())) {
+ QaSession qaSession = getSessionById(toolSessionId);
+ if (qaSession == null) {
try {
- QaSession qaSession = new QaSession(toolSessionId, new Date(System.currentTimeMillis()),
- QaSession.INCOMPLETE, toolSessionName, qaContent, new TreeSet());
- qaSessionDAO.CreateQaSession(qaSession);
+ qaSession = new QaSession(toolSessionId, new Date(System.currentTimeMillis()), QaSession.INCOMPLETE,
+ toolSessionName, qaContent, new TreeSet());
+ qaSessionDAO.createSession(qaSession);
} catch (Exception e) {
QaServicePOJO.logger.error("Error creating new toolsession in the db");
throw new ToolException("Error creating new toolsession in the db: " + e);
@@ -1065,7 +862,7 @@
QaSession qaSession = getSessionById(toolSessionId.longValue());
qaSession.setSession_end_date(new Date(System.currentTimeMillis()));
qaSession.setSession_status(QaAppConstants.COMPLETED);
- updateQaSession(qaSession);
+ updateSession(qaSession);
try {
String nextUrl = learnerService.completeToolSession(toolSessionId, learnerId);
@@ -1114,12 +911,12 @@
return getQaOutputFactory().getToolOutput(name, this, toolSessionId, learnerId);
}
- public IToolVO getToolBySignature(String toolSignature) throws QaApplicationException {
+ public IToolVO getToolBySignature(String toolSignature) {
IToolVO tool = toolService.getToolBySignature(toolSignature);
return tool;
}
- public long getToolDefaultContentIdBySignature(String toolSignature) throws QaApplicationException {
+ public long getToolDefaultContentIdBySignature(String toolSignature) {
long contentId = 0;
contentId = toolService.getToolDefaultContentIdBySignature(toolSignature);
return contentId;
@@ -1140,12 +937,12 @@
return list.get(0);
}
}
-
+
@Override
public boolean isGroupedActivity(long toolContentID) {
return toolService.isGroupedActivity(toolContentID);
}
-
+
@Override
public String getLearnerContentFolder(Long toolSessionId, Long userId) {
return toolService.getLearnerContentFolder(toolSessionId, userId);
@@ -1205,8 +1002,8 @@
public void setQaUsrRespDAO(IQaUsrRespDAO qaUsrRespDAO) {
this.qaUsrRespDAO = qaUsrRespDAO;
- }
-
+ }
+
public void setQaResponseRatingDAO(IResponseRatingDAO responseRatingDAO) {
this.qaResponseRatingDAO = responseRatingDAO;
}
@@ -1231,7 +1028,7 @@
public IQaUsrRespDAO getQaUsrRespDAO() {
return qaUsrRespDAO;
}
-
+
/**
* @return Returns the IResponseRatingDAO.
*/
@@ -1256,7 +1053,7 @@
/**
* @param qaToolContentHandler
- * The qaToolContentHandler to set.
+ * The qaToolContentHandler to set.
*/
public void setQaToolContentHandler(IToolContentHandler qaToolContentHandler) {
this.qaToolContentHandler = qaToolContentHandler;
@@ -1302,7 +1099,6 @@
toolContentObj.setContent(null);
toolContentObj.setReportTitle(null);
toolContentObj.setMonitoringReportTitle(null);
- toolContentObj.setSynchInMonitor(false); // doesn't appear to be used
// in LAMS 2.0
toolContentObj.setLockWhenFinished(true);
toolContentObj.setShowOtherAnswers(true);
@@ -1345,7 +1141,7 @@
QaContent qaContent = null;
if (toolContentId != null) {
- qaContent = getQa(toolContentId.longValue());
+ qaContent = getQaContent(toolContentId.longValue());
}
if (qaContent == null) {
throw new DataMissingException("Unable to set reflective data titled " + title
@@ -1366,16 +1162,16 @@
/**
* @param coreNotebookService
- * The coreNotebookService to set.
+ * The coreNotebookService to set.
*/
public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
this.coreNotebookService = coreNotebookService;
}
-
+
public void setEventNotificationService(IEventNotificationService eventNotificationService) {
this.eventNotificationService = eventNotificationService;
}
-
+
public void setMessageService(MessageService messageService) {
this.messageService = messageService;
}
@@ -1517,6 +1313,10 @@
public void removeQuestionsFromCache(QaContent qaContent) {
qaDAO.removeQuestionsFromCache(qaContent);
}
+
+ public void removeQaContentFromCache(QaContent qaContent) {
+ qaDAO.removeQaContentFromCache(qaContent);
+ }
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return getQaOutputFactory().getSupportedDefinitionClasses(definitionType);
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaComparator.java
===================================================================
diff -u -r629b2631320321b57015e15be850e7c6b747225f -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaComparator.java (.../QaComparator.java) (revision 629b2631320321b57015e15be850e7c6b747225f)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaComparator.java (.../QaComparator.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -28,11 +28,10 @@
import java.util.Comparator;
/**
- * @author Ozgur Demirtas
- *
* A comparator implementation that can be used as a constructor to collections.
* The TreeMap in the web layer makes use of it.
*
+ * @author Ozgur Demirtas
*/
public class QaComparator implements Comparator, Serializable {
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java
===================================================================
diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision c5457cc74f3986b393bc2947604b17168ba54dfb)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/QaUtils.java (.../QaUtils.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -23,80 +23,40 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.qa.util;
-import java.text.DateFormat;
-import java.util.Date;
-
import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
+import org.apache.commons.lang.StringUtils;
+import org.lamsfoundation.lams.tool.ToolAccessMode;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
import org.lamsfoundation.lams.tool.qa.QaContent;
-import org.lamsfoundation.lams.tool.qa.QaSession;
import org.lamsfoundation.lams.tool.qa.dto.QaGeneralAuthoringDTO;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
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;
-import org.lamsfoundation.lams.web.util.SessionMap;
/**
- * @author Ozgur Demirtas
- *
* Common utility functions live here.
+ *
+ * @author Ozgur Demirtas
*/
public abstract class QaUtils implements QaAppConstants {
- /**
- *
- * @param request
- * @param defaultQaContent
- * @param qaAuthoringForm
- */
- public static void populateAuthoringDTO(HttpServletRequest request, QaContent defaultQaContent,
- QaGeneralAuthoringDTO qaGeneralAuthoringDTO) {
- qaGeneralAuthoringDTO.setActivityTitle(defaultQaContent.getTitle());
- qaGeneralAuthoringDTO.setActivityInstructions(defaultQaContent.getInstructions());
- }
+ public static void setFormProperties(HttpServletRequest request, QaAuthoringForm qaAuthoringForm,
+ QaGeneralAuthoringDTO qaGeneralAuthoringDTO, String strToolContentID, String httpSessionID) {
- public static String replaceNewLines(String text) {
-
- String newText = "";
- if (text != null) {
- newText = text.replaceAll("\n", "
");
-
- }
-
- return newText;
- }
-
- public static void setFormProperties(HttpServletRequest request, IQaService qaService,
- QaAuthoringForm qaAuthoringForm, QaGeneralAuthoringDTO qaGeneralAuthoringDTO, String strToolContentID,
- String defaultContentIdStr, String activeModule, SessionMap sessionMap, String httpSessionID) {
-
qaAuthoringForm.setHttpSessionID(httpSessionID);
qaGeneralAuthoringDTO.setHttpSessionID(httpSessionID);
qaAuthoringForm.setToolContentID(strToolContentID);
- if ((defaultContentIdStr != null) && (defaultContentIdStr.length() > 0))
- qaAuthoringForm.setDefaultContentIdStr(new Long(defaultContentIdStr).toString());
-
- qaAuthoringForm.setActiveModule(activeModule);
- qaGeneralAuthoringDTO.setActiveModule(activeModule);
-
- String synchInMonitor = request.getParameter(SYNC_IN_MONITOR);
- qaAuthoringForm.setSynchInMonitor(synchInMonitor);
- qaGeneralAuthoringDTO.setSynchInMonitor(synchInMonitor);
-
String usernameVisible = request.getParameter(USERNAME_VISIBLE);
qaAuthoringForm.setUsernameVisible(usernameVisible);
qaGeneralAuthoringDTO.setUsernameVisible(usernameVisible);
-
+
String allowRateAnswers = request.getParameter(ALLOW_RATE_ANSWERS);
qaAuthoringForm.setAllowRateAnswers(allowRateAnswers);
qaGeneralAuthoringDTO.setAllowRateAnswers(allowRateAnswers);
-
+
String notifyTeachersOnResponseSubmit = request.getParameter(NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT);
qaAuthoringForm.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmit);
@@ -113,96 +73,47 @@
qaGeneralAuthoringDTO.setLockWhenFinished(lockWhenFinished);
String reflect = request.getParameter(REFLECT);
-
+
qaAuthoringForm.setReflect(reflect);
qaGeneralAuthoringDTO.setReflect(reflect);
String reflectionSubject = request.getParameter(REFLECTION_SUBJECT);
-
+
qaAuthoringForm.setReflectionSubject(reflectionSubject);
qaGeneralAuthoringDTO.setReflectionSubject(reflectionSubject);
-
-
+ ToolAccessMode mode;
+ String modeStr = request.getParameter(AttributeNames.ATTR_MODE);
+ if (StringUtils.equalsIgnoreCase(modeStr, ToolAccessMode.TEACHER.toString())) {
+ mode = ToolAccessMode.TEACHER;
+ } else {
+ mode = ToolAccessMode.AUTHOR;
+ }
+ request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());
}
- public static int getCurrentUserId(HttpServletRequest request) throws QaApplicationException {
- HttpSession ss = SessionManager.getSession();
- /* get back login user DTO */
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- return user.getUserID().intValue();
- }
-
/**
- *
- * @param long
- * toolContentID
- * @return boolean determine whether a specific toolContentID exists in the
- * db
- */
- public static boolean existsContent(long toolContentID, IQaService qaService) {
- QaContent qaContent = qaService.getQa(toolContentID);
- if (qaContent == null)
- return false;
-
- return true;
- }
-
- /**
- * it is expected that the tool session id already exists in the tool
- * sessions table existsSession(long toolSessionId)
- *
- * @param toolSessionId
- * @return boolean
- */
- public static boolean existsSession(long toolContentID, IQaService qaService) {
- QaSession qaSession = qaService.getSessionById(toolContentID);
-
-
- if (qaSession == null)
- return false;
-
- return true;
- }
-
- public static String getFormattedDateString(Date date) {
- return (DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date));
- }
-
- /**
- * the only attributes kept are TOOL_SESSION and TOOL_CONTENT_ID and
- * ACTIVITY_TITLE ACTIVITY_INSTRUCTIONS
+ * the only attributes kept are TOOL_SESSION and TOOL_CONTENT_ID and ACTIVITY_TITLE ACTIVITY_INSTRUCTIONS
* cleanUpSessionAbsolute(HttpServletRequest request)
*
* @param request
*/
public static void cleanUpSessionAbsolute(HttpServletRequest request) {
request.getSession().removeAttribute(MY_SIGNATURE);
- request.getSession().removeAttribute(ERROR_QAAPPLICATION);
- request.getSession().removeAttribute(TARGET_MODE);
- request.getSession().removeAttribute(TARGET_MODE_AUTHORING);
- request.getSession().removeAttribute(TARGET_MODE_LEARNING);
- request.getSession().removeAttribute(TARGET_MODE_MONITORING);
- request.getSession().removeAttribute(TARGET_MODE_EXPORT_PORTFOLIO);
request.getSession().removeAttribute(AUTHORING_STARTER);
request.getSession().removeAttribute(LOAD_LEARNER);
request.getSession().removeAttribute(LEARNING_STARTER);
request.getSession().removeAttribute(MONITORING_STARTER);
- request.getSession().removeAttribute(LOAD_MONITORING);
request.getSession().removeAttribute(EDITABLE_RESPONSE_ID);
request.getSession().removeAttribute(COPY_TOOL_CONTENT);
- request.getSession().removeAttribute(DEFAULT_CONTENT_ID_STR);
request.getSession().removeAttribute(TOOL_SESSION_ID);
- request.getSession().removeAttribute(LOAD);
request.getSession().removeAttribute(LOAD_QUESTIONS);
request.getSession().removeAttribute(LOAD_STARTER);
- request.getSession().removeAttribute(IS_DEFINE_LATER);
request.getSession().removeAttribute(LEARNING_MODE);
request.getSession().removeAttribute(IS_ADD_QUESTION);
request.getSession().removeAttribute(IS_REMOVE_QUESTION);
request.getSession().removeAttribute(IS_REMOVE_CONTENT);
request.getSession().removeAttribute(MAP_QUESTION_CONTENT);
- request.getSession().removeAttribute(DEFAULT_QUESTION_CONTENT);
request.getSession().removeAttribute(END_LEARNING_MESSSAGE);
request.getSession().removeAttribute(ON);
request.getSession().removeAttribute(OFF);
@@ -259,14 +170,8 @@
request.getSession().removeAttribute(SUBMIT_SUCCESS);
request.getSession().removeAttribute(IS_USERNAME_VISIBLE);
request.getSession().removeAttribute(CURRENT_ANSWER);
- request.getSession().removeAttribute(ACTIVE_MODULE);
- request.getSession().removeAttribute(AUTHORING);
- request.getSession().removeAttribute(DEFINE_LATER_IN_EDIT_MODE);
- request.getSession().removeAttribute(SHOW_AUTHORING_TABS);
request.getSession().removeAttribute(DEFINE_LATER);
request.getSession().removeAttribute(SOURCE_MC_STARTER);
- request.getSession().removeAttribute(LOAD_MONITORING_CONTENT_EDITACTIVITY);
- request.getSession().removeAttribute(MONITORING_ORIGINATED_DEFINELATER);
request.getSession().removeAttribute(REQUEST_LEARNING_REPORT);
request.getSession().removeAttribute(REQUEST_LEARNING_REPORT_VIEWONLY);
request.getSession().removeAttribute(REQUEST_PREVIEW);
@@ -276,18 +181,14 @@
request.getSession().removeAttribute(USER_EXCEPTION_UNCOMPATIBLE_IDS);
request.getSession().removeAttribute(USER_EXCEPTION_NUMBERFORMAT);
request.getSession().removeAttribute(USER_EXCEPTION_USER_DOESNOTEXIST);
- //request.getSession().removeAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST);
request.getSession().removeAttribute(USER_EXCEPTION_TOOLSESSION_DOESNOTEXIST);
request.getSession().removeAttribute(USER_EXCEPTION_CONTENTID_REQUIRED);
request.getSession().removeAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE);
request.getSession().removeAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE);
request.getSession().removeAttribute(USER_EXCEPTION_USERID_NOTNUMERIC);
request.getSession().removeAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS);
request.getSession().removeAttribute(USER_EXCEPTION_USERID_EXISTING);
request.getSession().removeAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED);
- request.getSession().removeAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP);
request.getSession().removeAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS);
request.getSession().removeAttribute(USER_EXCEPTION_NO_STUDENT_ACTIVITY);
request.getSession().removeAttribute(USER_EXCEPTION_CONTENT_IN_USE);
@@ -305,46 +206,12 @@
public static void setDefineLater(HttpServletRequest request, boolean value, String strToolContentID,
IQaService qaService) {
- QaContent qaContent = qaService.getQa(new Long(strToolContentID).longValue());
-
+ QaContent qaContent = qaService.getQaContent(new Long(strToolContentID).longValue());
+
if (qaContent != null) {
qaContent.setDefineLater(value);
- qaService.updateQa(qaContent);
+ qaService.updateQaContent(qaContent);
}
}
- /**
- * determines the struts level location to return
- *
- * @param sourceMcStarter
- * @param requestedModule
- * @return
- */
- public static String getDestination(String sourceMcStarter, String requestedModule) {
- if (requestedModule.equals(DEFINE_LATER)) {
- //request is from define Later url. return to LOAD_VIEW_ONLY
- return LOAD_VIEW_ONLY;
- } else if (requestedModule.equals(AUTHORING)) {
- //request is from authoring url. return to LOAD_QUESTIONS
- return LOAD_QUESTIONS;
- } else {
- //request is from an unknown source. return null
- return null;
- }
- }
-
- public static String getCurrentLearnerID() {
- String userID = "";
- HttpSession ss = SessionManager.getSession();
-
-
- if (ss != null) {
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if ((user != null) && (user.getUserID() != null)) {
- userID = user.getUserID().toString();
- }
- }
- return userID;
- }
-
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java
===================================================================
diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision c5457cc74f3986b393bc2947604b17168ba54dfb)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -28,24 +28,20 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
-import java.util.TreeMap;
import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import org.apache.commons.lang.StringUtils;
import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator;
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.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;
@@ -54,269 +50,167 @@
import org.lamsfoundation.lams.web.util.AttributeNames;
/**
- *
* Keeps all operations needed for Authoring mode.
*
* @author Ozgur Demirtas
- *
*/
public class AuthoringUtil implements QaAppConstants {
- protected static List swapNodes(List listQuestionContentDTO, String questionIndex, String direction,
- Set conditions) {
+ protected static List swapQuestions(List questionDTOs, String questionIndex,
+ String direction, Set conditions) {
int intQuestionIndex = new Integer(questionIndex).intValue();
int intOriginalQuestionIndex = intQuestionIndex;
- int replacedNodeIndex = 0;
+ int replacedQuestionIndex = 0;
if (direction.equals("down")) {
- //direction down
- replacedNodeIndex = ++intQuestionIndex;
+ // direction down
+ replacedQuestionIndex = ++intQuestionIndex;
} else {
- //direction up
- replacedNodeIndex = --intQuestionIndex;
-
+ // direction up
+ replacedQuestionIndex = --intQuestionIndex;
}
- QaQuestionDTO mainNode = extractNodeAtDisplayOrder(listQuestionContentDTO, intOriginalQuestionIndex);
+ QaQuestionDTO mainQuestion = getQuestionAtDisplayOrder(questionDTOs, intOriginalQuestionIndex);
- QaQuestionDTO replacedNode = extractNodeAtDisplayOrder(listQuestionContentDTO, replacedNodeIndex);
+ QaQuestionDTO replacedQuestion = getQuestionAtDisplayOrder(questionDTOs, replacedQuestionIndex);
- List listFinalQuestionContentDTO = new LinkedList();
+ List newQuestionDtos = new LinkedList();
- listFinalQuestionContentDTO = reorderSwappedListQuestionContentDTO(listQuestionContentDTO,
- intOriginalQuestionIndex, replacedNodeIndex, mainNode, replacedNode, conditions);
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ QaQuestionDTO questionDTO = iter.next();
+ QaQuestionDTO tempQuestion = null;
- return listFinalQuestionContentDTO;
- }
+ if (!questionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())
+ && !questionDTO.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) {
+ // normal copy
+ tempQuestion = questionDTO;
- protected static List reorderSwappedListQuestionContentDTO(List listQuestionContentDTO,
- int intOriginalQuestionIndex, int replacedNodeIndex, QaQuestionDTO mainNode,
- QaQuestionDTO replacedNode, Set conditions) {
+ } else if (questionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) {
+ // move type 1
+ tempQuestion = replacedQuestion;
- List listFinalQuestionContentDTO = new LinkedList();
-
- int queIndex = 0;
- Iterator listIterator = listQuestionContentDTO.iterator();
- while (listIterator.hasNext()) {
- QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
- queIndex++;
- QaQuestionDTO tempNode = null;
-
- if (!qaQuestionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())
- && !qaQuestionDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
- //normal copy
- tempNode = new QaQuestionDTO(qaQuestionDTO.getQuestion(),
- qaQuestionDTO.getDisplayOrder(), qaQuestionDTO.getFeedback(), qaQuestionDTO.isRequired());
- } else if (qaQuestionDTO.getDisplayOrder().equals(new Integer(intOriginalQuestionIndex).toString())) {
- //move type 1
- tempNode = new QaQuestionDTO(replacedNode.getQuestion(),
- replacedNode.getDisplayOrder(),replacedNode.getFeedback(), replacedNode.isRequired());
- } else if (qaQuestionDTO.getDisplayOrder().equals(new Integer(replacedNodeIndex).toString())) {
- //move type 1
- tempNode = new QaQuestionDTO(mainNode.getQuestion(),
- mainNode.getDisplayOrder(), mainNode.getFeedback(), mainNode.isRequired());
+ } else if (questionDTO.getDisplayOrder().equals(new Integer(replacedQuestionIndex).toString())) {
+ // move type 1
+ tempQuestion = mainQuestion;
}
- listFinalQuestionContentDTO.add(tempNode);
+ newQuestionDtos.add(tempQuestion);
}
+
// references in conditions also need to be changed
if (conditions != null) {
for (QaCondition condition : conditions) {
SortedSet newQuestionDTOSet = new TreeSet(
new QaQuestionContentDTOComparator());
- for (QaQuestionDTO dto : (List) listFinalQuestionContentDTO) {
+ for (QaQuestionDTO dto : (List) newQuestionDtos) {
if (condition.temporaryQuestionDTOSet.contains(dto)) {
newQuestionDTOSet.add(dto);
}
}
condition.temporaryQuestionDTOSet = newQuestionDTOSet;
}
}
- return listFinalQuestionContentDTO;
+
+ return newQuestionDtos;
}
- protected static QaQuestionDTO extractNodeAtDisplayOrder(List listQuestionContentDTO,
+ private static QaQuestionDTO getQuestionAtDisplayOrder(List questionDTOs,
int intOriginalQuestionIndex) {
- Iterator listIterator = listQuestionContentDTO.iterator();
- while (listIterator.hasNext()) {
- QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ QaQuestionDTO qaQuestionDTO = iter.next();
if (new Integer(intOriginalQuestionIndex).toString().equals(qaQuestionDTO.getDisplayOrder())) {
return qaQuestionDTO;
}
}
return null;
}
-
- protected static Map reorderQuestionContentMap(Map mapQuestionContent) {
- Map mapFinalQuestionContent = new TreeMap(new QaComparator());
- int queIndex = 0;
- Iterator itMap = mapQuestionContent.entrySet().iterator();
- while (itMap.hasNext()) {
- Map.Entry pairs = (Map.Entry) itMap.next();
- if (pairs.getValue() != null && !pairs.getValue().equals("")) {
- ++queIndex;
- mapFinalQuestionContent.put(new Integer(queIndex).toString(), pairs.getValue());
+ protected static List reorderQuestionDTOs(List questionDTOs) {
+ List listFinalQuestionDTO = new LinkedList();
- }
- }
- return mapFinalQuestionContent;
- }
-
- protected static List reorderListQuestionContentDTO(List listQuestionContentDTO, String excludeQuestionIndex) {
-
- List listFinalQuestionContentDTO = new LinkedList();
-
int queIndex = 0;
- Iterator listIterator = listQuestionContentDTO.iterator();
- while (listIterator.hasNext()) {
- QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
-
- String question = qaQuestionDTO.getQuestion();
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ QaQuestionDTO qaQuestionDTO = iter.next();
- String displayOrder = qaQuestionDTO.getDisplayOrder();
-
+ String question = qaQuestionDTO.getQuestion();
String feedback = qaQuestionDTO.getFeedback();
boolean required = qaQuestionDTO.isRequired();
if (question != null && !question.equals("")) {
- if (!displayOrder.equals(excludeQuestionIndex)) {
- ++queIndex;
-
- qaQuestionDTO.setQuestion(question);
- qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString());
- qaQuestionDTO.setFeedback(feedback);
- qaQuestionDTO.setRequired(required);
-
- listFinalQuestionContentDTO.add(qaQuestionDTO);
- }
- }
- }
- return listFinalQuestionContentDTO;
- }
-
- protected static List reorderSimpleListQuestionContentDTO(List listQuestionContentDTO) {
- List listFinalQuestionContentDTO = new LinkedList();
-
- int queIndex = 0;
- Iterator listIterator = listQuestionContentDTO.iterator();
- while (listIterator.hasNext()) {
- QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
-
- String question = qaQuestionDTO.getQuestion();
- String displayOrder = qaQuestionDTO.getDisplayOrder();
- String feedback = qaQuestionDTO.getFeedback();
- boolean required = qaQuestionDTO.isRequired();
-
- if (question != null && !question.equals("")) {
++queIndex;
qaQuestionDTO.setQuestion(question);
qaQuestionDTO.setDisplayOrder(new Integer(queIndex).toString());
qaQuestionDTO.setFeedback(feedback);
qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionDTO);
+ listFinalQuestionDTO.add(qaQuestionDTO);
}
}
- return listFinalQuestionContentDTO;
+ return listFinalQuestionDTO;
}
- protected static List reorderUpdateListQuestionContentDTO(List listQuestionContentDTO,
+ protected static List reorderUpdateQuestionDTOs(List questionDTOs,
QaQuestionDTO qaQuestionContentDTONew, String editableQuestionIndex) {
- List listFinalQuestionContentDTO = new LinkedList();
+ List listFinalQuestionDTO = new LinkedList();
int queIndex = 0;
- Iterator listIterator = listQuestionContentDTO.iterator();
- while (listIterator.hasNext()) {
- QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) listIterator.next();
-
+ Iterator iter = questionDTOs.iterator();
+ while (iter.hasNext()) {
+ QaQuestionDTO qaQuestionDTO = (QaQuestionDTO) iter.next();
+
++queIndex;
String question = qaQuestionDTO.getQuestion();
String displayOrder = qaQuestionDTO.getDisplayOrder();
String feedback = qaQuestionDTO.getFeedback();
- boolean required = qaQuestionDTO.isRequired();
-
+ boolean required = qaQuestionDTO.isRequired();
+
if (displayOrder.equals(editableQuestionIndex)) {
qaQuestionDTO.setQuestion(qaQuestionContentDTONew.getQuestion());
qaQuestionDTO.setDisplayOrder(qaQuestionContentDTONew.getDisplayOrder());
qaQuestionDTO.setFeedback(qaQuestionContentDTONew.getFeedback());
qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionDTO);
+ listFinalQuestionDTO.add(qaQuestionDTO);
} else {
qaQuestionDTO.setQuestion(question);
qaQuestionDTO.setDisplayOrder(displayOrder);
qaQuestionDTO.setFeedback(feedback);
qaQuestionDTO.setRequired(required);
- listFinalQuestionContentDTO.add(qaQuestionDTO);
+ listFinalQuestionDTO.add(qaQuestionDTO);
}
}
- return listFinalQuestionContentDTO;
+ return listFinalQuestionDTO;
}
- /**
- * repopulateMap(TreeMap mapQuestionContent, HttpServletRequest request)
- * return void repopulates the user entries into the Map
- */
- protected void repopulateMap(Map mapQuestionContent, HttpServletRequest request) {
- int intQuestionIndex = mapQuestionContent.size();
-
- /*
- * if there is data in the Map remaining from previous session remove those
- */
- mapQuestionContent.clear();
-
- for (long i = 0; i < intQuestionIndex; i++) {
- String candidateQuestionEntry = request.getParameter("questionContent" + i);
- if (i == 0) {
- }
- if (candidateQuestionEntry != null && candidateQuestionEntry.length() > 0) {
- mapQuestionContent.put(new Long(i + 1).toString(), candidateQuestionEntry);
- }
- }
- }
-
- public QaContent saveOrUpdateQaContent(List listQuestionContentDTO, IQaService qaService,
- QaAuthoringForm qaAuthoringForm, HttpServletRequest request, QaContent qaContent, String strToolContentID,
+ public static QaContent saveOrUpdateQaContent(List questionDTOs, IQaService qaService,
+ HttpServletRequest request, QaContent qaContent, String strToolContentID,
Set conditions) {
UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
String richTextTitle = request.getParameter(QaAppConstants.TITLE);
String richTextInstructions = request.getParameter(QaAppConstants.INSTRUCTIONS);
-
- String synchInMonitor = request.getParameter(QaAppConstants.SYNC_IN_MONITOR);
-
String usernameVisible = request.getParameter(QaAppConstants.USERNAME_VISIBLE);
-
String allowRateQuestions = request.getParameter(QaAppConstants.ALLOW_RATE_ANSWERS);
-
String notifyTeachersOnResponseSubmit = request.getParameter(QaAppConstants.NOTIFY_TEACHERS_ON_RESPONSE_SUBMIT);
-
String showOtherAnswers = request.getParameter("showOtherAnswers");
-
String questionsSequenced = request.getParameter(QaAppConstants.QUESTIONS_SEQUENCED);
-
String lockWhenFinished = request.getParameter("lockWhenFinished");
-
String allowRichEditor = request.getParameter("allowRichEditor");
-
String useSelectLeaderToolOuput = request.getParameter("useSelectLeaderToolOuput");
-
String reflect = request.getParameter(QaAppConstants.REFLECT);
-
String reflectionSubject = request.getParameter(QaAppConstants.REFLECTION_SUBJECT);
- String activeModule = request.getParameter(QaAppConstants.ACTIVE_MODULE);
-
boolean questionsSequencedBoolean = false;
- boolean synchInMonitorBoolean = false;
boolean lockWhenFinishedBoolean = false;
boolean usernameVisibleBoolean = false;
boolean allowRateQuestionsBoolean = false;
@@ -330,34 +224,30 @@
questionsSequencedBoolean = true;
}
- if (synchInMonitor != null && synchInMonitor.equalsIgnoreCase("1")) {
- synchInMonitorBoolean = true;
- }
-
if (lockWhenFinished != null && lockWhenFinished.equalsIgnoreCase("1")) {
lockWhenFinishedBoolean = true;
}
if (usernameVisible != null && usernameVisible.equalsIgnoreCase("1")) {
usernameVisibleBoolean = true;
}
-
+
if (allowRateQuestions != null && allowRateQuestions.equalsIgnoreCase("1")) {
allowRateQuestionsBoolean = true;
}
-
+
if (notifyTeachersOnResponseSubmit != null && notifyTeachersOnResponseSubmit.equalsIgnoreCase("1")) {
notifyTeachersOnResponseSubmitBoolean = true;
}
if (showOtherAnswers != null && showOtherAnswers.equalsIgnoreCase("1")) {
showOtherAnswersBoolean = true;
}
-
+
if (allowRichEditor != null && allowRichEditor.equalsIgnoreCase("1")) {
allowRichEditorBoolean = true;
}
-
+
if (useSelectLeaderToolOuput != null && useSelectLeaderToolOuput.equalsIgnoreCase("1")) {
useSelectLeaderToolOuputBoolean = true;
}
@@ -392,33 +282,26 @@
qaContent.setCreatedBy(userId);
/** make sure we are setting the userId from the User object above */
- if (activeModule.equals(QaAppConstants.AUTHORING)) {
- qaContent.setUsernameVisible(usernameVisibleBoolean);
- qaContent.setAllowRateAnswers(allowRateQuestionsBoolean);
- qaContent.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmitBoolean);
- qaContent.setShowOtherAnswers(showOtherAnswersBoolean);
- qaContent.setQuestionsSequenced(questionsSequencedBoolean);
- qaContent.setLockWhenFinished(lockWhenFinishedBoolean);
- qaContent.setSynchInMonitor(synchInMonitorBoolean);
- qaContent.setReflect(reflectBoolean);
- qaContent.setReflectionSubject(reflectionSubject);
- qaContent.setAllowRichEditor(allowRichEditorBoolean);
- qaContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean);
+ qaContent.setUsernameVisible(usernameVisibleBoolean);
+ qaContent.setAllowRateAnswers(allowRateQuestionsBoolean);
+ qaContent.setNotifyTeachersOnResponseSubmit(notifyTeachersOnResponseSubmitBoolean);
+ qaContent.setShowOtherAnswers(showOtherAnswersBoolean);
+ qaContent.setQuestionsSequenced(questionsSequencedBoolean);
+ qaContent.setLockWhenFinished(lockWhenFinishedBoolean);
+ qaContent.setReflect(reflectBoolean);
+ qaContent.setReflectionSubject(reflectionSubject);
+ qaContent.setAllowRichEditor(allowRichEditorBoolean);
+ qaContent.setUseSelectLeaderToolOuput(useSelectLeaderToolOuputBoolean);
- }
-
qaContent.setConditions(new TreeSet(new TextSearchConditionComparator()));
if (newContent) {
- qaService.createQa(qaContent);
+ qaService.createQaContent(qaContent);
} else {
- qaService.updateQa(qaContent);
+ qaService.updateQaContent(qaContent);
}
- qaContent = qaService.getQa(new Long(strToolContentID).longValue());
- qaContent = createQuestionContent(listQuestionContentDTO, qaService, qaContent);
+ qaContent = qaService.getQaContent(new Long(strToolContentID).longValue());
- qaContent = qaService.getQa(new Long(strToolContentID).longValue());
-
for (QaCondition condition : conditions) {
condition.setQuestions(new TreeSet(new QaQueContentComparator()));
for (QaQuestionDTO dto : condition.temporaryQuestionDTOSet) {
@@ -430,163 +313,51 @@
}
}
qaContent.setConditions(conditions);
- qaService.updateQa(qaContent);
- return qaContent;
- }
+ qaService.updateQaContent(qaContent);
+
+ //persist questions
+ int displayOrder = 0;
+ for (QaQuestionDTO questionDTO : questionDTOs) {
- /**
- * removes unused question entries from db
- *
- * @param mapQuestionContent
- * @param qaService
- * @param qaAuthoringForm
- */
- public void removeRedundantQuestions(ListlistQuestionContentDTO, IQaService qaService, QaAuthoringForm qaAuthoringForm,
- HttpServletRequest request, String toolContentID) {
+ String questionText = questionDTO.getQuestion();
- QaContent qaContent = qaService.getQa(new Long(toolContentID).longValue());
- if (qaContent != null) {
- List allQuestions = qaService.getAllQuestionEntries(qaContent.getUid());
-
- Iterator listIterator = allQuestions.iterator();
- boolean entryUsed = false;
- while (listIterator.hasNext()) {
-
- QaQueContent queContent = (QaQueContent) listIterator.next();
-
- //Checking whether to remove question with id queContent.getUid()
- entryUsed = false;
- for ( QaQuestionDTO questionDTO : listQuestionContentDTO ) {
- if (StringUtils.equals(queContent.getQuestion(), questionDTO.getQuestion())) {
- entryUsed = true;
- break;
- }
- }
-
- if (entryUsed == false) {
-
- QaQueContent removeableQaQueContent = qaService.getQuestionContentByQuestionText(queContent
- .getQuestion(), qaContent.getUid());
- if (removeableQaQueContent != null) {
- //Removing question with id removeableQaQueContent.getUid()
- qaService.removeQaQueContent(removeableQaQueContent);
- }
-
- }
+ // skip empty questions
+ if (questionText.isEmpty()) {
+ continue;
}
- }
- }
+ ++displayOrder;
- /**
- * 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,
- QaContent qaContent) {
- int displayOrder = 0;
- 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.
- // LDEV-2524 Partial rewrite - removed the old question and feedback maps and just use the original list.
- // Overriding the displayOrder with a new displayOrder.
- String questionText = questionContentDTO.getQuestion();
- if (StringUtils.isNotBlank(questionText)) {
-
- ++displayOrder;
+ QaQueContent question = qaService.getQuestionByUid(questionDTO.getUid());
+
+ // in case question doesn't exist
+ if (question == null) {
+ question = new QaQueContent(questionText, displayOrder, questionDTO.getFeedback(),
+ questionDTO.isRequired(), qaContent);
+ qaContent.getQaQueContents().add(question);
+ question.setQaContent(qaContent);
- QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(questionText, qaContent.getUid());
- if (existingQaQueContent == null) {
- QaQueContent queContent = new QaQueContent(questionText, displayOrder, questionContentDTO.getFeedback(),
- questionContentDTO.isRequired(), qaContent, null);
- qaContent.getQaQueContents().add(queContent);
- queContent.setQaContent(qaContent);
+ // in case question exists already
+ } else {
- qaService.createQaQue(queContent);
- } else {
-
- existingQaQueContent.setQuestion(questionText);
- existingQaQueContent.setFeedback(questionContentDTO.getFeedback());
- existingQaQueContent.setDisplayOrder(displayOrder);
- existingQaQueContent.setRequired(questionContentDTO.isRequired());
- qaService.saveOrUpdateQaQueContent(existingQaQueContent);
- }
+ question.setQuestion(questionText);
+ question.setFeedback(questionDTO.getFeedback());
+ question.setDisplayOrder(displayOrder);
+ question.setRequired(questionDTO.isRequired());
}
+
+ qaService.saveOrUpdateQuestion(question);
}
-
+
return qaContent;
}
- public static boolean checkDuplicateQuestions(List listQuestionContentDTO, String newQuestion) {
- for (QaQuestionDTO questionDTO : listQuestionContentDTO ) {
- if ( questionDTO.getQuestion() != null && questionDTO.getQuestion().equals(newQuestion) ) {
+ public static boolean checkDuplicateQuestions(List questionDTOs, String newQuestion) {
+ for (QaQuestionDTO questionDTO : questionDTOs) {
+ if (questionDTO.getQuestion() != null && questionDTO.getQuestion().equals(newQuestion)) {
return true;
}
}
return false;
}
-
- /**
- * sorts the questions by the display order
- *
- * @param mapQuestionContent
- * @param qaService
- * @param qaAuthoringForm
- * @param qaContent
- */
- public void reOrganizeDisplayOrder(IQaService qaService, QaAuthoringForm qaAuthoringForm,
- QaContent qaContent) {
- if (qaContent != null) {
- List sortedQuestions = qaService.getAllQuestionEntriesSorted(qaContent.getUid().longValue());
-
- Iterator listIterator = sortedQuestions.iterator();
- int displayOrder = 1;
- while (listIterator.hasNext()) {
- QaQueContent queContent = (QaQueContent) listIterator.next();
-
- QaQueContent existingQaQueContent = qaService.getQuestionContentByQuestionText(
- queContent.getQuestion(), qaContent.getUid());
- existingQaQueContent.setDisplayOrder(displayOrder);
- qaService.saveOrUpdateQaQueContent(existingQaQueContent);
- displayOrder++;
- }
- }
- }
-
- /**
- * checks if any entry is duplicate verifyDuplicatesOptionsMap(Map
- * mapQuestions)
- *
- * @param mapQuestions
- * @return
- */
- public static boolean verifyDuplicatesOptionsMap(Map mapQuestions) {
- Map originalMap = mapQuestions;
- Map backupMap = mapQuestions;
-
- int optionCount = 0;
- for (long i = 1; i <= QaAppConstants.MAX_QUESTION_COUNT.longValue(); i++) {
- String currentOption = (String) originalMap.get(new Long(i).toString());
-
- optionCount = 0;
- for (long j = 1; j <= QaAppConstants.MAX_QUESTION_COUNT.longValue(); j++) {
- String backedOption = (String) backupMap.get(new Long(j).toString());
-
- if (currentOption != null && backedOption != null) {
- if (currentOption.equals(backedOption)) {
- optionCount++;
- }
-
- if (optionCount > 1) {
- return false;
- }
- }
- }
- }
- return true;
- }
}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java
===================================================================
diff -u -raf2294a9411ee67e92a614ee7e60df3c1c764b6e -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java (.../ExportServlet.java) (revision af2294a9411ee67e92a614ee7e60df3c1c764b6e)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java (.../ExportServlet.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -136,7 +136,7 @@
throw new QaApplicationException(error);
}
- QaContent content = qaService.getQa(toolContentID.longValue());
+ QaContent content = qaService.getQaContent(toolContentID.longValue());
if (content == null) {
String error = "Data is missing from the database. Unable to Continue";
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java
===================================================================
diff -u -r7cefcae725bb4e568ae1d61624a75bd6b3f3a8c3 -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision 7cefcae725bb4e568ae1d61624a75bd6b3f3a8c3)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java (.../LearningUtil.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -96,31 +96,6 @@
return generalLearnerFlowDTO;
}
-
- public static String getRemainingQuestionCount(int currentQuestionIndex, String totalQuestionCount) {
- int remainingQuestionCount = new Long(totalQuestionCount).intValue() - currentQuestionIndex + 1;
- return new Integer(remainingQuestionCount).toString();
- }
-
- /**
- * feedBackAnswersProgress(HttpServletRequest request, int
- * currentQuestionIndex) give user feedback on the remaining questions
- *
- * @param qaLearningForm
- * return void
- */
- public static String feedBackAnswersProgress(HttpServletRequest request, int currentQuestionIndex,
- String totalQuestionCount) {
- int remainingQuestionCount = new Long(totalQuestionCount).intValue() - currentQuestionIndex + 1;
- String userFeedback = "";
- if (remainingQuestionCount != 0) {
- userFeedback = "Remaining question count: " + remainingQuestionCount;
- } else {
- userFeedback = "End of the questions.";
- }
-
- return userFeedback;
- }
/**
*/
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java
===================================================================
diff -u -r6ac8c3a8a953aab157cb5075fba73b09da5e4cf8 -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 6ac8c3a8a953aab157cb5075fba73b09da5e4cf8)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0)
@@ -52,7 +52,6 @@
import org.lamsfoundation.lams.tool.qa.service.IQaService;
import org.lamsfoundation.lams.tool.qa.util.QaSessionComparator;
import org.lamsfoundation.lams.tool.qa.util.QaStringComparator;
-import org.lamsfoundation.lams.tool.qa.util.QaUtils;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.DateUtil;
import org.lamsfoundation.lams.web.session.SessionManager;
@@ -66,16 +65,14 @@
public class MonitoringUtil implements QaAppConstants {
/**
- * User id is needed if learnerRequest = true, as it is required to work out
- * if the data being analysed is the current user (for not show other names)
- * or to work out which is the user's answers (for not show all answers).
+ * User id is needed if learnerRequest = true, as it is required to work out if the data being analysed is the
+ * current user (for not show other names) 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,
- String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String sessionId,
- String userId) {
+ String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String sessionId, String userId) {
List