Index: lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -rc5457cc74f3986b393bc2947604b17168ba54dfb -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision c5457cc74f3986b393bc2947604b17168ba54dfb) +++ lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -235,6 +235,7 @@ label.required =(Required) error.required =You must answer Question {0}. label.learning.number.of.votes ={0} / {1} votes +label.votes =votes label.authoring.allow.rate.answers =Allow learners to rate each other's answers label.learning.draft.autosaved =Draft autosaved monitor.summary.date.restriction =Date and time restriction Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java =================================================================== diff -u -ra7661f206a3f21114f1c05f9a29f56e20f5e35f0 -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- 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 efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -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 -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- 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 efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -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 -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (.../IQaUsrRespDAO.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaUsrRespDAO.java (.../IQaUsrRespDAO.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -41,10 +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 -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java (.../IResponseRatingDAO.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IResponseRatingDAO.java (.../IResponseRatingDAO.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -69,5 +69,7 @@ public List getRatingsByUser(Long userUid); - Map getAverageRatingDTOByResponseAndQuestionAndSession(Long questionUid, Long qaSessionId); + 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 -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaUsrRespDAO.java (.../QaUsrRespDAO.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -26,25 +26,34 @@ 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.hibernate3.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_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 = "from qaUsrResp in class QaUsrResp " + + " where qaUsrResp.qaQueUser.qaSession.qaSessionId=:qaSessionId 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_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 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) { this.getSession().setFlushMode(FlushMode.AUTO); this.getHibernateTemplate().save(qaUsrResp); @@ -85,6 +94,33 @@ } @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 = "NULL"; + break; + case QaAppConstants.SORT_BY_AVG_RATING_DESC: + sortingOrder = "NULL"; + break; + } + + return getSession().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 = getSession().createQuery(LOAD_ATTEMPT_FOR_USER).setLong("userUid", userUid.longValue()) .list(); @@ -100,4 +136,14 @@ 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 -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java (.../ResponseRatingDAO.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/ResponseRatingDAO.java (.../ResponseRatingDAO.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -52,8 +52,11 @@ 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_RESPONSE_QUESTION_SESSION = "SELECT r.response.responseId, AVG(r.rating), COUNT(*) from " + 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 = ?"; @@ -82,8 +85,8 @@ return new AverageRatingDTO(averageRating, numberOfVotes); } - public Map getAverageRatingDTOByResponseAndQuestionAndSession(Long questionUid, Long qaSessionId) { - List list = getHibernateTemplate().find(FIND_AVERAGE_RATING_BY_RESPONSE_QUESTION_SESSION, new Object[] { questionUid, qaSessionId }); + public Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId) { + List list = getHibernateTemplate().find(FIND_AVERAGE_RATING_BY_QUESTION_AND_SESSION, new Object[] { questionUid, qaSessionId }); Map mapResponseIdToAverageRating = new HashMap(); for (Object[] results : list) { @@ -107,7 +110,33 @@ return mapResponseIdToAverageRating; } + + public Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId) { + 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 -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- 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 efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -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 -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -101,12 +101,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 getAverageRatingDTOByResponseAndQuestionAndSession(Long questionUid, Long qaSessionId); + Map getAverageRatingDTOByQuestionAndSession(Long questionUid, Long qaSessionId); + + Map getAverageRatingDTOByUserAndContentId(Long userUid, Long contentId); + /** * Creates or updates response with answer submitted by user. * Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== diff -u -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -265,6 +265,11 @@ 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) { @@ -277,9 +282,25 @@ } @Override - public Map getAverageRatingDTOByResponseAndQuestionAndSession(Long questionUid, Long qaSessionId) { - return qaResponseRatingDAO.getAverageRatingDTOByResponseAndQuestionAndSession(questionUid, qaSessionId); + 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); @@ -310,33 +331,7 @@ updateUserResponse(response); } } - - public void getResponses(String newAnswer, String toolSessionID, Long questionDisplayOrder) { - HttpSession ss = SessionManager.getSession(); - UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER); - Long userId = new Long(toolUser.getUserID().longValue()); - QaQueUsr user = getUserByIdAndSession(userId, new Long(toolSessionID)); - QaSession session = getSessionById(new Long(toolSessionID)); - QaContent qaContent = session.getQaContent(); - - QaQueContent question = getQuestionByContentAndDisplayOrder(new Long(questionDisplayOrder), qaContent.getUid()); - - QaUsrResp response = getResponseByUserAndQuestion(user.getQueUsrId(), question.getUid()); - // if response doesn't exist - if (response == null) { - response = new QaUsrResp(newAnswer, new Date(System.currentTimeMillis()), "", question, user, true); - createUserResponse(response); - - // if answer has changed - } else if (!newAnswer.equals(response.getAnswer())) { - response.setAnswer(newAnswer); - response.setAttemptTime(new Date(System.currentTimeMillis())); - response.setTimezone(""); - updateUserResponse(response); - } - } - public List getUserBySessionOnly(final QaSession qaSession) { return qaQueUsrDAO.getUserBySessionOnly(qaSession); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java =================================================================== diff -u -rca386181e6fd53b23fe0bb633f368a870db55b2f -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision ca386181e6fd53b23fe0bb633f368a870db55b2f) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -72,7 +72,7 @@ String questionUid, boolean isUserNamesVisible, boolean isLearnerRequest, String sessionId, String userId) { List> listMonitoredAttemptsContainerDTO = new LinkedList>(); - Map mapResponseIdToAverageRating = qaService.getAverageRatingDTOByResponseAndQuestionAndSession(new Long(questionUid), new Long(sessionId)); + Map mapResponseIdToAverageRating = qaService.getAverageRatingDTOByQuestionAndSession(new Long(questionUid), new Long(sessionId)); List responses = new ArrayList(); if (!isLearnerRequest) { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java =================================================================== diff -u -r2647dbba0102cb224e8c01777f149624eda89fc4 -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision 2647dbba0102cb224e8c01777f149624eda89fc4) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningAction.java (.../QaLearningAction.java) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -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; @@ -951,18 +958,98 @@ 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"); + Long userId = WebUtil.readLongParam(request, "userId"); + 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, "column1]", 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 && isSort1.equals(0)) { + sorting = QaAppConstants.SORT_BY_AVG_RATING_ASC; + } else if (isSort2 != null && isSort1.equals(1)) { + sorting = QaAppConstants.SORT_BY_AVG_RATING_DESC; + } + + List responses = qaService.getResponsesForTablesorter(qaSessionId, questionUid, userId, page, size, + sorting); + + JSONArray rows = new JSONArray(); + JSONObject responcedata = new JSONObject(); + responcedata.put("total_rows", qaService.getCountResponsesBySessionAndQuestion(qaSessionId, questionUid, userId)); + + 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.escapeJava(response.getAnswer())); + responseRow.put("userName", StringEscapeUtils.escapeJavaScript(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 -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- 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 efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -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/web/learning/LearnerRep.jsp =================================================================== diff -u -r272351bf9374ac9e53fea79b2c9530764dc74f7a -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 272351bf9374ac9e53fea79b2c9530764dc74f7a) +++ lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -48,11 +48,92 @@ $(".tablesorter").tablesorter({ theme: 'blue', widthFixed: true, - widgets: ['zebra'] + widgets: ['zebra'], + headers : { 1 : { sorter: false } } }); $(".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(), + + // modify the url after all processing has been applied + // customAjaxUrl: function(table, url) { + // manipulate the url string as you desire + // url += '&cPage=' + window.location.pathname; + // trigger my custom event + //$(table).trigger('changingUrl', url); + // send the server the current page + // return url; + // }, + 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 +152,26 @@ 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").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 +222,29 @@ - - - +
+

${status.count}: - +

- - - - - - - - - -

- - - - - - -

-

- -

- -
-
-
-
+ +

+ + + + - + +

+

+ +

+ + + + +
@@ -177,15 +253,13 @@ - - - +

${status.count}: - +

- +
- - - - - - - - - - - - - - - - - -
@@ -200,48 +274,6 @@
-
- - - - - - - -
-
- - - - - - - - -
-
- - - -
@@ -269,7 +301,7 @@ - + Index: lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp =================================================================== diff -u -r272351bf9374ac9e53fea79b2c9530764dc74f7a -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 272351bf9374ac9e53fea79b2c9530764dc74f7a) +++ lams_tool_laqa/web/learning/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -49,11 +49,92 @@ $(".tablesorter").tablesorter({ theme: 'blue', widthFixed: true, - widgets: ['zebra'] + widgets: ['zebra'], + headers : { 1 : { sorter: false } } }); $(".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(), + + // modify the url after all processing has been applied + // customAjaxUrl: function(table, url) { + // manipulate the url string as you desire + // url += '&cPage=' + window.location.pathname; + // trigger my custom event + //$(table).trigger('changingUrl', url); + // send the server the current page + // return url; + // }, + 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 +153,26 @@ 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").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 +220,29 @@ - - - +
+

${status.count}: - +

- - - - - - - - - -

- - - - - -

-

- -

- -
-
-
-
+ +

+ + + + - + +

+

+ +

+ + + + +
@@ -182,15 +260,14 @@ - - +

${status.count}: - +

- +
- - - - - - - - - - - - - - - - - - -
@@ -204,48 +281,6 @@
-
- - - - - - - -
-
- - - - - - - - -
-
- - - -
@@ -312,7 +347,7 @@ - + Index: lams_tool_laqa/web/learning/mobile/LearnerRep.jsp =================================================================== diff -u -r272351bf9374ac9e53fea79b2c9530764dc74f7a -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/web/learning/mobile/LearnerRep.jsp (.../LearnerRep.jsp) (revision 272351bf9374ac9e53fea79b2c9530764dc74f7a) +++ lams_tool_laqa/web/learning/mobile/LearnerRep.jsp (.../LearnerRep.jsp) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -50,11 +50,92 @@ $(".tablesorter").tablesorter({ theme: 'blue', widthFixed: true, - widgets: ['zebra'] + widgets: ['zebra'], + headers : { 1 : { sorter: false } } }); $(".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(), + + // modify the url after all processing has been applied + // customAjaxUrl: function(table, url) { + // manipulate the url string as you desire + // url += '&cPage=' + window.location.pathname; + // trigger my custom event + //$(table).trigger('changingUrl', url); + // send the server the current page + // return url; + // }, + 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 +154,26 @@ 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").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 +227,7 @@ - + @@ -162,36 +248,28 @@
    - - - +
  • +

    ${status.count}: - +

    - - - - - - - -

    - - - -

    -

    - -

    - -
    -
    -
    -
    +

    + - + +

    +

    + +

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

    - +
    - - - - - - - - - - - - - - - - - - -
    @@ -223,46 +300,6 @@
    -
    - - - - -
    -
    - - - - - - - - -
    -
    - - - -
    Index: lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp =================================================================== diff -u -r272351bf9374ac9e53fea79b2c9530764dc74f7a -refbaf6ddcc506fed7b594bc9b663b81a03b1283f --- lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision 272351bf9374ac9e53fea79b2c9530764dc74f7a) +++ lams_tool_laqa/web/learning/mobile/RevisitedLearnerRep.jsp (.../RevisitedLearnerRep.jsp) (revision efbaf6ddcc506fed7b594bc9b663b81a03b1283f) @@ -51,11 +51,92 @@ $(".tablesorter").tablesorter({ theme: 'blue', widthFixed: true, - widgets: ['zebra'] + widgets: ['zebra'], + headers : { 1 : { sorter: false } } }); $(".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(), + + // modify the url after all processing has been applied + // customAjaxUrl: function(table, url) { + // manipulate the url string as you desire + // url += '&cPage=' + window.location.pathname; + // trigger my custom event + //$(table).trigger('changingUrl', url); + // send the server the current page + // return url; + // }, + 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 +155,26 @@ 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").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 @@ -190,16 +276,15 @@
      - - +
    • ${status.count}: - +

      - +
      - - - - - - - - - - - - - - - - - - -
      @@ -213,48 +298,6 @@
      -
      - - - - - - - -
      -
      - - - - - - - - -
      -
      - - - -
      @@ -303,7 +346,7 @@ - +