Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/Attic/McResources.properties,v
diff -u -r1.14 -r1.15
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 26 Oct 2005 15:50:35 -0000 1.14
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 27 Oct 2005 12:27:46 -0000 1.15
@@ -5,6 +5,10 @@
label.authoring.mc.basic.editOptions =Please define the question and/or its options.
label.authoring.title =Title
label.authoring.instructions =Instructions
+label.Questions =Questions
+label.weight =Weight
+label.action =Action
+label.actions =Actions
button.basic =Basic
button.uploadFile =Upload Package
@@ -13,17 +17,18 @@
button.instructions =Instructions
button.done =Done
tool.icon.name =MC
-button.add =+
-button.addNewQuestion =+
-button.remove =-
-button.removeQuestion =-
+button.add =Add
+button.addNewQuestion =Add
+button.remove =Delete
+button.removeQuestion =Delete
button.removeAllContent =Remove Content
button.submitAllContent =Submit
button.submit =Submit
button.done =Done
button.getNextQuestion =Next
button.getPreviousQuestion =Previous
button.editQuestion =Edit
+label.percent =%
label.option =Option
label.option1 =Option 1
label.options =Options
@@ -56,20 +61,23 @@
option.correct =Correct
option.incorrect =Incorrect
+
feedback =Please address the following issues before submit.
+error.weights.empty =Please correct this: The question weights can not be empty.
+error.weights.notInteger =Please correct this: The question weights must be an integer.
error.emptyQuestion =Please enter the question text. The chosen question can not be empty.
-error.title =The field "Title" is mandatory.
-error.instructions =The field "Instructions" is mandatory.
-error.reportTitle =The field "Report Title (Advanced)" is mandatory.
-error.defaultquestion.empty =The first question can not be empty.
+error.title =Please correct this: The field "Title" is mandatory.
+error.instructions =Please correct this: The field "Instructions" is mandatory.
+error.reportTitle =Please correct this: The field "Report Title (Advanced)" is mandatory.
+error.defaultquestion.empty =Please correct this: The first question can not be empty.
+error.passMark.empty =Please correct this: Pass Mark can not be empty.
+error.passmark.notInteger =Please correct this: Pass Mark can only be an integer.
+error.weights.total.invalid =Please correct this: The total weight must equal 100.
submit.successful =The content has been created successfully.
error.question.addNotAllowed.thisScreen = The question text can not be modified in this screen since it has options attached . Please use the "Options" button to edit the question text.
error.question.removeNotAllowed.thisScreen = The question can not be removed since one or more of the question texts has been modified. Please try again without any text modifications.
-error.passMark.empty =Pass Mark can not be empty.
-error.passmark.notInteger =Pass Mark can only be an integer.
-
error.selectedIndex.empty =Can not continue. Please select the correct answer and click "Done".
error.content.locked =The content has been locked since it is being used by one mor more learners.
The modification of the content is not allowed.
error.content.inUse =The modification of the content is not allowed since one or more students has attempted the activity.
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java,v
diff -u -r1.22 -r1.23
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 27 Oct 2005 07:39:47 -0000 1.22
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 27 Oct 2005 12:27:46 -0000 1.23
@@ -249,13 +249,25 @@
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
+ logger.debug("will validate weights");
+ boolean weightsValid=validateQuestionWeights(request,mcAuthoringForm);
+ logger.debug("weightsValid:" + weightsValid);
+ if (weightsValid == false)
+ {
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
Map mapQuestionsContent=repopulateMap(request, "questionContent");
logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent);
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
-
- addQuestion(request, mcAuthoringForm, mapQuestionsContent, true);
- logger.debug("after addQuestion");
-
+
+ Map mapWeights= repopulateMap(request, "questionWeight");
+ request.getSession().setAttribute(MAP_WEIGHTS, mapWeights);
+ System.out.print("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS));
+
+ addQuestion(request, mcAuthoringForm, mapQuestionsContent, true);
+ logger.debug("after addQuestion");
+
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -269,7 +281,6 @@
logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent);
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
-
String questionIndex =mcAuthoringForm.getQuestionIndex();
logger.debug("questionIndex:" + questionIndex);
String deletableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
@@ -325,6 +336,10 @@
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
+ Map mapWeights= repopulateMap(request, "questionWeight");
+ request.getSession().setAttribute(MAP_WEIGHTS, mapWeights);
+ System.out.print("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS));
+
removeRedundantQuestionEntries(request, mapQuestionsContent);
logger.debug("finished removeRedundantQuestionEntries");
@@ -636,6 +651,26 @@
ActionMessages errors= new ActionMessages();
+ boolean weightsValid=validateQuestionWeights(request,mcAuthoringForm);
+ logger.debug("weightsValid:" + weightsValid);
+ if (weightsValid == false)
+ {
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ boolean isTotalWeightsValid=validateTotalWeight(request);
+ logger.debug("isTotalWeightsValid:" + isTotalWeightsValid);
+ if (isTotalWeightsValid == false)
+ {
+ errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.total.invalid"));
+ saveErrors(request,errors);
+ mcAuthoringForm.resetUserAction();
+ persistError(request,"error.weights.total.invalid");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
boolean isQuestionsSequenced=false;
boolean isSynchInMonitor=false;
boolean isUsernameVisible=false;
@@ -675,7 +710,6 @@
{
errors= new ActionMessages();
errors.add(Globals.ERROR_KEY,new ActionMessage("error.passmark.notInteger"));
- logger.debug("add error.passmark.notInteger to ActionMessages");
saveErrors(request,errors);
mcAuthoringForm.resetUserAction();
persistError(request,"error.passmark.notInteger");
@@ -880,6 +914,26 @@
}
+ protected Map repopulateCurrentWeightsMap(HttpServletRequest request, String parameterType)
+ {
+ Map mapTempQuestionsContent= new TreeMap(new McComparator());
+ logger.debug("parameterType: " + parameterType);
+
+ long mapCounter=0;
+ for (long i=1; i <= MAX_QUESTION_COUNT ; i++)
+ {
+ String candidateQuestionEntry =request.getParameter(parameterType + i);
+ if (candidateQuestionEntry != null)
+ {
+ mapCounter++;
+ mapTempQuestionsContent.put(new Long(mapCounter).toString(), candidateQuestionEntry);
+ }
+ }
+ logger.debug("return repopulated Map: " + mapTempQuestionsContent);
+ return mapTempQuestionsContent;
+ }
+
+
protected McContent createContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm)
{
IMcService mcService =McUtils.getToolService(request);
@@ -1039,7 +1093,15 @@
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));
+ logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
+
+ Map mapWeights = (Map) request.getSession().getAttribute(MAP_WEIGHTS);
+ logger.debug("current mapWeights: " + mapWeights);
+ int mapWeightsSize=mapWeights.size();
+ mapWeights.put(new Long(++mapWeightsSize).toString(), "");
+ logger.debug("updated mapWeights size: " + mapWeights.size());
+ request.getSession().setAttribute(MAP_WEIGHTS, mapWeights);
+ logger.debug("updated mapWeights: " + request.getSession().getAttribute(MAP_WEIGHTS));
}
@@ -1173,7 +1235,78 @@
}
+ protected boolean validateQuestionWeights(HttpServletRequest request, McAuthoringForm mcAuthoringForm)
+ {
+ Map mapWeights= repopulateCurrentWeightsMap(request, "questionWeight");
+ logger.debug("mapWeights: " + mapWeights);
+
+ Iterator itMap = mapWeights.entrySet().iterator();
+ while (itMap.hasNext()) {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue());
+
+ if ((pairs.getValue() == null) || (pairs.getValue().toString().length() == 0))
+ {
+ ActionMessages errors= new ActionMessages();
+ errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.empty"));
+ saveErrors(request,errors);
+ mcAuthoringForm.resetUserAction();
+ persistError(request,"error.weights.empty");
+ return false;
+
+ }
+
+ try
+ {
+ int weight= new Integer(pairs.getValue().toString()).intValue();
+ logger.debug("tried weight: " + weight);
+ }
+ catch(Exception e)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.notInteger"));
+ saveErrors(request,errors);
+ mcAuthoringForm.resetUserAction();
+ persistError(request,"error.weights.notInteger");
+ return false;
+ }
+ }
+ mcAuthoringForm.resetUserAction();
+ return true;
+ }
+
+ protected boolean validateTotalWeight(HttpServletRequest request)
+ {
+ Map mapWeights= repopulateCurrentWeightsMap(request, "questionWeight");
+ logger.debug("mapWeights: " + mapWeights);
+
+ Iterator itMap = mapWeights.entrySet().iterator();
+ int totalWeight=0;
+ while (itMap.hasNext()) {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue());
+
+ if ((pairs.getValue() != null) || (pairs.getValue().toString().length() > 0))
+ {
+ totalWeight=totalWeight+ new Integer(pairs.getValue().toString()).intValue();
+ }
+ }
+
+ logger.debug("totalWeight: " + totalWeight);
+
+ if (totalWeight != 100)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+
/**
* persists error messages to request scope
* @param request
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java,v
diff -u -r1.13 -r1.14
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 27 Oct 2005 07:39:47 -0000 1.13
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 27 Oct 2005 12:27:46 -0000 1.14
@@ -98,7 +98,7 @@
public class McStarterAction extends Action implements McAppConstants {
- static Logger logger = Logger.getLogger(McAppConstants.class.getName());
+ static Logger logger = Logger.getLogger(McStarterAction.class.getName());
/**
* A Map data structure is used to present the UI.
@@ -507,7 +507,6 @@
System.out.print("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS));
}
-
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
Index: lams_tool_lamc/web/authoringMaincontent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/Attic/authoringMaincontent.jsp,v
diff -u -r1.21 -r1.22
--- lams_tool_lamc/web/authoringMaincontent.jsp 27 Oct 2005 07:39:47 -0000 1.21
+++ lams_tool_lamc/web/authoringMaincontent.jsp 27 Oct 2005 12:27:46 -0000 1.22
@@ -119,14 +119,33 @@
+ | +
+ |
+
+ |
+
+ |
+ + |
+ |
+
+
+
|
-
- +     + |
" value=" |
+
+
+ |
-
+ |
|
-
-
+    
+ |
|
+   
+ |
+ |
@@ -189,30 +232,32 @@
  |   |
|