Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java
===================================================================
diff -u -r4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb -r57412c3df9867b1ccef773efe817994848c58870
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 57412c3df9867b1ccef773efe817994848c58870)
@@ -65,13 +65,14 @@
/** these constants are from org.lamsfoundation.lams.web.util.AttributeNames */
- public static final String USER= "user";
- public static final String TOOL_CONTENT_ID = "toolContentID";
- public static final String TOOL_SESSION_ID = "toolSessionID";
- public static final String MODE = "mode";
- public static final String USER_ID = "userID";
- public static final String ACTIVITY_ID = "activityID";
- public static final String CURRENT_TAB = "currentTab";
+ public static final String USER = "user";
+ public static final String TOOL_CONTENT_ID = "toolContentID";
+ public static final String TOOL_SESSION_ID = "toolSessionID";
+ public static final String MODE = "mode";
+ public static final String USER_ID = "userID";
+ public static final String ACTIVITY_ID = "activityID";
+ public static final String CURRENT_TAB = "currentTab";
+ public static final String MAX_QUESTION_INDEX = "maxQuestionIndex";
/**
@@ -90,6 +91,7 @@
public static final long MAX_OPTION_COUNT =10;
+
/**
* Struts level constants
*/
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
diff -u -r4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb -r57412c3df9867b1ccef773efe817994848c58870
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 57412c3df9867b1ccef773efe817994848c58870)
@@ -248,8 +248,9 @@
mcAuthoringForm.setAddQuestion(null);
mcAuthoringForm.setRemoveQuestion(null);
mcAuthoringForm.setEditOptions(null);
+ mcAuthoringForm.setMoveUp(null);
+ mcAuthoringForm.setMoveDown(null);
-
String addQuestion=request.getParameter("addQuestion");
logger.debug("parameter addQuestion" + addQuestion);
if ((addQuestion != null) && addQuestion.equals("1"))
@@ -275,7 +276,23 @@
mcAuthoringForm.setRemoveQuestion("1");
}
+ String moveDown=request.getParameter("moveDown");
+ logger.debug("parameter moveDown" + moveDown);
+ if ((moveDown != null) && moveDown.equals("1"))
+ {
+ logger.debug("parameter moveDown is selected " + moveDown);
+ mcAuthoringForm.setMoveDown("1");
+ }
+
+ String moveUp=request.getParameter("moveUp");
+ logger.debug("parameter moveUp" + moveUp);
+ if ((moveUp != null) && moveUp.equals("1"))
+ {
+ logger.debug("parameter moveUp is selected " + moveUp);
+ mcAuthoringForm.setMoveUp("1");
+ }
+
String userAction=null;
if (mcAuthoringForm.getAddQuestion() != null)
@@ -299,6 +316,10 @@
saveErrors(request,errors);
mcAuthoringForm.resetUserAction();
persistError(request,"error.question.empty");
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -309,6 +330,10 @@
{
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
mcAuthoringForm.resetUserAction();
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -320,10 +345,14 @@
addQuestion(request, mcAuthoringForm, mapQuestionsContent, true);
logger.debug("after addQuestion");
- request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
logger.debug("resetting EDIT_OPTIONS_MODE to 0");
mcAuthoringForm.resetUserAction();
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
else if (mcAuthoringForm.getRemoveQuestion() != null)
@@ -380,8 +409,70 @@
logger.debug("resetting EDIT_OPTIONS_MODE to 0");
mcAuthoringForm.resetUserAction();
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
+ else if (mcAuthoringForm.getMoveDown() != null)
+ {
+ userAction="moveDown";
+ request.setAttribute(USER_ACTION, userAction);
+ logger.debug("userAction:" + userAction);
+
+ Map mapQuestionsContent=repopulateMap(request, "questionContent");
+ logger.debug("mapQuestionsContent before move down: " + mapQuestionsContent);
+
+ String questionIndex =mcAuthoringForm.getQuestionIndex();
+ logger.debug("questionIndex:" + questionIndex);
+ String movableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
+ logger.debug("movableQuestionEntry:" + movableQuestionEntry);
+
+ mapQuestionsContent= shiftMap(mapQuestionsContent, questionIndex,movableQuestionEntry, "down");
+ logger.debug("mapQuestionsContent after move down: " + mapQuestionsContent);
+
+ request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
+ logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
+
+ mcAuthoringForm.resetUserAction();
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("resetting EDIT_OPTIONS_MODE to 0");
+ request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+ else if (mcAuthoringForm.getMoveUp() != null)
+ {
+ userAction="moveUp";
+ request.setAttribute(USER_ACTION, userAction);
+ logger.debug("userAction:" + userAction);
+
+ Map mapQuestionsContent=repopulateMap(request, "questionContent");
+ logger.debug("mapQuestionsContent before move down: " + mapQuestionsContent);
+
+ String questionIndex =mcAuthoringForm.getQuestionIndex();
+ logger.debug("questionIndex:" + questionIndex);
+ String movableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
+ logger.debug("movableQuestionEntry:" + movableQuestionEntry);
+
+ mapQuestionsContent= shiftMap(mapQuestionsContent, questionIndex,movableQuestionEntry, "up");
+ logger.debug("mapQuestionsContent after move up: " + mapQuestionsContent);
+
+ mcAuthoringForm.resetUserAction();
+ request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
+ logger.debug("resetting EDIT_OPTIONS_MODE to 0");
+ request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
else if (mcAuthoringForm.getEditOptions() != null)
{
userAction="editOption";
@@ -791,14 +882,21 @@
request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
logger.debug("setting EDIT_OPTIONS_MODE to 0");
- ActionMessages errors= new ActionMessages();
+ Map mapQuestionsContent=repopulateMap(request, "questionContent");
+ logger.debug("mapQuestionsContent before move down: " + mapQuestionsContent);
+
+ ActionMessages errors= new ActionMessages();
boolean weightsValid=validateQuestionWeights(request,mcAuthoringForm);
logger.debug("weightsValid:" + weightsValid);
if (weightsValid == false)
{
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
mcAuthoringForm.resetUserAction();
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -815,6 +913,10 @@
request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
logger.debug("setting EDIT_OPTIONS_MODE to 0");
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -870,6 +972,10 @@
request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
logger.debug("setting EDIT_OPTIONS_MODE to 0");
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
}
@@ -892,6 +998,10 @@
request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0));
logger.debug("setting EDIT_OPTIONS_MODE to 0");
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -941,6 +1051,10 @@
logger.debug("setting EDIT_OPTIONS_MODE to 0");
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
mcAuthoringForm.resetUserAction();
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -959,7 +1073,7 @@
logger.debug("richTextEndLearningMessage: " + richTextEndLearningMessage);
- Map mapQuestionsContent=repopulateMap(request, "questionContent");
+ mapQuestionsContent=repopulateMap(request, "questionContent");
logger.debug("FINAL mapQuestionsContent after shrinking: " + mapQuestionsContent);
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
@@ -1059,6 +1173,10 @@
mcAuthoringForm.resetUserAction();
request.getSession().setAttribute(CURRENT_TAB, new Long(1));
+
+ int maxQuestionIndex=mapQuestionsContent.size();
+ request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex));
+ logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX));
return (mapping.findForward(LOAD_QUESTIONS));
}
else if (mcAuthoringForm.getAdvancedTabDone() != null)
@@ -1522,6 +1640,69 @@
}
+ protected Map shiftMap(Map mapQuestionsContent, String questionIndex , String movableQuestionEntry, String direction)
+ {
+ logger.debug("movableQuestionEntry: " + movableQuestionEntry);
+
+ /** map to be returned */
+ Map mapTempQuestionsContent= new TreeMap(new McComparator());
+
+ Iterator itMap = mapQuestionsContent.entrySet().iterator();
+ String shiftableEntry=null;
+
+ int shiftableIndex=0;
+ if (direction.equals("down"))
+ {
+ shiftableIndex=new Integer(questionIndex).intValue() + 1;
+
+ logger.debug("shiftableIndex: " + shiftableIndex);
+ shiftableEntry=(String)mapQuestionsContent.get(new Integer(shiftableIndex).toString());
+ logger.debug("shiftable entry: " + shiftableEntry);
+
+ if (shiftableEntry != null)
+ {
+ Iterator itQuestionsMap = mapQuestionsContent.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(questionIndex) && !pairs.getKey().equals(new Integer(shiftableIndex).toString()))
+ {
+ logger.debug("normal copy " + questionIndex);
+ mapTempQuestionsContent.put(new Long(mapCounter).toString(), pairs.getValue());
+ }
+ else if (pairs.getKey().equals(questionIndex))
+ {
+ logger.debug("move type 1 " + questionIndex);
+ mapTempQuestionsContent.put(new Long(mapCounter).toString(), shiftableEntry);
+ }
+ else if (pairs.getKey().equals(new Integer(shiftableIndex).toString()))
+ {
+ logger.debug("move type 2 " + shiftableIndex);
+ mapTempQuestionsContent.put(new Long(mapCounter).toString(), movableQuestionEntry);
+ }
+ }
+ }
+ else
+ {
+ logger.debug("no change to map");
+ mapTempQuestionsContent=mapQuestionsContent;
+ }
+ return mapTempQuestionsContent;
+ }
+ else
+ {
+ shiftableIndex=new Integer(questionIndex).intValue() - 1;
+ }
+
+ return null;
+
+ }
+
+
/**
* shrinks the size of the Map to only used entries
*
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java
===================================================================
diff -u -r62fed58c7feaf586a7f6ae9b6f2aa91fad04e1d3 -r57412c3df9867b1ccef773efe817994848c58870
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 62fed58c7feaf586a7f6ae9b6f2aa91fad04e1d3)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 57412c3df9867b1ccef773efe817994848c58870)
@@ -32,6 +32,8 @@
protected String addOption;
protected String removeOption;
protected String doneOptions;
+ protected String moveDown;
+ protected String moveUp;
protected String questionIndex;
protected String optionIndex;
@@ -111,6 +113,8 @@
this.submitQuestions=null;
this.advancedTabDone=null;
this.instructionsTabDone=null;
+ this.moveDown=null;
+ this.moveUp=null;
this.addContent=null;
this.removeContent=null;
@@ -141,6 +145,8 @@
this.submitQuestions=null;
this.advancedTabDone=null;
this.instructionsTabDone=null;
+ this.moveDown=null;
+ this.moveUp=null;
this.addContent=null;
this.removeContent=null;
@@ -828,4 +834,28 @@
public void setSln(String sln) {
this.sln = sln;
}
+ /**
+ * @return Returns the moveDown.
+ */
+ public String getMoveDown() {
+ return moveDown;
+ }
+ /**
+ * @param moveDown The moveDown to set.
+ */
+ public void setMoveDown(String moveDown) {
+ this.moveDown = moveDown;
+ }
+ /**
+ * @return Returns the moveUp.
+ */
+ public String getMoveUp() {
+ return moveUp;
+ }
+ /**
+ * @param moveUp The moveUp to set.
+ */
+ public void setMoveUp(String moveUp) {
+ this.moveUp = moveUp;
+ }
}
Index: lams_tool_lamc/web/BasicContent.jsp
===================================================================
diff -u -r4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb -r57412c3df9867b1ccef773efe817994848c58870
--- lams_tool_lamc/web/BasicContent.jsp (.../BasicContent.jsp) (revision 4cae7b4193c4421a86dac3eb9f4bddc9e0cbf2bb)
+++ lams_tool_lamc/web/BasicContent.jsp (.../BasicContent.jsp) (revision 57412c3df9867b1ccef773efe817994848c58870)
@@ -5,7 +5,10 @@
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="fck-editor" prefix="FCK" %>
-