Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -re6d1e7b2b7a185ef297334af35e9aec398a29930 -r7ae4a0ef94c0ee40dbe85263bd7ea102559b0918 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision e6d1e7b2b7a185ef297334af35e9aec398a29930) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 7ae4a0ef94c0ee40dbe85263bd7ea102559b0918) @@ -69,6 +69,7 @@ * refers to number of questions presented initially, we have a single record for default content */ public static final Long INITIAL_QUESTION_COUNT =new Long(1); + public static final long MAX_QUESTION_COUNT =50; /** * Struts level constants Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u -re6d1e7b2b7a185ef297334af35e9aec398a29930 -r7ae4a0ef94c0ee40dbe85263bd7ea102559b0918 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision e6d1e7b2b7a185ef297334af35e9aec398a29930) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 7ae4a0ef94c0ee40dbe85263bd7ea102559b0918) @@ -21,6 +21,8 @@ package org.lamsfoundation.lams.tool.mc.web; import java.io.IOException; +import java.util.Map; +import java.util.TreeMap; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -35,6 +37,7 @@ import org.apache.struts.action.ActionMessages; import org.apache.struts.actions.DispatchAction; import org.lamsfoundation.lams.tool.mc.McAppConstants; +import org.lamsfoundation.lams.tool.mc.McComparator; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.service.IMcService; @@ -211,13 +214,25 @@ logger.debug("loadQ initialised..."); McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - logger.debug("mcAuthoringForm.getEditDefaultQuestion():" + mcAuthoringForm.getEditDefaultQuestion()); - String userAction=null; + Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT); + logger.debug("mapQuestionsContent: " + mapQuestionsContent); + mapQuestionsContent=repopulateMap(mapQuestionsContent, request); + logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); + logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); + + + String userAction=null; if (mcAuthoringForm.getAddQuestion() != null) { userAction="addQuestion"; request.setAttribute(USER_ACTION, userAction); + + int mapSize=mapQuestionsContent.size(); + mapQuestionsContent.put(new Long(++mapSize).toString(), ""); + logger.debug("updated Questions Map size: " + mapQuestionsContent.size()); + request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); + logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); return (mapping.findForward(LOAD_QUESTIONS)); } else if (mcAuthoringForm.getEditDefaultQuestion() != null) @@ -268,7 +283,41 @@ } + /** + * shrinks the size of the Map to only used entries + * + * @param mapQuestionContent + * @param request + * @return + */ + protected Map repopulateMap(Map mapQuestionContent, HttpServletRequest request) + { + Map mapTempQuestionsContent= new TreeMap(new McComparator()); + + long mapCounter=0; + for (long i=1; i <= MAX_QUESTION_COUNT ; i++) + { + String candidateQuestionEntry =request.getParameter("questionContent" + i); + logger.debug("candidateQuestionEntry:" + candidateQuestionEntry); + if ( + (candidateQuestionEntry != null) && + (candidateQuestionEntry.length() > 0) && + !(candidateQuestionEntry.equals("")) + ) + { + mapCounter++; + logger.debug("mapCounter:" + mapCounter); + mapTempQuestionsContent.put(new Long(mapCounter).toString(), candidateQuestionEntry); + logger.debug("added new entry: " + candidateQuestionEntry); + } + } + logger.debug("return repopulated Map: " + mapTempQuestionsContent); + return mapTempQuestionsContent; + } + + + /** * persists error messages to request scope Index: lams_tool_lamc/web/authoringMaincontent.jsp =================================================================== diff -u -re6d1e7b2b7a185ef297334af35e9aec398a29930 -r7ae4a0ef94c0ee40dbe85263bd7ea102559b0918 --- lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision e6d1e7b2b7a185ef297334af35e9aec398a29930) +++ lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 7ae4a0ef94c0ee40dbe85263bd7ea102559b0918) @@ -130,7 +130,10 @@ size="50" maxlength="255"> - ADD + + + EDIT @@ -146,16 +149,16 @@ " value="" size="50" maxlength="255"> - - EDIT - - + + EDIT + +