Index: lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r528f2a23baa85e3155f96b535ae2c72649a97b42 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 528f2a23baa85e3155f96b535ae2c72649a97b42) +++ lams_tool_vote/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -164,6 +164,7 @@ msg.data.flow.clear.nominations =You have chosen to use input from an external tool. All defined nomitations will be deleted after save. Do you want to proceed? label.advanced.data.flow.limit =Limit number of students the input will be taken from: label.advanced.data.flow.limit.none =No limit +label.search=Search... #======= End labels: Exported 158 labels for en AU ===== Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -60,6 +60,7 @@ public static final String PREVIEW = "preview"; public static final String LEARNER_PROGRESS = "learnerProgress"; public static final String VOTE_NOMINATION_VIEWER = "voteNominationViewer"; + public static final String STATISTICS = "statistics"; public static final String LEARNER_PROGRESS_USERID = "learnerProgressUserId"; public static final String MIN_NOMINATION_COUNT = "minNominationCount"; public static final String MAX_NOMINATION_COUNT = "maxNominationCount"; @@ -74,8 +75,6 @@ public static final String CURRENT_UID = "currentUid"; public static final String DEFAULT_VOTING_TITLE = "Voting"; public static final String DEFAULT_VOTING_INSTRUCTIONS = "Instructions"; - public static final String NOTEBOOK_ENTRIES_EXIST = "notebookEntriesExist"; - public static final String NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST = "noSessionsNotebookEntriesExist"; public static final String UUID = "uuid"; public static final String VOTE_STATS_DTO = "voteStatsDTO"; public static final String LIST_ALL_GROUPS_DTO = "listAllGroupsDTO"; @@ -202,7 +201,6 @@ public static final String ACTIVITY_TITLE = "activityTitle"; public static final String ACTIVITY_INSTRUCTIONS = "activityInstructions"; public static final String REMOVABLE_QUESTION_INDEX = "removableQuestionIndex"; - public static final String EXISTS_OPEN_VOTES = "existsOpenVotes"; /* * user actions @@ -242,15 +240,21 @@ public static final String MONITORED_CONTENT_ID = "monitoredContentId"; public static final String VALIDATION_ERROR = "validationError"; public static final String FORM_INDEX = "formIndex"; - public static final String LIST_MONITORED_ANSWERS_CONTAINER_DTO = "listMonitoredAnswersContainerDto"; +// public static final String LIST_MONITORED_ANSWERS_CONTAINER_DTO = "listMonitoredAnswersContainerDto"; public static final String TIMEZONE = "timeZone"; public static final String PREVIEW_ONLY = "previewOnly"; public static final String MODE = "mode"; public static final String LEARNING_MODE = "learningMode"; public static final String EXPORT_USER_ID = "exportUserId"; public static final String SESSION_VOTES_CHART = "Session Votes Chart"; + + public static final String ATTR_QUESTION_UID = "questionUid"; + public static final String ATTR_SESSION_UID = "sessionUid"; // not the tool session id supplied by the core + public static final String ATTR_USER_NAME = "userName"; + public static final String ATTR_ATTEMPT_TIME = "attemptTime"; + /* * exception constants */ @@ -294,4 +298,15 @@ // Leader selection tool Constants public static final String LEADER_SELECTION_TOOL_SIGNATURE = "lalead11"; public static final String LEADER_SELECTION_TOOL_OUTPUT_NAME_LEADER_USERID = "leader.user.id"; + + public static final int SORT_BY_DEFAULT = 0; + public static final int SORT_BY_NAME_ASC = 1; + public static final int SORT_BY_NAME_DESC = 2; + public static final int SORT_BY_DATE_ASC = 3; + public static final int SORT_BY_DATE_DESC = 4; + public static final int SORT_BY_ENTRY_ASC = 5; + public static final int SORT_BY_ENTRY_DESC = 6; + public static final int SORT_BY_VISIBLE_ASC = 7; + public static final int SORT_BY_VISIBLE_DESC = 8; + } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java =================================================================== diff -u -r1a02559e19419af9991eaeb9363f809355b39bc7 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision 1a02559e19419af9991eaeb9363f809355b39bc7) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUsrAttemptDAO.java (.../IVoteUsrAttemptDAO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -25,6 +25,9 @@ import java.util.List; import java.util.Set; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.tool.vote.dto.OpenTextAnswerDTO; +import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; /** @@ -44,16 +47,12 @@ Set getUserEntries(final Long voteContentUid); - int getUserEnteredVotesCountForContent(final Long voteContentUid); - Set getSessionUserEntriesSet(final Long voteSessionUid); VoteUsrAttempt getAttemptByUID(Long uid); int getSessionEntriesCount(final Long voteSessionId); - List getStandardAttemptsByQuestionUid(final Long questionUid); - int getStandardAttemptsForQuestionContentAndSessionUid(final Long voteQueContentId, final Long voteSessionUid); List getAttemptsForQuestionContentAndSessionUid(final Long voteQueContentId, @@ -74,4 +73,28 @@ List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long voteQueContentId); + // Tablesorter methods + /** + * Gets the basic details about an attempt for a nomination. questionUid must not be null, sessionUid may be NULL. This is + * unusual for these methods - usually sessionId may not be null. In this case if sessionUid is null then you get + * the values for the whole class, not just the group. + * + * Will return List<[login (String), fullname(String), attemptTime(Timestamp]> + */ + List getUserAttemptsForTablesorter(Long sessionUid, Long questionUid, int page, int size, + int sorting, String searchString); + + /** Get the count of all possible users for getUserAttemptsForTablesorter(). Either sessionUid or questionUid may + * be null but not both. */ + int getCountUsersBySession(Long sessionUid, Long questionUid, String searchString); + + List getUserReflectionsForTablesorter(Long sessionUid, int page, int size, int sorting, + String searchString, ICoreNotebookService coreNotebookService); + + List getStatisticsBySession(Long toolContentId); + + /** Gets the details for the open text nominations */ + List getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long contentUid, int page, int size, + int sorting, String searchStringVote, String searchStringUsername); + int getCountUsersForOpenTextEntries(Long sessionUid, Long contentUid, String searchStringVote, String searchStringUsername); } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java =================================================================== diff -u -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUsrAttemptDAO.java (.../VoteUsrAttemptDAO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -28,9 +28,23 @@ import java.util.List; import java.util.Set; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; import org.hibernate.FlushMode; +import org.hibernate.Hibernate; +import org.hibernate.SQLQuery; +import org.hibernate.transform.Transformers; +import org.hibernate.type.BooleanType; +import org.hibernate.type.IntegerType; +import org.hibernate.type.LongType; +import org.hibernate.type.StringType; +import org.hibernate.type.TimestampType; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.dao.IVoteUsrAttemptDAO; +import org.lamsfoundation.lams.tool.vote.dto.OpenTextAnswerDTO; +import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; import org.springframework.stereotype.Repository; @@ -44,9 +58,9 @@ private static final String LOAD_ATTEMPT_FOR_USER = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId"; - private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContent.uid=:voteQueContentId"; - + // The following two queries are the same except one loads the attempts, the other counts them private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; + private static final String COUNT_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION = "select count(*) from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.voteQueContent.uid=:voteQueContentId and voteUsrAttempt.voteQueUsr.voteSession.uid=:sessionUid"; private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.queUsrId=:queUsrId and voteUsrAttempt.voteQueContent.uid=:voteQueContentId"; @@ -58,9 +72,6 @@ private static final String LOAD_USER_ENTRY_RECORDS = "from voteUsrAttempt in class VoteUsrAttempt where voteUsrAttempt.userEntry=:userEntry and voteUsrAttempt.voteQueContent.uid=1 and voteUsrAttempt.voteQueUsr.voteSession.voteContent.uid=:voteContentUid"; - 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_UID = "select att from VoteUsrAttempt att, VoteQueUsr user, VoteSession ses where " + "att.voteQueUsr=user and user.voteSession=ses and ses.uid=:voteSessionUid"; @@ -93,14 +104,6 @@ } @Override - public int getUserEnteredVotesCountForContent(final Long voteContentUid) { - List result = getSessionFactory().getCurrentSession().createQuery(VoteUsrAttemptDAO.COUNT_ATTEMPTS_BY_CONTENT_ID) - .setLong("voteContentId", voteContentUid).list(); - Long resultLong = result.get(0) != null ? (Long) result.get(0) : new Long(0); - return resultLong.intValue(); - } - - @Override public Set getUserEntries(final Long voteContentUid) { List list = getSessionFactory().getCurrentSession().createQuery(VoteUsrAttemptDAO.LOAD_USER_ENTRIES) .setLong("voteContentUid", voteContentUid).list(); @@ -154,8 +157,16 @@ @Override public int getStandardAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long sessionUid) { - List list = getAttemptsForQuestionContentAndSessionUid(questionUid, sessionUid); - return list.size(); + List list = getSession() + .createQuery(VoteUsrAttemptDAO.COUNT_ATTEMPT_FOR_QUESTION_CONTENT_AND_SESSION) + .setLong("voteQueContentId", questionUid.longValue()) + .setLong("sessionUid", sessionUid.longValue()).list(); + + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } @Override @@ -175,14 +186,6 @@ } @Override - public List getStandardAttemptsByQuestionUid(final Long questionUid) { - List list = getSessionFactory().getCurrentSession().createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_QUESTION_CONTENT) - .setLong("voteQueContentId", questionUid.longValue()).list(); - return list; - - } - - @Override public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long questionUid) { List list = getSessionFactory().getCurrentSession() .createQuery(VoteUsrAttemptDAO.LOAD_ATTEMPT_FOR_USER_AND_QUESTION_CONTENT) @@ -273,7 +276,321 @@ @Override public void removeVoteUsrAttempt(VoteUsrAttempt voteUsrAttempt) { - getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO); + this.getSession().setFlushMode(FlushMode.AUTO); this.getSession().delete(voteUsrAttempt); } + + // Used by Monitoring + + private static final String FIND_USER_ANSWERS_BY_QUESTION_UID = "SELECT user.username username, user.fullname fullname, attempt.attempt_time attemptTime" + + " FROM tl_lavote11_usr user " + + " JOIN tl_lavote11_usr_attempt attempt on user.uid = attempt.que_usr_id AND attempt.vote_nomination_content_id = :questionUid "; + private static final String FIND_USER_ANSWERS_BY_QUESTION_UID_SESSION_ADDITION = " AND user.vote_session_id = :sessionUid "; + + @SuppressWarnings("unchecked") + /** + * Gets the basic details about an attempt for a nomination. questionUid must not be null, sessionUid may be NULL. This is + * unusual for these methods - usually sessionId may not be null. In this case if sessionUid is null then you get + * the values for the whole class, not just the group. + * + * Will return List<[login (String), fullname(String), attemptTime(Timestamp]> + */ + public List getUserAttemptsForTablesorter(Long sessionUid, Long questionUid, int page, int size, + int sorting, String searchString) { + String sortingOrder; + switch (sorting) { + case VoteAppConstants.SORT_BY_NAME_ASC: + sortingOrder = "user.fullname ASC"; + break; + case VoteAppConstants.SORT_BY_NAME_DESC: + sortingOrder = "user.fullname DESC"; + break; + case VoteAppConstants.SORT_BY_DATE_ASC: + sortingOrder = "attempt.attempt_time ASC"; + break; + case VoteAppConstants.SORT_BY_DATE_DESC: + sortingOrder = "attempt.attempt_time DESC"; + break; + default: + sortingOrder = "user.uid"; + } + + // Basic select for the user records + StringBuilder queryText = new StringBuilder(FIND_USER_ANSWERS_BY_QUESTION_UID); + + if ( sessionUid != null ) + queryText.append(FIND_USER_ANSWERS_BY_QUESTION_UID_SESSION_ADDITION); + + // If filtering by name add a name based where clause + buildNameSearch(searchString, queryText, true); + + // Now specify the sort based on the switch statement above. + queryText.append(" ORDER BY " + sortingOrder); + + SQLQuery query = getSession().createSQLQuery(queryText.toString()); + query.addScalar("username", StringType.INSTANCE) + .addScalar("fullname", StringType.INSTANCE) + .addScalar("attemptTime", TimestampType.INSTANCE) + .setLong("questionUid", questionUid.longValue()) + .setFirstResult(page * size).setMaxResults(size); + if ( sessionUid != null ) + query.setLong("sessionUid", sessionUid.longValue()); + + return query.list(); + } + + private void buildNameSearch(String searchString, StringBuilder sqlBuilder, boolean useWhere) { + if (!StringUtils.isBlank(searchString)) { + String[] tokens = searchString.trim().split("\\s+"); + for (String token : tokens) { + String escToken = StringEscapeUtils.escapeSql(token); + sqlBuilder.append(useWhere ? " WHERE " : " AND ") + .append("(user.fullname LIKE '%").append(escToken) + .append("%' OR user.username LIKE '%").append(escToken).append("%') "); + } + } + } + + private static final String COUNT_USERS_BY_QUESTION_UID = "SELECT count(*) " + + " FROM tl_lavote11_usr user " + + " JOIN tl_lavote11_usr_attempt attempt ON user.uid = attempt.que_usr_id AND attempt.vote_nomination_content_id = :questionUid "; + private static final String COUNT_USERS_BY_QUESTION_UID_SESSION_ADDITION = " AND user.vote_session_id = :sessionUid "; + + private static final String COUNT_USERS_BY_SESSION_UID = "SELECT count(*) " + + " FROM tl_lavote11_usr user WHERE user.vote_session_id = :sessionUid "; + + @SuppressWarnings("rawtypes") + public int getCountUsersBySession(Long sessionUid, Long questionUid, String searchString) { + + SQLQuery query; + + if (questionUid == null) { + + // get all the users in this session - used for reflections + StringBuilder queryText = new StringBuilder(COUNT_USERS_BY_SESSION_UID); + buildNameSearch(searchString, queryText, false); // all ready have a WHERE so need an AND + query = getSession().createSQLQuery(queryText.toString()); + query.setLong("sessionUid", sessionUid.longValue()); + + } else { + + // get all the users by a question, possibly restricting by session + StringBuilder queryText = new StringBuilder(COUNT_USERS_BY_QUESTION_UID); + if (sessionUid != null) + queryText.append(COUNT_USERS_BY_QUESTION_UID_SESSION_ADDITION); + buildNameSearch(searchString, queryText, true); + + query = getSession().createSQLQuery(queryText.toString()); + query.setLong("questionUid", questionUid.longValue()); + if (sessionUid != null) + query.setLong("sessionUid", sessionUid.longValue()); + } + + List list = query.list(); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } + + @SuppressWarnings("unchecked") + /** + * Will return List<[login (String), fullname(String), String (notebook entry)]> + */ + public List getUserReflectionsForTablesorter(final Long sessionUid, int page, int size, int sorting, + String searchString, ICoreNotebookService coreNotebookService) { + String sortingOrder; + switch (sorting) { + case VoteAppConstants.SORT_BY_NAME_ASC: + sortingOrder = "user.fullname ASC"; + break; + case VoteAppConstants.SORT_BY_NAME_DESC: + sortingOrder = "user.fullname DESC"; + break; + default: + sortingOrder = "user.uid"; + } + + // If the session uses notebook, then get the sql to join across to get the entries + String[] notebookEntryStrings = coreNotebookService.getNotebookEntrySQLStrings("session.vote_session_id", + VoteAppConstants.MY_SIGNATURE, "user.user_id"); + + // Basic select for the user records + StringBuilder queryText = new StringBuilder(); + queryText.append("SELECT user.username username, user.fullname fullname "); + queryText.append(notebookEntryStrings[0]); + queryText.append(" FROM tl_lavote11_usr user "); + queryText.append(" JOIN tl_lavote11_session session ON user.vote_session_id = :sessionUid AND user.vote_session_id = session.uid "); + + // Add the notebook join + queryText.append(notebookEntryStrings[1]); + + // If filtering by name add a name based where clause + buildNameSearch(searchString, queryText, true); + + // Now specify the sort based on the switch statement above. + queryText.append(" ORDER BY " + sortingOrder); + + SQLQuery query = getSession().createSQLQuery(queryText.toString()); + query.addScalar("username", StringType.INSTANCE) + .addScalar("fullname", StringType.INSTANCE) + .addScalar("notebookEntry", StringType.INSTANCE) + .setLong("sessionUid", sessionUid.longValue()) + .setFirstResult(page * size).setMaxResults(size); + + return query.list(); + } + + private static final String FIND_USER_OPEN_TEXT = "SELECT user.uid userUid, user.username login, user.fullname fullName, " + + " attempt.uid userEntryUid, attempt.userEntry userEntry, attempt.attempt_time attemptTime, attempt.visible visible " + + " FROM tl_lavote11_usr user " + + " JOIN tl_lavote11_usr_attempt attempt ON user.uid = attempt.que_usr_id AND attempt.vote_nomination_content_id = 1 "; + + private static final String FIND_USER_OPEN_TEXT_SESSION_UID_ADD = "AND user.vote_session_id=:sessionUid"; + private static final String FIND_USER_OPEN_TEXT_CONTENT_UID_ADD = + "JOIN tl_lavote11_session session ON user.vote_session_id = session.uid " + + " JOIN tl_lavote11_content content ON session.vote_content_id = content.uid and content.content_id = :toolContentId"; + + @SuppressWarnings("unchecked") + /** + * Gets the details about an open text entry. Either sessionUid or toolContentId must be supplied - if sessionUid is supplied + * then it will be restricted to that session. Due to the large number of fields needed, a DTO will be returned. + * + * Will return List + */ + public List getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long toolContentId, int page, int size, + int sorting, String searchStringVote, String searchStringUsername) { + String sortingOrder; + switch (sorting) { + case VoteAppConstants.SORT_BY_NAME_ASC: + sortingOrder = "user.fullname ASC"; + break; + case VoteAppConstants.SORT_BY_NAME_DESC: + sortingOrder = "user.fullname DESC"; + break; + case VoteAppConstants.SORT_BY_DATE_ASC: + sortingOrder = "attempt.attempt_time ASC"; + break; + case VoteAppConstants.SORT_BY_DATE_DESC: + sortingOrder = "attempt.attempt_time DESC"; + break; + case VoteAppConstants.SORT_BY_ENTRY_ASC: + sortingOrder = "attempt.userEntry ASC"; + break; + case VoteAppConstants.SORT_BY_ENTRY_DESC: + sortingOrder = "attempt.userEntry DESC"; + break; + case VoteAppConstants.SORT_BY_VISIBLE_ASC: + sortingOrder = "attempt.visible ASC"; + break; + case VoteAppConstants.SORT_BY_VISIBLE_DESC: + sortingOrder = "attempt.visible DESC"; + break; + default: + sortingOrder = "user.uid"; + } + + // Basic select for the user records + StringBuilder queryText = new StringBuilder(FIND_USER_OPEN_TEXT); + + if ( sessionUid != null ) + queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD); + else + queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD); + + // If filtering by name/entry add a where clause + buildCombinedSearch(searchStringVote, searchStringUsername, queryText); + + // Now specify the sort based on the switch statement above. + queryText.append(" ORDER BY " + sortingOrder); + + SQLQuery query = getSession().createSQLQuery(queryText.toString()); + query.addScalar("userUid", LongType.INSTANCE) + .addScalar("login", StringType.INSTANCE) + .addScalar("fullName", StringType.INSTANCE) + .addScalar("userEntryUid", LongType.INSTANCE) + .addScalar("userEntry", StringType.INSTANCE) + .addScalar("attemptTime", TimestampType.INSTANCE) + .addScalar("visible", BooleanType.INSTANCE) + .setFirstResult(page * size).setMaxResults(size) + .setResultTransformer(Transformers.aliasToBean(OpenTextAnswerDTO.class)); + + if ( sessionUid != null ) + query.setLong("sessionUid", sessionUid); + else + query.setLong("toolContentId", toolContentId); + + return query.list(); + } + + private void buildCombinedSearch(String searchStringVote, String searchStringUsername, StringBuilder sqlBuilder) { + + if (!StringUtils.isBlank(searchStringVote)) { + String[] tokens = searchStringVote.trim().split("\\s+"); + for (String token : tokens) { + String escToken = StringEscapeUtils.escapeSql(token); + sqlBuilder.append(" WHERE (userEntry LIKE '%").append(escToken).append("%') "); + } + } else { + buildNameSearch(searchStringUsername, sqlBuilder, true); + } + } + + private static final String COUNT_USERS_OPEN_TEXT_BY_SESSION_UID = "SELECT count(*) " + + " FROM tl_lavote11_usr user " + + " JOIN tl_lavote11_usr_attempt attempt ON user.uid = attempt.que_usr_id AND attempt.vote_nomination_content_id = 1 "; + + @SuppressWarnings("rawtypes") + public int getCountUsersForOpenTextEntries(Long sessionUid, Long toolContentId, String searchStringVote, String searchStringUsername) { + + SQLQuery query; + StringBuilder queryText = new StringBuilder(COUNT_USERS_OPEN_TEXT_BY_SESSION_UID); + + if (sessionUid != null) { + // get all the users who did an open text reply, restricting by session + queryText.append(FIND_USER_OPEN_TEXT_SESSION_UID_ADD); + buildCombinedSearch(searchStringVote, searchStringUsername, queryText); + query = getSession().createSQLQuery(queryText.toString()); + query.setLong("sessionUid", sessionUid); + + } else { + + // get all the users for this content (more than one session potentially) + queryText.append(FIND_USER_OPEN_TEXT_CONTENT_UID_ADD); + buildCombinedSearch(searchStringVote, searchStringUsername, queryText); + query = getSession().createSQLQuery(queryText.toString()); + query.setLong("toolContentId", toolContentId); + + } + + List list = query.list(); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } + + + private static final String GET_STATISTICS = "SELECT session.session_name sessionName, session.uid sessionUid, SUM(user.responseFinalised) countUsersComplete " + +" FROM tl_lavote11_usr user " + +" JOIN tl_lavote11_session session ON user.vote_session_id = session.uid " + +" JOIN tl_lavote11_content content ON session.vote_content_id = content.uid and content.content_id = :contentId " + +" GROUP BY sessionUid " + +" ORDER BY sessionUid"; + + @SuppressWarnings("unchecked") + public List getStatisticsBySession(Long toolContentId) { + + SQLQuery query = getSession().createSQLQuery(GET_STATISTICS); + query.addScalar("sessionUid", LongType.INSTANCE) + .addScalar("sessionName", StringType.INSTANCE) + .addScalar("countUsersComplete", IntegerType.INSTANCE) + .setLong("contentId", toolContentId) + .setResultTransformer(Transformers.aliasToBean(VoteStatsDTO.class)); + + return (List) query.list(); + } + + + } \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/ExportPortfolioDTO.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/ExportPortfolioDTO.java (.../ExportPortfolioDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/ExportPortfolioDTO.java (.../ExportPortfolioDTO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -37,15 +37,15 @@ protected LinkedList sessionDtos; /** - * @return Returns the listMonitoredAnswersContainerDto. + * @return Returns the sessionDtos. */ public LinkedList getSessionDtos() { return sessionDtos; } /** - * @param listMonitoredAnswersContainerDto - * The listMonitoredAnswersContainerDto to set. + * @param sessionDtos + * The sessionDtos to set. */ public void setSessionDtos(LinkedList sessionDTOs) { this.sessionDtos = sessionDTOs; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/OpenTextAnswerDTO.java =================================================================== diff -u --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/OpenTextAnswerDTO.java (revision 0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/OpenTextAnswerDTO.java (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,105 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.vote.dto; + +import java.util.Date; + +import org.apache.commons.lang.builder.ToStringBuilder; + + +/** + * DTO that holds the details of an open text answer, used for Monitoring + */ +public class OpenTextAnswerDTO +{ + protected Long userUid; + protected String login; + protected String fullName; + protected Long userEntryUid; + protected String userEntry; + protected Date attemptTime; + protected Boolean visible; + + public String toString() { + return new ToStringBuilder(this).append("login: ", login).append("userUid: ", userUid) + .append("userEntry: ", userEntry).append("userEntryUid: ", userEntryUid).append("visible: ", visible) + .toString(); + } + + public Long getUserUid() { + return userUid; + } + + public void setUserUid(Long userUid) { + this.userUid = userUid; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public Long getUserEntryUid() { + return userEntryUid; + } + + public void setUserEntryUid( Long userEntryUid) { + this.userEntryUid = userEntryUid; + } + + public String getUserEntry() { + return userEntry; + } + + public void setUserEntry(String userEntry) { + this.userEntry = userEntry; + } + + public Date getAttemptTime() { + return attemptTime; + } + + public void setAttemptTime(Date attemptTime) { + this.attemptTime = attemptTime; + } + + public Boolean isVisible() { + return visible; + } + + public void setVisible(Boolean visible) { + this.visible = visible; + } + +} Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SessionNominationDTO.java =================================================================== diff -u --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SessionNominationDTO.java (revision 0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SessionNominationDTO.java (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,77 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.vote.dto; + + +/** + * DTO that holds summary data for a nomination, not the answers themselves + */ +public class SessionNominationDTO implements Comparable { + + Long questionUid; + Integer numberOfVotes; + Double percentageOfVotes; + String nomination; + + @Override + public int compareTo(Object o) { + SessionNominationDTO dto = (SessionNominationDTO) o; + if (dto == null) + return 1; + else + return questionUid.compareTo(dto.getQuestionUid()); + } + + public Long getQuestionUid() { + return questionUid; + } + + public void setQuestionUid(Long questionUid) { + this.questionUid = questionUid; + } + + public Integer getNumberOfVotes() { + return numberOfVotes; + } + + public void setNumberOfVotes(Integer numberOfVotes) { + this.numberOfVotes = numberOfVotes; + } + + public Double getPercentageOfVotes() { + return percentageOfVotes; + } + + public void setPercentageOfVotes(Double percentageOfVotes) { + this.percentageOfVotes = percentageOfVotes; + } + + public String getNomination() { + return nomination; + } + + public void setNomination(String nomination) { + this.nomination = nomination; + } + +} Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SummarySessionDTO.java =================================================================== diff -u --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SummarySessionDTO.java (revision 0) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/SummarySessionDTO.java (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,108 @@ +/*************************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * ***********************************************************************/ + +package org.lamsfoundation.lams.tool.vote.dto; + +import java.util.SortedSet; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * DTO that holds summary data for all the sessions - down to the %s, number of votes etc but not the actual answers. + */ +public class SummarySessionDTO implements Comparable { + private Long sessionUid; + private Long toolSessionId; + private String sessionName; + private SortedSet nominations; + private Integer openTextNumberOfVotes; + private Double openTextPercentageOfVotes; + + public String toString() { + return new ToStringBuilder(this).append("toolSessionId", getToolSessionId()).append("sessionName", getSessionName()).toString(); + } + + public int compareTo(Object o) { + SummarySessionDTO sessionDTO = (SummarySessionDTO) o; + + if (sessionDTO == null) + return 1; + else + return sessionUid.compareTo(sessionDTO.getSessionUid()); + } + + /** + * @return Returns the sessionName. + */ + public String getSessionName() { + return sessionName; + } + + /** + * @param sessionName + * The sessionName to set. + */ + public void setSessionName(String sessionName) { + this.sessionName = sessionName; + } + + public Long getSessionUid() { + return sessionUid; + } + + public void setSessionUid(Long sessionUid) { + this.sessionUid = sessionUid; + } + + public Long getToolSessionId() { + return toolSessionId; + } + + public void setToolSessionId(Long toolSessionId) { + this.toolSessionId = toolSessionId; + } + + public SortedSet getNominations() { + return nominations; + } + + public void setNominations(SortedSet nominations) { + this.nominations = nominations; + } + + public Integer getOpenTextNumberOfVotes() { + return openTextNumberOfVotes; + } + + public void setOpenTextNumberOfVotes(Integer openTextNumberOfVotes) { + this.openTextNumberOfVotes = openTextNumberOfVotes; + } + + public Double getOpenTextPercentageOfVotes() { + return openTextPercentageOfVotes; + } + + public void setOpenTextPercentageOfVotes(Double openTextPercentageOfVotes) { + this.openTextPercentageOfVotes = openTextPercentageOfVotes; + } + +} Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralLearnerFlowDTO.java =================================================================== diff -u -r1a02559e19419af9991eaeb9363f809355b39bc7 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralLearnerFlowDTO.java (.../VoteGeneralLearnerFlowDTO.java) (revision 1a02559e19419af9991eaeb9363f809355b39bc7) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralLearnerFlowDTO.java (.../VoteGeneralLearnerFlowDTO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -106,7 +106,7 @@ protected Map mapStandardToolSessionUid; - protected List listMonitoredAnswersContainerDto; + // protected List listMonitoredAnswersContainerDto; protected List listUserEntries; @@ -422,7 +422,7 @@ .append("mapStandardUserCount: ", mapStandardUserCount) .append("mapStandardQuestionUid: ", mapStandardQuestionUid) .append("mapStandardToolSessionUid: ", mapStandardToolSessionUid) - .append("listMonitoredAnswersContainerDto: ", listMonitoredAnswersContainerDto) +// .append("listMonitoredAnswersContainerDto: ", listMonitoredAnswersContainerDto) .append("listUserEntries: ", listUserEntries).append("reportViewOnly: ", reportViewOnly).toString(); } @@ -546,22 +546,22 @@ this.mapStandardUserCount = mapStandardUserCount; } - /** - * @return Returns the listMonitoredAnswersContainerDto. - */ - public List getListMonitoredAnswersContainerDto() { - return listMonitoredAnswersContainerDto; - } +// /** +// * @return Returns the listMonitoredAnswersContainerDto. +// */ +// public List getListMonitoredAnswersContainerDto() { +// return listMonitoredAnswersContainerDto; +// } +// +// /** +// * @param listMonitoredAnswersContainerDto +// * The listMonitoredAnswersContainerDto to set. +// */ +// public void setListMonitoredAnswersContainerDto(List listMonitoredAnswersContainerDto) { +// this.listMonitoredAnswersContainerDto = listMonitoredAnswersContainerDto; +// } /** - * @param listMonitoredAnswersContainerDto - * The listMonitoredAnswersContainerDto to set. - */ - public void setListMonitoredAnswersContainerDto(List listMonitoredAnswersContainerDto) { - this.listMonitoredAnswersContainerDto = listMonitoredAnswersContainerDto; - } - - /** * @return Returns the mapGeneralCheckedOptionsContent. */ public Map getMapGeneralCheckedOptionsContent() { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java (.../VoteGeneralMonitoringDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteGeneralMonitoringDTO.java (.../VoteGeneralMonitoringDTO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -43,12 +43,10 @@ protected String countAllUsers; protected String countSessionComplete; protected String isPortfolioExport; - protected String existsOpenVotes; protected String responseId; protected String toolContentID; - protected List listMonitoredAnswersContainerDto; - protected List listUserEntries; +// protected List listMonitoredAnswersContainerDto; protected List sessionDTOs; protected Map mapStandardNominationsContent; @@ -229,52 +227,22 @@ this.isPortfolioExport = isPortfolioExport; } - /** - * @return Returns the listMonitoredAnswersContainerDto. - */ - public List getListMonitoredAnswersContainerDto() { - return listMonitoredAnswersContainerDto; - } +// /** +// * @return Returns the listMonitoredAnswersContainerDto. +// */ +// public List getListMonitoredAnswersContainerDto() { +// return listMonitoredAnswersContainerDto; +// } +// +// /** +// * @param listMonitoredAnswersContainerDto +// * The listMonitoredAnswersContainerDto to set. +// */ +// public void setListMonitoredAnswersContainerDto(List listMonitoredAnswersContainerDto) { +// this.listMonitoredAnswersContainerDto = listMonitoredAnswersContainerDto; +// } /** - * @param listMonitoredAnswersContainerDto - * The listMonitoredAnswersContainerDto to set. - */ - public void setListMonitoredAnswersContainerDto(List listMonitoredAnswersContainerDto) { - this.listMonitoredAnswersContainerDto = listMonitoredAnswersContainerDto; - } - - /** - * @return Returns the listUserEntries. - */ - public List getListUserEntries() { - return listUserEntries; - } - - /** - * @param listUserEntries - * The listUserEntries to set. - */ - public void setListUserEntries(List listUserEntries) { - this.listUserEntries = listUserEntries; - } - - /** - * @return Returns the existsOpenVotes. - */ - public String getExistsOpenVotes() { - return existsOpenVotes; - } - - /** - * @param existsOpenVotes - * The existsOpenVotes to set. - */ - public void setExistsOpenVotes(String existsOpenVotes) { - this.existsOpenVotes = existsOpenVotes; - } - - /** * @return Returns the sessionDtos. */ public List getSessionDTOs() { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java (.../VoteStatsDTO.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dto/VoteStatsDTO.java (.../VoteStatsDTO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -34,51 +34,63 @@ * @author Ozgur Demirtas */ public class VoteStatsDTO implements Comparable { - private String countAllUsers; + + private String sessionName; + private Long sessionUid; + private Integer countAllUsers; + private Integer countUsersComplete; - private String countSessionComplete; - public String toString() { - return new ToStringBuilder(this).append("question", countAllUsers) - .append("countSessionComplete", countSessionComplete).toString(); + return new ToStringBuilder(this).append("sessionName", sessionName) + .append("countUsersComplete", countUsersComplete).toString(); } public int compareTo(Object o) { VoteStatsDTO qaStatsDTO = (VoteStatsDTO) o; - if (qaStatsDTO == null) return 1; else - return 0; + return sessionUid.compareTo(qaStatsDTO.getSessionUid()); } /** - * @return Returns the countAllUsers. + * @return How many users could vote - based on the session setting in the core, not in the activity */ - public String getCountAllUsers() { + public Integer getCountAllUsers() { return countAllUsers; } /** * @param countAllUsers * The countAllUsers to set. */ - public void setCountAllUsers(String countAllUsers) { + public void setCountAllUsers(Integer countAllUsers) { this.countAllUsers = countAllUsers; } - /** - * @return Returns the countSessionComplete. - */ - public String getCountSessionComplete() { - return countSessionComplete; + public String getSessionName() { + return sessionName; } - /** - * @param countSessionComplete - * The countSessionComplete to set. - */ - public void setCountSessionComplete(String countSessionComplete) { - this.countSessionComplete = countSessionComplete; + public void setSessionName(String sessionName) { + this.sessionName = sessionName; } + + public Long getSessionUid() { + return sessionUid; + } + + public void setSessionUid(Long sessionUid) { + this.sessionUid = sessionUid; + } + + public Integer getCountUsersComplete() { + return countUsersComplete; + } + + public void setCountUsersComplete(Integer countUsersComplete) { + this.countUsersComplete = countUsersComplete; + } + + } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java =================================================================== diff -u -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.SortedSet; import javax.servlet.http.HttpServletRequest; @@ -36,19 +37,21 @@ import org.lamsfoundation.lams.tool.ToolOutput; import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.vote.dto.OpenTextAnswerDTO; import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.vote.dto.SessionDTO; +import org.lamsfoundation.lams.tool.vote.dto.SummarySessionDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO; +import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; import org.lamsfoundation.lams.tool.vote.pojos.VoteSession; import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; -import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.util.MessageService; /** * @author Ozgur Demirtas @@ -58,6 +61,13 @@ public interface IVoteService { /** + * @return Returns the MessageService. + */ + MessageService getMessageService(); + + /** + + /** * @param user * @param toolSessionId * @return @@ -92,13 +102,21 @@ VoteGeneralLearnerFlowDTO voteGeneralLearnerFlowDTO); /** - * Generates data for all sessions in the Monitoring Summary, including all sessions summary. + * Generates data for all sessions in the Export Portfolio Summary, including all sessions summary. * * @param toolContentID * @return */ LinkedList getSessionDTOs(Long toolContentID); + /** + * Generates data for all sessions in the Monitoring Summary, including all sessions summary. + * + * @param toolContentID + * @return + */ + SortedSet getMonitoringSessionDTOs(Long toolContentID); + List getOpenVotes(Long voteContentUid, Long currentSessionId, Long userId); List getReflectionData(VoteContent voteContent, Long userID); @@ -125,9 +143,9 @@ void showOpenVote(VoteUsrAttempt voteUsrAttempt); - boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent); +// boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent); - int getUserEnteredVotesCountForContent(final Long voteContentUid); +// int getUserEnteredVotesCountForContent(final Long voteContentUid); List getAttemptsForQuestionContentAndSessionUid(final Long questionUid, final Long voteSessionUid); @@ -162,8 +180,6 @@ */ Map buildQuestionMap(VoteContent voteContent, Collection checkedOptions); - List getStandardAttemptsByQuestionUid(final Long questionUid); - void updateVoteUser(VoteQueUsr voteUser); void removeAttemptsForUserandSession(final Long queUsrId, final Long sessionUid); @@ -243,4 +259,26 @@ * @return */ boolean isGroupedActivity(long toolContentID); + + /** + * Gets the basic details about an attempt for a nomination. questionUid must not be null, sessionUid may be NULL. This is + * unusual for these methods - usually sessionId may not be null. In this case if sessionUid is null then you get + * the values for the whole class, not just the group. + * + * Will return List<[login (String), fullname(String), attemptTime(Timestamp]> + */ + List getUserAttemptsForTablesorter(Long sessionUid, Long questionUid, int page, int size, + int sorting, String searchString); + + int getCountUsersBySession(Long sessionUid, Long questionUid, String searchString); + + List getUserReflectionsForTablesorter(Long sessionUid, int page, int size, int sorting, + String searchString); + + List getStatisticsBySession(Long toolContentId); + + /** Gets the details for the open text nominations */ + List getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long contentUid, int page, int size, + int sorting, String searchStringVote, String searchStringUsername); + int getCountUsersForOpenTextEntries(Long sessionUid, Long contentUid, String searchStringVote, String searchStringUsername); } \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java =================================================================== diff -u -r8be2bc782a2c7066c8c33f5605962584df7a2f9b -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 8be2bc782a2c7066c8c33f5605962584df7a2f9b) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -25,12 +25,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; +import java.util.SortedSet; import java.util.TimeZone; import java.util.TreeMap; import java.util.TreeSet; @@ -71,12 +73,16 @@ import org.lamsfoundation.lams.tool.vote.dao.IVoteSessionDAO; import org.lamsfoundation.lams.tool.vote.dao.IVoteUserDAO; import org.lamsfoundation.lams.tool.vote.dao.IVoteUsrAttemptDAO; +import org.lamsfoundation.lams.tool.vote.dto.OpenTextAnswerDTO; import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.vote.dto.SessionDTO; +import org.lamsfoundation.lams.tool.vote.dto.SessionNominationDTO; +import org.lamsfoundation.lams.tool.vote.dto.SummarySessionDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO; +import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; @@ -308,14 +314,6 @@ int entriesCount = voteUsrAttemptDAO.getSessionEntriesCount(session.getUid()); - // potentialUserCount - int potentialUserCount = this.getVoteSessionPotentialLearnersCount(session.getUid()); - sessionDTO.setSessionUserCount(potentialUserCount); - - // completedSessionUserCount - int completedSessionUserCount = voteUserDAO.getCompletedVoteUserBySessionUid(session.getUid()); - sessionDTO.setCompletedSessionUserCount(completedSessionUserCount); - Long mapIndex = 1L; int totalStandardVotesCount = 0; @@ -454,6 +452,96 @@ return sessionDTOs; } + @Override + public SortedSet getMonitoringSessionDTOs(Long toolContentID) { + + SortedSet sessionDTOs = new TreeSet(); + + VoteContent voteContent = this.getVoteContent(toolContentID); + for (VoteSession session : (Set) voteContent.getVoteSessions()) { + + SummarySessionDTO sessionDTO = new SummarySessionDTO(); + sessionDTO.setSessionName(session.getSession_name()); + sessionDTO.setSessionUid(session.getUid()); + sessionDTO.setToolSessionId(session.getVoteSessionId()); + sessionDTO.setNominations(new TreeSet()); + + int entriesCount = voteUsrAttemptDAO.getSessionEntriesCount(session.getUid()); + + int totalStandardVotesCount = 0; + + for (VoteQueContent question : (Set) voteContent.getVoteQueContents()) { + + SessionNominationDTO nominationDTO = new SessionNominationDTO(); + nominationDTO.setQuestionUid(question.getUid()); + nominationDTO.setNomination(question.getQuestion()); + + int votesCount = voteUsrAttemptDAO.getStandardAttemptsForQuestionContentAndSessionUid(question.getUid(), + session.getUid()); + totalStandardVotesCount += votesCount; + + nominationDTO.setNumberOfVotes(votesCount); + nominationDTO.setPercentageOfVotes( (entriesCount != 0) ? ((votesCount * 100) / entriesCount) : 0d ); + sessionDTO.getNominations().add(nominationDTO); + + } + + // open votes + if (voteContent.isAllowText()) { + int userEnteredVotesCount = entriesCount - totalStandardVotesCount; + Double voteRate = (userEnteredVotesCount != 0) ? ((userEnteredVotesCount * 100) / entriesCount) : 0d; + sessionDTO.setOpenTextNumberOfVotes(userEnteredVotesCount); + sessionDTO.setOpenTextPercentageOfVotes(voteRate); + } else { + sessionDTO.setOpenTextNumberOfVotes(0); + sessionDTO.setOpenTextPercentageOfVotes(0D); + } + + sessionDTOs.add(sessionDTO); + } + + // All groups total + if (sessionDTOs.size() > 1) { + SummarySessionDTO totalSessionDTO = new SummarySessionDTO(); + totalSessionDTO.setSessionUid(0L); + totalSessionDTO.setToolSessionId(0L); + totalSessionDTO.setSessionName(messageService.getMessage("label.all.groups.total")); + totalSessionDTO.setNominations(new TreeSet()); + + HashMap nominationsTotals = new HashMap(); + int totalOpenVotes = 0; + int totalVotes = 0; + for (SummarySessionDTO sessionDTO : sessionDTOs) { + + for ( SessionNominationDTO nomination : sessionDTO.getNominations() ) { + Long questionUid = nomination.getQuestionUid(); + SessionNominationDTO dto = nominationsTotals.get(questionUid); + if ( dto == null ) { + dto = new SessionNominationDTO(); + dto.setQuestionUid(questionUid); + dto.setNomination(nomination.getNomination()); + dto.setNumberOfVotes(0); + nominationsTotals.put(questionUid, dto); + totalSessionDTO.getNominations().add(dto); + } + totalVotes += nomination.getNumberOfVotes(); + dto.setNumberOfVotes(dto.getNumberOfVotes()+nomination.getNumberOfVotes()); + } + + totalVotes += sessionDTO.getOpenTextNumberOfVotes(); + totalOpenVotes += sessionDTO.getOpenTextNumberOfVotes(); + } + for ( SessionNominationDTO nomination : totalSessionDTO.getNominations() ) { + nomination.setPercentageOfVotes( (totalVotes != 0) ? ((nomination.getNumberOfVotes() * 100) / totalVotes) : 0d); + } + totalSessionDTO.setOpenTextNumberOfVotes(totalOpenVotes); + totalSessionDTO.setOpenTextPercentageOfVotes( (totalVotes != 0) ? ((totalOpenVotes * 100) / totalVotes) : 0d); + sessionDTOs.add(totalSessionDTO); + } + + return sessionDTOs; + } + /** * Get the count of all the potential learners for the vote session. This will include the people that have never * logged into the lesson. Not great, but it is a better estimate of how many users there will be eventually than @@ -465,8 +553,7 @@ private int getVoteSessionPotentialLearnersCount(Long sessionUid) { VoteSession session = voteSessionDAO.getVoteSessionByUID(sessionUid); if (session != null) { - Set potentialLearners = toolService.getAllPotentialLearners(session.getVoteSessionId().longValue()); - return potentialLearners != null ? potentialLearners.size() : 0; + return toolService.getCountUsersForActivity(session.getVoteSessionId()); } else { VoteServicePOJO.logger .error("Unable to find vote session record id=" + sessionUid + ". Returning 0 users."); @@ -924,11 +1011,6 @@ } @Override - public List getStandardAttemptsByQuestionUid(final Long voteQueContentId) { - return voteUsrAttemptDAO.getStandardAttemptsByQuestionUid(voteQueContentId); - } - - @Override public VoteUsrAttempt getAttemptByUID(Long uid) { return voteUsrAttemptDAO.getAttemptByUID(uid); } @@ -955,12 +1037,12 @@ Date attempTime = new Date(System.currentTimeMillis()); String timeZone = TimeZone.getDefault().getDisplayName(); - //in case of free entry + // in case of free entry if (mapGeneralCheckedOptionsContent.size() == 0) { VoteQueContent defaultContentFirstQuestion = voteQueContentDAO.getDefaultVoteContentFirstQuestion(); createAttempt(defaultContentFirstQuestion, voteQueUsr, attempTime, timeZone, userEntry, voteSession); - //if the question is selected + // if the question is selected } else if (voteContentUid != null) { Iterator itCheckedMap = mapGeneralCheckedOptionsContent.entrySet().iterator(); while (itCheckedMap.hasNext()) { @@ -995,11 +1077,6 @@ } @Override - public int getUserEnteredVotesCountForContent(final Long voteContentUid) { - return voteUsrAttemptDAO.getUserEnteredVotesCountForContent(voteContentUid); - } - - @Override public VoteQueContent getQuestionByUid(Long uid) { return voteQueContentDAO.getQuestionByUid(uid); } @@ -1074,19 +1151,7 @@ return !voteContent.getVoteSessions().isEmpty(); } - @Override - public boolean studentActivityOccurredStandardAndOpen(VoteContent voteContent) { - boolean studentActivityOccurredGlobal = studentActivityOccurredGlobal(voteContent); - int userEnteredVotesCount = getUserEnteredVotesCountForContent(voteContent.getUid()); - if ((studentActivityOccurredGlobal == true) || (userEnteredVotesCount > 0)) { - return true; - } - - // there is no votes/nominations for this content - return false; - } - @Override public void recalculateUserAnswers(VoteContent content, Set oldQuestions, List questionDTOs, List deletedQuestions) { @@ -1525,6 +1590,48 @@ return voteQueContentDAO.getAllQuestionsSorted(voteContentId); } + + /******** Tablesorter methods ************/ + /** + * Gets the basic details about an attempt for a nomination. questionUid must not be null, sessionUid may be NULL. This is + * unusual for these methods - usually sessionId may not be null. In this case if sessionUid is null then you get + * the values for the whole class, not just the group. + * + * Will return List<[login (String), fullname(String), attemptTime(Timestamp]> + */ + public List getUserAttemptsForTablesorter(Long sessionUid, Long questionUid, int page, int size, + int sorting, String searchString) { + return voteUsrAttemptDAO.getUserAttemptsForTablesorter(sessionUid, questionUid, page, size, sorting, searchString); + } + + public int getCountUsersBySession(Long sessionUid, Long questionUid, String searchString) { + return voteUsrAttemptDAO.getCountUsersBySession(sessionUid, questionUid, searchString); + } + + public List getUserReflectionsForTablesorter(Long sessionUid, int page, int size, int sorting, + String searchString) { + return voteUsrAttemptDAO.getUserReflectionsForTablesorter(sessionUid, page, size, sorting, searchString, getCoreNotebookService()); + } + + public List getStatisticsBySession(Long toolContentId) { + + List stats = voteUsrAttemptDAO.getStatisticsBySession(toolContentId); + for ( VoteStatsDTO stat : stats ) { + stat.setCountAllUsers(getVoteSessionPotentialLearnersCount(stat.getSessionUid())); + } + return stats; + } + + /** Gets the details for the open text nominations */ + public List getUserOpenTextAttemptsForTablesorter(Long sessionUid, Long contentUid, int page, int size, + int sorting, String searchStringVote, String searchStringUsername) { + return voteUsrAttemptDAO.getUserOpenTextAttemptsForTablesorter(sessionUid, contentUid, page, size, sorting, searchStringVote, searchStringUsername); + } + + public int getCountUsersForOpenTextEntries(Long sessionUid, Long contentUid, String searchStringVote, String searchStringUsername) { + return voteUsrAttemptDAO.getCountUsersForOpenTextEntries(sessionUid, contentUid, searchStringVote, searchStringUsername); + } + /** * @return Returns the toolService. */ Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java (.../ExportServlet.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/ExportServlet.java (.../ExportServlet.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -111,7 +111,7 @@ LinkedList sessionDTOs = getSessionDTOs(request, content, voteService, toolSessionID, userID); exportPortfolioDTO.setSessionDtos(sessionDTOs); - boolean userExceptionNoToolSessions = !voteService.studentActivityOccurredStandardAndOpen(content); + boolean userExceptionNoToolSessions = !voteService.studentActivityOccurredGlobal(content); exportPortfolioDTO.setUserExceptionNoToolSessions(userExceptionNoToolSessions); boolean isGroupedActivity = voteService.isGroupedActivity(content.getVoteContentId()); @@ -152,7 +152,7 @@ LinkedList sessionDTOs = getSessionDTOs(request, content, voteService, null, null); exportPortfolioDTO.setSessionDtos(sessionDTOs); - boolean userExceptionNoToolSessions = !voteService.studentActivityOccurredStandardAndOpen(content); + boolean userExceptionNoToolSessions = !voteService.studentActivityOccurredGlobal(content); exportPortfolioDTO.setUserExceptionNoToolSessions(userExceptionNoToolSessions); request.getSession().setAttribute(VoteAppConstants.EXPORT_PORTFOLIO_DTO, exportPortfolioDTO); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java =================================================================== diff -u -rcce41fc01efa8103d62fac358488b979e8e90ad6 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision cce41fc01efa8103d62fac358488b979e8e90ad6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -24,8 +24,6 @@ import java.io.IOException; import java.util.Date; -import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.TimeZone; @@ -34,19 +32,23 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionRedirect; +import org.apache.tomcat.util.json.JSONArray; +import org.apache.tomcat.util.json.JSONException; +import org.apache.tomcat.util.json.JSONObject; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.vote.VoteAppConstants; +import org.lamsfoundation.lams.tool.vote.dto.OpenTextAnswerDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO; -import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt; import org.lamsfoundation.lams.tool.vote.service.IVoteService; import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy; @@ -73,101 +75,215 @@ } public ActionForward hideOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException, ToolException { - IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException { + return toggleHideShow(request, response, false); + } - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + public ActionForward showOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException { + return toggleHideShow(request, response, true); + } + + private ActionForward toggleHideShow(HttpServletRequest request, HttpServletResponse response, boolean show) + throws IOException, ServletException, ToolException, JSONException { - String currentUid = voteMonitoringForm.getCurrentUid(); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); - VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); + Long currentUid = WebUtil.readLongParam(request, "currentUid"); + VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(currentUid); - voteUsrAttempt.setVisible(false); + voteUsrAttempt.setVisible(show); voteService.updateVoteUsrAttempt(voteUsrAttempt); - voteService.hideOpenVote(voteUsrAttempt); - - String toolContentID = voteMonitoringForm.getToolContentID(); - String contentFolderID = voteMonitoringForm.getContentFolderID(); + String nextActionMethod; + if ( show ) { + nextActionMethod = "hideOptionVote"; + voteService.showOpenVote(voteUsrAttempt); + } else { + nextActionMethod = "showOpenVote"; + voteService.hideOpenVote(voteUsrAttempt); + } - ActionRedirect redirect = new ActionRedirect( - mapping.findForwardConfig(VoteAppConstants.MONITORING_STARTER_REDIRECT)); - redirect.addParameter(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentID); - redirect.addParameter(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); - return redirect; + JSONObject responsedata = new JSONObject(); + responsedata.put("currentUid", currentUid); + responsedata.put("nextActionMethod", nextActionMethod); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(new String(responsedata.toString())); + return null; } - public ActionForward showOpenVote(ActionMapping mapping, ActionForm form, HttpServletRequest request, + public ActionForward getVoteNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException { + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; + voteMonitoringForm.setVoteService(voteService); - String currentUid = voteMonitoringForm.getCurrentUid(); + VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); + MonitoringUtil.repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - VoteUsrAttempt voteUsrAttempt = voteService.getAttemptByUID(new Long(currentUid)); - voteUsrAttempt.setVisible(true); + Long questionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_QUESTION_UID, false); + Long sessionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SESSION_UID, true); - voteService.updateVoteUsrAttempt(voteUsrAttempt); - voteService.showOpenVote(voteUsrAttempt); + VoteQueContent nomination = voteService.getQuestionByUid(questionUid); + request.setAttribute("nominationText", nomination.getQuestion()); - String toolContentID = voteMonitoringForm.getToolContentID(); - String contentFolderID = voteMonitoringForm.getContentFolderID(); - - ActionRedirect redirect = new ActionRedirect( - mapping.findForwardConfig(VoteAppConstants.MONITORING_STARTER_REDIRECT)); - redirect.addParameter(AttributeNames.PARAM_TOOL_CONTENT_ID, toolContentID); - redirect.addParameter(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); - return redirect; + request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + request.setAttribute(VoteAppConstants.ATTR_QUESTION_UID, questionUid); + if ( sessionUid != null ) + request.setAttribute(VoteAppConstants.ATTR_SESSION_UID, sessionUid); + return mapping.findForward(VoteAppConstants.VOTE_NOMINATION_VIEWER); } - public ActionForward getVoteNomination(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException, ToolException { + public ActionForward getVoteNominationsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException { + + Long sessionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SESSION_UID, true); + if ( sessionUid == 0L ) + sessionUid = null; + + Long questionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_QUESTION_UID, false); + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer sortByName = WebUtil.readIntParam(request, "column[0]", true); + Integer sortByDate = WebUtil.readIntParam(request, "column[1]", true); + String searchString = request.getParameter("fcol[0]"); + + int sorting = VoteAppConstants.SORT_BY_DEFAULT; + if ( sortByName != null ) + sorting = sortByName.equals(0) ? VoteAppConstants.SORT_BY_NAME_ASC : VoteAppConstants.SORT_BY_NAME_DESC; + else if ( sortByDate != null ) + sorting = sortByDate.equals(0) ? VoteAppConstants.SORT_BY_DATE_ASC : VoteAppConstants.SORT_BY_DATE_DESC; + + //return user list according to the given sessionID IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + List users = voteService.getUserAttemptsForTablesorter(sessionUid, questionUid, page, size, sorting, searchString); + + JSONArray rows = new JSONArray(); + JSONObject responsedata = new JSONObject(); + responsedata.put("total_rows", voteService.getCountUsersBySession(sessionUid, questionUid, searchString)); - VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form; - voteMonitoringForm.setVoteService(voteService); + for (Object[] userAndAnswers: users) { - VoteGeneralMonitoringDTO voteGeneralMonitoringDTO = new VoteGeneralMonitoringDTO(); - MonitoringUtil.repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); + JSONObject responseRow = new JSONObject(); + responseRow.put(VoteAppConstants.ATTR_USER_NAME, StringEscapeUtils.escapeHtml((String) userAndAnswers[1])); + responseRow.put(VoteAppConstants.ATTR_ATTEMPT_TIME, DateUtil.convertToStringForJSON((Date) userAndAnswers[2], request.getLocale())); + rows.put(responseRow); + } + responsedata.put("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(new String(responsedata.toString())); + return null; + } - String questionUid = request.getParameter("questionUid"); - String sessionUid = request.getParameter("sessionUid"); + public ActionForward getReflectionsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException { + + Long sessionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SESSION_UID, true); - List userAttempts; - //in regular case when we need info for particular session - if (StringUtils.isNotBlank(sessionUid)) { - userAttempts = voteService.getAttemptsForQuestionContentAndSessionUid(new Long(questionUid), - new Long(sessionUid)); + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer sortByName = WebUtil.readIntParam(request, "column[0]", true); + String searchString = request.getParameter("fcol[0]"); + + int sorting = VoteAppConstants.SORT_BY_DEFAULT; + if ( sortByName != null ) + sorting = sortByName.equals(0) ? VoteAppConstants.SORT_BY_NAME_ASC : VoteAppConstants.SORT_BY_NAME_DESC; - //in case of All sessions - } else { - userAttempts = voteService.getStandardAttemptsByQuestionUid(new Long(questionUid)); + //return user list according to the given sessionID + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + List users = voteService.getUserReflectionsForTablesorter(sessionUid, page, size, sorting, searchString); + + JSONArray rows = new JSONArray(); + JSONObject responsedata = new JSONObject(); + responsedata.put("total_rows", voteService.getCountUsersBySession(sessionUid, null, searchString)); + + for (Object[] userAndReflection: users) { + JSONObject responseRow = new JSONObject(); + responseRow.put(VoteAppConstants.ATTR_USER_NAME, StringEscapeUtils.escapeHtml((String) userAndReflection[1])); + if ( userAndReflection.length > 2 && userAndReflection[2] != null) { + String reflection = StringEscapeUtils.escapeHtml((String)userAndReflection[2]); + responseRow.put(VoteAppConstants.NOTEBOOK, reflection.replaceAll("\n", "
")); + } + rows.put(responseRow); } + responsedata.put("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(new String(responsedata.toString())); + return null; + } + + public ActionForward statistics(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException { - List listVotedLearnersDTO = new LinkedList(); + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + + request.setAttribute("isGroupedActivity", voteService.isGroupedActivity(toolContentID)); + request.setAttribute(VoteAppConstants.VOTE_STATS_DTO, voteService.getStatisticsBySession(toolContentID)); + return mapping.findForward(VoteAppConstants.STATISTICS); + } - VoteContent voteContent = null; - Iterator userIterator = userAttempts.iterator(); - while (userIterator.hasNext()) { - VoteUsrAttempt voteUsrAttempt = (VoteUsrAttempt) userIterator.next(); + + public ActionForward getOpenTextNominationsJSON(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException, ToolException, JSONException { + + Long sessionUid = WebUtil.readLongParam(request, VoteAppConstants.ATTR_SESSION_UID, true); + if ( sessionUid == 0L ) + sessionUid = null; - if (voteUsrAttempt != null) { - voteContent = voteUsrAttempt.getVoteQueContent().getVoteContent(); - } + Long contentUid = WebUtil.readLongParam(request, VoteAppConstants.TOOL_CONTENT_UID, false); - VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO(); - voteMonitoredUserDTO.setUserName(voteUsrAttempt.getVoteQueUsr().getFullname()); - voteMonitoredUserDTO.setAttemptTime(voteUsrAttempt.getAttemptTime()); - listVotedLearnersDTO.add(voteMonitoredUserDTO); - } + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer sortByEntry = WebUtil.readIntParam(request, "column[0]", true); + Integer sortByName = WebUtil.readIntParam(request, "column[1]", true); + Integer sortByDate = WebUtil.readIntParam(request, "column[2]", true); + Integer sortByVisible = WebUtil.readIntParam(request, "column[3]", true); + String searchStringVote = request.getParameter("fcol[0]"); + String searchStringUsername = request.getParameter("fcol[1]"); + + int sorting = VoteAppConstants.SORT_BY_DEFAULT; + if ( sortByEntry != null ) + sorting = sortByEntry.equals(0) ? VoteAppConstants.SORT_BY_ENTRY_ASC : VoteAppConstants.SORT_BY_ENTRY_DESC; + if ( sortByName != null ) + sorting = sortByName.equals(0) ? VoteAppConstants.SORT_BY_NAME_ASC : VoteAppConstants.SORT_BY_NAME_DESC; + else if ( sortByDate != null ) + sorting = sortByDate.equals(0) ? VoteAppConstants.SORT_BY_DATE_ASC : VoteAppConstants.SORT_BY_DATE_DESC; + else if ( sortByVisible != null ) + sorting = sortByVisible.equals(0) ? VoteAppConstants.SORT_BY_VISIBLE_ASC : VoteAppConstants.SORT_BY_VISIBLE_DESC; + + //return user list according to the given sessionID + IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); + List users = voteService.getUserOpenTextAttemptsForTablesorter(sessionUid, contentUid, page, size, sorting, searchStringVote, searchStringUsername); + + JSONArray rows = new JSONArray(); + JSONObject responsedata = new JSONObject(); + responsedata.put("total_rows", voteService.getCountUsersForOpenTextEntries(sessionUid, contentUid, searchStringVote, searchStringUsername)); + + for (OpenTextAnswerDTO userAndAttempt: users) { + JSONObject responseRow = new JSONObject(); - voteGeneralMonitoringDTO.setMapStudentsVoted(listVotedLearnersDTO); - request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); + responseRow.put("uid", userAndAttempt.getUserUid()); + responseRow.put(VoteAppConstants.ATTR_USER_NAME, StringEscapeUtils.escapeHtml(userAndAttempt.getFullName())); - return mapping.findForward(VoteAppConstants.VOTE_NOMINATION_VIEWER); - } + responseRow.put("userEntryUid", userAndAttempt.getUserEntryUid()); + responseRow.put("userEntry", StringEscapeUtils.escapeHtml(userAndAttempt.getUserEntry())); + responseRow.put(VoteAppConstants.ATTR_ATTEMPT_TIME, DateUtil.convertToStringForJSON(userAndAttempt.getAttemptTime(), request.getLocale())); + responseRow.put("visible", userAndAttempt.isVisible()); + rows.put(responseRow); + } + responsedata.put("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(new String(responsedata.toString())); + return null; + } + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, ToolException { IVoteService VoteService = VoteServiceProxy.getVoteService(getServlet().getServletContext()); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java =================================================================== diff -u -r708bd4d049ae0a59d70c964ef2f864d2b7a352e6 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 708bd4d049ae0a59d70c964ef2f864d2b7a352e6) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -28,6 +28,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.SortedSet; import java.util.Map.Entry; import java.util.Set; import java.util.TimeZone; @@ -46,12 +47,12 @@ import org.lamsfoundation.lams.tool.vote.VoteAppConstants; import org.lamsfoundation.lams.tool.vote.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.vote.dto.SessionDTO; +import org.lamsfoundation.lams.tool.vote.dto.SummarySessionDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteGeneralMonitoringDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteMonitoredUserDTO; import org.lamsfoundation.lams.tool.vote.dto.VoteQuestionDTO; -import org.lamsfoundation.lams.tool.vote.dto.VoteStatsDTO; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr; @@ -97,189 +98,28 @@ } // initialiseMonitoringData - voteGeneralMonitoringDTO.setRequestLearningReport(new Boolean(false).toString()); + voteGeneralMonitoringDTO.setRequestLearningReport(Boolean.FALSE.toString()); /* we have made sure TOOL_CONTENT_ID is passed */ String toolContentID = voteMonitoringForm.getToolContentID(); VoteContent voteContent = voteService.getVoteContent(new Long(toolContentID)); if (voteContent == null) { VoteUtils.cleanUpUserExceptions(request); - voteGeneralMonitoringDTO.setUserExceptionContentDoesNotExist(new Boolean(true).toString()); + voteGeneralMonitoringDTO.setUserExceptionContentDoesNotExist(Boolean.TRUE.toString()); return (mapping.findForward(VoteAppConstants.ERROR_LIST)); } voteGeneralMonitoringDTO.setActivityTitle(voteContent.getTitle()); voteGeneralMonitoringDTO.setActivityInstructions(voteContent.getInstructions()); - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { - VoteUtils.cleanUpUserExceptions(request); - voteGeneralMonitoringDTO.setUserExceptionContentInUse(new Boolean(true).toString()); - } - - /* - * get the nominations section is needed for the Edit tab's View Only mode, starts here - */ - SessionMap sessionMap = new SessionMap(); - sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteContent.getTitle()); - sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); - - voteMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - - List listQuestionDTO = new LinkedList(); - - Iterator queIterator = voteContent.getVoteQueContents().iterator(); - while (queIterator.hasNext()) { - VoteQuestionDTO voteQuestionDTO = new VoteQuestionDTO(); - - VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); - if (voteQueContent != null) { - - voteQuestionDTO.setQuestion(voteQueContent.getQuestion()); - voteQuestionDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); - listQuestionDTO.add(voteQuestionDTO); - } - } - - request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); - sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); - /* this section is related to summary tab. Starts here. */ + + SortedSet sessionDTOs = voteService.getMonitoringSessionDTOs(new Long(toolContentID)); + request.setAttribute("sessionDTOs", sessionDTOs); - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } else { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - - String userExceptionNoToolSessions = voteGeneralMonitoringDTO.getUserExceptionNoToolSessions(); - - Set questions = voteContent.getVoteQueContents(); - - List listMonitoredAnswersContainerDTO = new LinkedList(); - - Iterator itListQuestions = questions.iterator(); - while (itListQuestions.hasNext()) { - VoteQueContent voteQueContent = (VoteQueContent) itListQuestions.next(); - - if (voteQueContent != null) { - VoteMonitoredAnswersDTO voteMonitoredAnswersDTO = new VoteMonitoredAnswersDTO(); - voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString()); - voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion()); - - String questionUid = voteQueContent.getUid().toString(); - - List> listMonitoredAttemptsContainerDTO = new LinkedList>(); - - // populateToolSessionsId - List sessionIds = voteService.getSessionsFromContent(voteContent); - Map summaryToolSessions = new TreeMap(new VoteComparator()); - int mapIndex = 1; - for (Long sessionId : sessionIds) { - summaryToolSessions.put("" + mapIndex, sessionId.toString()); - mapIndex++; - } - if (summaryToolSessions.isEmpty()) { - summaryToolSessions.put(new Long(1).toString(), "None"); - } else { - summaryToolSessions.put(new Long(summaryToolSessions.size() + 1).toString(), "All"); - } - - for (Entry pairs : summaryToolSessions.entrySet()) { - - if (!(pairs.getValue().equals("None")) && !(pairs.getValue().equals("All"))) { - VoteSession voteSession = voteService.getSessionBySessionId(new Long(pairs.getValue())); - if (voteSession != null) { - List users = voteService.getUserBySessionOnly(voteSession); - Map sessionUsersAttempts = VoteMonitoringStarterAction - .populateSessionUsersAttempts(request, voteContent, voteSession.getVoteSessionId(), - users, questionUid, false, null, voteService); - listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - } - } - } - - // //create data for All sessions in total - // if (summaryToolSessions.size() > 1) { - // Map sessionUsersAttempts = populateSessionUsersAttempts(request, - // voteContent, voteSession.getVoteSessionId(), users, questionUid, isUserNamesVisible, - // isLearnerRequest, userId, voteService); - // listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); - // } - - Map questionAttemptData = new TreeMap(new VoteComparator()); - Iterator listIterator = listMonitoredAttemptsContainerDTO.iterator(); - Long mapIndex2 = new Long(1); - while (listIterator.hasNext()) { - Map data = (Map) listIterator.next(); - questionAttemptData.put(mapIndex2.toString(), data); - mapIndex2 = new Long(mapIndex2.longValue() + 1); - } - voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); - listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO); - - } - } - /* ends here. */ - - List userEnteredNominations = voteService.getOpenVotes(voteContent.getUid(), null, - null); - - voteGeneralMonitoringDTO.setListMonitoredAnswersContainerDto(listMonitoredAnswersContainerDTO); - voteGeneralMonitoringDTO.setListUserEntries(userEnteredNominations); - - voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(false).toString()); - if (userEnteredNominations.size() > 0) { - voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(true).toString()); - } - - if (voteService.studentActivityOccurredGlobal(voteContent)) { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } else { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); - } - request.setAttribute(VoteAppConstants.VOTE_GENERAL_MONITORING_DTO, voteGeneralMonitoringDTO); - // find out if there are any reflection entries - if (!voteContent.getVoteSessions().isEmpty()) { - request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - if (userExceptionNoToolSessions.equals("true")) { - // there are no online student activity but there are reflections - request.setAttribute(VoteAppConstants.NO_SESSIONS_NOTEBOOK_ENTRIES_EXIST, new Boolean(true).toString()); - } - } else { - request.setAttribute(VoteAppConstants.NOTEBOOK_ENTRIES_EXIST, new Boolean(false).toString()); - } - - // buildVoteStatsDTO - int countSessionComplete = 0; - int countAllUsers = 0; - Iterator iteratorSession = voteContent.getVoteSessions().iterator(); - while (iteratorSession.hasNext()) { - VoteSession voteSession = (VoteSession) iteratorSession.next(); - - if (voteSession != null) { - if (voteSession.getSessionStatus().equals(VoteAppConstants.COMPLETED)) { - ++countSessionComplete; - } - - Iterator iteratorUser = voteSession.getVoteQueUsers().iterator(); - while (iteratorUser.hasNext()) { - VoteQueUsr voteQueUsr = (VoteQueUsr) iteratorUser.next(); - if (voteQueUsr != null) { - ++countAllUsers; - } - } - } - } - - VoteStatsDTO voteStatsDTO = new VoteStatsDTO(); - voteStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString()); - voteStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); - request.setAttribute(VoteAppConstants.VOTE_STATS_DTO, voteStatsDTO); - // setting up the advanced summary for LDEV-1662 request.setAttribute("useSelectLeaderToolOuput", voteContent.isUseSelectLeaderToolOuput()); request.setAttribute("lockOnFinish", voteContent.isLockOnFinish()); @@ -301,210 +141,56 @@ request.setAttribute(VoteAppConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); } - voteGeneralMonitoringDTO.setExistsOpenVotes(new Boolean(false).toString()); - voteMonitoringForm.setCurrentTab("1"); voteGeneralMonitoringDTO.setCurrentTab("1"); + voteGeneralMonitoringDTO.setIsPortfolioExport(Boolean.FALSE.toString()); - /* true means there is at least 1 response */ - if (voteService.studentActivityOccurredStandardAndOpen(voteContent)) { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(false).toString()); - } else { - voteGeneralMonitoringDTO.setUserExceptionNoToolSessions(new Boolean(true).toString()); + if (sessionDTOs.size() > 0) { + VoteUtils.cleanUpUserExceptions(request); + voteGeneralMonitoringDTO.setUserExceptionContentInUse(Boolean.TRUE.toString()); } - voteGeneralMonitoringDTO.setIsPortfolioExport(new Boolean(false).toString()); + /* + * get the nominations section is needed for the Edit tab's View Only mode, starts here + */ + SessionMap sessionMap = new SessionMap(); + sessionMap.put(VoteAppConstants.ACTIVITY_TITLE_KEY, voteContent.getTitle()); + sessionMap.put(VoteAppConstants.ACTIVITY_INSTRUCTIONS_KEY, voteContent.getInstructions()); + voteMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + List listQuestionDTO = new LinkedList(); + + Iterator queIterator = voteContent.getVoteQueContents().iterator(); + while (queIterator.hasNext()) { + VoteQuestionDTO voteQuestionDTO = new VoteQuestionDTO(); + + VoteQueContent voteQueContent = (VoteQueContent) queIterator.next(); + if (voteQueContent != null) { + + voteQuestionDTO.setQuestion(voteQueContent.getQuestion()); + voteQuestionDTO.setDisplayOrder(new Integer(voteQueContent.getDisplayOrder()).toString()); + listQuestionDTO.add(voteQuestionDTO); + } + } + + request.setAttribute(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); + sessionMap.put(VoteAppConstants.LIST_QUESTION_DTO, listQuestionDTO); + // this section is needed for Edit Activity screen voteGeneralAuthoringDTO.setActivityTitle(voteGeneralMonitoringDTO.getActivityTitle()); voteGeneralAuthoringDTO.setActivityInstructions(voteGeneralMonitoringDTO.getActivityInstructions()); MonitoringUtil.repopulateRequestParameters(request, voteMonitoringForm, voteGeneralMonitoringDTO); - List sessionDTOs = voteService.getSessionDTOs(new Long(toolContentID)); - voteGeneralMonitoringDTO.setSessionDTOs(sessionDTOs); - boolean isGroupedActivity = voteService.isGroupedActivity(new Long(toolContentID)); request.setAttribute("isGroupedActivity", isGroupedActivity); + request.setAttribute("isAllowText", voteContent.isAllowText()); - // refreshStatsData - /* it is possible that no users has ever logged in for the activity yet */ - int countAllUsers2 = voteService.getTotalNumberOfUsers(); - if (countAllUsers2 == 0) { - voteGeneralMonitoringDTO.setUserExceptionNoStudentActivity(new Boolean(true).toString()); - } - voteGeneralMonitoringDTO.setCountAllUsers(new Integer(countAllUsers2).toString()); - int countSessionComplete2 = voteService.countSessionComplete(); - voteGeneralMonitoringDTO.setCountSessionComplete(new Integer(countSessionComplete2).toString()); - - List reflectionsContainerDTO = voteService.getReflectionData(voteContent, null); - request.setAttribute(VoteAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionsContainerDTO); - return mapping.findForward(VoteAppConstants.LOAD_MONITORING); } - private static Map populateSessionUsersAttempts(HttpServletRequest request, - VoteContent voteContent, Long sessionId, List listUsers, String questionUid, boolean isLearnerRequest, - Long userId, IVoteService voteService) { - - List listMonitoredUserContainerDTO = new LinkedList(); - Iterator itUsers = listUsers.iterator(); - - if (userId == null) { - if (!isLearnerRequest) { - while (itUsers.hasNext()) { - VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); - - if (voteQueUsr != null) { - List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), - new Long(questionUid)); - - Iterator itAttempts = listUserAttempts.iterator(); - while (itAttempts.hasNext()) { - VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); - - 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()); - - voteMonitoredUserDTO.setQuestionUid(questionUid); - - VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); - String entry = voteQueContent.getQuestion(); - - String voteQuestionUid = voteUsrResp.getVoteQueContent().getUid().toString(); - - VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); - if (voteContent.getVoteContentId().toString() - .equals(localUserSession.getVoteContentId().toString())) { - if (entry != null) { - if (entry.equals("sample nomination") && (voteQuestionUid.equals("1"))) { - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } else { - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } - - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } else { - // summary reporting case 2 - // just populating data normally just like monitoring summary, except that the data is ony for a - // specific session - String userID = (String) request.getSession().getAttribute(VoteAppConstants.USER_ID); - VoteQueUsr voteQueUsr = voteService.getUserById(new Long(userID).longValue()); - - while (itUsers.hasNext()) { - voteQueUsr = (VoteQueUsr) itUsers.next(); - - if (voteQueUsr != null) { - List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), - new Long(questionUid)); - - Iterator itAttempts = listUserAttempts.iterator(); - while (itAttempts.hasNext()) { - VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); - - 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()); - voteMonitoredUserDTO.setQuestionUid(questionUid); - - VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); - String entry = voteQueContent.getQuestion(); - String questionUid2 = voteUsrResp.getVoteQueContent().getUid().toString(); - - VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); - if (voteContent.getVoteContentId().toString() - .equals(localUserSession.getVoteContentId().toString())) { - if (entry != null) { - if (entry.equals("sample nomination") && (questionUid2.equals("1"))) { - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } else { - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } - - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } - } else { - // summary reporting case 4 - // request is for learner progress report userId - while (itUsers.hasNext()) { - VoteQueUsr voteQueUsr = (VoteQueUsr) itUsers.next(); - - if (voteQueUsr != null) { - List listUserAttempts = voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), - new Long(questionUid)); - - Iterator itAttempts = listUserAttempts.iterator(); - while (itAttempts.hasNext()) { - VoteUsrAttempt voteUsrResp = (VoteUsrAttempt) itAttempts.next(); - - if (voteUsrResp != null) { - if (userId.equals(voteQueUsr.getQueUsrId())) { - // 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()); - voteMonitoredUserDTO.setQuestionUid(questionUid); - - VoteQueContent voteQueContent = voteUsrResp.getVoteQueContent(); - String entry = voteQueContent.getQuestion(); - - String voteQueContentId = voteUsrResp.getVoteQueContent().getUid().toString(); - - VoteSession localUserSession = voteUsrResp.getVoteQueUsr().getVoteSession(); - if (voteContent.getVoteContentId().toString() - .equals(localUserSession.getVoteContentId().toString())) { - if (entry != null) { - if (entry.equals("sample nomination") && (voteQueContentId.equals("1"))) { - voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry()); - } else { - voteMonitoredUserDTO.setResponse(voteQueContent.getQuestion()); - } - } - } - - listMonitoredUserContainerDTO.add(voteMonitoredUserDTO); - } - } - } - } - } - - } - - Map mapMonitoredUserContainerDTO = MonitoringUtil - .convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO); - return mapMonitoredUserContainerDTO; - } - private ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping, VoteMonitoringForm voteMonitoringForm) { Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/form/VoteMonitoringForm.java =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/form/VoteMonitoringForm.java (.../VoteMonitoringForm.java) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/form/VoteMonitoringForm.java (.../VoteMonitoringForm.java) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -45,8 +45,6 @@ protected String currentUid; - protected String existsOpenVotes; - protected String toolContentID; /** @@ -153,19 +151,4 @@ public void setShowOpenVote(String showOpenVote) { this.showOpenVote = showOpenVote; } - - /** - * @return Returns the existsOpenVotes. - */ - public String getExistsOpenVotes() { - return existsOpenVotes; - } - - /** - * @param existsOpenVotes - * The existsOpenVotes to set. - */ - public void setExistsOpenVotes(String existsOpenVotes) { - this.existsOpenVotes = existsOpenVotes; - } } Index: lams_tool_vote/web/WEB-INF/struts-config.xml =================================================================== diff -u -r5b17b810b5302c90b2daf6a5866bf4f6e85bef6a -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 5b17b810b5302c90b2daf6a5866bf4f6e85bef6a) +++ lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -385,13 +385,12 @@ redirect="false" /> - + /> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_tool_vote/web/monitoring/AllSessionsSummary.jsp =================================================================== diff -u -r0cf0d00e80ef05535a52247a471dd7db8d566fac -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision 0cf0d00e80ef05535a52247a471dd7db8d566fac) +++ lams_tool_vote/web/monitoring/AllSessionsSummary.jsp (.../AllSessionsSummary.jsp) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -3,8 +3,21 @@ - + +

+
+ + + +
+ + + + /monitoring/ReflectionViewer.jsp?sessionUid=${sessionUid} + + +

@@ -19,158 +32,69 @@ - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - monitoring.do?dispatch=getVoteNomination&questionUid=${currentQuestionUid.value}&sessionUid=${sessionUidParam} - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  ( ) - - + + monitoring.do?dispatch=getVoteNomination&questionUid=${questionUid}&sessionUid=${sessionUid} + + + + +  () - - - - + + - - + + + + + +
+ + + + monitoring/OtherTextNominationViewer.jsp?&toolContentUID=${toolContentID}&sessionUid=${sessionUid} + + + + +  ( ) +
+ +

+ + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - +

+ + + + +

- - -

- - - - -

- - -
+ + - -


-
- -

+

+
Fisheye: Tag 81d3515d29fd57e3b9e08cc37481fd0becbd8b10 refers to a dead (removed) revision in file `lams_tool_vote/web/monitoring/LearnerNotebook.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_vote/web/monitoring/MonitoringMaincontent.jsp =================================================================== diff -u -r1a02559e19419af9991eaeb9363f809355b39bc7 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 1a02559e19419af9991eaeb9363f809355b39bc7) +++ lams_tool_vote/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -1,5 +1,4 @@ - + <%@ include file="/common/taglibs.jsp"%> @@ -21,6 +20,8 @@ <fmt:message key="label.monitoring"/> <%@ include file="/common/tabbedheader.jsp"%> + + Index: lams_tool_vote/web/monitoring/OtherTextNominationViewer.jsp =================================================================== diff -u --- lams_tool_vote/web/monitoring/OtherTextNominationViewer.jsp (revision 0) +++ lams_tool_vote/web/monitoring/OtherTextNominationViewer.jsp (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,176 @@ + + +<%@ include file="/common/taglibs.jsp"%> + + + + <fmt:message key="label.learnersVoted"/> + + <%@ include file="/common/monitorheader.jsp"%> + + + + + +
+ +

:

+ +
+ + + + + +
+ + + + + + + + + + + + +
+ + +
+
+ + + + + + +
+
+
+ +
+ + +
Index: lams_tool_vote/web/monitoring/ReflectionViewer.jsp =================================================================== diff -u --- lams_tool_vote/web/monitoring/ReflectionViewer.jsp (revision 0) +++ lams_tool_vote/web/monitoring/ReflectionViewer.jsp (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,122 @@ + + +<%@ include file="/common/taglibs.jsp"%> + + + + <fmt:message key="label.learnersVoted"/> + + <%@ include file="/common/monitorheader.jsp"%> + + + + + +
+ +

+ +
+ + + + + + + + + +
+ + +
+
+ + + + + + +
+
+
+ +
+ + +
Fisheye: Tag 81d3515d29fd57e3b9e08cc37481fd0becbd8b10 refers to a dead (removed) revision in file `lams_tool_vote/web/monitoring/Reflections.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_vote/web/monitoring/Stats.jsp =================================================================== diff -u -r7d43dcacf4063a54d817283abe392c72e9968e97 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/monitoring/Stats.jsp (.../Stats.jsp) (revision 7d43dcacf4063a54d817283abe392c72e9968e97) +++ lams_tool_vote/web/monitoring/Stats.jsp (.../Stats.jsp) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -1,21 +1,5 @@ <%@ include file="/common/taglibs.jsp"%> - - - - - - - - - - -
- -
-
- - - - - - + +
+ <%@ include file="StatsPart.jsp"%> +
Index: lams_tool_vote/web/monitoring/StatsPart.jsp =================================================================== diff -u --- lams_tool_vote/web/monitoring/StatsPart.jsp (revision 0) +++ lams_tool_vote/web/monitoring/StatsPart.jsp (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -0,0 +1,17 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + +

${stats.sessionName}

+
+ +

${stats.countUsersComplete}
+ ${stats.countAllUsers}

+ +
+ Index: lams_tool_vote/web/monitoring/SummaryContent.jsp =================================================================== diff -u -r0cf0d00e80ef05535a52247a471dd7db8d566fac -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 0cf0d00e80ef05535a52247a471dd7db8d566fac) +++ lams_tool_vote/web/monitoring/SummaryContent.jsp (.../SummaryContent.jsp) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -43,34 +43,13 @@
- - - - - - -
- -
-
+ +
+ +
- - - -
- -
-
- - - - -
- - - - + <%@include file="AdvanceOptions.jsp"%> Index: lams_tool_vote/web/monitoring/VoteNominationViewer.jsp =================================================================== diff -u -r1a02559e19419af9991eaeb9363f809355b39bc7 -r81d3515d29fd57e3b9e08cc37481fd0becbd8b10 --- lams_tool_vote/web/monitoring/VoteNominationViewer.jsp (.../VoteNominationViewer.jsp) (revision 1a02559e19419af9991eaeb9363f809355b39bc7) +++ lams_tool_vote/web/monitoring/VoteNominationViewer.jsp (.../VoteNominationViewer.jsp) (revision 81d3515d29fd57e3b9e08cc37481fd0becbd8b10) @@ -1,35 +1,117 @@ - + <%@ include file="/common/taglibs.jsp"%> <fmt:message key="label.learnersVoted"/> - <%@ include file="/common/header.jsp"%> + <%@ include file="/common/monitorheader.jsp"%> + +
- - +

:

+ +
+
+ + + + + + +
+ +
- - - - - - - - - - - - - + +
+
+ + + + + + +
+
+
+