Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/DacoServiceImpl.java (.../DacoServiceImpl.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -36,7 +36,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.confidencelevel.ConfidenceLevelDTO; import org.lamsfoundation.lams.contentrepository.ICredentials; import org.lamsfoundation.lams.contentrepository.ITicket; @@ -86,6 +85,7 @@ import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.util.MessageService; +import org.springframework.web.multipart.MultipartFile; /** * @author Dapeng.Ni @@ -253,12 +253,12 @@ @Override public List> getDacoAnswersByUser(DacoUser user) { Set answers = user.getAnswers(); - List> result = new LinkedList>(); + List> result = new LinkedList<>(); if ((answers != null) && (answers.size() > 0)) { int recordId = 1; - List record = new LinkedList(); + List record = new LinkedList<>(); for (DacoAnswer answer : answers) { if (recordId != answer.getRecordId()) { recordId = answer.getRecordId(); @@ -269,7 +269,7 @@ if (record.size() > 0) { result.add(record); } - record = new LinkedList(); + record = new LinkedList<>(); } record.add(answer); } @@ -341,10 +341,10 @@ } @Override - public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException { + public void uploadDacoAnswerFile(DacoAnswer answer, MultipartFile file) throws UploadDacoFileException { try { InputStream is = file.getInputStream(); - String fileName = file.getFileName(); + String fileName = file.getName(); String fileType = file.getContentType(); // For file only upload one sigle file if ((answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE) @@ -448,7 +448,7 @@ @Override public List getMonitoringSummary(Long contentId, Long userUid) { List sessions = dacoSessionDao.getByContentId(contentId); - List result = new ArrayList(sessions.size()); + List result = new ArrayList<>(sessions.size()); Daco daco = getDacoByContentId(contentId); for (DacoSession session : sessions) { // for each session a monitoring summary is created but don't include users as the paging fetches them @@ -482,7 +482,7 @@ MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), session.getSessionName()); - List monitoringUsers = new ArrayList(); + List monitoringUsers = new ArrayList<>(); if (userId == null) { List users = dacoUserDao.getBySessionId(sessionId, sorting); for (DacoUser user : users) { @@ -509,14 +509,14 @@ @Override public List getSummaryForExport(Long contentId, Long userUid) { List sessions = dacoSessionDao.getByContentId(contentId); - List result = new ArrayList(sessions.size()); + List result = new ArrayList<>(sessions.size()); Daco daco = getDacoByContentId(contentId); for (DacoSession session : sessions) { // for each session a monitoring summary is created MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), session.getSessionName()); List users = dacoUserDao.getBySessionId(session.getSessionId()); - List monitoringUsers = new ArrayList(users.size()); + List monitoringUsers = new ArrayList<>(users.size()); for (DacoUser user : users) { MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(), user.getUserId().intValue(), user.getFullName(), user.getLoginName()); @@ -546,7 +546,7 @@ @Override public List getQuestionSummaries(Long userUid) { - List result = new ArrayList(); + List result = new ArrayList<>(); DacoUser user = (DacoUser) dacoUserDao.getObject(DacoUser.class, userUid); // Blank structure is created Set questions = user.getDaco().getDacoQuestions(); @@ -654,12 +654,12 @@ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) { return dacoOutputFactory.getToolOutput(name, this, toolSessionId, learnerId); } - + @Override public List getToolOutputs(String name, Long toolContentId) { - return new ArrayList(); + return new ArrayList<>(); } - + @Override public List getConfidenceLevels(Long toolSessionId) { return null; @@ -792,10 +792,10 @@ public boolean isGroupedActivity(long toolContentID) { return toolService.isGroupedActivity(toolContentID); } - + @Override public void auditLogStartEditingActivityInMonitor(long toolContentID) { - toolService.auditLogStartEditingActivityInMonitor(toolContentID); + toolService.auditLogStartEditingActivityInMonitor(toolContentID); } // ******************************************************************************* @@ -811,10 +811,10 @@ * @throws RepositoryCheckedException * @throws InvalidParameterException */ - private NodeKey processFile(FormFile file) throws UploadDacoFileException { + private NodeKey processFile(MultipartFile file) throws UploadDacoFileException { NodeKey node = null; - if ((file != null) && !StringUtils.isEmpty(file.getFileName())) { - String fileName = file.getFileName(); + if ((file != null) && !StringUtils.isEmpty(file.getName())) { + String fileName = file.getName(); try { node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType()); } catch (InvalidParameterException e) { @@ -1034,7 +1034,7 @@ public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) { return getDacoOutputFactory().getSupportedDefinitionClasses(definitionType); } - + @Override public ToolCompletionStatus getCompletionStatus(Long learnerId, Long toolSessionId) { DacoUser learner = getUserByUserIdAndSessionId(learnerId, toolSessionId); @@ -1045,19 +1045,22 @@ Date startDate = null; Date endDate = null; Set answers = learner.getAnswers(); - for ( DacoAnswer answer : answers ) { + for (DacoAnswer answer : answers) { Date createDate = answer.getCreateDate(); - if ( createDate != null ) { - if ( startDate == null || createDate.before(startDate) ) + if (createDate != null) { + if (startDate == null || createDate.before(startDate)) { startDate = createDate; - if ( endDate == null || createDate.after(endDate) ) + } + if (endDate == null || createDate.after(endDate)) { endDate = createDate; + } } } - if (learner.isSessionFinished()) + if (learner.isSessionFinished()) { return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_COMPLETED, startDate, endDate); - else + } else { return new ToolCompletionStatus(ToolCompletionStatus.ACTIVITY_ATTEMPTED, startDate, null); + } } } \ No newline at end of file Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -26,7 +26,6 @@ import java.util.Collection; import java.util.List; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.contentrepository.IVersionedNode; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.daco.dao.DacoAnswerDAO; @@ -37,6 +36,7 @@ import org.lamsfoundation.lams.tool.daco.model.DacoQuestion; import org.lamsfoundation.lams.tool.daco.model.DacoSession; import org.lamsfoundation.lams.tool.daco.model.DacoUser; +import org.springframework.web.multipart.MultipartFile; /** * @author Marcin Cieslak @@ -80,7 +80,7 @@ * @param file * @throws UploadDacoFileException */ - void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException; + void uploadDacoAnswerFile(DacoAnswer answer, MultipartFile file) throws UploadDacoFileException; // ********** for user methods ************* /** @@ -323,10 +323,10 @@ int getRecordNum(Long userID, Long sessionId); boolean isGroupedActivity(long toolContentID); - + /** * Audit log the teacher has started editing activity in monitor. - * + * * @param toolContentID */ void auditLogStartEditingActivityInMonitor(long toolContentID); Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/AuthoringController.java =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -354,21 +354,21 @@ * @throws ServletException */ @RequestMapping("/init") - protected String initPage(@ModelAttribute("dacoForm") DacoForm dacoForm, HttpServletRequest request) + protected String initPage(@ModelAttribute("authoringForm") DacoForm authoringForm, HttpServletRequest request) throws ServletException { String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); DacoForm existForm = (DacoForm) sessionMap.get(DacoConstants.ATTR_DACO_FORM); try { - PropertyUtils.copyProperties(dacoForm, existForm); + PropertyUtils.copyProperties(authoringForm, existForm); } catch (Exception e) { throw new ServletException(e); } ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); - request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); + authoringForm.setMode(mode.toString()); return "pages/authoring/authoring"; } @@ -605,15 +605,15 @@ * */ @RequestMapping("/start") - protected String start(@ModelAttribute("dacoForm") DacoForm dacoForm, HttpServletRequest request) + protected String start(@ModelAttribute("authoringForm") DacoForm authoringForm, HttpServletRequest request) throws ServletException { ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); request.setAttribute(AttributeNames.ATTR_MODE, mode.toString()); - return starting(dacoForm, request); + return starting(authoringForm, request); } @RequestMapping("/definelater") - protected String defineLater(@ModelAttribute("dacoForm") DacoForm dacoForm, HttpServletRequest request) + protected String defineLater(@ModelAttribute("authoringForm") DacoForm authoringForm, HttpServletRequest request) throws ServletException { // update define later flag to true Long contentId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); @@ -626,10 +626,10 @@ dacoService.auditLogStartEditingActivityInMonitor(contentId); request.setAttribute(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER.toString()); - return starting(dacoForm, request); + return starting(authoringForm, request); } - protected String starting(@ModelAttribute("dacoForm") DacoForm dacoForm, HttpServletRequest request) + protected String starting(@ModelAttribute("authoringForm") DacoForm authoringForm, HttpServletRequest request) throws ServletException { // save toolContentID into HTTPSession @@ -643,11 +643,11 @@ // initial Session Map SessionMap sessionMap = new SessionMap<>(); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - dacoForm.setSessionMapID(sessionMap.getSessionID()); + authoringForm.setSessionMapID(sessionMap.getSessionID()); // Get contentFolderID and save to form. String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - dacoForm.setContentFolderID(contentFolderID); + authoringForm.setContentFolderID(contentFolderID); sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); try { @@ -666,7 +666,7 @@ questions = new ArrayList<>(daco.getDacoQuestions()); } - dacoForm.setDaco(daco); + authoringForm.setDaco(daco); } catch (Exception e) { AuthoringController.log.error(e); throw new ServletException(e); @@ -697,7 +697,7 @@ dacoQuestionList.clear(); dacoQuestionList.addAll(questions); - sessionMap.put(DacoConstants.ATTR_DACO_FORM, dacoForm); + sessionMap.put(DacoConstants.ATTR_DACO_FORM, authoringForm); request.getSession().setAttribute(AttributeNames.PARAM_NOTIFY_CLOSE_URL, request.getParameter(AttributeNames.PARAM_NOTIFY_CLOSE_URL)); @@ -715,26 +715,26 @@ * @throws ServletException */ @RequestMapping("/update") - protected String updateContent(@ModelAttribute("dacoForm") DacoForm dacoForm, HttpServletRequest request) + protected String updateContent(@ModelAttribute("authoringForm") DacoForm authoringForm, HttpServletRequest request) throws Exception { // get back sessionMAP SessionMap sessionMap = (SessionMap) request.getSession() - .getAttribute(dacoForm.getSessionMapID()); + .getAttribute(authoringForm.getSessionMapID()); ToolAccessMode toolAccessMode = WebUtil.readToolAccessModeAuthorDefaulted(request); request.setAttribute(AttributeNames.ATTR_MODE, toolAccessMode.toString()); - MultiValueMap errorMap = validateDacoForm(dacoForm, request); + MultiValueMap errorMap = validateDacoForm(authoringForm, request); if (!errorMap.isEmpty()) { request.setAttribute("errorMap", errorMap); return "pages/authoring/authoring"; } - Daco daco = dacoForm.getDaco(); + Daco daco = authoringForm.getDaco(); // **********************************Get Daco PO********************* - Daco dacoPO = dacoService.getDacoByContentId(dacoForm.getDaco().getContentId()); + Daco dacoPO = dacoService.getDacoByContentId(authoringForm.getDaco().getContentId()); if (dacoPO == null) { // new Daco, create it. dacoPO = daco; @@ -762,7 +762,7 @@ // get back login user DTO UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); DacoUser dacoUser = dacoService.getUserByUserIdAndContentId(new Long(user.getUserID().intValue()), - dacoForm.getDaco().getContentId()); + authoringForm.getDaco().getContentId()); if (dacoUser == null) { dacoUser = new DacoUser(user, dacoPO); } @@ -795,17 +795,17 @@ dacoService.deleteDacoQuestion(question.getUid()); } } - dacoForm.setDaco(dacoPO); + authoringForm.setDaco(dacoPO); request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); return "pages/authoring/authoring"; } - protected MultiValueMap validateDacoForm(DacoForm dacoForm, HttpServletRequest request) { + protected MultiValueMap validateDacoForm(DacoForm authoringForm, HttpServletRequest request) { MultiValueMap errorMap = new LinkedMultiValueMap<>(); - Short min = dacoForm.getDaco().getMinRecords(); - Short max = dacoForm.getDaco().getMaxRecords(); + Short min = authoringForm.getDaco().getMinRecords(); + Short max = authoringForm.getDaco().getMaxRecords(); if (min != null && max != null && min > 0 && max > 0 && min > max) { errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORDLIMIT_MIN_TOOHIGH_MAX)); } Fisheye: Tag 5d60e2334cf6775f4e4afe5755a0e56ef78540c0 refers to a dead (removed) revision in file `lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/ClearSessionAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/ClearSessionController.java =================================================================== diff -u --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/ClearSessionController.java (revision 0) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/ClearSessionController.java (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -0,0 +1,64 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.daco.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; +import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishController; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.WebApplicationContext; + +/** + * This class give a chance to clear HttpSession when user save/close authoring page. + * + * @author Steve.Ni + */ +@Controller +public class ClearSessionController extends LamsAuthoringFinishController { + + @Autowired + private WebApplicationContext applicationContext; + + @RequestMapping("/clearsession") + public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException { + super.execute(request, response, applicationContext); + } + + @Override + public void clearSession(String customiseSessionID, HttpSession session, ToolAccessMode mode) { + if (mode.isAuthor()) { + session.removeAttribute(customiseSessionID); + } + } + +} Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/LearningController.java =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/LearningController.java (.../LearningController.java) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/LearningController.java (.../LearningController.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,1068 +1,1058 @@ -///**************************************************************** -// * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) -// * ============================================================= -// * License Information: http://lamsfoundation.org/licensing/lams/2.0/ -// * -// * This program is free software; you can redistribute it and/or modify -// * it under the terms of the GNU General Public License version 2.0 -// * as published by the Free Software Foundation. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program; if not, write to the Free Software -// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 -// * USA -// * -// * http://www.gnu.org/licenses/gpl.txt -// * **************************************************************** -// */ -// -// -//package org.lamsfoundation.lams.tool.daco.web.controller; -// -//import java.io.IOException; -//import java.text.ParseException; -//import java.util.ArrayList; -//import java.util.Calendar; -//import java.util.Date; -//import java.util.Iterator; -//import java.util.LinkedList; -//import java.util.List; -//import java.util.Locale; -//import java.util.Set; -//import java.util.SortedSet; -//import java.util.TreeSet; -// -//import javax.servlet.ServletException; -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpServletResponse; -//import javax.servlet.http.HttpSession; -// -//import org.apache.commons.lang.StringUtils; -//import org.apache.commons.lang.math.NumberUtils; -//import org.apache.log4j.Logger; -//import org.apache.struts.action.Action; -//import org.apache.struts.action.ActionErrors; -//import org.apache.struts.action.ActionForm; -//import org.apache.struts.action.ActionForward; -//import org.apache.struts.action.ActionMapping; -//import org.apache.struts.action.ActionMessage; -//import org.apache.struts.action.ActionMessages; -//import org.apache.struts.upload.FormFile; -//import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; -//import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; -//import org.lamsfoundation.lams.notebook.model.NotebookEntry; -//import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; -//import org.lamsfoundation.lams.tool.ToolAccessMode; -//import org.lamsfoundation.lams.tool.daco.DacoConstants; -//import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO; -//import org.lamsfoundation.lams.tool.daco.model.Daco; -//import org.lamsfoundation.lams.tool.daco.model.DacoAnswer; -//import org.lamsfoundation.lams.tool.daco.model.DacoQuestion; -//import org.lamsfoundation.lams.tool.daco.model.DacoSession; -//import org.lamsfoundation.lams.tool.daco.model.DacoUser; -//import org.lamsfoundation.lams.tool.daco.service.DacoApplicationException; -//import org.lamsfoundation.lams.tool.daco.service.IDacoService; -//import org.lamsfoundation.lams.tool.daco.service.UploadDacoFileException; -//import org.lamsfoundation.lams.tool.daco.util.DacoQuestionComparator; -//import org.lamsfoundation.lams.tool.daco.web.form.RecordForm; -//import org.lamsfoundation.lams.tool.daco.web.form.ReflectionForm; -//import org.lamsfoundation.lams.usermanagement.dto.UserDTO; -//import org.lamsfoundation.lams.util.FileValidatorSpringUtil; -//import org.lamsfoundation.lams.util.FileValidatorUtil; -//import org.lamsfoundation.lams.util.MessageService; -//import org.lamsfoundation.lams.util.NumberUtil; -//import org.lamsfoundation.lams.util.WebUtil; -//import org.lamsfoundation.lams.web.session.SessionManager; -//import org.lamsfoundation.lams.web.util.AttributeNames; -//import org.lamsfoundation.lams.web.util.SessionMap; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.beans.factory.annotation.Qualifier; -//import org.springframework.stereotype.Controller; -//import org.springframework.util.LinkedMultiValueMap; -//import org.springframework.util.MultiValueMap; -//import org.springframework.web.bind.annotation.ModelAttribute; -//import org.springframework.web.bind.annotation.RequestMapping; -//import org.springframework.web.bind.annotation.RequestMethod; -//import org.springframework.web.context.WebApplicationContext; -//import org.springframework.web.context.support.WebApplicationContextUtils; -//import org.springframework.web.multipart.MultipartFile; -// -///** -// * -// * @author Marcin Cieslak -// * -// * @version $Revision$ -// */ -//@Controller -//@RequestMapping("/learning") -//public class LearningController{ -// -// private static Logger log = Logger.getLogger(LearningController.class); -// -// @Autowired -// private WebApplicationContext applicationContext; -// -// @Autowired -// @Qualifier("dacoService") -// private IDacoService dacoService; -// -// @Autowired -// @Qualifier("dacoMessageService") -// private MessageService messageService; -// -// /** -// * @param mapping -// * @param request -// * @return -// */ -// @RequestMapping("/diplayHorizontalRecordList") -// protected String diplayHorizontalRecordList(HttpServletRequest request) { -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, -// request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID)); -// Long userUid = WebUtil.readLongParam(request, DacoConstants.USER_UID, true); -// if (userUid != null) { -// request.setAttribute(DacoConstants.USER_UID, userUid); -// } -// return "pages/learning/listRecordsHorizontalPart"; -// } -// -// /** -// * Read daco data from database and put them into HttpSession. It will redirect to init.do directly after this -// * method run successfully. -// * -// * This method will avoid read database again and lost un-saved resouce question lost when user "refresh page", -// * -// */ -// @RequestMapping("/start") -// protected String start(HttpServletRequest request) { -// -// // initial Session Map -// SessionMap sessionMap = new SessionMap(); -// request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); -// -// // save toolContentID into HTTPSession -// ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); -// -// Long sessionId = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID)); -// -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); -// -// // get back the daco and question list and display them on page -// IDacoService service = getDacoService(); -// DacoUser dacoUser = null; -// Daco daco = service.getDacoBySessionId(sessionId); -// -// if (mode != null && mode.isTeacher()) { -// // monitoring mode - user is specified in URL -// // dacoUser may be null if the user was force completed. -// dacoUser = getSpecifiedUser(service, sessionId, -// WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); -// } else { -// dacoUser = getCurrentUser(service, sessionId, daco); -// } -// -// // check whehter finish lock is on/off -// boolean lock = daco.getLockOnFinished() && dacoUser != null && dacoUser.isSessionFinished(); -// -// // get notebook entry -// String entryText = null; -// if (dacoUser != null) { -// NotebookEntry notebookEntry = service.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, -// DacoConstants.TOOL_SIGNATURE, dacoUser.getUserId().intValue()); -// if (notebookEntry != null) { -// entryText = notebookEntry.getEntry(); -// } -// } -// -// sessionMap.put(DacoConstants.ATTR_FINISH_LOCK, lock); -// sessionMap.put(DacoConstants.ATTR_USER_FINISHED, dacoUser != null && dacoUser.isSessionFinished()); -// sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); -// sessionMap.put(AttributeNames.ATTR_MODE, mode); -// sessionMap.put(DacoConstants.ATTR_REFLECTION_ENTRY, entryText); -// sessionMap.put(DacoConstants.ATTR_DACO, daco); -// sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); -// -// List> records = service.getDacoAnswersByUser(dacoUser); -// sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, records.size() + 1); -// -// List summaries = service.getQuestionSummaries(dacoUser.getUid()); -// sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries); -// -// Integer totalRecordCount = service.getGroupRecordCount(dacoUser.getSession().getSessionId()); -// sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount); -// -// ActivityPositionDTO activityPosition = LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionId, -// request, getServlet().getServletContext()); -// sessionMap.put(AttributeNames.ATTR_ACTIVITY_POSITION, activityPosition); -// -// // add define later support -// if (daco.isDefineLater()) { -// return "pages/learning/definelater"; -// } -// -// // set contentInUse flag to true! -// daco.setContentInUse(true); -// daco.setDefineLater(false); -// service.saveOrUpdateDaco(daco); -// -// sessionMap.put(DacoConstants.ATTR_DACO, daco); -// -// if (daco.isNotifyTeachersOnLearnerEntry()) { -// service.notifyTeachersOnLearnerEntry(sessionId, dacoUser); -// } -// -// return "pages/learning/learning"; -// } -// -// /** -// * Finish learning session. -// * -// * @param mapping -// * @param form -// * @param request -// * @param response -// * @return -// */ -// @RequestMapping("/finish") -// protected String finish(HttpServletRequest request) { -// -// // get back SessionMap -// String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// -// // get mode and ToolSessionID from sessionMAP -// ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); -// Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); -// -// MultiValueMap errorMap = validateBeforeFinish(request, sessionMapID); -// if (!errorMap.isEmpty()) { -// request.setAttribute("errorMap", errorMap); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, -// request.getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); -// return "pages/learning/learning"; -// } -// -// // get sessionId from HttpServletRequest -// String nextActivityUrl = null; -// try { -// HttpSession httpSession = SessionManager.getSession(); -// UserDTO user = (UserDTO) httpSession.getAttribute(AttributeNames.USER); -// Long userUid = new Long(user.getUserID().longValue()); -// -// nextActivityUrl = service.finishToolSession(sessionId, userUid); -// request.setAttribute(DacoConstants.ATTR_NEXT_ACTIVITY_URL, nextActivityUrl); -// } catch (DacoApplicationException e) { -// -// LearningController.log.error("Failed get next activity url:" + e.getMessage()); -// } -// -// return "pages/learning/finish"; -// } -// -// /** -// * Save file or textfield daco question into database. -// * -// * @param mapping -// * @param form -// * @param request -// * @param response -// * @return -// */ -// @RequestMapping(value = "/saveOrUpdateRecord", method = RequestMethod.POST) -// protected String saveOrUpdateRecord(@ModelAttribute("recordForm")RecordForm recordForm , HttpServletRequest request) { -// String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); -// Set questionList = daco.getDacoQuestions(); -// Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); -// DacoUser user = getCurrentUser(service, sessionId, daco); -// -// service.releaseAnswersFromCache(user.getAnswers()); -// -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// sessionMap.put(DacoConstants.ATTR_LEARNING_CURRENT_TAB, 1); -// -// /* -// * design decision - assume users will not have a lot of records each. If very large record sets -// * we should go to the db and just get the size & the next id, and the record to be updated, -// * rather than manipulating the full list of records. -// */ -// List record = null; -// List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); -// int recordCount = records.size(); -// int displayedRecordNumber = recordForm.getDisplayedRecordNumber(); -// -// /* -// * Cannot use the displayRecordNumber as the new record id as records may be deleted and there will -// * be missing numbers in the recordId sequence. Just using displayRecordNumber will add entries to -// * existing records. -// */ -// int nextRecordId = 1; -// if (recordCount > 0) { -// // records should be in recordId order, so find the next record id based on the last record -// List lastRecord = records.get(recordCount - 1); -// DacoAnswer lastRecordAnswer = lastRecord.get(0); -// if (lastRecordAnswer.getRecordId() >= nextRecordId) { -// nextRecordId = lastRecordAnswer.getRecordId() + 1; -// } -// } -// -// boolean isEdit = false; -// if (displayedRecordNumber <= recordCount) { -// record = records.get(displayedRecordNumber - 1); -// isEdit = true; -// } else { -// record = new LinkedList(); -// recordCount++; -// } -// -// MultiValueMap errorMap = validateRecordForm(daco, recordForm, questionList, recordCount); -// if (!errorMap.isEmpty()) { -// this.addErrors(request, errorMap); -// refreshQuestionSummaries(mapping, request); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, recordForm.getDisplayedRecordNumber()); -// return mapping.findForward(DacoConstants.SUCCESS); -// } -// -// Iterator questionIterator = questionList.iterator(); -// DacoQuestion question = null; -// int formAnswerNumber = 0; -// int answerNumber = 0; -// int fileNumber = 0; -// DacoAnswer answer = null; -// -// while (questionIterator.hasNext()) { -// -// question = questionIterator.next(); -// if (isEdit) { -// answer = record.get(answerNumber++); -// } else { -// answer = new DacoAnswer(); -// answer.setQuestion(question); -// answer.setRecordId(nextRecordId); -// answer.setUser(user); -// } -// answer.setCreateDate(new Date()); -// -// switch (question.getType()) { -// case DacoConstants.QUESTION_TYPE_NUMBER: { -// String formAnswer = recordForm.getAnswer(formAnswerNumber); -// if (StringUtils.isBlank(formAnswer)) { -// answer.setAnswer(null); -// } else { -// if (question.getDigitsDecimal() != null) { -// formAnswer = NumberUtil.formatLocalisedNumber(Double.parseDouble(formAnswer), (Locale) null, -// question.getDigitsDecimal()); -// } -// answer.setAnswer(formAnswer); -// } -// formAnswerNumber++; -// } -// break; -// case DacoConstants.QUESTION_TYPE_DATE: { -// String[] dateParts = new String[] { recordForm.getAnswer(formAnswerNumber++), -// recordForm.getAnswer(formAnswerNumber++), recordForm.getAnswer(formAnswerNumber) }; -// if (!(StringUtils.isBlank(dateParts[0]) || StringUtils.isBlank(dateParts[1]) -// || StringUtils.isBlank(dateParts[2]))) { -// -// Calendar calendar = Calendar.getInstance(); -// calendar.clear(); -// calendar.set(Integer.parseInt(dateParts[2]), Integer.parseInt(dateParts[1]) - 1, -// Integer.parseInt(dateParts[0])); -// answer.setAnswer(DacoConstants.DEFAULT_DATE_FORMAT.format(calendar.getTime())); -// } else { -// answer.setAnswer(null); -// } -// } -// formAnswerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_CHECKBOX: { -// String formAnswer = recordForm.getAnswer(formAnswerNumber); -// String[] checkboxes = formAnswer.split("&"); -// if (isEdit) { -// DacoAnswer localAnswer = answer; -// answerNumber--; -// do { -// service.deleteDacoAnswer(localAnswer.getUid()); -// record.remove(answerNumber); -// if (answerNumber < record.size()) { -// localAnswer = record.get(answerNumber); -// if (localAnswer.getQuestion().getType() != DacoConstants.QUESTION_TYPE_CHECKBOX) { -// localAnswer = null; -// } -// } else { -// localAnswer = null; -// } -// } while (localAnswer != null); -// answer = (DacoAnswer) answer.clone(); -// -// } -// if (StringUtils.isBlank(formAnswer)) { -// answer.setAnswer(null); -// } else { -// for (int checkboxNumber = 0; checkboxNumber < checkboxes.length; checkboxNumber++) { -// answer.setAnswer(checkboxes[checkboxNumber]); -// if (checkboxNumber < checkboxes.length - 1) { -// service.saveOrUpdateAnswer(answer); -// if (isEdit) { -// record.add(answerNumber++, answer); -// } else { -// record.add(answer); -// } -// -// answer = (DacoAnswer) answer.clone(); -// } -// } -// } -// if (isEdit) { -// record.add(answerNumber++, answer); -// } -// } -// formAnswerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_LONGLAT: { -// answer.setAnswer(recordForm.getAnswer(formAnswerNumber++)); -// service.saveOrUpdateAnswer(answer); -// if (isEdit) { -// answer = record.get(answerNumber++); -// } else { -// record.add(answer); -// answer = (DacoAnswer) answer.clone(); -// } -// answer.setAnswer(recordForm.getAnswer(formAnswerNumber)); -// } -// formAnswerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_FILE: -// case DacoConstants.QUESTION_TYPE_IMAGE: { -// FormFile file = recordForm.getFile(fileNumber); -// if (file != null) { -// try { -// service.uploadDacoAnswerFile(answer, file); -// } catch (UploadDacoFileException e) { -// LearningController.log.error("Failed upload Resource File " + e.toString()); -// e.printStackTrace(); -// } -// } -// } -// fileNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_DROPDOWN: { -// String formAnswer = recordForm.getAnswer(formAnswerNumber); -// answer.setAnswer("0".equals(formAnswer) ? null : formAnswer); -// } -// formAnswerNumber++; -// break; -// default: -// answer.setAnswer(recordForm.getAnswer(formAnswerNumber)); -// formAnswerNumber++; -// break; -// } -// -// service.saveOrUpdateAnswer(answer); -// if (!isEdit) { -// record.add(answer); -// } -// } -// -// form.reset(mapping, request); -// if (isEdit) { -// request.setAttribute(DacoConstants.ATTR_RECORD_OPERATION_SUCCESS, DacoConstants.RECORD_OPERATION_EDIT); -// } else { -// -// records.add(record); -// request.setAttribute(DacoConstants.ATTR_RECORD_OPERATION_SUCCESS, DacoConstants.RECORD_OPERATION_ADD); -// -// // notify teachers -// if (daco.isNotifyTeachersOnRecordSumbit()) { -// service.notifyTeachersOnRecordSumbit(sessionId, user); -// } -// } -// -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, records.size() + 1); -// refreshQuestionSummaries(mapping, request); -// -// return mapping.findForward(DacoConstants.SUCCESS); -// } -// -// /** -// * Display empty reflection form. -// * -// * @param mapping -// * @param form -// * @param request -// * @param response -// * @return -// */ -// protected ActionForward startReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request) { -// -// // get session value -// String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); -// -// ActionErrors errors = validateBeforeFinish(request, sessionMapID); -// if (!errors.isEmpty()) { -// this.addErrors(request, errors); -// refreshQuestionSummaries(mapping, request); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, -// request.getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); -// return mapping.getInputForward(); -// } -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// -// Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); -// IDacoService service = getDacoService(); -// ReflectionForm reflectionForm = (ReflectionForm) form; -// HttpSession httpSession = SessionManager.getSession(); -// UserDTO userDTO = (UserDTO) httpSession.getAttribute(AttributeNames.USER); -// DacoUser user = service.getUserByUserIdAndSessionId(userDTO.getUserID().longValue(), toolSessionID); -// -// reflectionForm.setUserId(userDTO.getUserID()); -// reflectionForm.setSessionId(toolSessionID); -// -// // get the existing reflection entry -// -// NotebookEntry entry = service.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, -// DacoConstants.TOOL_SIGNATURE, userDTO.getUserID()); -// -// if (entry != null) { -// reflectionForm.setEntryText(entry.getEntry()); -// } -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// reflectionForm.setSessionMapID(sessionMapID); -// return mapping.findForward(DacoConstants.SUCCESS); -// } -// -// /** -// * Submit reflection form input database. -// * -// * @param mapping -// * @param form -// * @param request -// * @param response -// * @return -// */ -// protected ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request) { -// ReflectionForm reflectionForm = (ReflectionForm) form; -// Integer userId = reflectionForm.getUserId(); -// Long sessionId = reflectionForm.getSessionId(); -// IDacoService service = getDacoService(); -// // check for existing notebook entry -// NotebookEntry entry = service.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, -// DacoConstants.TOOL_SIGNATURE, userId); -// -// if (entry == null) { -// // create new entry -// service.createNotebookEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE, -// userId, reflectionForm.getEntryText()); -// } else { -// // update existing entry -// entry.setEntry(reflectionForm.getEntryText()); -// entry.setLastModified(new Date()); -// service.updateEntry(entry); -// } -// -// return finish(mapping, request); -// } -// -// // ************************************************************************************* -// // Private method -// // ************************************************************************************* -// protected MultiValueMap validateBeforeFinish(HttpServletRequest request, String sessionMapID) { -// MultiValueMap errorMap = new LinkedMultiValueMap<>(); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// int recordCount = ((List) sessionMap.get(DacoConstants.ATTR_RECORD_LIST)).size(); -// Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); -// Short min = daco.getMinRecords(); -// if (min != null && min > 0 && recordCount < min) { -// errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_NOTENOUGH, new Object[] {daco.getMinRecords()})); -// } -// return errorMap; -// } -// -// /** -// * List save current daco questions. -// * -// * @param request -// * @return -// */ -// protected SortedSet getDacoQuestionList(SessionMap sessionMap) { -// SortedSet list = (SortedSet) sessionMap.get(DacoConstants.ATTR_QUESTION_LIST); -// if (list == null) { -// list = new TreeSet(new DacoQuestionComparator()); -// sessionMap.put(DacoConstants.ATTR_QUESTION_LIST, list); -// } -// return list; -// } -// -// /** -// * Get java.util.List from HttpSession by given name. -// * -// * @param request -// * @param name -// * @return -// */ -// protected List getListFromSession(SessionMap sessionMap, String name) { -// List list = (List) sessionMap.get(name); -// if (list == null) { -// list = new ArrayList(); -// sessionMap.put(name, list); -// } -// return list; -// } -// -// protected DacoUser getCurrentUser(IDacoService service, Long sessionId, Daco daco) { -// // try to get form system session -// HttpSession ss = SessionManager.getSession(); -// // get back login user DTO -// UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); -// DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), sessionId); -// -// if (dacoUser == null) { -// DacoSession session = service.getSessionBySessionId(sessionId); -// dacoUser = new DacoUser(user, session); -// dacoUser.setDaco(daco); -// service.createUser(dacoUser); -// } -// return dacoUser; -// } -// -// protected DacoUser getSpecifiedUser(IDacoService service, Long sessionId, Integer userId) { -// DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(userId.intValue()), sessionId); -// if (dacoUser == null) { -// LearningController.log -// .error("Unable to find specified user for daco activity. Screens are likely to fail. SessionId=" -// + sessionId + " UserId=" + userId); -// } -// return dacoUser; -// } -// -// protected MultiValueMap validateRecordForm(Daco daco, RecordForm recordForm, Set questionList, -// int recordCount) { -// MultiValueMap errorMap = new LinkedMultiValueMap<>(); -// Short maxRecords = daco.getMaxRecords(); -// if (maxRecords != null && maxRecords > 0 && recordCount > maxRecords) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_TOOMUCH, new Object[] {daco.getMaxRecords()})); -// } -// -// Iterator questionIterator = questionList.iterator(); -// DacoQuestion question = null; -// int answerNumber = 0; -// int fileNumber = 0; -// int questionNumber = 1; -// -// while (questionIterator.hasNext()) { -// question = questionIterator.next(); -// switch (question.getType()) { -// case DacoConstants.QUESTION_TYPE_TEXTFIELD: -// case DacoConstants.QUESTION_TYPE_RADIO: -// if (question.isRequired() && StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, new Object[] {questionNumber})); -// -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_TEXTAREA: { -// if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { -// if (question.isRequired()) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, new Object[] {questionNumber})); -// } -// } else if (question.getMax() != null) { -// long words = 0; -// int index = 0; -// boolean prevWhiteSpace = true; -// while (index < recordForm.getAnswer(answerNumber).length()) { -// char c = recordForm.getAnswer(answerNumber).charAt(index++); -// boolean currWhiteSpace = Character.isWhitespace(c); -// if (prevWhiteSpace && !currWhiteSpace) { -// words++; -// } -// prevWhiteSpace = currWhiteSpace; -// } -// int max = question.getMax().intValue(); -// if (words > max) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_TEXTAREA_LONG, new Object[] {questionNumber, max})); -// } -// } -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_NUMBER: { -// if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { -// if (question.isRequired()) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, new Object[] {questionNumber})); -// } -// } else { -// try { -// float number = Float.parseFloat(recordForm.getAnswer(answerNumber)); -// Float min = question.getMin(); -// Float max = question.getMax(); -// if (min != null && number < min) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_NUMBER_MIN, new Object[] {questionNumber, min})); -// } else if (max != null && number > max) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_NUMBER_MAX, new Object[] {questionNumber, max})); -// } -// } catch (NumberFormatException e) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_NUMBER_FLOAT, new Object[] {questionNumber})); -// } -// } -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_DATE: { -// String day = recordForm.getAnswer(answerNumber++); -// String month = recordForm.getAnswer(answerNumber++); -// String year = recordForm.getAnswer(answerNumber); -// if (StringUtils.isBlank(day) && StringUtils.isBlank(month) && StringUtils.isBlank(year)) { -// if (question.isRequired()) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, new Object[] {questionNumber})); -// } -// } else { -// Integer yearNum = null; -// Integer monthNum = null; -// if (StringUtils.isBlank(year)) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_YEAR_BLANK, new Object[] {questionNumber})); -// } else { -// try { -// yearNum = Integer.parseInt(year); -// } catch (NumberFormatException e) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_DATE_YEAR_INT, new Object[] {questionNumber})); -// } -// } -// boolean monthValid = false; -// if (StringUtils.isBlank(month)) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_BLANK, new Object[] {questionNumber})); -// } else { -// try { -// monthNum = Integer.parseInt(month); -// if (monthNum < 1 || monthNum > 12) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_LIMIT, new Object[] {questionNumber})); -// } else { -// monthValid = true; -// } -// } catch (NumberFormatException e) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_INT, new Object[] {questionNumber})); -// } -// } -// -// if (StringUtils.isBlank(day)) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_DAY_BLANK, new Object[] {questionNumber})); -// } else if (monthValid) { -// try { -// -// int dayNum = Integer.parseInt(day); -// Integer maxDays = yearNum == null || monthNum == null ? null -// : getMaxDays(monthNum, yearNum); -// if (dayNum < 1 || maxDays != null && dayNum > maxDays) { -// errorMap.add("GLOBAL", -// messageService.getMessage( -// DacoConstants.ERROR_MSG_RECORD_DATE_DAY_LIMIT, new Object[] {questionNumber, maxDays})); -// } -// } catch (NumberFormatException e) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_DAY_INT, new Object[] {questionNumber})); -// } -// } -// } -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_FILE: { -// MultipartFile file = recordForm.getFile(fileNumber); -// if (file == null || file.getSize() == 0) { -// if (question.isRequired()) { -// errorMap.add("GLOBAL", -// messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, new Object[] {questionNumber})); -// } -// } else { -// FileValidatorSpringUtil.validateFileSize(file, true); -// } -// fileNumber++; -// } -// break; -// case DacoConstants.QUESTION_TYPE_IMAGE: { -// FormFile file = recordForm.getFile(fileNumber); -// if (file == null || file.getFileSize() == 0) { -// if (question.isRequired()) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, questionNumber)); -// } -// } else { -// String fileName = file.getFileName(); -// boolean isImage = false; -// if (fileName.length() > 5) { -// -// String extension = fileName.substring(fileName.length() - 3); -// for (String acceptedExtension : DacoConstants.IMAGE_EXTENSIONS) { -// if (extension.equalsIgnoreCase(acceptedExtension)) { -// isImage = true; -// break; -// } -// } -// } -// if (!isImage) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_IMAGE_FORMAT, questionNumber)); -// } else { -// FileValidatorUtil.validateFileSize(file, true, errorMap); -// } -// } -// fileNumber++; -// } -// break; -// case DacoConstants.QUESTION_TYPE_DROPDOWN: { -// if (question.isRequired() && "0".equals(recordForm.getAnswer(answerNumber))) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, questionNumber)); -// -// } -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_CHECKBOX: { -// if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { -// if (question.isRequired()) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, questionNumber)); -// } -// } else { -// int count = recordForm.getAnswer(answerNumber).split("&").length; -// Float min = question.getMin(); -// Float max = question.getMax(); -// if (min != null && count < min) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( -// DacoConstants.ERROR_MSG_RECORD_CHECKBOX_MIN, questionNumber, min.intValue())); -// } else if (max != null && count > max) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( -// DacoConstants.ERROR_MSG_RECORD_CHECKBOX_MAX, questionNumber, max.intValue())); -// } -// } -// } -// answerNumber++; -// break; -// case DacoConstants.QUESTION_TYPE_LONGLAT: { -// String longitude = recordForm.getAnswer(answerNumber++); -// String latitude = recordForm.getAnswer(answerNumber); -// if (StringUtils.isBlank(longitude)) { -// if (StringUtils.isBlank(latitude)) { -// if (question.isRequired()) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, questionNumber)); -// } -// } else { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_LONGITUDE_BLANK, questionNumber)); -// } -// -// } else if (StringUtils.isBlank(latitude)) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_LATITUDE_BLANK, questionNumber)); -// } else { -// try { -// Float.parseFloat(longitude); -// } catch (NumberFormatException e) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_LONGITUDE_FLOAT, questionNumber)); -// } -// try { -// Float.parseFloat(latitude); -// } catch (NumberFormatException e) { -// errorMap.add(ActionMessages.GLOBAL_MESSAGE, -// new ActionMessage(DacoConstants.ERROR_MSG_RECORD_LATITUDE_FLOAT, questionNumber)); -// } -// } -// } -// answerNumber++; -// break; -// } -// questionNumber++; -// } -// return errorMap; -// } -// -// protected final int getMaxDays(int month, int year) { -// if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { -// return 31; -// } -// if (month == 2) { -// return isLeapYear(year) ? 29 : 28; -// } -// return 30; -// } -// -// protected final boolean isLeapYear(int year) { -// if (year % 4 == 0) { -// -// if (year % 100 != 0) { -// return true; -// } else if (year % 400 == 0) { -// return false; -// } else { -// return false; -// } -// } else { -// return false; -// } -// } -// -// protected ActionForward editRecord(ActionMapping mapping, ActionForm form, HttpServletRequest request) { -// String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// int recordIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_RECORD_INDEX), -1); -// List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); -// if (recordIndex != -1 && records != null && records.size() >= recordIndex) { -// List record = records.get(recordIndex - 1); -// RecordForm recordForm = (RecordForm) form; -// recordForm.setDisplayedRecordNumber(recordIndex); -// recordForm.setSessionMapID(sessionMapID); -// StringBuilder checkboxes = null; -// int checkboxQuestionNumber = 0; -// int formAnswerNumber = 0; -// for (int answerNumber = 0; answerNumber < record.size(); answerNumber++) { -// DacoAnswer answer = record.get(answerNumber); -// short questionType = answer.getQuestion().getType(); -// -// if (questionType == DacoConstants.QUESTION_TYPE_CHECKBOX) { -// if (checkboxes == null) { -// checkboxes = new StringBuilder(record.size() * 3); -// checkboxQuestionNumber = formAnswerNumber++; -// } -// checkboxes.append(answer.getAnswer()).append('&'); -// } else { -// if (checkboxes != null) { -// recordForm.setAnswer(checkboxQuestionNumber, checkboxes.toString()); -// checkboxes = null; -// } -// if (questionType == DacoConstants.QUESTION_TYPE_DATE) { -// String[] dateParts = new String[3]; -// if (answer.getAnswer() != null) { -// Calendar calendar = Calendar.getInstance(); -// calendar.clear(); -// -// try { -// calendar.setTime(DacoConstants.DEFAULT_DATE_FORMAT.parse(answer.getAnswer())); -// } catch (ParseException e) { -// LearningController.log.error(e.getMessage()); -// e.printStackTrace(); -// } -// -// dateParts[0] = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); -// dateParts[1] = String.valueOf(calendar.get(Calendar.MONTH) + 1); -// dateParts[2] = String.valueOf(calendar.get(Calendar.YEAR)); -// } -// recordForm.setAnswer(formAnswerNumber++, dateParts[0]); -// recordForm.setAnswer(formAnswerNumber++, dateParts[1]); -// recordForm.setAnswer(formAnswerNumber++, dateParts[2]); -// } else if (!(questionType == DacoConstants.QUESTION_TYPE_FILE -// || questionType == DacoConstants.QUESTION_TYPE_IMAGE)) { -// recordForm.setAnswer(formAnswerNumber++, answer.getAnswer()); -// } -// } -// } -// if (checkboxes != null) { -// recordForm.setAnswer(checkboxQuestionNumber, checkboxes.toString()); -// } -// -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// sessionMap.put(DacoConstants.ATTR_LEARNING_CURRENT_TAB, 1); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, recordIndex); -// return mapping.findForward(DacoConstants.SUCCESS); -// } else { -// return null; -// } -// } -// -// protected ActionForward removeRecord(ActionMapping mapping, HttpServletRequest request) { -// String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// int recordIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_RECORD_INDEX), -1); -// List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); -// IDacoService service = getDacoService(); -// if (recordIndex != -1 && records != null && records.size() >= recordIndex) { -// List record = records.get(recordIndex - 1); -// service.deleteDacoRecord(record); -// records.remove(record); -// sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records); -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// return mapping.findForward(DacoConstants.SUCCESS); -// } else { -// return null; -// } -// } -// -// protected ActionForward changeView(ActionMapping mapping, HttpServletRequest request) { -// String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, -// WebUtil.readIntParam(request, DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); -// request.setAttribute(DacoConstants.ATTR_LEARNING_CURRENT_TAB, -// WebUtil.readIntParam(request, DacoConstants.ATTR_LEARNING_CURRENT_TAB)); -// String currentView = (String) sessionMap.get(DacoConstants.ATTR_LEARNING_VIEW); -// if (DacoConstants.LEARNING_VIEW_HORIZONTAL.equals(currentView)) { -// sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); -// } else { -// sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_HORIZONTAL); -// } -// return mapping.findForward(DacoConstants.SUCCESS); -// } -// -// protected ActionForward refreshQuestionSummaries(ActionMapping mapping, HttpServletRequest request) { -// String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); -// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); -// Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); -// Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); -// IDacoService service = getDacoService(); -// DacoUser user = getCurrentUser(service, sessionId, daco); -// -// // get mode - monitoring vs learner -// ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); -// if (mode != null && mode.isTeacher()) { -// // monitoring mode - user is specified in URL -// // user may be null if the user was force completed. -// user = getSpecifiedUser(service, sessionId, -// WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); -// } else { -// user = getCurrentUser(service, sessionId, daco); -// } -// -// if (user != null) { -// List summaries = service.getQuestionSummaries(user.getUid()); -// sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries); -// Integer totalRecordCount = service.getGroupRecordCount(user.getSession().getSessionId()); -// sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount); -// } else { -// sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, new LinkedList()); -// sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, 0); -// } -// -// request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); -// return mapping.findForward(DacoConstants.SUCCESS); -// } -// -//} \ No newline at end of file +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.daco.web.controller; + +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learning.web.bean.ActivityPositionDTO; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.daco.DacoConstants; +import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO; +import org.lamsfoundation.lams.tool.daco.model.Daco; +import org.lamsfoundation.lams.tool.daco.model.DacoAnswer; +import org.lamsfoundation.lams.tool.daco.model.DacoQuestion; +import org.lamsfoundation.lams.tool.daco.model.DacoSession; +import org.lamsfoundation.lams.tool.daco.model.DacoUser; +import org.lamsfoundation.lams.tool.daco.service.DacoApplicationException; +import org.lamsfoundation.lams.tool.daco.service.IDacoService; +import org.lamsfoundation.lams.tool.daco.service.UploadDacoFileException; +import org.lamsfoundation.lams.tool.daco.util.DacoQuestionComparator; +import org.lamsfoundation.lams.tool.daco.web.form.RecordForm; +import org.lamsfoundation.lams.tool.daco.web.form.ReflectionForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.FileValidatorSpringUtil; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.NumberUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.multipart.MultipartFile; + +/** + * + * @author Marcin Cieslak + * + * @version $Revision$ + */ +@Controller +@RequestMapping("/learning") +public class LearningController { + + private static Logger log = Logger.getLogger(LearningController.class); + + @Autowired + private WebApplicationContext applicationContext; + + @Autowired + @Qualifier("dacoService") + private IDacoService dacoService; + + @Autowired + @Qualifier("dacoMessageService") + private MessageService messageService; + + /** + * @param mapping + * @param request + * @return + */ + @RequestMapping("/diplayHorizontalRecordList") + protected String diplayHorizontalRecordList(HttpServletRequest request) { + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, + request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID)); + Long userUid = WebUtil.readLongParam(request, DacoConstants.USER_UID, true); + if (userUid != null) { + request.setAttribute(DacoConstants.USER_UID, userUid); + } + return "pages/learning/listRecordsHorizontalPart"; + } + + /** + * Read daco data from database and put them into HttpSession. It will redirect to init.do directly after this + * method run successfully. + * + * This method will avoid read database again and lost un-saved resouce question lost when user "refresh page", + * + */ + @RequestMapping("/start") + protected String start(HttpServletRequest request) { + + // initial Session Map + SessionMap sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + + // save toolContentID into HTTPSession + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); + + Long sessionId = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID)); + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + + // get back the daco and question list and display them on page + DacoUser dacoUser = null; + Daco daco = dacoService.getDacoBySessionId(sessionId); + + if (mode != null && mode.isTeacher()) { + // monitoring mode - user is specified in URL + // dacoUser may be null if the user was force completed. + dacoUser = getSpecifiedUser(dacoService, sessionId, + WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); + } else { + dacoUser = getCurrentUser(dacoService, sessionId, daco); + } + + // check whehter finish lock is on/off + boolean lock = daco.getLockOnFinished() && dacoUser != null && dacoUser.isSessionFinished(); + + // get notebook entry + String entryText = null; + if (dacoUser != null) { + NotebookEntry notebookEntry = dacoService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, dacoUser.getUserId().intValue()); + if (notebookEntry != null) { + entryText = notebookEntry.getEntry(); + } + } + + sessionMap.put(DacoConstants.ATTR_FINISH_LOCK, lock); + sessionMap.put(DacoConstants.ATTR_USER_FINISHED, dacoUser != null && dacoUser.isSessionFinished()); + sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId); + sessionMap.put(AttributeNames.ATTR_MODE, mode); + sessionMap.put(DacoConstants.ATTR_REFLECTION_ENTRY, entryText); + sessionMap.put(DacoConstants.ATTR_DACO, daco); + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); + + List> records = dacoService.getDacoAnswersByUser(dacoUser); + sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, records.size() + 1); + + List summaries = dacoService.getQuestionSummaries(dacoUser.getUid()); + sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries); + + Integer totalRecordCount = dacoService.getGroupRecordCount(dacoUser.getSession().getSessionId()); + sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount); + + ActivityPositionDTO activityPosition = LearningWebUtil.putActivityPositionInRequestByToolSessionId(sessionId, + request, applicationContext.getServletContext()); + sessionMap.put(AttributeNames.ATTR_ACTIVITY_POSITION, activityPosition); + + // add define later support + if (daco.isDefineLater()) { + return "pages/learning/definelater"; + } + + // set contentInUse flag to true! + daco.setContentInUse(true); + daco.setDefineLater(false); + dacoService.saveOrUpdateDaco(daco); + + sessionMap.put(DacoConstants.ATTR_DACO, daco); + + if (daco.isNotifyTeachersOnLearnerEntry()) { + dacoService.notifyTeachersOnLearnerEntry(sessionId, dacoUser); + } + + return "pages/learning/learning"; + } + + /** + * Finish learning session. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/finish") + protected String finish(HttpServletRequest request) { + + // get back SessionMap + String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + // get mode and ToolSessionID from sessionMAP + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + + MultiValueMap errorMap = validateBeforeFinish(request, sessionMapID); + if (!errorMap.isEmpty()) { + request.setAttribute("errorMap", errorMap); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, + request.getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); + return "pages/learning/learning"; + } + + // get sessionId from HttpServletRequest + String nextActivityUrl = null; + try { + HttpSession httpSession = SessionManager.getSession(); + UserDTO user = (UserDTO) httpSession.getAttribute(AttributeNames.USER); + Long userUid = new Long(user.getUserID().longValue()); + + nextActivityUrl = dacoService.finishToolSession(sessionId, userUid); + request.setAttribute(DacoConstants.ATTR_NEXT_ACTIVITY_URL, nextActivityUrl); + } catch (DacoApplicationException e) { + + LearningController.log.error("Failed get next activity url:" + e.getMessage()); + } + + return "pages/learning/finish"; + } + + /** + * Save file or textfield daco question into database. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping(value = "/saveOrUpdateRecord", method = RequestMethod.POST) + protected String saveOrUpdateRecord(@ModelAttribute("recordForm") RecordForm recordForm, + HttpServletRequest request) { + String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); + Set questionList = daco.getDacoQuestions(); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + DacoUser user = getCurrentUser(dacoService, sessionId, daco); + + dacoService.releaseAnswersFromCache(user.getAnswers()); + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + sessionMap.put(DacoConstants.ATTR_LEARNING_CURRENT_TAB, 1); + + /* + * design decision - assume users will not have a lot of records each. If very large record sets + * we should go to the db and just get the size & the next id, and the record to be updated, + * rather than manipulating the full list of records. + */ + List record = null; + List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); + int recordCount = records.size(); + int displayedRecordNumber = recordForm.getDisplayedRecordNumber(); + + /* + * Cannot use the displayRecordNumber as the new record id as records may be deleted and there will + * be missing numbers in the recordId sequence. Just using displayRecordNumber will add entries to + * existing records. + */ + int nextRecordId = 1; + if (recordCount > 0) { + // records should be in recordId order, so find the next record id based on the last record + List lastRecord = records.get(recordCount - 1); + DacoAnswer lastRecordAnswer = lastRecord.get(0); + if (lastRecordAnswer.getRecordId() >= nextRecordId) { + nextRecordId = lastRecordAnswer.getRecordId() + 1; + } + } + + boolean isEdit = false; + if (displayedRecordNumber <= recordCount) { + record = records.get(displayedRecordNumber - 1); + isEdit = true; + } else { + record = new LinkedList<>(); + recordCount++; + } + + MultiValueMap errorMap = validateRecordForm(daco, recordForm, questionList, recordCount); + if (!errorMap.isEmpty()) { + request.setAttribute("errorMap", errorMap); + refreshQuestionSummaries(request); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, recordForm.getDisplayedRecordNumber()); + return "pages/learning/learning"; + } + + Iterator questionIterator = questionList.iterator(); + DacoQuestion question = null; + int formAnswerNumber = 0; + int answerNumber = 0; + int fileNumber = 0; + DacoAnswer answer = null; + + while (questionIterator.hasNext()) { + + question = questionIterator.next(); + if (isEdit) { + answer = record.get(answerNumber++); + } else { + answer = new DacoAnswer(); + answer.setQuestion(question); + answer.setRecordId(nextRecordId); + answer.setUser(user); + } + answer.setCreateDate(new Date()); + + switch (question.getType()) { + case DacoConstants.QUESTION_TYPE_NUMBER: { + String formAnswer = recordForm.getAnswer(formAnswerNumber); + if (StringUtils.isBlank(formAnswer)) { + answer.setAnswer(null); + } else { + if (question.getDigitsDecimal() != null) { + formAnswer = NumberUtil.formatLocalisedNumber(Double.parseDouble(formAnswer), (Locale) null, + question.getDigitsDecimal()); + } + answer.setAnswer(formAnswer); + } + formAnswerNumber++; + } + break; + case DacoConstants.QUESTION_TYPE_DATE: { + String[] dateParts = new String[] { recordForm.getAnswer(formAnswerNumber++), + recordForm.getAnswer(formAnswerNumber++), recordForm.getAnswer(formAnswerNumber) }; + if (!(StringUtils.isBlank(dateParts[0]) || StringUtils.isBlank(dateParts[1]) + || StringUtils.isBlank(dateParts[2]))) { + + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + calendar.set(Integer.parseInt(dateParts[2]), Integer.parseInt(dateParts[1]) - 1, + Integer.parseInt(dateParts[0])); + answer.setAnswer(DacoConstants.DEFAULT_DATE_FORMAT.format(calendar.getTime())); + } else { + answer.setAnswer(null); + } + } + formAnswerNumber++; + break; + case DacoConstants.QUESTION_TYPE_CHECKBOX: { + String formAnswer = recordForm.getAnswer(formAnswerNumber); + String[] checkboxes = formAnswer.split("&"); + if (isEdit) { + DacoAnswer localAnswer = answer; + answerNumber--; + do { + dacoService.deleteDacoAnswer(localAnswer.getUid()); + record.remove(answerNumber); + if (answerNumber < record.size()) { + localAnswer = record.get(answerNumber); + if (localAnswer.getQuestion().getType() != DacoConstants.QUESTION_TYPE_CHECKBOX) { + localAnswer = null; + } + } else { + localAnswer = null; + } + } while (localAnswer != null); + answer = (DacoAnswer) answer.clone(); + + } + if (StringUtils.isBlank(formAnswer)) { + answer.setAnswer(null); + } else { + for (int checkboxNumber = 0; checkboxNumber < checkboxes.length; checkboxNumber++) { + answer.setAnswer(checkboxes[checkboxNumber]); + if (checkboxNumber < checkboxes.length - 1) { + dacoService.saveOrUpdateAnswer(answer); + if (isEdit) { + record.add(answerNumber++, answer); + } else { + record.add(answer); + } + + answer = (DacoAnswer) answer.clone(); + } + } + } + if (isEdit) { + record.add(answerNumber++, answer); + } + } + formAnswerNumber++; + break; + case DacoConstants.QUESTION_TYPE_LONGLAT: { + answer.setAnswer(recordForm.getAnswer(formAnswerNumber++)); + dacoService.saveOrUpdateAnswer(answer); + if (isEdit) { + answer = record.get(answerNumber++); + } else { + record.add(answer); + answer = (DacoAnswer) answer.clone(); + } + answer.setAnswer(recordForm.getAnswer(formAnswerNumber)); + } + formAnswerNumber++; + break; + case DacoConstants.QUESTION_TYPE_FILE: + case DacoConstants.QUESTION_TYPE_IMAGE: { + MultipartFile file = recordForm.getFile(fileNumber); + if (file != null) { + try { + dacoService.uploadDacoAnswerFile(answer, file); + } catch (UploadDacoFileException e) { + LearningController.log.error("Failed upload Resource File " + e.toString()); + e.printStackTrace(); + } + } + } + fileNumber++; + break; + case DacoConstants.QUESTION_TYPE_DROPDOWN: { + String formAnswer = recordForm.getAnswer(formAnswerNumber); + answer.setAnswer("0".equals(formAnswer) ? null : formAnswer); + } + formAnswerNumber++; + break; + default: + answer.setAnswer(recordForm.getAnswer(formAnswerNumber)); + formAnswerNumber++; + break; + } + + dacoService.saveOrUpdateAnswer(answer); + if (!isEdit) { + record.add(answer); + } + } + + recordForm.reset(request); + if (isEdit) { + request.setAttribute(DacoConstants.ATTR_RECORD_OPERATION_SUCCESS, DacoConstants.RECORD_OPERATION_EDIT); + } else { + + records.add(record); + request.setAttribute(DacoConstants.ATTR_RECORD_OPERATION_SUCCESS, DacoConstants.RECORD_OPERATION_ADD); + + // notify teachers + if (daco.isNotifyTeachersOnRecordSumbit()) { + dacoService.notifyTeachersOnRecordSumbit(sessionId, user); + } + } + + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, records.size() + 1); + refreshQuestionSummaries(request); + + return "pages/learning/learning"; + } + + /** + * Display empty reflection form. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/startReflection") + protected String startReflection(@ModelAttribute("messageForm") ReflectionForm messageForm, + HttpServletRequest request) { + + // get session value + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + + MultiValueMap errorMap = validateBeforeFinish(request, sessionMapID); + if (!errorMap.isEmpty()) { + request.setAttribute("errorMap", errorMap); + refreshQuestionSummaries(request); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, + request.getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); + return "pages/learning/learning"; + } + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + HttpSession httpSession = SessionManager.getSession(); + UserDTO userDTO = (UserDTO) httpSession.getAttribute(AttributeNames.USER); + DacoUser user = dacoService.getUserByUserIdAndSessionId(userDTO.getUserID().longValue(), toolSessionID); + + messageForm.setUserId(userDTO.getUserID()); + messageForm.setSessionId(toolSessionID); + + // get the existing reflection entry + + NotebookEntry entry = dacoService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, userDTO.getUserID()); + + if (entry != null) { + messageForm.setEntryText(entry.getEntry()); + } + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + messageForm.setSessionMapID(sessionMapID); + return "pages/learning/notebook"; + } + + /** + * Submit reflection form input database. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/submitReflection") + protected String submitReflection(@ModelAttribute("messageForm") ReflectionForm messageForm, + HttpServletRequest request) { + Integer userId = messageForm.getUserId(); + Long sessionId = messageForm.getSessionId(); + // check for existing notebook entry + NotebookEntry entry = dacoService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, userId); + + if (entry == null) { + // create new entry + dacoService.createNotebookEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, userId, messageForm.getEntryText()); + } else { + // update existing entry + entry.setEntry(messageForm.getEntryText()); + entry.setLastModified(new Date()); + dacoService.updateEntry(entry); + } + + return "pages/learning/finish"; + } + + // ************************************************************************************* + // Private method + // ************************************************************************************* + protected MultiValueMap validateBeforeFinish(HttpServletRequest request, String sessionMapID) { + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + int recordCount = ((List) sessionMap.get(DacoConstants.ATTR_RECORD_LIST)).size(); + Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); + Short min = daco.getMinRecords(); + if (min != null && min > 0 && recordCount < min) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_NOTENOUGH, + new Object[] { daco.getMinRecords() })); + } + return errorMap; + } + + /** + * List save current daco questions. + * + * @param request + * @return + */ + protected SortedSet getDacoQuestionList(SessionMap sessionMap) { + SortedSet list = (SortedSet) sessionMap.get(DacoConstants.ATTR_QUESTION_LIST); + if (list == null) { + list = new TreeSet<>(new DacoQuestionComparator()); + sessionMap.put(DacoConstants.ATTR_QUESTION_LIST, list); + } + return list; + } + + /** + * Get java.util.List from HttpSession by given name. + * + * @param request + * @param name + * @return + */ + protected List getListFromSession(SessionMap sessionMap, String name) { + List list = (List) sessionMap.get(name); + if (list == null) { + list = new ArrayList(); + sessionMap.put(name, list); + } + return list; + } + + protected DacoUser getCurrentUser(IDacoService service, Long sessionId, Daco daco) { + // try to get form system session + HttpSession ss = SessionManager.getSession(); + // get back login user DTO + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), sessionId); + + if (dacoUser == null) { + DacoSession session = service.getSessionBySessionId(sessionId); + dacoUser = new DacoUser(user, session); + dacoUser.setDaco(daco); + service.createUser(dacoUser); + } + return dacoUser; + } + + protected DacoUser getSpecifiedUser(IDacoService service, Long sessionId, Integer userId) { + DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(userId.intValue()), sessionId); + if (dacoUser == null) { + LearningController.log + .error("Unable to find specified user for daco activity. Screens are likely to fail. SessionId=" + + sessionId + " UserId=" + userId); + } + return dacoUser; + } + + protected MultiValueMap validateRecordForm(Daco daco, RecordForm recordForm, + Set questionList, int recordCount) { + MultiValueMap errorMap = new LinkedMultiValueMap<>(); + Short maxRecords = daco.getMaxRecords(); + if (maxRecords != null && maxRecords > 0 && recordCount > maxRecords) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_TOOMUCH, + new Object[] { daco.getMaxRecords() })); + } + + Iterator questionIterator = questionList.iterator(); + DacoQuestion question = null; + int answerNumber = 0; + int fileNumber = 0; + int questionNumber = 1; + + while (questionIterator.hasNext()) { + question = questionIterator.next(); + switch (question.getType()) { + case DacoConstants.QUESTION_TYPE_TEXTFIELD: + case DacoConstants.QUESTION_TYPE_RADIO: + if (question.isRequired() && StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_TEXTAREA: { + if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else if (question.getMax() != null) { + long words = 0; + int index = 0; + boolean prevWhiteSpace = true; + while (index < recordForm.getAnswer(answerNumber).length()) { + char c = recordForm.getAnswer(answerNumber).charAt(index++); + boolean currWhiteSpace = Character.isWhitespace(c); + if (prevWhiteSpace && !currWhiteSpace) { + words++; + } + prevWhiteSpace = currWhiteSpace; + } + int max = question.getMax().intValue(); + if (words > max) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_TEXTAREA_LONG, + new Object[] { questionNumber, max })); + } + } + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_NUMBER: { + if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + try { + float number = Float.parseFloat(recordForm.getAnswer(answerNumber)); + Float min = question.getMin(); + Float max = question.getMax(); + if (min != null && number < min) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_NUMBER_MIN, + new Object[] { questionNumber, min })); + } else if (max != null && number > max) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_NUMBER_MAX, + new Object[] { questionNumber, max })); + } + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_NUMBER_FLOAT, new Object[] { questionNumber })); + } + } + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_DATE: { + String day = recordForm.getAnswer(answerNumber++); + String month = recordForm.getAnswer(answerNumber++); + String year = recordForm.getAnswer(answerNumber); + if (StringUtils.isBlank(day) && StringUtils.isBlank(month) && StringUtils.isBlank(year)) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + Integer yearNum = null; + Integer monthNum = null; + if (StringUtils.isBlank(year)) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_DATE_YEAR_BLANK, new Object[] { questionNumber })); + } else { + try { + yearNum = Integer.parseInt(year); + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_DATE_YEAR_INT, new Object[] { questionNumber })); + } + } + boolean monthValid = false; + if (StringUtils.isBlank(month)) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_BLANK, new Object[] { questionNumber })); + } else { + try { + monthNum = Integer.parseInt(month); + if (monthNum < 1 || monthNum > 12) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_LIMIT, + new Object[] { questionNumber })); + } else { + monthValid = true; + } + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_MONTH_INT, + new Object[] { questionNumber })); + } + } + + if (StringUtils.isBlank(day)) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_DATE_DAY_BLANK, new Object[] { questionNumber })); + } else if (monthValid) { + try { + + int dayNum = Integer.parseInt(day); + Integer maxDays = yearNum == null || monthNum == null ? null + : getMaxDays(monthNum, yearNum); + if (dayNum < 1 || maxDays != null && dayNum > maxDays) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_DATE_DAY_LIMIT, + new Object[] { questionNumber, maxDays })); + } + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_DATE_DAY_INT, new Object[] { questionNumber })); + } + } + } + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_FILE: { + MultipartFile file = recordForm.getFile(fileNumber); + if (file == null || file.getSize() == 0) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + FileValidatorSpringUtil.validateFileSize(file, true); + } + fileNumber++; + } + break; + case DacoConstants.QUESTION_TYPE_IMAGE: { + MultipartFile file = recordForm.getFile(fileNumber); + if (file == null || file.getSize() == 0) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + String fileName = file.getName(); + boolean isImage = false; + if (fileName.length() > 5) { + + String extension = fileName.substring(fileName.length() - 3); + for (String acceptedExtension : DacoConstants.IMAGE_EXTENSIONS) { + if (extension.equalsIgnoreCase(acceptedExtension)) { + isImage = true; + break; + } + } + } + if (!isImage) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_IMAGE_FORMAT, new Object[] { questionNumber })); + } else { + FileValidatorSpringUtil.validateFileSize(file, true); + } + } + fileNumber++; + } + break; + case DacoConstants.QUESTION_TYPE_DROPDOWN: { + if (question.isRequired() && "0".equals(recordForm.getAnswer(answerNumber))) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + + } + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_CHECKBOX: { + if (StringUtils.isBlank(recordForm.getAnswer(answerNumber))) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + int count = recordForm.getAnswer(answerNumber).split("&").length; + Float min = question.getMin(); + Float max = question.getMax(); + if (min != null && count < min) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_CHECKBOX_MIN, + new Object[] { questionNumber, min.intValue() })); + } else if (max != null && count > max) { + errorMap.add("GLOBAL", + messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_CHECKBOX_MAX, + new Object[] { questionNumber, max.intValue() })); + } + } + } + answerNumber++; + break; + case DacoConstants.QUESTION_TYPE_LONGLAT: { + String longitude = recordForm.getAnswer(answerNumber++); + String latitude = recordForm.getAnswer(answerNumber); + if (StringUtils.isBlank(longitude)) { + if (StringUtils.isBlank(latitude)) { + if (question.isRequired()) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_BLANK, + new Object[] { questionNumber })); + } + } else { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_LONGITUDE_BLANK, new Object[] { questionNumber })); + } + + } else if (StringUtils.isBlank(latitude)) { + errorMap.add("GLOBAL", messageService.getMessage(DacoConstants.ERROR_MSG_RECORD_LATITUDE_BLANK, + new Object[] { questionNumber })); + } else { + try { + Float.parseFloat(longitude); + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_LONGITUDE_FLOAT, new Object[] { questionNumber })); + } + try { + Float.parseFloat(latitude); + } catch (NumberFormatException e) { + errorMap.add("GLOBAL", messageService.getMessage( + DacoConstants.ERROR_MSG_RECORD_LATITUDE_FLOAT, new Object[] { questionNumber })); + } + } + } + answerNumber++; + break; + } + questionNumber++; + } + return errorMap; + } + + protected final int getMaxDays(int month, int year) { + if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { + return 31; + } + if (month == 2) { + return isLeapYear(year) ? 29 : 28; + } + return 30; + } + + protected final boolean isLeapYear(int year) { + if (year % 4 == 0) { + + if (year % 100 != 0) { + return true; + } else if (year % 400 == 0) { + return false; + } else { + return false; + } + } else { + return false; + } + } + + @RequestMapping("/editRecord") + protected String editRecord(@ModelAttribute("recordForm") RecordForm recordForm, HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + int recordIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_RECORD_INDEX), -1); + List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); + if (recordIndex != -1 && records != null && records.size() >= recordIndex) { + List record = records.get(recordIndex - 1); + recordForm.setDisplayedRecordNumber(recordIndex); + recordForm.setSessionMapID(sessionMapID); + StringBuilder checkboxes = null; + int checkboxQuestionNumber = 0; + int formAnswerNumber = 0; + for (int answerNumber = 0; answerNumber < record.size(); answerNumber++) { + DacoAnswer answer = record.get(answerNumber); + short questionType = answer.getQuestion().getType(); + + if (questionType == DacoConstants.QUESTION_TYPE_CHECKBOX) { + if (checkboxes == null) { + checkboxes = new StringBuilder(record.size() * 3); + checkboxQuestionNumber = formAnswerNumber++; + } + checkboxes.append(answer.getAnswer()).append('&'); + } else { + if (checkboxes != null) { + recordForm.setAnswer(checkboxQuestionNumber, checkboxes.toString()); + checkboxes = null; + } + if (questionType == DacoConstants.QUESTION_TYPE_DATE) { + String[] dateParts = new String[3]; + if (answer.getAnswer() != null) { + Calendar calendar = Calendar.getInstance(); + calendar.clear(); + + try { + calendar.setTime(DacoConstants.DEFAULT_DATE_FORMAT.parse(answer.getAnswer())); + } catch (ParseException e) { + LearningController.log.error(e.getMessage()); + e.printStackTrace(); + } + + dateParts[0] = String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)); + dateParts[1] = String.valueOf(calendar.get(Calendar.MONTH) + 1); + dateParts[2] = String.valueOf(calendar.get(Calendar.YEAR)); + } + recordForm.setAnswer(formAnswerNumber++, dateParts[0]); + recordForm.setAnswer(formAnswerNumber++, dateParts[1]); + recordForm.setAnswer(formAnswerNumber++, dateParts[2]); + } else if (!(questionType == DacoConstants.QUESTION_TYPE_FILE + || questionType == DacoConstants.QUESTION_TYPE_IMAGE)) { + recordForm.setAnswer(formAnswerNumber++, answer.getAnswer()); + } + } + } + if (checkboxes != null) { + recordForm.setAnswer(checkboxQuestionNumber, checkboxes.toString()); + } + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + sessionMap.put(DacoConstants.ATTR_LEARNING_CURRENT_TAB, 1); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, recordIndex); + return "pages/learning/addRecord"; + } else { + return null; + } + } + + @RequestMapping("/removeRecord") + protected String removeRecord(HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + int recordIndex = NumberUtils.stringToInt(request.getParameter(DacoConstants.PARAM_RECORD_INDEX), -1); + List> records = (List>) sessionMap.get(DacoConstants.ATTR_RECORD_LIST); + if (recordIndex != -1 && records != null && records.size() >= recordIndex) { + List record = records.get(recordIndex - 1); + dacoService.deleteDacoRecord(record); + records.remove(record); + sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records); + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "pages/learning/listRecords"; + } else { + return null; + } + } + + @RequestMapping("/changeView") + protected String changeView(HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, + WebUtil.readIntParam(request, DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER)); + request.setAttribute(DacoConstants.ATTR_LEARNING_CURRENT_TAB, + WebUtil.readIntParam(request, DacoConstants.ATTR_LEARNING_CURRENT_TAB)); + String currentView = (String) sessionMap.get(DacoConstants.ATTR_LEARNING_VIEW); + if (DacoConstants.LEARNING_VIEW_HORIZONTAL.equals(currentView)) { + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); + } else { + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_HORIZONTAL); + } + return "pages/learning/learning"; + } + + @RequestMapping("/refreshQuestionSummaries") + protected String refreshQuestionSummaries(HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); + Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + DacoUser user = getCurrentUser(dacoService, sessionId, daco); + + // get mode - monitoring vs learner + ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE); + if (mode != null && mode.isTeacher()) { + // monitoring mode - user is specified in URL + // user may be null if the user was force completed. + user = getSpecifiedUser(dacoService, sessionId, + WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false)); + } else { + user = getCurrentUser(dacoService, sessionId, daco); + } + + if (user != null) { + List summaries = dacoService.getQuestionSummaries(user.getUid()); + sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries); + Integer totalRecordCount = dacoService.getGroupRecordCount(user.getSession().getSessionId()); + sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount); + } else { + sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, new LinkedList()); + sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, 0); + } + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "pages/learning/questionSummaries"; + } + +} \ No newline at end of file Fisheye: Tag 5d60e2334cf6775f4e4afe5755a0e56ef78540c0 refers to a dead (removed) revision in file `lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/MonitoringAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/MonitoringController.java =================================================================== diff -u --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/MonitoringController.java (revision 0) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/controller/MonitoringController.java (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -0,0 +1,525 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.daco.web.controller; + +import java.io.IOException; +import java.text.ParseException; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +import javax.servlet.ServletException; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.daco.DacoConstants; +import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummarySessionDTO; +import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummaryUserDTO; +import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO; +import org.lamsfoundation.lams.tool.daco.model.Daco; +import org.lamsfoundation.lams.tool.daco.model.DacoAnswer; +import org.lamsfoundation.lams.tool.daco.model.DacoAnswerOption; +import org.lamsfoundation.lams.tool.daco.model.DacoQuestion; +import org.lamsfoundation.lams.tool.daco.model.DacoUser; +import org.lamsfoundation.lams.tool.daco.service.IDacoService; +import org.lamsfoundation.lams.tool.daco.util.DacoExcelUtil; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.CentralConstants; +import org.lamsfoundation.lams.util.FileUtil; +import org.lamsfoundation.lams.util.NumberUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.util.HtmlUtils; + +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; + +@Controller +@RequestMapping("/monitoring") +public class MonitoringController { + public static Logger log = Logger.getLogger(MonitoringController.class); + + @Autowired + @Qualifier("dacoService") + private IDacoService dacoService; + + @RequestMapping("/listRecords") + protected String listRecords(HttpServletRequest request) { + return listRecords(request, false); + } + + @RequestMapping("/changeView") + protected String changeView(HttpServletRequest request) { + return listRecords(request, true); + } + + private String listRecords(HttpServletRequest request, boolean changeView) { + + String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + Long userId = WebUtil.readLongParam(request, DacoConstants.USER_ID, true); + Integer sortOrder = WebUtil.readIntParam(request, DacoConstants.ATTR_SORT, true); + if (sortOrder == null) { + sortOrder = DacoConstants.SORT_BY_NO; + } + + sessionMap.put(DacoConstants.ATTR_MONITORING_SUMMARY, + dacoService.getAnswersAsRecords(toolSessionId, userId, sortOrder)); + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId); + request.setAttribute(DacoConstants.ATTR_SORT, sortOrder); + request.setAttribute(DacoConstants.USER_ID, userId); + + if (changeView) { + String currentView = (String) sessionMap.get(DacoConstants.ATTR_LEARNING_VIEW); + if (DacoConstants.LEARNING_VIEW_HORIZONTAL.equals(currentView)) { + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); + } else { + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_HORIZONTAL); + } + } + + return "pages/monitoring/listRecords"; + } + + @RequestMapping("/summary") + protected String summary(HttpServletRequest request) { + // initial Session Map + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID, true); + + boolean newSession = sessionMapID == null || request.getSession().getAttribute(sessionMapID) == null; + SessionMap sessionMap = null; + if (newSession) { + sessionMap = new SessionMap(); + sessionMapID = sessionMap.getSessionID(); + request.getSession().setAttribute(sessionMapID, sessionMap); + sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL); + } else { + sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + } + + Long contentId = sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID) == null + ? WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID) + : (Long) sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID); + Daco daco = dacoService.getDacoByContentId(contentId); + + List monitoringSummaryList = dacoService.getMonitoringSummary(contentId, + DacoConstants.MONITORING_SUMMARY_MATCH_NONE); + + Long userUid = WebUtil.readLongParam(request, DacoConstants.USER_UID, true); + if (userUid == null) { + userUid = (Long) sessionMap.get(DacoConstants.USER_UID); + request.setAttribute(DacoConstants.ATTR_MONITORING_CURRENT_TAB, 1); + } else { + request.setAttribute(DacoConstants.ATTR_MONITORING_CURRENT_TAB, 3); + } + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + sessionMap.put(DacoConstants.USER_UID, userUid); + sessionMap.put(DacoConstants.PAGE_EDITABLE, !daco.isContentInUse()); + sessionMap.put(DacoConstants.ATTR_MONITORING_SUMMARY, monitoringSummaryList); + + if (newSession) { + boolean isGroupedActivity = dacoService.isGroupedActivity(contentId); + sessionMap.put(DacoConstants.ATTR_IS_GROUPED_ACTIVITY, isGroupedActivity); + sessionMap.put(DacoConstants.ATTR_DACO, daco); + sessionMap.put(AttributeNames.PARAM_TOOL_CONTENT_ID, contentId); + sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, + WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID)); + + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + } + return "pages/monitoring/monitoring"; + } + + @RequestMapping(path = "/getUsers", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @ResponseBody + protected String getUsers(HttpServletRequest request, HttpServletResponse res) + throws IOException, ServletException { + + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID, true); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + Long contentId = sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID) == null + ? WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID) + : (Long) sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID); + + // paging parameters of tablesorter + int size = WebUtil.readIntParam(request, "size"); + int page = WebUtil.readIntParam(request, "page"); + Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true); + Integer isSort2 = WebUtil.readIntParam(request, "column[1]", true); + String searchString = request.getParameter("fcol[0]"); + + int sorting = DacoConstants.SORT_BY_NO; + if ((isSort1 != null) && isSort1.equals(0)) { + sorting = DacoConstants.SORT_BY_USER_NAME_ASC; + + } else if ((isSort1 != null) && isSort1.equals(1)) { + sorting = DacoConstants.SORT_BY_USER_NAME_DESC; + + } else if ((isSort2 != null) && isSort2.equals(0)) { + sorting = DacoConstants.SORT_BY_NUM_RECORDS_ASC; + + } else if ((isSort2 != null) && isSort2.equals(1)) { + sorting = DacoConstants.SORT_BY_NUM_RECORDS_DESC; + } + + Daco daco = dacoService.getDacoByContentId(contentId); + + List users = dacoService.getUsersForTablesorter(sessionId, page, size, sorting, searchString, + daco.isReflectOnActivity()); + + ArrayNode rows = JsonNodeFactory.instance.arrayNode(); + + ObjectNode responsedata = JsonNodeFactory.instance.objectNode(); + responsedata.put("total_rows", dacoService.getCountUsersBySession(sessionId, searchString)); + + for (Object[] userAndReflection : users) { + + ObjectNode responseRow = JsonNodeFactory.instance.objectNode(); + + DacoUser user = (DacoUser) userAndReflection[0]; + + responseRow.put(DacoConstants.USER_ID, user.getUserId()); + responseRow.put(DacoConstants.USER_FULL_NAME, HtmlUtils.htmlEscape(user.getFullName())); + + if (userAndReflection.length > 1 && userAndReflection[1] != null) { + responseRow.put(DacoConstants.RECORD_COUNT, (Integer) userAndReflection[1]); + } else { + responseRow.put(DacoConstants.RECORD_COUNT, 0); + } + + if (userAndReflection.length > 2 && userAndReflection[2] != null) { + responseRow.put(DacoConstants.NOTEBOOK_ENTRY, HtmlUtils.htmlEscape((String) userAndReflection[2])); + } + if (userAndReflection.length > 3 && userAndReflection[3] != null) { + responseRow.put(DacoConstants.PORTRAIT_ID, (String) userAndReflection[3]); + } + rows.add(responseRow); + } + responsedata.set("rows", rows); + return responsedata.toString(); + } + + @RequestMapping("/viewReflection") + protected String viewReflection(HttpServletRequest request) { + String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Integer userId = WebUtil.readIntParam(request, DacoConstants.USER_ID); + Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + DacoUser user = dacoService.getUserByUserIdAndSessionId(userId.longValue(), sessionId); + NotebookEntry notebookEntry = dacoService.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + DacoConstants.TOOL_SIGNATURE, userId); + + MonitoringSummaryUserDTO userDTO = new MonitoringSummaryUserDTO(null, userId, user.getFullName(), null); + userDTO.setReflectionEntry(notebookEntry.getEntry()); + sessionMap.put(DacoConstants.ATTR_USER, userDTO); + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "pages/monitoring/notebook"; + } + + /** + * Exports all learners' data to an Excel or CSV file. + * + * @param request + * @param response + * @return + * @throws IOException + * @throws JXLException + * @throws ParseException + */ + @RequestMapping("/exportToSpreadsheet") + protected String exportToSpreadsheet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ParseException { + // Get required parameters + String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO); + + // Prepare headers and column names + String title = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_TITLE, null); + String dateHeader = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_DATE, null); + + Set questions = daco.getDacoQuestions(); + HashMap questionUidToSpreadsheetColumnIndex = new HashMap<>(); + // First two columns are "user" and date when was the answer added + int columnIndex = 2; + String[] columnNames = new String[questions.size() + 2]; + columnNames[0] = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_USER, null); + columnNames[1] = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_ANSWER_DATE, null); + for (DacoQuestion question : questions) { + questionUidToSpreadsheetColumnIndex.put(question.getUid(), columnIndex); + columnNames[columnIndex] = WebUtil.removeHTMLtags(question.getDescription()); + columnIndex++; + } + + // Some strings used in building cell values + String longitudeHeader = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_LEARNING_LONGLAT_LONGITUDE, + null); + String longitudeUnit = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_LEARNING_LONGLAT_LONGITUDE_UNIT, + null); + String latitudeHeader = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_LEARNING_LONGLAT_LATITUDE, + null); + String latitudeUnit = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_LEARNING_LONGLAT_LATITUDE_UNIT, + null); + + List rows = new LinkedList<>(); + // We get all sessions with all users with all their records from the given Daco content + List monitoringSummary = dacoService.getSummaryForExport(daco.getContentId(), + null); + // Get current user's locale to format numbers properly + Locale monitoringUserLocale = null; + HttpSession ss = SessionManager.getSession(); + if (ss != null) { + UserDTO systemUser = (UserDTO) ss.getAttribute(AttributeNames.USER); + if (systemUser != null) { + monitoringUserLocale = new Locale(systemUser.getLocaleLanguage(), systemUser.getLocaleCountry()); + } + } + + for (MonitoringSummarySessionDTO summarySession : monitoringSummary) { + // Maybe we'll need delimiter between sessions one day - here is the place to add an empty row + for (MonitoringSummaryUserDTO user : summarySession.getUsers()) { + List> records = user.getRecords(); + for (int rowIndex = 0; rowIndex < records.size(); rowIndex++) { + Object[] row = new Object[questions.size() + 2]; + row[0] = user.getFullName(); + + List record = records.get(rowIndex); + for (int answerIndex = 0; answerIndex < record.size(); answerIndex++) { + DacoAnswer answer = record.get(answerIndex); + // we set the date of the whole row to the latest from all the participating answers + if (row[1] == null) { + row[1] = answer.getCreateDate(); + } else { + Date currentDate = (Date) row[1]; + Date newDate = answer.getCreateDate(); + if (currentDate.compareTo(newDate) < 0) { + row[1] = newDate; + } + } + Object cell = null; + String answerString = answer.getAnswer(); + columnIndex = questionUidToSpreadsheetColumnIndex.get(answer.getQuestion().getUid()); + // we extract answers and add them to "data" array in readable form + switch (answer.getQuestion().getType()) { + case DacoConstants.QUESTION_TYPE_NUMBER: + if (!StringUtils.isBlank(answerString)) { + Short fractionDigits = answer.getQuestion().getDigitsDecimal(); + if (fractionDigits == null) { + fractionDigits = Short.MAX_VALUE; + } + cell = NumberUtil.formatLocalisedNumber(Double.parseDouble(answerString), + monitoringUserLocale, fractionDigits); + } + break; + case DacoConstants.QUESTION_TYPE_DATE: + if (!StringUtils.isBlank(answerString)) { + cell = DacoConstants.DEFAULT_DATE_FORMAT.parse(answerString); + } + break; + case DacoConstants.QUESTION_TYPE_CHECKBOX: + if (!StringUtils.isBlank(answerString)) { + DacoQuestion question = answer.getQuestion(); + DacoQuestion currentQuestion = question; + List answerOptions = new LinkedList<>( + question.getAnswerOptions()); + StringBuilder cellStringBuilder = new StringBuilder(); + // instead of number, we create a comma-separated string of chosen options + do { + try { + int chosenAnswer = Integer.parseInt(answerString) - 1; + String chosenAnswerOption = answerOptions.get(chosenAnswer) + .getAnswerOption(); + cellStringBuilder.append(chosenAnswerOption).append(", "); + } catch (Exception e) { + log.error("exportToSpreadsheet encountered '" + e + + "' while parsing checkbox answer; answer was " + answerString); + } + answerIndex++; + // LDEV-3648 If the checkbox is the last entry, then there won't be any more answers so don't trigger an out of bounds exception! + if (answerIndex < record.size()) { + answer = record.get(answerIndex); + currentQuestion = answer.getQuestion(); + answerString = answer.getAnswer(); + } + } while (answerIndex < record.size() && currentQuestion.equals(question)); + // we went one answer too far, so we go back + answerIndex--; + cell = (cellStringBuilder.length() > 1 ? cellStringBuilder + .delete(cellStringBuilder.length() - 2, cellStringBuilder.length()) + .toString() : cellStringBuilder.toString()); + } + break; + case DacoConstants.QUESTION_TYPE_LONGLAT: + // Both longitude and latitude go in the same cell + if (StringUtils.isBlank(answerString)) { + // If longitude was not entered, then latitude also is blank, so skip the next answer + answerIndex++; + } else { + StringBuilder cellStringBuilder = new StringBuilder(longitudeHeader).append(' ') + .append(answerString).append(' ').append(longitudeUnit).append("; "); + answerIndex++; + answer = record.get(answerIndex); + cellStringBuilder.append(latitudeHeader).append(' ').append(answer.getAnswer()) + .append(' ').append(latitudeUnit); + cell = cellStringBuilder.toString(); + } + break; + case DacoConstants.QUESTION_TYPE_FILE: + case DacoConstants.QUESTION_TYPE_IMAGE: + if (!StringUtils.isBlank(answer.getFileName())) { + // Just get the file name, instead of the real file + cell = answer.getFileName(); + } + break; + case DacoConstants.QUESTION_TYPE_RADIO: + case DacoConstants.QUESTION_TYPE_DROPDOWN: + if (!StringUtils.isBlank(answerString)) { + List answerOptions = new LinkedList<>( + answer.getQuestion().getAnswerOptions()); + try { + int chosenAnswer = Integer.parseInt(answerString) - 1; + cell = answerOptions.get(chosenAnswer).getAnswerOption(); + } catch (Exception e) { + log.error("exportToSpreadsheet encountered '" + e + + "' while parsing dropdown or radio answer; answer was " + + answerString); + } + } + break; + default: + cell = answer.getAnswer(); + break; + } + row[columnIndex] = cell; + } + rows.add(row); + } + + } + } + // Convert from Collection to array + Object[][] data = rows.toArray(new Object[][] {}); + + // Prepare response headers + String fileName = DacoConstants.EXPORT_TO_SPREADSHEET_FILE_NAME; + fileName = FileUtil.encodeFilenameForDownload(request, fileName); + response.setContentType(CentralConstants.RESPONSE_CONTENT_TYPE_DOWNLOAD); + response.setHeader(CentralConstants.HEADER_CONTENT_DISPOSITION, + CentralConstants.HEADER_CONTENT_ATTACHMENT + fileName); + MonitoringController.log.debug("Exporting to a spreadsheet tool content with UID: " + daco.getUid()); + ServletOutputStream out = response.getOutputStream(); + + // Export to XLS + String sheetName = dacoService.getLocalisedMessage(DacoConstants.KEY_LABEL_EXPORT_FILE_SHEET, null); + DacoExcelUtil.exportToExcel(out, sheetName, title, dateHeader, columnNames, data); + + // Return the file inside response, but not any JSP page + return null; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + protected ActionForward getQuestionSummaries(ActionMapping mapping, HttpServletRequest request) { + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + DacoUser user; + Long userId = WebUtil.readLongParam(request, DacoConstants.USER_ID, true); + user = userId != null ? dacoService.getUserByUserIdAndSessionId(userId, sessionId) : null; + + if (user != null) { + List summaries = dacoService.getQuestionSummaries(user.getUid()); + sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries); + Integer totalRecordCount = dacoService.getGroupRecordCount(sessionId); + sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount); + Integer userRecordCount = dacoService.getRecordNum(userId, sessionId); + sessionMap.put(DacoConstants.RECORD_COUNT, userRecordCount); + sessionMap.put(DacoConstants.USER_FULL_NAME, user.getFullName()); + } else { + sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, new LinkedList()); + sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, 0); + sessionMap.put(DacoConstants.RECORD_COUNT, 0); + sessionMap.put(DacoConstants.USER_FULL_NAME, ""); + } + + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return mapping.findForward(DacoConstants.SUCCESS); + } + + /** + * Show statistics page. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + @RequestMapping("/statistic") + private String statistic(HttpServletRequest request) { + + String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + Long contentId = sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID) == null + ? WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID) + : (Long) sessionMap.get(AttributeNames.PARAM_TOOL_CONTENT_ID); + Daco daco = dacoService.getDacoByContentId(contentId); + List sessList = dacoService.getSessionStatistics(daco.getUid()); + + request.setAttribute(DacoConstants.ATTR_SESSION_SUMMARIES, sessList); + request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID); + return "statistic"; + } + +} Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java (.../DacoForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java (.../DacoForm.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -23,13 +23,7 @@ package org.lamsfoundation.lams.tool.daco.web.form; -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.tool.daco.model.Daco; /** @@ -40,7 +34,7 @@ * * User: Dapeng.Ni */ -public class DacoForm extends ActionForm { +public class DacoForm { private static final long serialVersionUID = 3599879328307492312L; private static Logger logger = Logger.getLogger(DacoForm.class.getName()); @@ -49,8 +43,9 @@ private String sessionMapID; private String contentFolderID; private int currentTab; - private FormFile offlineFile; - private FormFile onlineFile; + private String offlineFile; + private String onlineFile; + private String mode; private Daco daco; @@ -68,21 +63,21 @@ } } - @Override - public void reset(ActionMapping mapping, HttpServletRequest request) { - String param = mapping.getParameter(); - // if it is start page, all data read out from database or current - // session - // so need not reset checkbox to refresh value! - if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) { +// @Override +// public void reset(HttpServletRequest request) { +// String param = mapping.getParameter(); +// // if it is start page, all data read out from database or current +// // session +// // so need not reset checkbox to refresh value! +// if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) { +// +// daco.setLockOnFinished(false); +// daco.setDefineLater(false); +// +// daco.setReflectOnActivity(false); +// } +// } - daco.setLockOnFinished(false); - daco.setDefineLater(false); - - daco.setReflectOnActivity(false); - } - } - public int getCurrentTab() { return currentTab; } @@ -91,19 +86,19 @@ this.currentTab = currentTab; } - public FormFile getOfflineFile() { + public String getOfflineFile() { return offlineFile; } - public void setOfflineFile(FormFile offlineFile) { + public void setOfflineFile(String offlineFile) { this.offlineFile = offlineFile; } - public FormFile getOnlineFile() { + public String getOnlineFile() { return onlineFile; } - public void setOnlineFile(FormFile onlineFile) { + public void setOnlineFile(String onlineFile) { this.onlineFile = onlineFile; } @@ -126,4 +121,14 @@ public void setContentFolderID(String contentFolderID) { this.contentFolderID = contentFolderID; } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + } \ No newline at end of file Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoQuestionForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoQuestionForm.java (.../DacoQuestionForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoQuestionForm.java (.../DacoQuestionForm.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -23,8 +23,6 @@ package org.lamsfoundation.lams.tool.daco.web.form; -import org.apache.struts.action.ActionForm; - /** * Daco Question Form. * @@ -33,7 +31,7 @@ * * @version $Revision$ */ -public class DacoQuestionForm extends ActionForm { +public class DacoQuestionForm { private String questionIndex; private String sessionMapID; Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/RecordForm.java =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/RecordForm.java (.../RecordForm.java) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/RecordForm.java (.../RecordForm.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -29,9 +29,6 @@ import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.upload.FormFile; import org.springframework.web.multipart.MultipartFile; /** @@ -41,7 +38,7 @@ * * @author Marcin Cieslak */ -public class RecordForm{ +public class RecordForm { private static Logger logger = Logger.getLogger(RecordForm.class.getName()); private String sessionMapID; @@ -52,7 +49,7 @@ public void setAnswer(int number, String answer) { if (this.answer == null) { - this.answer = new ArrayList(); + this.answer = new ArrayList<>(); } while (number >= this.answer.size()) { this.answer.add(null); @@ -70,7 +67,7 @@ public void setFile(int number, MultipartFile file) { if (file.getSize() > 0) { if (this.file == null) { - this.file = new ArrayList(); + this.file = new ArrayList<>(); } while (number >= this.file.size()) { this.file.add(null); @@ -86,7 +83,6 @@ return file.get(number); } - public void reset(HttpServletRequest request) { answer = null; file = null; Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -21,19 +21,17 @@ * **************************************************************** */ - package org.lamsfoundation.lams.tool.daco.web.form; import org.apache.log4j.Logger; -import org.apache.struts.validator.ValidatorForm; /** * * Reflection Form. * * */ -public class ReflectionForm extends ValidatorForm { +public class ReflectionForm { private static final long serialVersionUID = -9054365604649146735L; private static Logger logger = Logger.getLogger(ReflectionForm.class.getName()); Index: lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -32,7 +32,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ attribute name="formID" required="true" rtexprvalue="true" %> @@ -123,11 +122,11 @@ } \ No newline at end of file Index: lams_tool_daco/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/AuthoringRatingAllStyleCriteria.tag (.../AuthoringRatingAllStyleCriteria.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_daco/web/WEB-INF/tags/AuthoringRatingCriteria.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/AuthoringRatingCriteria.tag (.../AuthoringRatingCriteria.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> @@ -284,42 +283,42 @@ - - + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + - - + + - - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + Index: lams_tool_daco/web/WEB-INF/tags/CommentsAuthor.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/CommentsAuthor.tag (.../CommentsAuthor.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,5 +1,4 @@ <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-html" prefix="html"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-lams" prefix="lams"%> @@ -42,23 +41,23 @@
-     -   +     +  
Index: lams_tool_daco/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -4,6 +4,7 @@ <%@ taglib uri="tags-lams" prefix="lams"%> <%@ attribute name="type" required="true" rtexprvalue="true"%> +<%@ attribute name="formID" required="false" rtexprvalue="true"%> <%@ attribute name="style" required="false" rtexprvalue="true"%> <%@ attribute name="title" required="false" rtexprvalue="true"%> <%@ attribute name="titleHelpURL" required="false" rtexprvalue="true"%> @@ -88,8 +89,8 @@ - - + + ${toolForm.toolSessionID} @@ -434,4 +435,4 @@
- + \ No newline at end of file Index: lams_tool_daco/web/WEB-INF/tags/Rating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/Rating.tag (.../Rating.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_daco/web/WEB-INF/tags/StyledRating.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/StyledRating.tag (.../StyledRating.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -8,7 +8,6 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> <%@ taglib uri="tags-lams" prefix="lams"%> <%@ taglib uri="tags-function" prefix="fn" %> Index: lams_tool_daco/web/WEB-INF/tags/TabBody.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/TabBody.tag (.../TabBody.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -34,7 +34,6 @@ <%@ attribute name="titleKey" required="false" rtexprvalue="true"%> <%@ attribute name="page" required="false" rtexprvalue="true"%> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-bean" prefix="bean"%> Index: lams_tool_daco/web/WEB-INF/tags/TabBodyArea.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/TabBodyArea.tag (.../TabBodyArea.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -30,7 +30,6 @@ %> <%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-bean" prefix="bean"%>
Index: lams_tool_daco/web/WEB-INF/tags/TextSearch.tag =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tags/TextSearch.tag (.../TextSearch.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -32,12 +32,11 @@ <%@ tag body-content="scriptless" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="tags-html" prefix="html" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> <%@ taglib uri="tags-lams" prefix="lams" %> <%-- Required attributes --%> <%@ attribute name="sessionMapID" required="true" rtexprvalue="true" %> -<%@ attribute name="wrapInFormTag" required="true" rtexprvalue="true" %> <%-- Optional attributes --%> <%@ attribute name="action" required="false" rtexprvalue="true" %> @@ -53,10 +52,10 @@ <%-- Default value for message key --%> - + - + @@ -85,52 +84,40 @@ - -
- - -

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

+ + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
\ No newline at end of file Index: lams_tool_daco/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -212,192 +212,6 @@ - - STRUTS-textarea - org.lamsfoundation.lams.web.tag.MultiLinesTextareaTag - empty - - accesskey - false - true - - - alt - false - true - - - altKey - false - true - - - bundle - false - true - - - cols - false - true - - - disabled - false - true - - - errorKey - false - true - - - errorStyle - false - true - - - errorStyleClass - false - true - - - errorStyleId - false - true - - - index - false - true - - - indexed - false - true - - - name - false - true - - - onblur - false - true - - - onchange - false - true - - - onclick - false - true - - - ondblclick - false - true - - - onfocus - false - true - - - onkeydown - false - true - - - onkeypress - false - true - - - onkeyup - false - true - - - onmousedown - false - true - - - onmousemove - false - true - - - onmouseout - false - true - - - onmouseover - false - true - - - onmouseup - false - true - - - property - true - true - - - readonly - false - true - - - rows - false - true - - - style - false - true - - - styleClass - false - true - - - styleId - false - true - - - tabindex - false - true - - - title - false - true - - - titleKey - false - true - - - value - false - true - - - Small portrait of a user User Portrait Index: lams_tool_daco/web/common/header.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/common/header.jsp (.../header.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/common/header.jsp (.../header.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -10,7 +10,7 @@ - + Index: lams_tool_daco/web/common/jqueryheader.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/common/jqueryheader.jsp (.../jqueryheader.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/common/jqueryheader.jsp (.../jqueryheader.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -20,5 +20,5 @@ - + \ No newline at end of file Index: lams_tool_daco/web/common/messages.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/common/messages.jsp (.../messages.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/common/messages.jsp (.../messages.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,8 +1,9 @@ <%-- Error Messages --%> - - - -
-
-
-
+ + + + +
+
+
+
\ No newline at end of file Index: lams_tool_daco/web/common/tabbedheader.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -9,7 +9,7 @@ - + Index: lams_tool_daco/web/common/taglibs.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/common/taglibs.jsp (.../taglibs.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/common/taglibs.jsp (.../taglibs.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,9 +1,7 @@ <%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> -<%@ taglib uri="tags-bean" prefix="bean" %> -<%@ taglib uri="tags-html" prefix="html" %> -<%@ taglib uri="tags-logic" prefix="logic" %> <%@ taglib uri="tags-function" prefix="fn" %> <%@ taglib uri="tags-core" prefix="c" %> <%@ taglib uri="tags-fmt" prefix="fmt" %> <%@ taglib uri="tags-xml" prefix="x" %> -<%@ taglib uri="tags-lams" prefix="lams" %> \ No newline at end of file +<%@ taglib uri="tags-lams" prefix="lams" %> +<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %> \ No newline at end of file Index: lams_tool_daco/web/pages/authoring/advanced.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,5 +1,4 @@ <%@ include file="/common/taglibs.jsp"%> - + Index: lams_tool_daco/web/pages/learning/addRecord.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/pages/learning/addRecord.jsp (.../addRecord.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/pages/learning/addRecord.jsp (.../addRecord.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -69,13 +69,13 @@
- + - - + + @@ -95,10 +95,10 @@ depending on the maximum number of characters the teacher provided --%> - + - + @@ -108,7 +108,7 @@
- + <%-- Number --%> @@ -126,7 +126,7 @@ - + <%-- Date can be entered in three textfields --%> @@ -137,19 +137,19 @@
-   +  
-   +  
- +
@@ -182,7 +182,7 @@ <%-- It displays for example A) instead of 1) --%> ${fn:substring(ordinal,status.index,status.index+1)}) -
+
@@ -191,20 +191,20 @@
- - + + - + - + <%-- Checkboxes --%>
- + ${fn:substring(ordinal,status.index,status.index+1)}) @@ -223,7 +223,7 @@
- +

@@ -234,7 +234,7 @@
- +

@@ -252,7 +252,7 @@ - +
@@ -279,9 +279,9 @@
- +
Index: lams_tool_daco/web/pages/learning/learning.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/pages/learning/learning.jsp (.../learning.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/pages/learning/learning.jsp (.../learning.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -56,7 +56,7 @@ var LABEL_NOT_ALLOWED_FORMAT = ''; - + @@ -97,9 +97,9 @@ - + - + Index: lams_tool_daco/web/pages/monitoring/listRecords.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_daco/web/pages/monitoring/listRecords.jsp (.../listRecords.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_daco/web/pages/monitoring/listRecords.jsp (.../listRecords.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -19,7 +19,7 @@ <%@ include file="/common/header.jsp"%> - + - + <fmt:message key="title.monitoring" /> Index: lams_tool_images/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r9e395fca5d7eb4a5ac4c9768642a336723a950f7 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_images/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 9e395fca5d7eb4a5ac4c9768642a336723a950f7) +++ lams_tool_images/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -115,7 +115,6 @@ }); $(".toggle-image-visibility").click(function() { - debugger; var imageToggleLink = $(this); var imageUid = $(this).data("image-uid"); Index: lams_tool_laqa/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_laqa/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.dolessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, @@ -434,4 +435,4 @@ - + \ No newline at end of file Index: lams_tool_larsrc/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_larsrc/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.do?lessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, Index: lams_tool_leader/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_leader/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.do?lessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, Index: lams_tool_leader/web/pages/learning/leaderselection.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_leader/web/pages/learning/leaderselection.jsp (.../leaderselection.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -37,7 +37,6 @@ }); function leaderSelection() { - debugger; $.ajax({ async: false, url: '', Index: lams_tool_notebook/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_notebook/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.do?lessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, Index: lams_tool_pixlr/web/WEB-INF/tags/Page.tag =================================================================== diff -u -r4259cd7dc345ed6ec5c4f6eb81e2326119cc5414 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 4259cd7dc345ed6ec5c4f6eb81e2326119cc5414) +++ lams_tool_pixlr/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.do?lessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, @@ -434,4 +435,4 @@ - + \ No newline at end of file Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java =================================================================== diff -u -rb18aa49cea9cab29bda065b37ee720bfa0a4ef6f -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java (.../LearningController.java) (revision b18aa49cea9cab29bda065b37ee720bfa0a4ef6f) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java (.../LearningController.java) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -74,6 +74,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.context.WebApplicationContext; import com.fasterxml.jackson.databind.node.JsonNodeFactory; @@ -603,7 +604,8 @@ * Autosaves burning questions. Only leaders can perform it. */ @RequestMapping("/autosaveBurningQuestions") - private String autosaveBurningQuestions(HttpServletRequest request) throws ScratchieApplicationException { + @ResponseBody + private void autosaveBurningQuestions(HttpServletRequest request) throws ScratchieApplicationException { String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); @@ -613,12 +615,9 @@ ScratchieUser leader = getCurrentUser(sessionId); ScratchieSession toolSession = scratchieService.getScratchieSessionBySessionId(sessionId); if (!toolSession.isUserGroupLeader(leader.getUid())) { - return null; } saveBurningQuestions(request); - - return null; } /** Index: lams_tool_scratchie/web/WEB-INF/tags/Page.tag =================================================================== diff -u -rb18aa49cea9cab29bda065b37ee720bfa0a4ef6f -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision b18aa49cea9cab29bda065b37ee720bfa0a4ef6f) +++ lams_tool_scratchie/web/WEB-INF/tags/Page.tag (.../Page.tag) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -1,5 +1,5 @@ <%@ tag body-content="scriptless"%> -<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-core" prefix="c"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> <%@ taglib uri="tags-lams" prefix="lams"%> @@ -138,12 +138,12 @@ function restartLesson(){ if (confirm(restartLessonConfirmation)) { - window.location.href = LEARNING_URL + 'learner/restartLesson.do?lessonID=' + lessonId; + window.location.href = LEARNING_URL + 'learner.do?method=restartLesson&lessonID=' + lessonId; } } function viewNotebookEntries(){ - openPopUp(LEARNING_URL + "notebook/viewAll.do?lessonID=" + lessonId, + openPopUp(LEARNING_URL + "notebook.do?method=viewAll&lessonID=" + lessonId, "Notebook", 648,1152, "no"); @@ -245,8 +245,9 @@ if ( lessonId != "" || toolSessionId != "" ) { $.ajax({ - url : LEARNING_URL + 'learner/getLessonDetails.do', + url : LEARNING_URL + 'learner.do', data : { + 'method' : 'getLessonDetails', 'lessonID' : lessonId, 'toolSessionID' : toolSessionId, }, @@ -434,4 +435,4 @@ - + \ No newline at end of file Index: lams_tool_scratchie/web/WEB-INF/tlds/lams/lams.tld =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_scratchie/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_scratchie/web/WEB-INF/tlds/lams/lams.tld (.../lams.tld) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -212,192 +212,6 @@ - - STRUTS-textarea - org.lamsfoundation.lams.web.tag.MultiLinesTextareaTag - empty - - accesskey - false - true - - - alt - false - true - - - altKey - false - true - - - bundle - false - true - - - cols - false - true - - - disabled - false - true - - - errorKey - false - true - - - errorStyle - false - true - - - errorStyleClass - false - true - - - errorStyleId - false - true - - - index - false - true - - - indexed - false - true - - - name - false - true - - - onblur - false - true - - - onchange - false - true - - - onclick - false - true - - - ondblclick - false - true - - - onfocus - false - true - - - onkeydown - false - true - - - onkeypress - false - true - - - onkeyup - false - true - - - onmousedown - false - true - - - onmousemove - false - true - - - onmouseout - false - true - - - onmouseover - false - true - - - onmouseup - false - true - - - property - true - true - - - readonly - false - true - - - rows - false - true - - - style - false - true - - - styleClass - false - true - - - styleId - false - true - - - tabindex - false - true - - - title - false - true - - - titleKey - false - true - - - value - false - true - - - Small portrait of a user User Portrait Index: lams_tool_scratchie/web/pages/learning/learning.jsp =================================================================== diff -u -rb18aa49cea9cab29bda065b37ee720bfa0a4ef6f -r5d60e2334cf6775f4e4afe5755a0e56ef78540c0 --- lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision b18aa49cea9cab29bda065b37ee720bfa0a4ef6f) +++ lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 5d60e2334cf6775f4e4afe5755a0e56ef78540c0) @@ -22,7 +22,7 @@ - +