Index: lams_tool_survey/conf/language/ApplicationResources.properties =================================================================== diff -u -r6a5d35ec57dde95eae93fb628d669af257d36949 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 6a5d35ec57dde95eae93fb628d669af257d36949) +++ lams_tool_survey/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -161,5 +161,7 @@ message.learner.choose.answer.percentage = {0} percent leaners of the class have chosen this answer. message.learner.choose.answer=The learner has chosen this answer error.chart.gen=Error occurs during generating chart, please try again. +error.single.choice.over=Only one option or open text can be chosen. title.chart.report=Report of Individual Question -label.learner=Learner \ No newline at end of file +label.learner=Learner +label.answer=Answer \ No newline at end of file Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/SurveyConstants.java =================================================================== diff -u -r6a5d35ec57dde95eae93fb628d669af257d36949 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/SurveyConstants.java (.../SurveyConstants.java) (revision 6a5d35ec57dde95eae93fb628d669af257d36949) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/SurveyConstants.java (.../SurveyConstants.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -60,6 +60,7 @@ public static final String ERROR_MSG_UPLOAD_FAILED = "error.upload.failed"; public static final String ERROR_MSG_MANDATORY_QUESTION = "error.mandatory.question"; public static final String ERROR_MSG_CHART_ERROR = "error.chart.gen"; + public static final String ERROR_MSG_SINGLE_CHOICE = "error.single.choice.over"; public static final String MSG_OPEN_RESPONSE ="label.open.response"; public static final String MSG_PIECHART_TITLE = "piechart.title"; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java =================================================================== diff -u -racfcd68cefd9d696f1b8ced611f7bedb30750024 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java (.../SurveyAnswerDAO.java) (revision acfcd68cefd9d696f1b8ced611f7bedb30750024) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyAnswerDAO.java (.../SurveyAnswerDAO.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.dao; import java.util.List; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyQuestionDAO.java =================================================================== diff -u -rf0c3f41d54ef4f390ef3f93f28c0679c46b6730c -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyQuestionDAO.java (.../SurveyQuestionDAO.java) (revision f0c3f41d54ef4f390ef3f93f28c0679c46b6730c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/SurveyQuestionDAO.java (.../SurveyQuestionDAO.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -23,8 +23,6 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.survey.dao; -import java.util.List; - import org.lamsfoundation.lams.tool.survey.model.SurveyQuestion; public interface SurveyQuestionDAO extends DAO { Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java =================================================================== diff -u -r6a5d35ec57dde95eae93fb628d669af257d36949 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision 6a5d35ec57dde95eae93fb628d669af257d36949) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyAnswerDAOHibernate.java (.../SurveyAnswerDAOHibernate.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.dao.hibernate; import java.util.List; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyQuestionDAOHibernate.java =================================================================== diff -u -ra2c091a27056e7b41531ca140012603bf027d5b8 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyQuestionDAOHibernate.java (.../SurveyQuestionDAOHibernate.java) (revision a2c091a27056e7b41531ca140012603bf027d5b8) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dao/hibernate/SurveyQuestionDAOHibernate.java (.../SurveyQuestionDAOHibernate.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.dao.hibernate; import org.lamsfoundation.lams.tool.survey.dao.SurveyQuestionDAO; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java (.../AnswerDTO.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/AnswerDTO.java (.../AnswerDTO.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.dto; import java.util.Set; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/ReflectDTO.java =================================================================== diff -u -r0020cbe23ed34775811ceab0779d065243444dcb -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/ReflectDTO.java (.../ReflectDTO.java) (revision 0020cbe23ed34775811ceab0779d065243444dcb) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/dto/ReflectDTO.java (.../ReflectDTO.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.dto; import org.lamsfoundation.lams.tool.survey.model.SurveyUser; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/ISurveyService.java (.../ISurveyService.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -99,7 +99,7 @@ void deleteSurveyAttachment(Long attachmentUid); //****************************************************************************************** - //*************** Questions methods ********************** + //*************** Questions and Answers methods ********************** //****************************************************************************************** SurveyQuestion getQuestion(Long questionUid); /** @@ -205,9 +205,15 @@ * Return a map which sorted by SurveySession and list of questions for this session. */ - SortedMap> getSummary(Long contentId); + SortedMap> getSummary(Long contentId); //****************************************************************************************** + // Export portfolio methods + //****************************************************************************************** + SortedMap>> exportByLeaner(SurveyUser learner); + SortedMap>> exportByContentId(Long toolContentID); + + //****************************************************************************************** // NOTEBOOK Functions //****************************************************************************************** Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/service/SurveyServiceImpl.java (.../SurveyServiceImpl.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -85,6 +85,7 @@ import org.lamsfoundation.lams.tool.survey.model.SurveyUser; import org.lamsfoundation.lams.tool.survey.util.SurveySessionComparator; import org.lamsfoundation.lams.tool.survey.util.SurveyToolContentHandler; +import org.lamsfoundation.lams.tool.survey.util.SurveyUserComparator; import org.lamsfoundation.lams.tool.survey.util.SurveyWebUtils; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; @@ -95,6 +96,8 @@ import org.lamsfoundation.lams.util.wddx.WDDXProcessor; import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; +import sun.reflect.generics.tree.Tree; + /** * * @author Dapeng.Ni @@ -401,33 +404,78 @@ } - public SortedMap> getSummary(Long toolContentId) { + public SortedMap> getSummary(Long toolContentId) { - SortedMap> summary = - new TreeMap>(new SurveySessionComparator()); + SortedMap> summary = + new TreeMap>(new SurveySessionComparator()); Survey survey = surveyDao.getByContentId(toolContentId); //get all question under this survey Set questionList = survey.getQuestions(); List sessionList = surveySessionDao.getByContentId(toolContentId); //iterator all sessions under this survey content, and get all questions and its answers. for (SurveySession session : sessionList) { - List responseList = new ArrayList(); + List responseList = new ArrayList(); for (SurveyQuestion question : questionList) { - SurveyQuestion response = getQuestionResponse(session.getSessionId(), question.getUid()); + AnswerDTO response = getQuestionResponse(session.getSessionId(), question.getUid()); responseList.add(response); } summary.put(session, responseList); } - return summary; } public SurveyQuestion getQuestion(Long questionUid) { return surveyQuestionDao.getByUid(questionUid); } + + + public SortedMap>> exportByContentId(Long toolContentID) { + SortedMap>> summary = + new TreeMap>>(new SurveySessionComparator()); + + //get all tool sessions in this content + List sessions = surveySessionDao.getByContentId(toolContentID); + if(sessions != null){ + for (SurveySession session : sessions) { + //get all users under this session + List users = surveyUserDao.getBySessionID(session.getSessionId()); + + //container for this user's answers + SortedMap> learnerAnswers = + new TreeMap>(new SurveyUserComparator()); + if(users != null){ + //for every user, get answers of all questions. + for (SurveyUser user : users) { + List answers = getQuestionAnswers(user.getSession().getSessionId(), user.getUid()); + learnerAnswers.put(user, answers); + } + } + summary.put(session, learnerAnswers); + } + } + + return summary; + } + + + public SortedMap>> exportByLeaner(SurveyUser learner) { + SortedMap>> summary = + new TreeMap>>(new SurveySessionComparator()); + + + List answers = getQuestionAnswers(learner.getSession().getSessionId(), learner.getUid()); + SortedMap> learnerAnswers = new TreeMap>(new SurveyUserComparator()); + learnerAnswers.put(learner, answers); + + summary.put(learner.getSession(), learnerAnswers); + + return summary; + } + + //***************************************************************************** // private methods //***************************************************************************** @@ -530,7 +578,6 @@ toolContentObj.setOnlineFileList(null); try { exportContentService.registerFileClassForExport(SurveyAttachment.class.getName(),"fileUuid","fileVersionId"); - exportContentService.registerFileClassForExport(SurveyQuestion.class.getName(),"fileUuid","fileVersionId"); exportContentService.exportToolContent( toolContentId, toolContentObj,surveyToolContentHandler, rootPath); } catch (ExportToolContentException e) { throw new ToolException(e); @@ -543,17 +590,15 @@ try { exportContentService.registerFileClassForImport(SurveyAttachment.class.getName() ,"fileUuid","fileVersionId","fileName","fileType",null,null); - exportContentService.registerFileClassForImport(SurveyQuestion.class.getName() - ,"fileUuid","fileVersionId","fileName","fileType",null,"initialItem"); Object toolPOJO = exportContentService.importToolContent(toolContentPath,surveyToolContentHandler); if(!(toolPOJO instanceof Survey)) - throw new ImportToolContentException("Import Share surveys tool content failed. Deserialized object is " + toolPOJO); + throw new ImportToolContentException("Import survey tool content failed. Deserialized object is " + toolPOJO); Survey toolContentObj = (Survey) toolPOJO; // reset it to new toolContentId toolContentObj.setContentId(toolContentId); - SurveyUser user = surveyUserDao.getUserByUserIDAndSessionID(new Long(newUserUid.longValue()), toolContentId); + SurveyUser user = surveyUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), toolContentId); if(user == null){ user = new SurveyUser(); UserDTO sysUser = ((User)userManagementService.findById(User.class,newUserUid)).getUserDTO(); @@ -838,6 +883,4 @@ this.surveyAnswerDao = surveyAnswerDao; } - - } Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/IntegerComparator.java =================================================================== diff -u -ra2c091a27056e7b41531ca140012603bf027d5b8 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/IntegerComparator.java (.../IntegerComparator.java) (revision a2c091a27056e7b41531ca140012603bf027d5b8) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/IntegerComparator.java (.../IntegerComparator.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.util; import java.util.Comparator; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/QuestionsComparator.java =================================================================== diff -u -ra2c091a27056e7b41531ca140012603bf027d5b8 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/QuestionsComparator.java (.../QuestionsComparator.java) (revision a2c091a27056e7b41531ca140012603bf027d5b8) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/QuestionsComparator.java (.../QuestionsComparator.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.util; import java.util.Comparator; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyOptionComparator.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyOptionComparator.java (.../SurveyOptionComparator.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyOptionComparator.java (.../SurveyOptionComparator.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.util; import java.util.Comparator; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveySessionComparator.java =================================================================== diff -u -racfcd68cefd9d696f1b8ced611f7bedb30750024 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveySessionComparator.java (.../SurveySessionComparator.java) (revision acfcd68cefd9d696f1b8ced611f7bedb30750024) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveySessionComparator.java (.../SurveySessionComparator.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.util; import java.util.Comparator; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyUserComparator.java =================================================================== diff -u -r6a5d35ec57dde95eae93fb628d669af257d36949 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyUserComparator.java (.../SurveyUserComparator.java) (revision 6a5d35ec57dde95eae93fb628d669af257d36949) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/util/SurveyUserComparator.java (.../SurveyUserComparator.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,3 +1,25 @@ +/**************************************************************** + * 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 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.survey.util; import java.util.Comparator; Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ClearSessionAction.java =================================================================== diff -u -rf0c3f41d54ef4f390ef3f93f28c0679c46b6730c -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ClearSessionAction.java (.../ClearSessionAction.java) (revision f0c3f41d54ef4f390ef3f93f28c0679c46b6730c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/ClearSessionAction.java (.../ClearSessionAction.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -28,8 +28,6 @@ import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; import org.lamsfoundation.lams.tool.ToolAccessMode; -import org.lamsfoundation.lams.tool.survey.SurveyConstants; -import org.lamsfoundation.lams.web.util.AttributeNames; /** * This class give a chance to clear HttpSession when user save/close authoring page. Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/LearningAction.java (.../LearningAction.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -144,7 +144,7 @@ SurveyUser surveyUser = getCurrentUser(service,sessionId); Survey survey; - List questions = service.getQuestionAnswers(sessionId,surveyUser.getUid()); + List answers = service.getQuestionAnswers(sessionId,surveyUser.getUid()); survey = service.getSurveyBySessionId(sessionId); //check whehter finish lock is on/off @@ -182,9 +182,9 @@ //init survey item list SortedMap surveyItemList = getQuestionList(sessionMap); surveyItemList.clear(); - if(questions != null){ - for(AnswerDTO question : questions){ - surveyItemList.put(question.getSequenceId(),question); + if(answers != null){ + for(AnswerDTO answer : answers){ + surveyItemList.put(answer.getSequenceId(),answer); } } if(survey.isShowOnePage()){ @@ -425,23 +425,22 @@ /** * Get answer by special question. */ - private ActionErrors getAnswer(HttpServletRequest request,AnswerDTO question) { + private ActionErrors getAnswer(HttpServletRequest request,AnswerDTO answerDto) { ActionErrors errors = new ActionErrors(); //get sessionMap String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - SurveyAnswer answer = getAnswerFromPage(request,question, sessionID); - question.setAnswer(answer); - //for mandatory questions, answer can not be null. - if(!question.isOptional() && answer == null){ - errors.add(SurveyConstants.ERROR_MSG_KEY+ question.getUid(),new ActionMessage(SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); + SurveyAnswer answer = getAnswerFromPage(request,answerDto, sessionID); + answerDto.setAnswer(answer); + validateAnswers(request, answerDto, errors, answer); + if(!errors.isEmpty()) addErrors(request, errors); - } - return errors; } + + /** * Get all answer for all questions in this page * @param request @@ -453,22 +452,34 @@ String sessionMapID = request.getParameter(SurveyConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); Long sessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - Collection questionList = getQuestionList(sessionMap).values(); + Collection answerDtoList = getQuestionList(sessionMap).values(); - for(AnswerDTO question :questionList){ - SurveyAnswer answer = getAnswerFromPage(request,question, sessionID); - question.setAnswer(answer); - //for mandatory questions, answer can not be null. - if(!question.isOptional() && answer == null){ - errors.add(SurveyConstants.ERROR_MSG_KEY + question.getUid(),new ActionMessage(SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); - } + for(AnswerDTO answerDto :answerDtoList){ + SurveyAnswer answer = getAnswerFromPage(request,answerDto, sessionID); + answerDto.setAnswer(answer); + validateAnswers(request, answerDto, errors, answer); } if(!errors.isEmpty()) addErrors(request, errors); return errors; } + private void validateAnswers(HttpServletRequest request, AnswerDTO question, ActionErrors errors, SurveyAnswer answer) { + //for mandatory questions, answer can not be null. + if(!question.isOptional() && answer == null){ + errors.add(SurveyConstants.ERROR_MSG_KEY+ question.getUid(),new ActionMessage(SurveyConstants.ERROR_MSG_MANDATORY_QUESTION)); + } + if(question.getType() == SurveyConstants.QUESTION_TYPE_SINGLE_CHOICE + && question.isAppendText()){ + //for single choice, user only can choose one option or open text (if it has) + if(!StringUtils.isBlank(question.getAnswer().getAnswerChoices()) + && !StringUtils.isBlank(question.getAnswer().getAnswerText())){ + errors.add(SurveyConstants.ERROR_MSG_KEY+ question.getUid(),new ActionMessage(SurveyConstants.ERROR_MSG_SINGLE_CHOICE)); + } + } + } + private SurveyAnswer getAnswerFromPage(HttpServletRequest request, AnswerDTO question, Long sessionID) { String[] choiceList = request.getParameterValues(SurveyConstants.PREFIX_QUESTION_CHOICE+question.getUid()); Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java =================================================================== diff -u -rde91e6d736e56d514d840e128bd06c9238b5871b -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision de91e6d736e56d514d840e128bd06c9238b5871b) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -105,11 +105,13 @@ SessionMap sessionMap = new SessionMap(); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); request.setAttribute(SurveyConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); + //save contentFolderID into session + sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID,WebUtil.readStrParam(request,AttributeNames.PARAM_CONTENT_FOLDER_ID)); Long contentId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); ISurveyService service = getSurveyService(); - SortedMap> summary = service.getSummary(contentId); + SortedMap> summary = service.getSummary(contentId); Survey survey = service.getSurveyByContentId(contentId); Map >relectList = service.getReflectList(contentId); Index: lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/servlet/ExportServlet.java =================================================================== diff -u -rf0c3f41d54ef4f390ef3f93f28c0679c46b6730c -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision f0c3f41d54ef4f390ef3f93f28c0679c46b6730c) +++ lams_tool_survey/src/java/org/lamsfoundation/lams/tool/survey/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -25,7 +25,10 @@ package org.lamsfoundation.lams.tool.survey.web.servlet; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import java.util.SortedMap; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; @@ -34,7 +37,10 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.survey.SurveyConstants; +import org.lamsfoundation.lams.tool.survey.dto.AnswerDTO; import org.lamsfoundation.lams.tool.survey.model.Survey; +import org.lamsfoundation.lams.tool.survey.model.SurveySession; import org.lamsfoundation.lams.tool.survey.model.SurveyUser; import org.lamsfoundation.lams.tool.survey.service.ISurveyService; import org.lamsfoundation.lams.tool.survey.service.SurveyApplicationException; @@ -73,7 +79,7 @@ teacher(request, response, directoryName, cookies,sessionMap); } } catch (SurveyApplicationException e) { - logger.error("Cannot perform export for share survey tool."); + logger.error("Cannot perform export for survey tool."); } String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() @@ -112,13 +118,9 @@ } -// List group = service.exportBySessionId(toolSessionID,true); -// -// List groupList = new ArrayList(); -// if(group.size() > 0) -// groupList.add(group); -// sessionMap.put(SurveyConstants.ATTR_TITLE, content.getTitle()); -// sessionMap.put(SurveyConstants.ATTR_SUMMARY_LIST, groupList); + SortedMap>> groupList = service.exportByLeaner(learner); + sessionMap.put(SurveyConstants.ATTR_TITLE, content.getTitle()); + sessionMap.put(SurveyConstants.ATTR_SUMMARY_LIST, groupList); } public void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies, HashMap sessionMap) @@ -139,11 +141,11 @@ logger.error(error); throw new SurveyApplicationException(error); } -// List> groupList = service.exportByContentId(toolContentID); -// -// // put it into HTTPSession -// sessionMap.put(SurveyConstants.ATTR_TITLE, content.getTitle()); -// sessionMap.put(SurveyConstants.ATTR_SUMMARY_LIST, groupList); + SortedMap>> groupList = service.exportByContentId(toolContentID); + + // put it into HTTPSession + sessionMap.put(SurveyConstants.ATTR_TITLE, content.getTitle()); + sessionMap.put(SurveyConstants.ATTR_SUMMARY_LIST, groupList); } } Index: lams_tool_survey/web/pages/export/exportportfolio.jsp =================================================================== diff -u -r0020cbe23ed34775811ceab0779d065243444dcb -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/web/pages/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision 0020cbe23ed34775811ceab0779d065243444dcb) +++ lams_tool_survey/web/pages/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -1,160 +1,115 @@ -<%@ include file="/common/taglibs.jsp"%> - - - - - - + - + +<%@ include file="/common/taglibs.jsp"%> + +<%@ page import="org.lamsfoundation.lams.tool.survey.SurveyConstants"%> + - <fmt:message key="export.title" /> - - - - - + <%@ include file="/common/header.jsp" %> - -
- -

${title}

-
-
- -
- - - - - - <%-- display group name on first row--%> - +
+

+ +

+
+
+
+ + + + <%-- display question header --%> + +

+
+ + <%-- --%> + + + <%-- + + + + --%> + + + + +   + + + +
- - - - - - ${item.sessionName} - - + <%= SurveyConstants.OPTION_SHORT_HEADER %>${optStatus.count} + ${option.description} +
- - - - - - - - + + + + + + +
- - - - - - - - - -  
+ <%-- End first check --%> + + +

+
+ + + + + + + + + + + + <%-- User answer list --%> + + + + - - - - +   + + + + - - - - - - - - - - -
+ <%= SurveyConstants.OPTION_SHORT_HEADER %>${optStatus.count} + + +
${user.loginName} + + + + + + + + + Y -
-
- -
-
+ + - -
- - - - - - - - - - - - - - - - ${item.itemTitle} - - ${item.username} - - - - - - - - - - - - - - - - - - - - - - - - - -
-
+
+ <%-- End first check --%> - - - -
- - - - - - + + + + -
+ Index: lams_tool_survey/web/pages/learning/learning.jsp =================================================================== diff -u -re1a0b4e8328530b90021f52f9d652db77bf44657 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/web/pages/learning/learning.jsp (.../learning.jsp) (revision e1a0b4e8328530b90021f52f9d652db77bf44657) +++ lams_tool_survey/web/pages/learning/learning.jsp (.../learning.jsp) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -18,7 +18,11 @@ $("surveyForm").action = ''; $("surveyForm").submit(); } - + function singleChoice(choiceName){ + var rs = document.getElementsByName(choiceName); + for(idx=0;idx Index: lams_tool_survey/web/pages/learning/question.jsp =================================================================== diff -u -raf90466abe57cb9be572bfc519ac6902cb8166fa -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/web/pages/learning/question.jsp (.../question.jsp) (revision af90466abe57cb9be572bfc519ac6902cb8166fa) +++ lams_tool_survey/web/pages/learning/question.jsp (.../question.jsp) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -45,7 +45,13 @@

-

+ + <%-- for single choice question, use javascript to ensure only one optino or openText can be chosen --%> + + + + +

\ No newline at end of file Index: lams_tool_survey/web/pages/monitoring/listanswers.jsp =================================================================== diff -u -r6a5d35ec57dde95eae93fb628d669af257d36949 -rc856a18bf4731ff3a9ba197b01e278b65549acb0 --- lams_tool_survey/web/pages/monitoring/listanswers.jsp (.../listanswers.jsp) (revision 6a5d35ec57dde95eae93fb628d669af257d36949) +++ lams_tool_survey/web/pages/monitoring/listanswers.jsp (.../listanswers.jsp) (revision c856a18bf4731ff3a9ba197b01e278b65549acb0) @@ -17,19 +17,22 @@
- <%-- display question header --%> +

+
- - + <%-- --%> + + <%-- - + + --%> - + - - - - - - - - - -
@@ -45,63 +48,65 @@  
- - - - - - - - - - +
- <%= SurveyConstants.OPTION_SHORT_HEADER %>${optStatus.count} - - -
<%-- End first check --%> - <%-- User answer list --%> -
${user.loginName} - - - - - - - - - "> - - - - - - "> - - -
- - - <%-- End first check --%> +

+
+ + + + + + + + + + + <%-- User answer list --%> + + + + + + + + + + +
+ <%= SurveyConstants.OPTION_SHORT_HEADER %>${optStatus.count} + + +
${user.loginName} + + + + + + + + + "> + + +   + + + + +   +
+
+ <%-- End first check --%> + -