Index: lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rca0f8f67547691b7a216d696046b36ae086fd619 -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision ca0f8f67547691b7a216d696046b36ae086fd619) +++ lams_tool_survey/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -181,5 +181,9 @@ 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 #======= End labels: Exported 174 labels for en AU ===== Index: lams_tool_survey/conf/xdoclet/struts-actions.xml =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -188,6 +188,23 @@ + + + + + + + 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, Long excludeUserId); + + List getByToolContentIdAndUserId(Long toolContentId, Long userId); + + List getOpenResponsesForTablesorter(final Long sessionId, final Long questionUid, + final Long excludeUserId, int page, int size, int sorting); + + int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId, final Long excludeUserId); } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java =================================================================== diff -u -r15045d0b9b0dbb930f42a9da7757207e7a325341 -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision 15045d0b9b0dbb930f42a9da7757207e7a325341) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -24,30 +24,79 @@ import java.util.List; +import org.lamsfoundation.lams.tool.survey.SurveyConstants; import org.lamsfoundation.lams.tool.survey.dao.SurveyAnswerDAO; import org.lamsfoundation.lams.tool.survey.model.SurveyAnswer; 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=? AND a.user.userId!=?"; + 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 List getSessionAnswer(Long sessionId, Long questionUid) { - return 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.user.userId!=:excludeUserId AND r.answerText<>'' order by "; + + private static final String GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION = "SELECT COUNT(*) FROM " + + SurveyAnswer.class.getName() + " AS r " + + "WHERE r.user.session.sessionId=? AND r.surveyQuestion.uid=? AND r.user.userId!=? AND r.answerText<>''"; + + @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; + } + + @Override + public List getSessionAnswer(Long sessionId, Long questionUid, Long excludeUserId) { + return getHibernateTemplate().find(GET_SESSION_ANSWER, new Object[] { sessionId, questionUid, excludeUserId}); + } + @SuppressWarnings("unchecked") + @Override public List getByToolContentIdAndUserId(Long toolContentId, Long userId) { return 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 Long excludeUserId, int page, int size, 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; + } + String sqlQuery = LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder; + + return getSession().createQuery(sqlQuery) + .setLong("sessionId", sessionId.longValue()).setLong("questionUid", questionUid.longValue()) + .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size).setMaxResults(size) + .list(); + } + + @Override + public int getCountResponsesBySessionAndQuestion(final Long sessionId, final Long questionId, + final Long excludeUserId) { + + List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION, + new Object[] { sessionId, questionId, excludeUserId }); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql =================================================================== diff -u --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql (revision 0) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dbupdates/patch20141023.sql (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -0,0 +1,14 @@ +-- Turn off autocommit, so nothing is committed if there is an error +SET AUTOCOMMIT = 0; +SET FOREIGN_KEY_CHECKS=0; +----------------------Put all sql statements below here------------------------- + +-- LDEV-3326 Option to include everyone results after survey responses are sent +ALTER TABLE tl_lasurv11_survey ADD COLUMN show_other_users_answers TINYINT(1) NOT NULL DEFAULT 0; + +----------------------Put all sql statements above here------------------------- + +-- If there were no errors, commit and restore autocommit to on +COMMIT; +SET AUTOCOMMIT = 1; +SET FOREIGN_KEY_CHECKS=1; \ No newline at end of file Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java =================================================================== diff -u -r103eacc68afe9e0df0c7bae49c482eb34873165a -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java (.../AnswerDTO.java) (revision 103eacc68afe9e0df0c7bae49c482eb34873165a) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java (.../AnswerDTO.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java (.../Survey.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/Survey.java (.../Survey.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java (.../SurveyAnswer.java) (revision 920894ca746cba5e080023c5cc80167d64d1653d) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyAnswer.java (.../SurveyAnswer.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java (.../SurveyOption.java) (revision 920894ca746cba5e080023c5cc80167d64d1653d) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyOption.java (.../SurveyOption.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java (.../SurveyQuestion.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyQuestion.java (.../SurveyQuestion.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java (.../SurveySession.java) (revision 920894ca746cba5e080023c5cc80167d64d1653d) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveySession.java (.../SurveySession.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r920894ca746cba5e080023c5cc80167d64d1653d -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java (.../SurveyUser.java) (revision 920894ca746cba5e080023c5cc80167d64d1653d) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/model/SurveyUser.java (.../SurveyUser.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -23,190 +23,195 @@ /* $$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; - /** - * @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; + } - 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.sessionFinished = 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; + } + + 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 =================================================================== diff -u -rbb597b8155375e6ac4dfe280f630d323b6e5e575 -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision bb597b8155375e6ac4dfe280f630d323b6e5e575) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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,7 +38,6 @@ 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 @@ -119,6 +117,21 @@ AnswerDTO getQuestionResponse(Long sessionId, Long questionUid); /** + * Get question's answer with response percentage infromation. + * + * @param sessionId + * @param questionUid + * @param excludeUserId exclude this user's answers from result list. + * @return + */ + AnswerDTO getQuestionResponse(Long sessionId, Long questionUid, Long excludeUserId); + + List getOpenResponsesForTablesorter(final Long qaSessionId, final Long questionId, + final Long excludeUserId, int page, int size, int sorting); + + int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId); + + /** * Commit answers for a group of question together. * * @param answerList Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java =================================================================== diff -u -r40eb54374e84591563d8b6a679ac719dbc85c8f7 -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision 40eb54374e84591563d8b6a679ac719dbc85c8f7) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -321,14 +321,20 @@ surveyAnswerDao.saveObject(ans); } } - + @Override public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid) { + //pass -1 as exclude userId to skip no users + return getQuestionResponse(sessionId, questionUid, -1L); + } + + @Override + public AnswerDTO getQuestionResponse(Long sessionId, Long questionUid, Long excludeUserId) { SurveyQuestion question = surveyQuestionDao.getByUid(questionUid); AnswerDTO answerDto = new AnswerDTO(question); // get question all answer from this session - List answsers = surveyAnswerDao.getSessionAnswer(sessionId, questionUid); + List answsers = surveyAnswerDao.getSessionAnswer(sessionId, questionUid, excludeUserId); // create a map to hold Option UID and sequenceID(start from 0); Map optMap = new HashMap(); @@ -340,55 +346,67 @@ } // 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, final Long excludeUserId, + int page, int size, int sorting) { + return surveyAnswerDao.getOpenResponsesForTablesorter(qaSessionId, questionId, excludeUserId, page, size, sorting); + } + + @Override + public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) { + return surveyAnswerDao.getCountResponsesBySessionAndQuestion(qaSessionId, questionId, excludeUserId); + } @Override public SortedMap> getSummary(Long toolContentId) { Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java (.../SurveyWebUtils.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyWebUtils.java (.../SurveyWebUtils.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -rd25b9e0ce0aa1cc320186300d26c05ef385b780c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java (.../ChartAction.java) (revision d25b9e0ce0aa1cc320186300d26c05ef385b780c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ChartAction.java (.../ChartAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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; @@ -66,8 +66,11 @@ Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); Long questionUid = WebUtil.readLongParam(request, SurveyConstants.ATTR_QUESTION_UID); + Long excludeUserId = WebUtil.readLongParam(request, SurveyConstants.ATTR_USER_ID, true); - AnswerDTO answer = getSurveyService().getQuestionResponse(sessionId, questionUid); + // if excludeUserId received exclude this user's answers + AnswerDTO answer = (excludeUserId == null) ? getSurveyService().getQuestionResponse(sessionId, questionUid) + : getSurveyService().getQuestionResponse(sessionId, questionUid, excludeUserId); if (answer.getType() == SurveyConstants.QUESTION_TYPE_TEXT_ENTRY) { ChartAction.logger.error("Error question type : Text entry can not generate chart."); response.getWriter().print(resource.getMessage(SurveyConstants.ERROR_MSG_CHART_ERROR)); @@ -94,7 +97,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 =================================================================== diff -u -rdb8cd59179f23576cd809e7657885236cfafa60b -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision db8cd59179f23576cd809e7657885236cfafa60b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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,9 @@ 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.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 +61,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 +70,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 +91,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 +112,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); } @@ -150,7 +160,7 @@ // 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,9 +171,8 @@ 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(); @@ -186,7 +195,9 @@ sessionMap.put(SurveyConstants.ATTR_FINISH_LOCK, lock); sessionMap.put(SurveyConstants.ATTR_LOCK_ON_FINISH, survey.getLockWhenFinished()); sessionMap.put(SurveyConstants.ATTR_SHOW_ON_ONE_PAGE, survey.isShowOnePage()); + sessionMap.put(SurveyConstants.ATTR_SHOW_OTHER_USERS_ANSWERS, survey.isShowOtherUsersAnswers()); sessionMap.put(SurveyConstants.ATTR_USER_FINISHED, surveyUser.isSessionFinished()); + sessionMap.put(SurveyConstants.ATTR_USER_ID, surveyUser.getUserId()); sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); sessionMap.put(AttributeNames.ATTR_MODE, mode); @@ -262,7 +273,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 +315,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 +350,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,14 +361,84 @@ 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); + + Long excludeUserId = (Long) sessionMap.get(SurveyConstants.ATTR_USER_ID); + SortedMap surveyItemMap = getQuestionList(sessionMap); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + List answerDtos = new ArrayList(); + for (SurveyQuestion question : surveyItemMap.values()) { + AnswerDTO answerDto = service.getQuestionResponse(sessionId, question.getUid(), excludeUserId); + answerDtos.add(answerDto); + } + request.setAttribute("answerDtos", answerDtos); + + 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"); + Long excludeUserId = WebUtil.readLongParam(request, "userId"); + + //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, excludeUserId, page, size, + sorting); + + JSONArray rows = new JSONArray(); + + JSONObject responcedata = new JSONObject(); + responcedata.put("total_rows", service.getCountResponsesBySessionAndQuestion(sessionId, questionUid, excludeUserId)); + + 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); @@ -364,13 +448,13 @@ 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) { + 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 +466,9 @@ List answerList = new ArrayList(); for (AnswerDTO question : surveyItemList) { if (question.getAnswer() != null) { - if (userID != null && userID != 0) + if ((userID != null) && (userID != 0)) { question.getAnswer().setUser(surveyLearner); + } answerList.add(question.getAnswer()); } } @@ -399,7 +484,7 @@ } service.notifyTeachersOnAnswerSumbit(sessionId, surveyLearner); } - + return mapping.findForward(SurveyConstants.SUCCESS); } @@ -417,7 +502,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 +550,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 +577,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 +611,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 +634,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 +652,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 +702,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 =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r1ee653aae7ac1b2ae1e30254a8e6bd2dcdf95bad -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision 1ee653aae7ac1b2ae1e30254a8e6bd2dcdf95bad) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r8b97231e320c0c5b674f07c14da711f232ba9e1c -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java (.../SurveyForm.java) (revision 8b97231e320c0c5b674f07c14da711f232ba9e1c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/form/SurveyForm.java (.../SurveyForm.java) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r1221ef505c31384495e181ad07f2d7992c5d18be -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/common/header.jsp (.../header.jsp) (revision 1221ef505c31384495e181ad07f2d7992c5d18be) +++ lams_tool_survey/web/common/header.jsp (.../header.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -8,7 +8,6 @@ - Index: lams_tool_survey/web/pages/authoring/addCondition.jsp =================================================================== diff -u -rc2ba0dc3e2d99441897de8d185e83c419a416f2d -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision c2ba0dc3e2d99441897de8d185e83c419a416f2d) +++ lams_tool_survey/web/pages/authoring/addCondition.jsp (.../addCondition.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -5,6 +5,7 @@ <%@ include file="/common/header.jsp"%> + - - + + @@ -60,16 +56,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 =================================================================== diff -u -r40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/learning/notebook.jsp (.../notebook.jsp) (revision 40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf) +++ lams_tool_survey/web/pages/learning/notebook.jsp (.../notebook.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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/result.jsp =================================================================== diff -u -r61d957b69e2230effe4ab96242233c281e0bba44 -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/learning/result.jsp (.../result.jsp) (revision 61d957b69e2230effe4ab96242233c281e0bba44) +++ lams_tool_survey/web/pages/learning/result.jsp (.../result.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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,16 @@

-
- - - - - - - - -
+
+ + + + + + + + +
@@ -65,10 +65,10 @@ - - + + + +

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

@@ -123,8 +122,7 @@

- - +

@@ -134,8 +132,7 @@
- +
@@ -145,13 +142,20 @@
- + + + + + + + + - + + @@ -160,14 +164,16 @@ + - + +
Index: lams_tool_survey/web/pages/learning/resultOtherUsers.jsp =================================================================== diff -u --- lams_tool_survey/web/pages/learning/resultOtherUsers.jsp (revision 0) +++ lams_tool_survey/web/pages/learning/resultOtherUsers.jsp (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -0,0 +1,367 @@ + + +<%@ include file="/common/taglibs.jsp"%> + + + + + + <fmt:message key="label.learning.title" /> + <%@ include file="/common/header.jsp"%> + + + + + + + + + + + + + + + + +
+

+ +

+

+ +

+ + +
+ + + + + + + + +
+
+ + <%-- user personal results--%> + +
+ + + + * + + + + +

+ + + + + +

+ + + + + + + + + + + + + +
+ + +

+ + + + + + + + +
+
+ + + + + + + + +
+

+ + + + + + +

+ +

+
+ +

+ +

+
+
+ + + + +
+
+ + <%-- other users personal results--%> + +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + <%-- Only show pie/bar chart when question is single/multiple choics type --%> + +
+ +
+
+
+ + + ${option.response} + + + + ${optStatus.index % 5 + 1} + + + ${option.responseCount} (${option.responseFormatStr}%) +
+ + + ${question.openResponseFormatStr} + + + + ${(optSize % 5) + 1} + + + ${question.openResponseCount} (${question.openResponseFormatStr}%) +
+ + + + + + + + + +
+ +
+ + +
+
+ + + + + + +
+
+
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + +
+ + Index: lams_tool_survey/web/pages/learning/submissionDeadline.jsp =================================================================== diff -u -r77bcef245dda8b166cdf40c12c62a7a5ab8d6fde -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision 77bcef245dda8b166cdf40c12c62a7a5ab8d6fde) +++ lams_tool_survey/web/pages/learning/submissionDeadline.jsp (.../submissionDeadline.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -8,17 +8,14 @@ <%@ include file="/common/header.jsp"%> Index: lams_tool_survey/web/pages/monitoring/advanceoptions.jsp =================================================================== diff -u --- lams_tool_survey/web/pages/monitoring/advanceoptions.jsp (revision 0) +++ lams_tool_survey/web/pages/monitoring/advanceoptions.jsp (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -0,0 +1,111 @@ +

+ + + + + +

+
+ + \ No newline at end of file Index: lams_tool_survey/web/pages/monitoring/listanswers.jsp =================================================================== diff -u -r40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/monitoring/listanswers.jsp (.../listanswers.jsp) (revision 40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf) +++ lams_tool_survey/web/pages/monitoring/listanswers.jsp (.../listanswers.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -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 =================================================================== diff -u -r40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/monitoring/notebook.jsp (.../notebook.jsp) (revision 40c565b9307a4b3fcc2f724b1baf104c6c8a2dcf) +++ lams_tool_survey/web/pages/monitoring/notebook.jsp (.../notebook.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -1,6 +1,6 @@ -<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/taglibs.jsp"%> Index: lams_tool_survey/web/pages/monitoring/summary.jsp =================================================================== diff -u -r77bcef245dda8b166cdf40c12c62a7a5ab8d6fde -rc9845f2002ce96c641bb4334b237ef4744cd83c4 --- lams_tool_survey/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 77bcef245dda8b166cdf40c12c62a7a5ab8d6fde) +++ lams_tool_survey/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision c9845f2002ce96c641bb4334b237ef4744cd83c4) @@ -214,98 +214,7 @@
-

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

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