Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== diff -u -r1c7c157a72edb59e9bbd8b7300d0b31eb52df88d -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 1c7c157a72edb59e9bbd8b7300d0b31eb52df88d) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -97,6 +97,7 @@ public static final String IS_DEFINE_LATER ="isDefineLater"; public static final String DEFAULT_CONTENT_ID_STR ="defaultContentIdStr"; public static final String DEFAULT_QUESTION_CONTENT ="defaultQuestionContent"; + public static final String DEFAULT_OPTION_CONTENT ="defaultOptionContent"; public static final String MAP_QUESTIONS_CONTENT ="mapQuestionsContent"; public static final String MAP_QUESTION_CONTENT ="mapQuestionContent"; public static final String MAP_OPTIONS_CONTENT ="mapOptionsContent"; @@ -188,7 +189,9 @@ public static final String OPTION_OFF ="false"; public static final String ACTIVITY_TITLE = "activityTitle"; public static final String ACTIVITY_INSTRUCTIONS = "activityInstructions"; - + public static final String POSTING = "posting"; + public static final String MONITORING ="monitoring"; + public static final String REMOVABLE_QUESTION_INDEX ="removableQuestionIndex"; /* * user actions Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java =================================================================== diff -u -r1c7c157a72edb59e9bbd8b7300d0b31eb52df88d -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 1c7c157a72edb59e9bbd8b7300d0b31eb52df88d) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -985,6 +985,87 @@ } + + protected void reconstructOptionContentMapForAdd(Map mapOptionsContent, HttpServletRequest request) + { + logger.debug("doing reconstructOptionContentMapForAdd."); + logger.debug("pre-add Map content: " + mapOptionsContent); + logger.debug("pre-add Map size: " + mapOptionsContent.size()); + + repopulateMap(mapOptionsContent, request); + + mapOptionsContent.put(new Long(mapOptionsContent.size()+1).toString(), ""); + request.getSession().setAttribute("mapOptionsContent", mapOptionsContent); + + logger.debug("post-add Map is: " + mapOptionsContent); + logger.debug("post-add count " + mapOptionsContent.size()); + } + + + protected void reconstructOptionContentMapForRemove(Map mapOptionsContent, HttpServletRequest request, VoteAuthoringForm voteAuthoringForm) + { + logger.debug("doing reconstructOptionContentMapForRemove."); + //String questionIndex =voteAuthoringForm.getQuestionIndex(); + String optIndex =voteAuthoringForm.getOptIndex(); + logger.debug("pre-delete map content: " + mapOptionsContent); + logger.debug("optIndex: " + optIndex); + + String defLater=(String)request.getSession().getAttribute(ACTIVE_MODULE); + logger.debug("defLater: " + defLater); + + String removableOptIndex=null; + if (defLater.equals(MONITORING)) + { + removableOptIndex=(String)request.getSession().getAttribute(REMOVABLE_QUESTION_INDEX); + logger.debug("removableOptIndex: " + removableOptIndex); + optIndex=removableOptIndex; + } + logger.debug("final removableOptIndex: " + optIndex); + + + long longOptIndex= new Long(optIndex).longValue(); + logger.debug("pre-delete count: " + mapOptionsContent.size()); + + repopulateMap(mapOptionsContent, request); + logger.debug("post-repopulateMap optIndex: " + optIndex); + + mapOptionsContent.remove(new Long(longOptIndex).toString()); + logger.debug("removed the question content with index: " + longOptIndex); + request.getSession().setAttribute("mapOptionsContent", mapOptionsContent); + + logger.debug("post-delete count " + mapOptionsContent.size()); + logger.debug("post-delete map content: " + mapOptionsContent); + } + + + protected void repopulateMap(Map mapOptionsContent, HttpServletRequest request) + { + logger.debug("optIndex: " + request.getSession().getAttribute("optIndex")); + long optIndex= new Long(request.getSession().getAttribute("optIndex").toString()).longValue(); + logger.debug("optIndex: " + optIndex); + + /* if there is data in the Map remaining from previous session remove those */ + mapOptionsContent.clear(); + logger.debug("Map got initialized: " + mapOptionsContent); + + for (long i=0; i < optIndex ; i++) + { + String candidateOptionEntry =request.getParameter("optionContent" + i); + if (i==0) + { + request.getSession().setAttribute("defaultOptionContent", candidateOptionEntry); + logger.debug("defaultQuestionContent set to: " + candidateOptionEntry); + } + if ((candidateOptionEntry != null) && (candidateOptionEntry.length() > 0)) + { + logger.debug("using key: " + i); + mapOptionsContent.put(new Long(i+1).toString(), candidateOptionEntry); + logger.debug("added new entry."); + } + } + } + + /** * cleans up authoring http session * cleanupAuthoringSession(HttpServletRequest request) Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java =================================================================== diff -u -r402985c35e80fbce6960c7d7598b0262292398eb -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision 402985c35e80fbce6960c7d7598b0262292398eb) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -22,6 +22,7 @@ package org.lamsfoundation.lams.tool.vote.web; import java.io.IOException; +import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -115,8 +116,88 @@ request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); return null; } + + + public ActionForward addNewQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + { + logger.debug("dispathcing addNewQuestion"); + + request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); + AuthoringUtil authoringUtil= new AuthoringUtil(); + Map mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); + + String richTextTitle = request.getParameter("title"); + String richTextInstructions = request.getParameter("instructions"); + String richTextPosting = request.getParameter("posting"); + + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + logger.debug("richTextPosting: " + richTextPosting); + + if (richTextTitle != null) + { + request.getSession().setAttribute(ACTIVITY_TITLE, richTextTitle); + } + + if (richTextInstructions != null) + { + request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, richTextInstructions); + } + if (richTextPosting != null) + { + request.getSession().setAttribute(POSTING, richTextPosting); + } + //request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); + authoringUtil.reconstructOptionContentMapForAdd(mapOptionsContent, request); + + logger.debug("richTextInstructions: " + request.getSession().getAttribute(ACTIVITY_INSTRUCTIONS)); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + { + logger.debug("doing removeQuestion "); + request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); + + String richTextTitle = request.getParameter("title"); + String richTextInstructions = request.getParameter("instructions"); + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + String richTextPosting = request.getParameter("posting"); + + if (richTextTitle != null) + { + request.getSession().setAttribute(ACTIVITY_TITLE, richTextTitle); + } + + if (richTextInstructions != null) + { + request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, richTextInstructions); + } + + if (richTextPosting != null) + { + request.getSession().setAttribute(POSTING, richTextPosting); + } + + + AuthoringUtil authoringUtil= new AuthoringUtil(); + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + Map mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); + logger.debug("mapOptionsContent: " + mapOptionsContent); + + //request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); + authoringUtil.reconstructOptionContentMapForRemove(mapOptionsContent, request, voteAuthoringForm); + + return (mapping.findForward(LOAD_QUESTIONS)); + } + + /** * persists error messages to request scope Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java =================================================================== diff -u -r402985c35e80fbce6960c7d7598b0262292398eb -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java (.../VoteAuthoringForm.java) (revision 402985c35e80fbce6960c7d7598b0262292398eb) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAuthoringForm.java (.../VoteAuthoringForm.java) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -35,6 +35,7 @@ protected String currentTab; protected String questionIndex; + protected String optIndex; protected String optionIndex; protected String selectedIndex; protected String deletableOptionIndex; @@ -161,6 +162,7 @@ this.title=null; this.instructions=null; this.questionIndex=null; + this.optIndex=null; this.optionIndex=null; this.selectedIndex=null; this.deletableOptionIndex=null; @@ -820,4 +822,16 @@ this.submit = submit; } + /** + * @return Returns the optIndex. + */ + public String getOptIndex() { + return optIndex; + } + /** + * @param optIndex The optIndex to set. + */ + public void setOptIndex(String optIndex) { + this.optIndex = optIndex; + } } Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java =================================================================== diff -u -r1c7c157a72edb59e9bbd8b7300d0b31eb52df88d -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision 1c7c157a72edb59e9bbd8b7300d0b31eb52df88d) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -97,6 +97,7 @@ import org.lamsfoundation.lams.tool.vote.VoteComparator; import org.lamsfoundation.lams.tool.vote.VoteUtils; import org.lamsfoundation.lams.tool.vote.pojos.VoteContent; +import org.lamsfoundation.lams.tool.vote.pojos.VoteOptsContent; import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent; import org.lamsfoundation.lams.tool.vote.service.IVoteService; import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy; @@ -572,7 +573,7 @@ /* - * get the existing question content + * get the posting content */ logger.debug("setting existing content data from the db"); mapQuestionContent.clear(); @@ -595,12 +596,42 @@ } } logger.debug("Map initialized with existing contentid to: " + mapQuestionContent); - - logger.debug("callling presentInitialUserInterface for the existing content."); - request.getSession().setAttribute(MAP_QUESTION_CONTENT, mapQuestionContent); logger.debug("starter initialized the Comparable Map: " + request.getSession().getAttribute("mapQuestionContent") ); + + + /* collect options for the default question content into a Map*/ + VoteQueContent voteQueContent=voteService.getToolDefaultQuestionContent(voteContent.getUid().longValue()); + logger.debug("voteQueContent:" + voteQueContent); + /* hold all he options for this question*/ + List list=voteService.findVoteOptionsContentByQueId(voteQueContent.getUid()); + logger.debug("options list:" + list); + + Map mapOptionsContent= new TreeMap(new VoteComparator()); + Iterator listIterator=list.iterator(); + Long mapOptsIndex=new Long(1); + while (listIterator.hasNext()) + { + VoteOptsContent voteOptsContent=(VoteOptsContent)listIterator.next(); + logger.debug("option text:" + voteOptsContent.getVoteQueOptionText()); + mapOptionsContent.put(mapOptsIndex.toString(),voteOptsContent.getVoteQueOptionText()); + + if (mapOptsIndex.longValue() == 1) + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, voteOptsContent.getVoteQueOptionText()); + + mapIndex=new Long(mapOptsIndex.longValue()+1); + } + + logger.debug("DEFAULT_QUESTION_CONTENT: " + request.getSession().getAttribute(DEFAULT_QUESTION_CONTENT)); + logger.debug("DEFAULT_OPTION_CONTENT: " + request.getSession().getAttribute(DEFAULT_OPTION_CONTENT)); + request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); + Map mapDefaultOptionsContent=mapOptionsContent; + request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptionsContent); + logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + logger.debug("starter initialized the Default Options Map: " + request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT)); + + logger.debug("final title: " + voteAuthoringForm.getTitle()); logger.debug("final ins: " + voteAuthoringForm.getInstructions()); Index: lams_tool_vote/web/WEB-INF/struts-config.xml =================================================================== diff -u -r19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4 -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4) +++ lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -119,9 +119,33 @@ scope="request" /> + + + + + + + + @@ -290,7 +314,6 @@ redirect="true" /> - - - - - - - Index: lams_tool_vote/web/WEB-INF/tiles/tiles-defs.xml =================================================================== diff -u -r1c7c157a72edb59e9bbd8b7300d0b31eb52df88d -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 1c7c157a72edb59e9bbd8b7300d0b31eb52df88d) +++ lams_tool_vote/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -35,104 +35,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file Index: lams_tool_vote/web/authoring/AuthoringMaincontent.jsp =================================================================== diff -u -r19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4 -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/web/authoring/AuthoringMaincontent.jsp (.../AuthoringMaincontent.jsp) (revision 19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4) +++ lams_tool_vote/web/authoring/AuthoringMaincontent.jsp (.../AuthoringMaincontent.jsp) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -104,8 +104,16 @@ else selectTab(1); //select the default tab; - initEditor("richTextTitle"); - initEditor("richTextInstructions"); + initEditor("title"); + initEditor("instructions"); + initEditor("posting"); + initEditor("optionContent0"); + + + + + initEditor(""); + } function doSelectTab(tabId) { Index: lams_tool_vote/web/authoring/BasicContent.jsp =================================================================== diff -u -r19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4 -r4355528fd4c5808b9b4d0eba2cbe68238560214e --- lams_tool_vote/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision 19bc5e18dcd7f69fba1b72edbcda28ae3c1de2e4) +++ lams_tool_vote/web/authoring/BasicContent.jsp (.../BasicContent.jsp) (revision 4355528fd4c5808b9b4d0eba2cbe68238560214e) @@ -58,6 +58,15 @@ + + + : + + + + + + @@ -66,35 +75,35 @@ - + - - - - + + + + - : + : - + + onclick="removeQuestion(${optIndex});"> + onclick="removeMonitoringQuestion(${optIndex});"> @@ -103,8 +112,8 @@ - - + + @@ -127,9 +136,10 @@