Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rb12da40950a8f9e56f46af0baffd5fa83097c0db -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_common/src/java/org/lamsfoundation/lams/notebook/service/CoreNotebookService.java (.../CoreNotebookService.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -89,7 +89,7 @@ return notebookEntryDAO.get(id, idType, signature, userID); } - /** + /** * Add the SQL needed to look up entries for a given tool. Expects a valid string buffer to be supplied. This allows * a tool to get the single matching entry (assuming the tool has only created one notebook entry for each learner * in each session) for the teacher to view. This is an efficient way to get the entries at the same time as @@ -111,15 +111,17 @@ * 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"); + * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry"); or + * queryText.append(notebookEntryStrings != null ? notebookEntryStrings[0] : ", NULL notebookEntry, NULL notebookModifiedDate"); or * * 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 + * null. So you can return a collection like List irrespective of whether or not the * notebook entries (the Strings) are needed. - * - * Finally, as it will be returning the notebook entry as a separate field in select clause, set up the sql -> java - * object translation using ".addScalar("notebookEntry", Hibernate.STRING)". - * + * + * Finally, as it will be returning the notebook entry as a separate field in select clause, set up the sql -> java + * object translation using ".addScalar("notebookEntry", Hibernate.STRING)". or + * ".addScalar("notebookEntry", Hibernate.STRING).addScalar("notebookModifiedDate", Hibernate.TIMESTAMP)" + * * @param sessionIdString * Session identifier, usually the toolSessionId * @param toolSignature @@ -142,7 +144,7 @@ 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[0] = includeDates ? ", entry.entry notebookEntry, (CASE WHEN entry.last_modified IS NULL THEN entry.create_date ELSE entry.last_modified END) notebookModifiedDate " : ", entry.entry notebookEntry "; retValue[1] = buf.toString(); return retValue; } Index: lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java (.../DateUtil.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_common/src/java/org/lamsfoundation/lams/util/DateUtil.java (.../DateUtil.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -30,9 +30,16 @@ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Locale; import java.util.TimeZone; +import javax.servlet.http.HttpSession; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + + /** * Date utility class that helps the conversion between time * @@ -46,7 +53,6 @@ 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. @@ -185,11 +191,82 @@ } - /** - * Convert a date to a String for sending to the client via JSON. + public static final int TYPE_BOTH = 1; + public static final int TYPE_DATE = 2; + public static final int TYPE_TIME = 3; + + /** + * Equivalent of . Use for processing a date to send to the client via JSON. + * Locale comes from request.getLocale(); + * Same as calling convertToStringForJSON(value, DateFormat.MEDIUM, TYPE_BOTH, locale) + * @param value + * @param locale + * @return */ - public static String convertToStringForJSON(Date date) { - return JSON_DATE_OUTPUT_FORMATTER.format(date); + public static String convertToStringForJSON(Date value, Locale locale) { + return convertToStringForJSON(value, DateFormat.MEDIUM, TYPE_BOTH, locale); } + /** + * Equivalent of . Use for processing a date to send to the client via JSON. + * Locale comes from request.getLocale(); + * @param value + * @param style DateFormat.MEDIUM, DateFormat.SHORT, DateFormat.FULL + * @param type TYPE_BOTH (both data and time), TYPE_DATE or TYPE_TIME + * @param locale + * @return + */ + public static String convertToStringForJSON(Date value, Integer style, Locale locale) { + return convertToStringForJSON(value, style, TYPE_BOTH, locale); + } + + + /** + * Equivalent of . Use for processing a date to send to the client via JSON. + * Locale comes from request.getLocale(); + * @param value + * @param type TYPE_BOTH (both data and time), TYPE_DATE or TYPE_TIME + * @param locale + * @return + */ + public static String convertToStringForJSON(Date value, Integer style, Integer type, Locale locale) { + + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone tz = user.getTimeZone(); + + int dateStyle, timeStyle; + switch (style) { + case DateFormat.SHORT: + dateStyle = DateFormat.SHORT; + timeStyle = DateFormat.SHORT; + break; + case DateFormat.FULL: + dateStyle = DateFormat.LONG; + timeStyle = DateFormat.FULL; + break; + default: + dateStyle = DateFormat.LONG; + timeStyle = DateFormat.MEDIUM; + } + + DateFormat df = null; + switch (type) { + case TYPE_DATE: + df = DateFormat.getDateInstance(dateStyle, locale); + break; + case TYPE_TIME: + df = DateFormat.getTimeInstance(timeStyle, locale); + break; + default: + df = DateFormat.getDateTimeInstance(dateStyle, timeStyle, locale); + } + + if (tz != null) + df.setTimeZone(tz); + + return df.format(value); + } + + } Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java (.../INotebookUserDAO.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/INotebookUserDAO.java (.../INotebookUserDAO.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -62,9 +62,7 @@ */ 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. + /** Will return List<[NotebookUser, String, Date]> where the String is the notebook entry and the modified date. */ List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, ICoreNotebookService coreNotebookService); Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java (.../NotebookUserDAO.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/dao/hibernate/NotebookUserDAO.java (.../NotebookUserDAO.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -100,9 +100,7 @@ } @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. + /** Will return List<[NotebookUser, String, Date]> where the String is the notebook entry and the modified date. */ public List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString, ICoreNotebookService coreNotebookService) { @@ -115,10 +113,10 @@ sortingOrder = "user.last_name DESC, user.first_name DESC"; break; case NotebookConstants.SORT_BY_DATE_ASC: - sortingOrder = "notebookCreateDate ASC"; + sortingOrder = "notebookModifiedDate ASC"; break; case NotebookConstants.SORT_BY_DATE_DESC: - sortingOrder = "notebookCreateDate DESC"; + sortingOrder = "notebookModifiedDate DESC"; break; case NotebookConstants.SORT_BY_COMMENT_ASC: sortingOrder = "user.teachers_comment ASC"; @@ -149,7 +147,6 @@ 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) Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java (.../INotebookService.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/service/INotebookService.java (.../INotebookService.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -166,8 +166,8 @@ */ 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. + /** + * Will return List<[NotebookUser, String, Date]> where the String is the notebook entry and the modified date. */ List getUsersForTablesorter(final Long sessionId, int page, int size, int sorting, String searchString); int getCountUsersBySession(final Long sessionId, String searchString); Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -112,7 +112,6 @@ 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"); @@ -157,15 +156,9 @@ 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)); + if ( userAndReflection.length > 2 && userAndReflection[2] != null) { + Date modifiedDate = (Date) userAndReflection[2]; + responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE, DateUtil.convertToStringForJSON(modifiedDate, request.getLocale())); } else { responseRow.put(NotebookConstants.PARAM_MODIFIED_DATE,noEntry); } Index: lams_tool_notebook/web/pages/monitoring/summary.jsp =================================================================== diff -u -redba8c9898046064fc839e9840fea429272aff59 -r41e881a8b2eb1cbfe219fe28bc63d6725d303763 --- lams_tool_notebook/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision edba8c9898046064fc839e9840fea429272aff59) +++ lams_tool_notebook/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 41e881a8b2eb1cbfe219fe28bc63d6725d303763) @@ -181,10 +181,10 @@ {name:'id',index:'id', width:10, hidden: true, search: false}, {name:'userUid',index:'userUid', width:0, hidden: true, search: false}, {name:'userName',index:'userName', width:200}, - {name:'lastEdited',index:'lastEdited', width:120, search: false, sortable: false}, + {name:'lastEdited',index:'lastEdited', width:120, search: false}, {name:'entry',index:'entry', hidden: true, width:0, search: false}, {name:'commentsort',index:'commentsort', width:40, search: false }, - {name:'comment',index:'comment', hidden: true, width:0, search: false } + {name:'comment',index:'comment', hidden: true, width:0, search: false} ], multiselect: false,