Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java,v diff -u -r1.25 -r1.26 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java 26 Sep 2006 02:26:48 -0000 1.25 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java 18 Feb 2009 23:06:58 -0000 1.26 @@ -44,12 +44,8 @@ public List getUserRecords(final String userEntry); - public List getContentEntries(final Long voteContentUid); - public Set getUserEntries(); - public int getAllEntriesCount(); - public int getUserEnteredVotesCountForContent(final Long voteContentUid); public boolean isVoteVisibleForSession(final String userEntry, final Long voteSessionUid); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java,v diff -u -r1.6 -r1.7 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java 9 Dec 2008 05:38:13 -0000 1.6 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteContentDAO.java 18 Feb 2009 23:06:58 -0000 1.7 @@ -40,7 +40,8 @@ /** * @author Ozgur Demirtas *
- * Hibernate implementation for database access to VoteContent for the voting tool. + * Hibernate implementation for database access to VoteContent for the + * voting tool. *
*/ Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java,v diff -u -r1.7 -r1.8 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java 26 Sep 2006 02:26:51 -0000 1.7 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteQueContentDAO.java 18 Feb 2009 23:06:58 -0000 1.8 @@ -31,217 +31,175 @@ import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; - /** * @author Ozgur Demirtas * - *Hibernate implementation for database access to VoteQueContent for the vote tool.
+ *+ * Hibernate implementation for database access to VoteQueContent for the vote + * tool. + *
*/ public class VoteQueContentDAO extends HibernateDaoSupport implements IVoteQueContentDAO { - static Logger logger = Logger.getLogger(VoteQueContentDAO.class.getName()); - - private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; - - private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; - - private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from voteQueContent in class VoteQueContent where voteQueContent.question=:question and voteQueContent.voteContentId=:voteContentUid"; - - private static final String LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.displayOrder=:displayOrder and voteQueContent.voteContentId=:voteContentUid"; - - private static final String SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId order by voteQueContent.displayOrder"; - - - public VoteQueContent getVoteQueContentByUID(Long uid) - { - return (VoteQueContent) this.getHibernateTemplate() - .get(VoteQueContent.class, uid); - } - - - public VoteQueContent getToolDefaultQuestionContent(final long voteContentId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) - .setLong("voteContentId", voteContentId) - .list(); - - if(list != null && list.size() > 0){ - VoteQueContent voteq = (VoteQueContent) list.get(0); - return voteq; - } - return null; - } - - - public List getVoteQueContentsByContentId(long voteContentId){ - return getHibernateTemplate().findByNamedParam(LOAD_QUESTION_CONTENT_BY_CONTENT_ID, "voteContentId", new Long(voteContentId)); - } - - public List getAllQuestionEntries(final long voteContentId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) - .setLong("voteContentId", voteContentId) - .list(); + static Logger logger = Logger.getLogger(VoteQueContentDAO.class.getName()); - return list; - } - - - public VoteQueContent getQuestionContentByQuestionText(final String question, final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT) - .setString("question", question) - .setLong("voteContentUid", voteContentUid.longValue()) - .list(); - - if(list != null && list.size() > 0){ - VoteQueContent voteq = (VoteQueContent) list.get(0); - return voteq; - } - return null; - } - - - public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER) - .setLong("displayOrder", displayOrder.longValue()) - .setLong("voteContentUid", voteContentUid.longValue()) - .list(); - - if(list != null && list.size() > 0){ - VoteQueContent voteq = (VoteQueContent) list.get(0); - return voteq; - } - return null; - } + private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; - - public void removeQuestionContentByVoteUid(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) - .setLong("voteContentId", voteContentUid.longValue()) - .list(); + private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId"; - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent)listIterator.next(); - this.getSession().setFlushMode(FlushMode.AUTO); - templ.delete(voteQueContent); - templ.flush(); - } - } - } - + private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from voteQueContent in class VoteQueContent where voteQueContent.question=:question and voteQueContent.voteContentId=:voteContentUid"; - public void resetAllQuestions(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) - .setLong("voteContentId", voteContentUid.longValue()) - .list(); + private static final String LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.displayOrder=:displayOrder and voteQueContent.voteContentId=:voteContentUid"; - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent)listIterator.next(); - this.getSession().setFlushMode(FlushMode.AUTO); - templ.update(voteQueContent); - } - } - } - + private static final String SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER = "from voteQueContent in class VoteQueContent where voteQueContent.voteContentId=:voteContentId order by voteQueContent.displayOrder"; - public void cleanAllQuestions(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID) - .setLong("voteContentId", voteContentUid.longValue()) - .list(); + public VoteQueContent getVoteQueContentByUID(Long uid) { + return (VoteQueContent) this.getHibernateTemplate().get(VoteQueContent.class, uid); + } - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent)listIterator.next(); - this.getSession().setFlushMode(FlushMode.AUTO); - logger.debug("deleting voteQueContent: " + voteQueContent); - templ.delete(voteQueContent); - } - } + public VoteQueContent getToolDefaultQuestionContent(final long voteContentId) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", + voteContentId).list(); + + if (list != null && list.size() > 0) { + VoteQueContent voteq = (VoteQueContent) list.get(0); + return voteq; + } + return null; + } + + public List getVoteQueContentsByContentId(long voteContentId) { + return getHibernateTemplate().findByNamedParam(LOAD_QUESTION_CONTENT_BY_CONTENT_ID, "voteContentId", + new Long(voteContentId)); + } + + public List getAllQuestionEntries(final long voteContentId) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", + voteContentId).list(); + + return list; + } + + public VoteQueContent getQuestionContentByQuestionText(final String question, final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT).setString("question", question) + .setLong("voteContentUid", voteContentUid.longValue()).list(); + + if (list != null && list.size() > 0) { + VoteQueContent voteq = (VoteQueContent) list.get(0); + return voteq; + } + return null; + } + + public VoteQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_DISPLAY_ORDER).setLong("displayOrder", + displayOrder.longValue()).setLong("voteContentUid", voteContentUid.longValue()).list(); + + if (list != null && list.size() > 0) { + VoteQueContent voteq = (VoteQueContent) list.get(0); + return voteq; + } + return null; + } + + public void removeQuestionContentByVoteUid(final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", + voteContentUid.longValue()).list(); + + if (list != null && list.size() > 0) { + Iterator listIterator = list.iterator(); + while (listIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + templ.delete(voteQueContent); + templ.flush(); } + } + } - - public void cleanAllQuestionsSimple(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE) - .setLong("voteContentId", voteContentUid.longValue()) - .list(); + public void resetAllQuestions(final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", + voteContentUid.longValue()).list(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent)listIterator.next(); - this.getSession().setFlushMode(FlushMode.AUTO); - logger.debug("deleting voteQueContent: " + voteQueContent); - templ.delete(voteQueContent); - } - } + if (list != null && list.size() > 0) { + Iterator listIterator = list.iterator(); + while (listIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + templ.update(voteQueContent); } + } + } - - public List getAllQuestionEntriesSorted(final long voteContentId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER) - .setLong("voteContentId", voteContentId) - .list(); + public void cleanAllQuestions(final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID).setLong("voteContentId", + voteContentUid.longValue()).list(); - return list; + if (list != null && list.size() > 0) { + Iterator listIterator = list.iterator(); + while (listIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + logger.debug("deleting voteQueContent: " + voteQueContent); + templ.delete(voteQueContent); } + } + } + public void cleanAllQuestionsSimple(final Long voteContentUid) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE).setLong("voteContentId", + voteContentUid.longValue()).list(); - - public void saveVoteQueContent(VoteQueContent voteQueContent) - { - this.getHibernateTemplate().save(voteQueContent); + if (list != null && list.size() > 0) { + Iterator listIterator = list.iterator(); + while (listIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) listIterator.next(); + this.getSession().setFlushMode(FlushMode.AUTO); + logger.debug("deleting voteQueContent: " + voteQueContent); + templ.delete(voteQueContent); } - - public void updateVoteQueContent(VoteQueContent voteQueContent) - { - this.getHibernateTemplate().update(voteQueContent); - } - - public void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent) - { - this.getHibernateTemplate().saveOrUpdate(voteQueContent); - } - - public void removeVoteQueContentByUID(Long uid) - { - VoteQueContent voteq = (VoteQueContent)getHibernateTemplate().get(VoteQueContent.class, uid); - this.getSession().setFlushMode(FlushMode.AUTO); - this.getHibernateTemplate().delete(voteq); - } - - - public void removeVoteQueContent(VoteQueContent voteQueContent) - { - this.getSession().setFlushMode(FlushMode.AUTO); - this.getHibernateTemplate().delete(voteQueContent); - } - - public void flush() - { - this.getHibernateTemplate().flush(); - } - } \ No newline at end of file + } + } + + public List getAllQuestionEntriesSorted(final long voteContentId) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(SORT_QUESTION_CONTENT_BY_DISPLAY_ORDER).setLong("voteContentId", + voteContentId).list(); + + return list; + } + + public void saveVoteQueContent(VoteQueContent voteQueContent) { + this.getHibernateTemplate().save(voteQueContent); + } + + public void updateVoteQueContent(VoteQueContent voteQueContent) { + this.getHibernateTemplate().update(voteQueContent); + } + + public void saveOrUpdateVoteQueContent(VoteQueContent voteQueContent) { + this.getHibernateTemplate().saveOrUpdate(voteQueContent); + } + + public void removeVoteQueContentByUID(Long uid) { + VoteQueContent voteq = (VoteQueContent) getHibernateTemplate().get(VoteQueContent.class, uid); + this.getSession().setFlushMode(FlushMode.AUTO); + this.getHibernateTemplate().delete(voteq); + } + + public void removeVoteQueContent(VoteQueContent voteQueContent) { + this.getSession().setFlushMode(FlushMode.AUTO); + this.getHibernateTemplate().delete(voteQueContent); + } + + public void flush() { + this.getHibernateTemplate().flush(); + } +} \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java,v diff -u -r1.31 -r1.32 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java 26 Sep 2006 02:26:51 -0000 1.31 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java 18 Feb 2009 23:06:58 -0000 1.32 @@ -39,671 +39,455 @@ import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** - * @author Ozgur Demirtas - *Hibernate implementation for database access to VoteUsrAttemptDAO for the voting tool.
+ * @author Ozgur Demirtas repaired by lfoxton + *+ * Hibernate implementation for database access to VoteUsrAttemptDAO for + * the voting tool. + *
*/ public class VoteUsrAttemptDAO extends HibernateDaoSupport implements IVoteUsrAttemptDAO { - static Logger logger = Logger.getLogger(VoteUsrAttemptDAO.class.getName()); - - private IVoteUserDAO voteUserDAO; - - private static final String LOAD_ATTEMPT_FOR_QUE_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - private static final String LOAD_ATTEMPT_FOR_USER = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; + static Logger logger = Logger.getLogger(VoteUsrAttemptDAO.class.getName()); - private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - private static final String LOAD_ATTEMPT_FOR_USER_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; - - private static final String LOAD_USER_ENTRIES = "select distinct voteUsrAttempt.userEntry from VoteUsrAttempt voteUsrAttempt"; - - private static final String LOAD_USER_ENTRY_RECORDS = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.userEntry=:userEntry and voteUsrAttempt.voteQueContentId=1 "; - - private static final String LOAD_DISTINCT_USER_ENTRY_RECORDS = "select distinct voteUsrAttempt.queUsrId from VoteUsrAttempt voteUsrAttempt where voteUsrAttempt.userEntry=:userEntry"; - - private static final String LOAD_ALL_ENTRIES = "from voteUsrAttempt in class VoteUsrAttempt"; - - private static final String LOAD_DISTINCT_USER_ENTRIES = "select distinct voteUsrAttempt.queUsrId from VoteUsrAttempt voteUsrAttempt"; - - - public VoteUsrAttempt getVoteUserAttemptByUID(Long uid) - { - return (VoteUsrAttempt) this.getHibernateTemplate() - .get(VoteUsrAttempt.class, uid); - } - - - public VoteUsrAttempt getAttemptByUID(Long uid) - { - String query = "from VoteUsrAttempt attempt where attempt.uid=?"; - - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(query) - .setLong(0,uid.longValue()) - .list(); - - if(list != null && list.size() > 0){ - VoteUsrAttempt attempt = (VoteUsrAttempt) list.get(0); - return attempt; - } - return null; - } + private IVoteUserDAO voteUserDAO; - - - public void saveVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) - { - this.getHibernateTemplate().save(voteUsrAttempt); - } - - - public List getAttemptsForUser(final Long queUsrId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER) - .setLong("queUsrId", queUsrId.longValue()) - .list(); - return list; - } + private static final String LOAD_ATTEMPT_FOR_QUE_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - public List getContentEntries(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ALL_ENTRIES) - .list(); + private static final String LOAD_ATTEMPT_FOR_USER = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; - List contentEntries= new ArrayList(); - Iterator listIterator=list.iterator(); - logger.debug("looking for voteContentUid: " + voteContentUid); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - if (attempt.getVoteQueUsr().getVoteSession().getVoteContent().getUid().toString().equals(voteContentUid.toString())) - { - logger.debug("found content: " + voteContentUid); - if (attempt.getVoteQueContentId().toString().equals("1")) - { - logger.debug("user entered nomination: " + attempt.getUserEntry()); - if ((attempt.getUserEntry() != null) && (attempt.getUserEntry().length() > 0)) - contentEntries.add(attempt.getUserEntry()); - } - else - { - logger.debug("standard content nomination: " + attempt.getVoteQueContent().getQuestion()); - contentEntries.add(attempt.getVoteQueContent().getQuestion()); - } - } - } - - return contentEntries; - } + private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - public int getUserEnteredVotesCountForContent(final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ALL_ENTRIES) - .list(); + private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - int count=0; - Iterator listIterator=list.iterator(); - logger.debug("looking for voteContentUid: " + voteContentUid); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - - if (attempt.getVoteQueUsr().getVoteSession().getVoteContent().getUid().toString().equals(voteContentUid.toString())) - { - ++count; - } - } - - return count; - } + private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContentId=:voteQueContentId"; - - - public Set getUserEntries() - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_USER_ENTRIES) - .list(); - - Set set= new HashSet(); - - Set userEntries= new HashSet(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - String entry=(String)listIterator.next(); - logger.debug("entry: " + entry); - if ((entry != null) && (entry.length() > 0)) - userEntries.add(entry); - } - } - return userEntries; - } - + private static final String LOAD_ATTEMPT_FOR_USER_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; - public List getSessionUserEntries(final Long voteSessionUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ALL_ENTRIES) - .list(); + private static final String LOAD_USER_ENTRIES = "select distinct voteUsrAttempt.userEntry from VoteUsrAttempt voteUsrAttempt"; - List sessionUserEntries= new ArrayList(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - if ((attempt.getUserEntry() != null) && (attempt.getUserEntry().length() > 0)) - sessionUserEntries.add(attempt.getUserEntry()); - } - } - } - return sessionUserEntries; - } + private static final String LOAD_USER_ENTRY_RECORDS = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.userEntry=:userEntry and voteUsrAttempt.voteQueContentId=1 "; - public Set getSessionUserEntriesSet(final Long voteSessionUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ALL_ENTRIES) - .list(); + private static final String LOAD_DISTINCT_USER_ENTRY_RECORDS = "select distinct voteUsrAttempt.queUsrId from VoteUsrAttempt voteUsrAttempt where voteUsrAttempt.userEntry=:userEntry"; - Set sessionUserEntries= new HashSet(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - if ((attempt.getUserEntry() != null) && (attempt.getUserEntry().length() > 0)) - sessionUserEntries.add(attempt.getUserEntry()); - } - } - } - return sessionUserEntries; - } - - public int getUserRecordsEntryCount(final String userEntry) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_DISTINCT_USER_ENTRY_RECORDS) - .setString("userEntry", userEntry) - .list(); + // lfoxton about below: + // No! Very Bad programmer!!! Go to your room and think about what you did! + //private static final String LOAD_ALL_ENTRIES = "from voteUsrAttempt in class VoteUsrAttempt"; - if(list != null && list.size() > 0){ - return list.size(); - } - - return 0; - } - + private static final String LOAD_DISTINCT_USER_ENTRIES = "select distinct voteUsrAttempt.queUsrId from VoteUsrAttempt voteUsrAttempt"; - public int getSessionUserRecordsEntryCount(final String userEntry, final Long voteSessionUid, IVoteService voteService) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_DISTINCT_USER_ENTRY_RECORDS) - .setString("userEntry", userEntry) - .list(); - - int entryCount=0; + private static final String COUNT_ATTEMPTS_BY_CONTENT_ID = "select count(*) from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + + "att.voteQueUsr=user and user.voteSession=ses and " + "ses.voteContentId=:voteContentId"; + + private static final String LOAD_ENTRIES_BY_SESSION_ID = "select att from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + + "att.voteQueUsr=user and user.voteSession=ses and ses.uid=:voteSessionUid"; + + private static final String COUNT_ENTRIES_BY_SESSION_ID = "select count(*) from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + + "att.voteQueUsr=user and user.voteSession=ses and ses.uid=:voteSessionUid"; - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - Long userId=(Long)listIterator.next(); - logger.debug("userId: " + userId); - logger.debug("voteService: " + voteService); - VoteQueUsr voteQueUsr=voteService.getVoteUserByUID(userId); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr.getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - ++entryCount; - } - } - } - return entryCount; - } - - - public void removeAttemptsForUser(final Long queUsrId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER) - .setLong("queUsrId", queUsrId.longValue()) - .list(); - - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - this.getSession().setFlushMode(FlushMode.AUTO); - templ.delete(attempt); - templ.flush(); - } - } - } + public VoteUsrAttempt getVoteUserAttemptByUID(Long uid) { + return (VoteUsrAttempt) this.getHibernateTemplate().get(VoteUsrAttempt.class, uid); + } - public void removeAttemptsForUserandSession(final Long queUsrId, final Long voteSessionId) - { - String strGetUser = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(strGetUser) - .setLong("queUsrId", queUsrId.longValue()) - .list(); - - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionId.toString())) - { - this.getSession().setFlushMode(FlushMode.AUTO); - templ.delete(attempt); - templ.flush(); - - } - } - } - } + public VoteUsrAttempt getAttemptByUID(Long uid) { + String query = "from VoteUsrAttempt attempt where attempt.uid=?"; + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(query).setLong(0, uid.longValue()).list(); - public int getAttemptsForQuestionContent(final Long voteQueContentId) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT) - .setLong("voteQueContentId", voteQueContentId.longValue()) - .list(); - - if(list != null && list.size() > 0){ - return list.size(); - } - - return 0; - } + if (list != null && list.size() > 0) { + VoteUsrAttempt attempt = (VoteUsrAttempt) list.get(0); + return attempt; + } + return null; + } - - public int getStandardAttemptsForQuestionContentAndSessionUid(final Long voteQueContentId, final Long voteSessionUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT) - .setLong("voteQueContentId", voteQueContentId.longValue()) - .list(); - - List userEntries= new ArrayList(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - userEntries.add(attempt); - } - } - } - return userEntries.size(); + public void saveVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) { + this.getHibernateTemplate().save(voteUsrAttempt); + } - } - - public List getStandardAttemptUsersForQuestionContentAndSessionUid(final Long voteQueContentId, final Long voteSessionUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT) - .setLong("voteQueContentId", voteQueContentId.longValue()) - .list(); - - List userEntries= new ArrayList(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - userEntries.add(attempt); - } - } - } - return userEntries; + public List getAttemptsForUser(final Long queUsrId) { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_ATTEMPT_FOR_USER).setLong("queUsrId", queUsrId.longValue()).list(); + return list; + } + public int getUserEnteredVotesCountForContent(final Long voteContentUid) { + List result = getSession().createQuery(COUNT_ATTEMPTS_BY_CONTENT_ID).setLong("voteContentId", voteContentUid) + .list(); + Integer resultInt = (result.get(0) != null) ? (Integer) result.get(0) : new Integer(0); + return resultInt.intValue(); + } + + public Set getUserEntries() { + HibernateTemplate templ = this.getHibernateTemplate(); + List list = getSession().createQuery(LOAD_USER_ENTRIES).list(); + + Set set = new HashSet(); + + Set userEntries = new HashSet(); + if (list != null && list.size() > 0) { + Iterator listIterator = list.iterator(); + while (listIterator.hasNext()) { + String entry = (String) listIterator.next(); + logger.debug("entry: " + entry); + if ((entry != null) && (entry.length() > 0)) + userEntries.add(entry); } + } + return userEntries; + } - - - public boolean isVoteVisibleForSession(final String userEntry, final Long voteSessionUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_USER_ENTRY_RECORDS) - .setString("userEntry", userEntry) - .list(); - - - List sessionUserEntries= new ArrayList(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - logger.debug("attempt: " + attempt); - if (attempt.getVoteQueUsr().getVoteSession().getUid().toString().equals(voteSessionUid.toString())) - { - boolean isVoteVisible= attempt.isVisible(); - logger.debug("isVoteVisible: " + isVoteVisible); - if (isVoteVisible == false) - return false; - } - } - } - - return true; - } + public List getSessionUserEntries(final Long voteSessionUid) { + + return getSession().createQuery(LOAD_ENTRIES_BY_SESSION_ID).setLong("voteSessionUid", voteSessionUid).list(); + } - public int getStandardAttemptsForQuestionContentAndContentUid(final Long voteQueContentId, final Long voteContentUid) - { - HibernateTemplate templ = this.getHibernateTemplate(); - List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT) - .setLong("voteQueContentId", voteQueContentId.longValue()) - .list(); - - List userEntries= new ArrayList(); - if(list != null && list.size() > 0){ - Iterator listIterator=list.iterator(); - while (listIterator.hasNext()) - { - VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next(); - - if (attempt.getVoteQueUsr().getVoteSession().getVoteContent().getUid().toString().equals(voteContentUid.toString())) - { - userEntries.add(attempt); - } - } - } - return userEntries.size(); + public Set getSessionUserEntriesSet(final Long voteSessionUid) { + ListMore generic monitoring mode functions live here
- * + *+ * More generic monitoring mode functions live here + *
+ * * @author Ozgur Demirtas - * + * */ -public class MonitoringUtil implements VoteAppConstants{ - static Logger logger = Logger.getLogger(MonitoringUtil.class.getName()); - - public static Map populateToolSessions(HttpServletRequest request, VoteContent voteContent, IVoteService voteService) - { - List sessionsList=voteService.getSessionNamesFromContent(voteContent); - logger.debug("sessionsList size is:..." + sessionsList.size()); - - Map sessionsMap=VoteUtils.convertToStringMap(sessionsList, "String"); - logger.debug("generated sessionsMap:..." + sessionsMap); - logger.debug("sessionsMap size:..." + sessionsMap.size()); - - if (sessionsMap.isEmpty()) - { - logger.debug("sessionsMap size is 0:"); - sessionsMap.put(new Long(1).toString() , "None"); - } - else - { - logger.debug("sessionsMap has some entries: " + sessionsMap.size()); - sessionsMap.put(new Long(sessionsMap.size()+ 1).toString() , "All"); - } - - logger.debug("final sessionsMap:" + sessionsMap); - return sessionsMap; +public class MonitoringUtil implements VoteAppConstants { + static Logger logger = Logger.getLogger(MonitoringUtil.class.getName()); + + public static Map populateToolSessions(HttpServletRequest request, VoteContent voteContent, IVoteService voteService) { + List sessionsList = voteService.getSessionNamesFromContent(voteContent); + logger.debug("sessionsList size is:..." + sessionsList.size()); + + Map sessionsMap = VoteUtils.convertToStringMap(sessionsList, "String"); + logger.debug("generated sessionsMap:..." + sessionsMap); + logger.debug("sessionsMap size:..." + sessionsMap.size()); + + if (sessionsMap.isEmpty()) { + logger.debug("sessionsMap size is 0:"); + sessionsMap.put(new Long(1).toString(), "None"); + } else { + logger.debug("sessionsMap has some entries: " + sessionsMap.size()); + sessionsMap.put(new Long(sessionsMap.size() + 1).toString(), "All"); } - /** - * - * used in presenting user votes data - * - * @param request - * @param voteContent - * @param isUserNamesVisible - * @param isLearnerRequest - * @param currentSessionId - * @param userId - * @param voteService - * @return - */ - public static List buildGroupsQuestionData(HttpServletRequest request, VoteContent voteContent, - boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, - IVoteService voteService) - { - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - logger.debug("userId: " + userId); - - logger.debug("voteService: " + voteService); - - logger.debug("will be building groups question data for content:..." + voteContent); - List listQuestions=voteService.getAllQuestionEntries(voteContent.getUid()); - logger.debug("listQuestions:..." + listQuestions); - - List listMonitoredAnswersContainerDTO= new LinkedList(); - - Iterator itListQuestions = listQuestions.iterator(); - while (itListQuestions.hasNext()) - { - VoteQueContent voteQueContent =(VoteQueContent)itListQuestions.next(); - logger.debug("voteQueContent:..." + voteQueContent); - - if (voteQueContent != null) - { - VoteMonitoredAnswersDTO voteMonitoredAnswersDTO= new VoteMonitoredAnswersDTO(); - voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString()); - voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion()); - - logger.debug("using allUsersData to retrieve users data: " + isUserNamesVisible); - Map questionAttemptData= buildGroupsAttemptData(request, voteContent, voteQueContent, voteQueContent.getUid().toString(), - isUserNamesVisible,isLearnerRequest, currentSessionId, userId, voteService); - logger.debug("questionAttemptData:..." + questionAttemptData); - voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); - listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); - - } - } - logger.debug("final listMonitoredAnswersContainerDTO:..." + listMonitoredAnswersContainerDTO); - return listMonitoredAnswersContainerDTO; + logger.debug("final sessionsMap:" + sessionsMap); + return sessionsMap; + } + + /** + * + * used in presenting user votes data + * + * @param request + * @param voteContent + * @param isUserNamesVisible + * @param isLearnerRequest + * @param currentSessionId + * @param userId + * @param voteService + * @return + */ + public static List buildGroupsQuestionData(HttpServletRequest request, VoteContent voteContent, + boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, + IVoteService voteService) { + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("userId: " + userId); + + logger.debug("voteService: " + voteService); + + logger.debug("will be building groups question data for content:..." + voteContent); + List listQuestions = voteService.getAllQuestionEntries(voteContent.getUid()); + logger.debug("listQuestions:..." + listQuestions); + + List listMonitoredAnswersContainerDTO = new LinkedList(); + + Iterator itListQuestions = listQuestions.iterator(); + while (itListQuestions.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) itListQuestions.next(); + logger.debug("voteQueContent:..." + voteQueContent); + + if (voteQueContent != null) { + VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO(); + voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString()); + voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion()); + + logger.debug("using allUsersData to retrieve users data: " + isUserNamesVisible); + Map questionAttemptData = buildGroupsAttemptData(request, voteContent, voteQueContent, voteQueContent + .getUid().toString(), isUserNamesVisible, isLearnerRequest, currentSessionId, userId, + voteService); + logger.debug("questionAttemptData:..." + questionAttemptData); + voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); + listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); + + } } - + logger.debug("final listMonitoredAnswersContainerDTO:..." + listMonitoredAnswersContainerDTO); + return listMonitoredAnswersContainerDTO; + } - /** - * groups user's votes - * - * @param request - * @param voteContent - * @param voteQueContent - * @param questionUid - * @param isUserNamesVisible - * @param isLearnerRequest - * @param currentSessionId - * @param userId - * @param voteService - * @return - */ - public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, VoteQueContent voteQueContent, String questionUid, - boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId, IVoteService voteService) - { - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - logger.debug("currentSessionId: " + currentSessionId); - logger.debug("userId: " + userId); - - logger.debug("doing buildGroupsAttemptData..."); - logger.debug("voteService: " + voteService); + /** + * groups user's votes + * + * @param request + * @param voteContent + * @param voteQueContent + * @param questionUid + * @param isUserNamesVisible + * @param isLearnerRequest + * @param currentSessionId + * @param userId + * @param voteService + * @return + */ + public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, + VoteQueContent voteQueContent, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, + String currentSessionId, String userId, IVoteService voteService) { + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("currentSessionId: " + currentSessionId); + logger.debug("userId: " + userId); - Map mapMonitoredAttemptsContainerDTO= new TreeMap(new VoteComparator()); - List listMonitoredAttemptsContainerDTO= new LinkedList(); - - Map summaryToolSessions=populateToolSessionsId(request, voteContent, voteService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - - Iterator itMap = summaryToolSessions.entrySet().iterator(); - - - /*request is for monitoring summary */ - if (!isLearnerRequest) - { - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) - { - logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); - VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString())); - logger.debug("voteSession: " + " = " + voteSession); - if (voteSession != null) - { - List listUsers=voteService.getUserBySessionOnly(voteSession); - logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request,voteContent, voteSession.getVoteSessionId(), listUsers, questionUid, - isUserNamesVisible, isLearnerRequest, userId, voteService); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - } - else - { - /*request is for learner report, use only the passed tool session in the report*/ - logger.debug("using currentSessionId for the learner report:" + currentSessionId); - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) - { - logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); - - if (currentSessionId.equals(pairs.getValue())) - { - logger.debug("only using this tool session for the learner report: " + " = " + pairs.getValue()); - VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString())); - logger.debug("voteSession: " + " = " + voteSession); - if (voteSession != null) - { - List listUsers=voteService.getUserBySessionOnly(voteSession); - logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request,voteContent, voteSession.getVoteSessionId(), listUsers, questionUid, - isUserNamesVisible, isLearnerRequest, userId, voteService); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - } - } + logger.debug("doing buildGroupsAttemptData..."); + logger.debug("voteService: " + voteService); - logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); - mapMonitoredAttemptsContainerDTO=convertToMap(listMonitoredAttemptsContainerDTO); - logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO); - return mapMonitoredAttemptsContainerDTO; + Map mapMonitoredAttemptsContainerDTO = new TreeMap(new VoteComparator()); + List listMonitoredAttemptsContainerDTO = new LinkedList(); + + Map summaryToolSessions = populateToolSessionsId(request, voteContent, voteService); + logger.debug("summaryToolSessions: " + summaryToolSessions); + + Iterator itMap = summaryToolSessions.entrySet().iterator(); + + /*request is for monitoring summary */ + if (!isLearnerRequest) { + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) { + logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); + VoteSession voteSession = voteService.retrieveVoteSession(new Long(pairs.getValue().toString())); + logger.debug("voteSession: " + " = " + voteSession); + if (voteSession != null) { + List listUsers = voteService.getUserBySessionOnly(voteSession); + logger + .debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + + listUsers); + Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteContent, voteSession + .getVoteSessionId(), listUsers, questionUid, isUserNamesVisible, isLearnerRequest, + userId, voteService); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } else { + /*request is for learner report, use only the passed tool session in the report*/ + logger.debug("using currentSessionId for the learner report:" + currentSessionId); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) { + logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); + + if (currentSessionId.equals(pairs.getValue())) { + logger + .debug("only using this tool session for the learner report: " + " = " + + pairs.getValue()); + VoteSession voteSession = voteService + .retrieveVoteSession(new Long(pairs.getValue().toString())); + logger.debug("voteSession: " + " = " + voteSession); + if (voteSession != null) { + List listUsers = voteService.getUserBySessionOnly(voteSession); + logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + + listUsers); + Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteContent, voteSession + .getVoteSessionId(), listUsers, questionUid, isUserNamesVisible, isLearnerRequest, + userId, voteService); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } } - - - public static Map populateSessionUsersAttempts(HttpServletRequest request, VoteContent voteContent, Long sessionId, List listUsers, - String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String userId, IVoteService voteService) - { - logger.debug("doing populateSessionUsersAttempts for: " +questionUid); - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - logger.debug("voteContent: " + voteContent); - logger.debug("userId: " + userId); - - logger.debug("doing populateSessionUsersAttempts..."); - logger.debug("voteService: " + voteService); - - Map mapMonitoredUserContainerDTO= new TreeMap(new VoteStringComparator()); - List listMonitoredUserContainerDTO= new LinkedList(); - Iterator itUsers=listUsers.iterator(); - - - if (userId == null) - { - logger.debug("request is not for learner progress report"); - if ((isUserNamesVisible) && (!isLearnerRequest)) - { - logger.debug("summary reporting case 1" ); - logger.debug("isUserNamesVisible true, isLearnerRequest false" ); - logger.debug("getting alll the user' data"); - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); - - logger.debug("attempt: " + voteUsrResp); - voteMonitoredUserDTO.setQuestionUid(questionUid); - - VoteQueContent voteQueContent=voteUsrResp.getVoteQueContent(); - logger.debug("voteQueContent: " + voteQueContent); - String entry=voteQueContent.getQuestion(); - logger.debug("entry: " + entry); - String voteQueContentId=voteUsrResp.getVoteQueContentId().toString(); - logger.debug("voteQueContentId: " + voteQueContentId); - - VoteSession localUserSession=voteUsrResp.getVoteQueUsr().getVoteSession(); - logger.debug("localUserSession: " + localUserSession); - logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); - logger.debug("incoming content id versus localUserSession's content id: " + voteContent.getVoteContentId() + " versus " + localUserSession.getVoteContentId()); - logger.debug("summary reporting case 1" ); - if (voteContent.getVoteContentId().toString().equals(localUserSession.getVoteContentId().toString())) - { - if (entry != null) - { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) - { - logger.debug("this nomination entry points to a user entered nomination: " + voteUsrResp.getUserEntry()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } - else - { - logger.debug("this nomination entry points to a standard nomination: " + voteQueContent.getQuestion()); - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } - - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } + logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); + mapMonitoredAttemptsContainerDTO = convertToMap(listMonitoredAttemptsContainerDTO); + logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO); + return mapMonitoredAttemptsContainerDTO; + } + + public static Map populateSessionUsersAttempts(HttpServletRequest request, VoteContent voteContent, Long sessionId, + List listUsers, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String userId, + IVoteService voteService) { + logger.debug("doing populateSessionUsersAttempts for: " + questionUid); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("voteContent: " + voteContent); + logger.debug("userId: " + userId); + + logger.debug("doing populateSessionUsersAttempts..."); + logger.debug("voteService: " + voteService); + + Map mapMonitoredUserContainerDTO = new TreeMap(new VoteStringComparator()); + List listMonitoredUserContainerDTO = new LinkedList(); + Iterator itUsers = listUsers.iterator(); + + if (userId == null) { + logger.debug("request is not for learner progress report"); + if ((isUserNamesVisible) && (!isLearnerRequest)) { + logger.debug("summary reporting case 1"); + logger.debug("isUserNamesVisible true, isLearnerRequest false"); + logger.debug("getting alll the user' data"); + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); + + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr + .getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); + + logger.debug("attempt: " + voteUsrResp); + voteMonitoredUserDTO.setQuestionUid(questionUid); + + VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); + logger.debug("voteQueContent: " + voteQueContent); + String entry = voteQueContent.getQuestion(); + logger.debug("entry: " + entry); + + String voteQueContentId = voteUsrResp.getVoteQueContentId().toString(); + logger.debug("voteQueContentId: " + voteQueContentId); + + VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); + logger.debug("localUserSession: " + localUserSession); + logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); + logger.debug("incoming content id versus localUserSession's content id: " + + voteContent.getVoteContentId() + " versus " + + localUserSession.getVoteContentId()); + logger.debug("summary reporting case 1"); + if (voteContent.getVoteContentId().toString().equals( + localUserSession.getVoteContentId().toString())) { + if (entry != null) { + if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) { + logger.debug("this nomination entry points to a user entered nomination: " + + voteUsrResp.getUserEntry()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + } else { + logger.debug("this nomination entry points to a standard nomination: " + + voteQueContent.getQuestion()); + voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); + } + } } + + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } } - else if ((isUserNamesVisible) && (isLearnerRequest)) - { - logger.debug("summary reporting case 2" ); - logger.debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session" ); - logger.debug("isUserNamesVisible true, isLearnerRequest true" ); - String userID= (String)request.getSession().getAttribute(USER_ID); - logger.debug("userID: " + userID); - VoteQueUsr voteQueUsr=voteService.getVoteQueUsrById(new Long(userID).longValue()); - logger.debug("the current user voteQueUsr " + voteQueUsr + " and username: " + voteQueUsr.getUsername()); - - while (itUsers.hasNext()) - { - voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); - logger.debug("attempt: " + voteUsrResp); - voteMonitoredUserDTO.setQuestionUid(questionUid); - - VoteQueContent voteQueContent=voteUsrResp.getVoteQueContent(); - logger.debug("voteQueContent: " + voteQueContent); - String entry=voteQueContent.getQuestion(); - logger.debug("entry: " + entry); - String voteQueContentId=voteUsrResp.getVoteQueContentId().toString(); - logger.debug("voteQueContentId: " + voteQueContentId); + } + } + } else if ((isUserNamesVisible) && (isLearnerRequest)) { + logger.debug("summary reporting case 2"); + logger + .debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session"); + logger.debug("isUserNamesVisible true, isLearnerRequest true"); + String userID = (String) request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); + VoteQueUsr voteQueUsr = voteService.getVoteQueUsrById(new Long(userID).longValue()); + logger + .debug("the current user voteQueUsr " + voteQueUsr + " and username: " + + voteQueUsr.getUsername()); - VoteSession localUserSession=voteUsrResp.getVoteQueUsr().getVoteSession(); - logger.debug("localUserSession: " + localUserSession); - logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); - logger.debug("incoming content id versus localUserSession's content id: " + voteContent.getVoteContentId() + " versus " + localUserSession.getVoteContentId()); - logger.debug("summary reporting case 2" ); - if (voteContent.getVoteContentId().toString().equals(localUserSession.getVoteContentId().toString())) - { - if (entry != null) - { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) - { - logger.debug("this nomination entry points to a user entered nomination: " + voteUsrResp.getUserEntry()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } - else - { - logger.debug("this nomination entry points to a standard nomination: " + voteQueContent.getQuestion()); - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } - - - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } + while (itUsers.hasNext()) { + voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); + + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr + .getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); + logger.debug("attempt: " + voteUsrResp); + voteMonitoredUserDTO.setQuestionUid(questionUid); + + VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); + logger.debug("voteQueContent: " + voteQueContent); + String entry = voteQueContent.getQuestion(); + logger.debug("entry: " + entry); + String voteQueContentId = voteUsrResp.getVoteQueContentId().toString(); + logger.debug("voteQueContentId: " + voteQueContentId); + + VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); + logger.debug("localUserSession: " + localUserSession); + logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); + logger.debug("incoming content id versus localUserSession's content id: " + + voteContent.getVoteContentId() + " versus " + + localUserSession.getVoteContentId()); + logger.debug("summary reporting case 2"); + if (voteContent.getVoteContentId().toString().equals( + localUserSession.getVoteContentId().toString())) { + if (entry != null) { + if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) { + logger.debug("this nomination entry points to a user entered nomination: " + + voteUsrResp.getUserEntry()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + } else { + logger.debug("this nomination entry points to a standard nomination: " + + voteQueContent.getQuestion()); + voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); } + } } - else if ((!isUserNamesVisible) && (isLearnerRequest)) - { - logger.debug("summary reporting case 3" ); - logger.debug("populating data normally exception are for a specific session and other user names are not visible."); - logger.debug("isUserNamesVisible false, isLearnerRequest true" ); - logger.debug("getting only current user's data" ); - String userID= (String)request.getSession().getAttribute(USER_ID); - logger.debug("userID: " + userID); - - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - - logger.debug("userID versus queUsrId: " + userID + "-" + voteQueUsr.getQueUsrId()); - if (userID.equals(voteQueUsr.getQueUsrId().toString())) - { - logger.debug("this is current user, put his name normally."); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - } - else - { - logger.debug("this is not current user, put his name as blank."); - voteMonitoredUserDTO.setUserName("[ ]"); - } - - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - logger.debug("attempt: " + voteUsrResp); - voteMonitoredUserDTO.setQuestionUid(questionUid); - voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); - - VoteQueContent voteQueContent=voteUsrResp.getVoteQueContent(); - logger.debug("voteQueContent: " + voteQueContent); - String entry=voteQueContent.getQuestion(); - logger.debug("entry: " + entry); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } + } + } + } + } else if ((!isUserNamesVisible) && (isLearnerRequest)) { + logger.debug("summary reporting case 3"); + logger + .debug("populating data normally exception are for a specific session and other user names are not visible."); + logger.debug("isUserNamesVisible false, isLearnerRequest true"); + logger.debug("getting only current user's data"); + String userID = (String) request.getSession().getAttribute(USER_ID); + logger.debug("userID: " + userID); - String voteQueContentId=voteUsrResp.getVoteQueContentId().toString(); - logger.debug("voteQueContentId: " + voteQueContentId); - - VoteSession localUserSession=voteUsrResp.getVoteQueUsr().getVoteSession(); - logger.debug("localUserSession: " + localUserSession); - logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); - logger.debug("incoming content id versus localUserSession's content id: " + voteContent.getVoteContentId() + " versus " + localUserSession.getVoteContentId()); - logger.debug("summary reporting case 3" ); - if (voteContent.getVoteContentId().toString().equals(localUserSession.getVoteContentId().toString())) - { - if (entry != null) - { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) - { - logger.debug("this nomination entry points to a user entered nomination: " + voteUsrResp.getUserEntry()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } - else - { - logger.debug("this nomination entry points to a standard nomination: " + voteQueContent.getQuestion()); - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr + .getUid(), new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); - } - } - } - } + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + + logger.debug("userID versus queUsrId: " + userID + "-" + voteQueUsr.getQueUsrId()); + if (userID.equals(voteQueUsr.getQueUsrId().toString())) { + logger.debug("this is current user, put his name normally."); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + } else { + logger.debug("this is not current user, put his name as blank."); + voteMonitoredUserDTO.setUserName("[ ]"); } + + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + + logger.debug("attempt: " + voteUsrResp); + voteMonitoredUserDTO.setQuestionUid(questionUid); + voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); + + VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); + logger.debug("voteQueContent: " + voteQueContent); + String entry = voteQueContent.getQuestion(); + logger.debug("entry: " + entry); + + String voteQueContentId = voteUsrResp.getVoteQueContentId().toString(); + logger.debug("voteQueContentId: " + voteQueContentId); + + VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); + logger.debug("localUserSession: " + localUserSession); + logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); + logger.debug("incoming content id versus localUserSession's content id: " + + voteContent.getVoteContentId() + " versus " + + localUserSession.getVoteContentId()); + logger.debug("summary reporting case 3"); + if (voteContent.getVoteContentId().toString().equals( + localUserSession.getVoteContentId().toString())) { + if (entry != null) { + if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) { + logger.debug("this nomination entry points to a user entered nomination: " + + voteUsrResp.getUserEntry()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + } else { + logger.debug("this nomination entry points to a standard nomination: " + + voteQueContent.getQuestion()); + voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); + } + } + } + + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + + } + } + } } - else - { - logger.debug("summary reporting case 4" ); - logger.debug("request is for learner progress report: " + userId); - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); + } + } else { + logger.debug("summary reporting case 4"); + logger.debug("request is for learner progress report: " + userId); + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - logger.debug("userID versus queUsrId: " + userId + "-" + voteQueUsr.getQueUsrId()); - if (userId.equals(voteQueUsr.getQueUsrId().toString())) - { - logger.debug("this is the user requested , include his name for learner progress."); - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); - logger.debug("attempt: " + voteUsrResp); - voteMonitoredUserDTO.setQuestionUid(questionUid); - - - VoteQueContent voteQueContent=voteUsrResp.getVoteQueContent(); - logger.debug("voteQueContent: " + voteQueContent); - String entry=voteQueContent.getQuestion(); - logger.debug("entry: " + entry); + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsListForUserAndQuestionContent(voteQueUsr.getUid(), + new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); - String voteQueContentId=voteUsrResp.getVoteQueContentId().toString(); - logger.debug("voteQueContentId: " + voteQueContentId); - - VoteSession localUserSession=voteUsrResp.getVoteQueUsr().getVoteSession(); - logger.debug("localUserSession: " + localUserSession); - logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); - logger.debug("incoming content id versus localUserSession's content id: " + voteContent.getVoteContentId() + " versus " + localUserSession.getVoteContentId()); - logger.debug("summary reporting case 4" ); - if (voteContent.getVoteContentId().toString().equals(localUserSession.getVoteContentId().toString())) - { - if (entry != null) - { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) - { - logger.debug("this nomination entry points to a user entered nomination: " + voteUsrResp.getUserEntry()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } - else - { - logger.debug("this nomination entry points to a standard nomination: " + voteQueContent.getQuestion()); - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } - + if (voteUsrResp != null) { + logger.debug("userID versus queUsrId: " + userId + "-" + voteQueUsr.getQueUsrId()); + if (userId.equals(voteQueUsr.getQueUsrId().toString())) { + logger.debug("this is the user requested , include his name for learner progress."); + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setUserEntry(voteUsrResp.getUserEntry()); + logger.debug("attempt: " + voteUsrResp); + voteMonitoredUserDTO.setQuestionUid(questionUid); + + VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); + logger.debug("voteQueContent: " + voteQueContent); + String entry = voteQueContent.getQuestion(); + logger.debug("entry: " + entry); + + String voteQueContentId = voteUsrResp.getVoteQueContentId().toString(); + logger.debug("voteQueContentId: " + voteQueContentId); + + VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); + logger.debug("localUserSession: " + localUserSession); + logger.debug("localUserSession's content id: " + localUserSession.getVoteContentId()); + logger.debug("incoming content id versus localUserSession's content id: " + + voteContent.getVoteContentId() + " versus " + + localUserSession.getVoteContentId()); + logger.debug("summary reporting case 4"); + if (voteContent.getVoteContentId().toString().equals( + localUserSession.getVoteContentId().toString())) { + if (entry != null) { + if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) { + logger.debug("this nomination entry points to a user entered nomination: " + + voteUsrResp.getUserEntry()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + } else { + logger.debug("this nomination entry points to a standard nomination: " + + voteQueContent.getQuestion()); + voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); + } + } + } + + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } + } + } } - - - logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); - mapMonitoredUserContainerDTO=convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); - logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); - return mapMonitoredUserContainerDTO; + } + } - - - public static Map populateToolSessionsId(HttpServletRequest request, VoteContent voteContent, IVoteService voteService) - { - logger.debug("attempt populateToolSessionsId for: " + voteContent); - List sessionsList=voteService.getSessionsFromContent(voteContent); - logger.debug("sessionsList size is:..." + sessionsList.size()); - - Map sessionsMap=VoteUtils.convertToStringMap(sessionsList, "Long"); - logger.debug("generated sessionsMap:..." + sessionsMap); - logger.debug("sessionsMap size:..." + sessionsMap.size()); - - if (sessionsMap.isEmpty()) - { - logger.debug("sessionsMap size is 0:"); - sessionsMap.put(new Long(1).toString() , "None"); - } - else - { - logger.debug("sessionsMap has some entries: " + sessionsMap.size()); - sessionsMap.put(new Long(sessionsMap.size()+ 1).toString() , "All"); - } - - logger.debug("final sessionsMap:" + sessionsMap); - return sessionsMap; + logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); + mapMonitoredUserContainerDTO = convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); + logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); + return mapMonitoredUserContainerDTO; + } + + public static Map populateToolSessionsId(HttpServletRequest request, VoteContent voteContent, + IVoteService voteService) { + logger.debug("attempt populateToolSessionsId for: " + voteContent); + List sessionsList = voteService.getSessionsFromContent(voteContent); + logger.debug("sessionsList size is:..." + sessionsList.size()); + + Map sessionsMap = VoteUtils.convertToStringMap(sessionsList, "Long"); + logger.debug("generated sessionsMap:..." + sessionsMap); + logger.debug("sessionsMap size:..." + sessionsMap.size()); + + if (sessionsMap.isEmpty()) { + logger.debug("sessionsMap size is 0:"); + sessionsMap.put(new Long(1).toString(), "None"); + } else { + logger.debug("sessionsMap has some entries: " + sessionsMap.size()); + sessionsMap.put(new Long(sessionsMap.size() + 1).toString(), "All"); } - public static Map convertToVoteMonitoredUserDTOMap(List list) - { - logger.debug("using convertToVoteMonitoredUserDTOMap: " + list); - Map map= new TreeMap(new VoteComparator()); - - Iterator listIterator=list.iterator(); - Long mapIndex=new Long(1); - - while (listIterator.hasNext()) - { - VoteMonitoredUserDTO data=(VoteMonitoredUserDTO)listIterator.next(); - logger.debug("using data: " + data); - logger.debug("using data: " + data.getResponse()); - logger.debug("using session id: " + data.getSessionId()); - logger.debug("using question uid: " + data.getQuestionUid()) ; - - - map.put(mapIndex.toString(), data); - mapIndex=new Long(mapIndex.longValue()+1); - } - return map; + logger.debug("final sessionsMap:" + sessionsMap); + return sessionsMap; + } + + public static Map convertToVoteMonitoredUserDTOMap(List list) { + logger.debug("using convertToVoteMonitoredUserDTOMap: " + list); + Map map = new TreeMap(new VoteComparator()); + + Iterator listIterator = list.iterator(); + Long mapIndex = new Long(1); + + while (listIterator.hasNext()) { + VoteMonitoredUserDTO data = (VoteMonitoredUserDTO) listIterator.next(); + logger.debug("using data: " + data); + logger.debug("using data: " + data.getResponse()); + logger.debug("using session id: " + data.getSessionId()); + logger.debug("using question uid: " + data.getQuestionUid()); + + map.put(mapIndex.toString(), data); + mapIndex = new Long(mapIndex.longValue() + 1); } + return map; + } - - public static double calculateTotal(Map mapVoteRatesContent) - { - logger.debug("calculating total for: " + mapVoteRatesContent); - double total=0d; - Iterator itMap = mapVoteRatesContent.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (pairs.getValue() != null) - { - total=total+ new Double(pairs.getValue().toString()).doubleValue(); - } - logger.debug("total: " + total); - } - return total; + public static double calculateTotal(Map mapVoteRatesContent) { + logger.debug("calculating total for: " + mapVoteRatesContent); + double total = 0d; + Iterator itMap = mapVoteRatesContent.entrySet().iterator(); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); + + if (pairs.getValue() != null) { + total = total + new Double(pairs.getValue().toString()).doubleValue(); + } + logger.debug("total: " + total); } + return total; + } - - public static Map convertToMap(List list) - { - logger.debug("using convertToMap: " + list); - Map map= new TreeMap(new VoteComparator()); - - Iterator listIterator=list.iterator(); - Long mapIndex=new Long(1); - - while (listIterator.hasNext()) - { - Map data=(Map)listIterator.next(); - map.put(mapIndex.toString(), data); - mapIndex=new Long(mapIndex.longValue()+1); - } - return map; + public static Map convertToMap(List list) { + logger.debug("using convertToMap: " + list); + Map map = new TreeMap(new VoteComparator()); + + Iterator listIterator = list.iterator(); + Long mapIndex = new Long(1); + + while (listIterator.hasNext()) { + Map data = (Map) listIterator.next(); + map.put(mapIndex.toString(), data); + mapIndex = new Long(mapIndex.longValue() + 1); } + return map; + } - /** - * Generates JFreeChart data for all sessions in the Monitoring Summary. - * @param request - * @param voteService - * @param voteMonitoringForm - * @param toolContentID - * @return - */ - public static List prepareChartDTO(HttpServletRequest request, IVoteService voteService, VoteMonitoringForm voteMonitoringForm, - Long toolContentID, MessageService messageService) - { - logger.debug("start preparing ChartDTO with voteMonitoringForm: " + voteMonitoringForm); - logger.debug("start preparing ChartDTO with toolContentID: " + toolContentID); - - List listVoteAllSessionsDTO= new LinkedList(); + /** + * Generates JFreeChart data for all sessions in the Monitoring Summary. + * + * @param request + * @param voteService + * @param voteMonitoringForm + * @param toolContentID + * @return + */ + public static List prepareChartDTO(HttpServletRequest request, IVoteService voteService, + VoteMonitoringForm voteMonitoringForm, Long toolContentID, MessageService messageService) { + logger.debug("start preparing ChartDTO with voteMonitoringForm: " + voteMonitoringForm); + logger.debug("start preparing ChartDTO with toolContentID: " + toolContentID); - VoteContent voteContent=voteService.retrieveVote(toolContentID); - logger.debug("existing voteContent:" + voteContent); - logger.debug("will be building groups question data for content:..." + voteContent); - - Iterator itListSessions = voteContent.getVoteSessions().iterator(); - while (itListSessions.hasNext()) - { - VoteSession voteSession =(VoteSession)itListSessions.next(); - logger.debug("voteSession:..." + voteSession); - logger.debug("current voteSession id :..." + voteSession.getVoteSessionId()); - logger.debug("current toolSessionUid :..." + voteSession.getUid()); + List listVoteAllSessionsDTO = new LinkedList(); - Map mapOptionsContent= new TreeMap(new VoteComparator()); - logger.debug("mapOptionsContent: " + mapOptionsContent); + VoteContent voteContent = voteService.retrieveVote(toolContentID); + logger.debug("existing voteContent:" + voteContent); + logger.debug("will be building groups question data for content:..." + voteContent); - Map mapVoteRatesContent= new TreeMap(new VoteComparator()); - logger.debug("mapVoteRatesContent: " + mapVoteRatesContent); + Iterator itListSessions = voteContent.getVoteSessions().iterator(); + while (itListSessions.hasNext()) { + VoteSession voteSession = (VoteSession) itListSessions.next(); + logger.debug("voteSession:..." + voteSession); + logger.debug("current voteSession id :..." + voteSession.getVoteSessionId()); + logger.debug("current toolSessionUid :..." + voteSession.getUid()); - VoteAllSessionsDTO voteAllSessionsDTO= new VoteAllSessionsDTO(); - voteAllSessionsDTO.setSessionId(voteSession.getVoteSessionId().toString()); - voteAllSessionsDTO.setSessionName(voteSession.getSession_name()); - - int entriesCount=voteService.getSessionEntriesCount(voteSession.getUid()); - logger.debug("entriesCount: " + entriesCount); - Set userEntries=voteService.getSessionUserEntriesSet(voteSession.getUid()); - logger.debug("sessionUserCount: " + userEntries.size()); + Map mapOptionsContent = new TreeMap(new VoteComparator()); + logger.debug("mapOptionsContent: " + mapOptionsContent); - int potentialUserCount=voteService.getVoteSessionPotentialLearnersCount(voteSession.getUid()); - logger.debug("potentialUserCount: " + potentialUserCount); - voteAllSessionsDTO.setSessionUserCount(Integer.toString(potentialUserCount)); - - int completedSessionUserCount=voteService.getCompletedVoteUserBySessionUid(voteSession.getUid()); - logger.debug("completedSessionUserCount: " + completedSessionUserCount); - voteAllSessionsDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); - - if (potentialUserCount != 0) - { - double completedPercent=(completedSessionUserCount*100) / potentialUserCount; - logger.debug("completed percent: " + completedPercent); - - if (completedPercent > 100) - completedPercent = 100; - - voteAllSessionsDTO.setCompletedSessionUserPercent(new Double(completedPercent).toString()); - } - else - { - voteAllSessionsDTO.setCompletedSessionUserPercent("Not Available"); - } - - - logger.debug("entriesCount: " + entriesCount); - logger.debug("userEntries: " + userEntries); - - Map mapStandardUserCount= new TreeMap(new VoteComparator()); + Map mapVoteRatesContent = new TreeMap(new VoteComparator()); + logger.debug("mapVoteRatesContent: " + mapVoteRatesContent); - logger.debug("setting existing content data from the db"); - mapOptionsContent.clear(); - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - Long mapIndex=new Long(1); - logger.debug("mapOptionsContent: " + mapOptionsContent); - int totalStandardVotesCount=0; - - logger.debug("using entriesCount: " + entriesCount); - Map mapStandardNominationsHTMLedContent= new TreeMap(new VoteComparator()); - Map mapStandardQuestionUid= new TreeMap(new VoteComparator()); - Map mapStandardToolSessionUid= new TreeMap(new VoteComparator()); + VoteAllSessionsDTO voteAllSessionsDTO = new VoteAllSessionsDTO(); + voteAllSessionsDTO.setSessionId(voteSession.getVoteSessionId().toString()); + voteAllSessionsDTO.setSessionName(voteSession.getSession_name()); - while (queIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(),voteQueContent.getQuestion()); - String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); - logger.debug("noHTMLNomination: " + noHTMLNomination); - mapOptionsContent.put(mapIndex.toString(),noHTMLNomination); - - int votesCount=0; - logger.debug("getting votesCount based on session: " + voteSession.getUid()); - votesCount=voteService.getStandardAttemptsForQuestionContentAndSessionUid(voteQueContent.getUid(), voteSession.getUid()); - - mapStandardQuestionUid.put(mapIndex.toString(),voteQueContent.getUid().toString()); - mapStandardToolSessionUid.put(mapIndex.toString(),voteSession.getUid()); - - logger.debug("votesCount for questionContent uid: " + votesCount + " for" + voteQueContent.getUid()); - mapStandardUserCount.put(mapIndex.toString(),new Integer(votesCount).toString()); - totalStandardVotesCount=totalStandardVotesCount + votesCount; + int entriesCount = voteService.getSessionEntriesCount(voteSession.getUid()); + logger.debug("entriesCount: " + entriesCount); + Set userEntries = voteService.getSessionUserEntriesSet(voteSession.getUid()); + logger.debug("sessionUserCount: " + userEntries.size()); - double voteRate=0d; - double doubleVotesCount=votesCount * 1d; - logger.debug("doubleVotesCount: " + doubleVotesCount); - double doubleEntriesCount=entriesCount * 1d; - logger.debug("doubleEntriesCount: " + doubleEntriesCount); + int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(voteSession.getUid()); + logger.debug("potentialUserCount: " + potentialUserCount); + voteAllSessionsDTO.setSessionUserCount(Integer.toString(potentialUserCount)); - if (entriesCount != 0) - { - voteRate=((doubleVotesCount * 100)/ doubleEntriesCount); - } + int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(voteSession.getUid()); + logger.debug("completedSessionUserCount: " + completedSessionUserCount); + voteAllSessionsDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); - logger.debug("voteRate" + voteRate); - - String stringVoteRate=new Double(voteRate).toString(); - int lengthVoteRate=stringVoteRate.length(); - logger.debug("lengthVoteRate" + lengthVoteRate); - if (lengthVoteRate > 5) - stringVoteRate=stringVoteRate.substring(0,6); - - - mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); - mapIndex=new Long(mapIndex.longValue()+1); - } - } - logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); - Map mapStandardNominationsContent= new TreeMap(new VoteComparator()); - mapStandardNominationsContent=mapOptionsContent; - logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); - logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); - - Map mapStandardRatesContent= new TreeMap(new VoteComparator()); - mapStandardRatesContent=mapVoteRatesContent; - logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); - logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); - - Iterator itListQuestions = userEntries.iterator(); - int mapVoteRatesSize=mapVoteRatesContent.size(); - logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); - mapIndex=new Long(mapVoteRatesSize+1); - logger.debug("updated mapIndex: " + mapIndex); - - double total=MonitoringUtil.calculateTotal(mapVoteRatesContent); - logger.debug("updated mapIndex: " + mapIndex); - double share=100d-total ; - logger.debug("share: " + share); - - logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); - int userEnteredVotesCount=entriesCount - totalStandardVotesCount; - logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); + if (potentialUserCount != 0) { + double completedPercent = (completedSessionUserCount * 100) / potentialUserCount; + logger.debug("completed percent: " + completedPercent); - if (userEnteredVotesCount != 0) - { - share=((userEnteredVotesCount * 100)/ entriesCount); - logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); - logger.debug("calculated share normally, entriesCount: " + entriesCount); - } - else - { - share=0; - logger.debug("reset share"); - } - logger.debug("final share: " + share); - - if (voteContent.isAllowText()) { - mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - } - mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); - mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); - /**following are needed just for proper iteration in the summary jsp*/ - mapStandardQuestionUid.put(mapIndex.toString(),"1"); - mapStandardToolSessionUid.put(mapIndex.toString(),"1"); + if (completedPercent > 100) + completedPercent = 100; + voteAllSessionsDTO.setCompletedSessionUserPercent(new Double(completedPercent).toString()); + } else { + voteAllSessionsDTO.setCompletedSessionUserPercent("Not Available"); + } - logger.debug("processed for prepareChartDTO: mapStandardNominationsContent: " + mapStandardNominationsContent); - logger.debug("processed for prepareChartDTO: mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); - logger.debug("processed for prepareChartDTO: mapStandardUserCount: " + mapStandardUserCount); - logger.debug("processed for prepareChartDTO: mapStandardRatesContent: " + mapStandardRatesContent); - - voteAllSessionsDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - voteAllSessionsDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - voteAllSessionsDTO.setMapStandardUserCount(mapStandardUserCount); - voteAllSessionsDTO.setMapStandardRatesContent(mapStandardRatesContent); - voteAllSessionsDTO.setMapStandardQuestionUid(mapStandardQuestionUid); - voteAllSessionsDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - - VoteMonitoringAction voteMonitoringAction= new VoteMonitoringAction(); - List listUserEntries=voteMonitoringAction.processUserEnteredNominations(voteService, voteContent, voteSession.getVoteSessionId().toString(), true, null, false); - logger.debug("listUserEntries: " + listUserEntries); - voteAllSessionsDTO.setListUserEntries(listUserEntries); - - if (listUserEntries.size() > 0) - voteAllSessionsDTO.setExistsOpenVote (new Boolean(true).toString()); - else - voteAllSessionsDTO.setExistsOpenVote (new Boolean(false).toString()); - - listVoteAllSessionsDTO.add(voteAllSessionsDTO); - } - logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); - - return listVoteAllSessionsDTO; - } - - /** - * Generates JFreeChart data for the learner module and - * monitoring module Summary tab (Individual Sessions mode) - * - * @param request - * @param voteService - * @param voteMonitoringForm - * @param toolContentID - * @param toolSessionUid - */ - public static void prepareChartData(HttpServletRequest request, IVoteService voteService, VoteMonitoringForm voteMonitoringForm, - String toolContentID, String toolSessionUid, VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO, MessageService messageService) - { - logger.debug("starting prepareChartData, voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - logger.debug("starting prepareChartData, toolContentID: " + toolContentID); - logger.debug("starting prepareChartData, toolSessionUid: " + toolSessionUid); - VoteContent voteContent=voteService.retrieveVote(new Long(toolContentID)); - logger.debug("starting prepareChartData, voteContent uid: " + voteContent.getUid()); - - logger.debug("starting prepareChartData, voteMonitoringForm: " + voteMonitoringForm); - - logger.debug("existing voteContent:" + voteContent); - Map mapOptionsContent= new TreeMap(new VoteComparator()); - logger.debug("mapOptionsContent: " + mapOptionsContent); - - Map mapVoteRatesContent= new TreeMap(new VoteComparator()); - logger.debug("mapVoteRatesContent: " + mapVoteRatesContent); - - - List distinctSessionUsers=new ArrayList(); - boolean sessionLevelCharting=true; - int entriesCount=0; - Set userEntries=null; - if (toolSessionUid != null) - { - logger.debug("process for session: " + toolSessionUid); - entriesCount=voteService.getSessionEntriesCount(new Long(toolSessionUid)); - logger.debug("entriesCount: " + entriesCount); - userEntries=voteService.getSessionUserEntriesSet(new Long(toolSessionUid)); - logger.debug("sessionUserCount: " + userEntries.size()); - - int completedSessionUserCount=voteService.getCompletedVoteUserBySessionUid(new Long(toolSessionUid)); - logger.debug("completedSessionUserCount: " + completedSessionUserCount); - - - int completedEntriesCount=voteService.getCompletedSessionEntriesCount(new Long(toolSessionUid)); - logger.debug("completedEntriesCount: " + completedEntriesCount); + logger.debug("entriesCount: " + entriesCount); + logger.debug("userEntries: " + userEntries); - if (voteMonitoringForm != null) - { - int potentialUserCount=voteService.getVoteSessionPotentialLearnersCount(new Long(toolSessionUid)); - logger.debug("potentialUserCount: " + potentialUserCount); - voteMonitoringForm.setSessionUserCount(Integer.toString(potentialUserCount)); - voteMonitoringForm.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); + Map mapStandardUserCount = new TreeMap(new VoteComparator()); - if (voteGeneralMonitoringDTO != null) - { - voteGeneralMonitoringDTO.setSessionUserCount(Integer.toString(potentialUserCount)); - voteGeneralMonitoringDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); - } + logger.debug("setting existing content data from the db"); + mapOptionsContent.clear(); + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + Long mapIndex = new Long(1); + logger.debug("mapOptionsContent: " + mapOptionsContent); + int totalStandardVotesCount = 0; - if (potentialUserCount != 0) - { - double completedPercent=(completedSessionUserCount*100) / potentialUserCount; - logger.debug("completed percent: " + completedPercent); - - if (completedPercent > 100) - completedPercent = 100; - - voteMonitoringForm.setCompletedSessionUserPercent(new Double(completedPercent).toString()); - if (voteGeneralMonitoringDTO != null) - { - voteGeneralMonitoringDTO.setCompletedSessionUserPercent(new Double(completedPercent).toString()); - } - } - else - { - voteMonitoringForm.setCompletedSessionUserPercent("Not Available"); - if (voteGeneralMonitoringDTO != null) - { - voteGeneralMonitoringDTO.setCompletedSessionUserPercent("Not Available"); - } - } + logger.debug("using entriesCount: " + entriesCount); + Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); + Map mapStandardQuestionUid = new TreeMap(new VoteComparator()); + Map mapStandardToolSessionUid = new TreeMap(new VoteComparator()); + + while (queIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + logger.debug("question: " + voteQueContent.getQuestion()); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); + logger.debug("noHTMLNomination: " + noHTMLNomination); + mapOptionsContent.put(mapIndex.toString(), noHTMLNomination); + + int votesCount = 0; + logger.debug("getting votesCount based on session: " + voteSession.getUid()); + votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid( + voteQueContent.getUid(), voteSession.getUid()); + + mapStandardQuestionUid.put(mapIndex.toString(), voteQueContent.getUid().toString()); + mapStandardToolSessionUid.put(mapIndex.toString(), voteSession.getUid()); + + logger + .debug("votesCount for questionContent uid: " + votesCount + " for" + + voteQueContent.getUid()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(votesCount).toString()); + totalStandardVotesCount = totalStandardVotesCount + votesCount; + + double voteRate = 0d; + double doubleVotesCount = votesCount * 1d; + logger.debug("doubleVotesCount: " + doubleVotesCount); + double doubleEntriesCount = entriesCount * 1d; + logger.debug("doubleEntriesCount: " + doubleEntriesCount); + + if (entriesCount != 0) { + voteRate = ((doubleVotesCount * 100) / doubleEntriesCount); } - } - - logger.debug("entriesCount: " + entriesCount); - logger.debug("userEntries: " + userEntries); - logger.debug("sessionLevelCharting: " + sessionLevelCharting); - - - Map mapStandardUserCount= new TreeMap(new VoteComparator()); - logger.debug("setting existing content data from the db"); - mapOptionsContent.clear(); - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - Long mapIndex=new Long(1); - logger.debug("mapOptionsContent: " + mapOptionsContent); - int totalStandardVotesCount=0; - - logger.debug("using entriesCount: " + entriesCount); - - Map mapStandardNominationsHTMLedContent= new TreeMap(new VoteComparator()); - Map mapStandardQuestionUid= new TreeMap(new VoteComparator()); - Map mapStandardToolSessionUid= new TreeMap(new VoteComparator()); - while (queIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), voteQueContent.getQuestion()); - String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); - logger.debug("noHTMLNomination: " + noHTMLNomination); - mapOptionsContent.put(mapIndex.toString(),noHTMLNomination); - - int votesCount=0; - if (sessionLevelCharting == true) - { - logger.debug("getting votesCount based on session: " + toolSessionUid); - votesCount=voteService.getStandardAttemptsForQuestionContentAndSessionUid(voteQueContent.getUid(), new Long(toolSessionUid)); - - mapStandardQuestionUid.put(mapIndex.toString(),voteQueContent.getUid().toString()); - mapStandardToolSessionUid.put(mapIndex.toString(),toolSessionUid.toString()); - - logger.debug("votesCount for questionContent uid: " + votesCount + " for" + voteQueContent.getUid()); - mapStandardUserCount.put(mapIndex.toString(),new Integer(votesCount).toString()); - totalStandardVotesCount=totalStandardVotesCount + votesCount; - } - else - { - logger.debug("getting votesCount based on content: " + voteQueContent.getUid()); - votesCount=voteService.getAttemptsForQuestionContent(voteQueContent.getUid()); - logger.debug("votesCount for questionContent uid: " + votesCount + " for" + voteQueContent.getUid()); - } - - double voteRate=0d; - double doubleVotesCount=votesCount * 1d; - logger.debug("doubleVotesCount: " + doubleVotesCount); - double doubleEntriesCount=entriesCount * 1d; - logger.debug("doubleEntriesCount: " + doubleEntriesCount); - if (entriesCount != 0) - { - voteRate=((doubleVotesCount * 100)/ doubleEntriesCount); - } + logger.debug("voteRate" + voteRate); - logger.debug("voteRate" + voteRate); - - String stringVoteRate=new Double(voteRate).toString(); - int lengthVoteRate=stringVoteRate.length(); - logger.debug("lengthVoteRate" + lengthVoteRate); - if (lengthVoteRate > 5) - stringVoteRate=stringVoteRate.substring(0,6); - - mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); - mapIndex=new Long(mapIndex.longValue()+1); - } + String stringVoteRate = new Double(voteRate).toString(); + int lengthVoteRate = stringVoteRate.length(); + logger.debug("lengthVoteRate" + lengthVoteRate); + if (lengthVoteRate > 5) + stringVoteRate = stringVoteRate.substring(0, 6); + + mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); + mapIndex = new Long(mapIndex.longValue() + 1); } - - logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); - Map mapStandardNominationsContent= new TreeMap(new VoteComparator()); - mapStandardNominationsContent=mapOptionsContent; - logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); - logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); - - Map mapStandardRatesContent= new TreeMap(new VoteComparator()); - mapStandardRatesContent=mapVoteRatesContent; - logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); - logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); - - int mapVoteRatesSize=mapVoteRatesContent.size(); + } + logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); + Map mapStandardNominationsContent = new TreeMap(new VoteComparator()); + mapStandardNominationsContent = mapOptionsContent; + logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); + logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); + + Map mapStandardRatesContent = new TreeMap(new VoteComparator()); + mapStandardRatesContent = mapVoteRatesContent; + logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); + logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); + + Iterator itListQuestions = userEntries.iterator(); + int mapVoteRatesSize = mapVoteRatesContent.size(); logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); - mapIndex=new Long(mapVoteRatesSize+1); + mapIndex = new Long(mapVoteRatesSize + 1); logger.debug("updated mapIndex: " + mapIndex); - - double total=MonitoringUtil.calculateTotal(mapVoteRatesContent); + + double total = MonitoringUtil.calculateTotal(mapVoteRatesContent); logger.debug("updated mapIndex: " + mapIndex); - double share=100-total ; + double share = 100d - total; logger.debug("share: " + share); - + logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); - int userEnteredVotesCount=entriesCount - totalStandardVotesCount; - logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); - - - if (userEnteredVotesCount != 0) - { - share=((userEnteredVotesCount * 100)/ entriesCount); - logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); - logger.debug("calculated share normally, entriesCount: " + entriesCount); + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); + + if (userEnteredVotesCount != 0) { + share = ((userEnteredVotesCount * 100) / entriesCount); + logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); + logger.debug("calculated share normally, entriesCount: " + entriesCount); + } else { + share = 0; + logger.debug("reset share"); + } + logger.debug("final share: " + share); + + if (voteContent.isAllowText()) { + mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService + .getMessage("label.open.vote")); + } + mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); + /** following are needed just for proper iteration in the summary jsp */ + mapStandardQuestionUid.put(mapIndex.toString(), "1"); + mapStandardToolSessionUid.put(mapIndex.toString(), "1"); + + logger.debug("processed for prepareChartDTO: mapStandardNominationsContent: " + + mapStandardNominationsContent); + logger.debug("processed for prepareChartDTO: mapStandardNominationsHTMLedContent: " + + mapStandardNominationsHTMLedContent); + logger.debug("processed for prepareChartDTO: mapStandardUserCount: " + mapStandardUserCount); + logger.debug("processed for prepareChartDTO: mapStandardRatesContent: " + mapStandardRatesContent); + + voteAllSessionsDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + voteAllSessionsDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + voteAllSessionsDTO.setMapStandardUserCount(mapStandardUserCount); + voteAllSessionsDTO.setMapStandardRatesContent(mapStandardRatesContent); + voteAllSessionsDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + voteAllSessionsDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); + + VoteMonitoringAction voteMonitoringAction = new VoteMonitoringAction(); + List listUserEntries = voteMonitoringAction.processUserEnteredNominations(voteService, voteContent, + voteSession.getVoteSessionId().toString(), true, null, false); + logger.debug("listUserEntries: " + listUserEntries); + voteAllSessionsDTO.setListUserEntries(listUserEntries); + + if (listUserEntries.size() > 0) + voteAllSessionsDTO.setExistsOpenVote(new Boolean(true).toString()); + else + voteAllSessionsDTO.setExistsOpenVote(new Boolean(false).toString()); + + listVoteAllSessionsDTO.add(voteAllSessionsDTO); + } + logger.debug("listVoteAllSessionsDTO: " + listVoteAllSessionsDTO); + + return listVoteAllSessionsDTO; + } + + /** + * Generates JFreeChart data for the learner module and monitoring module + * Summary tab (Individual Sessions mode) + * + * @param request + * @param voteService + * @param voteMonitoringForm + * @param toolContentID + * @param toolSessionUid + */ + public static void prepareChartData(HttpServletRequest request, IVoteService voteService, + VoteMonitoringForm voteMonitoringForm, String toolContentID, String toolSessionUid, + VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO, VoteGeneralMonitoringDTO voteGeneralMonitoringDTO, + MessageService messageService) { + logger.debug("starting prepareChartData, voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + logger.debug("starting prepareChartData, toolContentID: " + toolContentID); + logger.debug("starting prepareChartData, toolSessionUid: " + toolSessionUid); + VoteContent voteContent = voteService.retrieveVote(new Long(toolContentID)); + logger.debug("starting prepareChartData, voteContent uid: " + voteContent.getUid()); + + logger.debug("starting prepareChartData, voteMonitoringForm: " + voteMonitoringForm); + + logger.debug("existing voteContent:" + voteContent); + Map mapOptionsContent = new TreeMap(new VoteComparator()); + logger.debug("mapOptionsContent: " + mapOptionsContent); + + Map mapVoteRatesContent = new TreeMap(new VoteComparator()); + logger.debug("mapVoteRatesContent: " + mapVoteRatesContent); + + List distinctSessionUsers = new ArrayList(); + boolean sessionLevelCharting = true; + int entriesCount = 0; + Set userEntries = null; + if (toolSessionUid != null) { + logger.debug("process for session: " + toolSessionUid); + entriesCount = voteService.getSessionEntriesCount(new Long(toolSessionUid)); + logger.debug("entriesCount: " + entriesCount); + userEntries = voteService.getSessionUserEntriesSet(new Long(toolSessionUid)); + logger.debug("sessionUserCount: " + userEntries.size()); + + int completedSessionUserCount = voteService.getCompletedVoteUserBySessionUid(new Long(toolSessionUid)); + logger.debug("completedSessionUserCount: " + completedSessionUserCount); + + int completedEntriesCount = voteService.getCompletedSessionEntriesCount(new Long(toolSessionUid)); + logger.debug("completedEntriesCount: " + completedEntriesCount); + + if (voteMonitoringForm != null) { + int potentialUserCount = voteService.getVoteSessionPotentialLearnersCount(new Long(toolSessionUid)); + logger.debug("potentialUserCount: " + potentialUserCount); + voteMonitoringForm.setSessionUserCount(Integer.toString(potentialUserCount)); + voteMonitoringForm.setCompletedSessionUserCount(new Integer(completedSessionUserCount).toString()); + + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setSessionUserCount(Integer.toString(potentialUserCount)); + voteGeneralMonitoringDTO.setCompletedSessionUserCount(new Integer(completedSessionUserCount) + .toString()); } - else - { - share=0; - logger.debug("reset share"); - } - logger.debug("final share: " + share); - if(voteContent.isAllowText()) { - mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + if (potentialUserCount != 0) { + double completedPercent = (completedSessionUserCount * 100) / potentialUserCount; + logger.debug("completed percent: " + completedPercent); + + if (completedPercent > 100) + completedPercent = 100; + + voteMonitoringForm.setCompletedSessionUserPercent(new Double(completedPercent).toString()); + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO + .setCompletedSessionUserPercent(new Double(completedPercent).toString()); + } + } else { + voteMonitoringForm.setCompletedSessionUserPercent("Not Available"); + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setCompletedSessionUserPercent("Not Available"); + } } - - mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); - mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); - - /**following are needed just for proper iteration in the summary jsp*/ - mapStandardQuestionUid.put(mapIndex.toString(),"1"); - mapStandardToolSessionUid.put(mapIndex.toString(),"1"); + } + } - request.setAttribute(LIST_USER_ENTRIES_CONTENT, userEntries); - logger.debug("test2: mapUserEntriesContent: " + request.getSession().getAttribute(LIST_USER_ENTRIES_CONTENT)); + logger.debug("entriesCount: " + entriesCount); + logger.debug("userEntries: " + userEntries); + logger.debug("sessionLevelCharting: " + sessionLevelCharting); - request.getSession().setAttribute(MAP_STANDARD_NOMINATIONS_CONTENT, mapStandardNominationsContent); - logger.debug("test2: MAP_STANDARD_NOMINATIONS_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_NOMINATIONS_CONTENT)); + Map mapStandardUserCount = new TreeMap(new VoteComparator()); - request.getSession().setAttribute(MAP_STANDARD_RATES_CONTENT, mapStandardRatesContent); - logger.debug("test2: MAP_STANDARD_RATES_CONTENT: " + request.getSession().getAttribute(MAP_STANDARD_RATES_CONTENT)); + logger.debug("setting existing content data from the db"); + mapOptionsContent.clear(); + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + Long mapIndex = new Long(1); + logger.debug("mapOptionsContent: " + mapOptionsContent); + int totalStandardVotesCount = 0; - if (voteGeneralLearnerFlowDTO !=null) - { - logger.debug("placing maps within voteGeneralLearnerFlowDTO"); - voteGeneralLearnerFlowDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - voteGeneralLearnerFlowDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - voteGeneralLearnerFlowDTO.setMapStandardRatesContent(mapStandardRatesContent); - voteGeneralLearnerFlowDTO.setMapStandardUserCount(mapStandardUserCount); - voteGeneralLearnerFlowDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - voteGeneralLearnerFlowDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + logger.debug("using entriesCount: " + entriesCount); + + Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); + Map mapStandardQuestionUid = new TreeMap(new VoteComparator()); + Map mapStandardToolSessionUid = new TreeMap(new VoteComparator()); + while (queIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + logger.debug("question: " + voteQueContent.getQuestion()); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); + logger.debug("noHTMLNomination: " + noHTMLNomination); + mapOptionsContent.put(mapIndex.toString(), noHTMLNomination); + + int votesCount = 0; + if (sessionLevelCharting == true) { + logger.debug("getting votesCount based on session: " + toolSessionUid); + votesCount = voteService.getStandardAttemptsForQuestionContentAndSessionUid( + voteQueContent.getUid(), new Long(toolSessionUid)); + + mapStandardQuestionUid.put(mapIndex.toString(), voteQueContent.getUid().toString()); + mapStandardToolSessionUid.put(mapIndex.toString(), toolSessionUid.toString()); + + logger + .debug("votesCount for questionContent uid: " + votesCount + " for" + + voteQueContent.getUid()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(votesCount).toString()); + totalStandardVotesCount = totalStandardVotesCount + votesCount; + } else { + logger.debug("getting votesCount based on content: " + voteQueContent.getUid()); + votesCount = voteService.getAttemptsForQuestionContent(voteQueContent.getUid()); + logger + .debug("votesCount for questionContent uid: " + votesCount + " for" + + voteQueContent.getUid()); } - - if (voteGeneralMonitoringDTO !=null) - { - voteGeneralMonitoringDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - voteGeneralMonitoringDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - voteGeneralMonitoringDTO.setMapStandardRatesContent(mapStandardRatesContent); - voteGeneralMonitoringDTO.setMapStandardUserCount(mapStandardUserCount); - voteGeneralMonitoringDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); - voteGeneralMonitoringDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + + double voteRate = 0d; + double doubleVotesCount = votesCount * 1d; + logger.debug("doubleVotesCount: " + doubleVotesCount); + double doubleEntriesCount = entriesCount * 1d; + logger.debug("doubleEntriesCount: " + doubleEntriesCount); + if (entriesCount != 0) { + voteRate = ((doubleVotesCount * 100) / doubleEntriesCount); } - logger.debug("end of prepareChartData, voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); - request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO); - - logger.debug("end of prepareChartData, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); - request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + logger.debug("voteRate" + voteRate); + + String stringVoteRate = new Double(voteRate).toString(); + int lengthVoteRate = stringVoteRate.length(); + logger.debug("lengthVoteRate" + lengthVoteRate); + if (lengthVoteRate > 5) + stringVoteRate = stringVoteRate.substring(0, 6); + + mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); + mapIndex = new Long(mapIndex.longValue() + 1); + } } - - /** - * generates JFreeChart for the teacher export portfolio - * - * @param request - * @param voteService - * @param voteMonitoringForm - * @param toolContentID - * @param toolSessionUid - */ - public static void prepareChartDataForExportTeacher(HttpServletRequest request, IVoteService voteService, - VoteMonitoringForm voteMonitoringForm, Long toolContentID, Long toolSessionUid, ExportPortfolioDTO exportPortfolioDTO, MessageService messageService) - { - logger.debug("starting prepareChartDataForExportTeacher, toolContentID: " + toolContentID); - logger.debug("starting prepareChartDataForExportTeacher, toolSessionUid: " + toolSessionUid); - logger.debug("pased exportPortfolioDTO: " + exportPortfolioDTO); - - VoteContent voteContent=voteService.retrieveVote(toolContentID); - logger.debug("starting prepareChartData, voteContent uid: " + voteContent.getUid()); - logger.debug("starting prepareChartDataForExport, voteMonitoringForm: " + voteMonitoringForm); - logger.debug("existing voteContent:" + voteContent); - - Map mapOptionsContent= new TreeMap(new VoteComparator()); - Map mapVoteRatesContent= new TreeMap(new VoteComparator()); - Map mapStandardUserCount= new TreeMap(new VoteComparator()); - - Iterator queIterator=voteContent.getVoteQueContents().iterator(); - Long mapIndex=new Long(1); - int totalStandardVotesCount=0; - int totalStandardContentVotesCount=0; - int entriesCount=0; - - logger.debug("get all entries for content: " + voteContent); - List setEntriesCount=voteService.getContentEntries(voteContent.getUid()); - logger.debug("setEntriesCount: " +setEntriesCount); - entriesCount=setEntriesCount.size(); - logger.debug("entriesCount: " + entriesCount); - - Map mapStandardNominationsHTMLedContent= new TreeMap(new VoteComparator()); + logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); + Map mapStandardNominationsContent = new TreeMap(new VoteComparator()); + mapStandardNominationsContent = mapOptionsContent; + logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); + logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); - while (queIterator.hasNext()) - { - VoteQueContent voteQueContent=(VoteQueContent) queIterator.next(); - if (voteQueContent != null) - { - logger.debug("question: " + voteQueContent.getQuestion()); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(),voteQueContent.getQuestion()); - String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); - logger.debug("noHTMLNomination: " + noHTMLNomination); - mapOptionsContent.put(mapIndex.toString(),noHTMLNomination); + Map mapStandardRatesContent = new TreeMap(new VoteComparator()); + mapStandardRatesContent = mapVoteRatesContent; + logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); + logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); - int votesCount=voteService.getStandardAttemptsForQuestionContentAndContentUid(voteQueContent.getUid(), voteContent.getUid()); - logger.debug("standardContentAttemptCount: " + votesCount); - - mapStandardUserCount.put(mapIndex.toString(),new Integer(votesCount).toString()); - totalStandardVotesCount=totalStandardVotesCount + votesCount; + int mapVoteRatesSize = mapVoteRatesContent.size(); + logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); + mapIndex = new Long(mapVoteRatesSize + 1); + logger.debug("updated mapIndex: " + mapIndex); - - double voteRate=0d; - double doubleVotesCount=votesCount * 1d; - logger.debug("doubleVotesCount: " + doubleVotesCount); - double doubleEntriesCount=entriesCount * 1d; - logger.debug("doubleEntriesCount: " + doubleEntriesCount); - if (entriesCount != 0) - { - voteRate=((doubleVotesCount * 100)/ doubleEntriesCount); - } + double total = MonitoringUtil.calculateTotal(mapVoteRatesContent); + logger.debug("updated mapIndex: " + mapIndex); + double share = 100 - total; + logger.debug("share: " + share); - logger.debug("voteRate" + voteRate); - String stringVoteRate=new Double(voteRate).toString(); - int lengthVoteRate=stringVoteRate.length(); - logger.debug("lengthVoteRate" + lengthVoteRate); - if (lengthVoteRate > 5) - stringVoteRate=stringVoteRate.substring(0,6); - - mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); - mapIndex=new Long(mapIndex.longValue()+1); + logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); + + if (userEnteredVotesCount != 0) { + share = ((userEnteredVotesCount * 100) / entriesCount); + logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); + logger.debug("calculated share normally, entriesCount: " + entriesCount); + } else { + share = 0; + logger.debug("reset share"); + } + logger.debug("final share: " + share); + + if (voteContent.isAllowText()) { + mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + } + + mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); + + /** following are needed just for proper iteration in the summary jsp */ + mapStandardQuestionUid.put(mapIndex.toString(), "1"); + mapStandardToolSessionUid.put(mapIndex.toString(), "1"); + + request.setAttribute(LIST_USER_ENTRIES_CONTENT, userEntries); + logger.debug("test2: mapUserEntriesContent: " + request.getSession().getAttribute(LIST_USER_ENTRIES_CONTENT)); + + request.getSession().setAttribute(MAP_STANDARD_NOMINATIONS_CONTENT, mapStandardNominationsContent); + logger.debug("test2: MAP_STANDARD_NOMINATIONS_CONTENT: " + + request.getSession().getAttribute(MAP_STANDARD_NOMINATIONS_CONTENT)); + + request.getSession().setAttribute(MAP_STANDARD_RATES_CONTENT, mapStandardRatesContent); + logger.debug("test2: MAP_STANDARD_RATES_CONTENT: " + + request.getSession().getAttribute(MAP_STANDARD_RATES_CONTENT)); + + if (voteGeneralLearnerFlowDTO != null) { + logger.debug("placing maps within voteGeneralLearnerFlowDTO"); + voteGeneralLearnerFlowDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + voteGeneralLearnerFlowDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + voteGeneralLearnerFlowDTO.setMapStandardRatesContent(mapStandardRatesContent); + voteGeneralLearnerFlowDTO.setMapStandardUserCount(mapStandardUserCount); + voteGeneralLearnerFlowDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); + voteGeneralLearnerFlowDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + } + + if (voteGeneralMonitoringDTO != null) { + voteGeneralMonitoringDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + voteGeneralMonitoringDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + voteGeneralMonitoringDTO.setMapStandardRatesContent(mapStandardRatesContent); + voteGeneralMonitoringDTO.setMapStandardUserCount(mapStandardUserCount); + voteGeneralMonitoringDTO.setMapStandardToolSessionUid(mapStandardToolSessionUid); + voteGeneralMonitoringDTO.setMapStandardQuestionUid(mapStandardQuestionUid); + } + + logger.debug("end of prepareChartData, voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO); + request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO); + + logger.debug("end of prepareChartData, voteGeneralMonitoringDTO: " + voteGeneralMonitoringDTO); + request.setAttribute(VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + } + + /** + * generates JFreeChart for the teacher export portfolio + * + * @param request + * @param voteService + * @param voteMonitoringForm + * @param toolContentID + * @param toolSessionUid + */ + public static void prepareChartDataForExportTeacher(HttpServletRequest request, IVoteService voteService, + VoteMonitoringForm voteMonitoringForm, Long toolContentID, Long toolSessionUid, + ExportPortfolioDTO exportPortfolioDTO, MessageService messageService) { + logger.debug("starting prepareChartDataForExportTeacher, toolContentID: " + toolContentID); + logger.debug("starting prepareChartDataForExportTeacher, toolSessionUid: " + toolSessionUid); + logger.debug("pased exportPortfolioDTO: " + exportPortfolioDTO); + + VoteContent voteContent = voteService.retrieveVote(toolContentID); + logger.debug("starting prepareChartData, voteContent uid: " + voteContent.getUid()); + logger.debug("starting prepareChartDataForExport, voteMonitoringForm: " + voteMonitoringForm); + logger.debug("existing voteContent:" + voteContent); + + Map mapOptionsContent = new TreeMap(new VoteComparator()); + Map mapVoteRatesContent = new TreeMap(new VoteComparator()); + Map mapStandardUserCount = new TreeMap(new VoteComparator()); + + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + Long mapIndex = new Long(1); + int totalStandardVotesCount = 0; + int totalStandardContentVotesCount = 0; + int entriesCount = 0; + + logger.debug("get all entries for content: " + voteContent); + entriesCount = voteService.getUserEnteredVotesCountForContent(voteContent.getUid()); + logger.debug("entriesCount: " + entriesCount); + + Map mapStandardNominationsHTMLedContent = new TreeMap(new VoteComparator()); + + while (queIterator.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + logger.debug("question: " + voteQueContent.getQuestion()); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), voteQueContent.getQuestion()); + String noHTMLNomination = VoteUtils.stripHTML(voteQueContent.getQuestion()); + logger.debug("noHTMLNomination: " + noHTMLNomination); + mapOptionsContent.put(mapIndex.toString(), noHTMLNomination); + + int votesCount = voteService.getStandardAttemptsForQuestionContentAndContentUid( + voteQueContent.getUid(), voteContent.getUid()); + logger.debug("standardContentAttemptCount: " + votesCount); + + mapStandardUserCount.put(mapIndex.toString(), new Integer(votesCount).toString()); + totalStandardVotesCount = totalStandardVotesCount + votesCount; + + double voteRate = 0d; + double doubleVotesCount = votesCount * 1d; + logger.debug("doubleVotesCount: " + doubleVotesCount); + double doubleEntriesCount = entriesCount * 1d; + logger.debug("doubleEntriesCount: " + doubleEntriesCount); + if (entriesCount != 0) { + voteRate = ((doubleVotesCount * 100) / doubleEntriesCount); + } + + logger.debug("voteRate" + voteRate); + String stringVoteRate = new Double(voteRate).toString(); + int lengthVoteRate = stringVoteRate.length(); + logger.debug("lengthVoteRate" + lengthVoteRate); + if (lengthVoteRate > 5) + stringVoteRate = stringVoteRate.substring(0, 6); + + mapVoteRatesContent.put(mapIndex.toString(), stringVoteRate); + mapIndex = new Long(mapIndex.longValue() + 1); + } + } + logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); + Map mapStandardNominationsContent = new TreeMap(new VoteComparator()); + mapStandardNominationsContent = mapOptionsContent; + logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); + logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); + + Map mapStandardRatesContent = new TreeMap(new VoteComparator()); + mapStandardRatesContent = mapVoteRatesContent; + logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); + logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); + + int mapVoteRatesSize = mapVoteRatesContent.size(); + logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); + mapIndex = new Long(mapVoteRatesSize + 1); + logger.debug("updated mapIndex: " + mapIndex); + + double total = MonitoringUtil.calculateTotal(mapVoteRatesContent); + logger.debug("updated mapIndex: " + mapIndex); + double share = 100d - total; + logger.debug("share: " + share); + + logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); + + if (userEnteredVotesCount != 0) { + share = ((userEnteredVotesCount * 100) / entriesCount); + logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); + logger.debug("calculated share normally, entriesCount: " + entriesCount); + } else { + share = 0; + logger.debug("reset share"); + } + logger.debug("final share: " + share); + + if (voteContent.isAllowText()) { + mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + } + mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); + mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); + + if (exportPortfolioDTO != null) { + exportPortfolioDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); + exportPortfolioDTO.setMapStandardRatesContent(mapStandardRatesContent); + exportPortfolioDTO.setMapStandardUserCount(mapStandardUserCount); + exportPortfolioDTO.setMapStandardNominationsContent(mapStandardNominationsContent); + } + logger.debug("ending prepareChartDataForExportTeacher, exportPortfolioDTO: " + exportPortfolioDTO); + } + + public static boolean notebookEntriesExist(IVoteService voteService, VoteContent voteContent) { + logger.debug("finding out about content level notebook entries: " + voteContent); + Iterator iteratorSession = voteContent.getVoteSessions().iterator(); + while (iteratorSession.hasNext()) { + VoteSession voteSession = (VoteSession) iteratorSession.next(); + logger.debug("voteSession: " + voteSession); + + if (voteSession != null) { + logger.debug("voteSession id: " + voteSession.getVoteSessionId()); + + Iterator iteratorUser = voteSession.getVoteQueUsers().iterator(); + while (iteratorUser.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) iteratorUser.next(); + logger.debug("voteQueUsr: " + voteQueUsr); + + if (voteQueUsr != null) { + logger.debug("voteQueUsr id: " + voteQueUsr.getQueUsrId()); + + logger.debug("attempt getting notebookEntry: "); + NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, MY_SIGNATURE, new Integer(voteQueUsr.getQueUsrId() + .intValue())); + + logger.debug("notebookEntry: " + notebookEntry); + if (notebookEntry != null) { + logger.debug("found at least one notebookEntry: " + notebookEntry.getEntry()); + return true; } + + } } - logger.debug("test1: Map initialized with existing contentid to: " + mapOptionsContent); - Map mapStandardNominationsContent= new TreeMap(new VoteComparator()); - mapStandardNominationsContent=mapOptionsContent; - logger.debug("mapStandardNominationsContent: " + mapStandardNominationsContent); - logger.debug("mapStandardNominationsHTMLedContent: " + mapStandardNominationsHTMLedContent); - - Map mapStandardRatesContent= new TreeMap(new VoteComparator()); - mapStandardRatesContent=mapVoteRatesContent; - logger.debug("test1: mapStandardRatesContent: " + mapStandardRatesContent); - logger.debug("test1: mapStandardUserCount: " + mapStandardUserCount); - - int mapVoteRatesSize=mapVoteRatesContent.size(); - logger.debug("mapVoteRatesSize: " + mapVoteRatesSize); - mapIndex=new Long(mapVoteRatesSize+1); - logger.debug("updated mapIndex: " + mapIndex); - - double total=MonitoringUtil.calculateTotal(mapVoteRatesContent); - logger.debug("updated mapIndex: " + mapIndex); - double share=100d-total ; - logger.debug("share: " + share); - - logger.debug("totalStandardVotesCount: " + totalStandardVotesCount); - int userEnteredVotesCount=entriesCount - totalStandardVotesCount; - logger.debug("userEnteredVotesCount for this session: " + userEnteredVotesCount); - - if (userEnteredVotesCount != 0) - { - share=((userEnteredVotesCount * 100)/ entriesCount); - logger.debug("calculated share normally, userEnteredVotesCount: " + userEnteredVotesCount); - logger.debug("calculated share normally, entriesCount: " + entriesCount); + } + } + return false; + } + + public static void buildVoteStatsDTO(HttpServletRequest request, IVoteService voteService, VoteContent voteContent) { + logger.debug("building voteStatsDTO: " + voteContent); + VoteStatsDTO voteStatsDTO = new VoteStatsDTO(); + + int countSessionComplete = 0; + int countAllUsers = 0; + logger.debug("finding out about content level notebook entries: " + voteContent); + Iterator iteratorSession = voteContent.getVoteSessions().iterator(); + while (iteratorSession.hasNext()) { + VoteSession voteSession = (VoteSession) iteratorSession.next(); + logger.debug("voteSession: " + voteSession); + + if (voteSession != null) { + logger.debug("voteSession id: " + voteSession.getVoteSessionId()); + + if (voteSession.getSessionStatus().equals(COMPLETED)) { + ++countSessionComplete; } - else - { - share=0; - logger.debug("reset share"); - } - logger.debug("final share: " + share); + Iterator iteratorUser = voteSession.getVoteQueUsers().iterator(); + while (iteratorUser.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) iteratorUser.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - if(voteContent.isAllowText()) { - mapStandardNominationsContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); - mapStandardNominationsHTMLedContent.put(mapIndex.toString(), messageService.getMessage("label.open.vote")); + if (voteQueUsr != null) { + logger.debug("voteQueUsr foundid"); + ++countAllUsers; + } } - mapStandardRatesContent.put(mapIndex.toString(), new Double(share).toString()); - mapStandardUserCount.put(mapIndex.toString(), new Integer(userEnteredVotesCount).toString()); - - if (exportPortfolioDTO != null) - { - exportPortfolioDTO.setMapStandardNominationsHTMLedContent(mapStandardNominationsHTMLedContent); - exportPortfolioDTO.setMapStandardRatesContent(mapStandardRatesContent); - exportPortfolioDTO.setMapStandardUserCount(mapStandardUserCount); - exportPortfolioDTO.setMapStandardNominationsContent(mapStandardNominationsContent); - } - logger.debug("ending prepareChartDataForExportTeacher, exportPortfolioDTO: " + exportPortfolioDTO); - } + } + } + logger.debug("countAllUsers: " + countAllUsers); + logger.debug("countSessionComplete: " + countSessionComplete); - public static boolean notebookEntriesExist(IVoteService voteService, VoteContent voteContent) - { - logger.debug("finding out about content level notebook entries: " + voteContent); - Iterator iteratorSession= voteContent.getVoteSessions().iterator(); - while (iteratorSession.hasNext()) - { - VoteSession voteSession=(VoteSession) iteratorSession.next(); - logger.debug("voteSession: " + voteSession); - - if (voteSession != null) - { - logger.debug("voteSession id: " + voteSession.getVoteSessionId()); - - Iterator iteratorUser=voteSession.getVoteQueUsers().iterator(); - while (iteratorUser.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr) iteratorUser.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("voteQueUsr id: " + voteQueUsr.getQueUsrId()); - - logger.debug("attempt getting notebookEntry: "); - NotebookEntry notebookEntry = voteService.getEntry(voteSession.getVoteSessionId(), - CoreNotebookConstants.NOTEBOOK_TOOL, - MY_SIGNATURE, new Integer(voteQueUsr.getQueUsrId().intValue())); - - logger.debug("notebookEntry: " + notebookEntry); - if (notebookEntry != null) - { - logger.debug("found at least one notebookEntry: " + notebookEntry.getEntry()); - return true; - } - - } - } + voteStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString()); + voteStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); + + logger.debug("voteStatsDTO: " + voteStatsDTO); + + request.setAttribute(VOTE_STATS_DTO, voteStatsDTO); + } + + public static void generateGroupsSessionData(HttpServletRequest request, IVoteService voteService, + VoteContent voteContent) { + logger.debug("generateGroupsSessionData: " + voteContent); + + List listAllGroupsDTO = buildGroupBasedSessionData(request, voteContent, voteService); + logger.debug("listAllGroupsDTO: " + listAllGroupsDTO); + + request.setAttribute(LIST_ALL_GROUPS_DTO, listAllGroupsDTO); + } + + public static List buildGroupBasedSessionData(HttpServletRequest request, VoteContent voteContent, + IVoteService voteService) { + logger.debug("buildGroupBasedSessionData" + voteContent); + logger.debug("will be building groups question data for content:..." + voteContent); + List listQuestions = voteService.getAllQuestionEntries(voteContent.getUid()); + logger.debug("listQuestions:..." + listQuestions); + + List listAllGroupsContainerDTO = new LinkedList(); + + Iterator iteratorSession = voteContent.getVoteSessions().iterator(); + while (iteratorSession.hasNext()) { + VoteSession voteSession = (VoteSession) iteratorSession.next(); + logger.debug("iteration for group based session data: " + voteSession); + String currentSessionId = voteSession.getVoteSessionId().toString(); + logger.debug("currentSessionId: " + currentSessionId); + + String currentSessionName = voteSession.getSession_name(); + logger.debug("currentSessionName: " + currentSessionName); + + VoteAllGroupsDTO voteAllGroupsDTO = new VoteAllGroupsDTO(); + List listMonitoredAnswersContainerDTO = new LinkedList(); + + if (voteSession != null) { + Iterator itListQuestions = listQuestions.iterator(); + while (itListQuestions.hasNext()) { + VoteQueContent voteQueContent = (VoteQueContent) itListQuestions.next(); + logger.debug("voteQueContent:..." + voteQueContent); + + if (voteQueContent != null) { + logger.debug("populating VoteMonitoredAnswersDTO for : " + voteQueContent); + VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO(); + voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString()); + voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion()); + voteMonitoredAnswersDTO.setSessionId(currentSessionId); + voteMonitoredAnswersDTO.setSessionName(currentSessionName); + + Map questionAttemptData = buildGroupsAttemptData(request, voteContent, voteService, + voteQueContent, voteQueContent.getUid().toString(), true, false, currentSessionId, null); + logger.debug("generated questionAttemptData: " + questionAttemptData); + voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); + + logger.debug("adding voteMonitoredAnswersDTO to the listMonitoredAnswersContainerDTO: " + + voteMonitoredAnswersDTO); + listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); } } - return false; + } + logger.debug("listMonitoredAnswersContainerDTO:" + listMonitoredAnswersContainerDTO); + + logger.debug("adding listMonitoredAnswersContainerDTO to the voteAllGroupsDTO:" + + listMonitoredAnswersContainerDTO); + voteAllGroupsDTO.setGroupData(listMonitoredAnswersContainerDTO); + voteAllGroupsDTO.setSessionName(currentSessionName); + voteAllGroupsDTO.setSessionId(currentSessionId); + + logger.debug("built voteAllGroupsDTO:" + voteAllGroupsDTO); + listAllGroupsContainerDTO.add(voteAllGroupsDTO); + } - - - public static void buildVoteStatsDTO(HttpServletRequest request, IVoteService voteService, VoteContent voteContent) - { - logger.debug("building voteStatsDTO: " + voteContent); - VoteStatsDTO voteStatsDTO= new VoteStatsDTO(); - - int countSessionComplete=0; - int countAllUsers=0; - logger.debug("finding out about content level notebook entries: " + voteContent); - Iterator iteratorSession= voteContent.getVoteSessions().iterator(); - while (iteratorSession.hasNext()) - { - VoteSession voteSession=(VoteSession) iteratorSession.next(); - logger.debug("voteSession: " + voteSession); - - if (voteSession != null) - { - logger.debug("voteSession id: " + voteSession.getVoteSessionId()); - - if (voteSession.getSessionStatus().equals(COMPLETED)) - { - ++countSessionComplete; + + logger.debug("final listAllGroupsContainerDTO:..." + listAllGroupsContainerDTO); + return listAllGroupsContainerDTO; + } + + public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, + IVoteService voteService, VoteQueContent voteQueContent, String questionUid, boolean isUserNamesVisible, + boolean isLearnerRequest, String currentSessionId, String userId) { + logger.debug("doing buildGroupsAttemptData..."); + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("currentSessionId: " + currentSessionId); + logger.debug("userId: " + userId); + + logger.debug("voteService: " + voteService); + + Map mapMonitoredAttemptsContainerDTO = new TreeMap(new VoteStringComparator()); + List listMonitoredAttemptsContainerDTO = new LinkedList(); + + Map summaryToolSessions = populateToolSessionsId(request, voteContent, voteService); + logger.debug("summaryToolSessions: " + summaryToolSessions); + + Iterator itMap = summaryToolSessions.entrySet().iterator(); + + /*request is for monitoring summary */ + if (!isLearnerRequest) { + + if (currentSessionId != null) { + if (currentSessionId.equals("All")) { + logger.debug("**summary request is for All**:"); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + + pairs.getValue()); + + if (!(pairs.getValue().toString().equals("None")) + && !(pairs.getValue().toString().equals("All"))) { + logger + .debug("using the numerical summary tool sessions pair: " + " = " + + pairs.getValue()); + VoteSession voteSession = voteService.retrieveVoteSession(new Long(pairs.getValue() + .toString())); + logger.debug("voteSession: " + " = " + voteSession); + if (voteSession != null) { + List listUsers = voteService.getUserBySessionOnly(voteSession); + logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + + listUsers); + Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteService, + voteSession.getVoteSessionId(), listUsers, questionUid, isUserNamesVisible, + isLearnerRequest, userId); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); } - - Iterator iteratorUser=voteSession.getVoteQueUsers().iterator(); - while (iteratorUser.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr) iteratorUser.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("voteQueUsr foundid"); - ++countAllUsers; - } - } + } } + } else if (!currentSessionId.equals("All")) { + logger.debug("**summary request is for currentSessionId**:" + currentSessionId); + VoteSession voteSession = voteService.retrieveVoteSession(new Long(currentSessionId.toString())); + logger.debug("voteSession: " + " = " + voteSession); + + List listUsers = voteService.getUserBySessionOnly(voteSession); + logger.debug("listUsers: " + " = " + listUsers); + + Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteService, new Long( + currentSessionId), listUsers, questionUid, isUserNamesVisible, isLearnerRequest, userId); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); } - logger.debug("countAllUsers: " + countAllUsers); - logger.debug("countSessionComplete: " + countSessionComplete); - - - voteStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - voteStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - - logger.debug("voteStatsDTO: " + voteStatsDTO); + } + } else { + /*request is for learner report, use only the passed tool session in the report*/ + logger.debug("using currentSessionId for the learner report:" + currentSessionId); + while (itMap.hasNext()) { + Map.Entry pairs = (Map.Entry) itMap.next(); + logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - request.setAttribute(VOTE_STATS_DTO, voteStatsDTO); + if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) { + logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); + + if (currentSessionId.equals(pairs.getValue())) { + logger + .debug("only using this tool session for the learner report: " + " = " + + pairs.getValue()); + VoteSession voteSession = voteService + .retrieveVoteSession(new Long(pairs.getValue().toString())); + logger.debug("voteSession: " + " = " + voteSession); + if (voteSession != null) { + List listUsers = voteService.getUserBySessionOnly(voteSession); + logger.debug("listVoteUsers for session id:" + voteSession.getVoteSessionId() + " = " + + listUsers); + Map sessionUsersAttempts = populateSessionUsersAttempts(request, voteService, voteSession + .getVoteSessionId(), listUsers, questionUid, isUserNamesVisible, isLearnerRequest, + userId); + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + } + } + } + } } - - public static void generateGroupsSessionData(HttpServletRequest request, IVoteService voteService, VoteContent voteContent) - { - logger.debug("generateGroupsSessionData: " + voteContent); - - List listAllGroupsDTO=buildGroupBasedSessionData(request, voteContent, voteService); - logger.debug("listAllGroupsDTO: " + listAllGroupsDTO); - - request.setAttribute(LIST_ALL_GROUPS_DTO, listAllGroupsDTO); - } - - - public static List buildGroupBasedSessionData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService) - { - logger.debug("buildGroupBasedSessionData" + voteContent); - logger.debug("will be building groups question data for content:..." + voteContent); - List listQuestions=voteService.getAllQuestionEntries(voteContent.getUid()); - logger.debug("listQuestions:..." + listQuestions); - - List listAllGroupsContainerDTO= new LinkedList(); - - - Iterator iteratorSession= voteContent.getVoteSessions().iterator(); - while (iteratorSession.hasNext()) - { - VoteSession voteSession=(VoteSession) iteratorSession.next(); - logger.debug("iteration for group based session data: " + voteSession); - String currentSessionId=voteSession.getVoteSessionId().toString(); - logger.debug("currentSessionId: " + currentSessionId); - - String currentSessionName=voteSession.getSession_name(); - logger.debug("currentSessionName: " + currentSessionName); - - VoteAllGroupsDTO voteAllGroupsDTO= new VoteAllGroupsDTO(); - List listMonitoredAnswersContainerDTO= new LinkedList(); - - if (voteSession != null) - { - Iterator itListQuestions = listQuestions.iterator(); - while (itListQuestions.hasNext()) - { - VoteQueContent voteQueContent =(VoteQueContent)itListQuestions.next(); - logger.debug("voteQueContent:..." + voteQueContent); - - if (voteQueContent != null) - { - logger.debug("populating VoteMonitoredAnswersDTO for : " + voteQueContent); - VoteMonitoredAnswersDTO voteMonitoredAnswersDTO= new VoteMonitoredAnswersDTO(); - voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString()); - voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion()); - voteMonitoredAnswersDTO.setSessionId(currentSessionId); - voteMonitoredAnswersDTO.setSessionName(currentSessionName); - - Map questionAttemptData= buildGroupsAttemptData(request, voteContent, voteService, voteQueContent, voteQueContent.getUid().toString(), - true,false, currentSessionId, null); - logger.debug("generated questionAttemptData: " + questionAttemptData); - voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); - - logger.debug("adding voteMonitoredAnswersDTO to the listMonitoredAnswersContainerDTO: " + voteMonitoredAnswersDTO); - listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); - } + logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); + mapMonitoredAttemptsContainerDTO = convertToMap(listMonitoredAttemptsContainerDTO); + logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO); + return mapMonitoredAttemptsContainerDTO; + } + + public static Map populateSessionUsersAttempts(HttpServletRequest request, IVoteService voteService, + Long sessionId, List listUsers, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, + String userId) { + logger.debug("isUserNamesVisible: " + isUserNamesVisible); + logger.debug("isLearnerRequest: " + isLearnerRequest); + logger.debug("userId: " + userId); + + logger.debug("doing populateSessionUsersAttempts..."); + logger.debug("voteService: " + voteService); + + Map mapMonitoredUserContainerDTO = new TreeMap(new VoteStringComparator()); + List listMonitoredUserContainerDTO = new LinkedList(); + Iterator itUsers = listUsers.iterator(); + + if (userId == null) { + logger.debug("request is not for learner progress report"); + if ((isUserNamesVisible) && (!isLearnerRequest)) { + logger.debug("isUserNamesVisible true, isLearnerRequest false"); + logger.debug("getting alll the user' data"); + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); + + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), + new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + + String responsePresentable = VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); + logger.debug("responsePresentable: " + responsePresentable); + voteMonitoredUserDTO.setResponsePresentable(responsePresentable); + + voteMonitoredUserDTO.setQuestionUid(questionUid); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); } + } } - logger.debug("listMonitoredAnswersContainerDTO:" + listMonitoredAnswersContainerDTO); - - logger.debug("adding listMonitoredAnswersContainerDTO to the voteAllGroupsDTO:" + listMonitoredAnswersContainerDTO); - voteAllGroupsDTO.setGroupData(listMonitoredAnswersContainerDTO); - voteAllGroupsDTO.setSessionName(currentSessionName); - voteAllGroupsDTO.setSessionId(currentSessionId); - - logger.debug("built voteAllGroupsDTO:" + voteAllGroupsDTO); - listAllGroupsContainerDTO.add(voteAllGroupsDTO); - } - - - logger.debug("final listAllGroupsContainerDTO:..." + listAllGroupsContainerDTO); - return listAllGroupsContainerDTO; - } - - - public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService, VoteQueContent voteQueContent, String questionUid, - boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId) - { - logger.debug("doing buildGroupsAttemptData..."); - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - logger.debug("currentSessionId: " + currentSessionId); - logger.debug("userId: " + userId); - - - logger.debug("voteService: " + voteService); + } else if ((isUserNamesVisible) && (isLearnerRequest)) { + logger + .debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session"); + logger.debug("isUserNamesVisible true, isLearnerRequest true"); - Map mapMonitoredAttemptsContainerDTO= new TreeMap(new VoteStringComparator()); - List listMonitoredAttemptsContainerDTO= new LinkedList(); - - Map summaryToolSessions=populateToolSessionsId(request, voteContent, voteService); - logger.debug("summaryToolSessions: " + summaryToolSessions); - - Iterator itMap = summaryToolSessions.entrySet().iterator(); - - - /*request is for monitoring summary */ - if (!isLearnerRequest) - { + String userID = VoteUtils.getCurrentLearnerID(); + logger.debug("userID: " + userID); + VoteQueUsr voteQueUsr = voteService.getVoteQueUsrById(new Long(userID).longValue()); + logger + .debug("the current user voteQueUsr " + voteQueUsr + " and username: " + + voteQueUsr.getUsername()); - if (currentSessionId != null) - { - if (currentSessionId.equals("All")) - { - logger.debug("**summary request is for All**:"); - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) - { - logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); - VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString())); - logger.debug("voteSession: " + " = " + voteSession); - if (voteSession != null) - { - List listUsers=voteService.getUserBySessionOnly(voteSession); - logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request, voteService, voteSession.getVoteSessionId(), listUsers, questionUid, - isUserNamesVisible, isLearnerRequest, userId); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - } - else if (!currentSessionId.equals("All")) - { - logger.debug("**summary request is for currentSessionId**:" + currentSessionId); - VoteSession voteSession= voteService.retrieveVoteSession(new Long(currentSessionId.toString())); - logger.debug("voteSession: " + " = " + voteSession); - - List listUsers=voteService.getUserBySessionOnly(voteSession); - logger.debug("listUsers: " + " = " + listUsers); - - Map sessionUsersAttempts=populateSessionUsersAttempts(request, voteService, new Long(currentSessionId), listUsers, questionUid, - isUserNamesVisible, isLearnerRequest, userId); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - else - { - /*request is for learner report, use only the passed tool session in the report*/ - logger.debug("using currentSessionId for the learner report:" + currentSessionId); - while (itMap.hasNext()) - { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All"))) - { - logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue()); - - if (currentSessionId.equals(pairs.getValue())) - { - logger.debug("only using this tool session for the learner report: " + " = " + pairs.getValue()); - VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString())); - logger.debug("voteSession: " + " = " + voteSession); - if (voteSession != null) - { - List listUsers=voteService.getUserBySessionOnly(voteSession); - logger.debug("listVoteUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers); - Map sessionUsersAttempts=populateSessionUsersAttempts(request, voteService, voteSession.getVoteSessionId(), listUsers, questionUid, - isUserNamesVisible, isLearnerRequest, userId); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - } - } + while (itUsers.hasNext()) { + voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO); - mapMonitoredAttemptsContainerDTO=convertToMap(listMonitoredAttemptsContainerDTO); - logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO); - return mapMonitoredAttemptsContainerDTO; - } - + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), + new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); - - public static Map populateSessionUsersAttempts(HttpServletRequest request,IVoteService voteService, Long sessionId, - List listUsers, String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String userId) - { - logger.debug("isUserNamesVisible: " + isUserNamesVisible); - logger.debug("isLearnerRequest: " + isLearnerRequest); - logger.debug("userId: " + userId); - - logger.debug("doing populateSessionUsersAttempts..."); - logger.debug("voteService: " + voteService); - - Map mapMonitoredUserContainerDTO= new TreeMap(new VoteStringComparator()); - List listMonitoredUserContainerDTO= new LinkedList(); - Iterator itUsers=listUsers.iterator(); - - - if (userId == null) - { - logger.debug("request is not for learner progress report"); - if ((isUserNamesVisible) && (!isLearnerRequest)) - { - logger.debug("isUserNamesVisible true, isLearnerRequest false" ); - logger.debug("getting alll the user' data"); - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - - String responsePresentable=VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); - logger.debug("responsePresentable: " + responsePresentable); - voteMonitoredUserDTO.setResponsePresentable(responsePresentable); - - voteMonitoredUserDTO.setQuestionUid(questionUid); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + + String responsePresentable = VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); + logger.debug("responsePresentable: " + responsePresentable); + voteMonitoredUserDTO.setResponsePresentable(responsePresentable); + + voteMonitoredUserDTO.setQuestionUid(questionUid); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } } - else if ((isUserNamesVisible) && (isLearnerRequest)) - { - logger.debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session" ); - logger.debug("isUserNamesVisible true, isLearnerRequest true" ); + } + } + } else if ((!isUserNamesVisible) && (isLearnerRequest)) { + logger + .debug("populating data normally exception are for a specific session and other user names are not visible."); + logger.debug("isUserNamesVisible false, isLearnerRequest true"); + logger.debug("getting only current user's data"); - String userID = VoteUtils.getCurrentLearnerID(); - logger.debug("userID: " + userID); - VoteQueUsr voteQueUsr=voteService.getVoteQueUsrById(new Long(userID).longValue()); - logger.debug("the current user voteQueUsr " + voteQueUsr + " and username: " + voteQueUsr.getUsername()); - - while (itUsers.hasNext()) - { - voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - - String responsePresentable=VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); - logger.debug("responsePresentable: " + responsePresentable); - voteMonitoredUserDTO.setResponsePresentable(responsePresentable); - - voteMonitoredUserDTO.setQuestionUid(questionUid); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } - else if ((!isUserNamesVisible) && (isLearnerRequest)) - { - logger.debug("populating data normally exception are for a specific session and other user names are not visible."); - logger.debug("isUserNamesVisible false, isLearnerRequest true" ); - logger.debug("getting only current user's data" ); + String userID = VoteUtils.getCurrentLearnerID(); + logger.debug("userID: " + userID); - String userID = VoteUtils.getCurrentLearnerID(); - logger.debug("userID: " + userID); - - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); - - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - - logger.debug("userID versus queUsrId: " + userID + "-" + voteQueUsr.getQueUsrId()); - if (userID.equals(voteQueUsr.getQueUsrId().toString())) - { - logger.debug("this is current user, put his name normally."); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - } - else - { - logger.debug("this is not current user, put his name as blank."); - voteMonitoredUserDTO.setUserName(" "); - } - - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - - String responsePresentable=VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); - logger.debug("responsePresentable: " + responsePresentable); - voteMonitoredUserDTO.setResponsePresentable(responsePresentable); + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - voteMonitoredUserDTO.setQuestionUid(questionUid); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), + new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + + logger.debug("userID versus queUsrId: " + userID + "-" + voteQueUsr.getQueUsrId()); + if (userID.equals(voteQueUsr.getQueUsrId().toString())) { + logger.debug("this is current user, put his name normally."); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + } else { + logger.debug("this is not current user, put his name as blank."); + voteMonitoredUserDTO.setUserName(" "); } + + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + + String responsePresentable = VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); + logger.debug("responsePresentable: " + responsePresentable); + voteMonitoredUserDTO.setResponsePresentable(responsePresentable); + + voteMonitoredUserDTO.setQuestionUid(questionUid); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } + } + } } - else - { - logger.debug("request is for learner progress report: " + userId); - while (itUsers.hasNext()) - { - VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next(); - logger.debug("voteQueUsr: " + voteQueUsr); - - if (voteQueUsr != null) - { - logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid); - List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid)); - logger.debug("listUserAttempts: " + listUserAttempts); + } + } else { + logger.debug("request is for learner progress report: " + userId); + while (itUsers.hasNext()) { + VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); + logger.debug("voteQueUsr: " + voteQueUsr); - Iterator itAttempts=listUserAttempts.iterator(); - while (itAttempts.hasNext()) - { - VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next(); - logger.debug("voteUsrResp: " + voteUsrResp); - - if (voteUsrResp != null) - { - logger.debug("userID versus queUsrId: " + userId + "-" + voteQueUsr.getQueUsrId()); - if (userId.equals(voteQueUsr.getQueUsrId().toString())) - { - logger.debug("this is the user requested , include his name for learner progress."); - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); - //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); - voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); - voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); - voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); - voteMonitoredUserDTO.setSessionId(sessionId.toString()); - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - - String responsePresentable=VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); - logger.debug("responsePresentable: " + responsePresentable); - voteMonitoredUserDTO.setResponsePresentable(responsePresentable); - - voteMonitoredUserDTO.setQuestionUid(questionUid); - voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } - + if (voteQueUsr != null) { + logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + + " and que content id: " + questionUid); + List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), + new Long(questionUid)); + logger.debug("listUserAttempts: " + listUserAttempts); + + Iterator itAttempts = listUserAttempts.iterator(); + while (itAttempts.hasNext()) { + VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); + logger.debug("voteUsrResp: " + voteUsrResp); + + if (voteUsrResp != null) { + logger.debug("userID versus queUsrId: " + userId + "-" + voteQueUsr.getQueUsrId()); + if (userId.equals(voteQueUsr.getQueUsrId().toString())) { + logger.debug("this is the user requested , include his name for learner progress."); + VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); + voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime()); + //voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimezone()); + voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString()); + voteMonitoredUserDTO.setUserName(voteQueUsr.getFullname()); + voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString()); + voteMonitoredUserDTO.setSessionId(sessionId.toString()); + voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); + + String responsePresentable = VoteUtils.replaceNewLines(voteUsrResp.getUserEntry()); + logger.debug("responsePresentable: " + responsePresentable); + voteMonitoredUserDTO.setResponsePresentable(responsePresentable); + + voteMonitoredUserDTO.setQuestionUid(questionUid); + voteMonitoredUserDTO.setVisible(new Boolean(voteUsrResp.isVisible()).toString()); + listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); + } + } + } } - - - logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); - mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); - logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); - return mapMonitoredUserContainerDTO; + } + } - - public static Map convertToMcMonitoredUserDTOMap(List list) - { - logger.debug("using convertToVoteMonitoredUserDTOMap: " + list); - Map map= new TreeMap(new VoteStringComparator()); - - Iterator listIterator=list.iterator(); - Long mapIndex=new Long(1); - - while (listIterator.hasNext()) - { - VoteMonitoredUserDTO data=(VoteMonitoredUserDTO)listIterator.next(); - map.put(mapIndex.toString(), data); - mapIndex=new Long(mapIndex.longValue()+1); - } - return map; + logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO); + mapMonitoredUserContainerDTO = convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO); + logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO); + return mapMonitoredUserContainerDTO; + } + + public static Map convertToMcMonitoredUserDTOMap(List list) { + logger.debug("using convertToVoteMonitoredUserDTOMap: " + list); + Map map = new TreeMap(new VoteStringComparator()); + + Iterator listIterator = list.iterator(); + Long mapIndex = new Long(1); + + while (listIterator.hasNext()) { + VoteMonitoredUserDTO data = (VoteMonitoredUserDTO) listIterator.next(); + map.put(mapIndex.toString(), data); + mapIndex = new Long(mapIndex.longValue() + 1); } - + return map; + } + } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java,v diff -u -r1.48 -r1.49 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java 13 May 2008 07:23:20 -0000 1.48 +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningAction.java 18 Feb 2009 23:06:58 -0000 1.49 @@ -26,8 +26,8 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import java.util.Set; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -61,1023 +61,938 @@ import org.lamsfoundation.lams.tool.vote.service.IVoteService; import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; -import org.lamsfoundation.lams.util.MessageService; /** - *Action class that controls the logic of tool behavior.
+ *+ * Action class that controls the logic of tool behavior. + *
* - *Note that Struts action class only has the responsibility to navigate - * page flow. All database operation should go to service layer and data - * transformation from domain model to struts form bean should go to form - * bean class. This ensure clean and maintainable code. + *
+ * Note that Struts action class only has the responsibility to navigate page + * flow. All database operation should go to service layer and data + * transformation from domain model to struts form bean should go to form bean + * class. This ensure clean and maintainable code. *
* *SystemException
is thrown whenever an known error condition is
- * identified. No system exception error handling code should appear in the
- * Struts action class as all of them are handled in
+ * identified. No system exception error handling code should appear in the
+ * Struts action class as all of them are handled in
* CustomStrutsExceptionHandler.
*
* @author Ozgur Demirtas
*
*
-
-
-
-
-
-
+
+
-
-
-
-
+
-
+
-
-
+
-
+
-
+
-
-
-
+
-
-
+
- *
-*/
-public class VoteLearningAction extends LamsDispatchAction implements VoteAppConstants
-{
- static Logger logger = Logger.getLogger(VoteLearningAction.class.getName());
-
- /**
- * Default struts dispatch method.
+
+
+
+
+
+
+
+
+
+
+
+ *
+ */
+public class VoteLearningAction extends LamsDispatchAction implements VoteAppConstants {
+ static Logger logger = Logger.getLogger(VoteLearningAction.class.getName());
+
+ /**
+ *
+ * Default struts dispatch method.
+ *
*
- * It is assuming that progress engine should pass in the tool access
- * mode and the tool session id as http parameters.
+ *
+ * It is assuming that progress engine should pass in the tool access mode
+ * and the tool session id as http parameters.
+ *
*
- * @param mapping An ActionMapping class that will be used by the Action class to tell
- * the ActionServlet where to send the end-user.
- *
- * @param form The ActionForm class that will contain any data submitted
- * by the end-user via a form.
- * @param request A standard Servlet HttpServletRequest class.
- * @param response A standard Servlet HttpServletResponse class.
- * @return An ActionForward class that will be returned to the ActionServlet indicating where
- * the user is to go next.
+ * @param mapping
+ * An ActionMapping class that will be used by the Action
+ * class to tell the ActionServlet where to send the
+ * end-user.
+ *
+ * @param form
+ * The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request
+ * A standard Servlet HttpServletRequest class.
+ * @param response
+ * A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet
+ * indicating where the user is to go next.
* @throws IOException
* @throws ServletException
- * @throws VoteApplicationException the known runtime exception
+ * @throws VoteApplicationException
+ * the known runtime exception
*
- * unspecified(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
-
- * main content/question content management and workflow logic
- *
- * if the passed toolContentID exists in the db, we need to get the relevant data into the Map
- * if not, create the default Map
- */
- public ActionForward unspecified(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
-
- repopulateRequestParameters(request,voteLearningForm);
-
- VoteUtils.cleanUpUserExceptions(request);
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
- return null;
+ * unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest
+ * request, HttpServletResponse response) throws IOException,
+ * ServletException
+ *
+ * main content/question content management and workflow logic
+ *
+ * if the passed toolContentID exists in the db, we need to get the relevant
+ * data into the Map if not, create the default Map
+ */
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+
+ repopulateRequestParameters(request, voteLearningForm);
+
+ VoteUtils.cleanUpUserExceptions(request);
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
+ return null;
}
-
- public ActionForward viewAllResults(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- VoteUtils.cleanUpUserExceptions(request);
- logger.debug("dispatching viewAllResults...");
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
-
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ public ActionForward viewAllResults(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ VoteUtils.cleanUpUserExceptions(request);
+ logger.debug("dispatching viewAllResults...");
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
- repopulateRequestParameters(request,voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
-
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
- Long toolContentID=voteContent.getVoteContentId();
- logger.debug("toolContentID: " + toolContentID);
-
- setContentInUse(request,voteService, toolContentID);
-
-
- Long toolSessionUid=voteSession.getUid();
- logger.debug("toolSessionUid: " + toolSessionUid);
-
- VoteQueUsr existingVoteQueUsr=voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
- logger.debug("existingVoteQueUsr: " + existingVoteQueUsr);
-
- existingVoteQueUsr.setFinalScreenRequested(true);
- voteService.updateVoteUser(existingVoteQueUsr);
- logger.debug("final screen requested by: " + existingVoteQueUsr);
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
- Set userAttempts=voteService.getAttemptsForUserAndSession(existingVoteQueUsr.getUid(), toolSessionUid);
- logger.debug("userAttempts: "+ userAttempts);
- request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts);
-
- request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts);
- Set userEntries = voteService.getSessionUserEntriesSet(new Long(voteSession.getUid()));
-
- logger.debug("voteSession uid:" + voteSession.getUid());
- logger.debug("calling prepareChartData:" + voteContent.getVoteContentId() + " " + voteSession.getUid());
+ repopulateRequestParameters(request, voteLearningForm);
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO();
- MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(),
- voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService());
- logger.debug("end of prepareChartData:" + voteContent.getVoteContentId() + " " + voteSession.getUid());
-
- voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
- String reflectionSubject=VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
- voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- voteLearningForm.resetCommands();
-
- logger.debug("view-only voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
-
- logger.debug("fwding to ALL_NOMINATIONS: "+ ALL_NOMINATIONS);
- return (mapping.findForward(ALL_NOMINATIONS));
- }
-
-
- public ActionForward viewAnswers(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- VoteUtils.cleanUpUserExceptions(request);
- logger.debug("dispatching viewAnswers...");
-
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
-
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
- repopulateRequestParameters(request,voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- String revisitingUser=request.getParameter(REVISITING_USER);
- logger.debug("revisitingUser: " + revisitingUser);
- voteLearningForm.setRevisitingUser(revisitingUser);
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
-
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
-
- Long toolContentID=voteContent.getVoteContentId();
- logger.debug("toolContentID: " + toolContentID);
-
- setContentInUse(request, voteService, toolContentID);
-
- if (revisitingUser.equals("true"))
- {
- logger.debug("this is a revisiting user, get the nominations from the db: " + revisitingUser);
- logger.debug("toolContentID: " + toolContentID);
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
- VoteQueUsr voteQueUsr=LearningUtil.getUser(request, voteService);
- logger.debug("voteQueUsr: " + voteQueUsr);
+ Long toolContentID = voteContent.getVoteContentId();
+ logger.debug("toolContentID: " + toolContentID);
- List attempts=voteService.getAttemptsForUser(voteQueUsr.getUid());
- logger.debug("attempts: " + attempts);
-
- Map mapQuestionsContent= new TreeMap(new VoteComparator());
- Iterator listIterator=attempts.iterator();
- int order=0;
- while (listIterator.hasNext())
- {
- VoteUsrAttempt attempt=(VoteUsrAttempt)listIterator.next();
- logger.debug("attempt: " + attempt);
- VoteQueContent voteQueContent=attempt.getVoteQueContent();
- logger.debug("voteQueContent: " + voteQueContent);
- order++;
- if (voteQueContent != null)
- {
- mapQuestionsContent.put(new Integer(order).toString(),voteQueContent.getQuestion());
- }
- }
- request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapQuestionsContent);
- }
- else
- {
- logger.debug("this is not a revisiting user: " + revisitingUser);
- }
-
- voteLearningForm.resetCommands();
-
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
-
- logger.debug("fwd'ing to : " + VIEW_ANSWERS);
- return (mapping.findForward(VIEW_ANSWERS));
+ setContentInUse(request, voteService, toolContentID);
+
+ Long toolSessionUid = voteSession.getUid();
+ logger.debug("toolSessionUid: " + toolSessionUid);
+
+ VoteQueUsr existingVoteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
+ logger.debug("existingVoteQueUsr: " + existingVoteQueUsr);
+
+ existingVoteQueUsr.setFinalScreenRequested(true);
+ voteService.updateVoteUser(existingVoteQueUsr);
+ logger.debug("final screen requested by: " + existingVoteQueUsr);
+
+ Set userAttempts = voteService.getAttemptsForUserAndSession(existingVoteQueUsr.getUid(), toolSessionUid);
+ logger.debug("userAttempts: " + userAttempts);
+ request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts);
+
+ request.setAttribute(LIST_GENERAL_CHECKED_OPTIONS_CONTENT, userAttempts);
+
+ logger.debug("voteSession uid:" + voteSession.getUid());
+ logger.debug("calling prepareChartData:" + voteContent.getVoteContentId() + " " + voteSession.getUid());
+
+ VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
+ MonitoringUtil.prepareChartData(request, voteService, null, voteContent.getVoteContentId().toString(),
+ voteSession.getUid().toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO,
+ getMessageService());
+ logger.debug("end of prepareChartData:" + voteContent.getVoteContentId() + " " + voteSession.getUid());
+
+ voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
+ String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
+ voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
+
+ voteLearningForm.resetCommands();
+
+ logger.debug("view-only voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+
+ logger.debug("fwding to ALL_NOMINATIONS: " + ALL_NOMINATIONS);
+ return (mapping.findForward(ALL_NOMINATIONS));
}
-
-
- public ActionForward redoQuestionsOk(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- VoteUtils.cleanUpUserExceptions(request);
- logger.debug("dispatching redoQuestionsOk...");
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ public ActionForward viewAnswers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ VoteUtils.cleanUpUserExceptions(request);
+ logger.debug("dispatching viewAnswers...");
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
- repopulateRequestParameters(request,voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- String revisitingUser=request.getParameter(REVISITING_USER);
- logger.debug("revisitingUser: " + revisitingUser);
- voteLearningForm.setRevisitingUser(revisitingUser);
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
-
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
-
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
- Long toolContentID=voteContent.getVoteContentId();
- logger.debug("toolContentID: " + toolContentID);
-
- setContentInUse(request, voteService, toolContentID);
- logger.debug("requested redoQuestionsOk, user is sure to redo the questions.");
+ repopulateRequestParameters(request, voteLearningForm);
- voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
- String reflectionSubject=VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
- voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- voteLearningForm.resetCommands();
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
- return redoQuestions(mapping, form, request, response);
- }
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
- public ActionForward learnerFinished(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- logger.debug("dispatching learnerFinished");
- logger.debug("requested learner finished, the learner should be directed to next activity.");
+ String revisitingUser = request.getParameter(REVISITING_USER);
+ logger.debug("revisitingUser: " + revisitingUser);
+ voteLearningForm.setRevisitingUser(revisitingUser);
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
-
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
-
- repopulateRequestParameters(request,voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- VoteQueUsr voteQueUsr=voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
- logger.debug("voteQueUsr:" + voteQueUsr);
-
-
- /* it is possible that voteQueUsr can be null if the content is set as runoffline and reflection is on*/
- if (voteQueUsr == null)
- {
- logger.debug("attempt creating user record since it must exist for the runOffline + reflection screens");
- HttpSession ss = SessionManager.getSession();
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
- logger.debug("retrieving toolUser: " + toolUser);
- logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
- logger.debug("retrieving toolUser username: " + toolUser.getLogin());
+ Long toolContentID = voteContent.getVoteContentId();
+ logger.debug("toolContentID: " + toolContentID);
- String userName=toolUser.getLogin();
- String fullName= toolUser.getFirstName() + " " + toolUser.getLastName();
- logger.debug("retrieving toolUser fullname: " + fullName);
-
- Long userId=new Long(toolUser.getUserID().longValue());
- logger.debug("retrieving toolUser fullname: " + fullName);
-
- voteQueUsr= new VoteQueUsr(new Long(userID),
- userName,
- fullName,
- voteSession,
- new TreeSet());
- voteService.createVoteQueUsr(voteQueUsr);
- logger.debug("createVoteQueUsr - voteQueUsr: " + voteQueUsr);
- logger.debug("session uid: " + voteSession.getUid());
- }
+ setContentInUse(request, voteService, toolContentID);
-
- voteQueUsr.setResponseFinalised(true);
- if ( ! voteSession.getVoteContent().isShowResults() ) {
- // if not isShowResults then we will have skipped the final screen.
- voteQueUsr.setFinalScreenRequested(true);
- }
- voteService.updateVoteUser(voteQueUsr);
- logger.debug("user's response is finalised:" + voteQueUsr);
-
- String revisitingUser=request.getParameter(REVISITING_USER);
- logger.debug("revisitingUser: " + revisitingUser);
- voteLearningForm.setRevisitingUser(revisitingUser);
-
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
-
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ if (revisitingUser.equals("true")) {
+ logger.debug("this is a revisiting user, get the nominations from the db: " + revisitingUser);
+ logger.debug("toolContentID: " + toolContentID);
- logger.debug("attempting to leave/complete session with toolSessionID:" + toolSessionID + " and userID:"+userID);
-
- voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
- String reflectionSubject=VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
- voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
+ VoteQueUsr voteQueUsr = LearningUtil.getUser(request, voteService);
+ logger.debug("voteQueUsr: " + voteQueUsr);
-
- VoteUtils.cleanUpSessionAbsolute(request);
-
- String nextUrl=null;
- try
- {
- nextUrl=voteService.leaveToolSession(new Long(toolSessionID), new Long(userID));
- logger.debug("nextUrl: "+ nextUrl);
+ List attempts = voteService.getAttemptsForUser(voteQueUsr.getUid());
+ logger.debug("attempts: " + attempts);
+
+ Map mapQuestionsContent = new TreeMap(new VoteComparator());
+ Iterator listIterator = attempts.iterator();
+ int order = 0;
+ while (listIterator.hasNext()) {
+ VoteUsrAttempt attempt = (VoteUsrAttempt) listIterator.next();
+ logger.debug("attempt: " + attempt);
+ VoteQueContent voteQueContent = attempt.getVoteQueContent();
+ logger.debug("voteQueContent: " + voteQueContent);
+ order++;
+ if (voteQueContent != null) {
+ mapQuestionsContent.put(new Integer(order).toString(), voteQueContent.getQuestion());
}
- catch (DataMissingException e)
- {
- logger.debug("failure getting nextUrl: "+ e);
- voteLearningForm.resetCommands();
- //throw new ServletException(e);
- return (mapping.findForward(LEARNING_STARTER));
- }
- catch (ToolException e)
- {
- logger.debug("failure getting nextUrl: "+ e);
- voteLearningForm.resetCommands();
- //throw new ServletException(e);
- return (mapping.findForward(LEARNING_STARTER));
- }
- catch (Exception e)
- {
- logger.debug("unknown exception getting nextUrl: "+ e);
- voteLearningForm.resetCommands();
- //throw new ServletException(e);
- return (mapping.findForward(LEARNING_STARTER));
- }
+ }
+ request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapQuestionsContent);
+ } else {
+ logger.debug("this is not a revisiting user: " + revisitingUser);
+ }
- logger.debug("success getting nextUrl: "+ nextUrl);
- voteLearningForm.resetCommands();
-
- /* pay attention here*/
- logger.debug("redirecting to the nextUrl: "+ nextUrl);
- response.sendRedirect(nextUrl);
-
- return null;
+ voteLearningForm.resetCommands();
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+
+ logger.debug("fwd'ing to : " + VIEW_ANSWERS);
+ return (mapping.findForward(VIEW_ANSWERS));
}
- public ActionForward continueOptionsCombined(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- VoteUtils.cleanUpUserExceptions(request);
- logger.debug("dispatching continueOptionsCombined...");
-
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ public ActionForward redoQuestionsOk(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ VoteUtils.cleanUpUserExceptions(request);
+ logger.debug("dispatching redoQuestionsOk...");
- repopulateRequestParameters(request,voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- String maxNominationCount=request.getParameter(MAX_NOMINATION_COUNT);
- logger.debug("maxNominationCount: " + maxNominationCount);
- voteLearningForm.setMaxNominationCount(maxNominationCount);
-
- String userEntry=request.getParameter(USER_ENTRY);
- logger.debug("userEntry: " + userEntry);
- voteLearningForm.setUserEntry(userEntry);
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
+ repopulateRequestParameters(request, voteLearningForm);
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
-
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
- Collection voteDisplayOrderIds = voteLearningForm.votesAsCollection();
- logger.debug("Checkbox votes "+voteDisplayOrderIds);
-
- // check number of votes
- int castVoteCount= voteDisplayOrderIds!=null ? voteDisplayOrderIds.size() : 0;
- logger.debug("userEntry: " + userEntry);
-
- if ((userEntry != null) && (userEntry.length() > 0))
- {
- logger.debug("userEntry available: " + userEntry);
- ++castVoteCount;
- }
- logger.debug("castVoteCount post user entry count: " + castVoteCount);
- logger.debug("maxNominationCount: " + maxNominationCount);
-
- int intMaxNominationCount=0;
- if (maxNominationCount != null)
- intMaxNominationCount=new Integer(maxNominationCount).intValue();
- logger.debug("intMaxNominationCount: " + intMaxNominationCount);
- logger.debug("intMaxNominationCount versus current voting count: " + intMaxNominationCount + " versus " + castVoteCount );
+ String revisitingUser = request.getParameter(REVISITING_USER);
+ logger.debug("revisitingUser: " + revisitingUser);
+ voteLearningForm.setRevisitingUser(revisitingUser);
- if (castVoteCount > intMaxNominationCount )
- {
- voteLearningForm.setMaxNominationCountReached(new Boolean(true).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(true).toString());
- persistInRequestError(request, "error.maxNominationCount.reached");
- logger.debug("give warning, max nom count reached...");
- logger.debug("fwd'ing to: " + LOAD_LEARNER);
- return (mapping.findForward(LOAD_LEARNER));
- }
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
- Long toolContentID=voteContent.getVoteContentId();
- logger.debug("toolContentID: " + toolContentID);
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
- Long toolContentUID=voteContent.getUid();
- logger.debug("toolContentUID: " + toolContentUID);
- logger.debug("userEntry: " + userEntry);
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
- setContentInUse(request,voteService, toolContentID);
+ Long toolContentID = voteContent.getVoteContentId();
+ logger.debug("toolContentID: " + toolContentID);
- boolean userEntryAvailable=false;
- if ((userEntry != null) && (userEntry.length() > 0))
- {
- logger.debug("userEntry available: " + userEntry);
- userEntryAvailable=true;
- }
- logger.debug("userEntryAvailable " + userEntryAvailable);
+ setContentInUse(request, voteService, toolContentID);
+ logger.debug("requested redoQuestionsOk, user is sure to redo the questions.");
- Long toolSessionUid=voteSession.getUid();
- logger.debug("toolSessionUid: " + toolSessionUid);
+ voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
+ String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
+ voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- boolean isUserDefined=false;
- logger.debug("userID: " + userID);
- VoteQueUsr existingVoteQueUsr=voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
- logger.debug("existingVoteQueUsr: " + existingVoteQueUsr);
-
- if (existingVoteQueUsr != null)
- isUserDefined=true;
-
- logger.debug("isUserDefined: " + isUserDefined);
-
-
- VoteQueUsr voteQueUsr=null;
- if (isUserDefined == false)
- {
- voteQueUsr=LearningUtil.createUser(request, voteService, new Long(toolSessionID));
- logger.debug("created user in the db");
- logger.debug("new create");
- }
- else
- {
- voteQueUsr=existingVoteQueUsr;
- logger.debug("assign");
- }
-
- logger.debug("voteQueUsr: " + voteQueUsr);
- logger.debug("voteQueUsr is : " + voteQueUsr);
-
- if (existingVoteQueUsr != null)
- {
- logger.debug("attempt removing attempts for user id and session id:" + existingVoteQueUsr.getUid() + " " + voteSession.getUid() );
- voteService.removeAttemptsForUserandSession(existingVoteQueUsr.getUid(), voteSession.getUid());
- logger.debug("votes deleted for user: " + voteQueUsr.getUid());
- }
-
- /* to mimize changes to working code, convert the String[] array to the mapGeneralCheckedOptionsContent structure */
- Map mapGeneralCheckedOptionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, voteDisplayOrderIds);
- logger.debug("mapGeneralCheckedOptionsContent size: " + mapGeneralCheckedOptionsContent.size());
-
- if (mapGeneralCheckedOptionsContent.size() > 0)
- {
- LearningUtil.createAttempt(request, voteService, voteQueUsr, mapGeneralCheckedOptionsContent,
- userEntry, false, voteSession, toolContentUID);
- }
-
-
- if ((mapGeneralCheckedOptionsContent.size() == 0 && (userEntryAvailable == true)))
- {
- logger.debug("mapGeneralCheckedOptionsContent size is 0");
- Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator());
-
- logger.debug("after mapsize check mapLeanerCheckedOptionsContent " + mapLeanerCheckedOptionsContent);
- if (userEntry.length() > 0)
- {
- logger.debug("creating entry for: " + userEntry);
- LearningUtil.createAttempt(request, voteService, voteQueUsr, mapLeanerCheckedOptionsContent, userEntry,
- true, voteSession, toolContentUID);
- }
- }
-
- if ((mapGeneralCheckedOptionsContent.size() > 0) && (userEntryAvailable == true))
- {
- logger.debug("mapGeneralCheckedOptionsContent size is > 0" + userEntry);
- Map mapLeanerCheckedOptionsContent= new TreeMap(new VoteComparator());
-
- logger.debug("after mapsize check mapLeanerCheckedOptionsContent " + mapLeanerCheckedOptionsContent);
- if (userEntry.length() > 0)
- {
- logger.debug("creating entry for: " + userEntry);
- LearningUtil.createAttempt(request, voteService, voteQueUsr, mapLeanerCheckedOptionsContent, userEntry,
- false, voteSession, toolContentUID);
- }
- }
-
-
- logger.debug("created user attempt in the db");
-
- /* put the map in the request ready for the next screen */
- request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent);
- logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent);
- voteLearningForm.setMapGeneralCheckedOptionsContent(mapGeneralCheckedOptionsContent);
- voteGeneralLearnerFlowDTO.setMapGeneralCheckedOptionsContent(mapGeneralCheckedOptionsContent);
-
- voteLearningForm.setNominationsSubmited(new Boolean(true).toString());
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(true).toString());
-
- VoteGeneralMonitoringDTO voteGeneralMonitoringDTO=new VoteGeneralMonitoringDTO();
- logger.debug("calling prepareChartData: " + toolContentID);
- MonitoringUtil.prepareChartData(request, voteService, null, toolContentID.toString(), toolSessionUid.toString(),
- voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService());
-
- voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
- voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject());
-
- logger.debug("fwding to INDIVIDUAL_REPORT: " + INDIVIDUAL_REPORT);
- voteLearningForm.resetCommands();
-
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
+ voteLearningForm.resetCommands();
- return (mapping.findForward(INDIVIDUAL_REPORT));
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+ return redoQuestions(mapping, form, request, response);
}
- public ActionForward redoQuestions(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- logger.debug("dispatching redoQuestions...");
- VoteUtils.cleanUpUserExceptions(request);
+ public ActionForward learnerFinished(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ logger.debug("dispatching learnerFinished");
+ logger.debug("requested learner finished, the learner should be directed to next activity.");
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("retrieving voteService from session: " + voteService);
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- repopulateRequestParameters(request, voteLearningForm);
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- String revisitingUser=request.getParameter(REVISITING_USER);
- logger.debug("revisitingUser: " + revisitingUser);
- voteLearningForm.setRevisitingUser(revisitingUser);
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("retrieving voteContent: " + voteContent);
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
- voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
- voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
- voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
-
- voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
- voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+ repopulateRequestParameters(request, voteLearningForm);
- Long toolContentID=voteContent.getVoteContentId();
- logger.debug("toolContentID:" + toolContentID);
-
- Map mapQuestionsContent= new TreeMap(new VoteComparator());
- mapQuestionsContent=LearningUtil.buildQuestionContentMap(request, voteService, voteContent,null);
- logger.debug("mapQuestionsContent: " + mapQuestionsContent);
-
- request.setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
- logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getAttribute(MAP_QUESTION_CONTENT_LEARNER));
- logger.debug("voteContent has : " + mapQuestionsContent.size() + " entries.");
-
- Map mapGeneralCheckedOptionsContent= new TreeMap(new VoteComparator());
- request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent);
-
- voteLearningForm.setUserEntry("");
-
- voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
- voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject());
-
- logger.debug("fwd'ing to LOAD_LEARNER : " + LOAD_LEARNER);
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
+
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
+
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ VoteQueUsr voteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
+ logger.debug("voteQueUsr:" + voteQueUsr);
+
+ /* it is possible that voteQueUsr can be null if the content is set as runoffline and reflection is on*/
+ if (voteQueUsr == null) {
+ logger.debug("attempt creating user record since it must exist for the runOffline + reflection screens");
+ HttpSession ss = SessionManager.getSession();
+
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ logger.debug("retrieving toolUser: " + toolUser);
+ logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
+ logger.debug("retrieving toolUser username: " + toolUser.getLogin());
+
+ String userName = toolUser.getLogin();
+ String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
+ logger.debug("retrieving toolUser fullname: " + fullName);
+
+ Long userId = new Long(toolUser.getUserID().longValue());
+ logger.debug("retrieving toolUser fullname: " + fullName);
+
+ voteQueUsr = new VoteQueUsr(new Long(userID), userName, fullName, voteSession, new TreeSet());
+ voteService.createVoteQueUsr(voteQueUsr);
+ logger.debug("createVoteQueUsr - voteQueUsr: " + voteQueUsr);
+ logger.debug("session uid: " + voteSession.getUid());
+ }
+
+ voteQueUsr.setResponseFinalised(true);
+ if (!voteSession.getVoteContent().isShowResults()) {
+ // if not isShowResults then we will have skipped the final screen.
+ voteQueUsr.setFinalScreenRequested(true);
+ }
+ voteService.updateVoteUser(voteQueUsr);
+ logger.debug("user's response is finalised:" + voteQueUsr);
+
+ String revisitingUser = request.getParameter(REVISITING_USER);
+ logger.debug("revisitingUser: " + revisitingUser);
+ voteLearningForm.setRevisitingUser(revisitingUser);
+
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
+
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+
+ logger.debug("attempting to leave/complete session with toolSessionID:" + toolSessionID + " and userID:"
+ + userID);
+
+ voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
+ String reflectionSubject = VoteUtils.replaceNewLines(voteContent.getReflectionSubject());
+ voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
+
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+
+ VoteUtils.cleanUpSessionAbsolute(request);
+
+ String nextUrl = null;
+ try {
+ nextUrl = voteService.leaveToolSession(new Long(toolSessionID), new Long(userID));
+ logger.debug("nextUrl: " + nextUrl);
+ } catch (DataMissingException e) {
+ logger.debug("failure getting nextUrl: " + e);
voteLearningForm.resetCommands();
-
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO,voteGeneralLearnerFlowDTO);
+ //throw new ServletException(e);
+ return (mapping.findForward(LEARNING_STARTER));
+ } catch (ToolException e) {
+ logger.debug("failure getting nextUrl: " + e);
+ voteLearningForm.resetCommands();
+ //throw new ServletException(e);
+ return (mapping.findForward(LEARNING_STARTER));
+ } catch (Exception e) {
+ logger.debug("unknown exception getting nextUrl: " + e);
+ voteLearningForm.resetCommands();
+ //throw new ServletException(e);
+ return (mapping.findForward(LEARNING_STARTER));
+ }
+ logger.debug("success getting nextUrl: " + nextUrl);
+ voteLearningForm.resetCommands();
+
+ /* pay attention here*/
+ logger.debug("redirecting to the nextUrl: " + nextUrl);
+ response.sendRedirect(nextUrl);
+
+ return null;
+
+ }
+
+ public ActionForward continueOptionsCombined(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ VoteUtils.cleanUpUserExceptions(request);
+ logger.debug("dispatching continueOptionsCombined...");
+
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+
+ repopulateRequestParameters(request, voteLearningForm);
+
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
+
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ String maxNominationCount = request.getParameter(MAX_NOMINATION_COUNT);
+ logger.debug("maxNominationCount: " + maxNominationCount);
+ voteLearningForm.setMaxNominationCount(maxNominationCount);
+
+ String userEntry = request.getParameter(USER_ENTRY);
+ logger.debug("userEntry: " + userEntry);
+ voteLearningForm.setUserEntry(userEntry);
+
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
+
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
+
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+
+ Collection voteDisplayOrderIds = voteLearningForm.votesAsCollection();
+ logger.debug("Checkbox votes " + voteDisplayOrderIds);
+
+ // check number of votes
+ int castVoteCount = voteDisplayOrderIds != null ? voteDisplayOrderIds.size() : 0;
+ logger.debug("userEntry: " + userEntry);
+
+ if ((userEntry != null) && (userEntry.length() > 0)) {
+ logger.debug("userEntry available: " + userEntry);
+ ++castVoteCount;
+ }
+ logger.debug("castVoteCount post user entry count: " + castVoteCount);
+ logger.debug("maxNominationCount: " + maxNominationCount);
+
+ int intMaxNominationCount = 0;
+ if (maxNominationCount != null)
+ intMaxNominationCount = new Integer(maxNominationCount).intValue();
+ logger.debug("intMaxNominationCount: " + intMaxNominationCount);
+ logger.debug("intMaxNominationCount versus current voting count: " + intMaxNominationCount + " versus "
+ + castVoteCount);
+
+ if (castVoteCount > intMaxNominationCount) {
+ voteLearningForm.setMaxNominationCountReached(new Boolean(true).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(true).toString());
+ persistInRequestError(request, "error.maxNominationCount.reached");
+ logger.debug("give warning, max nom count reached...");
+ logger.debug("fwd'ing to: " + LOAD_LEARNER);
return (mapping.findForward(LOAD_LEARNER));
- }
+ }
-
-
- protected void setContentInUse(HttpServletRequest request, IVoteService voteService, Long toolContentID)
- {
- logger.debug("toolContentID:" + toolContentID);
-
- VoteContent voteContent=voteService.retrieveVote(toolContentID);
- logger.debug("voteContent:" + voteContent);
- voteContent.setContentInUse(true);
- logger.debug("content has been set to inuse");
- voteService.saveVoteContent(voteContent);
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
+
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+
+ Long toolContentID = voteContent.getVoteContentId();
+ logger.debug("toolContentID: " + toolContentID);
+
+ Long toolContentUID = voteContent.getUid();
+ logger.debug("toolContentUID: " + toolContentUID);
+ logger.debug("userEntry: " + userEntry);
+
+ setContentInUse(request, voteService, toolContentID);
+
+ boolean userEntryAvailable = false;
+ if ((userEntry != null) && (userEntry.length() > 0)) {
+ logger.debug("userEntry available: " + userEntry);
+ userEntryAvailable = true;
+ }
+ logger.debug("userEntryAvailable " + userEntryAvailable);
+
+ Long toolSessionUid = voteSession.getUid();
+ logger.debug("toolSessionUid: " + toolSessionUid);
+
+ boolean isUserDefined = false;
+ logger.debug("userID: " + userID);
+ VoteQueUsr existingVoteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
+ logger.debug("existingVoteQueUsr: " + existingVoteQueUsr);
+
+ if (existingVoteQueUsr != null)
+ isUserDefined = true;
+
+ logger.debug("isUserDefined: " + isUserDefined);
+
+ VoteQueUsr voteQueUsr = null;
+ if (isUserDefined == false) {
+ voteQueUsr = LearningUtil.createUser(request, voteService, new Long(toolSessionID));
+ logger.debug("created user in the db");
+ logger.debug("new create");
+ } else {
+ voteQueUsr = existingVoteQueUsr;
+ logger.debug("assign");
+ }
+
+ logger.debug("voteQueUsr: " + voteQueUsr);
+ logger.debug("voteQueUsr is : " + voteQueUsr);
+
+ if (existingVoteQueUsr != null) {
+ logger.debug("attempt removing attempts for user id and session id:" + existingVoteQueUsr.getUid() + " "
+ + voteSession.getUid());
+ voteService.removeAttemptsForUserandSession(existingVoteQueUsr.getUid(), voteSession.getUid());
+ logger.debug("votes deleted for user: " + voteQueUsr.getUid());
+ }
+
+ /* to mimize changes to working code, convert the String[] array to the mapGeneralCheckedOptionsContent structure */
+ Map mapGeneralCheckedOptionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent,
+ voteDisplayOrderIds);
+ logger.debug("mapGeneralCheckedOptionsContent size: " + mapGeneralCheckedOptionsContent.size());
+
+ if (mapGeneralCheckedOptionsContent.size() > 0) {
+ LearningUtil.createAttempt(request, voteService, voteQueUsr, mapGeneralCheckedOptionsContent, userEntry,
+ false, voteSession, toolContentUID);
+ }
+
+ if ((mapGeneralCheckedOptionsContent.size() == 0 && (userEntryAvailable == true))) {
+ logger.debug("mapGeneralCheckedOptionsContent size is 0");
+ Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator());
+
+ logger.debug("after mapsize check mapLeanerCheckedOptionsContent " + mapLeanerCheckedOptionsContent);
+ if (userEntry.length() > 0) {
+ logger.debug("creating entry for: " + userEntry);
+ LearningUtil.createAttempt(request, voteService, voteQueUsr, mapLeanerCheckedOptionsContent, userEntry,
+ true, voteSession, toolContentUID);
+ }
+ }
+
+ if ((mapGeneralCheckedOptionsContent.size() > 0) && (userEntryAvailable == true)) {
+ logger.debug("mapGeneralCheckedOptionsContent size is > 0" + userEntry);
+ Map mapLeanerCheckedOptionsContent = new TreeMap(new VoteComparator());
+
+ logger.debug("after mapsize check mapLeanerCheckedOptionsContent " + mapLeanerCheckedOptionsContent);
+ if (userEntry.length() > 0) {
+ logger.debug("creating entry for: " + userEntry);
+ LearningUtil.createAttempt(request, voteService, voteQueUsr, mapLeanerCheckedOptionsContent, userEntry,
+ false, voteSession, toolContentUID);
+ }
+ }
+
+ logger.debug("created user attempt in the db");
+
+ /* put the map in the request ready for the next screen */
+ request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent);
+ logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent);
+ voteLearningForm.setMapGeneralCheckedOptionsContent(mapGeneralCheckedOptionsContent);
+ voteGeneralLearnerFlowDTO.setMapGeneralCheckedOptionsContent(mapGeneralCheckedOptionsContent);
+
+ voteLearningForm.setNominationsSubmited(new Boolean(true).toString());
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(true).toString());
+
+ VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO();
+ logger.debug("calling prepareChartData: " + toolContentID);
+ MonitoringUtil.prepareChartData(request, voteService, null, toolContentID.toString(),
+ toolSessionUid.toString(), voteGeneralLearnerFlowDTO, voteGeneralMonitoringDTO, getMessageService());
+
+ voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
+ voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject());
+
+ logger.debug("fwding to INDIVIDUAL_REPORT: " + INDIVIDUAL_REPORT);
+ voteLearningForm.resetCommands();
+
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+
+ return (mapping.findForward(INDIVIDUAL_REPORT));
}
+ public ActionForward redoQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ logger.debug("dispatching redoQuestions...");
+ VoteUtils.cleanUpUserExceptions(request);
-
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+
+ repopulateRequestParameters(request, voteLearningForm);
+
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
+
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ String revisitingUser = request.getParameter(REVISITING_USER);
+ logger.debug("revisitingUser: " + revisitingUser);
+ voteLearningForm.setRevisitingUser(revisitingUser);
+
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
+
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("retrieving voteContent: " + voteContent);
+
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+ voteGeneralLearnerFlowDTO.setActivityInstructions(voteContent.getInstructions());
+
+ voteLearningForm.setNominationsSubmited(new Boolean(false).toString());
+ voteLearningForm.setMaxNominationCountReached(new Boolean(false).toString());
+
+ voteGeneralLearnerFlowDTO.setNominationsSubmited(new Boolean(false).toString());
+ voteGeneralLearnerFlowDTO.setMaxNominationCountReached(new Boolean(false).toString());
+
+ Long toolContentID = voteContent.getVoteContentId();
+ logger.debug("toolContentID:" + toolContentID);
+
+ Map mapQuestionsContent = new TreeMap(new VoteComparator());
+ mapQuestionsContent = LearningUtil.buildQuestionContentMap(request, voteService, voteContent, null);
+ logger.debug("mapQuestionsContent: " + mapQuestionsContent);
+
+ request.setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
+ logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getAttribute(MAP_QUESTION_CONTENT_LEARNER));
+ logger.debug("voteContent has : " + mapQuestionsContent.size() + " entries.");
+
+ Map mapGeneralCheckedOptionsContent = new TreeMap(new VoteComparator());
+ request.setAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT, mapGeneralCheckedOptionsContent);
+
+ voteLearningForm.setUserEntry("");
+
+ voteGeneralLearnerFlowDTO.setReflection(new Boolean(voteContent.isReflect()).toString());
+ voteGeneralLearnerFlowDTO.setReflectionSubject(voteContent.getReflectionSubject());
+
+ logger.debug("fwd'ing to LOAD_LEARNER : " + LOAD_LEARNER);
+ voteLearningForm.resetCommands();
+
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
+
+ return (mapping.findForward(LOAD_LEARNER));
+ }
+
+ protected void setContentInUse(HttpServletRequest request, IVoteService voteService, Long toolContentID) {
+ logger.debug("toolContentID:" + toolContentID);
+
+ VoteContent voteContent = voteService.retrieveVote(toolContentID);
+ logger.debug("voteContent:" + voteContent);
+ voteContent.setContentInUse(true);
+ logger.debug("content has been set to inuse");
+ voteService.saveVoteContent(voteContent);
+ }
+
/**
* persists error messages to request scope
+ *
* @param request
* @param message
*/
- public void persistInRequestError(HttpServletRequest request, String message)
- {
- ActionMessages errors= new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage(message));
- logger.debug("add " + message +" to ActionMessages:");
- saveErrors(request,errors);
+ public void persistInRequestError(HttpServletRequest request, String message) {
+ ActionMessages errors = new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug("add " + message + " to ActionMessages:");
+ saveErrors(request, errors);
+ }
+
+ public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException, ToolException {
+ logger.debug("dispatching submitReflection...");
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+
+ repopulateRequestParameters(request, voteLearningForm);
+
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("voteService: " + voteService);
+
+ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
+
+ String userID = request.getParameter("userID");
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ String reflectionEntry = request.getParameter(ENTRY_TEXT);
+ logger.debug("reflectionEntry: " + reflectionEntry);
+
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
+
+ VoteQueUsr voteQueUsr = voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
+ logger.debug("voteQueUsr:" + voteQueUsr);
+
+ /* it is possible that voteQueUsr can be null if the content is set as runoffline and reflection is on*/
+ if (voteQueUsr == null) {
+ logger.debug("attempt creating user record since it must exist for the runOffline + reflection screens");
+ HttpSession ss = SessionManager.getSession();
+
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ logger.debug("retrieving toolUser: " + toolUser);
+ logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
+ logger.debug("retrieving toolUser username: " + toolUser.getLogin());
+
+ String userName = toolUser.getLogin();
+ String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
+ logger.debug("retrieving toolUser fullname: " + fullName);
+
+ Long userId = new Long(toolUser.getUserID().longValue());
+ logger.debug("retrieving toolUser fullname: " + fullName);
+
+ voteQueUsr = new VoteQueUsr(new Long(userID), userName, fullName, voteSession, new TreeSet());
+ voteService.createVoteQueUsr(voteQueUsr);
+ logger.debug("createVoteQueUsr - voteQueUsr: " + voteQueUsr);
+ logger.debug("session uid: " + voteSession.getUid());
}
-
-
- public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException, ToolException
- {
- logger.debug("dispatching submitReflection...");
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
-
- repopulateRequestParameters(request,voteLearningForm);
-
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("voteService: " + voteService);
+ logger.debug("voteQueUsr:" + voteQueUsr);
+ logger.debug("toolSessionID:" + toolSessionID);
+ logger.debug("CoreNotebookConstants.NOTEBOOK_TOOL:" + CoreNotebookConstants.NOTEBOOK_TOOL);
+ logger.debug("MY_SIGNATURE:" + MY_SIGNATURE);
+ logger.debug("userID:" + userID);
+ logger.debug("reflectionEntry:" + reflectionEntry);
- String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
+ voteService.createNotebookEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, MY_SIGNATURE,
+ new Integer(userID), reflectionEntry);
- String userID=request.getParameter("userID");
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- String reflectionEntry=request.getParameter(ENTRY_TEXT);
- logger.debug("reflectionEntry: " + reflectionEntry);
+ voteLearningForm.resetUserActions(); /*resets all except submitAnswersContent */
+ return learnerFinished(mapping, form, request, response);
+ }
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteQueUsr voteQueUsr=voteService.getVoteUserBySession(new Long(userID), voteSession.getUid());
- logger.debug("voteQueUsr:" + voteQueUsr);
-
- /* it is possible that voteQueUsr can be null if the content is set as runoffline and reflection is on*/
- if (voteQueUsr == null)
- {
- logger.debug("attempt creating user record since it must exist for the runOffline + reflection screens");
- HttpSession ss = SessionManager.getSession();
+ public ActionForward forwardtoReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException, ToolException {
+ logger.debug("dispatching forwardtoReflection...");
+ VoteLearningForm voteLearningForm = (VoteLearningForm) form;
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("voteService: " + voteService);
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
- logger.debug("retrieving toolUser: " + toolUser);
- logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
- logger.debug("retrieving toolUser username: " + toolUser.getLogin());
+ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
- String userName=toolUser.getLogin();
- String fullName= toolUser.getFirstName() + " " + toolUser.getLastName();
- logger.debug("retrieving toolUser fullname: " + fullName);
-
- Long userId=new Long(toolUser.getUserID().longValue());
- logger.debug("retrieving toolUser fullname: " + fullName);
-
- voteQueUsr= new VoteQueUsr(new Long(userID),
- userName,
- fullName,
- voteSession,
- new TreeSet());
- voteService.createVoteQueUsr(voteQueUsr);
- logger.debug("createVoteQueUsr - voteQueUsr: " + voteQueUsr);
- logger.debug("session uid: " + voteSession.getUid());
- }
-
- logger.debug("voteQueUsr:" + voteQueUsr);
- logger.debug("toolSessionID:" + toolSessionID);
- logger.debug("CoreNotebookConstants.NOTEBOOK_TOOL:" + CoreNotebookConstants.NOTEBOOK_TOOL);
- logger.debug("MY_SIGNATURE:" + MY_SIGNATURE);
- logger.debug("userID:" + userID);
- logger.debug("reflectionEntry:" + reflectionEntry);
-
- voteService.createNotebookEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL,
- MY_SIGNATURE, new Integer(userID), reflectionEntry);
-
- voteLearningForm.resetUserActions(); /*resets all except submitAnswersContent */
- return learnerFinished(mapping, form, request, response);
+ VoteSession voteSession = voteService.retrieveVoteSession(new Long(toolSessionID));
+ logger.debug("retrieving voteSession: " + voteSession);
+
+ VoteContent voteContent = voteSession.getVoteContent();
+ logger.debug("using voteContent: " + voteContent);
+
+ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO = new VoteGeneralLearnerFlowDTO();
+ voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
+
+ String reflectionSubject = voteContent.getReflectionSubject();
+ reflectionSubject = VoteUtils.replaceNewLines(reflectionSubject);
+
+ voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
+
+ String userID = request.getParameter("userID");
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ logger.debug("attempt getting notebookEntry: ");
+ NotebookEntry notebookEntry = voteService.getEntry(new Long(toolSessionID),
+ CoreNotebookConstants.NOTEBOOK_TOOL, MY_SIGNATURE, new Integer(userID));
+
+ logger.debug("notebookEntry: " + notebookEntry);
+
+ if (notebookEntry != null) {
+ String notebookEntryPresentable = notebookEntry.getEntry();
+ logger.debug("notebookEntryPresentable: " + notebookEntryPresentable);
+ voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable);
+ voteLearningForm.setEntryText(notebookEntryPresentable);
}
-
-
- public ActionForward forwardtoReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
- throws IOException, ServletException, ToolException
- {
- logger.debug("dispatching forwardtoReflection...");
- VoteLearningForm voteLearningForm = (VoteLearningForm) form;
- IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
- logger.debug("voteService: " + voteService);
-
- String toolSessionID=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
-
- VoteSession voteSession=voteService.retrieveVoteSession(new Long(toolSessionID));
- logger.debug("retrieving voteSession: " + voteSession);
-
- VoteContent voteContent=voteSession.getVoteContent();
- logger.debug("using voteContent: " + voteContent);
-
- VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO= new VoteGeneralLearnerFlowDTO();
- voteGeneralLearnerFlowDTO.setActivityTitle(voteContent.getTitle());
-
- String reflectionSubject=voteContent.getReflectionSubject();
- reflectionSubject=VoteUtils.replaceNewLines(reflectionSubject);
-
- voteGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- String userID=request.getParameter("userID");
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
-
- logger.debug("attempt getting notebookEntry: ");
- NotebookEntry notebookEntry = voteService.getEntry(new Long(toolSessionID),
- CoreNotebookConstants.NOTEBOOK_TOOL,
- MY_SIGNATURE, new Integer(userID));
-
- logger.debug("notebookEntry: " + notebookEntry);
-
- if (notebookEntry != null) {
- String notebookEntryPresentable=notebookEntry.getEntry();
- logger.debug("notebookEntryPresentable: " + notebookEntryPresentable);
- voteGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable);
- voteLearningForm.setEntryText(notebookEntryPresentable);
- }
-
-
-
- request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
-
- logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
- voteLearningForm.resetCommands();
-
- logger.debug("fwd'ing to: " + NOTEBOOK);
- return (mapping.findForward(NOTEBOOK));
- }
-
- protected void repopulateRequestParameters(HttpServletRequest request, VoteLearningForm voteLearningForm)
- {
- logger.debug("starting repopulateRequestParameters");
-
- String toolSessionID=request.getParameter(TOOL_SESSION_ID);
- logger.debug("toolSessionID: " + toolSessionID);
- voteLearningForm.setToolSessionID(toolSessionID);
-
- String userID=request.getParameter(USER_ID);
- logger.debug("userID: " + userID);
- voteLearningForm.setUserID(userID);
- String revisitingUser=request.getParameter(REVISITING_USER);
- logger.debug("revisitingUser: " + revisitingUser);
- voteLearningForm.setRevisitingUser(revisitingUser);
+ request.setAttribute(VOTE_GENERAL_LEARNER_FLOW_DTO, voteGeneralLearnerFlowDTO);
- String previewOnly=request.getParameter(PREVIEW_ONLY);
- logger.debug("previewOnly: " + previewOnly);
- voteLearningForm.setPreviewOnly(previewOnly);
+ logger.debug("final voteGeneralLearnerFlowDTO: " + voteGeneralLearnerFlowDTO);
+ voteLearningForm.resetCommands();
- String maxNominationCount=request.getParameter(MAX_NOMINATION_COUNT);
- logger.debug("maxNominationCount: " + maxNominationCount);
- voteLearningForm.setMaxNominationCount(maxNominationCount);
+ logger.debug("fwd'ing to: " + NOTEBOOK);
+ return (mapping.findForward(NOTEBOOK));
+ }
- String allowTextEntry=request.getParameter(ALLOW_TEXT_ENTRY);
- logger.debug("allowTextEntry: " + allowTextEntry);
- voteLearningForm.setAllowTextEntry(allowTextEntry);
-
- String showResults=request.getParameter(SHOW_RESULTS);
- voteLearningForm.setShowResults(showResults);
-
- String lockOnFinish=request.getParameter(LOCK_ON_FINISH);
- logger.debug("lockOnFinish: " + lockOnFinish);
- voteLearningForm.setLockOnFinish(lockOnFinish);
+ protected void repopulateRequestParameters(HttpServletRequest request, VoteLearningForm voteLearningForm) {
+ logger.debug("starting repopulateRequestParameters");
- String reportViewOnly=request.getParameter(REPORT_VIEW_ONLY);
- logger.debug("reportViewOnly: " + reportViewOnly);
- voteLearningForm.setReportViewOnly(reportViewOnly);
-
- String userEntry=request.getParameter(USER_ENTRY);
- logger.debug("userEntry: " + userEntry);
- voteLearningForm.setUserEntry(userEntry);
+ String toolSessionID = request.getParameter(TOOL_SESSION_ID);
+ logger.debug("toolSessionID: " + toolSessionID);
+ voteLearningForm.setToolSessionID(toolSessionID);
+
+ String userID = request.getParameter(USER_ID);
+ logger.debug("userID: " + userID);
+ voteLearningForm.setUserID(userID);
+
+ String revisitingUser = request.getParameter(REVISITING_USER);
+ logger.debug("revisitingUser: " + revisitingUser);
+ voteLearningForm.setRevisitingUser(revisitingUser);
+
+ String previewOnly = request.getParameter(PREVIEW_ONLY);
+ logger.debug("previewOnly: " + previewOnly);
+ voteLearningForm.setPreviewOnly(previewOnly);
+
+ String maxNominationCount = request.getParameter(MAX_NOMINATION_COUNT);
+ logger.debug("maxNominationCount: " + maxNominationCount);
+ voteLearningForm.setMaxNominationCount(maxNominationCount);
+
+ String allowTextEntry = request.getParameter(ALLOW_TEXT_ENTRY);
+ logger.debug("allowTextEntry: " + allowTextEntry);
+ voteLearningForm.setAllowTextEntry(allowTextEntry);
+
+ String showResults = request.getParameter(SHOW_RESULTS);
+ voteLearningForm.setShowResults(showResults);
+
+ String lockOnFinish = request.getParameter(LOCK_ON_FINISH);
+ logger.debug("lockOnFinish: " + lockOnFinish);
+ voteLearningForm.setLockOnFinish(lockOnFinish);
+
+ String reportViewOnly = request.getParameter(REPORT_VIEW_ONLY);
+ logger.debug("reportViewOnly: " + reportViewOnly);
+ voteLearningForm.setReportViewOnly(reportViewOnly);
+
+ String userEntry = request.getParameter(USER_ENTRY);
+ logger.debug("userEntry: " + userEntry);
+ voteLearningForm.setUserEntry(userEntry);
}
-
+
/**
- * Return ResourceService bean.
- */
- private MessageService getMessageService() {
- return (MessageService) VoteServiceProxy.getMessageService(getServlet().getServletContext());
- }
+ * Return ResourceService bean.
+ */
+ private MessageService getMessageService() {
+ return (MessageService) VoteServiceProxy.getMessageService(getServlet().getServletContext());
+ }
}
-
-