Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java,v
diff -u -r1.11 -r1.12
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 20 Oct 2005 20:24:20 -0000 1.11
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 22 Oct 2005 19:08:23 -0000 1.12
@@ -70,7 +70,9 @@
*/
public static final Long INITIAL_QUESTION_COUNT =new Long(1);
public static final long MAX_QUESTION_COUNT =20;
+ public static final long MAX_OPTION_COUNT =10;
+
/**
* Struts level constants
*/
@@ -144,6 +146,9 @@
public static final String IS_USERNAME_VISIBLE_MONITORING ="isUsernameVisibleMonitoring";
public static final String IS_SYNCH_INMONITOR_MONITORING ="isSynchInMonitorMonitoring";
public static final String IS_QUESTIONS_SEQUENCED_MONITORING ="isQuestionsSequencedMonitoring";
+
+
+
public static final String RICHTEXT_OFFLINEINSTRUCTIONS ="richTextOfflineInstructions";
public static final String RICHTEXT_ONLINEINSTRUCTIONS ="richTextOnlineInstructions";
public static final String RICHTEXT_TITLE ="richTextTitle";
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.11 -r1.12
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 22 Oct 2005 14:45:38 -0000 1.11
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 22 Oct 2005 19:08:23 -0000 1.12
@@ -24,8 +24,10 @@
button.getNextQuestion =Next
button.getPreviousQuestion =Previous
button.editQuestion =Edit
+label.option =Option
label.option1 =Option 1
label.options =Options
+label.option.correct =Correct
label.report.title =Report Title
label.monitoringReport.title =Monitoring Report Title
@@ -61,6 +63,7 @@
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.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.
error.content.beingModified =The content creation is not allowed since the same content is being modified.
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java,v
diff -u -r1.9 -r1.10
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java 20 Oct 2005 21:41:20 -0000 1.9
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java 22 Oct 2005 19:08:23 -0000 1.10
@@ -22,6 +22,8 @@
package org.lamsfoundation.lams.tool.mc.dao;
+import java.util.List;
+
import org.lamsfoundation.lams.tool.mc.McQueContent;
@@ -38,6 +40,8 @@
public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid);
+ public List refreshQuestionContent(final Long mcContentId);
+
public void cleanAllQuestions(final Long mcContentUid);
public void resetAllQuestions(final Long mcContentUid);
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.14 -r1.15
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 21 Oct 2005 13:20:45 -0000 1.14
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 22 Oct 2005 19:08:23 -0000 1.15
@@ -48,6 +48,9 @@
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 REFRESH_QUESTION_CONTENT = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId and mcQueContent.disabled=false";
+
+
private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from mcQueContent in class McQueContent where mcQueContent.question=:question and mcQueContent.mcContentId=:mcContentUid";
@@ -73,7 +76,17 @@
return null;
}
+ public List refreshQuestionContent(final Long mcContentId)
+ {
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(REFRESH_QUESTION_CONTENT)
+ .setLong("mcContentId", mcContentId.longValue())
+ .list();
+
+ return list;
+ }
+
public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid)
{
HibernateTemplate templ = this.getHibernateTemplate();
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java,v
diff -u -r1.10 -r1.11
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 20 Oct 2005 21:41:19 -0000 1.10
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 22 Oct 2005 19:08:23 -0000 1.11
@@ -81,6 +81,8 @@
public void cleanAllQuestions(final Long mcContentUid) throws McApplicationException;
+ public List refreshQuestionContent(final Long mcContentId) throws McApplicationException;
+
public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
public void removeMcOptionsContent(McOptsContent mcOptsContent);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java,v
diff -u -r1.11 -r1.12
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 20 Oct 2005 21:41:19 -0000 1.11
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 22 Oct 2005 19:08:23 -0000 1.12
@@ -331,7 +331,22 @@
e);
}
}
+
+ public List refreshQuestionContent(final Long mcContentId) throws McApplicationException
+ {
+ try
+ {
+ return mcQueContentDAO.refreshQuestionContent(mcContentId);
+ }
+ catch (DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is refreshing mc question content: "
+ + e.getMessage(),
+ e);
+ }
+
+ }
public void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException
{
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.17 -r1.18
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 22 Oct 2005 14:45:37 -0000 1.17
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 22 Oct 2005 19:08:23 -0000 1.18
@@ -43,6 +43,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.McApplicationException;
import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McContent;
import org.lamsfoundation.lams.tool.mc.McOptsContent;
@@ -231,7 +232,16 @@
McUtils.persistRichText(request);
+ String selectedQuestion=request.getParameter(SELECTED_QUESTION);
+ logger.debug("read parameter selectedQuestion: " + selectedQuestion);
+
+ if ((selectedQuestion != null) && (selectedQuestion.length() > 0))
+ {
+ request.getSession().setAttribute(SELECTED_QUESTION,selectedQuestion);
+ logger.debug("updated SELECTED_QUESTION");
+ }
+
String userAction=null;
if (mcAuthoringForm.getAddQuestion() != null)
{
@@ -514,15 +524,52 @@
userAction="doneOptions";
request.setAttribute(USER_ACTION, userAction);
logger.debug("userAction:" + userAction);
+
+ String selectedIndex=mcAuthoringForm.getSelectedIndex();
+ logger.debug("selectedIndex:" + selectedIndex);
- /** make the particular question content in the main page disabled for user access*/
- Long selectedQuestionContentUid=(Long) request.getSession().getAttribute(SELECTED_QUESTION_CONTENT_UID);
- logger.debug("selectedQuestionContentUid:" + selectedQuestionContentUid);
+ if ((selectedIndex == null) || (selectedIndex.equals("")))
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY,new ActionMessage("error.selectedIndex.empty"));
+ logger.debug("add error.selectedIndex.empty to ActionMessages");
+ saveErrors(request,errors);
+ mcAuthoringForm.resetUserAction();
+ logger.debug("return to EDIT_OPTS_CONTENT to fix error.");
+ return (mapping.findForward(EDIT_OPTS_CONTENT));
+ }
+
+ String parameterType="optionContent";
+ long mapCounter=0;
+ String selectedAnswer=null;
+ for (long i=1; i <= MAX_OPTION_COUNT ; i++)
+ {
+ if (selectedIndex.equals(new Long(i).toString()))
+ {
+ selectedAnswer=request.getParameter(parameterType + i);
+ logger.debug("found selectedAnswer: " + selectedAnswer);
+ }
+ }
+
+ Long selectedQuestionContentUid=(Long)request.getSession().getAttribute(SELECTED_QUESTION_CONTENT_UID);
+ logger.debug("selectedQuestionContentUid:" + selectedQuestionContentUid);
+
+ selectedQuestion=(String) request.getSession().getAttribute(SELECTED_QUESTION);
+ logger.debug("final selectedQuestion:" + selectedQuestion);
+ /** make the particular question content in the main page disabled for user access*/
McQueContent mcQueContent = mcService.retrieveMcQueContentByUID(selectedQuestionContentUid);
logger.debug("mcQueContent:" + mcQueContent);
+ mcQueContent.setQuestion(selectedQuestion);
+ mcService.saveOrUpdateMcQueContent(mcQueContent);
+ logger.debug("persisted selectedQuestion" + selectedQuestion);
+ Map mapQuestionsContent =rebuildQuestionMapfromDB(request);
+ request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
+ logger.debug("updated MAP_QUESTIONS_CONTENT with the changed question:" + mapQuestionsContent);
+
+
/** parse all the options and persist them */
Map mapOptionsContent=repopulateMap(request,"optionContent");
logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent);
@@ -551,6 +598,21 @@
}
logger.debug("doneOptions persists all the options");
+ if (selectedAnswer != null && selectedAnswer.length() > 0)
+ {
+ logger.debug("update the record for the correct option.");
+ McOptsContent mcOptsContent=mcService.getOptionContentByOptionText(selectedAnswer, selectedQuestionContentUid);
+ logger.debug("found mcOptsContent to be updated " + mcOptsContent);
+
+ if (mcOptsContent != null)
+ {
+ logger.debug("found mcOptsContent is correctOption" + mcOptsContent.isCorrectOption());
+ mcOptsContent.setCorrectOption(true);
+ mcService.updateMcOptionsContent(mcOptsContent);
+ logger.debug("persisted the updated mcOptsContent" + mcOptsContent);
+ logger.debug("updated mcOptsContent isCorrect?" + mcOptsContent.isCorrectOption());
+ }
+ }
mcAuthoringForm.resetUserAction();
@@ -874,7 +936,36 @@
}
+
+ protected Map rebuildQuestionMapfromDB(HttpServletRequest request)
+ {
+ Map mapQuestionsContent= new TreeMap(new McComparator());
+
+ IMcService mcService =McUtils.getToolService(request);
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId:" + toolContentId);
+ McContent mcContent=mcService.retrieveMc(toolContentId);
+ logger.debug("mcContent:" + mcContent);
+
+ List list=mcService.refreshQuestionContent(mcContent.getUid());
+ logger.debug("refreshed list:" + list);
+
+ Iterator listIterator=list.iterator();
+ Long mapIndex=new Long(1);
+ while (listIterator.hasNext())
+ {
+ McQueContent mcQueContent=(McQueContent)listIterator.next();
+ logger.debug("mcQueContent:" + mcQueContent);
+ mapQuestionsContent.put(mapIndex.toString(),mcQueContent.getQuestion());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+
+ logger.debug("refreshed Map:" + mapQuestionsContent);
+ return mapQuestionsContent;
+ }
+
+
/**
* persists error messages to request scope
* @param request
Index: lams_tool_lamc/web/authoringMaincontent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/Attic/authoringMaincontent.jsp,v
diff -u -r1.16 -r1.17
--- lams_tool_lamc/web/authoringMaincontent.jsp 22 Oct 2005 14:45:37 -0000 1.16
+++ lams_tool_lamc/web/authoringMaincontent.jsp 22 Oct 2005 19:08:23 -0000 1.17
@@ -100,7 +100,7 @@