Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java,v
diff -u -r1.3 -r1.4
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 14 Oct 2005 16:35:32 -0000 1.3
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 21 Oct 2005 13:20:45 -0000 1.4
@@ -197,6 +197,42 @@
request.getSession().setAttribute(TIMEZONE_ID, timeZone.getID());
}
+
+ public static void persistRichText(HttpServletRequest request)
+ {
+ /*
+ String richTextOfflineInstructions=request.getParameter(RICHTEXT_OFFLINEINSTRUCTIONS);
+ logger.debug("read parameter richTextOfflineInstructions: " + richTextOfflineInstructions);
+ String richTextOnlineInstructions=request.getParameter(RICHTEXT_ONLINEINSTRUCTIONS);
+ logger.debug("read parameter richTextOnlineInstructions: " + richTextOnlineInstructions);
+
+ if ((richTextOfflineInstructions != null) && (richTextOfflineInstructions.length() > 0))
+ {
+ request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,richTextOfflineInstructions);
+ }
+
+ if ((richTextOnlineInstructions != null) && (richTextOnlineInstructions.length() > 0))
+ {
+ request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,richTextOnlineInstructions);
+ }
+
+ */
+ String richTextTitle=request.getParameter(RICHTEXT_TITLE);
+ logger.debug("read parameter richTextTitle: " + richTextTitle);
+ String richTextInstructions=request.getParameter(RICHTEXT_INSTRUCTIONS);
+ logger.debug("read parameter richTextInstructions: " + richTextInstructions);
+
+ if ((richTextTitle != null) && (richTextTitle.length() > 0))
+ {
+ request.getSession().setAttribute(RICHTEXT_TITLE,richTextTitle);
+ }
+
+ if ((richTextInstructions != null) && (richTextInstructions.length() > 0))
+ {
+ request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,richTextInstructions);
+ }
+ }
+
public static void configureContentRepository(HttpServletRequest request)
{
logger.debug("attempt configureContentRepository");
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java,v
diff -u -r1.13 -r1.14
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 20 Oct 2005 21:41:20 -0000 1.13
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 21 Oct 2005 13:20:45 -0000 1.14
@@ -46,7 +46,7 @@
private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
- private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
+ private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId and mcQueContent.disabled=true";
private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from mcQueContent in class McQueContent where mcQueContent.question=:question and mcQueContent.mcContentId=:mcContentUid";
@@ -103,6 +103,7 @@
McQueContent mcQueContent=(McQueContent)listIterator.next();
this.getSession().setFlushMode(FlushMode.AUTO);
templ.delete(mcQueContent);
+ templ.flush();
}
}
}
@@ -136,15 +137,14 @@
.list();
if(list != null && list.size() > 0){
+ logger.debug("will iterate the list of McQueContent");
Iterator listIterator=list.iterator();
while (listIterator.hasNext())
{
McQueContent mcQueContent=(McQueContent)listIterator.next();
- if ((mcQueContent != null) && (mcQueContent.isDisabled()));
- {
- this.getSession().setFlushMode(FlushMode.AUTO);
- templ.delete(mcQueContent);
- }
+ this.getSession().setFlushMode(FlushMode.AUTO);
+ logger.debug("deleting mcQueContent: " + mcQueContent);
+ templ.delete(mcQueContent);
}
}
}
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.15 -r1.16
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 20 Oct 2005 21:41:19 -0000 1.15
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 21 Oct 2005 13:20:45 -0000 1.16
@@ -223,13 +223,15 @@
ServletException
{
- logger.debug("loadQ initialised...");
+ logger.debug("loadQ started...");
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
IMcService mcService =McUtils.getToolService(request);
logger.debug("mcService:" + mcService);
+ McUtils.persistRichText(request);
+
String userAction=null;
if (mcAuthoringForm.getAddQuestion() != null)
{
@@ -558,7 +560,35 @@
userAction="submitQuestions";
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
+
+ ActionMessages errors= new ActionMessages();
+ String richTextTitle=(String) request.getSession().getAttribute(RICHTEXT_TITLE);
+ logger.debug("richTextTitle: " + richTextTitle);
+ String richTextInstructions=(String) request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS);
+ logger.debug("richTextInstructions: " + richTextInstructions);
+
+
+ if ((richTextTitle == null) || (richTextTitle.length() == 0) || richTextTitle.equalsIgnoreCase(RICHTEXT_BLANK))
+ {
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.title"));
+ logger.debug("add title to ActionMessages");
+ }
+
+ if ((richTextInstructions == null) || (richTextInstructions.length() == 0) || richTextInstructions.equalsIgnoreCase(RICHTEXT_BLANK))
+ {
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.instructions"));
+ logger.debug("add instructions to ActionMessages: ");
+ }
+
+ if (errors.size() > 0)
+ {
+ logger.debug("either title or instructions or both is missingr. Returning back to from to fix errors:");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+
Map mapQuestionsContent=repopulateMap(request, "questionContent");
logger.debug("FINAL mapQuestionsContent after shrinking: " + mapQuestionsContent);
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
@@ -570,6 +600,11 @@
McContent mcContent=mcService.retrieveMc(toolContentId);
logger.debug("mcContent:" + mcContent);
+ logger.debug("updating mcContent title and instructions:" + mcContent);
+ mcContent.setTitle(richTextTitle);
+ mcContent.setInstructions(richTextInstructions);
+
+
mcService.resetAllQuestions(mcContent.getUid());
logger.debug("all question reset for :" + mcContent.getUid());
@@ -590,10 +625,12 @@
}
}
+ /** attend here later again, for the moment we are not deleting unused question physically from the DB,
+ * we are just marking them as disabled */
mcService.cleanAllQuestions(mcContent.getUid());
logger.debug("all questions cleaned for :" + mcContent.getUid());
- ActionMessages errors= new ActionMessages();
+ errors.clear();
errors.add(Globals.ERROR_KEY,new ActionMessage("submit.successful"));
logger.debug("add submit.successful to ActionMessages");
saveErrors(request,errors);
@@ -714,24 +751,20 @@
if (mcAuthoringForm.getEndLearningMessage() == null)
endLearningMessage=(String)request.getSession().getAttribute(END_LEARNING_MESSAGE);
-
- /**
- * title and instructions are mandatory
- */
- title=mcAuthoringForm.getTitle();
- if (title == null)
- title="dummy Title";
+ String richTextTitle="";
+ richTextTitle = (String)request.getSession().getAttribute(RICHTEXT_TITLE);
+ logger.debug("createContent richTextTitle from session: " + richTextTitle);
+ if (richTextTitle == null) richTextTitle="";
- instructions=mcAuthoringForm.getInstructions();
- if (instructions == null)
- instructions="dummy instructions";
+ String richTextInstructions="";
+ richTextInstructions = (String)request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS);
+ logger.debug("createContent richTextInstructions from session: " + richTextInstructions);
+ if (richTextInstructions == null) richTextInstructions="";
-
- creationDate=(String)request.getSession().getAttribute(CREATION_DATE);
+ creationDate=(String)request.getSession().getAttribute(CREATION_DATE);
if (creationDate == null)
creationDate=new Date(System.currentTimeMillis()).toString();
-
/**obtain user object from the session*/
HttpSession ss = SessionManager.getSession();
@@ -747,8 +780,8 @@
/** create a new qa content and leave the default content intact*/
McContent mc = new McContent();
mc.setMcContentId(toolContentId);
- mc.setTitle(title);
- mc.setInstructions(instructions);
+ mc.setTitle(richTextTitle);
+ mc.setInstructions(richTextInstructions);
mc.setCreationDate(creationDate); /**preserve this from the db*/
mc.setUpdateDate(new Date(System.currentTimeMillis())); /**keep updating this one*/
mc.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/
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.7 -r1.8
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 20 Oct 2005 16:08:51 -0000 1.7
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 21 Oct 2005 13:20:45 -0000 1.8
@@ -294,8 +294,8 @@
return (mapping.findForward(LOAD_QUESTIONS));
}
- request.getSession().setAttribute(TITLE,mcContent.getTitle());
- request.getSession().setAttribute(INSTRUCTIONS,mcContent.getInstructions());
+ request.getSession().setAttribute(RICHTEXT_TITLE,mcContent.getTitle());
+ request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,mcContent.getInstructions());
request.getSession().setAttribute(QUESTIONS_SEQUENCED,new Boolean(mcContent.isQuestionsSequenced()));
request.getSession().setAttribute(USERNAME_VISIBLE,new Boolean(mcContent.isUsernameVisible()));
request.getSession().setAttribute(CREATED_BY, new Long(mcContent.getCreatedBy()));
Index: lams_tool_lamc/web/authoringMaincontent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/Attic/authoringMaincontent.jsp,v
diff -u -r1.14 -r1.15
--- lams_tool_lamc/web/authoringMaincontent.jsp 20 Oct 2005 21:41:19 -0000 1.14
+++ lams_tool_lamc/web/authoringMaincontent.jsp 21 Oct 2005 13:20:44 -0000 1.15
@@ -105,7 +105,7 @@
: |
-
+
|
@@ -114,7 +114,7 @@
: |
-
+
|
Index: lams_tool_lamc/web/editOptionsContent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/Attic/editOptionsContent.jsp,v
diff -u -r1.5 -r1.6
--- lams_tool_lamc/web/editOptionsContent.jsp 20 Oct 2005 21:41:19 -0000 1.5
+++ lams_tool_lamc/web/editOptionsContent.jsp 21 Oct 2005 13:20:45 -0000 1.6
@@ -111,24 +111,25 @@