Index: lams_tool_lamc/build.properties
===================================================================
diff -u -rb729587d2ebffa80f02239e91bc80352869d311a -rb261a00d2159e4a3b753a6637fe2891e24819595
--- lams_tool_lamc/build.properties (.../build.properties) (revision b729587d2ebffa80f02239e91bc80352869d311a)
+++ lams_tool_lamc/build.properties (.../build.properties) (revision b261a00d2159e4a3b753a6637fe2891e24819595)
@@ -1,21 +1,28 @@
-# properties for building the Lams mc Tool
+# Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# http://www.gnu.org/licenses/gpl.txt
-#name of this project
+# project-wide properties
signature=lamc11
-#mc files package definition
-package=org.lamsfoundation.lams.tool.mc
-mc.path=org/lamsfoundation/lams/tool/mc
+package=org/lamsfoundation/lams/tool/mc
+package.name=org.lamsfoundation.lams.tool.mc
-#configuration files
-conf.includes.dir=${basedir}/web/includes
-conf.template.dir=${basedir}/web/template
-conf.resources.dir=${conf.web.dir}/resources
-# Build directory
-build.web.includes=${build}/web/includes
-build.web.template=${build}/web/template
-testweb=${basedir}/test/web
-testwebinf=${testweb}/WEB-INF
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties
===================================================================
diff -u -r4336aafba788b801aa78c2dc27f8d07a2f932be7 -rb261a00d2159e4a3b753a6637fe2891e24819595
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 4336aafba788b801aa78c2dc27f8d07a2f932be7)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision b261a00d2159e4a3b753a6637fe2891e24819595)
@@ -43,6 +43,7 @@
option.on =ON
option.off =OFF
feedback =Please address the following issues before submit.
+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.
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
diff -u -r284785a0cc2d61ac8a129a69888b3442141904ab -rb261a00d2159e4a3b753a6637fe2891e24819595
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 284785a0cc2d61ac8a129a69888b3442141904ab)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision b261a00d2159e4a3b753a6637fe2891e24819595)
@@ -229,21 +229,21 @@
IMcService mcService =McUtils.getToolService(request);
logger.debug("mcService:" + mcService);
- Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
- logger.debug("mapQuestionsContent: " + mapQuestionsContent);
-
- mapQuestionsContent=repopulateMap(mapQuestionsContent, request, "questionContent");
- 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);
logger.debug("userAction:" + userAction);
- addQuestion(request, mcAuthoringForm, mapQuestionsContent);
+ Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
+ logger.debug("mapQuestionsContent: " + mapQuestionsContent);
+
+ mapQuestionsContent=repopulateMap(mapQuestionsContent, 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");
mcAuthoringForm.resetUserAction();
@@ -255,32 +255,52 @@
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
+ Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
+ logger.debug("mapQuestionsContent: " + mapQuestionsContent);
+
+ mapQuestionsContent=repopulateMap(mapQuestionsContent, request, "questionContent");
+ 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);
logger.debug("deletableQuestionEntry:" + deletableQuestionEntry);
- if (!(deletableQuestionEntry.equals("")))
+ if (deletableQuestionEntry != null)
{
- mapQuestionsContent.remove(questionIndex);
- logger.debug("removed entry:" + deletableQuestionEntry + " from the Map");
- request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
- logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
-
- Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
- logger.debug("toolContentId:" + toolContentId);
-
- McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(deletableQuestionEntry, toolContentId);
- logger.debug("mcQueContent:" + mcQueContent);
-
- if (mcQueContent != null)
+ if (!(deletableQuestionEntry.equals("")))
{
- mcQueContent=mcService.retrieveMcQueContentByUID(mcQueContent.getUid());
- mcService.removeMcQueContent(mcQueContent);
- logger.debug("removed mcQueContent from DB:" + mcQueContent);
+ mapQuestionsContent.remove(questionIndex);
+ logger.debug("removed entry:" + deletableQuestionEntry + " from the Map");
+ request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
+ logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
+
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId:" + toolContentId);
+
+ McContent mcContent =mcService.retrieveMc(toolContentId);
+ logger.debug("mcContent:" + mcContent);
+ if (mcContent != null)
+ {
+ McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(deletableQuestionEntry, mcContent.getUid());
+ logger.debug("mcQueContent:" + mcQueContent);
+
+ if (mcQueContent != null)
+ {
+ mcQueContent=mcService.retrieveMcQueContentByUID(mcQueContent.getUid());
+ mcService.removeMcQueContent(mcQueContent);
+ logger.debug("removed mcQueContent from DB:" + mcQueContent);
+ }
+ }
}
}
-
+ else
+ {
+ /** just present the Map as it is */
+ request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
+ logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
+ }
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -290,11 +310,29 @@
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
+ Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
+ logger.debug("mapQuestionsContent: " + mapQuestionsContent);
+
+ mapQuestionsContent=repopulateMap(mapQuestionsContent, request, "questionContent");
+ logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent);
+ logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
+
String questionIndex =mcAuthoringForm.getQuestionIndex();
logger.debug("questionIndex:" + questionIndex);
String editableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
logger.debug("editableQuestionEntry:" + editableQuestionEntry);
+ if ((editableQuestionEntry == null) || (editableQuestionEntry.equals("")))
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.emptyQuestion"));
+ logger.debug("add error.emptyQuestion to ActionMessages");
+ saveErrors(request,errors);
+ mcAuthoringForm.resetUserAction();
+ logger.debug("return to LOAD_QUESTIONS to fix error.");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
logger.debug("toolContentId:" + toolContentId);
@@ -304,7 +342,7 @@
if (mcContent == null)
{
logger.debug("convenience add");
- addQuestion(request, mcAuthoringForm, mapQuestionsContent);
+ addQuestion(request, mcAuthoringForm, mapQuestionsContent, false);
logger.debug("after addQuestion");
mcContent=mcService.retrieveMc(toolContentId);
logger.debug("mcContent:" + mcContent);
@@ -314,6 +352,7 @@
McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(editableQuestionEntry, mcContent.getUid());
logger.debug("mcQueContent:" + mcQueContent);
+
request.getSession().setAttribute(SELECTED_QUESTION, mcQueContent.getQuestion());
logger.debug("SELECTED_QUESTION:" + request.getSession().getAttribute(SELECTED_QUESTION));
@@ -374,7 +413,7 @@
Map mapOptionsContent=(Map) request.getSession().getAttribute(MAP_OPTIONS_CONTENT);
logger.debug("mapOptionsContent: " + mapOptionsContent);
- mapOptionsContent=repopulateMap(mapQuestionsContent, request,"optionContent");
+ mapOptionsContent=repopulateMap(mapOptionsContent, request,"optionContent");
logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent);
logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size());
@@ -390,12 +429,24 @@
McQueContent mcQueContent = mcService.retrieveMcQueContentByUID(selectedQuestionContentUid);
logger.debug("mcQueContent:" + mcQueContent);
+ mcService.removeMcOptionsContentByQueId(selectedQuestionContentUid);
+ logger.debug("removed all mcOptionsContents for mcQueContentId :" + selectedQuestionContentUid);
+
if (mcQueContent != null)
{
- McOptsContent mcOptionsContent= new McOptsContent(false, "a sample answer", mcQueContent, new HashSet());
- logger.debug("mcOptionsContent:" + mcOptionsContent);
- mcService.saveMcOptionsContent(mcOptionsContent);
- logger.debug("persisted a sample answer: " + mcOptionsContent);
+ /** iterate the options Map and persist the options into the DB*/
+ Iterator itOptionsMap = mapOptionsContent.entrySet().iterator();
+ while (itOptionsMap.hasNext()) {
+ Map.Entry pairs = (Map.Entry)itOptionsMap.next();
+ logger.debug("adding the pair: " + pairs.getKey() + " = " + pairs.getValue());
+ if ((pairs.getValue() != null) && (!pairs.getValue().equals("")))
+ {
+ McOptsContent mcOptionsContent= new McOptsContent(false,pairs.getValue().toString() , mcQueContent, new HashSet());
+ logger.debug("created mcOptionsContent: " + mcOptionsContent);
+ mcService.saveMcOptionsContent(mcOptionsContent);
+ logger.debug("persisted the answer: " + pairs.getValue().toString());
+ }
+ }
}
@@ -411,6 +462,44 @@
String optionIndex =mcAuthoringForm.getOptionIndex();
logger.debug("optionIndex:" + optionIndex);
+
+ Map mapOptionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
+ logger.debug("mapQuestionsContent: " + mapOptionsContent);
+
+ mapOptionsContent=repopulateMap(mapOptionsContent, request, "optionContent");
+ logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent);
+ logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size());
+
+ String deletableOptionEntry=(String)mapOptionsContent.get(optionIndex);
+ logger.debug("deletableOptionEntry:" + deletableOptionEntry);
+
+
+ if (deletableOptionEntry != null)
+ {
+ if (!(deletableOptionEntry.equals("")))
+ {
+ mapOptionsContent.remove(optionIndex);
+ logger.debug("removed entry:" + deletableOptionEntry + " from the Map");
+ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
+
+ /*
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId:" + toolContentId);
+
+ McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(deletableQuestionEntry, toolContentId);
+ logger.debug("mcQueContent:" + mcQueContent);
+
+ if (mcQueContent != null)
+ {
+ mcQueContent=mcService.retrieveMcQueContentByUID(mcQueContent.getUid());
+ mcService.removeMcQueContent(mcQueContent);
+ logger.debug("removed mcQueContent from DB:" + mcQueContent);
+ }
+ */
+ }
+ }
+
mcAuthoringForm.resetUserAction();
return (mapping.findForward(EDIT_OPTS_CONTENT));
}
@@ -633,36 +722,60 @@
}
- protected void addQuestion(HttpServletRequest request, McAuthoringForm mcAuthoringForm, Map mapQuestionsContent)
+ protected void addQuestion(HttpServletRequest request, McAuthoringForm mcAuthoringForm, Map mapQuestionsContent, boolean increaseMapSize)
{
IMcService mcService =McUtils.getToolService(request);
+ logger.debug("increaseMapSize: " + increaseMapSize);
- 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));
+ if (increaseMapSize)
+ {
+ 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));
+ }
- McContent mcContent=createContent(request, mcAuthoringForm);
- logger.debug("mcContent: " + mcContent);
+ McContent mcContent=null;
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ if ((toolContentId != null) && (toolContentId.longValue() != 0))
+ {
+ logger.debug("passed TOOL_CONTENT_ID : " + toolContentId);
+ mcContent= mcService.retrieveMc(toolContentId);
+ logger.debug("mcContent: " + mcContent);
+ }
+
+ if (mcContent == null)
+ {
+ mcContent=createContent(request, mcAuthoringForm);
+ logger.debug("mcContent: " + mcContent);
+ }
+
/** iterate the questions Map and persist the questions into the DB*/
Iterator itQuestionsMap = mapQuestionsContent.entrySet().iterator();
while (itQuestionsMap.hasNext()) {
Map.Entry pairs = (Map.Entry)itQuestionsMap.next();
logger.debug("adding the pair: " + pairs.getKey() + " = " + pairs.getValue());
if ((pairs.getValue() != null) && (!pairs.getValue().equals("")))
{
- McQueContent mcQueContent= new McQueContent(pairs.getValue().toString(),
- new Integer(pairs.getKey().toString()),
- mcContent,
- new HashSet(),
- new HashSet()
- );
- logger.debug("created mcQueContent: " + mcQueContent);
- mcService.createMcQue(mcQueContent);
+ logger.debug("checking existing question text: " + pairs.getValue().toString() + " and mcContent uid():" + mcContent.getUid());
+ McQueContent mcQueContent=mcService.getQuestionContentByQuestionText(pairs.getValue().toString(), mcContent.getUid());
+ logger.debug("mcQueContent: " + mcQueContent);
+ if (mcQueContent == null)
+ {
+ mcQueContent= new McQueContent(pairs.getValue().toString(),
+ new Integer(pairs.getKey().toString()),
+ mcContent,
+ new HashSet(),
+ new HashSet()
+ );
+ mcService.createMcQue(mcQueContent);
+ logger.debug("persisted mcQueContent: " + mcQueContent);
+ }
}
}
+
}
Index: lams_tool_lamc/web/author_page/css/aqua.css
===================================================================
diff -u -r653f0f0eff40af5e6891c22ef2b8efe9bf2f75af -rb261a00d2159e4a3b753a6637fe2891e24819595
--- lams_tool_lamc/web/author_page/css/aqua.css (.../aqua.css) (revision 653f0f0eff40af5e6891c22ef2b8efe9bf2f75af)
+++ lams_tool_lamc/web/author_page/css/aqua.css (.../aqua.css) (revision b261a00d2159e4a3b753a6637fe2891e24819595)
@@ -65,6 +65,14 @@
width: 20%;
}
+
+.error {
+ font-size: small;
+ color: red;
+ font-style: normal;
+ text-align: left;
+}
+
.formcontrol {
font-size: small;
font-style: normal;
Index: lams_tool_lamc/web/authoringMaincontent.jsp
===================================================================
diff -u -r284785a0cc2d61ac8a129a69888b3442141904ab -rb261a00d2159e4a3b753a6637fe2891e24819595
--- lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 284785a0cc2d61ac8a129a69888b3442141904ab)
+++ lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision b261a00d2159e4a3b753a6637fe2891e24819595)
@@ -84,21 +84,20 @@
-
+
-
-
-
-
Basic Question Definitions
+
+
+
+
+ <%@ include file="errorbox.jsp" %>
+ |
+
+