Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java (.../McAppConstants.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -101,6 +101,7 @@ * authoring mode constants */ public static final String MAP_QUESTION_CONTENT ="mapQuestionContent"; + public static final String MAP_OPTIONS_CONTENT ="mapOptionsContent"; public static final String DEFAULT_QUESTION_CONTENT ="defaultQuestionContent"; public static final String TITLE ="title"; public static final String INSTRUCTIONS ="instructions"; @@ -110,6 +111,7 @@ public static final String OFFLINE_INSTRUCTIONS ="offlineInstructions"; public static final String END_LEARNING_MESSSAGE ="endLearningMessage"; public static final String CONTENT_LOCKED ="contentLocked"; + public static final String CONTENT_IN_USE ="contentInUse"; public static final String ON ="ON"; public static final String OFF ="OFF"; public static final String IS_USERNAME_VISIBLE_MONITORING ="isUsernameVisibleMonitoring"; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties =================================================================== diff -u -r5f80d71e39cb040460d57e45cf7f94b34204f1b3 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 5f80d71e39cb040460d57e45cf7f94b34204f1b3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties (.../McResources.properties) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -18,6 +18,7 @@ button.done =Done button.getNextQuestion =Next button.getPreviousQuestion =Previous +button.editQuestion =Edit label.report.title =Report Title label.monitoringReport.title =Monitoring Report Title Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== diff -u -re641617111e90d02c659127046f06b0f5c8e2845 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision e641617111e90d02c659127046f06b0f5c8e2845) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -73,25 +73,6 @@ } - - public static void setDefaultSessionAttributes(HttpServletRequest request, McContent defaultMcContent, McAuthoringForm mcAuthoringForm) - { - /**should never be null anyway as default content MUST exist in the db*/ - if (defaultMcContent != null) - { - mcAuthoringForm.setTitle(defaultMcContent.getTitle()); - mcAuthoringForm.setInstructions(defaultMcContent.getInstructions()); - mcAuthoringForm.setReportTitle(defaultMcContent.getReportTitle()); - mcAuthoringForm.setEndLearningMessage(defaultMcContent.getEndLearningMessage()); - mcAuthoringForm.setOnlineInstructions(defaultMcContent.getOnlineInstructions()); - mcAuthoringForm.setOfflineInstructions(defaultMcContent.getOfflineInstructions()); - mcAuthoringForm.setMonitoringReportTitle(defaultMcContent.getMonitoringReportTitle()); - - request.getSession().setAttribute(TITLE,mcAuthoringForm.getTitle()); - request.getSession().setAttribute(INSTRUCTIONS,mcAuthoringForm.getInstructions()); - } - } - public static int getCurrentUserId(HttpServletRequest request) throws McApplicationException { HttpSession ss = SessionManager.getSession(); @@ -187,7 +168,20 @@ return true; } - + public static void setDefaultSessionAttributes(HttpServletRequest request, McContent defaultMcContent, McAuthoringForm mcAuthoringForm) + { + /**should never be null anyway as default content MUST exist in the db*/ + if (defaultMcContent != null) + { + mcAuthoringForm.setTitle(defaultMcContent.getTitle()); + mcAuthoringForm.setInstructions(defaultMcContent.getInstructions()); + + request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,defaultMcContent.getOfflineInstructions()); + request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,defaultMcContent.getOnlineInstructions()); + } + } + + public static String getFormattedDateString(Date date) { logger.debug(logger + " " + " McUtils getFormattedDateString: " + Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -22,6 +22,8 @@ package org.lamsfoundation.lams.tool.mc.dao; +import java.util.List; + import org.lamsfoundation.lams.tool.mc.McOptsContent; @@ -34,6 +36,8 @@ { public McOptsContent getMcOptionsContentByUID(Long uid); + public List findMcOptionsContentByQueId(Long mcQueContentId); + public void saveMcOptionsContent(McOptsContent mcOptionsContent); public void updateMcOptionsContent(McOptsContent mcOptionsContent); Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -21,9 +21,12 @@ * ***********************************************************************/ package org.lamsfoundation.lams.tool.mc.dao.hibernate; +import java.util.List; + import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.mc.McOptsContent; import org.lamsfoundation.lams.tool.mc.dao.IMcOptionsContentDAO; +import org.springframework.orm.hibernate3.HibernateTemplate; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; @@ -38,12 +41,28 @@ public class McOptionsContentDAO extends HibernateDaoSupport implements IMcOptionsContentDAO { static Logger logger = Logger.getLogger(McOptionsContentDAO.class.getName()); + private static final String FIND_MC_OPTIONS_CONTENT = "from " + McOptsContent.class.getName() + " as mco where mc_que_content_id=?"; + public McOptsContent getMcOptionsContentByUID(Long uid) { return (McOptsContent) this.getHibernateTemplate() .get(McOptsContent.class, uid); } + + public List findMcOptionsContentByQueId(Long mcQueContentId) + { + HibernateTemplate templ = this.getHibernateTemplate(); + if ( mcQueContentId != null) { + List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT) + .setLong(0,mcQueContentId.longValue()) + .list(); + return list; + } + return null; + } + + public void saveMcOptionsContent(McOptsContent mcOptsContent) { Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== diff -u -rb7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision b7e4d4f379a4a90d25f4af4a5d421310cb6bf8e3) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -89,6 +89,8 @@ public void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException; + public List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException; + public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException; public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException; Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision c36523c3640d5bda32e4b738383c2595ca9603cf) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -419,6 +419,21 @@ } + public List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException + { + try + { + List list=mcOptionsContentDAO.findMcOptionsContentByQueId(mcQueContentId); + return list; + } + catch (DataAccessException e) + { + throw new McApplicationException("Exception occured when lams is finding by que id" + + " the mc options: " + + e.getMessage(),e); + } + } + public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException { try Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== diff -u --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (revision 0) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9) @@ -0,0 +1,241 @@ +/* + *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 + */ +package org.lamsfoundation.lams.tool.mc.web; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.Globals; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +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.McUtils; +import org.lamsfoundation.lams.tool.mc.service.IMcService; + + +/** + * + * change the logic about completion status + * + */ + +/** + * + * once lams_learning is ready and appContext file is src/ then FINISH toool session will work. + * + */ + +/** + * + * done: removed styling, except error messages and table centering + * + */ + +/** + * The tool's Spring configuration file: qaCompactApplicationContext.xml + * Main service bean of the tool is: org.lamsfoundation.lams.tool.qa.service.McServicePOJO + * + * done: config file is read from classpath + */ + + +/** + * + * the tool's web.xml will be modified to have classpath to learning service. + * This is how the tool gets the definition of "learnerService" + */ + +/** + * + * when to reset define later and synchin monitor etc.. + * + */ + +/** make sure the tool gets called on: + * setAsForceComplete(Long userId) throws McApplicationException + */ + + +/** + * + * User Issue: + * Right now: + * 1- the tool gets the request object from the container. + * 2- Principal principal = req.getUserPrincipal(); + * 3- String username = principal.getName(); + * 4- User userCompleteData = qaService.getCurrentUserData(userName); + * 5- write back userCompleteData.getUserId() + */ + + +/** + * + * JBoss Issue: + * Currently getUserPrincipal() returns null and ServletRequest.isUserInRole() always returns false on unsecured pages, + * even after the user has been authenticated. + * http://jira.jboss.com/jira/browse/JBWEB-19 + */ + + +/** + * eliminate calls: + * authoringUtil.simulatePropertyInspector_RunOffline(request); + * authoringUtil.simulatePropertyInspector_setAsDefineLater(request); + */ + + +/** + * + * @author ozgurd + * + * TOOL PARAMETERS: ?? (toolAccessMode) ?? + * Authoring environment: toolContentId + * Learning environment: toolSessionId + toolContentId + * Monitoring environment: toolContentId / Contribute tab:toolSessionId(s) + * + * + */ + +/** + * Note: the tool must support deletion of an existing content from within the authoring environment. + * The current support for this is by implementing the tool contract : removeToolContent(Long toolContentId) + */ + + +/** + * + * We have had to simulate container bahaviour in development stage by calling + * createToolSession and leaveToolSession from the web layer. These will go once the tool is + * in deployment environment. + * + * + * CHECK: leaveToolSession and relavent LearnerService may need to be defined in the spring config file. + * + */ + + +/** + * + * GROUPING SUPPORT: Find out what to do. + */ + + +/** + *
Action class that controls the logic of tool behavior.
+ * + *Note that Struts action class only has the responsibility to navigate + * page flow. All database operation should go to service layer and data + * transformation from domain model to struts form bean should go to form + * bean class. This ensure clean and maintainable code. + *
+ * + *SystemException
is thrown whenever an known error condition is
+ * identified. No system exception error handling code should appear in the
+ * Struts action class as all of them are handled in
+ * CustomStrutsExceptionHandler.
+ *
+ * @author Ozgur Demirtas
+ */
+public class McAction extends DispatchAction implements McAppConstants
+{
+ static Logger logger = Logger.getLogger(McAction.class.getName());
+
+ /**
+ * Struts dispatch method.
+ *
+ * It is assuming that progress engine should pass in the tool access
+ * mode and the tool session id as http parameters.
+ *
+ * @param mapping An ActionMapping class that will be used by the Action class to tell
+ * the ActionServlet where to send the end-user.
+ *
+ * @param form The ActionForm class that will contain any data submitted
+ * by the end-user via a form.
+ * @param request A standard Servlet HttpServletRequest class.
+ * @param response A standard Servlet HttpServletResponse class.
+ * @return An ActionForward class that will be returned to the ActionServlet indicating where
+ * the user is to go next.
+ * @throws IOException
+ * @throws ServletException
+ * @throws McApplicationException the known runtime exception
+ *
+ */
+
+ /**
+ * loadQ(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+
+ * return ActionForward
+ * main content/question content management and workflow logic
+ *
+ * if the passed toolContentId exists in the db, we need to get the relevant data into the Map
+ * if not, create the default Map
+ */
+
+ public ActionForward loadQ(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+
+ logger.debug("loadQ initialised...");
+ McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
+
+ logger.debug("mcAuthoringForm.getEditDefaultQuestion():" + mcAuthoringForm.getEditDefaultQuestion());
+ String userAction=null;
+ if (mcAuthoringForm.getEditDefaultQuestion() != null)
+ {
+ userAction="editDefaultQuestion";
+
+ }
+ logger.debug("userAction:" + userAction);
+
+ IMcService mcService =McUtils.getToolService(request);
+ logger.debug("mcService:" + mcService);
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+ /**
+ * persists error messages to request scope
+ * @param request
+ * @param message
+ */
+ public void persistError(HttpServletRequest request, String message)
+ {
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage(message));
+ logger.debug("add " + message +" to ActionMessages:");
+ saveErrors(request,errors);
+ }
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java
===================================================================
diff -u -re641617111e90d02c659127046f06b0f5c8e2845 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision e641617111e90d02c659127046f06b0f5c8e2845)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java (.../McAuthoringForm.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -22,6 +22,9 @@
*/
public class McAuthoringForm extends ActionForm implements McAppConstants {
/** form controllers */
+ protected String editDefaultQuestion;
+
+
protected String addContent;
protected String removeContent;
protected String removeAllContent;
@@ -30,6 +33,7 @@
protected String submitOfflineFile;
protected String submitOnlineFile;
+
/** tab controller, these may go away once the Flash wraps the jsp */
protected String choice;
protected String choiceBasic;
@@ -48,6 +52,9 @@
protected FormFile theOfflineFile;
protected FormFile theOnlineFile;
+ protected String richTextOfflineInstructions;
+ protected String richTextOnlineInstructions;
+
/** advanced content */
protected String synchInMonitor;
protected String reportTitle;
@@ -66,6 +73,7 @@
public void resetUserAction()
{
+ this.editDefaultQuestion=null;
this.addContent=null;
this.removeContent=null;
this.removeAllContent=null;
@@ -104,6 +112,9 @@
this.onlineInstructions=null;
this.offlineInstructions=null;
+
+ this.richTextOfflineInstructions=null;
+ this.richTextOnlineInstructions=null;
this.endLearningMessage=null;
this.synchInMonitor=null;
@@ -503,4 +514,41 @@
public void setSubmitOnlineFile(String submitOnlineFile) {
this.submitOnlineFile = submitOnlineFile;
}
+ /**
+ * @return Returns the richTextOfflineInstructions.
+ */
+ public String getRichTextOfflineInstructions() {
+ return richTextOfflineInstructions;
+ }
+ /**
+ * @param richTextOfflineInstructions The richTextOfflineInstructions to set.
+ */
+ public void setRichTextOfflineInstructions(
+ String richTextOfflineInstructions) {
+ this.richTextOfflineInstructions = richTextOfflineInstructions;
+ }
+ /**
+ * @return Returns the richTextOnlineInstructions.
+ */
+ public String getRichTextOnlineInstructions() {
+ return richTextOnlineInstructions;
+ }
+ /**
+ * @param richTextOnlineInstructions The richTextOnlineInstructions to set.
+ */
+ public void setRichTextOnlineInstructions(String richTextOnlineInstructions) {
+ this.richTextOnlineInstructions = richTextOnlineInstructions;
+ }
+ /**
+ * @return Returns the editDefaultQuestion.
+ */
+ public String getEditDefaultQuestion() {
+ return editDefaultQuestion;
+ }
+ /**
+ * @param editDefaultQuestion The editDefaultQuestion to set.
+ */
+ public void setEditDefaultQuestion(String editDefaultQuestion) {
+ this.editDefaultQuestion = editDefaultQuestion;
+ }
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java
===================================================================
diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision c36523c3640d5bda32e4b738383c2595ca9603cf)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java (.../McStarterAction.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -67,6 +67,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;
@@ -86,6 +88,7 @@
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;
import org.lamsfoundation.lams.tool.mc.McQueContent;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.service.IMcService;
@@ -103,6 +106,7 @@
throws IOException, ServletException, McApplicationException {
Map mapQuestionContent= new TreeMap(new McComparator());
+ Map mapOptionsContent= new TreeMap(new McComparator());
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
mcAuthoringForm.resetRadioBoxes();
@@ -174,7 +178,7 @@
/**
- * retrieve the default question content id based on default content UID determined above
+ * retrieve the default question content based on default content UID determined above
*/
try
{
@@ -236,11 +240,83 @@
logger.debug("forwarding to: " + LOAD_QUESTIONS);
return (mapping.findForward(LOAD_QUESTIONS));
}
- /**
- * load questions page
- */
+ /**
+ * find out if the passed tool content id exists in the db
+ * present user either a first timer screen with default content data or fetch the existing content.
+ *
+ * if the toolcontentid does not exist in the db, create the default Map,
+ * there is no need to check if the content is in use in this case.
+ * It is always unlocked -> not in use since it is the default content.
+ */
+ if (!existsContent(toolContentId, request))
+ {
+ logger.debug("getting default content");
+ contentId=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE);
+ McContent mcContent=mcService.retrieveMc(new Long(contentId));
+ logger.debug("mcContent:" + mcContent);
+
+ if (mcContent == null)
+ {
+ logger.debug("Exception occured: No default content");
+ request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+ McUtils.setDefaultSessionAttributes(request, mcContent, mcAuthoringForm);
+ logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE));
+ logger.debug("getting default content");
+ /**
+ * this is a new content creation, the content must not be in use.
+ * relevant attribute: CONTENT_IN_USE
+ */
+ request.getSession().setAttribute(CONTENT_IN_USE, new Boolean(false));
+ logger.debug("CONTENT_IN_USE: " + request.getSession().getAttribute(CONTENT_IN_USE));
+
+ mcAuthoringForm.setUsernameVisible(OFF);
+ mcAuthoringForm.setQuestionsSequenced(OFF);
+ mcAuthoringForm.setSynchInMonitor(OFF);
+
+ /** collect options for the default question content into a Map*/
+ McQueContent mcQueContent=mcService.getToolDefaultQuestionContent(mcContent.getUid().longValue());
+ System.out.print("mcQueContent:" + mcQueContent);
+ if (mcQueContent == null)
+ {
+ logger.debug("Exception occured: No default question content");
+ request.setAttribute(USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultQuestionContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+ /** 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("starter initialized the Options Map: " + request.getSession().getAttribute("mapOptionsContent") );
+
+ }
+ else
+ {
+ logger.debug("getting existing content with id:" + toolContentId);
+ }
+
+
+
+
+
+
+
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -252,13 +328,13 @@
* @return boolean
* determine whether a specific toolContentId exists in the db
*/
- protected boolean existsContent(Long toolContentId, HttpServletRequest request)
+ protected boolean existsContent(long toolContentId, HttpServletRequest request)
{
/**
* retrive the service
*/
IMcService mcService =McUtils.getToolService(request);
- McContent mcContent=mcService.retrieveMc(toolContentId);
+ McContent mcContent=mcService.retrieveMc(new Long(toolContentId));
if (mcContent == null)
return false;
Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java
===================================================================
diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision c36523c3640d5bda32e4b738383c2595ca9603cf)
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java (.../McDataAccessTestCase.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -87,19 +87,19 @@
//create new mc content
McContent mc = new McContent();
mc.setMcContentId(DEFAULT_CONTENT_ID);
- mc.setTitle("New - Put Title Here");
- mc.setInstructions("New - Put instructions here.");
+ mc.setTitle("title...");
+ mc.setInstructions("instructions...");
mc.setQuestionsSequenced(false);
mc.setUsernameVisible(false);
mc.setCreatedBy(0);
- mc.setMonitoringReportTitle("New-Monitoring Report title");
- mc.setReportTitle("New-Report title");
+ mc.setMonitoringReportTitle("Monitoring Report");
+ mc.setReportTitle("Report");
mc.setRunOffline(false);
mc.setDefineLater(false);
mc.setSynchInMonitor(false);
- mc.setOnlineInstructions("New- online instructions");
- mc.setOfflineInstructions("New- offline instructions");
- mc.setEndLearningMessage("New- endLearningMessage");
+ mc.setOnlineInstructions("online instructions...");
+ mc.setOfflineInstructions("offline instructions...");
+ mc.setEndLearningMessage("Thanks.");
mc.setContentInUse(false);
mc.setRetries(false);
mc.setShowFeedback(false);
@@ -109,7 +109,7 @@
McContent mcContent = mcContentDAO.findMcContentById(DEFAULT_CONTENT_ID);
- McQueContent mcQueContent= new McQueContent("What planet are you from?",
+ McQueContent mcQueContent= new McQueContent("A sample question",
new Integer(444),
mcContent,
new HashSet(),
@@ -119,15 +119,15 @@
McQueContent mcQueContent1 = mcQueContentDAO.getMcQueContentByUID(new Long(1));
- McOptsContent mcOptionsContent= new McOptsContent(new Long(777), true, "red", mcQueContent1, new HashSet());
+ McOptsContent mcOptionsContent= new McOptsContent(new Long(777), true, "sample answer 1", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent);
- McOptsContent mcOptionsContent2= new McOptsContent(new Long(888), false, "blue", mcQueContent1, new HashSet());
+ McOptsContent mcOptionsContent2= new McOptsContent(new Long(888), false, "sample answer 2", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent2);
- McOptsContent mcOptionsContent3= new McOptsContent(new Long(999), false, "yellow", mcQueContent1, new HashSet());
+ 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/TestMcOptionsContent.java
===================================================================
diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcOptionsContent.java (.../TestMcOptionsContent.java) (revision c36523c3640d5bda32e4b738383c2595ca9603cf)
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcOptionsContent.java (.../TestMcOptionsContent.java) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -9,7 +9,8 @@
package org.lamsfoundation.lams.tool.mc;
-import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
/*
@@ -37,8 +38,7 @@
super(name);
}
-
-
+ /*
public void testCreateMcOptionsContent()
{
McQueContent mcQueContent = mcQueContentDAO.getMcQueContentByUID(new Long(1));
@@ -51,8 +51,20 @@
McOptsContent mcOptionsContent3= new McOptsContent(new Long(999), false, "yellow", mcQueContent, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent3);
}
-
+ */
+ public void testRetrieveMcOptionsContent()
+ {
+ List list=mcOptionsContentDAO.findMcOptionsContentByQueId(new Long(1));
+ System.out.print("list:" + list);
+
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McOptsContent mcOptsContent=(McOptsContent)listIterator.next();
+ System.out.println("option text:" + mcOptsContent.getMcQueOptionText());
+ }
+ }
}
Index: lams_tool_lamc/web/WEB-INF/struts-config.xml
===================================================================
diff -u -re641617111e90d02c659127046f06b0f5c8e2845 -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision e641617111e90d02c659127046f06b0f5c8e2845)
+++ lams_tool_lamc/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -51,6 +51,29 @@
redirect="true"
/>
+
+
+
+
+
+
Index: lams_tool_lamc/web/authoringMaincontent.jsp
===================================================================
diff -u -rc36523c3640d5bda32e4b738383c2595ca9603cf -r562680abb2d5566e7972f1ee4a1993fbbebc4ca9
--- lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision c36523c3640d5bda32e4b738383c2595ca9603cf)
+++ lams_tool_lamc/web/authoringMaincontent.jsp (.../authoringMaincontent.jsp) (revision 562680abb2d5566e7972f1ee4a1993fbbebc4ca9)
@@ -92,15 +92,54 @@
-
+
+
+
-Basic tab content
+Basic Question Definitions
-
-
-
-
-
+
+
+ :
+
+
+
+
+
+
+
+
+ :
+
+
+
+
+
+
+
+
+
+
+ :
+
+
+ ">
+  
+
+
+
+
+
+
+
+
+
+
+
+
Cancel
@@ -112,7 +151,7 @@
-Advanced tab content
+Advanced Question Definitions
The advanced contents should go here
@@ -122,7 +161,7 @@
-Instructions tab content
+Instructions
Instructions are here
@@ -133,11 +172,27 @@
+
+
+
-
+