Index: lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.26 -r1.26.2.1 --- lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties 3 Apr 2014 15:26:55 -0000 1.26 +++ lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties 29 Oct 2014 19:58:21 -0000 1.26.2.1 @@ -47,8 +47,6 @@ error.survey.item.question.blank =Question can not be blank error.survey.item.question.less.option =You must input at least two options. label.submit.survey =Done -label.retake.survey =Retake survey -label.retake =[Retake] label.append.text =Append text: label.next =Next label.previous =Previous @@ -137,8 +135,6 @@ label.monitoring.button.export.excel =Export Report errors.maxfilesize =The uploaded file has exceeded the maximum file size limit of {0} bytes message.not.available =Not Available -message.warnLockOnFinish =Note: After you click on "Next Activity" and you come back to this Survey, you won't be able to change your answers. -message.activityLocked == The instructor has set this activity not to allow you to retake the survey after you have finished it. As you are returning to this activity, you are able to see your answers but not allowed to change them. label.export.reflection =Notebook entries label.on =On label.off =Off @@ -181,5 +177,15 @@ label.submit =Finish label.monitoring.heading =Survey Monitoring +label.show.answers.from.other.users =Show answers from other learners +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} +label.retake.survey =Change answers +label.retake =[Change answer] +message.activityLocked =The instructor has set this activity not to allow you to retake the survey after you have finished it. As you are returning to this activity, you are able to see your answers but not allowed to change them. +message.warnLockOnFinish =Note: After you click on "{0}" and you come back to this Survey, you won't be able to change your answers. + #======= End labels: Exported 174 labels for en AU ===== Index: lams_tool_survey/conf/xdoclet/struts-actions.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/conf/xdoclet/struts-actions.xml,v diff -u -r1.15 -r1.15.2.1 --- lams_tool_survey/conf/xdoclet/struts-actions.xml 17 Jan 2014 22:18:06 -0000 1.15 +++ lams_tool_survey/conf/xdoclet/struts-actions.xml 29 Oct 2014 19:58:21 -0000 1.15.2.1 @@ -157,6 +157,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/dao/SurveyAnswerDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java,v diff -u -r1.5 -r1.5.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java 2 Feb 2014 17:18:41 -0000 1.5 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java 29 Oct 2014 19:58:20 -0000 1.5.2.1 @@ -24,18 +24,26 @@ import java.util.List; +import org.lamsfoundation.lams.tool.survey.SurveyConstants; import org.lamsfoundation.lams.tool.survey.model.SurveyAnswer; public interface SurveyAnswerDAO extends DAO { - SurveyAnswer getAnswer(Long uid, Long userUid); - - /** - * Get all answers from same session for same question. - * @param sessionId - * @param questionUid - * @return - */ - List getSessionAnswer(Long sessionId,Long questionUid); - List getByToolContentIdAndUserId(Long toolContentId, Long userId); + SurveyAnswer getAnswer(Long uid, Long userUid); + + /** + * Get all answers from same session for same question. + * + * @param sessionId + * @param questionUid + * @return + */ + List getSessionAnswer(Long sessionId, Long questionUid); + + List getByToolContentIdAndUserId(Long toolContentId, Long userId); + + List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid, int page, int size, + int sorting); + + int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId); } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java,v diff -u -r1.2 -r1.2.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java 25 Sep 2006 23:20:03 -0000 1.2 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyUserDAO.java 29 Oct 2014 19:58:20 -0000 1.2.14.1 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java,v diff -u -r1.6.2.1 -r1.6.2.2 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java 15 Aug 2014 09:31:05 -0000 1.6.2.1 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java 29 Oct 2014 19:58:21 -0000 1.6.2.2 @@ -24,31 +24,85 @@ import java.util.List; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.lamsfoundation.lams.tool.survey.SurveyConstants; import org.lamsfoundation.lams.tool.survey.dao.SurveyAnswerDAO; import org.lamsfoundation.lams.tool.survey.model.SurveyAnswer; +import org.springframework.orm.hibernate4.HibernateCallback; public class SurveyAnswerDAOHibernate extends BaseDAOHibernate implements SurveyAnswerDAO { - 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=?"; - 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 = ?"; - - public SurveyAnswer getAnswer(Long questionUid, Long userUid) { - List list = getHibernateTemplate().find(GET_LEARNER_ANSWER,new Object[]{questionUid,userUid}); - if(list.size() > 0) - return (SurveyAnswer) list.get(0); - else - return null; - } + 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=?"; + 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 = ?"; - @SuppressWarnings("unchecked") - public List getSessionAnswer(Long sessionId, Long questionUid) { - return (List) getHibernateTemplate().find(GET_SESSION_ANSWER,new Object[]{sessionId,questionUid}); - } - + 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.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.answerText<>''"; + + @Override + public SurveyAnswer getAnswer(Long questionUid, Long userUid) { + List list = getHibernateTemplate().find(GET_LEARNER_ANSWER, new Object[] { questionUid, userUid }); + if (list.size() > 0) + return (SurveyAnswer) list.get(0); + else + return null; + } + @SuppressWarnings("unchecked") + public List getSessionAnswer(Long sessionId, Long questionUid) { + return (List) getHibernateTemplate().find(GET_SESSION_ANSWER, + new Object[] { sessionId, questionUid }); + } + + @SuppressWarnings("unchecked") public List getByToolContentIdAndUserId(Long toolContentId, Long userId) { - return (List) getHibernateTemplate().find(GET_BY_TOOL_CONTENT_ID_AND_USER_ID, new Object[] { toolContentId, userId }); + return (List) getHibernateTemplate().find(GET_BY_TOOL_CONTENT_ID_AND_USER_ID, + new Object[] { toolContentId, userId }); } + + @Override + public List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid, final int page, + final int size, final int sorting) { + String sortingOrder = ""; + switch (sorting) { + case SurveyConstants.SORT_BY_DEAFAULT: + sortingOrder = "r.updateDate"; + break; + case SurveyConstants.SORT_BY_ANSWER_ASC: + sortingOrder = "r.answerText ASC"; + break; + case SurveyConstants.SORT_BY_ANSWER_DESC: + sortingOrder = "r.answerText DESC"; + break; + } + final String sqlQuery = LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder; + + return (List) getHibernateTemplate().execute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + return session.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) { + + List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION, + new Object[] { sessionId, questionId }); + 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/dao/hibernate/SurveyUserDAOHibernate.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java,v diff -u -r1.2.14.1 -r1.2.14.2 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java 15 Aug 2014 09:31:05 -0000 1.2.14.1 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyUserDAOHibernate.java 29 Oct 2014 19:58:21 -0000 1.2.14.2 @@ -28,31 +28,43 @@ 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); + } - @SuppressWarnings("unchecked") - public List getBySessionID(Long sessionId) { - return (List) this.getHibernateTemplate().find(FIND_BY_SESSION_ID,sessionId); + @SuppressWarnings("unchecked") + public List getBySessionID(Long sessionId) { + return (List) 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(); + } - } Fisheye: Tag 1.2.2.1 refers to a dead (removed) revision in file `lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java,v diff -u -r1.3 -r1.3.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java 28 Sep 2006 05:44:04 -0000 1.3 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java 29 Oct 2014 19:58:20 -0000 1.3.14.1 @@ -35,83 +35,91 @@ import org.lamsfoundation.lams.tool.survey.model.SurveyUser; import org.lamsfoundation.lams.tool.survey.util.SurveyOptionComparator; +public class AnswerDTO extends SurveyQuestion { + private static final int SHORT_TITLE_LENGTH = 60; -public class AnswerDTO extends SurveyQuestion{ + // *********************************************** + // DTO fields: + // this is DTO field. For answer, which is user and session level. For question, which is content level. + private SurveyAnswer answer; + // Open text entry response percentage if this question has open text entry. + private double openResponse; + private String openResponseFormatStr; + private int openResponseCount; - private static final int SHORT_TITLE_LENGTH = 60; - - //*********************************************** - //DTO fields: - //this is DTO field. For answer, which is user and session level. For question, which is content level. - private SurveyAnswer answer; - //Open text entry response percentage if this question has open text entry. - private double openResponse; - private String openResponseFormatStr; - private int openResponseCount; - - //this field could have value even this user does not reply this question (the answer is null) - private SurveyUser replier; - - static Logger logger = Logger.getLogger(AnswerDTO.class.getName()); - public AnswerDTO(SurveyQuestion question){ - try { - PropertyUtils.copyProperties(this, question); - } catch (Exception e) { - logger.error("Error occurs during creating AnswerDTO"); - } - - //clone options - Set optList = question.getOptions(); - if(optList != null){ - SortedSet newOptions = new TreeSet(new SurveyOptionComparator()); - for (SurveyOption option : optList) { - SurveyOption newOption = (SurveyOption) option.clone(); - //clone does not copy the UID, here copy it back - newOption.setUid(option.getUid()); - newOptions.add(newOption); - } - this.setOptions(newOptions); - } - - String desc = this.getDescription(); - desc = desc.replaceAll("<(.|\n)*?>", ""); - this.setShortTitle(StringUtils.abbreviate(desc,SHORT_TITLE_LENGTH)); + // this field could have value even this user does not reply this question (the answer is null) + private SurveyUser replier; + private static Logger logger = Logger.getLogger(AnswerDTO.class.getName()); + + public AnswerDTO(SurveyQuestion question) { + try { + PropertyUtils.copyProperties(this, question); + } catch (Exception e) { + logger.error("Error occurs during creating AnswerDTO"); } - //**************************************************************** - // DTO fields - //**************************************************************** - public SurveyAnswer getAnswer() { - return answer; + + // clone options + Set optList = question.getOptions(); + if (optList != null) { + SortedSet newOptions = new TreeSet(new SurveyOptionComparator()); + for (SurveyOption option : optList) { + SurveyOption newOption = (SurveyOption) option.clone(); + // clone does not copy the UID, here copy it back + newOption.setUid(option.getUid()); + newOptions.add(newOption); + } + this.setOptions(newOptions); } - public void setAnswer(SurveyAnswer answer) { - this.answer = answer; - } - public double getOpenResponse() { - return openResponse; - } - public void setOpenResponse(double openResponse) { - this.openResponse = openResponse; - } - public int getOpenResponseCount() { - return openResponseCount; - } - public void setOpenResponseCount(int openResponseCount) { - this.openResponseCount = openResponseCount; - } - public String getOpenResponseFormatStr() { - return openResponseFormatStr; - } - public void setOpenResponseFormatStr(String openResponseFormatStr) { - this.openResponseFormatStr = openResponseFormatStr; - } - - public SurveyUser getReplier() { - return replier; - } - public void setReplier(SurveyUser replier) { - this.replier = replier; - } + String desc = this.getDescription(); + desc = desc.replaceAll("<(.|\n)*?>", ""); + this.setShortTitle(StringUtils.abbreviate(desc, SHORT_TITLE_LENGTH)); + + } + + // **************************************************************** + // DTO fields + // **************************************************************** + public SurveyAnswer getAnswer() { + return answer; + } + + public void setAnswer(SurveyAnswer answer) { + this.answer = answer; + } + + public double getOpenResponse() { + return openResponse; + } + + public void setOpenResponse(double openResponse) { + this.openResponse = openResponse; + } + + public int getOpenResponseCount() { + return openResponseCount; + } + + public void setOpenResponseCount(int openResponseCount) { + this.openResponseCount = openResponseCount; + } + + public String getOpenResponseFormatStr() { + return openResponseFormatStr; + } + + public void setOpenResponseFormatStr(String openResponseFormatStr) { + this.openResponseFormatStr = openResponseFormatStr; + } + + public SurveyUser getReplier() { + return replier; + } + + public void setReplier(SurveyUser replier) { + this.replier = replier; + } + } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java,v diff -u -r1.10 -r1.10.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java 17 Jan 2014 22:18:06 -0000 1.10 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java 29 Oct 2014 19:58:20 -0000 1.10.2.1 @@ -23,21 +23,16 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.survey.model; -import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Set; import java.util.TreeSet; -import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; -import org.lamsfoundation.lams.tool.survey.util.SurveyToolContentHandler; /** * Survey @@ -59,6 +54,7 @@ private String instructions; // advance private boolean showOnePage; + private boolean showOtherUsersAnswers; private boolean lockWhenFinished; private boolean reflectOnActivity; @@ -384,7 +380,19 @@ public void setShowOnePage(boolean showOnePage) { this.showOnePage = showOnePage; } + + /** + * @hibernate.property column="show_other_users_answers" + * @return + */ + public boolean isShowOtherUsersAnswers() { + return showOtherUsersAnswers; + } + public void setShowOtherUsersAnswers(boolean showOtherUsersAnswers) { + this.showOtherUsersAnswers = showOtherUsersAnswers; + } + /** * @hibernate.property column="answer_submit_notify" * @return Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java,v diff -u -r1.6 -r1.6.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java 24 Oct 2006 00:06:52 -0000 1.6 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java 29 Oct 2014 19:58:20 -0000 1.6.14.1 @@ -25,103 +25,111 @@ package org.lamsfoundation.lams.tool.survey.model; import java.util.Date; + /** * Survey + * * @author Dapeng Ni - * - * @hibernate.class table="tl_lasurv11_answer" - * + * + * @hibernate.class table="tl_lasurv11_answer" + * */ public class SurveyAnswer { - private Long uid; - - private SurveyUser user; - - private SurveyQuestion surveyQuestion; - //options choice string: option UIDs are conjunctioned by &. Such as 2&5&3 - private String answerChoices; - private String answerText; - private Date updateDate; - - //************************************************ - // DTO fields - //************************************************ - //it is list of optional UIDs. Uid is long type, but here just save them by String format - private String[] choices; - - /** - * @hibernate.many-to-one column="question_uid" - * cascade="none" - * @return - */ - public SurveyQuestion getSurveyQuestion() { - return surveyQuestion; - } - public void setSurveyQuestion(SurveyQuestion item) { - this.surveyQuestion = item; - } - - /** - * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" - * @return Returns the log Uid. - */ - public Long getUid() { - return uid; - } - public void setUid(Long uid) { - this.uid = uid; - } - /** - * @hibernate.many-to-one column="user_uid" - * cascade="none" - * @return - */ - public SurveyUser getUser() { - return user; - } - public void setUser(SurveyUser user) { - this.user = user; - } - /** - * @hibernate.property column="answer_choices" - * @return - */ - public String getAnswerChoices() { - return answerChoices; - } - public void setAnswerChoices(String answers) { - this.answerChoices = answers; - } - /** - * @hibernate.property column="udpate_date" - * @return - */ - public Date getUpdateDate() { - return updateDate; - } - public void setUpdateDate(Date updateDate) { - this.updateDate = updateDate; - } - /** - * @hibernate.property column="answer_text" - * @return - */ - public String getAnswerText() { - return answerText; - } - public void setAnswerText(String textEntry) { - this.answerText = textEntry; - } - public String[] getChoices() { - return choices; - } - public void setChoices(String[] choices) { - this.choices = choices; - } - + private Long uid; + private SurveyUser user; - - + private SurveyQuestion surveyQuestion; + // options choice string: option UIDs are conjunctioned by &. Such as 2&5&3 + private String answerChoices; + private String answerText; + private Date updateDate; + + // ************************************************ + // DTO fields + // ************************************************ + // it is list of optional UIDs. Uid is long type, but here just save them by String format + private String[] choices; + + /** + * @hibernate.many-to-one column="question_uid" cascade="none" + * @return + */ + public SurveyQuestion getSurveyQuestion() { + return surveyQuestion; + } + + public void setSurveyQuestion(SurveyQuestion item) { + this.surveyQuestion = item; + } + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * @return Returns the log Uid. + */ + public Long getUid() { + return uid; + } + + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @hibernate.many-to-one column="user_uid" cascade="none" + * @return + */ + public SurveyUser getUser() { + return user; + } + + public void setUser(SurveyUser user) { + this.user = user; + } + + /** + * @hibernate.property column="answer_choices" + * @return + */ + public String getAnswerChoices() { + return answerChoices; + } + + public void setAnswerChoices(String answers) { + this.answerChoices = answers; + } + + /** + * @hibernate.property column="udpate_date" + * @return + */ + public Date getUpdateDate() { + return updateDate; + } + + public void setUpdateDate(Date updateDate) { + this.updateDate = updateDate; + } + + /** + * @hibernate.property column="answer_text" + * @return + */ + public String getAnswerText() { + return answerText; + } + + public void setAnswerText(String textEntry) { + this.answerText = textEntry; + } + + public String[] getChoices() { + return choices; + } + + public void setChoices(String[] choices) { + this.choices = choices; + } + } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java,v diff -u -r1.6 -r1.6.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java 24 Oct 2006 00:06:52 -0000 1.6 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java 29 Oct 2014 19:58:21 -0000 1.6.14.1 @@ -23,8 +23,6 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.survey.model; -import java.util.Set; - import org.apache.log4j.Logger; /** * @hibernate.class table="tl_lasurv11_option" Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java,v diff -u -r1.10 -r1.10.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java 17 Jan 2014 22:18:06 -0000 1.10 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java 29 Oct 2014 19:58:21 -0000 1.10.2.1 @@ -27,197 +27,205 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import java.util.SortedMap; import org.apache.log4j.Logger; /** * Survey + * * @author Dapeng Ni - * - * @hibernate.class table="tl_lasurv11_question" - * + * + * @hibernate.class table="tl_lasurv11_question" + * */ -public class SurveyQuestion implements Cloneable{ - private static final Logger log = Logger.getLogger(SurveyQuestion.class); - - private Long uid; - - //Survey Type:1=Single Choice,2=Multiple Choice,3=Text Entry - private short type; - - private String description; - private int sequenceId; - - //option of Question - private boolean appendText; - private boolean optional; - private boolean allowMultipleAnswer; - - private Set options; - - private Date createDate; - private SurveyUser createBy; - -// *********************************************** - //DTO fields: - private String shortTitle; - - public Object clone(){ - SurveyQuestion obj = null; - try { - obj = (SurveyQuestion) super.clone(); -// clone options - if(options != null){ - Iterator iter = options.iterator(); - Set set = new HashSet(); - while(iter.hasNext()){ - SurveyOption instruct = (SurveyOption)iter.next(); - SurveyOption newInsruct = (SurveyOption) instruct.clone(); - set.add(newInsruct); - } - obj.options = set; - } - ((SurveyQuestion)obj).setUid(null); - //clone ReourceUser as well - if(this.createBy != null) - ((SurveyQuestion)obj).setCreateBy((SurveyUser) this.createBy.clone()); - - } catch (CloneNotSupportedException e) { - log.error("When clone " + SurveyQuestion.class + " failed"); - } - - return obj; - } -// ********************************************************** - // Get/Set methods -// ********************************************************** - /** - * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" - * @return Returns the uid. - */ - public Long getUid() { - return uid; - } - /** - * @param uid The uid to set. - */ - public void setUid(Long userID) { - this.uid = userID; - } - - /** - * @hibernate.property column="description" type="text" - * @return - */ - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - - /** - * @hibernate.set lazy="false" - * cascade="all-delete-orphan" - * inverse="false" - * order-by="sequence_id asc" - * @hibernate.collection-key column="question_uid" - * @hibernate.collection-one-to-many - * class="org.lamsfoundation.lams.tool.survey.model.SurveyOption" - * @return - */ - public Set getOptions() { - return options; - } - public void setOptions(Set itemInstructions) { - this.options = itemInstructions; - } - - /** - * @hibernate.many-to-one - * cascade="none" - * column="create_by" - * - * @return - */ - public SurveyUser getCreateBy() { - return createBy; - } - public void setCreateBy(SurveyUser createBy) { - this.createBy = createBy; - } - /** - * @hibernate.property column="create_date" - * @return - */ - public Date getCreateDate() { - return createDate; - } - public void setCreateDate(Date createDate) { - this.createDate = createDate; - } +public class SurveyQuestion implements Cloneable { + private static final Logger log = Logger.getLogger(SurveyQuestion.class); - /** - * @hibernate.property column="question_type" - * @return - */ - public short getType() { - return type; + private Long uid; + + // Survey Type:1=Single Choice,2=Multiple Choice,3=Text Entry + private short type; + + private String description; + private int sequenceId; + + // option of Question + private boolean appendText; + private boolean optional; + private boolean allowMultipleAnswer; + + private Set options; + + private Date createDate; + private SurveyUser createBy; + + // *********************************************** + // DTO fields: + private String shortTitle; + + public Object clone() { + SurveyQuestion obj = null; + try { + obj = (SurveyQuestion) super.clone(); + // clone options + if (options != null) { + Iterator iter = options.iterator(); + Set set = new HashSet(); + while (iter.hasNext()) { + SurveyOption instruct = (SurveyOption) iter.next(); + SurveyOption newInsruct = (SurveyOption) instruct.clone(); + set.add(newInsruct); } - public void setType(short type) { - this.type = type; - } - /** - * @hibernate.property column="append_text" - * @return - */ - public boolean isAppendText() { - return appendText; + obj.options = set; } - public void setAppendText(boolean appendText) { - this.appendText = appendText; - } - - /** - * @hibernate.property column="optional" - * @return - */ - public boolean isOptional() { - return optional; - } - public void setOptional(boolean compulsory) { - this.optional = compulsory; - } - /** - * @hibernate.property column="allow_multiple_answer" - * @return - */ - public boolean isAllowMultipleAnswer() { - return allowMultipleAnswer; - } - public void setAllowMultipleAnswer(boolean allowMultipleAnswer) { - this.allowMultipleAnswer = allowMultipleAnswer; - } - /** - * @hibernate.property column="sequence_id" - * @return - */ - public int getSequenceId() { - return sequenceId; - } - public void setSequenceId(int sequenceId) { - this.sequenceId = sequenceId; - } - public String getShortTitle() { - return shortTitle; - } - public void setShortTitle(String shortTitle) { - this.shortTitle = shortTitle; - } + ((SurveyQuestion) obj).setUid(null); + // clone ReourceUser as well + if (this.createBy != null) + ((SurveyQuestion) obj).setCreateBy((SurveyUser) this.createBy.clone()); - - - + } catch (CloneNotSupportedException e) { + log.error("When clone " + SurveyQuestion.class + " failed"); + } + return obj; + } + + // ********************************************************** + // Get/Set methods + // ********************************************************** + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long userID) { + this.uid = userID; + } + + /** + * @hibernate.property column="description" type="text" + * @return + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * @hibernate.set lazy="false" cascade="all-delete-orphan" inverse="false" order-by="sequence_id asc" + * @hibernate.collection-key column="question_uid" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.survey.model.SurveyOption" + * @return + */ + public Set getOptions() { + return options; + } + + public void setOptions(Set itemInstructions) { + this.options = itemInstructions; + } + + /** + * @hibernate.many-to-one cascade="none" column="create_by" + * + * @return + */ + public SurveyUser getCreateBy() { + return createBy; + } + + public void setCreateBy(SurveyUser createBy) { + this.createBy = createBy; + } + + /** + * @hibernate.property column="create_date" + * @return + */ + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } + + /** + * @hibernate.property column="question_type" + * @return + */ + public short getType() { + return type; + } + + public void setType(short type) { + this.type = type; + } + + /** + * @hibernate.property column="append_text" + * @return + */ + public boolean isAppendText() { + return appendText; + } + + public void setAppendText(boolean appendText) { + this.appendText = appendText; + } + + /** + * @hibernate.property column="optional" + * @return + */ + public boolean isOptional() { + return optional; + } + + public void setOptional(boolean compulsory) { + this.optional = compulsory; + } + + /** + * @hibernate.property column="allow_multiple_answer" + * @return + */ + public boolean isAllowMultipleAnswer() { + return allowMultipleAnswer; + } + + public void setAllowMultipleAnswer(boolean allowMultipleAnswer) { + this.allowMultipleAnswer = allowMultipleAnswer; + } + + /** + * @hibernate.property column="sequence_id" + * @return + */ + public int getSequenceId() { + return sequenceId; + } + + public void setSequenceId(int sequenceId) { + this.sequenceId = sequenceId; + } + + public String getShortTitle() { + return shortTitle; + } + + public void setShortTitle(String shortTitle) { + this.shortTitle = shortTitle; + } + } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java,v diff -u -r1.5 -r1.5.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java 24 Oct 2006 00:06:52 -0000 1.5 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java 29 Oct 2014 19:58:21 -0000 1.5.14.1 @@ -24,10 +24,7 @@ package org.lamsfoundation.lams.tool.survey.model; import java.util.Date; -import java.util.Set; -import org.apache.log4j.Logger; - /** * Survey * @author Dapeng Ni Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java,v diff -u -r1.4 -r1.4.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java 24 Oct 2006 00:06:52 -0000 1.4 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java 29 Oct 2014 19:58:21 -0000 1.4.14.1 @@ -23,190 +23,213 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.survey.model; -import java.util.Date; - import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.log4j.Logger; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; + /** * Survey + * * @author Dapeng Ni - * - * @hibernate.class table="tl_lasurv11_user" - * + * + * @hibernate.class table="tl_lasurv11_user" */ -public class SurveyUser implements Cloneable{ - private static final long serialVersionUID = -7043502180037866257L; - private static Logger log = Logger.getLogger(SurveyUser.class); - +public class SurveyUser implements Cloneable { + private static final long serialVersionUID = -7043502180037866257L; + private static Logger log = Logger.getLogger(SurveyUser.class); + private Long uid; - private Long userId; - private String firstName; - private String lastName; - private String loginName; - private boolean sessionFinished; - - private SurveySession session; - private Survey survey; - - - public SurveyUser(){ - } - public SurveyUser(UserDTO user, SurveySession session){ - this.userId = new Long(user.getUserID().intValue()); - this.firstName = user.getFirstName(); - this.lastName = user.getLastName(); - this.loginName = user.getLogin(); - this.session = session; - this.survey = null; - this.sessionFinished = false; - } - public SurveyUser(UserDTO user, Survey content){ - this.userId = new Long(user.getUserID().intValue()); - this.firstName = user.getFirstName(); - this.lastName = user.getLastName(); - this.loginName = user.getLogin(); - this.session = null; - this.survey = content; - this.sessionFinished = false; - } - /** - * Clone method from java.lang.Object - */ - public Object clone(){ - - SurveyUser user = null; - try{ - user = (SurveyUser) super.clone(); - user.setUid(null); - //never clone session - user.setSession(null); - } catch (CloneNotSupportedException e) { - log.error("When clone " + SurveyUser.class + " failed"); - } - - return user; - } -// ********************************************************** - // Get/Set methods -// ********************************************************** - /** - * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" - * @return Returns the uid. - */ - public Long getUid() { - return uid; - } - /** - * @param uid The uid to set. - */ - public void setUid(Long userID) { - this.uid = userID; - } + private Long userId; + private String firstName; + private String lastName; + private String loginName; + private boolean sessionFinished; + private boolean responseFinalized; - /** - * @hibernate.property column="user_id" length="20" - * @return Returns the userId. - */ - public Long getUserId() { - return userId; - } - /** - * @param userId - * The userId to set. - */ - public void setUserId(Long userID) { - this.userId = userID; - } + private SurveySession session; + private Survey survey; - /** - * @hibernate.property length="255" column="last_name" - * @return - */ - public String getLastName() { - return lastName; - } - public void setLastName(String lastName) { - this.lastName = lastName; - } - /** - * @hibernate.property length="255" column="first_name" - * @return - */ - public String getFirstName() { - return firstName; - } - public void setFirstName(String firstName) { - this.firstName = firstName; - } - + public SurveyUser() { + } - /** - * @hibernate.property column="login_name" - * @return - */ - public String getLoginName() { - return loginName; - } + public SurveyUser(UserDTO user, SurveySession session) { + this.userId = new Long(user.getUserID().intValue()); + this.firstName = user.getFirstName(); + this.lastName = user.getLastName(); + this.loginName = user.getLogin(); + this.session = session; + this.survey = null; + this.sessionFinished = false; + this.responseFinalized = false; + } - public void setLoginName(String loginName) { - this.loginName = loginName; - } - /** - * @hibernate.many-to-one column="session_uid" - * cascade="none" - * @return - */ - public SurveySession getSession() { - return session; - } + public SurveyUser(UserDTO user, Survey content) { + this.userId = new Long(user.getUserID().intValue()); + this.firstName = user.getFirstName(); + this.lastName = user.getLastName(); + this.loginName = user.getLogin(); + this.session = null; + this.survey = content; + this.responseFinalized = false; + } - public void setSession(SurveySession session) { - this.session = session; - } - /** - * @hibernate.many-to-one column="survey_uid" - * cascade="none" - * @return - */ - public Survey getSurvey() { - return survey; - } - public void setSurvey(Survey content) { - this.survey = content; - } - /** - * @hibernate.property column="session_finished" - * @return - */ - public boolean isSessionFinished() { - return sessionFinished; - } + /** + * Clone method from java.lang.Object + */ + public Object clone() { - public void setSessionFinished(boolean sessionFinished) { - this.sessionFinished = sessionFinished; + SurveyUser user = null; + try { + user = (SurveyUser) super.clone(); + user.setUid(null); + // never clone session + user.setSession(null); + } catch (CloneNotSupportedException e) { + log.error("When clone " + SurveyUser.class + " failed"); } - - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!(obj instanceof SurveyUser)) - return false; - final SurveyUser user = (SurveyUser) obj; - - return new EqualsBuilder().append(this.uid, user.uid).append(this.firstName, user.firstName) - .append(this.lastName,user.lastName).append(this.loginName, user.loginName).isEquals(); - - } + return user; + } - public int hashCode() { - return new HashCodeBuilder().append(uid).append(firstName) - .append(lastName).append(loginName) - .toHashCode(); - } + // ********************************************************** + // Get/Set methods + // ********************************************************** + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + /** + * @param uid + * The uid to set. + */ + public void setUid(Long userID) { + this.uid = userID; + } + /** + * @hibernate.property column="user_id" length="20" + * @return Returns the userId. + */ + public Long getUserId() { + return userId; + } + /** + * @param userId + * The userId to set. + */ + public void setUserId(Long userID) { + this.userId = userID; + } + + /** + * @hibernate.property length="255" column="last_name" + * @return + */ + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @hibernate.property length="255" column="first_name" + * @return + */ + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @hibernate.property column="login_name" + * @return + */ + public String getLoginName() { + return loginName; + } + + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + /** + * @hibernate.many-to-one column="session_uid" cascade="none" + * @return + */ + public SurveySession getSession() { + return session; + } + + public void setSession(SurveySession session) { + this.session = session; + } + + /** + * @hibernate.many-to-one column="survey_uid" cascade="none" + * @return + */ + public Survey getSurvey() { + return survey; + } + + public void setSurvey(Survey content) { + this.survey = content; + } + + /** + * @hibernate.property column="session_finished" + * @return + */ + public boolean isSessionFinished() { + return sessionFinished; + } + + 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; + if (!(obj instanceof SurveyUser)) + return false; + + final SurveyUser user = (SurveyUser) obj; + + return new EqualsBuilder().append(this.uid, user.uid).append(this.firstName, user.firstName) + .append(this.lastName, user.lastName).append(this.loginName, user.loginName).isEquals(); + + } + + public int hashCode() { + return new HashCodeBuilder().append(uid).append(firstName).append(lastName).append(loginName).toHashCode(); + } + } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java,v diff -u -r1.20 -r1.20.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java 10 Mar 2014 22:39:23 -0000 1.20 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java 29 Oct 2014 19:58:20 -0000 1.20.2.1 @@ -29,7 +29,6 @@ import java.util.Set; import java.util.SortedMap; -import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.survey.dto.AnswerDTO; import org.lamsfoundation.lams.tool.survey.dto.ReflectDTO; @@ -39,12 +38,11 @@ import org.lamsfoundation.lams.tool.survey.model.SurveyQuestion; import org.lamsfoundation.lams.tool.survey.model.SurveySession; import org.lamsfoundation.lams.tool.survey.model.SurveyUser; -import org.lamsfoundation.lams.usermanagement.User; /** * @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 { @@ -118,6 +116,11 @@ */ AnswerDTO getQuestionResponse(Long sessionId, Long questionUid); + List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId, int page, int size, + int sorting); + + int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId); + /** * Commit answers for a group of question together. * @@ -165,6 +168,14 @@ * @return */ List getSessionUsers(Long sessionId); + + /** + * Get number of finished users. + * + * @param sessionId + * @return + */ + int getCountFinishedUsers(Long sessionId); // ****************************************************************************************** // ********** Session methods *********************** @@ -193,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 @@ -261,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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java,v diff -u -r1.37 -r1.37.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java 6 Jun 2014 16:42:59 -0000 1.37 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java 29 Oct 2014 19:58:20 -0000 1.37.2.1 @@ -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) { @@ -340,57 +352,70 @@ } // initial a array to hold how many time chose has been done for a option or open text. - int optSize = options.size(); + int numberAvailableOptions = options.size(); // for appendText and open Text Entry will be the last one of choose[] array. if (answerDto.isAppendText() || answerDto.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { - optSize++; + numberAvailableOptions++; } - int[] choose = new int[optSize]; - Arrays.fill(choose, 0); + int[] choiceArray = new int[numberAvailableOptions]; + Arrays.fill(choiceArray, 0); // sum up all option and open text (if has) have been selected count list - int answerSum = 0; + int numberAnswers = 0; if (answsers != null) { for (SurveyAnswer answer : answsers) { - String[] choseOpt = SurveyWebUtils.getChoiceList(answer.getAnswerChoices()); - for (String optUid : choseOpt) { + String[] choiceList = SurveyWebUtils.getChoiceList(answer.getAnswerChoices()); + for (String optUid : choiceList) { // if option has been chosen, the relative index of choose[] array will increase. if (optMap.containsKey(optUid)) { - choose[optMap.get(optUid)]++; - answerSum++; + choiceArray[optMap.get(optUid)]++; + numberAnswers++; } } // handle appendText or Open Text Entry if ((answerDto.isAppendText() || answerDto.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) && !StringUtils.isBlank(answer.getAnswerText())) { - choose[optSize - 1]++; - answerSum++; + choiceArray[numberAvailableOptions - 1]++; + numberAnswers++; } } } // caculate the percentage of answer response idx = 0; - if (answerSum == 0) { - answerSum = 1; + if (numberAnswers == 0) { + numberAnswers = 1; } for (SurveyOption option : options) { - option.setResponse((double) choose[idx] / (double) answerSum * 100d); - option.setResponseFormatStr(new Long(Math.round(option.getResponse())).toString()); - option.setResponseCount(choose[idx]); + double percentage = (double) choiceArray[idx] / (double) numberAnswers * 100d; + option.setResponse(percentage); + option.setResponseFormatStr(new Long(Math.round(percentage)).toString()); + option.setResponseCount(choiceArray[idx]); idx++; } if (answerDto.isAppendText() || answerDto.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { - answerDto.setOpenResponse((double) choose[idx] / (double) answerSum * 100d); - answerDto.setOpenResponseFormatStr(new Long(Math.round(answerDto.getOpenResponse())).toString()); - answerDto.setOpenResponseCount(choose[idx]); + double percentage = (double) choiceArray[idx] / (double) numberAnswers * 100d; + answerDto.setOpenResponse(percentage); + answerDto.setOpenResponseFormatStr(new Long(Math.round(percentage)).toString()); + answerDto.setOpenResponseCount(choiceArray[idx]); } return answerDto; + } + @Override + 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) { + return surveyAnswerDao.getCountResponsesBySessionAndQuestion(qaSessionId, questionId); + } + + @Override public SortedMap> getSummary(Long toolContentId) { SortedMap> summary = new TreeMap>( @@ -502,11 +527,11 @@ return summary; } - + public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } - + @Override public String createConditionName(Collection existingConditions) { String uniqueNumber = null; @@ -531,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); @@ -633,7 +658,7 @@ try { // register version filter class exportContentService.registerImportVersionFilterClass(SurveyImportContentVersionFilter.class); - + Object toolPOJO = exportContentService.importToolContent(toolContentPath, surveyToolContentHandler, fromVersion, toVersion); if (!(toolPOJO instanceof Survey)) { @@ -719,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); @@ -732,7 +757,7 @@ } survey.setDefineLater(false); } - + @Override public boolean isContentEdited(Long toolContentId) { return getSurveyByContentId(toolContentId).isDefineLater(); @@ -837,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/util/SurveyWebUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java,v diff -u -r1.6 -r1.6.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java 27 Sep 2006 04:41:00 -0000 1.6 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java 29 Oct 2014 19:58:20 -0000 1.6.14.1 @@ -21,53 +21,49 @@ * **************************************************************** */ -/* $$Id$$ */ +/* $$Id$$ */ package org.lamsfoundation.lams.tool.survey.util; -import org.apache.commons.lang.StringUtils; import org.lamsfoundation.lams.tool.survey.model.Survey; -import org.lamsfoundation.lams.tool.survey.model.SurveyQuestion; import org.lamsfoundation.lams.tool.survey.web.action.MonitoringAction; - - /** * Contains helper methods used by the Action Servlets * * @author Anthony Sukkar - * */ public class SurveyWebUtils { - public static boolean isSurveyEditable(Survey survey) { - if ( (survey.isDefineLater() == true) && (survey.isContentInUse()==true) ) - { - // throw new SurveyApplicationException("An exception has occurred: There is a bug in this tool, conflicting flags are set"); - MonitoringAction.log.error("An exception has occurred: There is a bug in this tool, conflicting flags are set"); - return false; - } - else if ( (survey.isDefineLater() == true) && (survey.isContentInUse() == false)) - return true; - else if ( (survey.isDefineLater() == false) && (survey.isContentInUse() == false)) - return true; - else // (content.isContentInUse()==true && content.isDefineLater() == false) - return false; - } + public static boolean isSurveyEditable(Survey survey) { + if ((survey.isDefineLater() == true) && (survey.isContentInUse() == true)) { + // throw new + // SurveyApplicationException("An exception has occurred: There is a bug in this tool, conflicting flags are set"); + MonitoringAction.log + .error("An exception has occurred: There is a bug in this tool, conflicting flags are set"); + return false; + } else if ((survey.isDefineLater() == true) && (survey.isContentInUse() == false)) + return true; + else if ((survey.isDefineLater() == false) && (survey.isContentInUse() == false)) + return true; + else + // (content.isContentInUse()==true && content.isDefineLater() == false) + return false; + } - public static String getChoicesStr(String[] choiceList) { - String choices = ""; - if(choiceList == null) - return choices; - - for(String c: choiceList) - choices = choices + c + "&"; - return choices; - } - - public static String[] getChoiceList(String choiceList) { - if(choiceList == null) - return new String[]{}; - - return choiceList.split("&"); - } + public static String getChoicesStr(String[] choiceList) { + String choices = ""; + if (choiceList == null) + return choices; + + for (String c : choiceList) + choices = choices + c + "&"; + return choices; + } + + public static String[] getChoiceList(String choiceList) { + if (choiceList == null) + return new String[] {}; + + return choiceList.split("&"); + } } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java,v diff -u -r1.27 -r1.27.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java 17 Jan 2014 22:18:05 -0000 1.27 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java 29 Oct 2014 19:58:20 -0000 1.27.2.1 @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -54,9 +53,7 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.authoring.web.AuthoringConstants; -import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.learningdesign.TextSearchConditionComparator; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.survey.SurveyConstants; @@ -67,13 +64,11 @@ import org.lamsfoundation.lams.tool.survey.model.SurveyUser; import org.lamsfoundation.lams.tool.survey.service.ISurveyService; import org.lamsfoundation.lams.tool.survey.service.SurveyApplicationException; -import org.lamsfoundation.lams.tool.survey.service.UploadSurveyFileException; import org.lamsfoundation.lams.tool.survey.util.QuestionsComparator; import org.lamsfoundation.lams.tool.survey.util.SurveyWebUtils; import org.lamsfoundation.lams.tool.survey.web.form.QuestionForm; import org.lamsfoundation.lams.tool.survey.web.form.SurveyForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; -import org.lamsfoundation.lams.util.FileValidatorUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java,v diff -u -r1.7 -r1.7.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java 23 Nov 2012 09:58:05 -0000 1.7 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java 29 Oct 2014 19:58:20 -0000 1.7.2.1 @@ -54,7 +54,7 @@ */ public class ChartAction extends Action { - static Logger logger = Logger.getLogger(ChartAction.class); + private static Logger logger = Logger.getLogger(ChartAction.class); private static ISurveyService surveyService; private MessageResources resource; @@ -67,6 +67,7 @@ Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID); + // if excludeUserId received exclude this user's answers 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."); @@ -94,7 +95,7 @@ } catch (JSONException e) { ChartAction.logger.error("Error while generating pie chart for Survey Tool: " + sessionId); } - + response.setContentType("application/json;charset=utf-8"); response.getWriter().write(responseJSON.toString()); return null; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java,v diff -u -r1.29 -r1.29.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java 8 Jul 2014 08:39:53 -0000 1.29 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java 29 Oct 2014 19:58:20 -0000 1.29.2.1 @@ -32,14 +32,15 @@ import java.util.List; import java.util.Map; import java.util.SortedMap; -import java.util.TreeMap; import java.util.TimeZone; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.action.Action; @@ -48,8 +49,10 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; -import org.lamsfoundation.lams.events.DeliveryMethodMail; -import org.lamsfoundation.lams.events.IEventNotificationService; +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; import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; import org.lamsfoundation.lams.notebook.model.NotebookEntry; @@ -59,6 +62,7 @@ import org.lamsfoundation.lams.tool.survey.dto.AnswerDTO; import org.lamsfoundation.lams.tool.survey.model.Survey; import org.lamsfoundation.lams.tool.survey.model.SurveyAnswer; +import org.lamsfoundation.lams.tool.survey.model.SurveyQuestion; import org.lamsfoundation.lams.tool.survey.model.SurveySession; import org.lamsfoundation.lams.tool.survey.model.SurveyUser; import org.lamsfoundation.lams.tool.survey.service.ISurveyService; @@ -67,7 +71,6 @@ import org.lamsfoundation.lams.tool.survey.util.SurveyWebUtils; import org.lamsfoundation.lams.tool.survey.web.form.AnswerForm; import org.lamsfoundation.lams.tool.survey.web.form.ReflectionForm; -import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.WebUtil; @@ -89,7 +92,7 @@ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException { + HttpServletResponse response) throws IOException, ServletException, JSONException { String param = mapping.getParameter(); // -----------------------Survey Learner function --------------------------- @@ -110,6 +113,14 @@ return retake(mapping, form, request, response); } + if (param.equals("showOtherUsersAnswers")) { + return showOtherUsersAnswers(mapping, form, request, response); + } + + if (param.equals("getOpenResponses")) { + return getOpenResponses(mapping, form, request, response); + } + if (param.equals("finish")) { return finish(mapping, form, request, response); } @@ -138,19 +149,20 @@ 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(); SurveyUser surveyUser = null; - if (mode != null && mode.isTeacher()) { + if ((mode != null) && mode.isTeacher()) { // monitoring mode - user is specified in URL surveyUser = getSpecifiedUser(service, sessionId, WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); @@ -161,12 +173,9 @@ surveyUser = getCurrentUser(service, sessionId); } - Survey survey; List answers = service.getQuestionAnswers(sessionId, surveyUser.getUid()); - survey = service.getSurveyBySessionId(sessionId); + 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(); @@ -183,10 +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, surveyUser); sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); sessionMap.put(AttributeNames.ATTR_MODE, mode); @@ -249,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, @@ -262,7 +284,8 @@ Integer questionSeqID = answerForm.getQuestionSeqID(); String sessionMapID = answerForm.getSessionMapID(); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); SortedMap surveyItemMap = getQuestionList(sessionMap); ActionErrors errors = getAnswer(request, surveyItemMap.get(questionSeqID)); @@ -303,7 +326,8 @@ Integer questionSeqID = answerForm.getQuestionSeqID(); String sessionMapID = answerForm.getSessionMapID(); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); SortedMap surveyItemMap = getQuestionList(sessionMap); ActionErrors errors = getAnswer(request, surveyItemMap.get(questionSeqID)); @@ -337,8 +361,9 @@ Integer questionSeqID = answerForm.getQuestionSeqID(); answerForm.setPosition(SurveyConstants.POSITION_ONLY_ONE); String sessionMapID = answerForm.getSessionMapID(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); SortedMap surveyItemMap = getQuestionList(sessionMap); // get current question index of total questions int currIdx = new ArrayList(surveyItemMap.keySet()).indexOf(questionSeqID) + 1; @@ -347,30 +372,98 @@ return mapping.findForward(SurveyConstants.SUCCESS); } + private ActionForward showOtherUsersAnswers(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + ISurveyService service = getSurveyService(); + String sessionMapID = request.getParameter("sessionMapID"); + request.setAttribute("sessionMapID", sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); + + 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()); + 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); + } + + /** + * Get OpenResponses. + */ + private ActionForward getOpenResponses(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse res) throws IOException, ServletException, JSONException { + ISurveyService service = getSurveyService(); + + Long questionUid = WebUtil.readLongParam(request, "questionUid"); + Long sessionId = WebUtil.readLongParam(request, "sessionId"); + + //paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); + + int sorting = SurveyConstants.SORT_BY_DEAFAULT; + if (isSort1 != null && isSort1.equals(0)) { + sorting = SurveyConstants.SORT_BY_ANSWER_ASC; + } else if (isSort1 != null && isSort1.equals(1)) { + sorting = SurveyConstants.SORT_BY_ANSWER_DESC; + } + + 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)); + + for (String response : responses) { + //JSONArray cell=new JSONArray(); + //cell.put(StringEscapeUtils.escapeHtml(user.getFirstName()) + " " + StringEscapeUtils.escapeHtml(user.getLastName()) + " [" + StringEscapeUtils.escapeHtml(user.getLogin()) + "]"); + + JSONObject responseRow = new JSONObject(); + responseRow.put("answer", StringEscapeUtils.escapeCsv(response)); +// responseRow.put("attemptTime", response.getAttemptTime()); + + rows.put(responseRow); + } + responcedata.put("rows", rows); + res.setContentType("application/json;charset=utf-8"); + res.getWriter().print(new String(responcedata.toString())); + return null; + } + private ActionForward doSurvey(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ISurveyService service = getSurveyService(); AnswerForm answerForm = (AnswerForm) form; Integer questionSeqID = answerForm.getQuestionSeqID(); String sessionMapID = answerForm.getSessionMapID(); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); // validate 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)) { + if ((questionSeqID == null) || questionSeqID.equals(0)) { errors = getAnswers(request); } else { errors = getAnswer(request, surveyItemMap.get(questionSeqID)); @@ -382,8 +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()); } } @@ -394,12 +486,9 @@ Survey survey = service.getSurveyBySessionId(sessionId); if (survey.isNotifyTeachersOnAnswerSumbit()) { - if (surveyLearner == null) { - surveyLearner = getCurrentUser(service, sessionId); - } service.notifyTeachersOnAnswerSumbit(sessionId, surveyLearner); } - + return mapping.findForward(SurveyConstants.SUCCESS); } @@ -417,7 +506,8 @@ // get back SessionMap String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); // get mode and ToolSessionID from sessionMAP Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -464,7 +554,7 @@ // get the existing reflection entry ISurveyService submitFilesService = getSurveyService(); - SessionMap map = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap map = (SessionMap) request.getSession().getAttribute(sessionMapID); Long toolSessionID = (Long) map.get(AttributeNames.PARAM_TOOL_SESSION_ID); NotebookEntry entry = submitFilesService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, SurveyConstants.TOOL_SIGNATURE, user.getUserID()); @@ -491,7 +581,8 @@ Integer userId = refForm.getUserID(); String sessionMapID = WebUtil.readStrParam(request, SurveyConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); ISurveyService service = getSurveyService(); @@ -524,7 +615,8 @@ ActionErrors errors = new ActionErrors(); // get sessionMap String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); SurveyAnswer answer = getAnswerFromPage(request, answerDto, sessionID); @@ -546,7 +638,8 @@ ActionErrors errors = new ActionErrors(); // get sessionMap String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( + sessionMapID); Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); Collection answerDtoList = getQuestionList(sessionMap).values(); @@ -563,14 +656,14 @@ private void validateAnswers(HttpServletRequest request, AnswerDTO question, ActionErrors errors, SurveyAnswer answer) { - boolean isAnswerEmpty = (answer.getChoices() == null && StringUtils.isBlank(answer.getAnswerText())); + boolean isAnswerEmpty = ((answer.getChoices() == null) && StringUtils.isBlank(answer.getAnswerText())); // for mandatory questions, answer can not be null. if (!question.isOptional() && isAnswerEmpty) { errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(), new ActionMessage( SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); } - if (question.getType() == SurveyConstants.QUESTION_TYPE_SINGLE_CHOICE && question.isAppendText() + if ((question.getType() == SurveyConstants.QUESTION_TYPE_SINGLE_CHOICE) && question.isAppendText() && !isAnswerEmpty) { // for single choice, user only can choose one option or open text (if it has) if (!StringUtils.isBlank(answer.getAnswerChoices()) && !StringUtils.isBlank(answer.getAnswerText())) { @@ -613,7 +706,7 @@ * @param request * @return */ - private SortedMap getQuestionList(SessionMap sessionMap) { + private SortedMap getQuestionList(SessionMap sessionMap) { SortedMap list = (SortedMap) sessionMap .get(SurveyConstants.ATTR_QUESTION_LIST); if (list == null) { Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java,v diff -u -r1.23 -r1.23.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java 17 Jan 2014 22:18:05 -0000 1.23 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java 29 Oct 2014 19:58:20 -0000 1.23.2.1 @@ -27,14 +27,14 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.util.Date; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; -import java.util.TreeMap; -import java.util.Map.Entry; -import java.util.Date; import java.util.TimeZone; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -66,12 +66,12 @@ import org.lamsfoundation.lams.tool.survey.util.SurveyUserComparator; import org.lamsfoundation.lams.tool.survey.util.SurveyWebUtils; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; -import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; -import org.lamsfoundation.lams.web.session.SessionManager; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -456,8 +456,7 @@ * @param string * @return */ - private String removeHTMLTags(String string) - { + private String removeHTMLTags(String string) { return string.replaceAll("\\<.*?>", "").replaceAll(" ", " "); } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java,v diff -u -r1.3 -r1.3.14.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java 17 Nov 2006 02:06:43 -0000 1.3 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java 29 Oct 2014 19:58:21 -0000 1.3.14.1 @@ -24,12 +24,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.survey.web.form; -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; import org.apache.struts.validator.ValidatorForm; /** Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java,v diff -u -r1.4 -r1.4.2.1 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java 17 Jan 2014 22:18:05 -0000 1.4 +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java 29 Oct 2014 19:58:21 -0000 1.4.2.1 @@ -33,101 +33,95 @@ import org.lamsfoundation.lams.tool.survey.model.Survey; /** - * - * Survey Form. - * @struts.form name="surveyForm" - * + * Survey Form. + * + * @struts.form name="surveyForm" + * * User: Dapeng.Ni */ -public class SurveyForm extends ActionForm { - private static final long serialVersionUID = 3599879328307492312L; +public class SurveyForm extends ActionForm { + private static final long serialVersionUID = 3599879328307492312L; - private static Logger logger = Logger.getLogger(SurveyForm.class.getName()); + private static Logger logger = Logger.getLogger(SurveyForm.class.getName()); - //Forum fields - private String sessionMapID; - private String contentFolderID; - private int currentTab; + // Forum fields + private String sessionMapID; + private String contentFolderID; + private int currentTab; private FormFile offlineFile; private FormFile onlineFile; private Survey survey; - - public SurveyForm(){ - survey = new Survey(); - survey.setTitle("Survey"); - currentTab = 1; + + public SurveyForm() { + survey = new Survey(); + survey.setTitle("Survey"); + currentTab = 1; } - - public void setSurvey(Survey survey) { - this.survey = survey; - //set Form special varaible from given forum - if(survey == null){ - logger.error("Initial SurveyForum failed by null value of Survey."); - } + + public void setSurvey(Survey survey) { + this.survey = survey; + // set Form special varaible from given forum + if (survey == null) { + logger.error("Initial SurveyForum failed by null value of Survey."); } - public void reset(ActionMapping mapping, HttpServletRequest request){ - String param = mapping.getParameter(); - //if it is start page, all data read out from database or current session - //so need not reset checkbox to refresh value! - if(!StringUtils.equals(param,"start") && !StringUtils.equals(param,"initPage")){ - survey.setLockWhenFinished(false); - survey.setDefineLater(false); - survey.setReflectOnActivity(false); - survey.setShowOnePage(false); - - } } - public int getCurrentTab() { - return currentTab; + public void reset(ActionMapping mapping, HttpServletRequest request) { + String param = mapping.getParameter(); + // if it is start page, all data read out from database or current session + // so need not reset checkbox to refresh value! + if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) { + survey.setLockWhenFinished(false); + survey.setDefineLater(false); + survey.setReflectOnActivity(false); + survey.setShowOnePage(false); + survey.setShowOtherUsersAnswers(false); } + } + public int getCurrentTab() { + return currentTab; + } - public void setCurrentTab(int currentTab) { - this.currentTab = currentTab; - } + public void setCurrentTab(int currentTab) { + this.currentTab = currentTab; + } + public FormFile getOfflineFile() { + return offlineFile; + } - public FormFile getOfflineFile() { - return offlineFile; - } + public void setOfflineFile(FormFile offlineFile) { + this.offlineFile = offlineFile; + } + public FormFile getOnlineFile() { + return onlineFile; + } - public void setOfflineFile(FormFile offlineFile) { - this.offlineFile = offlineFile; - } + public void setOnlineFile(FormFile onlineFile) { + this.onlineFile = onlineFile; + } + public Survey getSurvey() { + return survey; + } - public FormFile getOnlineFile() { - return onlineFile; - } + public String getSessionMapID() { + return sessionMapID; + } + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } - public void setOnlineFile(FormFile onlineFile) { - this.onlineFile = onlineFile; - } + public String getContentFolderID() { + return contentFolderID; + } + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } - public Survey getSurvey() { - return survey; - } - - public String getSessionMapID() { - return sessionMapID; - } - - public void setSessionMapID(String sessionMapID) { - this.sessionMapID = sessionMapID; - } - - public String getContentFolderID() { - return contentFolderID; - } - - public void setContentFolderID(String contentFolderID) { - this.contentFolderID = contentFolderID; - } - - } Index: lams_tool_survey/web/common/header.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/common/header.jsp,v diff -u -r1.4.2.1 -r1.4.2.2 --- lams_tool_survey/web/common/header.jsp 3 Sep 2014 12:52:10 -0000 1.4.2.1 +++ lams_tool_survey/web/common/header.jsp 29 Oct 2014 19:58:21 -0000 1.4.2.2 @@ -8,7 +8,6 @@ - Index: lams_tool_survey/web/pages/authoring/addCondition.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/authoring/addCondition.jsp,v diff -u -r1.5 -r1.5.2.1 --- lams_tool_survey/web/pages/authoring/addCondition.jsp 15 Aug 2013 20:20:21 -0000 1.5 +++ lams_tool_survey/web/pages/authoring/addCondition.jsp 29 Oct 2014 19:58:21 -0000 1.5.2.1 @@ -5,6 +5,7 @@ <%@ include file="/common/header.jsp"%> + - - + + - -

@@ -60,16 +55,14 @@ <%-- Show on one page or when learner does not choose edit one question --%> - + <%@ include file="/pages/learning/question.jsp"%> - + ${currentIdx} ${sessionMap.totalQuestions} <%@ include file="/pages/learning/question.jsp"%> Index: lams_tool_survey/web/pages/learning/notebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/learning/notebook.jsp,v diff -u -r1.14 -r1.14.2.1 --- lams_tool_survey/web/pages/learning/notebook.jsp 1 Apr 2014 19:05:18 -0000 1.14 +++ lams_tool_survey/web/pages/learning/notebook.jsp 29 Oct 2014 19:58:20 -0000 1.14.2.1 @@ -10,10 +10,10 @@ function disableFinishButton() { document.getElementById("finishButton").disabled = true; } - function submitForm(methodName){ - var f = document.getElementById('messageForm'); - f.submit(); - } + function submitForm(methodName){ + var f = document.getElementById('messageForm'); + f.submit(); + } Index: lams_tool_survey/web/pages/learning/question.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/learning/question.jsp,v diff -u -r1.10 -r1.10.2.1 --- lams_tool_survey/web/pages/learning/question.jsp 1 Apr 2014 19:05:18 -0000 1.10 +++ lams_tool_survey/web/pages/learning/question.jsp 29 Oct 2014 19:58:20 -0000 1.10.2.1 @@ -45,8 +45,7 @@

- + ${answerText}

Index: lams_tool_survey/web/pages/learning/result.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/learning/result.jsp,v diff -u -r1.23 -r1.23.2.1 --- lams_tool_survey/web/pages/learning/result.jsp 3 Apr 2014 15:35:51 -0000 1.23 +++ lams_tool_survey/web/pages/learning/result.jsp 29 Oct 2014 19:58:20 -0000 1.23.2.1 @@ -1,39 +1,39 @@ - + <%@ include file="/common/taglibs.jsp"%> - <fmt:message key="label.learning.title" /> - + <fmt:message key="label.learning.title" /> <%@ include file="/common/header.jsp"%> - -

@@ -43,16 +43,37 @@

-
- - - - - - - - -
+
+ + + + + ${buttonLabel} + + + + + + + + + + + + + + + + + + + + + ${buttonLabel} + + + +
@@ -65,10 +86,10 @@ - - + + + +

@@ -96,7 +117,7 @@

- + @@ -107,13 +128,12 @@
- + - +

@@ -123,8 +143,7 @@

- - +

@@ -134,8 +153,7 @@
- +
@@ -145,13 +163,20 @@
- + + + + + + + + - + + @@ -160,14 +185,16 @@ + - + +
Fisheye: Tag 1.3.2.1 refers to a dead (removed) revision in file `lams_tool_survey/web/pages/learning/resultOtherUsers.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_survey/web/pages/learning/submissionDeadline.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/learning/submissionDeadline.jsp,v diff -u -r1.2 -r1.2.2.1 --- lams_tool_survey/web/pages/learning/submissionDeadline.jsp 7 Apr 2014 00:38:06 -0000 1.2 +++ lams_tool_survey/web/pages/learning/submissionDeadline.jsp 29 Oct 2014 19:58:20 -0000 1.2.2.1 @@ -8,17 +8,14 @@ <%@ include file="/common/header.jsp"%> Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_survey/web/pages/monitoring/advanceoptions.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_survey/web/pages/monitoring/listanswers.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/monitoring/listanswers.jsp,v diff -u -r1.8 -r1.8.2.1 --- lams_tool_survey/web/pages/monitoring/listanswers.jsp 1 Apr 2014 19:05:18 -0000 1.8 +++ lams_tool_survey/web/pages/monitoring/listanswers.jsp 29 Oct 2014 19:58:21 -0000 1.8.2.1 @@ -1,7 +1,6 @@ - <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.survey.SurveyConstants"%> Index: lams_tool_survey/web/pages/monitoring/notebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/monitoring/Attic/notebook.jsp,v diff -u -r1.9 -r1.9.2.1 --- lams_tool_survey/web/pages/monitoring/notebook.jsp 1 Apr 2014 19:05:18 -0000 1.9 +++ lams_tool_survey/web/pages/monitoring/notebook.jsp 29 Oct 2014 19:58:21 -0000 1.9.2.1 @@ -1,6 +1,6 @@ -<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/taglibs.jsp"%> Index: lams_tool_survey/web/pages/monitoring/summary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_survey/web/pages/monitoring/summary.jsp,v diff -u -r1.18 -r1.18.2.1 --- lams_tool_survey/web/pages/monitoring/summary.jsp 7 Apr 2014 00:43:04 -0000 1.18 +++ lams_tool_survey/web/pages/monitoring/summary.jsp 29 Oct 2014 19:58:21 -0000 1.18.2.1 @@ -214,98 +214,7 @@
-

- +<%@include file="advanceoptions.jsp"%> - - - -

-
- - - <%@include file="daterestriction.jsp"%> \ No newline at end of file