Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java (.../QaAppConstants.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -28,6 +28,12 @@ * @author Ozgur Demirtas */ public interface QaAppConstants { + + public static final int SORT_BY_NO = 0; + public static final int SORT_BY_ANSWER_ASC = 1; + public static final int SORT_BY_ANSWER_DESC = 2; + public static final int SORT_BY_AVG_RATING_ASC = 3; + public static final int SORT_BY_AVG_RATING_DESC = 4; public static final String MY_SIGNATURE = "laqa11"; public static final String TOOL_CONTENT_ID = "toolContentID"; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java =================================================================== diff -u -r9fbb7ff85ea238ebc8699e9ec116eb0cd782ff90 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (.../QaUsrResp.java) (revision 9fbb7ff85ea238ebc8699e9ec116eb0cd782ff90) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUsrResp.java (.../QaUsrResp.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -62,6 +62,10 @@ /** nullable persistent field */ private String timezone; + + //DTO fields + private String averageRating; + private String numberOfVotes; /** full constructor */ public QaUsrResp(Long responseId, String answer, Date attemptTime, String timezone, @@ -233,4 +237,20 @@ this.visible = visible; } + public String getNumberOfVotes() { + return numberOfVotes; + } + + public void setNumberOfVotes(String numberOfVotes) { + this.numberOfVotes = numberOfVotes; + } + + public String getAverageRating() { + return averageRating; + } + + public void setAverageRating(String averageRating) { + this.averageRating = averageRating; + } + } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java =================================================================== diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (.../IQaUsrRespDAO.java) (revision c5457cc74f3986b393bc2947604b17168ba54dfb) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (.../IQaUsrRespDAO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -41,8 +41,15 @@ public QaUsrResp getResponseById(Long responseId); public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long questionId); - + int getCountResponsesByQaContent(final Long qaContentId); - + List getResponsesByUserUid(final Long userUid); + + List getResponseBySessionAndQuestion(final Long qaSessionId, final Long questionId); + + List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long userId, + int page, int size, int sorting); + + int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java =================================================================== diff -u -r15045d0b9b0dbb930f42a9da7757207e7a325341 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java (.../IResponseRatingDAO.java) (revision 15045d0b9b0dbb930f42a9da7757207e7a325341) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java (.../IResponseRatingDAO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.tool.qa.dao; import java.util.List; +import java.util.Map; import org.lamsfoundation.lams.tool.qa.ResponseRating; import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; @@ -67,4 +68,8 @@ public void removeResponseRating(ResponseRating rating); public List getRatingsByUser(Long userUid); + + Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId); + + Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java =================================================================== diff -u -rccfd66f1abbfc63cd0ed0a044f89914418d67cd1 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision ccfd66f1abbfc63cd0ed0a044f89914418d67cd1) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -26,23 +26,38 @@ import java.util.List; import org.hibernate.FlushMode; +import org.lamsfoundation.lams.tool.qa.QaAppConstants; import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.dao.IQaUsrRespDAO; import org.springframework.orm.hibernate4.support.HibernateDaoSupport; /** - * * @author Ozgur Demirtas - * */ public class QaUsrRespDAO extends HibernateDaoSupport implements IQaUsrRespDAO { - private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION = "from qaUsrResp in class QaUsrResp where qaUsrResp.qaQueUser.queUsrId=:queUsrId and qaUsrResp.qaQuestion.uid=:questionId"; + private static final String LOAD_ATTEMPT_FOR_USER_AND_QUESTION = "from qaUsrResp in class QaUsrResp " + + "where qaUsrResp.qaQueUser.queUsrId=:queUsrId and qaUsrResp.qaQuestion.uid=:questionId"; - private static final String LOAD_ATTEMPT_FOR_USER = "from qaUsrResp in class QaUsrResp where qaUsrResp.qaQueUser.uid=:userUid order by qaUsrResp.qaQuestion.displayOrder asc"; + private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION = "from qaUsrResp in class QaUsrResp " + + " where qaUsrResp.qaQueUser.qaSession.qaSessionId=:qaSessionId and qaUsrResp.qaQuestion.uid=:questionId"; + + private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT = "from qaUsrResp in class QaUsrResp " + + "where qaUsrResp.qaQueUser.qaSession.qaSessionId=:qaSessionId AND qaUsrResp.qaQuestion.uid=:questionId AND qaUsrResp.qaQueUser.queUsrId!=:excludeUserId order by "; - private static final String GET_COUNT_RESPONSES_BY_QACONTENT = "SELECT COUNT(*) from " - + QaUsrResp.class.getName() + " as r where r.qaQuestion.qaContent.qaContentId=?"; + private static final String LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_ORDER_BY_AVG_RATING = "SELECT resp FROM " + + " ResponseRating as rating RIGHT JOIN rating.response as resp " + + " WHERE resp.qaQueUser.qaSession.qaSessionId=:qaSessionId AND resp.qaQuestion.uid=:questionId AND resp.qaQueUser.queUsrId!=:excludeUserId GROUP BY resp.responseId ORDER BY AVG(rating.rating) "; + + private static final String LOAD_ATTEMPT_FOR_USER = "from qaUsrResp in class QaUsrResp " + + "where qaUsrResp.qaQueUser.uid=:userUid order by qaUsrResp.qaQuestion.displayOrder asc"; + private static final String GET_COUNT_RESPONSES_BY_QACONTENT = "SELECT COUNT(*) from " + QaUsrResp.class.getName() + + " as r where r.qaQuestion.qaContent.qaContentId=?"; + + private static final String GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION = "SELECT COUNT(*) from " + + QaUsrResp.class.getName() + + " as r where r.qaQueUser.qaSession.qaSessionId=? and r.qaQuestion.uid=? AND r.qaQueUser.queUsrId!=?"; + public void createUserResponse(QaUsrResp qaUsrResp) { getSessionFactory().getCurrentSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().save(qaUsrResp); @@ -65,6 +80,7 @@ this.getHibernateTemplate().delete(resp); } + @Override public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long questionId) { List list = getSessionFactory().getCurrentSession().createQuery(LOAD_ATTEMPT_FOR_USER_AND_QUESTION) .setLong("queUsrId", queUsrId.longValue()).setLong("questionId", questionId.longValue()).list(); @@ -74,21 +90,80 @@ return (QaUsrResp) list.get(list.size() - 1); } } - + @Override + public List getResponseBySessionAndQuestion(final Long qaSessionId, final Long questionId) { + return getSessionFactory().getCurrentSession().createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION) + .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()).list(); + } + + @Override + public List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long excludeUserId, + int page, int size, int sorting) { + String sortingOrder = ""; + switch (sorting) { + case QaAppConstants.SORT_BY_NO: + sortingOrder = "qaUsrResp.attemptTime"; + break; + case QaAppConstants.SORT_BY_ANSWER_ASC: + sortingOrder = "answer ASC"; + break; + case QaAppConstants.SORT_BY_ANSWER_DESC: + sortingOrder = "answer DESC"; + break; + case QaAppConstants.SORT_BY_AVG_RATING_ASC: + sortingOrder = "ASC"; + break; + case QaAppConstants.SORT_BY_AVG_RATING_DESC: + sortingOrder = "DESC"; + break; + } + + if (sorting == QaAppConstants.SORT_BY_AVG_RATING_ASC || sorting == QaAppConstants.SORT_BY_AVG_RATING_DESC) { + + List list = getSessionFactory().getCurrentSession() + .createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT_ORDER_BY_AVG_RATING + sortingOrder) + .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()) + .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size) + .setMaxResults(size).list(); + + return list; + + } else { + return getSessionFactory().getCurrentSession() + .createQuery(LOAD_ATTEMPT_FOR_SESSION_AND_QUESTION_LIMIT + sortingOrder) + .setLong("qaSessionId", qaSessionId.longValue()).setLong("questionId", questionId.longValue()) + .setLong("excludeUserId", excludeUserId.longValue()).setFirstResult(page * size) + .setMaxResults(size).list(); + } + + + } + + @Override public List getResponsesByUserUid(final Long userUid) { List list = getSessionFactory().getCurrentSession().createQuery(LOAD_ATTEMPT_FOR_USER).setLong("userUid", userUid.longValue()) .list(); return list; } - + public int getCountResponsesByQaContent(final Long qaContentId) { - + List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_BY_QACONTENT, new Object[] { qaContentId }); if (list == null || list.size() == 0) { return 0; } return ((Number) list.get(0)).intValue(); } + public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) { + + List list = getHibernateTemplate().find(GET_COUNT_RESPONSES_FOR_SESSION_AND_QUESTION, + new Object[] { qaSessionId, questionId, excludeUserId }); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } + } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java =================================================================== diff -u -rccfd66f1abbfc63cd0ed0a044f89914418d67cd1 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java (.../ResponseRatingDAO.java) (revision ccfd66f1abbfc63cd0ed0a044f89914418d67cd1) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java (.../ResponseRatingDAO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -24,8 +24,10 @@ package org.lamsfoundation.lams.tool.qa.dao.hibernate; import java.text.NumberFormat; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; import org.hibernate.FlushMode; import org.lamsfoundation.lams.dao.hibernate.BaseDAO; @@ -50,6 +52,12 @@ private static final String FIND_AVERAGE_RATING_BY_RESPONSE = "SELECT AVG(r.rating), COUNT(*) from " + ResponseRating.class.getName() + " as r where r.response.responseId=?"; + private static final String FIND_AVERAGE_RATING_BY_QUESTION_AND_SESSION = "SELECT r.response.responseId, AVG(r.rating), COUNT(*) from " + + ResponseRating.class.getName() + " as r where r.response.qaQuestion.uid=? and r.response.qaQueUser.qaSession.qaSessionId=? group by r.response.responseId"; + + private static final String FIND_AVERAGE_RATING_BY_USER_AND_CONTENT = "SELECT r.response.responseId, AVG(r.rating), COUNT(*) from " + + ResponseRating.class.getName() + " as r where r.response.qaQueUser.uid=? and r.response.qaQuestion.qaContent.qaContentId=? group by r.response.responseId"; + private static final String FIND_BY_USER_UID = "from " + ResponseRating.class.getName() + " as r where r.user.uid = ?"; @@ -78,7 +86,59 @@ String numberOfVotes = (results[1] == null) ? "0" : String.valueOf(results[1]); return new AverageRatingDTO(averageRating, numberOfVotes); } + + public Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId) { + List list = (List) getHibernateTemplate().find(FIND_AVERAGE_RATING_BY_QUESTION_AND_SESSION, new Object[] { questionUid, qaSessionId }); + + Map mapResponseIdToAverageRating = new HashMap(); + for (Object[] results : list) { + if (results[0] == null) { + return null; + } + + Long responseId = (Long) results[0]; + Object averageRatingObj = results[1]; + NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); + numberFormat.setMaximumFractionDigits(1); + String averageRating = numberFormat.format(averageRatingObj); + + String numberOfVotes = String.valueOf(results[2]); + + mapResponseIdToAverageRating.put(responseId, new AverageRatingDTO(averageRating, numberOfVotes)); + + } + + return mapResponseIdToAverageRating; + + } + + public Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId) { + List list = (List) getHibernateTemplate().find(FIND_AVERAGE_RATING_BY_USER_AND_CONTENT, new Object[] {userUid, contentId}); + + Map mapResponseIdToAverageRating = new HashMap(); + for (Object[] results : list) { + if (results[0] == null) { + return null; + } + + Long responseId = (Long) results[0]; + + Object averageRatingObj = results[1]; + NumberFormat numberFormat = NumberFormat.getInstance(Locale.US); + numberFormat.setMaximumFractionDigits(1); + String averageRating = numberFormat.format(averageRatingObj); + + String numberOfVotes = String.valueOf(results[2]); + + mapResponseIdToAverageRating.put(responseId, new AverageRatingDTO(averageRating, numberOfVotes)); + + } + + return mapResponseIdToAverageRating; + + } + public void saveObject(Object o) { super.insertOrUpdate(o); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java =================================================================== diff -u -r7cefcae725bb4e568ae1d61624a75bd6b3f3a8c3 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 7cefcae725bb4e568ae1d61624a75bd6b3f3a8c3) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dto/GeneralLearnerFlowDTO.java (.../GeneralLearnerFlowDTO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -25,8 +25,11 @@ import java.util.List; import java.util.Map; +import java.util.Set; import org.apache.commons.lang.builder.ToStringBuilder; +import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; /** *

@@ -93,7 +96,12 @@ protected Map mapQuestionContentLearner; + //only for export now protected List listMonitoredAnswersContainerDTO; + + protected Set questions; + + protected List userResponses; protected String initialScreen; @@ -468,8 +476,38 @@ public void setListMonitoredAnswersContainerDTO(List listMonitoredAnswersContainerDTO) { this.listMonitoredAnswersContainerDTO = listMonitoredAnswersContainerDTO; } + + /** + * @return Returns the questions. + */ + public List getUserResponses() { + return userResponses; + } /** + * @param questions + * The questions to set. + */ + public void setUserResponses(List userResponses) { + this.userResponses = userResponses; + } + + /** + * @return Returns the questions. + */ + public Set getQuestions() { + return questions; + } + + /** + * @param questions + * The questions to set. + */ + public void setQuestions(Set questions) { + this.questions = questions; + } + + /** * @return Returns the mapAnswersPresentable. */ public Map getMapAnswersPresentable() { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.SortedSet; @@ -41,6 +42,7 @@ import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.QaWizardCategory; import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; +import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO; import org.lamsfoundation.lams.util.audit.IAuditService; @@ -100,9 +102,22 @@ int countSessionComplete(QaContent qa); void updateUser(QaQueUsr qaQueUsr); + + List getResponsesByUserUid(final Long userUid); QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId); + + List getResponseBySessionAndQuestion(final Long qaSessionId, final Long questionId); + + List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long excludeUserId, + int page, int size, int sorting); + + int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId); + Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId); + + Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId); + /** * Creates or updates response with answer submitted by user. * @@ -319,6 +334,17 @@ * @return */ List getReflectList(QaContent content, String userID); + + /** + * ends up populating the attempt history for all the users of all the tool sessions for a content + * + * User id is needed if isUserNamesVisible is false && is learnerRequest = true, as it is required to work out if + * the data being analysed is the current user. + */ + List exportLearner(QaContent qaContent, boolean isUserNamesVisible, boolean isLearnerRequest, String sessionId, + String userId); + + List exportTeacher(QaContent qaContent); /** * notifyTeachersOnResponseSubmit Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -r40eb54374e84591563d8b6a679ac719dbc85c8f7 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 40eb54374e84591563d8b6a679ac719dbc85c8f7) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -31,10 +31,12 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.Set; import java.util.SortedMap; import java.util.SortedSet; +import java.util.TreeMap; import java.util.TreeSet; import javax.servlet.http.HttpSession; @@ -78,10 +80,14 @@ import org.lamsfoundation.lams.tool.qa.dao.IQaWizardDAO; import org.lamsfoundation.lams.tool.qa.dao.IResponseRatingDAO; import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; +import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; +import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredAnswersDTO; +import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredUserDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.qa.util.QaApplicationException; import org.lamsfoundation.lams.tool.qa.util.QaSessionComparator; +import org.lamsfoundation.lams.tool.qa.util.QaStringComparator; import org.lamsfoundation.lams.tool.service.ILamsToolService; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; @@ -260,13 +266,46 @@ return user; } + @Override public QaQueUsr getUserByIdAndSession(final Long queUsrId, final Long qaSessionId) { return qaQueUsrDAO.getQaUserBySession(queUsrId, qaSessionId); } + + @Override + public List getResponsesByUserUid(final Long userUid) { + return qaUsrRespDAO.getResponsesByUserUid(userUid); + } + @Override public QaUsrResp getResponseByUserAndQuestion(final Long queUsrId, final Long qaQueContentId) { return qaUsrRespDAO.getResponseByUserAndQuestion(queUsrId, qaQueContentId); } + + @Override + public List getResponseBySessionAndQuestion(final Long qaSessionId, final Long questionId) { + return qaUsrRespDAO.getResponseBySessionAndQuestion(qaSessionId, questionId); + } + + @Override + public List getResponsesForTablesorter(final Long qaSessionId, final Long questionId, final Long excludeUserId, + int page, int size, int sorting) { + return qaUsrRespDAO.getResponsesForTablesorter(qaSessionId, questionId, excludeUserId, page, size, sorting); + } + + @Override + public int getCountResponsesBySessionAndQuestion(final Long qaSessionId, final Long questionId, final Long excludeUserId) { + return qaUsrRespDAO.getCountResponsesBySessionAndQuestion(qaSessionId, questionId, excludeUserId); + } + + @Override + public Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId) { + return qaResponseRatingDAO.getAverageRatingDTOByQuestionAndSession(questionUid, qaSessionId); + } + + @Override + public Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId) { + return qaResponseRatingDAO.getAverageRatingDTOByUserAndContentId(userUid, contentId); + } public void updateUserResponse(QaUsrResp resp) { qaUsrRespDAO.updateUserResponse(resp); @@ -655,8 +694,191 @@ return reflectionDTOs; } + + @Override + public List exportLearner(QaContent qaContent, boolean isUserNamesVisible, boolean isLearnerRequest, + String sessionId, String userId) { + List listQuestions = getAllQuestionEntries(qaContent.getUid()); + List listMonitoredAnswersContainerDTO = new LinkedList(); + + Iterator itListQuestions = listQuestions.iterator(); + while (itListQuestions.hasNext()) { + QaQueContent qaQuestion = (QaQueContent) itListQuestions.next(); + + if (qaQuestion != null) { + QaMonitoredAnswersDTO qaMonitoredAnswersDTO = new QaMonitoredAnswersDTO(); + qaMonitoredAnswersDTO.setQuestionUid(qaQuestion.getUid().toString()); + qaMonitoredAnswersDTO.setQuestion(qaQuestion.getQuestion()); + qaMonitoredAnswersDTO.setFeedback(qaQuestion.getFeedback()); + + Map questionAttemptData = exportGroupsAttemptData(qaContent, qaQuestion.getUid().toString(), + isUserNamesVisible, isLearnerRequest, sessionId, userId); + qaMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); + listMonitoredAnswersContainerDTO.add(qaMonitoredAnswersDTO); + + } + } + return listMonitoredAnswersContainerDTO; + } + @Override + public List exportTeacher(QaContent qaContent) { + List questions = getAllQuestionEntries(qaContent.getUid()); + List groupDTOs = new LinkedList(); + Set sessions = new TreeSet(new QaSessionComparator()); + sessions.addAll(qaContent.getQaSessions()); + for (QaSession session : sessions) { + String sessionId = session.getQaSessionId().toString(); + String sessionName = session.getSession_name(); + + GroupDTO groupDTO = new GroupDTO(); + List qaMonitoredAnswersDTOs = new LinkedList(); + + if (session != null) { + Iterator itQuestions = questions.iterator(); + while (itQuestions.hasNext()) { + QaQueContent question = itQuestions.next(); + + QaMonitoredAnswersDTO qaMonitoredAnswersDTO = new QaMonitoredAnswersDTO(); + qaMonitoredAnswersDTO.setQuestionUid(question.getUid().toString()); + qaMonitoredAnswersDTO.setQuestion(question.getQuestion()); + qaMonitoredAnswersDTO.setFeedback(question.getFeedback()); + qaMonitoredAnswersDTO.setSessionId(sessionId); + qaMonitoredAnswersDTO.setSessionName(sessionName); + + Map questionAttemptData = exportGroupsAttemptData(qaContent, question.getUid() + .toString(), true, false, sessionId, null); + qaMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData); + qaMonitoredAnswersDTOs.add(qaMonitoredAnswersDTO); + } + } + + groupDTO.setGroupData(qaMonitoredAnswersDTOs); + groupDTO.setSessionName(sessionName); + groupDTO.setSessionId(sessionId); + groupDTOs.add(groupDTO); + } + return groupDTOs; + } + + /** + * User id is needed if learnerRequest = true, as it is required to work out if the data being analysed is the + * current user (for not show other names) or to work out which is the user's answers (for not show all answers). + */ + private Map exportGroupsAttemptData(QaContent qaContent, String questionUid, boolean isUserNamesVisible, + boolean isLearnerRequest, String sessionId, String userId) { + List> listMonitoredAttemptsContainerDTO = new LinkedList>(); + + Map mapResponseIdToAverageRating = getAverageRatingDTOByQuestionAndSession(new Long( + questionUid), new Long(sessionId)); + + List responses = new ArrayList(); + if (!isLearnerRequest) { + /* request is for monitoring summary */ + + if (qaContent.isUseSelectLeaderToolOuput()) { + QaSession session = getSessionById(new Long(sessionId).longValue()); + QaQueUsr groupLeader = session.getGroupLeader(); + if (groupLeader != null) { + QaUsrResp response = getResponseByUserAndQuestion(groupLeader.getQueUsrId(), new Long( + questionUid)); + if (response != null) { + responses.add(response); + } + } + + } else { + responses = getResponseBySessionAndQuestion(new Long(sessionId), new Long(questionUid)); + } + + } else { + if (qaContent.isShowOtherAnswers()) { + responses = getResponseBySessionAndQuestion(new Long(sessionId), new Long(questionUid)); + + } else { + QaUsrResp response = getResponseByUserAndQuestion(new Long(userId), new Long(questionUid)); + if (response != null) { + responses.add(response); + } + } + } + + /** + * Populates all the user's attempt data of a particular tool session. User id is needed if isUserNamesVisible + * is false && is learnerRequest = true, as it is required to work out if the data being analysed is the current + * user. + */ + List qaMonitoredUserDTOs = new LinkedList(); + for (QaUsrResp response : responses) { + QaQueUsr user = response.getQaQueUser(); + if (response != null) { + QaMonitoredUserDTO qaMonitoredUserDTO = new QaMonitoredUserDTO(); + qaMonitoredUserDTO.setAttemptTime(response.getAttemptTime()); + qaMonitoredUserDTO.setTimeZone(response.getTimezone()); + qaMonitoredUserDTO.setUid(response.getResponseId().toString()); + + if (!isUserNamesVisible && isLearnerRequest && !userId.equals(user.getQueUsrId().toString())) { + // this is not current user, put his name as blank + qaMonitoredUserDTO.setUserName(" "); + } else { + // this is current user, put his name normally + qaMonitoredUserDTO.setUserName(user.getFullname()); + } + + qaMonitoredUserDTO.setQueUsrId(user.getQueUsrId().toString()); + qaMonitoredUserDTO.setSessionId(sessionId.toString()); + qaMonitoredUserDTO.setResponse(response.getAnswer()); + + // String responsePresentable = QaUtils.replaceNewLines(response.getAnswer()); + qaMonitoredUserDTO.setResponsePresentable(response.getAnswer()); + + qaMonitoredUserDTO.setQuestionUid(questionUid); + qaMonitoredUserDTO.setVisible(new Boolean(response.isVisible()).toString()); + + // set averageRating + if (qaContent.isAllowRateAnswers()) { + + AverageRatingDTO averageRating = mapResponseIdToAverageRating.get(response.getResponseId()); + // AverageRatingDTO averageRating = + // qaService.getAverageRatingDTOByResponse(response.getResponseId()); + if (averageRating == null) { + qaMonitoredUserDTO.setAverageRating("0"); + qaMonitoredUserDTO.setNumberOfVotes("0"); + } else { + qaMonitoredUserDTO.setAverageRating(averageRating.getRating()); + qaMonitoredUserDTO.setNumberOfVotes(averageRating.getNumberOfVotes()); + } + + } + + qaMonitoredUserDTOs.add(qaMonitoredUserDTO); + } + } + + // convert To McMonitoredUserDTOMap + Map sessionUsersAttempts = new TreeMap( + new QaStringComparator()); + Long mapIndex = new Long(1); + for (QaMonitoredUserDTO data : qaMonitoredUserDTOs) { + sessionUsersAttempts.put(mapIndex.toString(), data); + mapIndex = mapIndex + 1; + } + listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts); + + // convertToMap + Map map = new TreeMap(new QaStringComparator()); + Iterator listIterator = listMonitoredAttemptsContainerDTO.iterator(); + Long mapIndex2 = new Long(1); + while (listIterator.hasNext()) { + Map data = (Map) listIterator.next(); + map.put(mapIndex2.toString(), data); + mapIndex2 = new Long(mapIndex2.longValue() + 1); + } + return map; + } + + @Override public void notifyTeachersOnResponseSubmit(Long sessionId) { final String NEW_LINE_CHARACTER = "
"; Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java (.../ExportServlet.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/ExportServlet.java (.../ExportServlet.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -37,6 +37,7 @@ import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO; +import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; @@ -52,7 +53,6 @@ * * @author Ozgur Demirtas */ - public class ExportServlet extends AbstractExportPortfolioServlet implements QaAppConstants { static Logger logger = Logger.getLogger(ExportServlet.class.getName()); private static final long serialVersionUID = -1779093489007108143L; @@ -111,17 +111,17 @@ request.getSession().setAttribute(QaAppConstants.IS_TOOL_SESSION_AVAILABLE, isNoToolSessions); GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(content); - List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, content, qaService, - content.isUsernameVisible(), true, toolSessionID.toString(), userID.toString()); + List listMonitoredAnswersContainerDTO = qaService.exportLearner(content, content.isUsernameVisible(), true, + toolSessionID.toString(), userID.toString()); generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); generalLearnerFlowDTO.setUserUid(userID.toString()); request.getSession().setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - MonitoringUtil.setUpMonitoring(request, qaService, content); - - List reflectionDTOs = qaService.getReflectList(content, userID.toString()); - request.getSession().setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionDTOs); + if (content.isReflect()) { + List reflectionDTOs = qaService.getReflectList(content, userID.toString()); + request.getSession().setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionDTOs); + } } request.getSession().setAttribute(PORTFOLIO_EXPORT_MODE, "learner"); @@ -150,15 +150,15 @@ GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(content); request.getSession().setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - MonitoringUtil.setUpMonitoring(request, qaService, content); - request.getSession().setAttribute(PORTFOLIO_EXPORT_MODE, "teacher"); - List reflectionDTOs = qaService.getReflectList(content, userID.toString()); - request.getSession().setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionDTOs); + if (content.isReflect()) { + List reflectionDTOs = qaService.getReflectList(content, null); + request.getSession().setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionDTOs); + } // generateGroupsSessionData - List listAllGroupsDTO = MonitoringUtil.buildGroupBasedSessionData(request, content, qaService); + List listAllGroupsDTO = qaService.exportTeacher(content); request.setAttribute(LIST_ALL_GROUPS_DTO, listAllGroupsDTO); request.getSession().setAttribute(LIST_ALL_GROUPS_DTO, listAllGroupsDTO); } Fisheye: Tag 4606a90972c3824568c8f9648f3ffaf47030ed7d refers to a dead (removed) revision in file `lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== diff -u -r52c8c1dcf1233af8cbd4e3447f318146a9975f41 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 52c8c1dcf1233af8cbd4e3447f318146a9975f41) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -24,17 +24,21 @@ package org.lamsfoundation.lams.tool.qa.web; import java.io.IOException; +import java.util.Collection; import java.util.Date; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.Globals; @@ -43,8 +47,10 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.apache.tomcat.util.json.JSONArray; import org.apache.tomcat.util.json.JSONException; import org.apache.tomcat.util.json.JSONObject; +import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.exception.ToolException; @@ -53,6 +59,7 @@ import org.lamsfoundation.lams.tool.qa.QaQueContent; import org.lamsfoundation.lams.tool.qa.QaQueUsr; import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.QaUsrResp; import org.lamsfoundation.lams.tool.qa.dto.AverageRatingDTO; import org.lamsfoundation.lams.tool.qa.dto.GeneralLearnerFlowDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; @@ -136,8 +143,8 @@ mapAnswers.put(questionIndexInteger.toString(), answer); mapAnswersPresentable.put(questionIndexInteger.toString(), answer); - Map questionContentMap = generalLearnerFlowDTO.getMapQuestionContentLearner(); - QaQuestionDTO dto = questionContentMap.get(questionIndexInteger); + Map questionMap = generalLearnerFlowDTO.getMapQuestionContentLearner(); + QaQuestionDTO dto = questionMap.get(questionIndexInteger); if (dto.isRequired() && isEmpty(answer)) { errors.add(Globals.ERROR_KEY, new ActionMessage("error.required", questionIndexInteger)); forwardName = QaAppConstants.LOAD_LEARNER; @@ -159,7 +166,7 @@ int numQuestions = questionMap.size(); Integer finalQuestionIndex = new Integer(numQuestions); QaQuestionDTO dto = questionMap.get(finalQuestionIndex); - if (dto.isRequired() && isEmpty(mapAnswersPresentable.get(finalQuestionIndex).toString())) { + if (dto.isRequired() && isEmpty(mapAnswersPresentable.get(finalQuestionIndex.toString()))) { errors.add(Globals.ERROR_KEY, new ActionMessage("error.required", finalQuestionIndex)); forwardName = QaAppConstants.LOAD_LEARNER; } @@ -951,18 +958,103 @@ boolean isUserNamesVisible, String sessionId, String userId, GeneralLearnerFlowDTO generalLearnerFlowDTO) { - List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, qaContent, qaService, - isUserNamesVisible, true, sessionId, userId); +// List listMonitoredAnswersContainerDTO = MonitoringUtil.buildGroupsQuestionData(request, qaContent, qaService, +// isUserNamesVisible, true, sessionId, userId); +// generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); + + Set questions = qaContent.getQaQueContents(); + generalLearnerFlowDTO.setQuestions(questions); + generalLearnerFlowDTO.setUserNameVisible(new Boolean(qaContent.isUsernameVisible()).toString()); + + QaQueUsr user = qaService.getUserByIdAndSession(new Long(userId), new Long(sessionId)); + List userResponses = qaService.getResponsesByUserUid(user.getUid()); + Map mapResponseIdToAverageRating = qaService.getAverageRatingDTOByUserAndContentId(user.getUid(), qaContent.getQaContentId()); - if (generalLearnerFlowDTO != null) { - generalLearnerFlowDTO.setListMonitoredAnswersContainerDTO(listMonitoredAnswersContainerDTO); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); - request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - } + for (QaUsrResp userResponse : userResponses) { - MonitoringUtil.setUpMonitoring(request, qaService, qaContent); + AverageRatingDTO averageRating = mapResponseIdToAverageRating.get(userResponse.getResponseId()); + if (averageRating == null) { + userResponse.setAverageRating("0"); + userResponse.setNumberOfVotes("0"); + } else { + userResponse.setAverageRating(averageRating.getRating()); + userResponse.setNumberOfVotes(averageRating.getNumberOfVotes()); + } + } + + for (QaQueContent question : questions) { + //TODO may be add questions that were not answered + + } + generalLearnerFlowDTO.setUserResponses(userResponses); + generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); } + + /** + * Refreshes user list. + */ + public ActionForward getResponses(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse res) throws IOException, ServletException, JSONException { + initializeQAService(); + + Long questionUid = WebUtil.readLongParam(request, "questionUid"); + Long qaSessionId = WebUtil.readLongParam(request, "qaSessionId"); + + //in case of monitoring we show all results. in case of learning - don't show results from the current user + boolean isMonitoring = WebUtil.readBooleanParam(request, "isMonitoring", false); + Long excludeUserId = isMonitoring ? -1 : WebUtil.readLongParam(request, "userId"); + + //paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); + Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true); + + int sorting = QaAppConstants.SORT_BY_NO; + if (isSort1 != null && isSort1.equals(0)) { + sorting = QaAppConstants.SORT_BY_ANSWER_ASC; + } else if (isSort1 != null && isSort1.equals(1)) { + sorting = QaAppConstants.SORT_BY_ANSWER_DESC; + } else if (isSort2 != null && isSort2.equals(0)) { + sorting = QaAppConstants.SORT_BY_AVG_RATING_ASC; + } else if (isSort2 != null && isSort2.equals(1)) { + sorting = QaAppConstants.SORT_BY_AVG_RATING_DESC; + } + + List responses = qaService.getResponsesForTablesorter(qaSessionId, questionUid, excludeUserId, page, size, + sorting); + + JSONArray rows = new JSONArray(); + JSONObject responcedata = new JSONObject(); + responcedata.put("total_rows", qaService.getCountResponsesBySessionAndQuestion(qaSessionId, questionUid, excludeUserId)); + + for (QaUsrResp response : responses) { + QaQueUsr user = response.getQaQueUser(); + //JSONArray cell=new JSONArray(); + //cell.put(StringEscapeUtils.escapeHtml(user.getFirstName()) + " " + StringEscapeUtils.escapeHtml(user.getLastName()) + " [" + StringEscapeUtils.escapeHtml(user.getLogin()) + "]"); + + JSONObject responseRow = new JSONObject(); + responseRow.put("responseUid", response.getResponseId().toString()); + responseRow.put("answer", StringEscapeUtils.escapeCsv(response.getAnswer())); + responseRow.put("userName", StringEscapeUtils.escapeCsv(user.getFullname())); + responseRow.put("visible", new Boolean(response.isVisible()).toString()); + responseRow.put("attemptTime", response.getAttemptTime()); + + AverageRatingDTO averageRatingDto = qaService.getAverageRatingDTOByResponse(response.getResponseId()); + String averageRating = (averageRatingDto == null) ? "0" : averageRatingDto.getRating(); + responseRow.put("averageRating", averageRating); + String numberOfVotes = (averageRatingDto == null) ? "0" : averageRatingDto.getNumberOfVotes(); + responseRow.put("numberOfVotes", numberOfVotes); + + rows.put(responseRow); + } + responcedata.put("rows", rows); + res.setContentType("application/json;charset=utf-8"); + res.getWriter().print(new String(responcedata.toString())); + return null; + } + private static Map removeNewLinesMap(Map map) { Map newMap = new TreeMap(new QaStringComparator()); Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java (.../QaLearningStarterAction.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -282,6 +282,7 @@ QaLearningAction.refreshSummaryData(request, qaContent, qaService, qaContent.isUsernameVisible(), toolSessionID, userId.toString(), generalLearnerFlowDTO); + request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); return (mapping.findForward(INDIVIDUAL_LEARNER_REPORT)); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringStarterAction.java (.../QaMonitoringStarterAction.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -25,15 +25,20 @@ package org.lamsfoundation.lams.tool.qa.web; import java.io.IOException; +import java.util.Date; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.SortedSet; +import java.util.TimeZone; import java.util.TreeSet; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; import org.apache.struts.Globals; @@ -48,13 +53,23 @@ import org.lamsfoundation.lams.tool.qa.QaCondition; import org.lamsfoundation.lams.tool.qa.QaContent; import org.lamsfoundation.lams.tool.qa.QaQueContent; +import org.lamsfoundation.lams.tool.qa.QaQueUsr; +import org.lamsfoundation.lams.tool.qa.QaSession; +import org.lamsfoundation.lams.tool.qa.dto.GroupDTO; +import org.lamsfoundation.lams.tool.qa.dto.QaMonitoredAnswersDTO; import org.lamsfoundation.lams.tool.qa.dto.QaQuestionDTO; +import org.lamsfoundation.lams.tool.qa.dto.QaStatsDTO; +import org.lamsfoundation.lams.tool.qa.dto.ReflectionDTO; import org.lamsfoundation.lams.tool.qa.service.IQaService; import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy; import org.lamsfoundation.lams.tool.qa.util.QaApplicationException; +import org.lamsfoundation.lams.tool.qa.util.QaSessionComparator; import org.lamsfoundation.lams.tool.qa.util.QaUtils; import org.lamsfoundation.lams.tool.qa.web.form.QaMonitoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.DateUtil; import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; @@ -73,14 +88,11 @@ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form; IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext()); - - qaMonitoringForm.setQaService(qaService); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); qaMonitoringForm.setContentFolderID(contentFolderID); ActionForward validateParameters = validateParameters(request, mapping, qaMonitoringForm); - if (validateParameters != null) { return validateParameters; } @@ -92,49 +104,97 @@ throw new ServletException("Data not initialised in Monitoring"); } - MonitoringUtil.setUpMonitoring(request, qaService, qaContent); - qaMonitoringForm.setCurrentTab("1"); String strToolContentID = request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); qaMonitoringForm.setToolContentID(strToolContentID); - /* this section is related to summary tab. Starts here. */ +// SessionMap sessionMap = new SessionMap(); +// sessionMap.put(ACTIVITY_TITLE_KEY, qaContent.getTitle()); +// sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); +// +// qaMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); +// request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - SessionMap sessionMap = new SessionMap(); - sessionMap.put(ACTIVITY_TITLE_KEY, qaContent.getTitle()); - sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, qaContent.getInstructions()); + List questionDTOs = new LinkedList(); + for (QaQueContent question : qaContent.getQaQueContents()) { + QaQuestionDTO questionDTO = new QaQuestionDTO(question); + questionDTOs.add(questionDTO); + } + request.setAttribute(LIST_QUESTION_DTOS, questionDTOs); +// sessionMap.put(LIST_QUESTION_DTOS, questionDTOs); +// request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); - qaMonitoringForm.setHttpSessionID(sessionMap.getSessionID()); - request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + //session dto list + List groupDTOs = new LinkedList(); + Set sessions = new TreeSet(new QaSessionComparator()); + sessions.addAll(qaContent.getQaSessions()); + for (QaSession session : sessions) { + String sessionId = session.getQaSessionId().toString(); + String sessionName = session.getSession_name(); - List questionDTOs = new LinkedList(); - Iterator queIterator = qaContent.getQaQueContents().iterator(); - while (queIterator.hasNext()) { - QaQueContent qaQuestion = (QaQueContent) queIterator.next(); - if (qaQuestion != null) { - QaQuestionDTO qaQuestionDTO = new QaQuestionDTO(qaQuestion); - questionDTOs.add(qaQuestionDTO); + GroupDTO groupDTO = new GroupDTO(); + groupDTO.setSessionName(sessionName); + groupDTO.setSessionId(sessionId); + groupDTOs.add(groupDTO); + } + request.setAttribute(LIST_ALL_GROUPS_DTO, groupDTOs); + + if (qaContent.isReflect()) { + List reflectionDTOs = qaService.getReflectList(qaContent, null); + request.setAttribute(QaAppConstants.REFLECTIONS_CONTAINER_DTO, reflectionDTOs); + } + + // setting up the advanced summary for LDEV-1662 + request.setAttribute(QaAppConstants.ATTR_CONTENT, qaContent); + + boolean isGroupedActivity = qaService.isGroupedActivity(qaContent.getQaContentId()); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + //buildQaStatsDTO + QaStatsDTO qaStatsDTO = new QaStatsDTO(); + int countSessionComplete = 0; + int countAllUsers = 0; + Iterator iteratorSession = qaContent.getQaSessions().iterator(); + while (iteratorSession.hasNext()) { + QaSession qaSession = (QaSession) iteratorSession.next(); + + if (qaSession != null) { + + if (qaSession.getSession_status().equals(COMPLETED)) { + ++countSessionComplete; + } + + Iterator iteratorUser = qaSession.getQaQueUsers().iterator(); + while (iteratorUser.hasNext()) { + QaQueUsr qaQueUsr = (QaQueUsr) iteratorUser.next(); + + if (qaQueUsr != null) { + ++countAllUsers; + } + } } } - request.setAttribute(LIST_QUESTION_DTOS, questionDTOs); - sessionMap.put(LIST_QUESTION_DTOS, questionDTOs); - request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(questionDTOs.size())); + qaStatsDTO.setCountAllUsers(new Integer(countAllUsers).toString()); + qaStatsDTO.setCountSessionComplete(new Integer(countSessionComplete).toString()); + request.setAttribute(QA_STATS_DTO, qaStatsDTO); - // preserve conditions into sessionMap - SortedSet conditionSet = new TreeSet(new TextSearchConditionComparator()); - conditionSet.addAll(qaContent.getConditions()); - sessionMap.put(QaAppConstants.ATTR_CONDITION_SET, conditionSet); + // set SubmissionDeadline, if any + if (qaContent.getSubmissionDeadline() != null) { + Date submissionDeadline = qaContent.getSubmissionDeadline(); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(teacherTimeZone, submissionDeadline); + request.setAttribute(QaAppConstants.ATTR_SUBMISSION_DEADLINE, tzSubmissionDeadline.getTime()); + } - MonitoringUtil.setUpMonitoring(request, qaService, qaContent); - return (mapping.findForward(LOAD_MONITORING)); } /** * validates request paramaters based on tool contract - * validateParameters(HttpServletRequest request, ActionMapping mapping) * * @param request * @param mapping @@ -161,16 +221,4 @@ } return null; } - - /** - * persists error messages to request scope - * - * @param request - * @param message - */ - public void persistError(HttpServletRequest request, String message) { - ActionMessages errors = new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - saveErrors(request, errors); - } } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaMonitoringForm.java =================================================================== diff -u -r9fbb7ff85ea238ebc8699e9ec116eb0cd782ff90 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaMonitoringForm.java (.../QaMonitoringForm.java) (revision 9fbb7ff85ea238ebc8699e9ec116eb0cd782ff90) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/form/QaMonitoringForm.java (.../QaMonitoringForm.java) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -43,24 +43,7 @@ protected String sessionId; - protected IQaService qaService; - /** - * @return Returns the qaService. - */ - public IQaService getQaService() { - return qaService; - } - - /** - * @param qaService - * The qaService to set. - */ - public void setQaService(IQaService qaService) { - this.qaService = qaService; - } - - /** * @return Returns the currentUid. */ public String getCurrentUid() { Index: lams_tool_laqa/web/learning/LearnerRep.jsp =================================================================== diff -u -r55acfa2355b842ad87bac70171e366e088daad3c -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 55acfa2355b842ad87bac70171e366e088daad3c) +++ lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -53,6 +53,75 @@ $(".tablesorter").each(function() { $(this).tablesorterPager({ + // set to false otherwise it remembers setting from other jsFiddle demos + savePages: false, + // use this format: "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" + // where {page} is replaced by the page number (or use {page+1} to get a one-based index), + // {size} is replaced by the number of records to show, + // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds + // the filterList to the url into an "fcol" array. + // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url + ajaxUrl : "?method=getResponses&page={page}&size={size}&{sortList:column}&qaSessionId=" + $("#toolSessionID").val() + "&questionUid=" + $(this).attr('data-question-uid') + "&userId=" + $("#userID").val(), + ajaxProcessing: function (data) { + if (data && data.hasOwnProperty('rows')) { + var rows = [], + json = {}; + + for (i = 0; i < data.rows.length; i++){ + var userData = data.rows[i]; + + rows += ''; + rows += ''; + + if (${generalLearnerFlowDTO.userNameVisible == 'true'}) { + rows += '

'; + rows += ''; + rows += userData["userName"]; + rows += ' '; + rows += userData["attemptTime"]; + rows += '
'; + } + + rows += '
'; + if (userData["visible"] == 'true') { + rows += userData["answer"]; + } else { + rows += ''; + } + rows += '
'; + + rows += ''; + + if (${generalLearnerFlowDTO.allowRateAnswers == 'true'}) { + rows += ''; + + if (userData["visible"] == 'true') { + var responseUid = userData["responseUid"]; + + rows += '
'; + rows += '
'; + rows += '
'; + rows += '' + userData["averageRating"] +' / '; + rows += '' + userData["numberOfVotes"] +' '; + rows += ''; + rows += '
'; + rows += '
'; + rows += '
'; + } + + rows += ''; + } + + rows += ''; + } + + json.total = data.total_rows; // only allow 100 rows in total + //json.filteredRows = 100; // no filtering + json.rows = $(rows); + return json; + + } + }, container: $(this).next(".pager"), output: '{startRow} to {endRow} ({totalRows})',// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty @@ -71,22 +140,34 @@ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) cssDisabled: 'disabled' // Note there is no period "." in front of this class name + }) + + // bind to pager events + .bind('pagerInitialized pagerComplete', function(event, options){ + $(".rating-stars").each(function() { + //make sure jRating gets applied only once + if ($(this)[0].innerHTML.indexOf("jRatingColor") > -1) { + return; + } + + $(this).jRating({ + phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), + rateMax : 5, + decimalLength : 1, + onSuccess : function(data, responseUid){ + $("#averageRating" + responseUid).html(data.averageRating); + $("#numberOfVotes" + responseUid).html(data.numberOfVotes); + $("#averageRating" + responseUid).parents(".tablesorter").trigger("update"); + }, + onError : function(){ + jError('Error : please retry'); + } + }) + }) + }); }); - $(".rating-stars").jRating({ - phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), - rateMax : 5, - decimalLength : 1, - onSuccess : function(data, responseUid){ - $("#averageRating" + responseUid).html(data.averageRating); - $("#numberOfVotes" + responseUid).html(data.numberOfVotes); - $("#averageRating" + responseUid).parents(".tablesorter").trigger("update"); - }, - onError : function(){ - jError('Error : please retry'); - } - }); $(".rating-stars-disabled").jRating({ rateMax : 5, isDisabled : true @@ -137,38 +218,29 @@ - - - +
+

- : - + ${status.count}: +

- - - - - - - - - -

- - - - - - -

-

- -

- -
-
-
-
+ +

+ + + + - + +

+

+ +

+ + + + +
@@ -177,15 +249,13 @@ - - - +

- : - + ${status.count}: +

- +
- - - - - - - - - - - - - - - - - -
@@ -200,48 +270,6 @@
-
- - - - - - - -
-
- - - - - - - - -
-
- - - -
@@ -269,7 +297,7 @@ - + Index: lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp =================================================================== diff -u -r6ac8c3a8a953aab157cb5075fba73b09da5e4cf8 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 6ac8c3a8a953aab157cb5075fba73b09da5e4cf8) +++ lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -53,7 +53,78 @@ }); $(".tablesorter").each(function() { - $(this).tablesorterPager({ + $(this).tablesorterPager({ + // set to false otherwise it remembers setting from other jsFiddle demos + savePages: false, + // use this format: "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" + // where {page} is replaced by the page number (or use {page+1} to get a one-based index), + // {size} is replaced by the number of records to show, + // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds + // the filterList to the url into an "fcol" array. + // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url + // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url + ajaxUrl : "?method=getResponses&page={page}&size={size}&{sortList:column}&qaSessionId=" + $("#toolSessionID").val() + "&questionUid=" + $(this).attr('data-question-uid') + "&userId=" + $("#userID").val(), + + ajaxProcessing: function (data) { + if (data && data.hasOwnProperty('rows')) { + var rows = [], + json = {}; + + for (i = 0; i < data.rows.length; i++){ + var userData = data.rows[i]; + + rows += ''; + rows += ''; + + if (${generalLearnerFlowDTO.userNameVisible == 'true'}) { + rows += '
'; + rows += ''; + rows += userData["userName"]; + rows += ' '; + rows += userData["attemptTime"]; + rows += '
'; + } + + rows += '
'; + if (userData["visible"] == 'true') { + rows += userData["answer"]; + } else { + rows += ''; + } + rows += '
'; + + rows += ''; + + if (${generalLearnerFlowDTO.allowRateAnswers == 'true'}) { + rows += ''; + + if (userData["visible"] == 'true') { + var responseUid = userData["responseUid"]; + + rows += '
'; + rows += '
'; + rows += '
'; + rows += '' + userData["averageRating"] +' / '; + rows += '' + userData["numberOfVotes"] +' '; + rows += ''; + rows += '
'; + rows += '
'; + rows += '
'; + } + + rows += ''; + } + + rows += ''; + } + + json.total = data.total_rows; // only allow 100 rows in total + //json.filteredRows = 100; // no filtering + json.rows = $(rows); + return json; + + } + }, container: $(this).next(".pager"), output: '{startRow} to {endRow} ({totalRows})',// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty @@ -72,21 +143,33 @@ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) cssDisabled: 'disabled' // Note there is no period "." in front of this class name + }) + + // bind to pager events + .bind('pagerInitialized pagerComplete', function(event, options){ + $(".rating-stars").each(function() { + //make sure jRating gets applied only once + if ($(this)[0].innerHTML.indexOf("jRatingColor") > -1) { + return; + } + + $(this).jRating({ + phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), + rateMax : 5, + decimalLength : 1, + onSuccess : function(data, responseUid){ + $("#averageRating" + responseUid).html(data.averageRating); + $("#numberOfVotes" + responseUid).html(data.numberOfVotes); + $("#averageRating" + responseUid).parents(".tablesorter").trigger("update"); + }, + onError : function(){ + jError('Error : please retry'); + } + }) + }) }); }); - $(".rating-stars").jRating({ - phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), - rateMax : 5, - decimalLength : 1, - onSuccess : function(data, responseUid){ - $("#averageRating" + responseUid).html(data.averageRating); - $("#numberOfVotes" + responseUid).html(data.numberOfVotes); - }, - onError : function(){ - jError('Error : please retry'); - } - }); $(".rating-stars-disabled").jRating({ rateMax : 5, isDisabled : true @@ -134,37 +217,29 @@ - - - +
+

- : - + ${status.count}: +

- - - - - - - - - -

- - - - - -

-

- -

- -
-
-
-
+ +

+ + + + - + +

+

+ +

+ + + + +
@@ -182,15 +257,14 @@ - - +

- : - + ${status.count}: +

- +
- - - - - - - - - - - - - - - - - - -
@@ -204,48 +278,6 @@
-
- - - - - - - -
-
- - - - - - - - -
-
- - - -
@@ -312,7 +344,7 @@ - + Index: lams_tool_laqa/web/learning/mobile/LearnerRep.jsp =================================================================== diff -u -r6c5d0c6b8ff17d661580df2c265f2dcabfe7d76c -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/web/learning/mobile/LearnerRep.jsp (.../LearnerRep.jsp) (revision 6c5d0c6b8ff17d661580df2c265f2dcabfe7d76c) +++ lams_tool_laqa/web/learning/mobile/LearnerRep.jsp (.../LearnerRep.jsp) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -55,6 +55,77 @@ $(".tablesorter").each(function() { $(this).tablesorterPager({ + // set to false otherwise it remembers setting from other jsFiddle demos + savePages: false, + // use this format: "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" + // where {page} is replaced by the page number (or use {page+1} to get a one-based index), + // {size} is replaced by the number of records to show, + // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds + // the filterList to the url into an "fcol" array. + // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url + // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url + ajaxUrl : "?method=getResponses&page={page}&size={size}&{sortList:column}&qaSessionId=" + $("#toolSessionID").val() + "&questionUid=" + $(this).attr('data-question-uid') + "&userId=" + $("#userID").val(), + + ajaxProcessing: function (data) { + if (data && data.hasOwnProperty('rows')) { + var rows = [], + json = {}; + + for (i = 0; i < data.rows.length; i++){ + var userData = data.rows[i]; + + rows += ''; + rows += ''; + + if (${generalLearnerFlowDTO.userNameVisible == 'true'}) { + rows += '
'; + rows += ''; + rows += userData["userName"]; + rows += ' '; + rows += userData["attemptTime"]; + rows += '
'; + } + + rows += '
'; + if (userData["visible"] == 'true') { + rows += userData["answer"]; + } else { + rows += ''; + } + rows += '
'; + + rows += ''; + + if (${generalLearnerFlowDTO.allowRateAnswers == 'true'}) { + rows += ''; + + if (userData["visible"] == 'true') { + var responseUid = userData["responseUid"]; + + rows += '
'; + rows += '
'; + rows += '
'; + rows += '' + userData["averageRating"] +' / '; + rows += '' + userData["numberOfVotes"] +' '; + rows += ''; + rows += '
'; + rows += '
'; + rows += '
'; + } + + rows += ''; + } + + rows += ''; + } + + json.total = data.total_rows; // only allow 100 rows in total + //json.filteredRows = 100; // no filtering + json.rows = $(rows); + return json; + + } + }, container: $(this).next(".pager"), output: '{startRow} to {endRow} ({totalRows})',// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty @@ -73,21 +144,33 @@ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) cssDisabled: 'disabled' // Note there is no period "." in front of this class name + }) + + // bind to pager events + .bind('pagerInitialized pagerComplete', function(event, options){ + $(".rating-stars").each(function() { + //make sure jRating gets applied only once + if ($(this)[0].innerHTML.indexOf("jRatingColor") > -1) { + return; + } + + $(this).jRating({ + phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), + rateMax : 5, + decimalLength : 1, + onSuccess : function(data, responseUid){ + $("#averageRating" + responseUid).html(data.averageRating); + $("#numberOfVotes" + responseUid).html(data.numberOfVotes); + $("#averageRating" + responseUid).parents(".tablesorter").trigger("update"); + }, + onError : function(){ + jError('Error : please retry'); + } + }) + }); }); }); - $(".rating-stars").jRating({ - phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), - rateMax : 5, - decimalLength : 1, - onSuccess : function(data, responseUid){ - $("#averageRating" + responseUid).html(data.averageRating); - $("#numberOfVotes" + responseUid).html(data.numberOfVotes); - }, - onError : function(){ - jError('Error : please retry'); - } - }); $(".rating-stars-disabled").jRating({ rateMax : 5, isDisabled : true @@ -141,7 +224,7 @@ - + @@ -162,36 +245,28 @@
    - - - +
  • +

    - : - + ${status.count}: +

    - - - - - - - -

    - - - -

    -

    - -

    - -
    -
    -
    -
    +

    + - + +

    +

    + +

    + + + + +
  • -
    +
@@ -200,16 +275,15 @@
    - - +
  • - : - + ${status.count}: +

    - +
    - - - - - - - - - - - - - - - - - - -
    @@ -223,46 +297,6 @@
    -
    - - - - -
    -
    - - - - - - - - -
    -
    - - - -
    Index: lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp =================================================================== diff -u -r6ac8c3a8a953aab157cb5075fba73b09da5e4cf8 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 6ac8c3a8a953aab157cb5075fba73b09da5e4cf8) +++ lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -56,6 +56,77 @@ $(".tablesorter").each(function() { $(this).tablesorterPager({ + // set to false otherwise it remembers setting from other jsFiddle demos + savePages: false, + // use this format: "http:/mydatabase.com?page={page}&size={size}&{sortList:col}" + // where {page} is replaced by the page number (or use {page+1} to get a one-based index), + // {size} is replaced by the number of records to show, + // {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds + // the filterList to the url into an "fcol" array. + // So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url + // and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url + ajaxUrl : "?method=getResponses&page={page}&size={size}&{sortList:column}&qaSessionId=" + $("#toolSessionID").val() + "&questionUid=" + $(this).attr('data-question-uid') + "&userId=" + $("#userID").val(), + + ajaxProcessing: function (data) { + if (data && data.hasOwnProperty('rows')) { + var rows = [], + json = {}; + + for (i = 0; i < data.rows.length; i++){ + var userData = data.rows[i]; + + rows += ''; + rows += ''; + + if (${generalLearnerFlowDTO.userNameVisible == 'true'}) { + rows += '
    '; + rows += ''; + rows += userData["userName"]; + rows += ' '; + rows += userData["attemptTime"]; + rows += '
    '; + } + + rows += '
    '; + if (userData["visible"] == 'true') { + rows += userData["answer"]; + } else { + rows += ''; + } + rows += '
    '; + + rows += ''; + + if (${generalLearnerFlowDTO.allowRateAnswers == 'true'}) { + rows += ''; + + if (userData["visible"] == 'true') { + var responseUid = userData["responseUid"]; + + rows += '
    '; + rows += '
    '; + rows += '
    '; + rows += '' + userData["averageRating"] +' / '; + rows += '' + userData["numberOfVotes"] +' '; + rows += ''; + rows += '
    '; + rows += '
    '; + rows += '
    '; + } + + rows += ''; + } + + rows += ''; + } + + json.total = data.total_rows; // only allow 100 rows in total + //json.filteredRows = 100; // no filtering + json.rows = $(rows); + return json; + + } + }, container: $(this).next(".pager"), output: '{startRow} to {endRow} ({totalRows})',// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows} // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty @@ -74,21 +145,33 @@ cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option // class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page) cssDisabled: 'disabled' // Note there is no period "." in front of this class name + }) + + // bind to pager events + .bind('pagerInitialized pagerComplete', function(event, options){ + $(".rating-stars").each(function() { + //make sure jRating gets applied only once + if ($(this)[0].innerHTML.indexOf("jRatingColor") > -1) { + return; + } + + $(this).jRating({ + phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), + rateMax : 5, + decimalLength : 1, + onSuccess : function(data, responseUid){ + $("#averageRating" + responseUid).html(data.averageRating); + $("#numberOfVotes" + responseUid).html(data.numberOfVotes); + $("#averageRating" + responseUid).parents(".tablesorter").trigger("update"); + }, + onError : function(){ + jError('Error : please retry'); + } + }) + }); }); }); - $(".rating-stars").jRating({ - phpPath : "?method=rateResponse&toolSessionID=" + $("#toolSessionID").val(), - rateMax : 5, - decimalLength : 1, - onSuccess : function(data, responseUid){ - $("#averageRating" + responseUid).html(data.averageRating); - $("#numberOfVotes" + responseUid).html(data.numberOfVotes); - }, - onError : function(){ - jError('Error : please retry'); - } - }); $(".rating-stars-disabled").jRating({ rateMax : 5, isDisabled : true @@ -141,12 +224,12 @@
      - +
    • - : + ${status.count}:

      @@ -190,16 +273,15 @@
        - - +
      • - : - + ${status.count}: +

        - +
        - - - - - - - - - - - - - - - - - - -
        @@ -213,48 +295,6 @@
        -
        - - - - - - - -
        -
        - - - - - - - - -
        -
        - - - -
        @@ -303,7 +343,7 @@ - + Index: lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -r4606a90972c3824568c8f9648f3ffaf47030ed7d --- lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision a7661f206a3f21114f1c05f9a29f56e20f5e35f0) +++ lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 4606a90972c3824568c8f9648f3ffaf47030ed7d) @@ -120,10 +120,6 @@