Index: lams_tool_vote/db/sql/create_lams_tool_vote.sql =================================================================== diff -u -rb9472d342c6b0edd1c3e0df5ff2b7179051bb389 -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/db/sql/create_lams_tool_vote.sql (.../create_lams_tool_vote.sql) (revision b9472d342c6b0edd1c3e0df5ff2b7179051bb389) +++ lams_tool_vote/db/sql/create_lams_tool_vote.sql (.../create_lams_tool_vote.sql) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -95,4 +95,4 @@ INSERT INTO tl_vote11_content(uid, content_id , title , instructions , posting, creation_date , questions_sequenced , username_visible , created_by , monitoring_report_title , report_title , run_offline , define_later, offline_instructions, online_instructions, end_learning_message, content_in_use, retries, show_report) VALUES (1, ${default_content_id} ,'Voting Title','Voting Instructions', 'sample posting', NOW(), 0, 0,1,'Voting Report','Report', 0, 0, 'offline instructions','online instructions','Finished Activity...', 0, 0, 0); -INSERT INTO tl_vote11_que_content (uid,question, display_order, vote_content_id) VALUES (1, 'sample posting', 1, 1); \ No newline at end of file +INSERT INTO tl_vote11_que_content (uid,question, display_order, vote_content_id) VALUES (1, 'sample nomination', 1, 1); \ No newline at end of file Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -77,7 +77,7 @@ public static final String TOOL_CONTENT_UID = "toolContentUID"; public static final String TOOL_SESSION_ID = "toolSessionID"; public static final String USER_ID = "userID"; - public static final String MAX_QUESTION_INDEX = "maxQuestionIndex"; + public static final String MAX_OPTION_INDEX = "maxOptionIndex"; public static final String COPY_TOOL_CONTENT = "copyToolContent"; public static final String REMOVE_TOOL_CONTENT = "removeToolContent"; @@ -100,6 +100,7 @@ public static final String MAP_QUESTIONS_CONTENT ="mapQuestionsContent"; public static final String MAP_QUESTION_CONTENT ="mapQuestionContent"; public static final String MAP_OPTIONS_CONTENT ="mapOptionsContent"; + public static final String MAP_OPTIONS_CONTENT_FCK ="mapOptionsContentFck"; public static final String MAP_DEFAULTOPTIONS_CONTENT ="mapDefaultOptionsContent"; public static final String MAP_DISABLED_QUESTIONS ="mapDisabledQuestions"; public static final String MAP_GENERAL_OPTIONS_CONTENT ="mapGeneralOptionsContent"; Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -190,6 +190,12 @@ logger.debug("parameterType: " + parameterType); long mapCounter=0; + String optionContent0=request.getParameter("optionContent0"); + logger.debug("optionContent0: " + optionContent0); + mapCounter++; + mapTempQuestionsContent.put(new Long(mapCounter).toString(), optionContent0); + + for (long i=1; i <= MAX_QUESTION_COUNT ; i++) { String candidateEntry =request.getParameter(parameterType + i); @@ -309,6 +315,64 @@ } + public static Map shiftMap(Map mapOptionsContent, String optIndex , String movableOptionEntry, String direction) + { + logger.debug("movableOptionEntry: " + movableOptionEntry); + /* map to be returned */ + Map mapTempOptionsContent= new TreeMap(new VoteComparator()); + + String shiftableEntry=null; + + int shiftableIndex=0; + if (direction.equals("down")) + { + logger.debug("moving map down"); + shiftableIndex=new Integer(optIndex).intValue() + 1; + } + else + { + logger.debug("moving map up"); + shiftableIndex=new Integer(optIndex).intValue() - 1; + } + + logger.debug("shiftableIndex: " + shiftableIndex); + shiftableEntry=(String)mapOptionsContent.get(new Integer(shiftableIndex).toString()); + logger.debug("shiftable entry: " + shiftableEntry); + + if (shiftableEntry != null) + { + Iterator itQuestionsMap = mapOptionsContent.entrySet().iterator(); + long mapCounter=0; + while (itQuestionsMap.hasNext()) { + Map.Entry pairs = (Map.Entry)itQuestionsMap.next(); + logger.debug("comparing the pair: " + pairs.getKey() + " = " + pairs.getValue()); + mapCounter++; + logger.debug("mapCounter: " + mapCounter); + + if (!pairs.getKey().equals(optIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString())) + { + logger.debug("normal copy " + optIndex); + mapTempOptionsContent.put(new Long(mapCounter).toString(), pairs.getValue()); + } + else if (pairs.getKey().equals(optIndex)) + { + logger.debug("move type 1 " + optIndex); + mapTempOptionsContent.put(new Long(mapCounter).toString(), shiftableEntry); + } + else if (pairs.getKey().equals(new Integer(shiftableIndex).toString())) + { + mapTempOptionsContent.put(new Long(mapCounter).toString(), movableOptionEntry); + } + } + } + else + { + mapTempOptionsContent=mapOptionsContent; + } + return mapTempOptionsContent; + } + + public static boolean isOptionSelectedInMap(String optionText, Map currentOptionsMap) { logger.debug("optionText: " + optionText); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteAction.java (.../VoteAction.java) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -148,6 +148,15 @@ mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); logger.debug("final mapOptionsContent: " + mapOptionsContent); + + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + String firstEntry=(String)mapOptionsContent.get("1"); + logger.debug("firstEntry: " + firstEntry); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, firstEntry); + return (mapping.findForward(LOAD_QUESTIONS)); } @@ -171,6 +180,14 @@ mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); logger.debug("final mapOptionsContent: " + mapOptionsContent); + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + String firstEntry=(String)mapOptionsContent.get("1"); + logger.debug("firstEntry: " + firstEntry); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, firstEntry); + return (mapping.findForward(LOAD_QUESTIONS)); } @@ -194,6 +211,15 @@ Map mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); logger.debug("mapOptionsContent :" +mapOptionsContent); + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + String firstEntry=(String)mapOptionsContent.get("1"); + logger.debug("firstEntry: " + firstEntry); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, firstEntry); + + if (mapOptionsContent == null) mapOptionsContent= new TreeMap(new VoteComparator()); logger.debug("mapOptionsContent :" +mapOptionsContent); @@ -271,7 +297,124 @@ } + public ActionForward moveOptionDown(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + VoteUtils.cleanUpUserExceptions(request); + logger.debug("dispatching moveOptionDown..."); + request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); + + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + IVoteService voteService =VoteUtils.getToolService(request); + + /* determine whether the request is from Monitoring url Edit Activity*/ + String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); + logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination=VoteUtils.getDestination(sourceVoteStarter); + logger.debug("destination: " + destination); + + VoteUtils.persistRichText(request); + + Map mapOptionsContent=AuthoringUtil.repopulateMap(request, "optionContent"); + logger.debug("mapOptionsContent before move down: " + mapOptionsContent); + logger.debug("mapOptionsContent size move down: " + mapOptionsContent.size()); + + //perform a move down if there are at least 2 questions + if (mapOptionsContent.size() > 1) + { + String optIndex =voteAuthoringForm.getOptIndex(); + logger.debug("optIndex:" + optIndex); + String movableOptionEntry=(String)mapOptionsContent.get(optIndex); + logger.debug("movableOptionEntry:" + movableOptionEntry); + + if (movableOptionEntry != null && (!movableOptionEntry.equals(""))) + { + mapOptionsContent= AuthoringUtil.shiftMap(mapOptionsContent, optIndex,movableOptionEntry, "down"); + logger.debug("mapOptionsContent after move down: " + mapOptionsContent); + request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); + logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + } + } + + voteAuthoringForm.resetUserAction(); + + mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); + logger.debug("mapOptionsContent: " + mapOptionsContent); + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + String firstEntry=(String)mapOptionsContent.get("1"); + logger.debug("firstEntry: " + firstEntry); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, firstEntry); + + return (mapping.findForward(destination)); + } + + + public ActionForward moveOptionUp(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + VoteUtils.cleanUpUserExceptions(request); + logger.debug("dispatching moveOptionUp..."); + request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); + + VoteAuthoringForm voteAuthoringForm = (VoteAuthoringForm) form; + IVoteService voteService =VoteUtils.getToolService(request); + + /* determine whether the request is from Monitoring url Edit Activity*/ + String sourceVoteStarter = (String) request.getAttribute(SOURCE_VOTE_STARTER); + logger.debug("sourceVoteStarter: " + sourceVoteStarter); + String destination=VoteUtils.getDestination(sourceVoteStarter); + logger.debug("destination: " + destination); + + VoteUtils.persistRichText(request); + + Map mapOptionsContent=AuthoringUtil.repopulateMap(request, "optionContent"); + logger.debug("mapOptionsContent before move down: " + mapOptionsContent); + logger.debug("mapOptionsContent size move down: " + mapOptionsContent.size()); + + //perform a move down if there are at least 2 questions + if (mapOptionsContent.size() > 1) + { + String optIndex =voteAuthoringForm.getOptIndex(); + logger.debug("optIndex:" + optIndex); + String movableOptionEntry=(String)mapOptionsContent.get(optIndex); + logger.debug("movableOptionEntry:" + movableOptionEntry); + + if (movableOptionEntry != null && (!movableOptionEntry.equals(""))) + { + mapOptionsContent= AuthoringUtil.shiftMap(mapOptionsContent, optIndex,movableOptionEntry, "up"); + logger.debug("mapOptionsContent after move down: " + mapOptionsContent); + request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); + logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + } + } + + voteAuthoringForm.resetUserAction(); + + mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); + logger.debug("mapOptionsContent: " + mapOptionsContent); + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + String firstEntry=(String)mapOptionsContent.get("1"); + logger.debug("firstEntry: " + firstEntry); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, firstEntry); + + return (mapping.findForward(destination)); + } + + + protected ActionMessages validateSubmit(HttpServletRequest request, ActionMessages errors, VoteAuthoringForm voteAuthoringForm) { request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java =================================================================== diff -u -r2aa47ca68bc396e9360c49746d3ddcf4644d221d -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision 2aa47ca68bc396e9360c49746d3ddcf4644d221d) +++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -552,7 +552,7 @@ */ if (mapIndex.longValue() == 1) { - request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, voteQueContent.getQuestion()); + request.getSession().setAttribute(DEFAULT_OPTION_CONTENT, voteQueContent.getQuestion()); } mapIndex=new Long(mapIndex.longValue()+1); @@ -562,6 +562,11 @@ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); logger.debug("starter initialized the Comparable Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT) ); + int maxIndex=mapOptionsContent.size(); + request.getSession().setAttribute(MAX_OPTION_INDEX, new Integer(maxIndex)); + logger.debug("MAX_OPTION_INDEX: " + request.getSession().getAttribute(MAX_OPTION_INDEX)); + + logger.debug("final title: " + voteAuthoringForm.getTitle()); logger.debug("final ins: " + voteAuthoringForm.getInstructions()); Index: lams_tool_vote/web/authoring/AuthoringMaincontent.jsp =================================================================== diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -ra135b38b088c2fe771f10b3d87705efc5b877412 --- lams_tool_vote/web/authoring/AuthoringMaincontent.jsp (.../AuthoringMaincontent.jsp) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10) +++ lams_tool_vote/web/authoring/AuthoringMaincontent.jsp (.../AuthoringMaincontent.jsp) (revision a135b38b088c2fe771f10b3d87705efc5b877412) @@ -63,9 +63,9 @@