Index: lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -185,5 +185,6 @@
label.view.all.responses =View All Responses
label.sort.by.answer =Sort by answer
label.other.answers =Answers from other Learners
+label.total.responses =Total responses so far: {0}
#======= End labels: Exported 174 labels for en AU =====
Index: lams_tool_survey/conf/xdoclet/struts-actions.xml
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -157,6 +157,7 @@
+
getSessionAnswer(Long sessionId, Long questionUid, Long excludeUserId);
+ List getSessionAnswer(Long sessionId, Long questionUid);
List getByToolContentIdAndUserId(Long toolContentId, Long userId);
- List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid,
- final Long excludeUserId, int page, int size, int sorting);
+ List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid, int page, int size,
+ int sorting);
- int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId, final Long excludeUserId);
+ int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId);
}
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java
===================================================================
diff -u -rf0c3f41d54ef4f390ef3f93f28c0679c46b6730c -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java (.../SurveyUserDAO.java) (revision f0c3f41d54ef4f390ef3f93f28c0679c46b6730c)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java (.../SurveyUserDAO.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -29,9 +29,11 @@
public interface SurveyUserDAO extends DAO {
- SurveyUser getUserByUserIDAndSessionID(Long userID, Long sessionId);
+ SurveyUser getUserByUserIDAndSessionID(Long userID, Long sessionId);
- SurveyUser getUserByUserIDAndContentID(Long userId, Long contentId);
+ SurveyUser getUserByUserIDAndContentID(Long userId, Long contentId);
- List getBySessionID(Long sessionId);
+ List getBySessionID(Long sessionId);
+
+ int getCountFinishedUsers(Long sessionId);
}
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -32,18 +32,18 @@
private static final String GET_LEARNER_ANSWER = "FROM " + SurveyAnswer.class.getName()
+ " AS a WHERE a.surveyQuestion.uid=? AND a.user.uid=?";
private static final String GET_SESSION_ANSWER = "FROM " + SurveyAnswer.class.getName() + " AS a "
- + " WHERE a.user.session.sessionId=? AND a.surveyQuestion.uid=? AND a.user.userId!=?";
+ + " WHERE a.user.session.sessionId=? AND a.surveyQuestion.uid=?";
private static final String GET_BY_TOOL_CONTENT_ID_AND_USER_ID = "FROM " + SurveyAnswer.class.getName() + " AS a "
+ " WHERE a.user.session.survey.contentId = ? AND a.user.userId = ?";
private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT = "SELECT r.answerText FROM "
+ SurveyAnswer.class.getName()
+ " AS r "
- + "WHERE r.user.session.sessionId=:sessionId AND r.surveyQuestion.uid=:questionUid AND r.user.userId!=:excludeUserId AND r.answerText<>'' order by ";
+ + "WHERE r.user.session.sessionId=:sessionId AND r.surveyQuestion.uid=:questionUid AND r.answerText<>'' order by ";
private static final String GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION = "SELECT COUNT(*) FROM "
+ SurveyAnswer.class.getName() + " AS r "
- + "WHERE r.user.session.sessionId=? AND r.surveyQuestion.uid=? AND r.user.userId!=? AND r.answerText<>''";
+ + "WHERE r.user.session.sessionId=? AND r.surveyQuestion.uid=? AND r.answerText<>''";
@Override
public SurveyAnswer getAnswer(Long questionUid, Long userUid) {
@@ -55,8 +55,8 @@
}
@Override
- public List getSessionAnswer(Long sessionId, Long questionUid, Long excludeUserId) {
- return getHibernateTemplate().find(GET_SESSION_ANSWER, new Object[] { sessionId, questionUid, excludeUserId});
+ public List getSessionAnswer(Long sessionId, Long questionUid) {
+ return getHibernateTemplate().find(GET_SESSION_ANSWER, new Object[] { sessionId, questionUid});
}
@SuppressWarnings("unchecked")
@@ -66,8 +66,8 @@
}
@Override
- public List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid,
- final Long excludeUserId, int page, int size, int sorting) {
+ public List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid, int page,
+ int size, int sorting) {
String sortingOrder = "";
switch (sorting) {
case SurveyConstants.SORT_BY_DEAFAULT:
@@ -82,18 +82,15 @@
}
String sqlQuery = LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder;
- return getSession().createQuery(sqlQuery)
- .setLong("sessionId", sessionId.longValue()).setLong("questionUid", questionUid.longValue())
- .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size).setMaxResults(size)
- .list();
+ return getSession().createQuery(sqlQuery).setLong("sessionId", sessionId.longValue())
+ .setLong("questionUid", questionUid.longValue()).setFirstResult(page * size).setMaxResults(size).list();
}
@Override
- public int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId,
- final Long excludeUserId) {
+ public int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId) {
List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION,
- new Object[] { sessionId, questionId, excludeUserId });
+ new Object[] { sessionId, questionId });
if (list == null || list.size() == 0) {
return 0;
}
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java
===================================================================
diff -u -rf0c3f41d54ef4f390ef3f93f28c0679c46b6730c -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java (.../SurveyUserDAOHibernate.java) (revision f0c3f41d54ef4f390ef3f93f28c0679c46b6730c)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java (.../SurveyUserDAOHibernate.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -28,30 +28,42 @@
import org.lamsfoundation.lams.tool.survey.dao.SurveyUserDAO;
import org.lamsfoundation.lams.tool.survey.model.SurveyUser;
+public class SurveyUserDAOHibernate extends BaseDAOHibernate implements SurveyUserDAO {
-public class SurveyUserDAOHibernate extends BaseDAOHibernate implements SurveyUserDAO{
-
- private static final String FIND_BY_USER_ID_CONTENT_ID = "from " + SurveyUser.class.getName() + " as u where u.userId =? and u.survey.contentId=?";
- private static final String FIND_BY_USER_ID_SESSION_ID = "from " + SurveyUser.class.getName() + " as u where u.userId =? and u.session.sessionId=?";
- private static final String FIND_BY_SESSION_ID = "from " + SurveyUser.class.getName() + " as u where u.session.sessionId=?";
+ private static final String FIND_BY_USER_ID_CONTENT_ID = "FROM " + SurveyUser.class.getName()
+ + " AS u WHERE u.userId =? AND u.survey.contentId=?";
+ private static final String FIND_BY_USER_ID_SESSION_ID = "FROM " + SurveyUser.class.getName()
+ + " AS u WHERE u.userId =? AND u.session.sessionId=?";
+ private static final String FIND_BY_SESSION_ID = "FROM " + SurveyUser.class.getName()
+ + " AS u WHERE u.session.sessionId=?";
+ private static final String GET_COUNT_FINISHED_USERS_FOR_SESSION = "SELECT COUNT(*) FROM "
+ + SurveyUser.class.getName()
+ + " AS u WHERE u.session.sessionId=? AND (u.sessionFinished is true OR u.responseFinalized is true)";
- public SurveyUser getUserByUserIDAndSessionID(Long userID, Long sessionId) {
- List list = this.getHibernateTemplate().find(FIND_BY_USER_ID_SESSION_ID,new Object[]{userID,sessionId});
- if(list == null || list.size() == 0)
- return null;
- return (SurveyUser) list.get(0);
- }
+ public SurveyUser getUserByUserIDAndSessionID(Long userID, Long sessionId) {
+ List list = this.getHibernateTemplate().find(FIND_BY_USER_ID_SESSION_ID, new Object[] { userID, sessionId });
+ if (list == null || list.size() == 0)
+ return null;
+ return (SurveyUser) list.get(0);
+ }
- public SurveyUser getUserByUserIDAndContentID(Long userId, Long contentId) {
- List list = this.getHibernateTemplate().find(FIND_BY_USER_ID_CONTENT_ID,new Object[]{userId,contentId});
- if(list == null || list.size() == 0)
- return null;
- return (SurveyUser) list.get(0);
- }
+ public SurveyUser getUserByUserIDAndContentID(Long userId, Long contentId) {
+ List list = this.getHibernateTemplate().find(FIND_BY_USER_ID_CONTENT_ID, new Object[] { userId, contentId });
+ if (list == null || list.size() == 0)
+ return null;
+ return (SurveyUser) list.get(0);
+ }
- public List getBySessionID(Long sessionId) {
- return this.getHibernateTemplate().find(FIND_BY_SESSION_ID,sessionId);
+ public List getBySessionID(Long sessionId) {
+ return this.getHibernateTemplate().find(FIND_BY_SESSION_ID, sessionId);
+ }
+
+ public int getCountFinishedUsers(Long sessionId) {
+ List list = getHibernateTemplate().find(GET_COUNT_FINISHED_USERS_FOR_SESSION, new Object[] { sessionId });
+ if (list == null || list.size() == 0) {
+ return 0;
}
+ return ((Number) list.get(0)).intValue();
+ }
-
}
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql (.../patch20141023.sql) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql (.../patch20141023.sql) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -5,6 +5,7 @@
-- LDEV-3326 Option to include everyone results after survey responses are sent
ALTER TABLE tl_lasurv11_survey ADD COLUMN show_other_users_answers TINYINT(1) NOT NULL DEFAULT 0;
+ALTER TABLE tl_lasurv11_user ADD COLUMN response_finalized TINYINT(1) NOT NULL DEFAULT 0;
----------------------Put all sql statements above here-------------------------
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java (.../SurveyUser.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java (.../SurveyUser.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -45,6 +45,7 @@
private String lastName;
private String loginName;
private boolean sessionFinished;
+ private boolean responseFinalized;
private SurveySession session;
private Survey survey;
@@ -60,6 +61,7 @@
this.session = session;
this.survey = null;
this.sessionFinished = false;
+ this.responseFinalized = false;
}
public SurveyUser(UserDTO user, Survey content) {
@@ -69,7 +71,7 @@
this.loginName = user.getLogin();
this.session = null;
this.survey = content;
- this.sessionFinished = false;
+ this.responseFinalized = false;
}
/**
@@ -196,7 +198,23 @@
public void setSessionFinished(boolean sessionFinished) {
this.sessionFinished = sessionFinished;
}
+
+ /**
+ * @hibernate.property column="response_finalized"
+ * @return Returns the responseFinalized.
+ */
+ public boolean isResponseFinalized() {
+ return responseFinalized;
+ }
+ /**
+ * @param responseFinalized
+ * The responseFinalized to set.
+ */
+ public void setResponseFinalized(boolean responseFinalized) {
+ this.responseFinalized = responseFinalized;
+ }
+
public boolean equals(Object obj) {
if (this == obj)
return true;
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -42,7 +42,7 @@
/**
* @author Dapeng.Ni
*
- * Interface that defines the contract that all Survey service provider must follow.
+ * Interface that defines the contract that all Survey service provider must follow.
*/
public interface ISurveyService {
@@ -116,20 +116,10 @@
*/
AnswerDTO getQuestionResponse(Long sessionId, Long questionUid);
- /**
- * Get question's answer with response percentage infromation.
- *
- * @param sessionId
- * @param questionUid
- * @param excludeUserId exclude this user's answers from result list.
- * @return
- */
- AnswerDTO getQuestionResponse(Long sessionId, Long questionUid, Long excludeUserId);
-
- List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId,
- final Long excludeUserId, int page, int size, int sorting);
+ List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId, int page, int size,
+ int sorting);
- int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId);
+ int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId);
/**
* Commit answers for a group of question together.
@@ -178,6 +168,14 @@
* @return
*/
List getSessionUsers(Long sessionId);
+
+ /**
+ * Get number of finished users.
+ *
+ * @param sessionId
+ * @return
+ */
+ int getCountFinishedUsers(Long sessionId);
// ******************************************************************************************
// ********** Session methods ***********************
@@ -206,6 +204,13 @@
* @return
*/
String finishToolSession(Long toolSessionId, Long userId) throws SurveyApplicationException;
+
+ /**
+ * Mark user as finalized response which will signify he has submitted response.
+ *
+ * @param user
+ */
+ void setResponseFinalized(Long userUid);
// ******************************************************************************************
// Monitoring summary /statistic methods
@@ -274,21 +279,21 @@
* @return
*/
Map> getReflectList(Long contentId, boolean setEntry);
-
+
void notifyTeachersOnAnswerSumbit(Long sessionId, SurveyUser surveyUser);
/**
* Creates an unique name for a SurveyCondition. 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 SurveyCondition name
*/
String createConditionName(Collection existingConditions);
void deleteCondition(SurveyCondition condition);
-
+
/**
* Returns whether activity is grouped and therefore it is expected more than one tool session.
*
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -174,6 +174,11 @@
public SurveyUser getUserByIDAndSession(Long userId, Long sessionId) {
return surveyUserDao.getUserByUserIDAndSessionID(userId, sessionId);
}
+
+ @Override
+ public int getCountFinishedUsers(Long sessionId) {
+ return surveyUserDao.getCountFinishedUsers(sessionId);
+ }
@Override
public void saveOrUpdateSurvey(Survey survey) {
@@ -219,6 +224,13 @@
}
return nextUrl;
}
+
+ @Override
+ public void setResponseFinalized(Long userUid) {
+ SurveyUser user = (SurveyUser) surveyUserDao.getObject(SurveyUser.class, userUid);
+ user.setResponseFinalized(true);
+ surveyUserDao.saveObject(user);
+ }
@Override
public Map> getReflectList(Long contentId, boolean setEntry) {
@@ -321,20 +333,14 @@
surveyAnswerDao.saveObject(ans);
}
}
-
- @Override
- public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid) {
- //pass -1 as exclude userId to skip no users
- return getQuestionResponse(sessionId, questionUid, -1L);
- }
@Override
- public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid, Long excludeUserId) {
+ public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid) {
SurveyQuestion question = surveyQuestionDao.getByUid(questionUid);
AnswerDTO answerDto = new AnswerDTO(question);
// get question all answer from this session
- List answsers = surveyAnswerDao.getSessionAnswer(sessionId, questionUid, excludeUserId);
+ List answsers = surveyAnswerDao.getSessionAnswer(sessionId, questionUid);
// create a map to hold Option UID and sequenceID(start from 0);
Map optMap = new HashMap();
@@ -396,16 +402,17 @@
return answerDto;
}
-
+
@Override
- public List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long excludeUserId,
- int page, int size, int sorting) {
- return surveyAnswerDao.getOpenResponsesForTablesorter(qaSessionId, questionId, excludeUserId, page, size, sorting);
- }
-
+ public List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId, int page,
+ int size, int sorting) {
+ return surveyAnswerDao.getOpenResponsesForTablesorter(qaSessionId, questionId, page, size,
+ sorting);
+ }
+
@Override
- public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) {
- return surveyAnswerDao.getCountResponsesBySessionAndQuestion(qaSessionId, questionId, excludeUserId);
+ public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId) {
+ return surveyAnswerDao.getCountResponsesBySessionAndQuestion(qaSessionId, questionId);
}
@Override
@@ -520,11 +527,11 @@
return summary;
}
-
+
public boolean isGroupedActivity(long toolContentID) {
return toolService.isGroupedActivity(toolContentID);
}
-
+
@Override
public String createConditionName(Collection existingConditions) {
String uniqueNumber = null;
@@ -549,15 +556,15 @@
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return getSurveyOutputFactory().getSupportedDefinitionClasses(definitionType);
}
-
+
@Override
public void notifyTeachersOnAnswerSumbit(Long sessionId, SurveyUser surveyUser) {
-
- //it appears surveyUser can be null (?)
+
+ // it appears surveyUser can be null (?)
if (surveyUser == null) {
return;
}
-
+
String userName = surveyUser.getLastName() + " " + surveyUser.getFirstName();
String message = getLocalisedMessage("event.answer.submit.body", new Object[] { userName });
eventNotificationService.notifyLessonMonitors(sessionId, message, false);
@@ -651,7 +658,7 @@
try {
// register version filter class
exportContentService.registerImportVersionFilterClass(SurveyImportContentVersionFilter.class);
-
+
Object toolPOJO = exportContentService.importToolContent(toolContentPath, surveyToolContentHandler,
fromVersion, toVersion);
if (!(toolPOJO instanceof Survey)) {
@@ -737,11 +744,11 @@
}
}
}
-
+
public String getToolContentTitle(Long toolContentId) {
return getSurveyByContentId(toolContentId).getTitle();
}
-
+
@Override
public void resetDefineLater(Long toolContentId) throws DataMissingException, ToolException {
Survey survey = surveyDao.getByContentId(toolContentId);
@@ -750,7 +757,7 @@
}
survey.setDefineLater(false);
}
-
+
@Override
public boolean isContentEdited(Long toolContentId) {
return getSurveyByContentId(toolContentId).isDefineLater();
@@ -855,31 +862,33 @@
/* ===============Methods implemented from ToolContentImport102Manager =============== */
/*
- * Sample content for import: content 34.0
- * 1.0 Sample Multiple choice - only one
- * response allowed? simpleChoice 1.0 Option 1
- * 2.0 Option 2
- * 3.0 Option 3
+ * Sample content for import: content 34.0 1.0 Sample Multiple choice - only one response allowed? simpleChoice 1.0 Option 1
+ * 2.0 Option 2
+ * 3.0 Option 3
* 2.0 Sample Multiple choice -
- * multiple response allowed? choiceMultiple
- *
- * 1.0 Option 1
- * 2.0 Option 2
- * 3.0 Option 3
+ * name='isOptional'> Sample Multiple choice - multiple
+ * response allowed? choiceMultiple 1.0 Option 1 2.0 Option 2 3.0 Option 3
* 3.0 Sample Free text question? textEntry
* Put instructions here.
- *
- * Thank you for your participation! xxxxxxxxxx Put
- * Title Here Survey Questions surveycontent
- * 31.0
+ * name='contentDefineLater'> Put instructions
+ * here. Thank you for your participation! xxxxxxxxxx
+ * Put Title Here Survey
+ * Questions surveycontent 31.0
*/
/**
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml
===================================================================
diff -u -r3ff38201dcc90ccdf402ac3ba094b0c05fd32d05 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml (.../surveyApplicationContext.xml) (revision 3ff38201dcc90ccdf402ac3ba094b0c05fd32d05)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/surveyApplicationContext.xml (.../surveyApplicationContext.xml) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -104,6 +104,7 @@
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
+ PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java (.../ChartAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java (.../ChartAction.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -66,11 +66,9 @@
Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID);
- Long excludeUserId = WebUtil.readLongParam(request, SurveyConstants.ATTR_USER_ID, true);
// if excludeUserId received exclude this user's answers
- AnswerDTO answer = (excludeUserId == null) ? getSurveyService().getQuestionResponse(sessionId, questionUid)
- : getSurveyService().getQuestionResponse(sessionId, questionUid, excludeUserId);
+ AnswerDTO answer = getSurveyService().getQuestionResponse(sessionId, questionUid);
if (answer.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) {
ChartAction.logger.error("Error question type : Text entry can not generate chart.");
response.getWriter().print(resource.getMessage(SurveyConstants.ERROR_MSG_CHART_ERROR));
Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -49,6 +49,7 @@
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionRedirect;
import org.apache.tomcat.util.json.JSONArray;
import org.apache.tomcat.util.json.JSONException;
import org.apache.tomcat.util.json.JSONObject;
@@ -148,14 +149,15 @@
AnswerForm answerForm = (AnswerForm) form;
// initial Session Map
SessionMap sessionMap = new SessionMap();
- request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
- answerForm.setSessionMapID(sessionMap.getSessionID());
+ String sessionMapID = sessionMap.getSessionID();
+ request.getSession().setAttribute(sessionMapID, sessionMap);
+ answerForm.setSessionMapID(sessionMapID);
// save toolContentID into HTTPSession
ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true);
Long sessionId = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID));
// it will be use when submissionDeadline or lock on finish page.
- request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
+ request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID);
// get back the survey and question list and display them on page
ISurveyService service = getSurveyService();
@@ -174,8 +176,6 @@
List answers = service.getQuestionAnswers(sessionId, surveyUser.getUid());
Survey survey = service.getSurveyBySessionId(sessionId);
- // check whehter finish lock is on/off
- boolean lock = survey.getLockWhenFinished() && surveyUser.isSessionFinished();
// get notebook entry
String entryText = new String();
@@ -192,12 +192,14 @@
// basic information
sessionMap.put(SurveyConstants.ATTR_TITLE, survey.getTitle());
sessionMap.put(SurveyConstants.ATTR_SURVEY_INSTRUCTION, survey.getInstructions());
+ // check whehter finish lock is on/off
+ boolean lock = survey.getLockWhenFinished() && surveyUser.isSessionFinished();
sessionMap.put(SurveyConstants.ATTR_FINISH_LOCK, lock);
sessionMap.put(SurveyConstants.ATTR_LOCK_ON_FINISH, survey.getLockWhenFinished());
sessionMap.put(SurveyConstants.ATTR_SHOW_ON_ONE_PAGE, survey.isShowOnePage());
sessionMap.put(SurveyConstants.ATTR_SHOW_OTHER_USERS_ANSWERS, survey.isShowOtherUsersAnswers());
sessionMap.put(SurveyConstants.ATTR_USER_FINISHED, surveyUser.isSessionFinished());
- sessionMap.put(SurveyConstants.ATTR_USER_ID, surveyUser.getUserId());
+ sessionMap.put(SurveyConstants.ATTR_USER, surveyUser);
sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
sessionMap.put(AttributeNames.ATTR_MODE, mode);
@@ -260,11 +262,20 @@
} else {
answerForm.setPosition(SurveyConstants.POSITION_FIRST);
}
- // if page is locked, only go to result pages.
- if (lock) {
+
+ // if session is finished go to result pages.
+ if (surveyUser.isSessionFinished() && !survey.isShowOtherUsersAnswers()) {
return mapping.findForward(SurveyConstants.FORWARD_RESULT);
+
+ //if show other users is ON and response is finalized - show results page with other users answers
+ } else if (survey.isShowOtherUsersAnswers() && surveyUser.isResponseFinalized()) {
+ ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("resultOtherUsers"));
+ redirect.addParameter(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMapID);
+ return redirect;
+
+ } else {
+ return mapping.findForward(SurveyConstants.SUCCESS);
}
- return mapping.findForward(SurveyConstants.SUCCESS);
}
private ActionForward nextQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request,
@@ -369,17 +380,22 @@
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(
sessionMapID);
- Long excludeUserId = (Long) sessionMap.get(SurveyConstants.ATTR_USER_ID);
SortedMap surveyItemMap = getQuestionList(sessionMap);
Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
List answerDtos = new ArrayList();
for (SurveyQuestion question : surveyItemMap.values()) {
- AnswerDTO answerDto = service.getQuestionResponse(sessionId, question.getUid(), excludeUserId);
+ AnswerDTO answerDto = service.getQuestionResponse(sessionId, question.getUid());
answerDtos.add(answerDto);
}
request.setAttribute("answerDtos", answerDtos);
+ SurveyUser surveyLearner = (SurveyUser) sessionMap.get(SurveyConstants.ATTR_USER);
+ service.setResponseFinalized(surveyLearner.getUid());
+
+ int countFinishedUser = service.getCountFinishedUsers(sessionId);
+ request.setAttribute(SurveyConstants.ATTR_COUNT_FINISHED_USERS, countFinishedUser);
+
return mapping.findForward(SurveyConstants.SUCCESS);
}
@@ -392,7 +408,6 @@
Long questionUid = WebUtil.readLongParam(request, "questionUid");
Long sessionId = WebUtil.readLongParam(request, "sessionId");
- Long excludeUserId = WebUtil.readLongParam(request, "userId");
//paging parameters of tablesorter
int size = WebUtil.readIntParam(request, "size");
@@ -406,13 +421,13 @@
sorting = SurveyConstants.SORT_BY_ANSWER_DESC;
}
- List responses = service.getOpenResponsesForTablesorter(sessionId, questionUid, excludeUserId, page, size,
+ List responses = service.getOpenResponsesForTablesorter(sessionId, questionUid, page, size,
sorting);
JSONArray rows = new JSONArray();
JSONObject responcedata = new JSONObject();
- responcedata.put("total_rows", service.getCountResponsesBySessionAndQuestion(sessionId, questionUid, excludeUserId));
+ responcedata.put("total_rows", service.getCountResponsesBySessionAndQuestion(sessionId, questionUid));
for (String response : responses) {
//JSONArray cell=new JSONArray();
@@ -444,15 +459,9 @@
SortedMap surveyItemMap = getQuestionList(sessionMap);
Collection surveyItemList = surveyItemMap.values();
- SurveyUser surveyLearner = null;
+ SurveyUser surveyLearner = (SurveyUser) sessionMap.get(SurveyConstants.ATTR_USER);
Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
- Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, true);
- if ((userID != null) && (userID != 0)) {
- surveyLearner = service.getUserByIDAndSession(userID, sessionId);
- request.setAttribute(AttributeNames.PARAM_USER_ID, userID);
- }
-
ActionErrors errors;
if ((questionSeqID == null) || questionSeqID.equals(0)) {
errors = getAnswers(request);
@@ -466,9 +475,7 @@
List answerList = new ArrayList();
for (AnswerDTO question : surveyItemList) {
if (question.getAnswer() != null) {
- if ((userID != null) && (userID != 0)) {
- question.getAnswer().setUser(surveyLearner);
- }
+ question.getAnswer().setUser(surveyLearner);
answerList.add(question.getAnswer());
}
}
@@ -479,9 +486,6 @@
Survey survey = service.getSurveyBySessionId(sessionId);
if (survey.isNotifyTeachersOnAnswerSumbit()) {
- if (surveyLearner == null) {
- surveyLearner = getCurrentUser(service, sessionId);
- }
service.notifyTeachersOnAnswerSumbit(sessionId, surveyLearner);
}
Index: lams_tool_survey/web/pages/learning/learning.jsp
===================================================================
diff -u -rc9845f2002ce96c641bb4334b237ef4744cd83c4 -r19c53ce28433c0e4d47c5f303be3e658c808329c
--- lams_tool_survey/web/pages/learning/learning.jsp (.../learning.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4)
+++ lams_tool_survey/web/pages/learning/learning.jsp (.../learning.jsp) (revision 19c53ce28433c0e4d47c5f303be3e658c808329c)
@@ -6,7 +6,8 @@
<%@ include file="/common/header.jsp"%>
-
+
+
@@ -171,7 +171,7 @@
-
+
@@ -218,6 +218,12 @@
+
+
+
+ ${countFinishedUser}
+
+
@@ -278,8 +284,7 @@
- |
-
+ |
|