Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java,v diff -u -r1.11.4.2 -r1.11.4.3 --- lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java 30 Dec 2015 20:40:40 -0000 1.11.4.2 +++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java 3 Feb 2016 04:11:21 -0000 1.11.4.3 @@ -96,23 +96,23 @@ * retrieving the tool data, rather than making a separate lookup. Note - if there is more than on row for each * tool/session/learner, then the tool will end up with a cross product against the learner record and you will get * one row in the learner + notebook result for each notebook entry. - * - * May only be used for entries where the external_id_type = CoreNotebookConstants.NOTEBOOK_TOOL - * - * The parameters are strings, and the SQL is built up rather than using parameters as either sessionIdString or - * userIdString may be the name of a field you are joining on. Typically the sessionId will be a number as the tool - * would be requesting the entries for only one session but the user field will need to be a reference to a column + * + * May only be used for entries where the external_id_type = CoreNotebookConstants.NOTEBOOK_TOOL + * + * The parameters are strings, and the SQL is built up rather than using parameters as either sessionIdString or + * userIdString may be the name of a field you are joining on. Typically the sessionId will be a number as the tool + * would be requesting the entries for only one session but the user field will need to be a reference to a column * in the user table so that it can get entries for more than one user. If you wanted multiple users across multiple * sessions, then the sessionId would need to refer to the column in the user/session table. - * - * If you only want an entry for one user, use getEntry(id, idIdType, signature, userID); - * + * + * If you only want an entry for one user, use getEntry(id, idIdType, signature, userID); + * * The return values are the entry for the select clause (will always have a leading but no trailing comma and an * alias of notebookEntry) and the sql join clause, which should go with any other join clauses. - * - * To make sure it always returns the same number of objects add the select clause like this: - * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry"); - * + * + * To make sure it always returns the same number of objects add the select clause like this: + * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry"); + * * Then if there is isn't a notebookEntry to return, it still returns a notebookEntry column, which translates to * null. So you can return a collection like List irrespective of whether or not the * notebook entries (the Strings) are needed. @@ -126,23 +126,34 @@ * Tool's string signature (without any quotes) e.g. lantbk11 * @param userIdString * User identifier field string e.g. - * @return String[] { partial select string, join clause } - * - */ + * @param includeDates + * if true, SQL should also return the date modified as well as the notebook entry + * @return String[] { partial select string, join clause } + * + */ @Override - public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString) { - StringBuilder buf = new StringBuilder(" LEFT JOIN lams_notebook_entry entry ON entry.external_id="); - buf.append(sessionIdString); - buf.append(" AND entry.external_id_type="); - buf.append(CoreNotebookConstants.NOTEBOOK_TOOL); - buf.append(" AND entry.external_signature=\""); - buf.append(toolSignature); - buf.append("\" AND entry.user_id="); - buf.append(userIdString); - return new String[] { ", entry.entry notebookEntry ", buf.toString() }; - } + public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString, boolean includeDates) { + StringBuilder buf = new StringBuilder(" LEFT JOIN lams_notebook_entry entry ON entry.external_id="); + buf.append(sessionIdString); + buf.append(" AND entry.external_id_type="); + buf.append(CoreNotebookConstants.NOTEBOOK_TOOL); + buf.append(" AND entry.external_signature=\""); + buf.append(toolSignature); + buf.append("\" AND entry.user_id="); + buf.append(userIdString); + String[] retValue = new String[2]; + retValue[0] = includeDates ? ", entry.entry notebookEntry, entry.create_date notebookCreateDate, entry.last_modified notebookModifiedDate " : ", entry.entry notebookEntry "; + retValue[1] = buf.toString(); + return retValue; + } + @Override + public String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString) { + return getNotebookEntrySQLStrings(sessionIdString, toolSignature, userIdString, false); + } + + @Override public List getEntry(Long id, Integer idType, String signature) { return notebookEntryDAO.get(id, idType, signature); } Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java,v diff -u -r1.8.4.2 -r1.8.4.3 --- lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java 30 Dec 2015 20:40:40 -0000 1.8.4.2 +++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/ICoreNotebookService.java 3 Feb 2016 04:11:21 -0000 1.8.4.3 @@ -41,7 +41,8 @@ List getEntry(Long id, Integer idType, String signature, Integer userID); String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString); - + String[] getNotebookEntrySQLStrings(String sessionIdString, String toolSignature, String userIdString, boolean includeDates); + List getEntry(Long id, Integer idType, String signature); List getEntry(Long id, Integer idType, Integer userID); Index: lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java,v diff -u -r1.11 -r1.11.4.1 --- lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java 2 Jul 2009 08:19:27 -0000 1.11 +++ lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java 3 Feb 2016 04:11:21 -0000 1.11.4.1 @@ -24,6 +24,7 @@ package org.lamsfoundation.lams.util; import java.sql.Timestamp; +import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; @@ -45,6 +46,7 @@ public static final String WDDX_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; public static final String LAMS_FLASH_FORMAT = "dd/M/yyyy h:mm a"; + private static final DateFormat JSON_DATE_OUTPUT_FORMATTER = new SimpleDateFormat("d MMMM yyyy h:mm:ss a"); /** * Convert your local time to Universal Time Coordinator. @@ -182,4 +184,12 @@ return convertFromString(dateString, LAMS_FLASH_FORMAT); } + + /** + * Convert a date to a String for sending to the client via JSON. + */ + public static String convertToStringForJSON(Date date) { + return JSON_DATE_OUTPUT_FORMATTER.format(date); + } + } Index: lams_tool_notebook/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/conf/language/lams/ApplicationResources.properties,v diff -u -r1.29.2.2 -r1.29.2.3 --- lams_tool_notebook/conf/language/lams/ApplicationResources.properties 6 Jan 2016 21:11:33 -0000 1.29.2.2 +++ lams_tool_notebook/conf/language/lams/ApplicationResources.properties 3 Feb 2016 04:08:52 -0000 1.29.2.3 @@ -111,6 +111,10 @@ event.teacher.comment.subject =Teacher has left a comment for your notebook entry. event.teacher.comment.body =Comment: label.click.to.edit =Click to edit - - +label.notebook.entries=Notebook Entries +label.user.name=Username +label.comment=Comment +label.no.entry=No Entry +label.yes=Yes +label.no=No #======= End labels: Exported 105 labels for en AU ===== Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java,v diff -u -r1.3 -r1.3.14.1 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java 1 Nov 2006 02:49:57 -0000 1.3 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java 3 Feb 2016 04:08:52 -0000 1.3.14.1 @@ -24,7 +24,11 @@ package org.lamsfoundation.lams.tool.notebook.dao; +import java.util.List; + import org.lamsfoundation.lams.dao.IBaseDAO; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; +import org.lamsfoundation.lams.tool.notebook.dto.StatisticDTO; import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; /** @@ -57,4 +61,15 @@ * @return */ NotebookUser getByUID(Long uid); + + /** Will return List<[NotebookUser, String, Date, Date]> + * where the String is the notebook entry, the first date is the create date and the second date is the modified date. + * No notebook entries needed? Will return in their place. + */ + List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, + ICoreNotebookService coreNotebookService); + int getCountUsersBySession(final Long sessionId, String searchString); + + /** Get the statistics for monitoring */ + List getStatisticsBySession(final Long contentId) ; } \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java,v diff -u -r1.3.14.1 -r1.3.14.2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java 29 Nov 2014 21:40:34 -0000 1.3.14.1 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java 3 Feb 2016 04:08:52 -0000 1.3.14.2 @@ -26,9 +26,20 @@ import java.util.List; +import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; +import org.hibernate.SQLQuery; +import org.hibernate.transform.Transformers; +import org.hibernate.type.IntegerType; +import org.hibernate.type.LongType; +import org.hibernate.type.StringType; +import org.hibernate.type.TimestampType; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; +import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; import org.lamsfoundation.lams.tool.notebook.dao.INotebookUserDAO; +import org.lamsfoundation.lams.tool.notebook.dto.StatisticDTO; import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; +import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; import org.springframework.stereotype.Repository; /** @@ -87,4 +98,121 @@ return (NotebookUser) list.get(0); } + + @SuppressWarnings("unchecked") + /** Will return List<[NotebookUser, String, Date, Date]> + * where the String is the notebook entry, the first date is the create date and the second date is the modified date. + * No notebook entries needed? Will return in their place. + */ + public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, + ICoreNotebookService coreNotebookService) { + String sortingOrder; + switch (sorting) { + case NotebookConstants.SORT_BY_USERNAME_ASC: + sortingOrder = "user.last_name ASC, user.first_name ASC"; + break; + case NotebookConstants.SORT_BY_USERNAME_DESC: + sortingOrder = "user.last_name DESC, user.first_name DESC"; + break; + case NotebookConstants.SORT_BY_DATE_ASC: + sortingOrder = "notebookCreateDate ASC"; + break; + case NotebookConstants.SORT_BY_DATE_DESC: + sortingOrder = "notebookCreateDate DESC"; + break; + case NotebookConstants.SORT_BY_COMMENT_ASC: + sortingOrder = "user.teachers_comment ASC"; + break; + case NotebookConstants.SORT_BY_COMMENT_DESC: + sortingOrder = "user.teachers_comment DESC"; + break; + default: + sortingOrder = "user.last_name, user.first_name"; + } + + String[] notebookEntryStrings = coreNotebookService.getNotebookEntrySQLStrings(sessionId.toString(),NotebookConstants.TOOL_SIGNATURE,"user.user_id",true ); + + // Basic select for the user records + StringBuilder queryText = new StringBuilder(); + queryText.append("SELECT user.* "); + queryText.append(notebookEntryStrings[0]); + queryText.append(" FROM tl_lantbk11_user user "); + queryText.append(" JOIN tl_lantbk11_session session ON user.notebook_session_uid = session.uid and session.session_id = :sessionId"); + queryText.append(notebookEntryStrings[1]); + + // If filtering by name add a name based where clause + buildNameSearch(searchString, queryText); + + // Now specify the sort based on the switch statement above. + queryText.append(" ORDER BY " + sortingOrder); + + SQLQuery query = getSession().createSQLQuery(queryText.toString()); + query.addEntity("user", NotebookUser.class) + .addScalar("notebookEntry", StringType.INSTANCE) + .addScalar("notebookCreateDate", TimestampType.INSTANCE) + .addScalar("notebookModifiedDate", TimestampType.INSTANCE) + .setLong("sessionId", sessionId.longValue()) + .setFirstResult(page * size) + .setMaxResults(size); + return query.list(); + } + + private void buildNameSearch(String searchString, StringBuilder sqlBuilder) { + if (!StringUtils.isBlank(searchString)) { + String[] tokens = searchString.trim().split("\\s+"); + for (String token : tokens) { + String escToken = StringEscapeUtils.escapeSql(token); + sqlBuilder.append(" WHERE (user.first_name LIKE '%").append(escToken) + .append("%' OR user.last_name LIKE '%").append(escToken) + .append("%' OR user.login_name LIKE '%").append(escToken).append("%') "); + } + } + } + + @SuppressWarnings("rawtypes") + public int getCountUsersBySession(final Long sessionId, String searchString) { + + StringBuilder queryText = new StringBuilder("SELECT count(*) FROM tl_lantbk11_user user "); + queryText.append(" JOIN tl_lantbk11_session session ON user.notebook_session_uid = session.uid and session.session_id = :sessionId"); + buildNameSearch(searchString, queryText); + + List list = getSession().createSQLQuery(queryText.toString()).setLong("sessionId", sessionId.longValue()).list(); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } + + @SuppressWarnings("rawtypes") + public int getStatistics(final Long sessionId, String searchString) { + + StringBuilder queryText = new StringBuilder("SELECT count(*) FROM tl_lantbk11_user user "); + queryText.append(" JOIN tl_lantbk11_session session ON user.notebook_session_uid = session.uid and session.session_id = :sessionId"); + buildNameSearch(searchString, queryText); + + List list = getSession().createSQLQuery(queryText.toString()).setLong("sessionId", sessionId.longValue()).list(); + if (list == null || list.size() == 0) { + return 0; + } + return ((Number) list.get(0)).intValue(); + } + + private static final String GET_STATISTICS = "SELECT session.session_id sessionId, session.session_name sessionName, " + + " COUNT(user.uid) numLearners, SUM(user.finishedActivity) numLearnersFinished " + + " FROM tl_lantbk11_notebook notebook, tl_lantbk11_session session, tl_lantbk11_user user " + + " WHERE notebook.tool_content_id = :contentId and notebook.uid = session.notebook_uid AND user.notebook_session_uid = session.uid " + + " GROUP BY session.session_id"; + + @SuppressWarnings("unchecked") + public List getStatisticsBySession(final Long contentId) { + SQLQuery query = getSession().createSQLQuery(GET_STATISTICS); + query.addScalar("sessionId", LongType.INSTANCE) + .addScalar("sessionName", StringType.INSTANCE) + .addScalar("numLearners", IntegerType.INSTANCE) + .addScalar("numLearnersFinished", IntegerType.INSTANCE) + .setLong("contentId", contentId) + .setResultTransformer(Transformers.aliasToBean(StatisticDTO.class)); + return query.list(); + } + } Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dto/NotebookSessionsDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dto/StatisticDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java,v diff -u -r1.9.2.1 -r1.9.2.2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java 2 Sep 2014 21:20:37 -0000 1.9.2.1 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java 3 Feb 2016 04:08:52 -0000 1.9.2.2 @@ -25,13 +25,14 @@ package org.lamsfoundation.lams.tool.notebook.service; import java.util.Collection; +import java.util.List; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.notebook.dto.StatisticDTO; import org.lamsfoundation.lams.tool.notebook.model.Notebook; import org.lamsfoundation.lams.tool.notebook.model.NotebookCondition; import org.lamsfoundation.lams.tool.notebook.model.NotebookSession; import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; -import org.lamsfoundation.lams.tool.notebook.util.NotebookException; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; /** @@ -165,4 +166,13 @@ */ String getLearnerContentFolder(Long toolSessionId, Long userId); + /** Will return List<[NotebookUser, String, Date, Date]> + * where the String is the notebook entry, the first date is the create date and the second date is the modified date. + */ + List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString); + int getCountUsersBySession(final Long sessionId, String searchString); + + /** Get the statistics for monitoring */ + List getStatisticsBySession(final Long contentId) ; + } \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java,v diff -u -r1.31.2.7 -r1.31.2.8 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java 30 Dec 2015 20:40:38 -0000 1.31.2.7 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/NotebookService.java 3 Feb 2016 04:08:52 -0000 1.31.2.8 @@ -57,6 +57,7 @@ import org.lamsfoundation.lams.tool.notebook.dao.INotebookDAO; import org.lamsfoundation.lams.tool.notebook.dao.INotebookSessionDAO; import org.lamsfoundation.lams.tool.notebook.dao.INotebookUserDAO; +import org.lamsfoundation.lams.tool.notebook.dto.StatisticDTO; import org.lamsfoundation.lams.tool.notebook.model.Notebook; import org.lamsfoundation.lams.tool.notebook.model.NotebookCondition; import org.lamsfoundation.lams.tool.notebook.model.NotebookSession; @@ -480,7 +481,19 @@ private String getLocalisedMessage(String key, Object[] args) { return messageService.getMessage(key, args); } + + public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString) { + return notebookUserDAO.getUsersForTablesorter(sessionId, page, size, sorting, searchString, coreNotebookService); + } + + public int getCountUsersBySession(final Long sessionId, String searchString) { + return notebookUserDAO.getCountUsersBySession(sessionId, searchString); + } + public List getStatisticsBySession(final Long contentId) { + return notebookUserDAO.getStatisticsBySession(contentId); + } + /* ===============Methods implemented from ToolContentImport102Manager =============== */ /** Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/util/NotebookConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/util/NotebookConstants.java,v diff -u -r1.9 -r1.9.2.1 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/util/NotebookConstants.java 17 Jul 2014 18:04:10 -0000 1.9 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/util/NotebookConstants.java 3 Feb 2016 04:08:52 -0000 1.9.2.1 @@ -60,8 +60,24 @@ public static final String ERROR_MSG_CONDITION = "error.condition"; public static final String ERROR_MSG_NAME_BLANK = "error.condition.name.blank"; public static final String ERROR_MSG_NAME_DUPLICATED = "error.condition.duplicated.name"; + public static final String PARAM_ENTRY = "entry"; + public static final String PARAM_NAME = "userName"; + public static final String PARAM_MODIFIED_DATE = "lastEdited"; + public static final String PARAM_COMMENT = "comment"; + public static final String PARAM_COMMENT_SORT = "commentsort"; // used to trigger sorting on comments // for submission deadline public static final String ATTR_SUBMISSION_DEADLINE = "submissionDeadline"; public static final String ATTR_IS_SUBMISSION_DEADLINE_PASSED = "isSubmissionDeadlinePassed"; + + // monitor sorting + public static final int SORT_BY_NO = 1; + public static final int SORT_BY_USERNAME_ASC = 2; + public static final int SORT_BY_USERNAME_DESC = 3; + public static final int SORT_BY_DATE_ASC = 4; + public static final int SORT_BY_DATE_DESC = 5; + public static final int SORT_BY_COMMENT_ASC = 6; + public static final int SORT_BY_COMMENT_DESC = 7; + public static final String ASC = "asc"; + public static final String DESC = "desc"; } \ No newline at end of file Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java,v diff -u -r1.13.2.1 -r1.13.2.2 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java 2 Sep 2014 21:20:37 -0000 1.13.2.1 +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java 3 Feb 2016 04:08:52 -0000 1.13.2.2 @@ -24,7 +24,7 @@ package org.lamsfoundation.lams.tool.notebook.web.actions; -import java.util.ArrayList; +import java.io.IOException; import java.util.Date; import java.util.List; import java.util.TimeZone; @@ -33,38 +33,42 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.lamsfoundation.lams.events.IEventNotificationService; -import org.lamsfoundation.lams.notebook.model.NotebookEntry; -import org.lamsfoundation.lams.tool.notebook.dto.NotebookDTO; -import org.lamsfoundation.lams.tool.notebook.dto.NotebookEntryDTO; -import org.lamsfoundation.lams.tool.notebook.dto.NotebookSessionDTO; -import org.lamsfoundation.lams.tool.notebook.dto.NotebookUserDTO; +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.tool.notebook.dto.NotebookSessionsDTO; import org.lamsfoundation.lams.tool.notebook.model.Notebook; import org.lamsfoundation.lams.tool.notebook.model.NotebookUser; import org.lamsfoundation.lams.tool.notebook.service.INotebookService; import org.lamsfoundation.lams.tool.notebook.service.NotebookServiceProxy; import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; -import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** * @struts.action path="/monitoring" parameter="dispatch" scope="request" name="monitoringForm" validate="false" * * @struts.action-forward name="success" path="tiles:/monitoring/main" + * + * @struts.action-forward name="statistic" path="/pages/monitoring/statisticpart.jsp" */ public class MonitoringAction extends LamsDispatchAction { private static Logger log = Logger.getLogger(MonitoringAction.class); + private static String noEntryText = null; // access via getNoEntryText() public INotebookService notebookService; @@ -84,21 +88,10 @@ boolean isGroupedActivity = notebookService.isGroupedActivity(toolContentID); request.setAttribute("isGroupedActivity", isGroupedActivity); - NotebookDTO notebookDTO = new NotebookDTO(notebook); + NotebookSessionsDTO notebookDTO = new NotebookSessionsDTO(notebook); Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); - notebookDTO.setCurrentTab(currentTab); + notebookDTO.setCurrentTab(currentTab != null ? currentTab : 1); - // add the notebookEntry for each user in each session - for (NotebookSessionDTO session : notebookDTO.getSessionDTOs()) { - for (NotebookUserDTO user : session.getUserDTOs()) { - NotebookEntry entry = notebookService.getEntry(user.getEntryUID()); - if (entry != null) { - NotebookEntryDTO entryDTO = new NotebookEntryDTO(entry); - user.setEntryDTO(entryDTO); - } - } - } - request.setAttribute("notebookDTO", notebookDTO); Date submissionDeadline = notebook.getSubmissionDeadline(); @@ -113,6 +106,78 @@ return mapping.findForward("success"); } + public ActionForward getUsers(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException { + + setupService(); + Long toolSessionId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID)); + + // TODO fix modified date - sorts on creation date at the moment due to database. + boolean hasSearch = WebUtil.readBooleanParam(request, "_search", false); + String searchString = hasSearch ? request.getParameter(NotebookConstants.PARAM_NAME) : null; + int page = WebUtil.readIntParam(request, "page"); + int size = WebUtil.readIntParam(request, "rows"); + int sorting = NotebookConstants.SORT_BY_NO; + String sidx = request.getParameter("sidx"); + String sord = request.getParameter("sord"); + if ( sidx != null ) { + if ( sidx.equals(NotebookConstants.PARAM_NAME) ) + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_USERNAME_ASC : NotebookConstants.SORT_BY_USERNAME_DESC; + else if ( sidx.equals(NotebookConstants.PARAM_MODIFIED_DATE) ) + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_DATE_ASC : NotebookConstants.SORT_BY_DATE_DESC; + else if ( sidx.equals(NotebookConstants.PARAM_COMMENT_SORT) ) + sorting = sord != null && sord.equals(NotebookConstants.ASC) ? NotebookConstants.SORT_BY_COMMENT_ASC : NotebookConstants.SORT_BY_COMMENT_DESC; + } + + JSONObject responsedata = new JSONObject(); + int totalRows = notebookService.getCountUsersBySession(toolSessionId, searchString); + responsedata.put("total_rows", totalRows); + responsedata.put("page", page); + responsedata.put("total", Math.ceil((float)totalRows/size)); + + JSONArray rows = new JSONArray(); + // our code expects the first page to be 0 but jqgrid uses 1 for the first page. + List users = notebookService.getUsersForTablesorter(toolSessionId, page > 0 ? page-1 : 0, size, sorting, searchString); + + String noEntry = getNoEntryText(); + + int id = 1; + for (Object[] userAndReflection : users) { + + JSONObject responseRow = new JSONObject(); + + NotebookUser user = (NotebookUser) userAndReflection[0]; + responseRow.put("id", id++); + responseRow.put(NotebookConstants.PARAM_USER_UID, user.getUid()); + responseRow.put(NotebookConstants.PARAM_NAME, StringEscapeUtils.escapeHtml(user.getLastName() + " " + user.getFirstName())); + if ( userAndReflection.length > 1 && userAndReflection[1] != null) { + responseRow.put(NotebookConstants.PARAM_ENTRY, userAndReflection[1]); + } + if ( user.getTeachersComment() != null && user.getTeachersComment().length() > 0 ) { + responseRow.put(NotebookConstants.PARAM_COMMENT, user.getTeachersComment()); + } + + Date modifiedDate = null; + if ( userAndReflection.length > 3 && userAndReflection[3] != null) { + modifiedDate = (Date) userAndReflection[3]; + } else if ( userAndReflection.length > 2 && userAndReflection[2] != null) { + modifiedDate = (Date) userAndReflection[2]; + } + if ( modifiedDate != null ) { + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE, + DateUtil.convertToStringForJSON(modifiedDate)); + } else { + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE,noEntry); + } + rows.put(responseRow); + } + responsedata.put("rows", rows); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(responsedata.toString()); + return null; + + } + /** * Updates a user's mark or feedback for an entire lesson * @@ -180,6 +245,21 @@ return null; } + /** Get the statistics for monitoring */ + public ActionForward getStatistics(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + setupService(); + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + + boolean isGroupedActivity = notebookService.isGroupedActivity(contentID); + request.setAttribute("isGroupedActivity", isGroupedActivity); + + request.setAttribute("statisticList", notebookService.getStatisticsBySession(contentID)); + + return mapping.findForward("statistic"); + } + /** * set up notebookService */ @@ -188,4 +268,13 @@ notebookService = NotebookServiceProxy.getNotebookService(this.getServlet().getServletContext()); } } + + private String getNoEntryText() { + if ( noEntryText == null ) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + noEntryText = ((MessageService) wac.getBean("notebookMessageService")).getMessage("label.no.entry"); + } + return noEntryText; + } } Index: lams_tool_notebook/web/pages/learning/notebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/web/pages/learning/notebook.jsp,v diff -u -r1.30.2.1 -r1.30.2.2 --- lams_tool_notebook/web/pages/learning/notebook.jsp 21 Oct 2014 10:31:42 -0000 1.30.2.1 +++ lams_tool_notebook/web/pages/learning/notebook.jsp 3 Feb 2016 04:08:52 -0000 1.30.2.2 @@ -104,7 +104,7 @@

- +

Index: lams_tool_notebook/web/pages/learning/mobile/notebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/web/pages/learning/mobile/notebook.jsp,v diff -u -r1.5.2.1 -r1.5.2.2 --- lams_tool_notebook/web/pages/learning/mobile/notebook.jsp 21 Oct 2014 10:31:42 -0000 1.5.2.1 +++ lams_tool_notebook/web/pages/learning/mobile/notebook.jsp 3 Feb 2016 04:08:52 -0000 1.5.2.2 @@ -94,7 +94,7 @@

- +

Index: lams_tool_notebook/web/pages/monitoring/monitoring.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/web/pages/monitoring/monitoring.jsp,v diff -u -r1.6 -r1.6.2.1 --- lams_tool_notebook/web/pages/monitoring/monitoring.jsp 17 Jan 2014 22:10:27 -0000 1.6 +++ lams_tool_notebook/web/pages/monitoring/monitoring.jsp 3 Feb 2016 04:08:52 -0000 1.6.2.1 @@ -2,19 +2,39 @@ <%@ page import="org.lamsfoundation.lams.tool.notebook.util.NotebookConstants"%>
- + + Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_notebook/web/pages/monitoring/statisticpart.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_notebook/web/pages/monitoring/statistics.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/web/pages/monitoring/statistics.jsp,v diff -u -r1.5 -r1.5.2.1 --- lams_tool_notebook/web/pages/monitoring/statistics.jsp 17 Jul 2014 18:04:10 -0000 1.5 +++ lams_tool_notebook/web/pages/monitoring/statistics.jsp 3 Feb 2016 04:08:52 -0000 1.5.2.1 @@ -1,33 +1,4 @@ <%@ include file="/common/taglibs.jsp"%> - - - - - - - -
-

- ${session.sessionName} -

-
- - - - - - - - - - -
- heading.totalLearnersInGroup - - ${session.numberOfLearners} -
- heading.totalFinishedLearnersInGroup - - ${session.numberOfFinishedLearners} -
-
+
+ <%@ include file="statisticpart.jsp"%> +
Index: lams_tool_notebook/web/pages/monitoring/summary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_notebook/web/pages/monitoring/summary.jsp,v diff -u -r1.15.2.4 -r1.15.2.5 --- lams_tool_notebook/web/pages/monitoring/summary.jsp 15 Oct 2015 10:01:13 -0000 1.15.2.4 +++ lams_tool_notebook/web/pages/monitoring/summary.jsp 3 Feb 2016 04:08:52 -0000 1.15.2.5 @@ -6,7 +6,7 @@