Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties
===================================================================
diff -u -rc1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision c1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -22,6 +22,7 @@
button.getPreviousQuestion =Previous
button.editQuestion =Edit
label.option1 =Option 1
+label.options =Options
label.report.title =Report Title
label.monitoringReport.title =Monitoring Report Title
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java
===================================================================
diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java (.../IMcQueContentDAO.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -35,6 +35,8 @@
public McQueContent getMcQueContentByUID(Long uid);
public McQueContent getToolDefaultQuestionContent(final long mcContentId);
+
+ public McQueContent getQuestionContentByQuestionText(final String question);
public void saveMcQueContent(McQueContent mcQueContent);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java
===================================================================
diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java (.../McQueContentDAO.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java (.../McQueContentDAO.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -43,6 +43,8 @@
static Logger logger = Logger.getLogger(McQueContentDAO.class.getName());
private static final String LOAD_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
+
+ private static final String LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT = "from mcQueContent in class McQueContent where mcQueContent.question=:question";
public McQueContent getMcQueContentByUID(Long uid)
@@ -64,9 +66,22 @@
}
});
}
-
+ public McQueContent getQuestionContentByQuestionText(final String question)
+ {
+ return (McQueContent) getHibernateTemplate().execute(new HibernateCallback()
+ {
+ public Object doInHibernate(Session session) throws HibernateException
+ {
+ return session.createQuery(LOAD_QUESTION_CONTENT_BY_QUESTION_TEXT)
+ .setString("question", question)
+ .uniqueResult();
+ }
+ });
+ }
+
+
public void saveMcQueContent(McQueContent mcQueContent)
{
this.getHibernateTemplate().save(mcQueContent);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java
===================================================================
diff -u -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -71,6 +71,8 @@
public McQueContent retrieveMcQueContentByUID(Long uid) throws McApplicationException;
+ public McQueContent getQuestionContentByQuestionText(final String question);
+
public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException;
public McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException;
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
diff -u -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -270,8 +270,23 @@
e);
}
}
+
+ public McQueContent getQuestionContentByQuestionText(final String question)
+ {
+ try
+ {
+ return mcQueContentDAO.getQuestionContentByQuestionText(question);
+ }
+ catch (DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is retrieving question content by question text: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException
{
try
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java
===================================================================
diff -u -raa3eef2f8bc90640f43a1a493154ba94c3e02c00 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision aa3eef2f8bc90640f43a1a493154ba94c3e02c00)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (.../McAction.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -21,6 +21,8 @@
package org.lamsfoundation.lams.tool.mc.web;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -38,6 +40,8 @@
import org.apache.struts.actions.DispatchAction;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
import org.lamsfoundation.lams.tool.mc.McComparator;
+import org.lamsfoundation.lams.tool.mc.McOptsContent;
+import org.lamsfoundation.lams.tool.mc.McQueContent;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.service.IMcService;
@@ -213,10 +217,17 @@
logger.debug("loadQ initialised...");
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
+
+ IMcService mcService =McUtils.getToolService(request);
+ logger.debug("mcService:" + mcService);
Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT);
logger.debug("mapQuestionsContent: " + mapQuestionsContent);
+ Map mapOptionsContent=(Map) request.getSession().getAttribute(MAP_OPTIONS_CONTENT);
+ logger.debug("mapOptionsContent: " + mapOptionsContent);
+ mapOptionsContent.clear();
+
mapQuestionsContent=repopulateMap(mapQuestionsContent, request);
logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent);
logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size());
@@ -254,21 +265,45 @@
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
- else if (mcAuthoringForm.getEditDefaultQuestion() != null)
+ else if (mcAuthoringForm.getEditOptions() != null)
{
- userAction="editDefaultQuestion";
+ userAction="editOption";
request.setAttribute(USER_ACTION, userAction);
- mcAuthoringForm.resetUserAction();
- return (mapping.findForward(EDIT_OPTS_CONTENT));
+ String questionIndex =mcAuthoringForm.getQuestionIndex();
+ logger.debug("questionIndex:" + questionIndex);
+ String editableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
+ logger.debug("editableQuestionEntry:" + editableQuestionEntry);
+ McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(editableQuestionEntry);
+ logger.debug("mcQueContent:" + mcQueContent);
+
+ if (mcQueContent != null)
+ {
+ /** hold all he options for this question*/
+ List list=mcService.findMcOptionsContentByQueId(mcQueContent.getUid());
+ logger.debug("options list:" + list);
+
+ Iterator listIterator=list.iterator();
+ Long mapIndex=new Long(1);
+ while (listIterator.hasNext())
+ {
+ McOptsContent mcOptsContent=(McOptsContent)listIterator.next();
+ logger.debug("option text:" + mcOptsContent.getMcQueOptionText());
+ mapOptionsContent.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ logger.debug("updated the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
+ }
+ else
+ {
+ logger.debug("we are not supposed to reach here: error getting question content by question text.");
+ }
+
+ return (mapping.findForward(EDIT_OPTS_CONTENT));
+
}
-
-
-
logger.debug("userAction:" + userAction);
-
- IMcService mcService =McUtils.getToolService(request);
- logger.debug("mcService:" + mcService);
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java
===================================================================
diff -u -raa3eef2f8bc90640f43a1a493154ba94c3e02c00 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision aa3eef2f8bc90640f43a1a493154ba94c3e02c00)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -22,12 +22,20 @@
*/
public class McAuthoringForm extends ActionForm implements McAppConstants {
/** form controllers */
- protected String editDefaultQuestion;
+
protected String addOptionContent;
- protected String removeOptionContent;
protected String addQuestion;
protected String removeQuestion;
+ protected String editOptions;
+ protected String addOption;
+ protected String questionIndex;
+ protected String optionIndex;
+
+ protected String editDefaultQuestion;
+ protected String removeOptionContent;
+
+
protected String addContent;
protected String removeContent;
protected String removeAllContent;
@@ -46,7 +54,7 @@
/** basic content */
protected String title;
protected String instructions;
- protected String questionIndex;
+
protected String isRemoveContent;
protected String toolContentId;
/** instructions content */
@@ -81,6 +89,8 @@
this.removeOptionContent=null;
this.addQuestion=null;
this.removeQuestion=null;
+ this.editOptions=null;
+ this.addOption=null;
this.addContent=null;
this.removeContent=null;
@@ -104,6 +114,8 @@
this.removeOptionContent=null;
this.addQuestion=null;
this.removeQuestion=null;
+ this.editOptions=null;
+ this.addOption=null;
this.addContent=null;
this.removeContent=null;
@@ -121,6 +133,7 @@
this.title=null;
this.instructions=null;
this.questionIndex=null;
+ this.optionIndex=null;
this.isRemoveContent=null;
this.toolContentId=null;
@@ -613,4 +626,40 @@
public void setRemoveQuestion(String removeQuestion) {
this.removeQuestion = removeQuestion;
}
+ /**
+ * @return Returns the editOptions.
+ */
+ public String getEditOptions() {
+ return editOptions;
+ }
+ /**
+ * @param editOptions The editOptions to set.
+ */
+ public void setEditOptions(String editOptions) {
+ this.editOptions = editOptions;
+ }
+ /**
+ * @return Returns the addOption.
+ */
+ public String getAddOption() {
+ return addOption;
+ }
+ /**
+ * @param addOption The addOption to set.
+ */
+ public void setAddOption(String addOption) {
+ this.addOption = addOption;
+ }
+ /**
+ * @return Returns the optionIndex.
+ */
+ public String getOptionIndex() {
+ return optionIndex;
+ }
+ /**
+ * @param optionIndex The optionIndex to set.
+ */
+ public void setOptionIndex(String optionIndex) {
+ this.optionIndex = optionIndex;
+ }
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java
===================================================================
diff -u -re6d1e7b2b7a185ef297334af35e9aec398a29930 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision e6d1e7b2b7a185ef297334af35e9aec398a29930)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -289,7 +289,7 @@
request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, mcQueContent.getQuestion());
mapQuestionsContent.put(new Long(1).toString(), mcQueContent.getQuestion());
request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent);
- logger.debug("starter initialized the Questions Map: " + request.getSession().getAttribute("mapQuestionsContent") );
+ logger.debug("starter initialized the Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT));
/** hold all he options for this question*/
@@ -306,21 +306,15 @@
mapIndex=new Long(mapIndex.longValue()+1);
}
request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
- logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute("mapOptionsContent") );
+ logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
}
else
{
logger.debug("getting existing content with id:" + toolContentId);
}
-
-
-
-
-
-
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java
===================================================================
diff -u -rc1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision c1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1)
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -80,8 +80,8 @@
super.tearDown();
}
+ /*
-
public void testInitDB()
{
//create new mc content
@@ -128,6 +128,6 @@
McOptsContent mcOptionsContent3= new McOptsContent(new Long(999), false, "sample answer 3", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent3);
}
-
+*/
}
Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java
===================================================================
diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java (.../TestMcQueContent.java) (revision c36523c3640d5bda32e4b738383c2595ca9603cf)
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java (.../TestMcQueContent.java) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -91,10 +91,21 @@
}
*/
+ /*
public void testGetToolDefaultQuestionContent()
{
McQueContent mcQueContent = mcQueContentDAO.getToolDefaultQuestionContent(new Long(1).longValue());
System.out.print("mcQueContent:" + mcQueContent);
}
+ */
+
+ public void testGetQuestionContentByQuestionText()
+ {
+ McQueContent mcQueContent = mcQueContentDAO.getQuestionContentByQuestionText("A sample question");
+ System.out.print("mcQueContent:" + mcQueContent);
+ }
+
+
+
}
\ No newline at end of file
Index: lams_tool_lamc/test/web/WEB-INF/tiles/tiles-defs.xml
===================================================================
diff -u -rc1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1 -r671255080ca12fba787bcf07b5d0d196fc96c5ea
--- lams_tool_lamc/test/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision c1e9ee48a9fd7b643af1e4eae6b9806b9aae18d1)
+++ lams_tool_lamc/test/web/WEB-INF/tiles/tiles-defs.xml (.../tiles-defs.xml) (revision 671255080ca12fba787bcf07b5d0d196fc96c5ea)
@@ -49,9 +49,9 @@