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.7 -r1.8
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 14 Oct 2005 18:47:09 -0000 1.7
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 15 Oct 2005 15:21:56 -0000 1.8
@@ -95,6 +95,8 @@
public static final String IS_REMOVE_QUESTION ="isRemoveQuestion";
public static final String IS_REMOVE_CONTENT ="isRemoveContent";
+ public static final String QUESTIONS_SEQUENCED ="questionsSequenced";
+
/**
* tab controllers, constants for authoring page html tabs, used within jsp
*/
@@ -109,13 +111,24 @@
*/
public static final String MAP_QUESTIONS_CONTENT ="mapQuestionsContent";
public static final String MAP_OPTIONS_CONTENT ="mapOptionsContent";
+ public static final String MAP_DEFAULTOPTIONS_CONTENT ="mapDefaultOptionsContent";
+
public static final String MAP_QUESTION_CONTENT ="mapQuestionContent";
public static final String DEFAULT_QUESTION_CONTENT ="defaultQuestionContent";
public static final String TITLE ="title";
public static final String INSTRUCTIONS ="instructions";
+ public static final String CREATED_BY ="createdBy";
public static final String CREATION_DATE ="creationDate";
public static final String USERNAME_VISIBLE ="usernameVisible";
+ public static final String RUN_OFFLINE ="runOffline";
+ public static final String DEFINE_LATER ="defineLater";
+ public static final String SYNCH_IN_MONITOR ="synchInMonitor";
+ public static final String RETRIES ="retries";
+ public static final String PASSMARK ="passMark";
+ public static final String SHOW_FEEDBACK ="showFeedback";
+
+
public static final String ONLINE_INSTRUCTIONS ="onlineInstructions";
public static final String OFFLINE_INSTRUCTIONS ="offlineInstructions";
public static final String END_LEARNING_MESSSAGE ="endLearningMessage";
@@ -175,6 +188,8 @@
public static final String USER_EXCEPTION_TOOLSESSIONID_REQUIRED ="userExceptionToolSessionIdRequired";
public static final String USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE ="userExceptionDefaultContentNotAvailable";
public static final String USER_EXCEPTION_DEFAULTQUESTIONCONTENT_NOT_AVAILABLE ="userExceptionDefaultQuestionContentNotAvailable";
+ public static final String USER_EXCEPTION_DEFAULTOPTIONSCONTENT_NOT_AVAILABLE ="userExceptionDefaultOptionsContentNotAvailable";
+
public static final String USER_EXCEPTION_USERID_NOTAVAILABLE ="userExceptionUserIdNotAvailable";
public static final String USER_EXCEPTION_USERID_NOTNUMERIC ="userExceptionUserIdNotNumeric";
public static final String USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS ="userExceptionOnlyContentAndNoSessions";
@@ -217,6 +232,7 @@
public static final String MONITORING_REPORT_TITLE ="monitoringReportTitle";
public static final String REPORT_TITLE_LEARNER ="reportTitleLearner";
public static final String END_LEARNING_MESSAGE ="endLearningMessage";
+
public static final String IS_TOOL_ACTIVITY_OFFLINE ="isToolActivityOffline";
public static final String IS_USERNAME_VISIBLE ="isUsernameVisible";
public static final String IS_ALL_SESSIONS_COMPLETED ="isAllSessionsCompleted";
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.4 -r1.5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 14 Oct 2005 20:23:15 -0000 1.4
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McResources.properties 15 Oct 2005 15:21:56 -0000 1.5
@@ -55,6 +55,7 @@
error.content.unstableState =The content is in an unstable state since it has been left editable while monitored.
Please use this screen to redefine the content.
error.defaultContent.notAvailable =Tool Activity Error! Can't continue
The the default content for the Tool Activity has not been set up.
error.defaultQuestionContent.notAvailable =Tool Activity Error! Can't continue
The the default question content for the Tool Activity has not been set up.
+error.defaultOptionsContent.notAvailable =Tool Activity Error! Can't continue
The the default options content for the Tool Activity has not been set up.
#Learning mode resources
label.learning.qa =Answers for Q/A
@@ -99,6 +100,8 @@
error.tab.contentId.required =Sorry, the screen is not available. The Tool Activity requires a content id.
monitoring.feedback.instructionUpdate =The content has been updated successfully.
+
+
group.label =Group
button.summary =Summary
button.editActivity =Edit Activity
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java,v
diff -u -r1.7 -r1.8
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java 11 Oct 2005 11:35:27 -0000 1.7
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McContentDAO.java 15 Oct 2005 15:21:56 -0000 1.8
@@ -28,6 +28,7 @@
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.lamsfoundation.lams.tool.mc.McContent;
+import org.lamsfoundation.lams.tool.mc.McQueContent;
import org.lamsfoundation.lams.tool.mc.McSession;
import org.lamsfoundation.lams.tool.mc.dao.IMcContentDAO;
import org.springframework.orm.hibernate3.HibernateCallback;
@@ -61,10 +62,22 @@
public McContent findMcContentById(Long mcContentId)
{
String query = "from McContent as mc where mc.mcContentId = ?";
-
+ /*
return (McContent) getSession().createQuery(query)
.setLong(0,mcContentId.longValue())
.uniqueResult();
+ */
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(query)
+ .setLong(0,mcContentId.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ McContent mc = (McContent) list.get(0);
+ return mc;
+ }
+ return null;
}
/** @see org.lamsfoundation.lams.tool.mc.dao.IMcContentDAO#getMcContentBySession(java.lang.Long) */
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.6 -r1.7
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 14 Oct 2005 20:23:15 -0000 1.6
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 15 Oct 2005 15:21:56 -0000 1.7
@@ -21,12 +21,15 @@
* ***********************************************************************/
package org.lamsfoundation.lams.tool.mc.dao.hibernate;
+import java.util.List;
+
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.lamsfoundation.lams.tool.mc.McQueContent;
import org.lamsfoundation.lams.tool.mc.dao.IMcQueContentDAO;
import org.springframework.orm.hibernate3.HibernateCallback;
+import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
@@ -56,15 +59,16 @@
public McQueContent getToolDefaultQuestionContent(final long mcContentId)
{
- return (McQueContent) getHibernateTemplate().execute(new HibernateCallback()
- {
- public Object doInHibernate(Session session) throws HibernateException
- {
- return session.createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID)
- .setLong("mcContentId", mcContentId)
- .uniqueResult();
- }
- });
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_QUESTION_CONTENT_BY_CONTENT_ID)
+ .setLong("mcContentId", mcContentId)
+ .list();
+
+ if(list != null && list.size() > 0){
+ McQueContent mcq = (McQueContent) list.get(0);
+ return mcq;
+ }
+ return null;
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java,v
diff -u -r1.4 -r1.5
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java 11 Oct 2005 11:35:27 -0000 1.4
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java 15 Oct 2005 15:21:56 -0000 1.5
@@ -60,10 +60,22 @@
public McSession findMcSessionById(Long mcSessionId)
{
String query = "from McSession mcs where mcs.mcSessionId=?";
-
+ /*
return (McSession) getSession().createQuery(query)
.setLong(0,mcSessionId.longValue())
.uniqueResult();
+ */
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(query)
+ .setLong(0,mcSessionId.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ McSession mcs = (McSession) list.get(0);
+ return mcs;
+ }
+ return null;
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java,v
diff -u -r1.5 -r1.6
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java 11 Oct 2005 11:35:27 -0000 1.5
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java 15 Oct 2005 15:21:56 -0000 1.6
@@ -57,10 +57,22 @@
public McQueUsr findMcUserById(Long userId)
{
String query = "from McQueUsr user where user.queUsrId=?";
-
+ /*
return (McQueUsr) getSession().createQuery(query)
.setLong(0,userId.longValue())
.uniqueResult();
+ */
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(query)
+ .setLong(0,userId.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ McQueUsr mcu = (McQueUsr) list.get(0);
+ return mcu;
+ }
+ return null;
}
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.6 -r1.7
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 14 Oct 2005 20:23:14 -0000 1.6
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 15 Oct 2005 15:21:56 -0000 1.7
@@ -21,14 +21,18 @@
package org.lamsfoundation.lams.tool.mc.web;
import java.io.IOException;
+import java.util.Date;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import java.util.TreeSet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
@@ -40,10 +44,14 @@
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.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;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
/**
@@ -224,10 +232,6 @@
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());
@@ -245,6 +249,28 @@
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);
+
+ /** 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);
+ }
+ }
+
+
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -257,11 +283,24 @@
logger.debug("questionIndex:" + questionIndex);
String deletableQuestionEntry=(String)mapQuestionsContent.get(questionIndex);
logger.debug("deletableQuestionEntry:" + deletableQuestionEntry);
- 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));
+ if (!(deletableQuestionEntry.equals("")))
+ {
+ 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));
+
+ McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(deletableQuestionEntry);
+ logger.debug("mcQueContent:" + mcQueContent);
+
+ if (mcQueContent != null)
+ {
+ mcService.retrieveMcQueContentByUID(mcQueContent.getUid());
+ logger.debug("removed mcQueContent from DB:" + mcQueContent);
+ }
+ }
+
mcAuthoringForm.resetUserAction();
return (mapping.findForward(LOAD_QUESTIONS));
}
@@ -277,6 +316,9 @@
McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(editableQuestionEntry);
logger.debug("mcQueContent:" + mcQueContent);
+ Map mapOptionsContent= new TreeMap(new McComparator());
+ logger.debug("initialized mapOptionsContent:" + mapOptionsContent);
+
if (mcQueContent != null)
{
/** hold all he options for this question*/
@@ -297,7 +339,12 @@
}
else
{
- logger.debug("we are not supposed to reach here: error getting question content by question text.");
+ /** this is a new question content created by the user and has no options yet */
+ logger.debug("this is a new question content created by the user and has no options yet");
+ mapOptionsContent=(Map) request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT);
+ logger.debug("mapOptionsContent is the default options Map: " + mapOptionsContent);
+ request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ logger.debug("updated the Options Map with the default Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
}
return (mapping.findForward(EDIT_OPTS_CONTENT));
@@ -371,8 +418,148 @@
}
+
+ protected McContent createContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm)
+ {
+ IMcService mcService =McUtils.getToolService(request);
+
+ /** the tool content id is passed from the container to the tool and placed into session in the McStarterAction */
+ Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
+ if ((toolContentId != null) && (toolContentId.longValue() != 0))
+ {
+ logger.debug("passed TOOL_CONTENT_ID : " + toolContentId);
+ /**delete the existing content in the database before applying new content*/
+ mcService.deleteMcById(toolContentId);
+ logger.debug("post-deletion existing content");
+ }
+
+ String title;
+ String instructions;
+ Long createdBy;
+ String monitoringReportTitle="";
+ String reportTitle="";
+
+ String offlineInstructions="";
+ String onlineInstructions="";
+ String endLearningMessage="";
+ String creationDate="";
+ int passmark=0;
+
+ boolean isQuestionsSequenced=false;
+ boolean isSynchInMonitor=false;
+ boolean isUsernameVisible=false;
+ boolean isRunOffline=false;
+ boolean isDefineLater=false;
+ boolean isContentInUse=false;
+ boolean isRetries=false;
+ boolean isShowFeedback=false;
+
+
+ logger.debug("isQuestionsSequenced: " + mcAuthoringForm.getQuestionsSequenced());
+ if (mcAuthoringForm.getQuestionsSequenced().equalsIgnoreCase(ON))
+ isQuestionsSequenced=true;
+
+ logger.debug("isSynchInMonitor: " + mcAuthoringForm.getSynchInMonitor());
+ if (mcAuthoringForm.getSynchInMonitor().equalsIgnoreCase(ON))
+ isSynchInMonitor=true;
+
+ logger.debug("isUsernameVisible: " + mcAuthoringForm.getUsernameVisible());
+ if (mcAuthoringForm.getUsernameVisible().equalsIgnoreCase(ON))
+ isUsernameVisible=true;
+
+ logger.debug("isRetries: " + mcAuthoringForm.getRetries());
+ if (mcAuthoringForm.getRetries().equalsIgnoreCase(ON))
+ isRetries=true;
+
+ logger.debug("isShowFeedback: " + mcAuthoringForm.getShowFeedback());
+ if (mcAuthoringForm.getShowFeedback().equalsIgnoreCase(ON))
+ isShowFeedback=true;
+
+ logger.debug("MONITORING_REPORT_TITLE: " + mcAuthoringForm.getMonitoringReportTitle());
+ if (mcAuthoringForm.getMonitoringReportTitle() == null)
+ monitoringReportTitle=(String)request.getSession().getAttribute(MONITORING_REPORT_TITLE);
+
+ logger.debug("REPORT_TITLE: " + mcAuthoringForm.getReportTitle());
+ if (mcAuthoringForm.getReportTitle() == null)
+ reportTitle=(String)request.getSession().getAttribute(REPORT_TITLE);
+
+ logger.debug("OFFLINE_INSTRUCTIONS: " + mcAuthoringForm.getOfflineInstructions());
+ if (mcAuthoringForm.getOfflineInstructions() == null)
+ offlineInstructions=(String)request.getSession().getAttribute(OFFLINE_INSTRUCTIONS);
+
+ logger.debug("ONLINE_INSTRUCTIONS: " + mcAuthoringForm.getOnlineInstructions());
+ if (mcAuthoringForm.getOnlineInstructions() == null)
+ onlineInstructions=(String)request.getSession().getAttribute(ONLINE_INSTRUCTIONS);
+
+ logger.debug("END_LEARNING_MESSAGE: " + mcAuthoringForm.getEndLearningMessage());
+ 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";
+
+ instructions=mcAuthoringForm.getInstructions();
+ if (instructions == null)
+ instructions="dummy instructions";
+
+
+ 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();
+ //get back login user DTO
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ logger.debug("retrieving toolUser: " + toolUser);
+ logger.debug("retrieving toolUser userId: " + toolUser.getUserID());
+ String fullName= toolUser.getFirstName() + " " + toolUser.getLastName();
+ logger.debug("retrieving toolUser fullname: " + fullName);
+ long userId=toolUser.getUserID().longValue();
+ logger.debug("userId: " + userId);
+
+ /** 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.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*/
+ mc.setUsernameVisible(isUsernameVisible);
+ mc.setQuestionsSequenced(isQuestionsSequenced); /**the default question listing in learner mode will be all in the same page*/
+ mc.setOnlineInstructions(onlineInstructions);
+ mc.setOfflineInstructions(offlineInstructions);
+ mc.setRunOffline(false);
+ mc.setDefineLater(false);
+ mc.setSynchInMonitor(isSynchInMonitor);
+ mc.setEndLearningMessage(endLearningMessage);
+ mc.setReportTitle(reportTitle);
+ mc.setMonitoringReportTitle(monitoringReportTitle);
+ mc.setEndLearningMessage(endLearningMessage);
+ mc.setRetries(isRetries);
+ mc.setPassMark(new Integer(passmark));
+ mc.setShowFeedback(isShowFeedback);
+ mc.setMcQueContents(new TreeSet());
+ mc.setMcSessions(new TreeSet());
+ logger.debug("mc content :" + mc);
+
+ /**create the content in the db*/
+ mcService.createMc(mc);
+ logger.debug("mc created with content id: " + toolContentId);
+
+ return mc;
+ }
+
/**
* persists error messages to request scope
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java,v
diff -u -r1.6 -r1.7
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 14 Oct 2005 20:23:14 -0000 1.6
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 15 Oct 2005 15:21:56 -0000 1.7
@@ -68,6 +68,11 @@
/** advanced content */
protected String synchInMonitor;
+ protected String showFeedback;
+ protected String retries;
+ protected String passmark;
+
+
protected String reportTitle;
protected String monitoringReportTitle;
protected String endLearningMessage;
@@ -148,7 +153,10 @@
this.reportTitle=null;
this.monitoringReportTitle=null;
this.questionsSequenced=null;
-
+ this.showFeedback=null;
+ this.retries=null;
+ this.passmark=null;
+
this.summaryMonitoring=null;
this.instructionsMonitoring=null;
this.editActivityMonitoring=null;
@@ -662,4 +670,40 @@
public void setOptionIndex(String optionIndex) {
this.optionIndex = optionIndex;
}
+ /**
+ * @return Returns the retries.
+ */
+ public String getRetries() {
+ return retries;
+ }
+ /**
+ * @param retries The retries to set.
+ */
+ public void setRetries(String retries) {
+ this.retries = retries;
+ }
+ /**
+ * @return Returns the showFeedback.
+ */
+ public String getShowFeedback() {
+ return showFeedback;
+ }
+ /**
+ * @param showFeedback The showFeedback to set.
+ */
+ public void setShowFeedback(String showFeedback) {
+ this.showFeedback = showFeedback;
+ }
+ /**
+ * @return Returns the passmark.
+ */
+ public String getPassmark() {
+ return passmark;
+ }
+ /**
+ * @param passmark The passmark to set.
+ */
+ public void setPassmark(String passmark) {
+ this.passmark = passmark;
+ }
}
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.5 -r1.6
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 14 Oct 2005 20:23:14 -0000 1.5
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 15 Oct 2005 15:21:56 -0000 1.6
@@ -107,6 +107,7 @@
Map mapQuestionsContent= new TreeMap(new McComparator());
Map mapOptionsContent= new TreeMap(new McComparator());
+ Map mapDefaultOptionsContent= new TreeMap(new McComparator());
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
mcAuthoringForm.resetRadioBoxes();
@@ -178,8 +179,9 @@
/**
- * retrieve the default question content based on default content UID determined above
+ * retrieve uid of the default question content
*/
+ long queContentUID=0;
try
{
logger.debug("retrieve the default question content based on default content UID: " + contentId);
@@ -192,6 +194,8 @@
persistError(request,"error.defaultQuestionContent.notAvailable");
return (mapping.findForward(LOAD_QUESTIONS));
}
+ logger.debug("using mcQueContent uid: " + mcQueContent.getUid());
+ queContentUID=mcQueContent.getUid().longValue();
}
catch(Exception e)
{
@@ -201,7 +205,34 @@
return (mapping.findForward(LOAD_QUESTIONS));
}
+
/**
+ * retrieve default options content
+ */
+ try
+ {
+ logger.debug("retrieve the default options content based on default question content UID: " + queContentUID);
+ List list=mcService.findMcOptionsContentByQueId(new Long(queContentUID));
+ logger.debug("using options list: " + list);
+ if (list == null)
+ {
+ logger.debug("Exception occured: No default options content");
+ request.setAttribute(USER_EXCEPTION_DEFAULTOPTIONSCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultOptionsContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+ }
+ catch(Exception e)
+ {
+ logger.debug("Exception occured: No default options content");
+ request.setAttribute(USER_EXCEPTION_DEFAULTOPTIONSCONTENT_NOT_AVAILABLE, new Boolean(true));
+ persistError(request,"error.defaultOptionsContent.notAvailable");
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }
+
+
+
+ /**
* mark the http session as an authoring activity
*/
request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_AUTHORING);
@@ -227,7 +258,7 @@
{
toolContentId=new Long(strToolContentId).longValue();
logger.debug("passed TOOL_CONTENT_ID : " + toolContentId);
- request.getSession().setAttribute(TOOL_CONTENT_ID,strToolContentId);
+ request.getSession().setAttribute(TOOL_CONTENT_ID, new Long(strToolContentId));
}
catch(NumberFormatException e)
{
@@ -259,6 +290,26 @@
persistError(request,"error.defaultContent.notAvailable");
return (mapping.findForward(LOAD_QUESTIONS));
}
+
+ request.getSession().setAttribute(TITLE,mcContent.getTitle());
+ request.getSession().setAttribute(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()));
+ request.getSession().setAttribute(MONITORING_REPORT_TITLE,mcContent.getMonitoringReportTitle());
+ request.getSession().setAttribute(REPORT_TITLE,mcContent.getReportTitle());
+ request.getSession().setAttribute(RUN_OFFLINE, new Boolean(mcContent.isRunOffline()));
+ request.getSession().setAttribute(DEFINE_LATER, new Boolean(mcContent.isDefineLater()));
+ request.getSession().setAttribute(SYNCH_IN_MONITOR, new Boolean(mcContent.isSynchInMonitor()));
+ request.getSession().setAttribute(OFFLINE_INSTRUCTIONS,mcContent.getOfflineInstructions());
+ request.getSession().setAttribute(ONLINE_INSTRUCTIONS,mcContent.getOnlineInstructions());
+ request.getSession().setAttribute(END_LEARNING_MESSAGE,mcContent.getEndLearningMessage());
+ request.getSession().setAttribute(CONTENT_IN_USE, new Boolean(mcContent.isContentInUse()));
+ request.getSession().setAttribute(RETRIES, new Boolean(mcContent.isRetries()));
+ request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer
+ request.getSession().setAttribute(SHOW_FEEDBACK, new Boolean(mcContent.isShowFeedback()));
+
+
McUtils.setDefaultSessionAttributes(request, mcContent, mcAuthoringForm);
logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE));
logger.debug("getting default content");
@@ -272,6 +323,8 @@
mcAuthoringForm.setUsernameVisible(OFF);
mcAuthoringForm.setQuestionsSequenced(OFF);
mcAuthoringForm.setSynchInMonitor(OFF);
+ mcAuthoringForm.setRetries(OFF);
+ mcAuthoringForm.setShowFeedback(OFF);
/** collect options for the default question content into a Map*/
McQueContent mcQueContent=mcService.getToolDefaultQuestionContent(mcContent.getUid().longValue());
@@ -306,8 +359,10 @@
mapIndex=new Long(mapIndex.longValue()+1);
}
request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent);
+ mapDefaultOptionsContent=mapOptionsContent;
+ request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptionsContent);
logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
-
+ logger.debug("starter initialized the Default Options Map: " + request.getSession().getAttribute(MAP_DEFAULTOPTIONS_CONTENT));
}
else
{
Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/Attic/McDataAccessTestCase.java,v
diff -u -r1.12 -r1.13
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java 14 Oct 2005 20:23:15 -0000 1.12
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McDataAccessTestCase.java 15 Oct 2005 15:21:56 -0000 1.13
@@ -80,7 +80,6 @@
super.tearDown();
}
- /*
public void testInitDB()
{
@@ -110,24 +109,23 @@
McContent mcContent = mcContentDAO.findMcContentById(DEFAULT_CONTENT_ID);
McQueContent mcQueContent= new McQueContent("A sample question",
- new Integer(444),
+ new Integer(1),
mcContent,
new HashSet(),
new HashSet()
);
mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent);
-
McQueContent mcQueContent1 = mcQueContentDAO.getMcQueContentByUID(new Long(1));
- McOptsContent mcOptionsContent= new McOptsContent(new Long(777), true, "sample answer 1", mcQueContent1, new HashSet());
+ McOptsContent mcOptionsContent= new McOptsContent( true, "sample answer 1", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent);
- McOptsContent mcOptionsContent2= new McOptsContent(new Long(888), false, "sample answer 2", mcQueContent1, new HashSet());
+ McOptsContent mcOptionsContent2= new McOptsContent(false, "sample answer 2", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent2);
- McOptsContent mcOptionsContent3= new McOptsContent(new Long(999), false, "sample answer 3", mcQueContent1, new HashSet());
+ McOptsContent mcOptionsContent3= new McOptsContent(false, "sample answer 3", mcQueContent1, new HashSet());
mcOptionsContentDAO.saveMcOptionsContent(mcOptionsContent3);
- }
-*/
+ }
}
+
Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/Attic/TestMcQueContent.java,v
diff -u -r1.7 -r1.8
--- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java 14 Oct 2005 20:23:15 -0000 1.7
+++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/TestMcQueContent.java 15 Oct 2005 15:21:56 -0000 1.8
@@ -91,21 +91,36 @@
}
*/
- /*
+
public void testGetToolDefaultQuestionContent()
{
McQueContent mcQueContent = mcQueContentDAO.getToolDefaultQuestionContent(new Long(1).longValue());
System.out.print("mcQueContent:" + mcQueContent);
}
- */
+ /*
+ public void testCreateSampleQuestionContent()
+ {
+ McContent mcContent = mcContentDAO.findMcContentById(DEFAULT_CONTENT_ID);
+ System.out.print("mcContent:" + mcContent);
+
+ McQueContent mcQueContent= new McQueContent("A sample question",
+ new Integer(1),
+ mcContent,
+ new HashSet(),
+ new HashSet()
+ );
+ mcQueContentDAO.saveOrUpdateMcQueContent(mcQueContent);
+ }
+ */
+
+ /*
public void testGetQuestionContentByQuestionText()
{
McQueContent mcQueContent = mcQueContentDAO.getQuestionContentByQuestionText("A sample question");
System.out.print("mcQueContent:" + mcQueContent);
}
-
-
-
+ */
+
}
\ No newline at end of file