Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java,v
diff -u -r1.24 -r1.25
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 15 Dec 2005 08:02:52 -0000 1.24
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 5 Jan 2006 04:36:32 -0000 1.25
@@ -27,7 +27,7 @@
* temporarily refers to an existing content id for an incoming tool session id, won't need it in deployment environment
*/
public static final long THE_MOCKED_CONTENT_ID =1803739427456570536L;
- public static final String TOOL_SERVICE ="tool_service";
+// public static final String TOOL_SERVICE ="tool_service";
/*
* indicates which mode the tool runs under between Authoring, Learning, Monitoring
*/
@@ -232,7 +232,7 @@
// public static final String FORM_INDEX ="formIndex";
public static final String RENDER_MONITORING_EDITACTIVITY ="renderMonitoringEditActivity";
public static final String NO_AVAILABLE_SESSIONS ="noAvailableSessions";
- public static final String INITIAL_MONITORING_TOOL_CONTENT_ID ="initialMonitoringToolContentId";
+// public static final String INITIAL_MONITORING_TOOL_CONTENT_ID ="initialMonitoringToolContentId";
public static final String IS_MONITORING_DEFINE_LATER ="isMonitoringDefineLater";
public static final String NO_TOOL_SESSIONS_AVAILABLE ="noToolSessionAvailable";
public static final String ORIGINAL_TOOL_SESSIONS ="originalToolSessions";
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/Attic/QaUtils.java,v
diff -u -r1.20 -r1.21
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 15 Dec 2005 08:02:52 -0000 1.20
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 5 Jan 2006 04:36:32 -0000 1.21
@@ -63,11 +63,11 @@
public abstract class QaUtils implements QaAppConstants {
static Logger logger = Logger.getLogger(QaUtils.class.getName());
- public static IQaService getToolService(HttpServletRequest request)
- {
- IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
- return qaService;
- }
+// public static IQaService getToolService(HttpServletRequest request)
+// {
+// IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+// return qaService;
+// }
public static long generateId()
{
@@ -140,7 +140,7 @@
request.getSession().removeAttribute(CHECK_ALL_SESSIONS_COMPLETED);
request.getSession().removeAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
request.getSession().removeAttribute(ATTR_USERDATA);
- request.getSession().removeAttribute(TOOL_SERVICE);
+// request.getSession().removeAttribute(TOOL_SERVICE);
request.getSession().removeAttribute(TARGET_MODE);
}
@@ -318,10 +318,8 @@
* @return boolean
* determine whether a specific toolContentId exists in the db
*/
- public static boolean existsContent(long toolContentId, HttpServletRequest request)
- {
- IQaService qaService =QaUtils.getToolService(request);
-
+ public static boolean existsContent(long toolContentId, IQaService qaService)
+ {
QaContent qaContent=qaService.loadQa(toolContentId);
logger.debug(logger + " " + "QaUtils " + "retrieving qaContent: " + qaContent);
if (qaContent == null)
@@ -336,10 +334,9 @@
* @param toolSessionId
* @return boolean
*/
- public static boolean existsSession(long toolSessionId, HttpServletRequest request)
+ public static boolean existsSession(long toolSessionId, IQaService qaService)
{
logger.debug("existsSession");
- IQaService qaService =QaUtils.getToolService(request);
QaSession qaSession=qaService.retrieveQaSessionOrNullById(toolSessionId);
logger.debug("qaSession:" + qaSession);
@@ -405,15 +402,15 @@
}
- public static void configureContentRepository(HttpServletRequest request)
- {
- logger.debug("attempt configureContentRepository");
- IQaService qaService =QaUtils.getToolService(request);
- logger.debug("retrieving qaService from session: " + qaService);
- logger.debug("calling configureContentRepository()");
- qaService.configureContentRepository();
- logger.debug("configureContentRepository ran successfully");
- }
+// public static void configureContentRepository(HttpServletRequest request)
+// {
+// logger.debug("attempt configureContentRepository");
+// IQaService qaService =QaUtils.getToolService(request);
+// logger.debug("retrieving qaService from session: " + qaService);
+// logger.debug("calling configureContentRepository()");
+// qaService.configureContentRepository();
+// logger.debug("configureContentRepository ran successfully");
+// }
public static void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, boolean isOfflineFile)
@@ -783,9 +780,8 @@
// }
- public static void populateUploadedFilesData(HttpServletRequest request, QaContent defaultQaContent) {
- IQaService qaService =QaUtils.getToolService(request);
- List attachmentList = qaService.retrieveQaUploadedFiles(defaultQaContent);
+ public static void populateUploadedFilesData(HttpServletRequest request, QaContent qaContent, IQaService qaService) {
+ List attachmentList = qaService.retrieveQaUploadedFiles(qaContent);
request.getSession().setAttribute(ATTACHMENT_LIST, attachmentList);
if(request.getSession().getAttribute(DELETED_ATTACHMENT_LIST)==null)
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java,v
diff -u -r1.20 -r1.21
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 15 Dec 2005 08:02:52 -0000 1.20
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 5 Jan 2006 04:36:32 -0000 1.21
@@ -30,6 +30,7 @@
import org.lamsfoundation.lams.tool.qa.QaUploadedFile;
import org.lamsfoundation.lams.tool.qa.QaUtils;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
@@ -44,6 +45,7 @@
*/
public class AuthoringUtil implements QaAppConstants {
static Logger logger = Logger.getLogger(AuthoringUtil.class.getName());
+
/**
* reconstructQuestionContentMapForAdd(TreeMap mapQuestionContent, HttpServletRequest request)
@@ -479,10 +481,9 @@
// }
//doesn't update files
- public QaContent saveOrUpdateQaContent(Map mapQuestionContent, HttpServletRequest request, QaAuthoringForm qaAuthoringForm){
+ public QaContent saveOrUpdateQaContent(Map mapQuestionContent, IQaService qaService, QaAuthoringForm qaAuthoringForm){
UserDTO toolUser = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);//request.getSession().getAttribute(AttributeNames.USER);
- IQaService qaService =QaUtils.getToolService(request);
boolean isQuestionsSequenced=false;
boolean isSynchInMonitor=false;
@@ -534,7 +535,7 @@
qaService.updateQa(qa);
//recreate all question contents
- createQuestionContent(mapQuestionContent, request, qa);
+ createQuestionContent(mapQuestionContent, qaService, qa);
return qa;
}
@@ -545,10 +546,8 @@
*
* persist the questions in the Map the user has submitted
*/
- protected void createQuestionContent(Map mapQuestionContent, HttpServletRequest request, QaContent qaContent)
- {
- IQaService qaService =QaUtils.getToolService(request);
-
+ protected void createQuestionContent(Map mapQuestionContent, IQaService qaService, QaContent qaContent)
+ {
Iterator itMap = mapQuestionContent.entrySet().iterator();
int diplayOrder=0;
while (itMap.hasNext())
@@ -609,59 +608,59 @@
// }
// }
- /**
- * Normally, a request to set runOffline property of the content comes directly from container through the property inspector.
- * What we do below is simulate that for development purposes.
- * @param request
- */
-
- public void simulatePropertyInspector_RunOffline(HttpServletRequest request)
- {
- IQaService qaService =QaUtils.getToolService(request);
-
- String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
- if ((toolContentId != null) && (!toolContentId.equals("")))
- {
- logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId));
- try
- {
- qaService.setAsRunOffline(new Long(toolContentId));
- }
- catch(ToolException e)
- {
- logger.debug("we should never come here");
- }
-
- logger.debug("post-RunAsOffline");
- }
- logger.debug("end of simulating RunOffline on content id: " + toolContentId);
- }
+// /**
+// * Normally, a request to set runOffline property of the content comes directly from container through the property inspector.
+// * What we do below is simulate that for development purposes.
+// * @param request
+// */
+//
+// public void simulatePropertyInspector_RunOffline(HttpServletRequest request)
+// {
+// IQaService qaService =QaUtils.getToolService(request);
+//
+// String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+// if ((toolContentId != null) && (!toolContentId.equals("")))
+// {
+// logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+// try
+// {
+// qaService.setAsRunOffline(new Long(toolContentId));
+// }
+// catch(ToolException e)
+// {
+// logger.debug("we should never come here");
+// }
+//
+// logger.debug("post-RunAsOffline");
+// }
+// logger.debug("end of simulating RunOffline on content id: " + toolContentId);
+// }
+//
+// /**
+// * Normally, a request to set defineLaterproperty of the content comes directly from container through the property inspector.
+// * What we do below is simulate that for development purposes.
+// * @param request
+// */
+// public void simulatePropertyInspector_setAsDefineLater(HttpServletRequest request)
+// {
+// IQaService qaService =QaUtils.getToolService(request);
+//
+// String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+// if ((toolContentId != null) && (!toolContentId.equals("")))
+// {
+// logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+// try
+// {
+// qaService.setAsDefineLater(new Long(toolContentId));
+// }
+// catch(ToolException e)
+// {
+// logger.debug("we should never come here");
+// }
+//
+// logger.debug("post-setAsDefineLater");
+// }
+// logger.debug("end of simulating setAsDefineLater on content id: " + toolContentId);
+// }
- /**
- * Normally, a request to set defineLaterproperty of the content comes directly from container through the property inspector.
- * What we do below is simulate that for development purposes.
- * @param request
- */
- public void simulatePropertyInspector_setAsDefineLater(HttpServletRequest request)
- {
- IQaService qaService =QaUtils.getToolService(request);
-
- String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
- if ((toolContentId != null) && (!toolContentId.equals("")))
- {
- logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId));
- try
- {
- qaService.setAsDefineLater(new Long(toolContentId));
- }
- catch(ToolException e)
- {
- logger.debug("we should never come here");
- }
-
- logger.debug("post-setAsDefineLater");
- }
- logger.debug("end of simulating setAsDefineLater on content id: " + toolContentId);
- }
-
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java,v
diff -u -r1.14 -r1.15
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 6 Dec 2005 00:32:38 -0000 1.14
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/LearningUtil.java 5 Jan 2006 04:36:32 -0000 1.15
@@ -8,6 +8,7 @@
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -40,109 +41,109 @@
public class LearningUtil implements QaAppConstants{
static Logger logger = Logger.getLogger(LearningUtil.class.getName());
- /**
- * NEVER USED: redundant method.
- * deleteSessionUsersAndResponses(HttpServletRequest request)
- * @param request
- */
- protected void deleteSessionUsersAndResponses(HttpServletRequest request)
- {
- IQaService qaService =QaUtils.getToolService(request);
- /*
- * retrive contentId from the http session
- */
- logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID));
- Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
- QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
-
- logger.debug("retrieving qaContent: " + qaContent);
- Iterator sessionIterator=qaContent.getQaSessions().iterator();
- while (sessionIterator.hasNext())
- {
- QaSession qaSession=(QaSession)sessionIterator.next();
- logger.debug("iterated qaSession : " + qaSession);
-
- Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator();
- while (sessionUsersIterator.hasNext())
- {
- QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next();
- logger.debug("iterated qaQueUsr : " + qaQueUsr);
-
- Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator();
- while (sessionUsersResponsesIterator.hasNext())
- {
- QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next();
- logger.debug("iterated qaUsrResp : " + qaUsrResp);
- qaService.removeUserResponse(qaUsrResp);
- logger.debug("removed qaUsrResp : " + qaUsrResp);
- }
- }
- }
- logger.debug("end of deleteSessionUsersAndResponses()");
- }
+// /**
+// * NEVER USED: redundant method.
+// * deleteSessionUsersAndResponses(HttpServletRequest request)
+// * @param request
+// */
+// protected void deleteSessionUsersAndResponses(HttpServletRequest request)
+// {
+// IQaService qaService =QaUtils.getToolService(request);
+// /*
+// * retrive contentId from the http session
+// */
+// logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID));
+// Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+// QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
+//
+// logger.debug("retrieving qaContent: " + qaContent);
+// Iterator sessionIterator=qaContent.getQaSessions().iterator();
+// while (sessionIterator.hasNext())
+// {
+// QaSession qaSession=(QaSession)sessionIterator.next();
+// logger.debug("iterated qaSession : " + qaSession);
+//
+// Iterator sessionUsersIterator=qaSession.getQaQueUsers().iterator();
+// while (sessionUsersIterator.hasNext())
+// {
+// QaQueUsr qaQueUsr=(QaQueUsr) sessionUsersIterator.next();
+// logger.debug("iterated qaQueUsr : " + qaQueUsr);
+//
+// Iterator sessionUsersResponsesIterator=qaQueUsr.getQaUsrResps().iterator();
+// while (sessionUsersResponsesIterator.hasNext())
+// {
+// QaUsrResp qaUsrResp=(QaUsrResp)sessionUsersResponsesIterator.next();
+// logger.debug("iterated qaUsrResp : " + qaUsrResp);
+// qaService.removeUserResponse(qaUsrResp);
+// logger.debug("removed qaUsrResp : " + qaUsrResp);
+// }
+// }
+// }
+// logger.debug("end of deleteSessionUsersAndResponses()");
+// }
+//
+//
+// /**
+// * NEVER USED: redundant method.
+// * deletes the user of a particular question content and her responses
+// * deleteExistingUsersAndResponses(HttpServletRequest request)
+// *
+// * return void
+// * @param request
+// */
+// protected void deleteExistingUsersAndResponses(HttpServletRequest request)
+// {
+// IQaService qaService =QaUtils.getToolService(request);
+// /*
+// * retrive contentId from the http session
+// */
+// logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID));
+// Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+// QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
+//
+// logger.debug("retrieving qaContent: " + qaContent);
+//
+// Iterator contentIterator=qaContent.getQaQueContents().iterator();
+// while (contentIterator.hasNext())
+// {
+// QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
+// logger.debug("retrieving qaQueContent: " + qaQueContent);
+// if (qaQueContent != null)
+// {
+// Set qaQueUsers=qaQueContent.getQaQueUsers();
+// logger.debug("qaQueUsers size: " + qaQueUsers.size());
+// /*
+// * iterate users and delete them
+// */
+// Iterator usersIterator=qaQueUsers.iterator();
+// while (usersIterator.hasNext())
+// {
+// QaQueUsr qaQueUsr=(QaQueUsr) usersIterator.next();
+// logger.debug("retrieving qaQueUsr: " + qaQueUsr);
+// if (qaQueUsr != null)
+// {
+// Set qaUsrResps=qaQueUsr.getQaUsrResps();
+// logger.debug("retrieving user's all responses : " + qaUsrResps);
+// Iterator responsesIterator=qaUsrResps.iterator();
+// while (responsesIterator.hasNext())
+// {
+// QaUsrResp qaUsrResp=(QaUsrResp)responsesIterator.next();
+// if (qaUsrResp != null)
+// {
+// logger.debug("retrieving qaUsrResp: " + qaUsrResp);
+// qaService.removeUserResponse(qaUsrResp);
+// logger.debug("removed qaUsrResp with id:" + qaUsrResp.getResponseId());
+// }
+// }
+// qaService.deleteQaQueUsr(qaQueUsr);
+// logger.debug("deleted user: " + qaQueUsr);
+// }
+// }
+// }
+// }
+// logger.debug("end of deleteExistingUsersAndResponses()");
+// }
-
- /**
- * NEVER USED: redundant method.
- * deletes the user of a particular question content and her responses
- * deleteExistingUsersAndResponses(HttpServletRequest request)
- *
- * return void
- * @param request
- */
- protected void deleteExistingUsersAndResponses(HttpServletRequest request)
- {
- IQaService qaService =QaUtils.getToolService(request);
- /*
- * retrive contentId from the http session
- */
- logger.debug("attempt retrieving toolContentId: " + request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID));
- Long toolContentId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
- QaContent qaContent=qaService.retrieveQa(toolContentId.longValue());
-
- logger.debug("retrieving qaContent: " + qaContent);
-
- Iterator contentIterator=qaContent.getQaQueContents().iterator();
- while (contentIterator.hasNext())
- {
- QaQueContent qaQueContent=(QaQueContent)contentIterator.next();
- logger.debug("retrieving qaQueContent: " + qaQueContent);
- if (qaQueContent != null)
- {
- Set qaQueUsers=qaQueContent.getQaQueUsers();
- logger.debug("qaQueUsers size: " + qaQueUsers.size());
- /*
- * iterate users and delete them
- */
- Iterator usersIterator=qaQueUsers.iterator();
- while (usersIterator.hasNext())
- {
- QaQueUsr qaQueUsr=(QaQueUsr) usersIterator.next();
- logger.debug("retrieving qaQueUsr: " + qaQueUsr);
- if (qaQueUsr != null)
- {
- Set qaUsrResps=qaQueUsr.getQaUsrResps();
- logger.debug("retrieving user's all responses : " + qaUsrResps);
- Iterator responsesIterator=qaUsrResps.iterator();
- while (responsesIterator.hasNext())
- {
- QaUsrResp qaUsrResp=(QaUsrResp)responsesIterator.next();
- if (qaUsrResp != null)
- {
- logger.debug("retrieving qaUsrResp: " + qaUsrResp);
- qaService.removeUserResponse(qaUsrResp);
- logger.debug("removed qaUsrResp with id:" + qaUsrResp.getResponseId());
- }
- }
- qaService.deleteQaQueUsr(qaQueUsr);
- logger.debug("deleted user: " + qaQueUsr);
- }
- }
- }
- }
- logger.debug("end of deleteExistingUsersAndResponses()");
- }
-
/**
* createUsersAndResponses(Map mapAnswers, HttpServletRequest request)
@@ -151,9 +152,8 @@
* return void
*
*/
- protected void createUsersAndResponses(Map mapAnswers, HttpServletRequest request)
+ protected void createUsersAndResponses(Map mapAnswers, HttpServletRequest request, IQaService qaService)
{
- IQaService qaService =QaUtils.getToolService(request);
logger.debug("createUsers-retrieving qaService: " + qaService);
HttpSession ss = SessionManager.getSession();
@@ -260,10 +260,8 @@
* return void
*
*/
- protected void buidLearnerReport(HttpServletRequest request, int toolSessionIdCounter)
- {
- IQaService qaService =QaUtils.getToolService(request);
-
+ protected void buidLearnerReport(HttpServletRequest request, int toolSessionIdCounter, IQaService qaService)
+ {
/*
* find out the current tool session
*/
@@ -289,8 +287,19 @@
QaContent qaContent=qaService.loadQa(toolContentId.longValue());
logger.debug("retrieve qaContent: " + qaContent);
- Iterator contentIterator=qaContent.getQaQueContents().iterator();
- logger.debug("content iteration count: " + qaContent.getQaQueContents().size());
+ /*
+ * Reason for commentting the line below. When the user response is updated in monitor
+ * qaContent.getQaQueContents() would failed for some reason. Hence I've created a new
+ * method retrieveQaQueContentsByToolContentId() to work around this problem. I'm not
+ * sure why qaContent.getQaQueContents() fails but I assume it's a transation problem.
+ *
+ * Anthony
+ */
+ //Set qaQueContents = qaContent.getQaQueContents();
+ List qaQueContents = qaService.retrieveQaQueContentsByToolContentId(toolContentId.longValue());
+ Iterator contentIterator=qaQueContents.iterator();
+
+ logger.debug("content iteration count: " + qaQueContents.size());
int questionIndex=0;
/*
@@ -585,12 +594,9 @@
request.getSession().setAttribute(USER_FEEDBACK, userFeedback);
}
- public void lockContent(HttpServletRequest request)
+ public void lockContent(long toolContentId, IQaService qaService)
{
- IQaService qaService =QaUtils.getToolService(request);
- Long toolContentId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
- logger.debug("current toolContentId: " + toolContentId);
- QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ QaContent qaContent=qaService.loadQa(toolContentId);
logger.debug("retrieve qaContent: " + qaContent);
qaContent.setContentLocked(true);
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/MonitoringUtil.java,v
diff -u -r1.9 -r1.10
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 6 Dec 2005 00:32:38 -0000 1.9
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/MonitoringUtil.java 5 Jan 2006 04:36:32 -0000 1.10
@@ -31,13 +31,8 @@
* @param toolContentId
* @return boolean
*/
- public boolean isSessionsSync(HttpServletRequest request, long toolContentId)
+ public boolean isSessionsSync(QaContent qaContent)
{
- logger.debug("start of isSessionsSync with toolContentId: " + toolContentId);
- IQaService qaService =QaUtils.getToolService(request);
-
- QaContent qaContent =qaService.loadQa(toolContentId);
- logger.debug("retrieving qaContent: " + qaContent);
/*
* iterate all the tool sessions, if even one session is INCOMPLETE, the function returns false
@@ -80,137 +75,137 @@
request.getSession().removeAttribute(CHECK_ALL_SESSIONS_COMPLETED);
request.getSession().removeAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
request.getSession().removeAttribute(ATTR_USERDATA);
- request.getSession().removeAttribute(TOOL_SERVICE);
+// request.getSession().removeAttribute(TOOL_SERVICE);
request.getSession().removeAttribute(TARGET_MODE);
}
-
- /**
- * startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) throws ToolException
- *
- * @param qaMonitoringForm
- * @param request
- * @throws ToolException
- */
- public void startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) throws ToolException
- {
- IQaService qaService=QaUtils.getToolService(request);
-
- String strFromToolContentId="";
- String strToToolContentId="";
-
- qaMonitoringForm.resetUserAction();
- /*
- * In deployment, we won't be passing FROM_TOOL_CONTENT_ID, TO_TOOL_CONTENT_ID and TOOL_SESSION_ID from url
- * the Monitoring Service bean calls:
- * copyToolContent(Long fromContentId, Long toContentId)
- */
- strFromToolContentId=request.getParameter(FROM_TOOL_CONTENT_ID);
- logger.debug("startLesson" + "FROM_TOOL_CONTENT_ID: " + strFromToolContentId);
- if (strFromToolContentId == null)
- {
- throw new QaApplicationException("Exception occured: " +
- "Tool expects a legitimate FROM_TOOL_CONTENT_ID from the container. Can't continue!");
- }
-
- strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
- logger.debug("startLesson" + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
- if (strToToolContentId == null)
- {
- throw new QaApplicationException("Exception occured: " +
- "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
- }
-
- try
- {
- qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId));
- }
- catch(ToolException e)
- {
- logger.debug("exception copying content.");
- throw e;
- }
-
- /* calls to these two methods will be made from Monitoring Service bean optionally depending on
- * the the tool is setup for DefineLater and (or) RunOffline
- */
-
- /*
- * TESTED to work
- * qaService.setAsDefineLater(new Long(strToToolContentId));
- qaService.setAsRunOffline(new Long(strToToolContentId));
- *
- */
- qaMonitoringForm.resetUserAction();
- }
+//
+// /**
+// * startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) throws ToolException
+// *
+// * @param qaMonitoringForm
+// * @param request
+// * @throws ToolException
+// */
+// public void startLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request) throws ToolException
+// {
+// IQaService qaService=QaUtils.getToolService(request);
+//
+// String strFromToolContentId="";
+// String strToToolContentId="";
+//
+// qaMonitoringForm.resetUserAction();
+// /*
+// * In deployment, we won't be passing FROM_TOOL_CONTENT_ID, TO_TOOL_CONTENT_ID and TOOL_SESSION_ID from url
+// * the Monitoring Service bean calls:
+// * copyToolContent(Long fromContentId, Long toContentId)
+// */
+// strFromToolContentId=request.getParameter(FROM_TOOL_CONTENT_ID);
+// logger.debug("startLesson" + "FROM_TOOL_CONTENT_ID: " + strFromToolContentId);
+// if (strFromToolContentId == null)
+// {
+// throw new QaApplicationException("Exception occured: " +
+// "Tool expects a legitimate FROM_TOOL_CONTENT_ID from the container. Can't continue!");
+// }
+//
+// strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+// logger.debug("startLesson" + "TO_TOOL_CONTENT_ID: " + strToToolContentId);
+// if (strToToolContentId == null)
+// {
+// throw new QaApplicationException("Exception occured: " +
+// "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+// }
+//
+// try
+// {
+// qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId));
+// }
+// catch(ToolException e)
+// {
+// logger.debug("exception copying content.");
+// throw e;
+// }
+//
+// /* calls to these two methods will be made from Monitoring Service bean optionally depending on
+// * the the tool is setup for DefineLater and (or) RunOffline
+// */
+//
+// /*
+// * TESTED to work
+// * qaService.setAsDefineLater(new Long(strToToolContentId));
+// qaService.setAsRunOffline(new Long(strToToolContentId));
+// *
+// */
+// qaMonitoringForm.resetUserAction();
+// }
+//
+// /**
+// * deleteLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+// * @param qaMonitoringForm
+// * @param request
+// */
+// public void deleteLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+// {
+// IQaService qaService=QaUtils.getToolService(request);
+//
+// String strFromToolContentId="";
+// String strToToolContentId="";
+//
+// qaMonitoringForm.resetUserAction();
+//
+// /*
+// * TESTED to work
+// */
+// strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+// logger.debug("TO_TOOL_CONTENT_ID: " + strToToolContentId);
+// if (strToToolContentId == null)
+// {
+// throw new QaApplicationException("Exception occured: " +
+// "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+// }
+// qaService.removeToolContent(new Long(strToToolContentId));
+// qaMonitoringForm.resetUserAction();
+// }
+//
+//
+// /**
+// * forceComplete(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+// * @param qaMonitoringForm
+// * @param request
+// */
+// public void forceComplete(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
+// {
+// IQaService qaService=QaUtils.getToolService(request);
+// /*
+// * Parameter: userId
+// */
+// qaMonitoringForm.resetUserAction();
+// logger.debug("request for forceComplete");
+// String userId=request.getParameter(MONITOR_USER_ID);
+// logger.debug("MONITOR_USER_ID: " + userId);
+// qaService.setAsForceComplete(new Long(userId));
+// logger.debug("end of setAsForceComplete with userId: " + userId);
+// }
+//
+// /**
+// * boolean isDefaultMonitoringScreen(QaMonitoringForm qaMonitoringForm)
+// * @param qaMonitoringForm
+// * @return boolean
+// */
+// public boolean isDefaultMonitoringScreen(QaMonitoringForm qaMonitoringForm)
+// {
+// if ((qaMonitoringForm.getSummary() == null) &&
+// (qaMonitoringForm.getInstructions() == null) &&
+// (qaMonitoringForm.getEditActivity() == null) &&
+// (qaMonitoringForm.getStats() == null))
+// {
+// qaMonitoringForm.setSummary("summary");
+// return true;
+// }
+// return false;
+// }
- /**
- * deleteLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
- * @param qaMonitoringForm
- * @param request
- */
- public void deleteLesson(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
- {
- IQaService qaService=QaUtils.getToolService(request);
-
- String strFromToolContentId="";
- String strToToolContentId="";
-
- qaMonitoringForm.resetUserAction();
-
- /*
- * TESTED to work
- */
- strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
- logger.debug("TO_TOOL_CONTENT_ID: " + strToToolContentId);
- if (strToToolContentId == null)
- {
- throw new QaApplicationException("Exception occured: " +
- "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
- }
- qaService.removeToolContent(new Long(strToToolContentId));
- qaMonitoringForm.resetUserAction();
- }
-
/**
- * forceComplete(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
- * @param qaMonitoringForm
- * @param request
- */
- public void forceComplete(QaMonitoringForm qaMonitoringForm, HttpServletRequest request)
- {
- IQaService qaService=QaUtils.getToolService(request);
- /*
- * Parameter: userId
- */
- qaMonitoringForm.resetUserAction();
- logger.debug("request for forceComplete");
- String userId=request.getParameter(MONITOR_USER_ID);
- logger.debug("MONITOR_USER_ID: " + userId);
- qaService.setAsForceComplete(new Long(userId));
- logger.debug("end of setAsForceComplete with userId: " + userId);
- }
-
- /**
- * boolean isDefaultMonitoringScreen(QaMonitoringForm qaMonitoringForm)
- * @param qaMonitoringForm
- * @return boolean
- */
- public boolean isDefaultMonitoringScreen(QaMonitoringForm qaMonitoringForm)
- {
- if ((qaMonitoringForm.getSummary() == null) &&
- (qaMonitoringForm.getInstructions() == null) &&
- (qaMonitoringForm.getEditActivity() == null) &&
- (qaMonitoringForm.getStats() == null))
- {
- qaMonitoringForm.setSummary("summary");
- return true;
- }
- return false;
- }
-
-
- /**
* findSelectedMonitoringTab(ActionForm form,
* HttpServletRequest request)
* return void
@@ -286,14 +281,12 @@
/**
* updateResponse(HttpServletRequest request, String responseId, String updatedResponse)
- * @param request
+ * @param qaService
* @param responseId
* @param updatedResponse
*/
- public void updateResponse(HttpServletRequest request, String responseId, String updatedResponse)
- {
- IQaService qaService=QaUtils.getToolService(request);
-
+ public void updateResponse(IQaService qaService, String responseId, String updatedResponse)
+ {
logger.debug("load response with responseId: " + new Long(responseId).longValue());
QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
logger.debug("loaded user response: " + qaUsrResp);
@@ -304,13 +297,11 @@
/**
* hideResponse(HttpServletRequest request, String responseId)
- * @param request
+ * @param qaService
* @param responseId
*/
- public void hideResponse(HttpServletRequest request, String responseId)
+ public void hideResponse(IQaService qaService, String responseId)
{
- IQaService qaService=QaUtils.getToolService(request);
-
logger.debug("load response with responseId for hiding: " + new Long(responseId).longValue());
QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
logger.debug("loaded user response: " + qaUsrResp);
@@ -324,10 +315,8 @@
* @param request
* @param responseId
*/
- public void unHideResponse(HttpServletRequest request, String responseId)
+ public void unHideResponse(IQaService qaService, String responseId)
{
- IQaService qaService=QaUtils.getToolService(request);
-
logger.debug("load response with responseId for un-hiding: " + new Long(responseId).longValue());
QaUsrResp qaUsrResp=qaService.retrieveQaUsrResp(new Long(responseId).longValue());
logger.debug("loaded user response: " + qaUsrResp);
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QAction.java,v
diff -u -r1.19 -r1.20
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 15 Dec 2005 08:02:52 -0000 1.19
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 5 Jan 2006 04:36:32 -0000 1.20
@@ -39,7 +39,6 @@
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.apache.struts.upload.FormFile;
import org.lamsfoundation.lams.contentrepository.NodeKey;
import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException;
@@ -50,6 +49,7 @@
import org.lamsfoundation.lams.tool.qa.QaUploadedFile;
import org.lamsfoundation.lams.tool.qa.QaUtils;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
+import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
import org.lamsfoundation.lams.tool.qa.util.QaToolContentHandler;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.WebUtil;
@@ -385,7 +385,7 @@
public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
- IQaService qaService =QaUtils.getToolService(request);
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
AuthoringUtil authoringUtil= new AuthoringUtil();
Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT);
@@ -423,7 +423,7 @@
/*delete-recreate the questions in the db*/
authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request);
- QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, request, qaAuthoringForm);
+ QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, qaService, qaAuthoringForm);
saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request);
@@ -651,6 +651,7 @@
LearningUtil learningUtil= new LearningUtil();
QaLearningForm qaLearningForm = (QaLearningForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
/*retrieve the default question content map*/
Map mapQuestions=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER);
@@ -714,13 +715,13 @@
{
logger.debug(logger + " " + this.getClass().getName() + "submit the responses: " + mapAnswers);
/*recreate the users and responses*/
- learningUtil.createUsersAndResponses(mapAnswers, request);
+ learningUtil.createUsersAndResponses(mapAnswers, request, qaService);
qaLearningForm.resetUserActions();
qaLearningForm.setSubmitAnswersContent(null);
/*start generating a report for the Learner*/
- learningUtil.buidLearnerReport(request,1);
-
- learningUtil.lockContent(request);
+ learningUtil.buidLearnerReport(request,1, qaService);
+ Long toolContentId=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ learningUtil.lockContent(toolContentId.longValue(), qaService);
logger.debug("content has been locked");
return (mapping.findForward(LEARNER_REPORT));
}
@@ -741,7 +742,6 @@
logger.debug("simulating container behaviour by calling " +
"leaveToolSession() with toolSessionId: " + toolSessionId + " and user: " + user);
- IQaService qaService =QaUtils.getToolService(request);
String nextActivityUrl = qaService.leaveToolSession(toolSessionId, new Long(user.getUserID().longValue()));
response.sendRedirect(nextActivityUrl);
return null;
@@ -757,83 +757,83 @@
}
- /**
- * used to load Monitoring tabs back once the controller moves to Edit Activity.
- *
- * ActionForward loadMonitoring(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
-
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward loadMonitoring(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
-
- if (qaAuthoringForm.getSummaryMonitoring() != null)
- {
- logger.debug("request for getSummaryMonitoring, start proxying...");
- logger.debug("NO_AVAILABLE_SESSIONS: " + request.getSession().getAttribute(NO_AVAILABLE_SESSIONS));
-
- Boolean noAvailableSessions=(Boolean)request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
- logger.debug("NO_AVAILABLE_SESSIONS: " +noAvailableSessions);
- qaAuthoringForm.resetUserAction();
- if ((noAvailableSessions != null) && (noAvailableSessions.booleanValue()))
- {
- persistError(request,"error.noStudentActivity");
- request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
- request.setAttribute(STOP_RENDERING_QUESTIONS, new Boolean(true));
- return (mapping.findForward(LOAD));
- }
- else
- {
- logger.debug("NO_AVAILABLE_SESSIONS: " +false);
- QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
- QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
- return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
- }
- }
- else if (qaAuthoringForm.getInstructionsMonitoring() != null)
- {
- logger.debug("QAction- request for getInstructionsMonitoring()");
- qaAuthoringForm.resetUserAction();
- QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
- QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
- qaMonitoringForm.setInstructions("instructions");
- return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
- }
- else if (qaAuthoringForm.getEditActivityMonitoring() != null)
- {
- logger.debug("QAction-request for getEditActivityMonitoring()");
- QaStarterAction qaStarterAction = new QaStarterAction();
- logger.debug("forwarding to Authoring Basic tab.");
- ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
- logger.debug("actionForward: " + actionForward);
- qaAuthoringForm.resetUserAction();
- return (actionForward);
- }
- else if (qaAuthoringForm.getStatsMonitoring() != null)
- {
- qaAuthoringForm.resetUserAction();
- QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
- QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
- qaMonitoringForm.setStats("stats");
- return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
- }
- return null;
- }
+// /**
+// * used to load Monitoring tabs back once the controller moves to Edit Activity.
+// *
+// * ActionForward loadMonitoring(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+//
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return ActionForward
+// * @throws IOException
+// * @throws ServletException
+// */
+// public ActionForward loadMonitoring(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form;
+//
+// if (qaAuthoringForm.getSummaryMonitoring() != null)
+// {
+// logger.debug("request for getSummaryMonitoring, start proxying...");
+// logger.debug("NO_AVAILABLE_SESSIONS: " + request.getSession().getAttribute(NO_AVAILABLE_SESSIONS));
+//
+// Boolean noAvailableSessions=(Boolean)request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
+// logger.debug("NO_AVAILABLE_SESSIONS: " +noAvailableSessions);
+// qaAuthoringForm.resetUserAction();
+// if ((noAvailableSessions != null) && (noAvailableSessions.booleanValue()))
+// {
+// persistError(request,"error.noStudentActivity");
+// request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+// request.setAttribute(STOP_RENDERING_QUESTIONS, new Boolean(true));
+// return (mapping.findForward(LOAD));
+// }
+// else
+// {
+// logger.debug("NO_AVAILABLE_SESSIONS: " +false);
+// QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+// QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+// return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+// }
+// }
+// else if (qaAuthoringForm.getInstructionsMonitoring() != null)
+// {
+// logger.debug("QAction- request for getInstructionsMonitoring()");
+// qaAuthoringForm.resetUserAction();
+// QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+// QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+// qaMonitoringForm.setInstructions("instructions");
+// return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+// }
+// else if (qaAuthoringForm.getEditActivityMonitoring() != null)
+// {
+// logger.debug("QAction-request for getEditActivityMonitoring()");
+// QaStarterAction qaStarterAction = new QaStarterAction();
+// logger.debug("forwarding to Authoring Basic tab.");
+// ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
+// logger.debug("actionForward: " + actionForward);
+// qaAuthoringForm.resetUserAction();
+// return (actionForward);
+// }
+// else if (qaAuthoringForm.getStatsMonitoring() != null)
+// {
+// qaAuthoringForm.resetUserAction();
+// QaMonitoringAction qaMonitoringAction=new QaMonitoringAction();
+// QaMonitoringForm qaMonitoringForm=new QaMonitoringForm();
+// qaMonitoringForm.setStats("stats");
+// return qaMonitoringAction.generateToolSessionDataMap(mapping,qaMonitoringForm,request,response);
+// }
+// return null;
+// }
/**
@@ -855,7 +855,7 @@
public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm)
{
logger.debug("attempt addFileToContentRepository");
- IQaService qaService =QaUtils.getToolService(request);
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
logger.debug("qaService: " + qaService);
List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST);
@@ -948,7 +948,7 @@
if(attachmentList==null || deletedAttachmentList==null)
return null;
- IQaService qaService =QaUtils.getToolService(request);
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
if ( deletedAttachmentList != null ) {
Iterator iter = deletedAttachmentList.iterator();
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaExportPortfolioStarterAction.java,v
diff -u -r1.15 -r1.16
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java 6 Dec 2005 00:32:38 -0000 1.15
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaExportPortfolioStarterAction.java 5 Jan 2006 04:36:32 -0000 1.16
@@ -63,8 +63,8 @@
{
IQaService qaService=null;
qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
- logger.debug("retrieved qaService : " + qaService);
- request.getSession().setAttribute(TOOL_SERVICE, qaService);
+// logger.debug("retrieved qaService : " + qaService);
+// request.getSession().setAttribute(TOOL_SERVICE, qaService);
/*
* persist time zone information to session scope.
@@ -173,7 +173,7 @@
{
if ((strToolContentId != null) && (strToolContentId.length() > 0))
{
- if (!QaUtils.existsContent(new Long(strToolContentId).longValue(), request))
+ if (!QaUtils.existsContent(new Long(strToolContentId).longValue(), qaService))
{
persistError(request,"error.content.doesNotExist");
request.setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true));
@@ -248,7 +248,7 @@
/* a single toolSessionId */
request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId);
logger.debug("build a learner report:");
- learningUtil.buidLearnerReport(request, 1);
+ learningUtil.buidLearnerReport(request, 1, qaService);
}
else
{
@@ -280,7 +280,7 @@
toolSessionId=(Long)sessionListIterator.next();
logger.debug("toolSessionId: " + toolSessionId);
request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId);
- learningUtil.buidLearnerReport(request, toolSessionCounter);
+ learningUtil.buidLearnerReport(request, toolSessionCounter, qaService);
toolSessionCounter++;
}
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java,v
diff -u -r1.14 -r1.15
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 6 Dec 2005 00:32:38 -0000 1.14
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaLearningStarterAction.java 5 Jan 2006 04:36:32 -0000 1.15
@@ -136,7 +136,7 @@
IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
logger.debug("retrieving qaService: " + qaService);
- request.getSession().setAttribute(TOOL_SERVICE, qaService);
+// request.getSession().setAttribute(TOOL_SERVICE, qaService);
/*
* mark the http session as a learning activity
@@ -203,7 +203,7 @@
* make sure this session exists in tool's session table by now.
*/
- if (!QaUtils.existsSession(toolSessionId, request))
+ if (!QaUtils.existsSession(toolSessionId, qaService))
{
logger.debug("tool session does not exist" + toolSessionId);
/*
@@ -337,7 +337,7 @@
{
logger.debug("the learner has already responsed to this content, just generate a read-only report.");
LearningUtil learningUtil= new LearningUtil();
- learningUtil.buidLearnerReport(request,1);
+ learningUtil.buidLearnerReport(request,1, qaService);
logger.debug("buidLearnerReport called successfully, forwarding to: " + LEARNER_REPORT);
return (mapping.findForward(LEARNER_REPORT));
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java,v
diff -u -r1.9 -r1.10
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 6 Dec 2005 00:32:38 -0000 1.9
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringAction.java 5 Jan 2006 04:36:32 -0000 1.10
@@ -26,12 +26,15 @@
package org.lamsfoundation.lams.tool.qa.web;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
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,7 +43,8 @@
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.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.qa.QaAppConstants;
import org.lamsfoundation.lams.tool.qa.QaApplicationException;
import org.lamsfoundation.lams.tool.qa.QaContent;
@@ -49,748 +53,1567 @@
import org.lamsfoundation.lams.tool.qa.QaUtils;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
-public class QaMonitoringAction extends DispatchAction implements QaAppConstants
+public class QaMonitoringAction extends LamsDispatchAction implements QaAppConstants
{
static Logger logger = Logger.getLogger(QaMonitoringAction.class.getName());
public static String SELECTBOX_SELECTED_TOOL_SESSION ="selectBoxSelectedToolSession";
public static Integer READABLE_TOOL_SESSION_COUNT = new Integer(1);
- public ActionForward generateToolSessionDataMap(ActionMapping mapping,
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws IOException, ServletException, ToolException{
+
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+// qaService =(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
+
+ /*
+ * persist time zone information to session scope.
+ */
+ QaUtils.persistTimeZone(request);
+
+ /*
+ * mark the http session as an authoring activity
+ */
+ request.getSession().setAttribute(TARGET_MODE,TARGET_MODE_MONITORING);
+
+ /*
+ * obtain and setup the current user's data
+ */
+ String userId = "";
+ /* get session from shared session. */
+ HttpSession ss = SessionManager.getSession();
+ /* get back login user DTO */
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if ((user == null) || (user.getUserID() == null))
+ {
+ logger.debug("error: The tool expects userId");
+ persistError(request,"error.authoringUser.notAvailable");
+ request.setAttribute(USER_EXCEPTION_USERID_NOTAVAILABLE, new Boolean(true));
+ return (mapping.findForward(LOAD_QUESTIONS));
+ }else
+ userId = user.getUserID().toString();
+
+ logger.debug("TOOL_USER is:" + user);
+
+// String toolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ Long toolContentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID));
+ logger.debug("TOOL_CONTENT_ID: " + toolContentId);
+ qaMonitoringForm.setToolContentID(toolContentId);
+
+// Long initialMonitoringContentId=(Long) request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// logger.debug("INITIAL_MONITORING_TOOL_CONTENT_ID: " + initialMonitoringContentId);
+//
+// if ((toolContentId == null) || (toolContentId.length() == 0))
+// {
+// logger.debug(logger + "Warning!: toolContentId is not available!");
+// }
+// else if (initialMonitoringContentId != null)
+// {
+// logger.debug("using INITIAL_MONITORING_TOOL_CONTENT_ID: " + initialMonitoringContentId);
+// toolContentId=initialMonitoringContentId.toString();
+// }
+
+ try
+ {
+ if ((toolContentId != null) && (toolContentId.longValue() != 0))
+ {
+ if (!QaUtils.existsContent(toolContentId.longValue(), qaService))
+ {
+ persistError(request,"error.content.doesNotExist");
+ request.setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true));
+ logger.debug("forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+// request.getSession().setAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID, new Long(toolContentId));
+ }
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request,"error.numberFormatException");
+ request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true));
+ logger.debug("forwarding to: " + MONITORING_ERROR);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+// /*
+// * load the values for online and offline instructions
+// */
+// initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// if (initialMonitoringContentId != null)
+// {
+// QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+// logger.debug("qaContent: " + qaContent);
+// request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+// request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+// logger.debug("session updated with online/offline instructions");
+// }
+
+ /*
+ * find out if only content id but no tool sessions has been passed
+ * since with the updated tool contract only userId+toolContentId is passed
+ * this will always return true
+ */
+
+ boolean isOnlyContentIdAvailable = isOnlyContentIdAvailable(request);
+ logger.debug("final isOnlyContentIdAvailable: " + isOnlyContentIdAvailable);
+
+ request.getSession().setAttribute(NO_TOOL_SESSIONS_AVAILABLE, new Boolean(false));
+ if (isOnlyContentIdAvailable == false)
+ {
+ /*
+ * this block of code will normally never run!
+ */
+ logger.debug("Warning! We are not supposed to reach here!");
+ }
+ else
+ {
+ logger.debug("isOnlyContentIdAvailable: " + isOnlyContentIdAvailable);
+ logger.debug("no tool sessions passed and they will be populated from toolContentId.");
+ qaMonitoringForm.resetUserAction();
+ logger.debug("getting qaContent for toolContentId: " + toolContentId);
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug("retrieved qaContent: " + qaContent);
+ List listToolSessionIds=qaService.getToolSessionsForContent(qaContent);
+ logger.debug("retrieved listToolSessionIds: " + listToolSessionIds);
+
+ Map originalSessionList= new TreeMap(new QaStringComparator());
+ Iterator sessionIdsIterator=listToolSessionIds.iterator();
+ int sessionIdCounter=1;
+ while (sessionIdsIterator.hasNext())
+ {
+ Long derivedToolSessionId=(Long) sessionIdsIterator.next();
+ logger.debug("derivedToolSessionId: " + derivedToolSessionId);
+ originalSessionList.put(new Integer(sessionIdCounter).toString(), derivedToolSessionId.toString());
+ sessionIdCounter++;
+ }
+ logger.debug("constructed originalSessionList: " + originalSessionList);
+
+ if (originalSessionList.size() == 0)
+ request.getSession().setAttribute(NO_TOOL_SESSIONS_AVAILABLE, new Boolean(true));
+ else
+ request.getSession().setAttribute(ORIGINAL_TOOL_SESSIONS,originalSessionList);
+
+ qaMonitoringForm.setSummary("summary");
+ }
+
+ String strFromToolContentId="";
+ String strToToolContentId="";
+
+ /*
+ * simulate Monitoring Service bean by calling the interface methods here
+ */
+ if (qaMonitoringForm.getStartLesson() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ /*
+ * In deployment, we won't be passing FROM_TOOL_CONTENT_ID, TO_TOOL_CONTENT_ID and TOOL_SESSION_ID from url
+ * the Monitoring Service bean calls:
+ * copyToolContent(Long fromContentId, Long toContentId)
+ */
+ strFromToolContentId=request.getParameter(FROM_TOOL_CONTENT_ID);
+ logger.debug("FROM_TOOL_CONTENT_ID: " + strFromToolContentId);
+
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug("TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ try
+ {
+ qaService.copyToolContent(new Long(strFromToolContentId), new Long(strToToolContentId));
+ }
+ catch(ToolException e)
+ {
+ logger.debug("exception copying content.");
+ throw e;
+ }
+ logger.debug("test successfull: copyToolContent.");
+
+ /*
+ * calls to these two methods will be made from Monitoring Service bean optionally depending on
+ * the the tool is setup for DefineLater and (or) RunOffline
+ */
+
+ /*
+ * TESTED to work
+ * qaService.setAsDefineLater(new Long(strToToolContentId));
+ qaService.setAsRunOffline(new Long(strToToolContentId));
+ *
+ */
+ }
+ else if (qaMonitoringForm.getDeleteLesson() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ /*
+ * TESTED to work
+ */
+ strToToolContentId=request.getParameter(TO_TOOL_CONTENT_ID);
+ logger.debug("TO_TOOL_CONTENT_ID: " + strToToolContentId);
+ if (strToToolContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TO_TOOL_CONTENT_ID from the container. Can't continue!");
+ }
+ qaService.removeToolContent(new Long(strToToolContentId));
+ }
+ /*
+ *forceComplete is an API call to service bean from monitoring environment with userId as the parameter
+ */
+ else if (qaMonitoringForm.getForceComplete() != null)
+ {
+ /*
+ * Parameter: userId
+ */
+ qaMonitoringForm.resetUserAction();
+ logger.debug("request for forceComplete");
+ userId=request.getParameter(MONITOR_USER_ID);
+ logger.debug("MONITOR_USER_ID: " + userId);
+ qaService.setAsForceComplete(new Long(userId));
+ logger.debug("end of setAsForceComplete with userId: " + userId);
+ }
+ /*
+ * summary tab is one of the main tabs in monitoring screen, summary is the default tab
+ */
+ else if (qaMonitoringForm.getSummary() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug("do generateToolSessionDataMap");
+// QaMonitoringAction qaMonitoringAction= new QaMonitoringAction();
+ return showSummary(mapping, form, request, response);
+ }
+ else if (qaMonitoringForm.getInstructions() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug("request for instructions");
+ }
+ else if (qaMonitoringForm.getEditActivity() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug("request for editActivity");
+ }
+ else if (qaMonitoringForm.getStats() != null)
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug("request for stats");
+ }
+ return null;
+ }
+
+ public ActionForward showStats(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
- MonitoringUtil monitoringUtil = new MonitoringUtil();
- monitoringUtil.findSelectedMonitoringTab(form, request);
- logger.debug("done with findSelectedMonitoringTab");
-
- /*
- * load the values for online and offline instructions
- */
- handleInstructionsScreen(mapping, form, request);
- IQaService qaService =QaUtils.getToolService(request);
- Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
- if (initialMonitoringContentId != null)
- {
- QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
- logger.debug("qaContent: " + qaContent);
- request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
- request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
- logger.debug("session updated with online/offline instructions");
- }
-
- /*
- * determine what screen(tab) to generate
- */
- String choiceMonitoring=(String)request.getSession().getAttribute(CHOICE_MONITORING);
- logger.debug("CHOICE_MONITORING: " + choiceMonitoring);
-
- if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_SUMMARY))
- {
- logger.debug("will generate summary screen");
- return generateSummaryScreen(mapping, form, request, response);
- }
- else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_INSTRUCTIONS))
- {
- logger.debug("will generate instructions screen");
- request.getSession().setAttribute(MONITORING_INSTRUCTIONS_VISITED, new Boolean(true));
- return generateInstructionsScreen(mapping, form, request, response);
- }
- else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_EDITACTIVITY))
- {
- logger.debug("will generate editActivity screen");
- request.getSession().setAttribute(MONITORING_EDITACTIVITY_VISITED, new Boolean(true));
- return generateEditActivityScreen(mapping, form, request, response);
- }
- else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_STATS))
- {
- logger.debug("will generate stats screen");
- request.getSession().setAttribute(MONITORING_STATS_VISITED, new Boolean(true));
- return generateStatsScreen(mapping, form, request, response);
- }
- return null;
- }
-
-
- /**
- *
- * produces the summary screen
- * ActionForward generateSummaryScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+ if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+ {
+ qaMonitoringForm.resetUserAction();
+ logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+ persistError(request,"error.content.noToolSessions");
+ request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+ logger.debug("forwarding to: " + MONITORING_REPORT);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug("retrieving qaService: " + qaService);
+
+ Map mapStats= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_STATS,mapStats);
+
+ Map sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ String strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+ logger.debug("strToolSessionId from http session: " + strToolSessionId);
+ if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+ {
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strToolSessionId).longValue());
+ logger.debug("retrieving qaSession: " + qaSession);
+ if (qaSession != null)
+ {
+ logger.debug("retrieving qaSession: " + qaSession);
+ int countSessionUser=qaService.countSessionUser(qaSession);
+ logger.debug("countSessionUser: " + countSessionUser);
+ mapStats.put(strToolSessionId, new Integer(countSessionUser).toString());
+ request.getSession().setAttribute(MAP_STATS,mapStats);
+ }
+
+ }
+ }
+ mapStats=(Map)request.getSession().getAttribute(MAP_STATS);
+ logger.debug("final MAP_STATS: " + mapStats);
+ qaMonitoringForm.resetUserAction();
+
+ request.getSession().setAttribute(CHOICE_MONITORING, CHOICE_TYPE_MONITORING_STATS);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ public ActionForward showEditActivity(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward generateSummaryScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ logger.debug("retrieving qaService: " + qaService);
+// Long toolContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+ Long toolContentId = qaMonitoringForm.getToolContentID();
+ logger.debug("toolContentId: " + toolContentId);
+
+ request.getSession().setAttribute(CHOICE_MONITORING, CHOICE_TYPE_MONITORING_EDITACTIVITY);
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false));
+
+ if (toolContentId == null)
+ {
+ /*
+ * toolContentId is not available from the toolSessions passed to the monitoring url.
+ * in this case, toolContentId must have been passed separetely
+ */
+ Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+ logger.debug("will generateEditActivityScreen: " + monitoredContentId);
+
+ if (monitoredContentId == null)
+ {
+ throw new QaApplicationException("Exception occured: " +
+ "Tool expects a legitimate TOOL_CONTENT_ID from the container since it is also not available from the toolSession(s) passed. Can't continue!");
+ }
+ toolContentId=monitoredContentId;
+ }
+ request.getSession().setAttribute(MONITORED_CONTENT_ID, toolContentId);
+
+ logger.debug("will use monitoredContentId: " + toolContentId);
+ QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+ logger.debug("will use qaContent: " + qaContent);
+
+ request.getSession().setAttribute(IS_MONITORING_DEFINE_LATER, new Boolean(qaContent.isDefineLater()));
+ logger.debug("IS_MONITORING_DEFINE_LATER: " + request.getSession().getAttribute(IS_MONITORING_DEFINE_LATER));
+
+ logger.debug("calling studentActivityOccurredGlobal with: " + qaContent);
+ boolean studentActivity=qaService.studentActivityOccurredGlobal(qaContent);
+ logger.debug("studentActivity on content: " + studentActivity);
+
+ qaMonitoringForm.resetUserAction();
+ if (studentActivity == false)
+ {
+ /*
+ * forward to Authoring Basic tab
+ */
+ QaStarterAction qaStarterAction = new QaStarterAction();
+ QaAuthoringForm qaAuthoringForm = new QaAuthoringForm();
+ logger.debug("forward to Authoring Basic tab ");
+ ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
+ logger.debug("actionForward: " + actionForward);
+ return (actionForward);
+ }
+ else
+ {
+ logger.debug("forward to warning screen as the content is not allowed to be modified.");
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.inUse"));
+ saveErrors(request,errors);
+ request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(true));
+ request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+ logger.debug("forwarding to:" + LOAD);
+ return (mapping.findForward(LOAD));
+ }
+ }
+
+ public ActionForward showInstructions(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
-
- Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
- logger.debug("generateSummaryScreen has noToolSessionsAvailable: " + noToolSessionsAvailable);
- if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
- {
- qaMonitoringForm.resetUserAction();
- logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
- persistError(request,"error.content.noToolSessions");
- request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
- logger.debug("forwarding to: " + MONITORING_REPORT);
- return (mapping.findForward(MONITORING_REPORT));
- }
-
- MonitoringUtil monitoringUtil = new MonitoringUtil();
- String responseId=qaMonitoringForm.getResponseId();
- String hiddenResponseId=qaMonitoringForm.getHiddenResponseId();
- String unHiddenResponseId=qaMonitoringForm.getUnHiddenResponseId();
-
- if (qaMonitoringForm.getEditReport() != null)
- {
- logger.debug("responseId for editReport" + responseId);
- request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, responseId);
- }
- else if (qaMonitoringForm.getUpdateReport() != null)
- {
- logger.debug("request for responseUpdate with id: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
- responseId=(String)request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
- String updatedResponse=qaMonitoringForm.getUpdatedResponse();
- monitoringUtil.updateResponse(request, responseId, updatedResponse);
- request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
- logger.debug("end of updateResponse with: " + responseId + "-" + updatedResponse);
- }
-
- if (qaMonitoringForm.getHideReport() != null)
- {
- logger.debug("hiddenResponseId for hideReport" + hiddenResponseId);
- request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, hiddenResponseId);
- monitoringUtil.hideResponse(request, hiddenResponseId);
- }
-
- if (qaMonitoringForm.getUnhideReport() != null)
- {
- logger.debug("hiddenResponseId for unHideReport" + unHiddenResponseId);
- request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, "");
- monitoringUtil.unHideResponse(request, unHiddenResponseId);
- }
-
- logger.debug("DATAMAP_EDITABLE_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
- logger.debug("DATAMAP_HIDDEN_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_HIDDEN_RESPONSE_ID));
-
- qaMonitoringForm.setUpdatedResponse("");
- logger.debug("request for summary");
-
- String isToolSessionChanged=request.getParameter(IS_TOOL_SESSION_CHANGED);
- logger.debug("IS_TOOL_SESSION_CHANGED - initial: " + isToolSessionChanged);
-
- /*
- * sessionList holds all the toolSessionIds passed to summary page to be presented in a drop-down box.
- */
- Map sessionList = new TreeMap();
- int SELECTION_CASE=0;
-
- logger.debug("isNonDefaultScreensVisited: " + monitoringUtil.isNonDefaultScreensVisited(request));
-
- /*
- * Following conditions test which entry has been selected in the monitoring mode-summary screen drop box.
- * is Default page
- */
- String selectionCase=(String)request.getSession().getAttribute("selectionCase");
- logger.debug("current selectionCase: " + selectionCase);
-
- boolean sessionListReadable=false;
- if ((isToolSessionChanged == null) && !monitoringUtil.isNonDefaultScreensVisited(request))
- {
- logger.debug("First case based on null. Gets rendered only once in http session life time");
- logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
- /*
- * initialize sessionList with "All", which is the default option.
- */
- sessionList.put("All", "All");
- READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
- SELECTION_CASE=1;
- }
- else if ((isToolSessionChanged == null) && monitoringUtil.isNonDefaultScreensVisited(request))
- {
- logger.debug("Other tabs visited. Gets rendered for all tool sessions");
- sessionList.put("All", "All");
- READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
- SELECTION_CASE=2;
- sessionListReadable=true;
- }
- else if ((isToolSessionChanged != null) && isToolSessionChanged.equalsIgnoreCase("1"))
- {
- String selectedToolSessionId=(String)request.getParameter("toolSessionId1");
- logger.debug("selectedToolSessionId" + selectedToolSessionId);
- /*
- * is "All" selected
- */
- if (selectedToolSessionId.equalsIgnoreCase("All"))
- {
- logger.debug("Second case");
- logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
- /*
- * initialize sessionList with "All", which is the default option.
- */
- sessionList.put("All", "All");
- READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
- SELECTION_CASE=2;
- sessionListReadable=true;
- }
- else
- {
- /*
- * is a single session id selected
- */
- logger.debug("Third case");
- logger.debug("selectedToolSessionId" + selectedToolSessionId);
- READABLE_TOOL_SESSION_COUNT=new Integer(2);
- SELECTION_CASE=3;
- request.getSession().setAttribute(CURRENT_MONITORED_TOOL_SESSION,selectedToolSessionId);
- logger.debug("CURRENT_MONITORED_TOOL_SESSION " + selectedToolSessionId);
- }
- }
- else if (isToolSessionChanged.equals("") && (selectionCase.equals("3")))
- {
- /*
- * is a single session id selected
- */
- logger.debug("case with single session and edit or update selected");
- READABLE_TOOL_SESSION_COUNT=new Integer(2);
- SELECTION_CASE=3;
- }
- else if (isToolSessionChanged.equals(""))
- {
- logger.debug("All is selected");
- sessionList.put("All", "All");
- READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
- SELECTION_CASE=2;
- sessionListReadable=true;
- }
- logger.debug("final SELECTION_CASE: " + SELECTION_CASE);
-
- boolean useSelectedToolSessionId=false;
- String selectedToolSessionId = (String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
- if ((selectedToolSessionId != null) && (SELECTION_CASE == 3) && (READABLE_TOOL_SESSION_COUNT.intValue() == 2))
- {
- useSelectedToolSessionId=true;
- }
-
- if ((qaMonitoringForm.getEditReport() == null) && (qaMonitoringForm.getUpdateReport() == null))
- {
- logger.debug("no editReport or updateReport selected");
- request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
- request.getSession().setAttribute("selectionCase",new Long(SELECTION_CASE).toString());
- }
- qaMonitoringForm.resetUserAction();
-
- /*
- * holds all the toolSessionIds passed in the form toolSessionId1, toolSessionId2 etc.
- */
- Map mapToolSessions= new TreeMap(new QaStringComparator());
- request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions);
- logger.debug("MAP_TOOL_SESSIONS placed into session");
-
- Map mapUserResponses= new TreeMap(new QaStringComparator());
- request.getSession().setAttribute(MAP_USER_RESPONSES,mapUserResponses);
- logger.debug("MAP_USER_RESPONSES placed into session");
- logger.debug("request for contributeLesson");
- /*
- * monitoring reads all the toolSessionsIds appended one after other until it finds a null one. The cap was limited to 500.
- * This is the case all the tool sessions are using the same content.
- *
- * The final Map mapToolSessions holds the Map mapQuestions which in turn holds the Map mapUserResponses.
- * The key of mapToolSessions: incremental numbers
- * The key of mapQuestions: questions themselves
- * The key of mapUserResponses: incremental numbers
- *
- */
-
- IQaService qaService = QaUtils.getToolService(request);
- logger.debug("retrieving qaService: " + qaService);
-
- if (qaService == null)
- {
- qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
- logger.debug("retrieving qaService from proxy: " + qaService);
- request.getSession().setAttribute(TOOL_SERVICE, qaService);
- }
-
- request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(false));
- logger.debug("NO_AVAILABLE_SESSIONS: " + false);
-
- logger.debug("retrieving ORIGINAL_TOOL_SESSIONS");
- Map originalSessionList=(Map)request.getSession().getAttribute(ORIGINAL_TOOL_SESSIONS);
- logger.debug("retrieved ORIGINAL_TOOL_SESSIONS : " + originalSessionList);
- /*
- * monitoredToolSessionsCounter holds the total number of valid toolSessionIds passed to the monitoring url
- */
- logger.debug("READABLE_TOOL_SESSION_COUNT: " + READABLE_TOOL_SESSION_COUNT);
- int monitoredToolSessionsCounter=0;
- for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
- {
- logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
- String strToolSessionId="";
- if (useSelectedToolSessionId)
- {
- strToolSessionId=(String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
- logger.debug("using strToolSessionId: " +strToolSessionId);
- }
- else
- {
- strToolSessionId=(String) originalSessionList.get(""+toolSessionIdCounter);
- logger.debug("using strToolSessionId from the session: ");
- }
- logger.debug("original strToolSessionId: " + strToolSessionId);
-
- String strRetrievableToolSessionId="";
- /*
- * catering for un-formatted monitoring url
- * Watch for case where the "All" is selected in the drop-down.
- */
- logger.debug("SELECTION_CASE: " + SELECTION_CASE);
- if ((strToolSessionId == null) && (SELECTION_CASE == 1))
- {
- logger.debug("un-formatted monitoring url, exiting...");
- break;
- }
- else if ((!sessionListReadable) && ((strToolSessionId == null) || (strToolSessionId.length() == 0)))
- {
- logger.debug("un-formatted monitoring url, exiting...");
- break;
- }
- else
- {
- if (sessionListReadable)
- {
- logger.debug("sessionListReadable is true.");
- logger.debug("strToolSessionId is All: " + strToolSessionId);
- sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
- logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
- logger.debug(logger + " " + this.getClass().getName() + "sessionList size: " + sessionList.size());
-
- if (toolSessionIdCounter==sessionList.size())
- {
- logger.debug("sessionList size equals toolSessionIdCounter, exiting...");
- break;
- }
-
- logger.debug("sessionList: " + sessionList);
- strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
- logger.debug("strToolSessionId from sessionList: " + strToolSessionId);
- }
-
- strRetrievableToolSessionId=strToolSessionId;
- logger.debug("retrievableStrToolSessionId: " + strRetrievableToolSessionId);
-
- QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strRetrievableToolSessionId).longValue());
- logger.debug("retrieving qaSession: " + qaSession);
-
- if (qaSession !=null)
- {
- monitoredToolSessionsCounter++;
- request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, new Long(strToolSessionId));
- logger.debug("TOOL_SESSION_ID in session");
-
- if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
- {
- logger.debug("default screen - READABLE_TOOL_SESSION_COUNT equals MAX_TOOL_SESSION_COUNT");
- /*
- * add the current toolSessionId to the arraylist for the drop-down box
- */
- sessionList.put("Group" + monitoredToolSessionsCounter, strToolSessionId);
- logger.debug("sessionList Map new entry, strToolSessionId added to the list: " + toolSessionIdCounter + "->" + strToolSessionId );
- }
-
- /*
- * get to content from the tool session
- */
- QaContent qaContent=qaSession.getQaContent();
- logger.debug("using qaContent: " + qaContent);
- logger.debug("Monitor - contribute will be using TOOL_CONTENT_ID: " + qaContent.getQaContentId());
-
- /*
- * editActivity-defineLater screen depends on MONITORED_CONTENT_ID
- */
- request.getSession().setAttribute(MONITORED_CONTENT_ID,qaContent.getQaContentId());
-
- /*
- * place it into TOOL_CONTENT_ID session attribute since learningUtil.buidLearnerReport(request) depends on it
- * to generate a report
- */
- request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,qaContent.getQaContentId());
-
- /*
- * this is to convince jsp although usernameVisible applies only to learning mode
- */
- request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(true));
-
- logger.debug("REPORT_TITLE_MONITOR: " + qaContent.getMonitoringReportTitle());
- request.getSession().setAttribute(REPORT_TITLE_MONITOR,qaContent.getMonitoringReportTitle());
-
-
- /*
- * check if the author requires that the all tool sessions must be COMPLETED before the report in Monitoring
- */
- boolean isAllSessionsCompleted=monitoringUtil.isSessionsSync(request,qaContent.getQaContentId().longValue());
- logger.debug("Monitor - contribute will be using isAllSessionsCompleted: " + isAllSessionsCompleted);
- logger.debug("Monitor - contribute will be using isSynchInMonitor: " + qaContent.isSynchInMonitor());
- /*
- * if the author requires syncronization but not all the sessions are COMPLETED give an error
- */
- if (qaContent.isSynchInMonitor() && (!isAllSessionsCompleted))
- {
- request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(true));
- request.getSession().setAttribute(IS_ALL_SESSIONS_COMPLETED, new Boolean(isAllSessionsCompleted));
-
- ActionMessages errors= new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage("error.synchInMonitor"));
- logger.debug("add synchInMonitor to ActionMessages");
- saveErrors(request,errors);
- }
- else
- {
- request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(false));
- }
- logger.debug("IS_ALL_SESSIONS_COMPLETED:" + request.getSession().getAttribute(IS_ALL_SESSIONS_COMPLETED));
- logger.debug("CHECK_ALL_SESSIONS_COMPLETED" + request.getSession().getAttribute(CHECK_ALL_SESSIONS_COMPLETED));
-
- LearningUtil learningUtil= new LearningUtil();
- /*
- * generate a report for the Author/Teacher
- */
- logger.debug("calling buidMonitoringReport with toolSessionIdCounter:" + toolSessionIdCounter);
- learningUtil.buidLearnerReport(request, toolSessionIdCounter);
- }
- }
- }
-
- /*
- * store the arrayList in the session
- */
- if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
- {
- logger.debug("sessionList storable");
- request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS,sessionList);
- logger.debug("SUMMARY_TOOL_SESSIONS stored into the session:" + request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS));
- }
-
- mapToolSessions=(Map)request.getSession().getAttribute(MAP_TOOL_SESSIONS);
- logger.debug("before forwarding MAP_TOOL_SESSIONS:" + mapToolSessions);
-
- if (mapToolSessions.size() == 0)
- {
- request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(true));
- logger.debug("NO_AVAILABLE_SESSIONS: " +true);
- ActionMessages errors= new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage("error.noStudentActivity"));
- logger.debug("add error.noStudentActivity to ActionMessages");
- saveErrors(request,errors);
- }
-
- Boolean noAvailableSessions=(Boolean) request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
- logger.debug("before forwarding NO_AVAILABLE_SESSIONS:" + noAvailableSessions);
-
- Map mapMonitoringQuestions=(Map)request.getSession().getAttribute(MAP_MONITORING_QUESTIONS);
- logger.debug("before forwarding MAP_MONITORING_QUESTIONS:" + mapMonitoringQuestions);
-
- String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
- logger.debug("TARGET_MODE: " + targetMode);
- return (mapping.findForward(MONITORING_REPORT));
- }
-
- /**
- * produces the Instructions screen
- *
- * ActionForward generateInstructionsScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ logger.debug(logger + " " + this.getClass().getName() + "will generateInstructionsScreen.");
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+
+// Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// if (initialMonitoringContentId == null)
+// {
+// logger.debug("missing content id:");
+// persistError(request,"error.tab.contentId.required");
+// request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_REPORT);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+
+ qaMonitoringForm.resetUserAction();
+
+ request.getSession().setAttribute(CHOICE_MONITORING, CHOICE_TYPE_MONITORING_INSTRUCTIONS);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+ public ActionForward showSummary(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward generateInstructionsScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+
+// Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+// logger.debug("generateSummaryScreen has noToolSessionsAvailable: " + noToolSessionsAvailable);
+// if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+// {
+// qaMonitoringForm.resetUserAction();
+// logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+// persistError(request,"error.content.noToolSessions");
+// request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_REPORT);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+// String responseId=qaMonitoringForm.getResponseId();
+// String hiddenResponseId=qaMonitoringForm.getHiddenResponseId();
+// String unHiddenResponseId=qaMonitoringForm.getUnHiddenResponseId();
+
+// if (qaMonitoringForm.getEditReport() != null)
+// {
+// logger.debug("responseId for editReport" + responseId);
+// request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, responseId);
+// }
+// else if (qaMonitoringForm.getUpdateReport() != null)
+// {
+// logger.debug("request for responseUpdate with id: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+// responseId=(String)request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
+// String updatedResponse=qaMonitoringForm.getUpdatedResponse();
+// monitoringUtil.updateResponse(qaService, responseId, updatedResponse);
+// request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+// logger.debug("end of updateResponse with: " + responseId + "-" + updatedResponse);
+// }
+//
+// if (qaMonitoringForm.getHideReport() != null)
+// {
+// logger.debug("hiddenResponseId for hideReport" + hiddenResponseId);
+// request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, hiddenResponseId);
+// monitoringUtil.hideResponse(qaService, hiddenResponseId);
+// }
+//
+// if (qaMonitoringForm.getUnhideReport() != null)
+// {
+// logger.debug("hiddenResponseId for unHideReport" + unHiddenResponseId);
+// request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, "");
+// monitoringUtil.unHideResponse(qaService, unHiddenResponseId);
+// }
+
+// logger.debug("DATAMAP_EDITABLE_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+// logger.debug("DATAMAP_HIDDEN_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_HIDDEN_RESPONSE_ID));
+
+ qaMonitoringForm.setUpdatedResponse("");
+ logger.debug("request for summary");
+
+ String isToolSessionChanged=request.getParameter(IS_TOOL_SESSION_CHANGED);
+ logger.debug("IS_TOOL_SESSION_CHANGED - initial: " + isToolSessionChanged);
+
+ /*
+ * sessionList holds all the toolSessionIds passed to summary page to be presented in a drop-down box.
+ */
+ Map sessionList = new TreeMap();
+ int SELECTION_CASE=0;
+
+ logger.debug("isNonDefaultScreensVisited: " + monitoringUtil.isNonDefaultScreensVisited(request));
+
+ /*
+ * Following conditions test which entry has been selected in the monitoring mode-summary screen drop box.
+ * is Default page
+ */
+ String selectionCase=(String)request.getSession().getAttribute("selectionCase");
+ logger.debug("current selectionCase: " + selectionCase);
+
+ boolean sessionListReadable=false;
+ if ((isToolSessionChanged == null) && !monitoringUtil.isNonDefaultScreensVisited(request))
+ {
+ logger.debug("First case based on null. Gets rendered only once in http session life time");
+ logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
+ /*
+ * initialize sessionList with "All", which is the default option.
+ */
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=1;
+ }
+ else if ((isToolSessionChanged == null) && monitoringUtil.isNonDefaultScreensVisited(request))
+ {
+ logger.debug("Other tabs visited. Gets rendered for all tool sessions");
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ else if ((isToolSessionChanged != null) && isToolSessionChanged.equalsIgnoreCase("1"))
+ {
+ String selectedToolSessionId=(String)request.getParameter("toolSessionId1");
+ logger.debug("selectedToolSessionId" + selectedToolSessionId);
+ /*
+ * is "All" selected
+ */
+ if (selectedToolSessionId.equalsIgnoreCase("All"))
+ {
+ logger.debug("Second case");
+ logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
+ /*
+ * initialize sessionList with "All", which is the default option.
+ */
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ else
+ {
+ /*
+ * is a single session id selected
+ */
+ logger.debug("Third case");
+ logger.debug("selectedToolSessionId" + selectedToolSessionId);
+ READABLE_TOOL_SESSION_COUNT=new Integer(2);
+ SELECTION_CASE=3;
+ request.getSession().setAttribute(CURRENT_MONITORED_TOOL_SESSION,selectedToolSessionId);
+ logger.debug("CURRENT_MONITORED_TOOL_SESSION " + selectedToolSessionId);
+ }
+ }
+ else if (isToolSessionChanged.equals("") && (selectionCase.equals("3")))
+ {
+ /*
+ * is a single session id selected
+ */
+ logger.debug("case with single session and edit or update selected");
+ READABLE_TOOL_SESSION_COUNT=new Integer(2);
+ SELECTION_CASE=3;
+ }
+ else if (isToolSessionChanged.equals(""))
+ {
+ logger.debug("All is selected");
+ sessionList.put("All", "All");
+ READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+ SELECTION_CASE=2;
+ sessionListReadable=true;
+ }
+ logger.debug("final SELECTION_CASE: " + SELECTION_CASE);
+
+ boolean useSelectedToolSessionId=false;
+ String selectedToolSessionId = (String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
+ if ((selectedToolSessionId != null) && (SELECTION_CASE == 3) && (READABLE_TOOL_SESSION_COUNT.intValue() == 2))
+ {
+ useSelectedToolSessionId=true;
+ }
+
+ if ((qaMonitoringForm.getEditReport() == null) && (qaMonitoringForm.getUpdateReport() == null))
+ {
+ logger.debug("no editReport or updateReport selected");
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+ request.getSession().setAttribute("selectionCase",new Long(SELECTION_CASE).toString());
+ }
+ qaMonitoringForm.resetUserAction();
+
+ /*
+ * holds all the toolSessionIds passed in the form toolSessionId1, toolSessionId2 etc.
+ */
+ Map mapToolSessions= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions);
+ logger.debug("MAP_TOOL_SESSIONS placed into session");
+
+ Map mapUserResponses= new TreeMap(new QaStringComparator());
+ request.getSession().setAttribute(MAP_USER_RESPONSES,mapUserResponses);
+ logger.debug("MAP_USER_RESPONSES placed into session");
+ logger.debug("request for contributeLesson");
+ /*
+ * monitoring reads all the toolSessionsIds appended one after other until it finds a null one. The cap was limited to 500.
+ * This is the case all the tool sessions are using the same content.
+ *
+ * The final Map mapToolSessions holds the Map mapQuestions which in turn holds the Map mapUserResponses.
+ * The key of mapToolSessions: incremental numbers
+ * The key of mapQuestions: questions themselves
+ * The key of mapUserResponses: incremental numbers
+ *
+ */
+
+ request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(false));
+ logger.debug("NO_AVAILABLE_SESSIONS: " + false);
+
+ logger.debug("retrieving ORIGINAL_TOOL_SESSIONS");
+ Map originalSessionList=(Map)request.getSession().getAttribute(ORIGINAL_TOOL_SESSIONS);
+ logger.debug("retrieved ORIGINAL_TOOL_SESSIONS : " + originalSessionList);
+ /*
+ * monitoredToolSessionsCounter holds the total number of valid toolSessionIds passed to the monitoring url
+ */
+ logger.debug("READABLE_TOOL_SESSION_COUNT: " + READABLE_TOOL_SESSION_COUNT);
+ int monitoredToolSessionsCounter=0;
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
+ String strToolSessionId="";
+ if (useSelectedToolSessionId)
+ {
+ strToolSessionId=(String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
+ logger.debug("using strToolSessionId: " +strToolSessionId);
+ }
+ else
+ {
+ strToolSessionId=(String) originalSessionList.get(""+toolSessionIdCounter);
+ logger.debug("using strToolSessionId from the session: ");
+ }
+ logger.debug("original strToolSessionId: " + strToolSessionId);
+
+ String strRetrievableToolSessionId="";
+ /*
+ * catering for un-formatted monitoring url
+ * Watch for case where the "All" is selected in the drop-down.
+ */
+ logger.debug("SELECTION_CASE: " + SELECTION_CASE);
+ if ((strToolSessionId == null) && (SELECTION_CASE == 1))
+ {
+ logger.debug("un-formatted monitoring url, exiting...");
+ break;
+ }
+ else if ((!sessionListReadable) && ((strToolSessionId == null) || (strToolSessionId.length() == 0)))
+ {
+ logger.debug("un-formatted monitoring url, exiting...");
+ break;
+ }
+ else
+ {
+ if (sessionListReadable)
+ {
+ logger.debug("sessionListReadable is true.");
+ logger.debug("strToolSessionId is All: " + strToolSessionId);
+ sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+ logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
+ logger.debug(logger + " " + this.getClass().getName() + "sessionList size: " + sessionList.size());
+
+ if (toolSessionIdCounter==sessionList.size())
+ {
+ logger.debug("sessionList size equals toolSessionIdCounter, exiting...");
+ break;
+ }
+
+ logger.debug("sessionList: " + sessionList);
+ strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+ logger.debug("strToolSessionId from sessionList: " + strToolSessionId);
+ }
+
+ strRetrievableToolSessionId=strToolSessionId;
+ logger.debug("retrievableStrToolSessionId: " + strRetrievableToolSessionId);
+
+ QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strRetrievableToolSessionId).longValue());
+ logger.debug("retrieving qaSession: " + qaSession);
+
+ if (qaSession !=null)
+ {
+ monitoredToolSessionsCounter++;
+ request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, new Long(strToolSessionId));
+ logger.debug("TOOL_SESSION_ID in session");
+
+ if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+ {
+ logger.debug("default screen - READABLE_TOOL_SESSION_COUNT equals MAX_TOOL_SESSION_COUNT");
+ /*
+ * add the current toolSessionId to the arraylist for the drop-down box
+ */
+ sessionList.put("Group" + monitoredToolSessionsCounter, strToolSessionId);
+ logger.debug("sessionList Map new entry, strToolSessionId added to the list: " + toolSessionIdCounter + "->" + strToolSessionId );
+ }
+
+ /*
+ * get to content from the tool session
+ */
+ QaContent qaContent=qaSession.getQaContent();
+ logger.debug("using qaContent: " + qaContent);
+ logger.debug("Monitor - contribute will be using TOOL_CONTENT_ID: " + qaContent.getQaContentId());
+
+ /*
+ * editActivity-defineLater screen depends on MONITORED_CONTENT_ID
+ */
+ request.getSession().setAttribute(MONITORED_CONTENT_ID,qaContent.getQaContentId());
+
+ /*
+ * place it into TOOL_CONTENT_ID session attribute since learningUtil.buidLearnerReport(request) depends on it
+ * to generate a report
+ */
+ request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,qaContent.getQaContentId());
+
+ /*
+ * this is to convince jsp although usernameVisible applies only to learning mode
+ */
+ request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(true));
+
+ logger.debug("REPORT_TITLE_MONITOR: " + qaContent.getMonitoringReportTitle());
+ request.getSession().setAttribute(REPORT_TITLE_MONITOR,qaContent.getMonitoringReportTitle());
+
+
+ /*
+ * check if the author requires that the all tool sessions must be COMPLETED before the report in Monitoring
+ */
+ boolean isAllSessionsCompleted=monitoringUtil.isSessionsSync(qaContent);
+ logger.debug("Monitor - contribute will be using isAllSessionsCompleted: " + isAllSessionsCompleted);
+ logger.debug("Monitor - contribute will be using isSynchInMonitor: " + qaContent.isSynchInMonitor());
+ /*
+ * if the author requires syncronization but not all the sessions are COMPLETED give an error
+ */
+ if (qaContent.isSynchInMonitor() && (!isAllSessionsCompleted))
+ {
+ request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(true));
+ request.getSession().setAttribute(IS_ALL_SESSIONS_COMPLETED, new Boolean(isAllSessionsCompleted));
+
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.synchInMonitor"));
+ logger.debug("add synchInMonitor to ActionMessages");
+ saveErrors(request,errors);
+ }
+ else
+ {
+ request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(false));
+ }
+ logger.debug("IS_ALL_SESSIONS_COMPLETED:" + request.getSession().getAttribute(IS_ALL_SESSIONS_COMPLETED));
+ logger.debug("CHECK_ALL_SESSIONS_COMPLETED" + request.getSession().getAttribute(CHECK_ALL_SESSIONS_COMPLETED));
+
+ LearningUtil learningUtil= new LearningUtil();
+ /*
+ * generate a report for the Author/Teacher
+ */
+ logger.debug("calling buidMonitoringReport with toolSessionIdCounter:" + toolSessionIdCounter);
+ learningUtil.buidLearnerReport(request, toolSessionIdCounter, qaService);
+ }
+ }
+ }
+
+ /*
+ * store the arrayList in the session
+ */
+ if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+ {
+ logger.debug("sessionList storable");
+ request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS,sessionList);
+ logger.debug("SUMMARY_TOOL_SESSIONS stored into the session:" + request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS));
+ }
+
+ mapToolSessions=(Map)request.getSession().getAttribute(MAP_TOOL_SESSIONS);
+ logger.debug("before forwarding MAP_TOOL_SESSIONS:" + mapToolSessions);
+
+ if (mapToolSessions.size() == 0)
+ {
+ request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(true));
+ logger.debug("NO_AVAILABLE_SESSIONS: " +true);
+ ActionMessages errors= new ActionMessages();
+ errors.add(Globals.ERROR_KEY, new ActionMessage("error.noStudentActivity"));
+ logger.debug("add error.noStudentActivity to ActionMessages");
+ saveErrors(request,errors);
+ }
+
+ Boolean noAvailableSessions=(Boolean) request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
+ logger.debug("before forwarding NO_AVAILABLE_SESSIONS:" + noAvailableSessions);
+
+ Map mapMonitoringQuestions=(Map)request.getSession().getAttribute(MAP_MONITORING_QUESTIONS);
+ logger.debug("before forwarding MAP_MONITORING_QUESTIONS:" + mapMonitoringQuestions);
+
+ String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
+ logger.debug("TARGET_MODE: " + targetMode);
+ request.getSession().setAttribute(CHOICE_MONITORING, CHOICE_TYPE_MONITORING_SUMMARY);
+ return (mapping.findForward(MONITORING_REPORT));
+ }
+
+
+ public ActionForward editResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- logger.debug(logger + " " + this.getClass().getName() + "will generateInstructionsScreen.");
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
-
- Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
- if (initialMonitoringContentId == null)
- {
- logger.debug("missing content id:");
- persistError(request,"error.tab.contentId.required");
- request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
- logger.debug("forwarding to: " + MONITORING_REPORT);
- return (mapping.findForward(MONITORING_REPORT));
- }
-
- qaMonitoringForm.resetUserAction();
- return (mapping.findForward(MONITORING_REPORT));
- }
-
- /**
- * produces the EditActivity screen
- *
- * ActionForward generateEditActivityScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm)form;
+ String responseId=qaMonitoringForm.getResponseId();
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, responseId);
+
+ return showSummary(mapping, form, request, response);
+ }
+
+
+ public ActionForward updateReport(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward generateEditActivityScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+ String responseId=qaMonitoringForm.getResponseId();
+
+ responseId=(String)request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
+ String updatedResponse=qaMonitoringForm.getUpdatedResponse();
+ monitoringUtil.updateResponse(qaService, responseId, updatedResponse);
+
+ request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+ return showSummary(mapping, form, request, response);
+ }
+
+ public ActionForward selectToolSession(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
-
- request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false));
- IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
- logger.debug("retrieving qaService: " + qaService);
-
- Long toolContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
- logger.debug("toolContentId: " + toolContentId);
-
- if (toolContentId == null)
- {
- /*
- * toolContentId is not available from the toolSessions passed to the monitoring url.
- * in this case, toolContentId must have been passed separetely
- */
- Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
- logger.debug("will generateEditActivityScreen: " + monitoredContentId);
-
- if (monitoredContentId == null)
- {
- throw new QaApplicationException("Exception occured: " +
- "Tool expects a legitimate TOOL_CONTENT_ID from the container since it is also not available from the toolSession(s) passed. Can't continue!");
- }
- toolContentId=monitoredContentId;
- }
- request.getSession().setAttribute(MONITORED_CONTENT_ID, toolContentId);
-
- logger.debug("will use monitoredContentId: " + toolContentId);
- QaContent qaContent=qaService.loadQa(toolContentId.longValue());
- logger.debug("will use qaContent: " + qaContent);
-
- request.getSession().setAttribute(IS_MONITORING_DEFINE_LATER, new Boolean(qaContent.isDefineLater()));
- logger.debug("IS_MONITORING_DEFINE_LATER: " + request.getSession().getAttribute(IS_MONITORING_DEFINE_LATER));
-
- logger.debug("calling studentActivityOccurredGlobal with: " + qaContent);
- boolean studentActivity=qaService.studentActivityOccurredGlobal(qaContent);
- logger.debug("studentActivity on content: " + studentActivity);
-
- qaMonitoringForm.resetUserAction();
- if (studentActivity == false)
- {
- /*
- * forward to Authoring Basic tab
- */
- QaStarterAction qaStarterAction = new QaStarterAction();
- QaAuthoringForm qaAuthoringForm = new QaAuthoringForm();
- logger.debug("forward to Authoring Basic tab ");
- ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
- logger.debug("actionForward: " + actionForward);
- return (actionForward);
- }
- else
- {
- logger.debug("forward to warning screen as the content is not allowed to be modified.");
- ActionMessages errors= new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.inUse"));
- saveErrors(request,errors);
- request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(true));
- request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
- logger.debug("forwarding to:" + LOAD);
- return (mapping.findForward(LOAD));
- }
- }
-
- /**
- * produces the Stats screen
- *
- * ActionForward generateStatsScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ return showSummary(mapping, form, request, response);
+ }
+
+ public ActionForward hideResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws IOException
- * @throws ServletException
- */
- public ActionForward generateStatsScreen(ActionMapping mapping,
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ String hiddenResponseId=qaMonitoringForm.getHiddenResponseId();
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+
+ request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, hiddenResponseId);
+ monitoringUtil.hideResponse(qaService, hiddenResponseId);
+
+ return showSummary(mapping, form, request, response);
+ }
+
+ public ActionForward unhideResponse(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
- Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
- if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
- {
- qaMonitoringForm.resetUserAction();
- logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
- persistError(request,"error.content.noToolSessions");
- request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
- logger.debug("forwarding to: " + MONITORING_REPORT);
- return (mapping.findForward(MONITORING_REPORT));
- }
-
- IQaService qaService=(IQaService)request.getSession().getAttribute(TOOL_SERVICE);
- logger.debug("retrieving qaService: " + qaService);
-
- Map mapStats= new TreeMap(new QaStringComparator());
- request.getSession().setAttribute(MAP_STATS,mapStats);
-
- Map sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
- for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
- {
- String strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
- logger.debug("strToolSessionId from http session: " + strToolSessionId);
- if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
- {
- QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strToolSessionId).longValue());
- logger.debug("retrieving qaSession: " + qaSession);
- if (qaSession != null)
- {
- logger.debug("retrieving qaSession: " + qaSession);
- int countSessionUser=qaService.countSessionUser(qaSession);
- logger.debug("countSessionUser: " + countSessionUser);
- mapStats.put(strToolSessionId, new Integer(countSessionUser).toString());
- request.getSession().setAttribute(MAP_STATS,mapStats);
- }
-
- }
- }
- mapStats=(Map)request.getSession().getAttribute(MAP_STATS);
- logger.debug("final MAP_STATS: " + mapStats);
- qaMonitoringForm.resetUserAction();
- return (mapping.findForward(MONITORING_REPORT));
- }
+ HttpServletResponse response) throws IOException, ServletException
+ {
+ QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+ String unHiddenResponseId=qaMonitoringForm.getUnHiddenResponseId();
+ MonitoringUtil monitoringUtil = new MonitoringUtil();
+
+ request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, "");
+ monitoringUtil.unHideResponse(qaService, unHiddenResponseId);
+
+ return showSummary(mapping, form, request, response);
+ }
+
+// public ActionForward generateToolSessionDataMap(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException, ServletException
+// {
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+// MonitoringUtil monitoringUtil = new MonitoringUtil();
+// monitoringUtil.findSelectedMonitoringTab(form, request);
+// logger.debug("done with findSelectedMonitoringTab");
+//
+// /*
+// * load the values for online and offline instructions
+// */
+// handleInstructionsScreen(mapping, form, request);
+// IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+// Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// if (initialMonitoringContentId != null)
+// {
+// QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+// logger.debug("qaContent: " + qaContent);
+// request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+// request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+// logger.debug("session updated with online/offline instructions");
+// }
+//
+// /*
+// * determine what screen(tab) to generate
+// */
+// String choiceMonitoring=(String)request.getSession().getAttribute(CHOICE_MONITORING);
+// logger.debug("CHOICE_MONITORING: " + choiceMonitoring);
+//
+// if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_SUMMARY))
+// {
+// logger.debug("will generate summary screen");
+// return generateSummaryScreen(mapping, form, request, response);
+// }
+// else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_INSTRUCTIONS))
+// {
+// logger.debug("will generate instructions screen");
+// request.getSession().setAttribute(MONITORING_INSTRUCTIONS_VISITED, new Boolean(true));
+// return generateInstructionsScreen(mapping, form, request, response);
+// }
+// else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_EDITACTIVITY))
+// {
+// logger.debug("will generate editActivity screen");
+// request.getSession().setAttribute(MONITORING_EDITACTIVITY_VISITED, new Boolean(true));
+// return generateEditActivityScreen(mapping, form, request, response);
+// }
+// else if (choiceMonitoring.equalsIgnoreCase(CHOICE_TYPE_MONITORING_STATS))
+// {
+// logger.debug("will generate stats screen");
+// request.getSession().setAttribute(MONITORING_STATS_VISITED, new Boolean(true));
+// return generateStatsScreen(mapping, form, request, response);
+// }
+// return null;
+// }
+
+
+// /**
+// *
+// * produces the summary screen
+// * ActionForward generateSummaryScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// *
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return ActionForward
+// * @throws IOException
+// * @throws ServletException
+// */
+// public ActionForward generateSummaryScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+// IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+//
+// Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+// logger.debug("generateSummaryScreen has noToolSessionsAvailable: " + noToolSessionsAvailable);
+// if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+// {
+// qaMonitoringForm.resetUserAction();
+// logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+// persistError(request,"error.content.noToolSessions");
+// request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_REPORT);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+//
+// MonitoringUtil monitoringUtil = new MonitoringUtil();
+// String responseId=qaMonitoringForm.getResponseId();
+// String hiddenResponseId=qaMonitoringForm.getHiddenResponseId();
+// String unHiddenResponseId=qaMonitoringForm.getUnHiddenResponseId();
+//
+// if (qaMonitoringForm.getEditReport() != null)
+// {
+// logger.debug("responseId for editReport" + responseId);
+// request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, responseId);
+// }
+// else if (qaMonitoringForm.getUpdateReport() != null)
+// {
+// logger.debug("request for responseUpdate with id: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+// responseId=(String)request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID);
+// String updatedResponse=qaMonitoringForm.getUpdatedResponse();
+// monitoringUtil.updateResponse(qaService, responseId, updatedResponse);
+// request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+// logger.debug("end of updateResponse with: " + responseId + "-" + updatedResponse);
+// }
+//
+// if (qaMonitoringForm.getHideReport() != null)
+// {
+// logger.debug("hiddenResponseId for hideReport" + hiddenResponseId);
+// request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, hiddenResponseId);
+// monitoringUtil.hideResponse(qaService, hiddenResponseId);
+// }
+//
+// if (qaMonitoringForm.getUnhideReport() != null)
+// {
+// logger.debug("hiddenResponseId for unHideReport" + unHiddenResponseId);
+// request.getSession().setAttribute(DATAMAP_HIDDEN_RESPONSE_ID, "");
+// monitoringUtil.unHideResponse(qaService, unHiddenResponseId);
+// }
+//
+// logger.debug("DATAMAP_EDITABLE_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_EDITABLE_RESPONSE_ID));
+// logger.debug("DATAMAP_HIDDEN_RESPONSE_ID: " + request.getSession().getAttribute(DATAMAP_HIDDEN_RESPONSE_ID));
+//
+// qaMonitoringForm.setUpdatedResponse("");
+// logger.debug("request for summary");
+//
+// String isToolSessionChanged=request.getParameter(IS_TOOL_SESSION_CHANGED);
+// logger.debug("IS_TOOL_SESSION_CHANGED - initial: " + isToolSessionChanged);
+//
+// /*
+// * sessionList holds all the toolSessionIds passed to summary page to be presented in a drop-down box.
+// */
+// Map sessionList = new TreeMap();
+// int SELECTION_CASE=0;
+//
+// logger.debug("isNonDefaultScreensVisited: " + monitoringUtil.isNonDefaultScreensVisited(request));
+//
+// /*
+// * Following conditions test which entry has been selected in the monitoring mode-summary screen drop box.
+// * is Default page
+// */
+// String selectionCase=(String)request.getSession().getAttribute("selectionCase");
+// logger.debug("current selectionCase: " + selectionCase);
+//
+// boolean sessionListReadable=false;
+// if ((isToolSessionChanged == null) && !monitoringUtil.isNonDefaultScreensVisited(request))
+// {
+// logger.debug("First case based on null. Gets rendered only once in http session life time");
+// logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
+// /*
+// * initialize sessionList with "All", which is the default option.
+// */
+// sessionList.put("All", "All");
+// READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+// SELECTION_CASE=1;
+// }
+// else if ((isToolSessionChanged == null) && monitoringUtil.isNonDefaultScreensVisited(request))
+// {
+// logger.debug("Other tabs visited. Gets rendered for all tool sessions");
+// sessionList.put("All", "All");
+// READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+// SELECTION_CASE=2;
+// sessionListReadable=true;
+// }
+// else if ((isToolSessionChanged != null) && isToolSessionChanged.equalsIgnoreCase("1"))
+// {
+// String selectedToolSessionId=(String)request.getParameter("toolSessionId1");
+// logger.debug("selectedToolSessionId" + selectedToolSessionId);
+// /*
+// * is "All" selected
+// */
+// if (selectedToolSessionId.equalsIgnoreCase("All"))
+// {
+// logger.debug("Second case");
+// logger.debug("summary to use MAX_TOOL_SESSION_COUNT");
+// /*
+// * initialize sessionList with "All", which is the default option.
+// */
+// sessionList.put("All", "All");
+// READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+// SELECTION_CASE=2;
+// sessionListReadable=true;
+// }
+// else
+// {
+// /*
+// * is a single session id selected
+// */
+// logger.debug("Third case");
+// logger.debug("selectedToolSessionId" + selectedToolSessionId);
+// READABLE_TOOL_SESSION_COUNT=new Integer(2);
+// SELECTION_CASE=3;
+// request.getSession().setAttribute(CURRENT_MONITORED_TOOL_SESSION,selectedToolSessionId);
+// logger.debug("CURRENT_MONITORED_TOOL_SESSION " + selectedToolSessionId);
+// }
+// }
+// else if (isToolSessionChanged.equals("") && (selectionCase.equals("3")))
+// {
+// /*
+// * is a single session id selected
+// */
+// logger.debug("case with single session and edit or update selected");
+// READABLE_TOOL_SESSION_COUNT=new Integer(2);
+// SELECTION_CASE=3;
+// }
+// else if (isToolSessionChanged.equals(""))
+// {
+// logger.debug("All is selected");
+// sessionList.put("All", "All");
+// READABLE_TOOL_SESSION_COUNT=MAX_TOOL_SESSION_COUNT;
+// SELECTION_CASE=2;
+// sessionListReadable=true;
+// }
+// logger.debug("final SELECTION_CASE: " + SELECTION_CASE);
+//
+// boolean useSelectedToolSessionId=false;
+// String selectedToolSessionId = (String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
+// if ((selectedToolSessionId != null) && (SELECTION_CASE == 3) && (READABLE_TOOL_SESSION_COUNT.intValue() == 2))
+// {
+// useSelectedToolSessionId=true;
+// }
+//
+// if ((qaMonitoringForm.getEditReport() == null) && (qaMonitoringForm.getUpdateReport() == null))
+// {
+// logger.debug("no editReport or updateReport selected");
+// request.getSession().setAttribute(DATAMAP_EDITABLE_RESPONSE_ID, "");
+// request.getSession().setAttribute("selectionCase",new Long(SELECTION_CASE).toString());
+// }
+// qaMonitoringForm.resetUserAction();
+//
+// /*
+// * holds all the toolSessionIds passed in the form toolSessionId1, toolSessionId2 etc.
+// */
+// Map mapToolSessions= new TreeMap(new QaStringComparator());
+// request.getSession().setAttribute(MAP_TOOL_SESSIONS,mapToolSessions);
+// logger.debug("MAP_TOOL_SESSIONS placed into session");
+//
+// Map mapUserResponses= new TreeMap(new QaStringComparator());
+// request.getSession().setAttribute(MAP_USER_RESPONSES,mapUserResponses);
+// logger.debug("MAP_USER_RESPONSES placed into session");
+// logger.debug("request for contributeLesson");
+// /*
+// * monitoring reads all the toolSessionsIds appended one after other until it finds a null one. The cap was limited to 500.
+// * This is the case all the tool sessions are using the same content.
+// *
+// * The final Map mapToolSessions holds the Map mapQuestions which in turn holds the Map mapUserResponses.
+// * The key of mapToolSessions: incremental numbers
+// * The key of mapQuestions: questions themselves
+// * The key of mapUserResponses: incremental numbers
+// *
+// */
+//
+// request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(false));
+// logger.debug("NO_AVAILABLE_SESSIONS: " + false);
+//
+// logger.debug("retrieving ORIGINAL_TOOL_SESSIONS");
+// Map originalSessionList=(Map)request.getSession().getAttribute(ORIGINAL_TOOL_SESSIONS);
+// logger.debug("retrieved ORIGINAL_TOOL_SESSIONS : " + originalSessionList);
+// /*
+// * monitoredToolSessionsCounter holds the total number of valid toolSessionIds passed to the monitoring url
+// */
+// logger.debug("READABLE_TOOL_SESSION_COUNT: " + READABLE_TOOL_SESSION_COUNT);
+// int monitoredToolSessionsCounter=0;
+// for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+// {
+// logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
+// String strToolSessionId="";
+// if (useSelectedToolSessionId)
+// {
+// strToolSessionId=(String) request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION);
+// logger.debug("using strToolSessionId: " +strToolSessionId);
+// }
+// else
+// {
+// strToolSessionId=(String) originalSessionList.get(""+toolSessionIdCounter);
+// logger.debug("using strToolSessionId from the session: ");
+// }
+// logger.debug("original strToolSessionId: " + strToolSessionId);
+//
+// String strRetrievableToolSessionId="";
+// /*
+// * catering for un-formatted monitoring url
+// * Watch for case where the "All" is selected in the drop-down.
+// */
+// logger.debug("SELECTION_CASE: " + SELECTION_CASE);
+// if ((strToolSessionId == null) && (SELECTION_CASE == 1))
+// {
+// logger.debug("un-formatted monitoring url, exiting...");
+// break;
+// }
+// else if ((!sessionListReadable) && ((strToolSessionId == null) || (strToolSessionId.length() == 0)))
+// {
+// logger.debug("un-formatted monitoring url, exiting...");
+// break;
+// }
+// else
+// {
+// if (sessionListReadable)
+// {
+// logger.debug("sessionListReadable is true.");
+// logger.debug("strToolSessionId is All: " + strToolSessionId);
+// sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+// logger.debug("toolSessionIdCounter: " + toolSessionIdCounter);
+// logger.debug(logger + " " + this.getClass().getName() + "sessionList size: " + sessionList.size());
+//
+// if (toolSessionIdCounter==sessionList.size())
+// {
+// logger.debug("sessionList size equals toolSessionIdCounter, exiting...");
+// break;
+// }
+//
+// logger.debug("sessionList: " + sessionList);
+// strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+// logger.debug("strToolSessionId from sessionList: " + strToolSessionId);
+// }
+//
+// strRetrievableToolSessionId=strToolSessionId;
+// logger.debug("retrievableStrToolSessionId: " + strRetrievableToolSessionId);
+//
+// QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strRetrievableToolSessionId).longValue());
+// logger.debug("retrieving qaSession: " + qaSession);
+//
+// if (qaSession !=null)
+// {
+// monitoredToolSessionsCounter++;
+// request.getSession().setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, new Long(strToolSessionId));
+// logger.debug("TOOL_SESSION_ID in session");
+//
+// if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+// {
+// logger.debug("default screen - READABLE_TOOL_SESSION_COUNT equals MAX_TOOL_SESSION_COUNT");
+// /*
+// * add the current toolSessionId to the arraylist for the drop-down box
+// */
+// sessionList.put("Group" + monitoredToolSessionsCounter, strToolSessionId);
+// logger.debug("sessionList Map new entry, strToolSessionId added to the list: " + toolSessionIdCounter + "->" + strToolSessionId );
+// }
+//
+// /*
+// * get to content from the tool session
+// */
+// QaContent qaContent=qaSession.getQaContent();
+// logger.debug("using qaContent: " + qaContent);
+// logger.debug("Monitor - contribute will be using TOOL_CONTENT_ID: " + qaContent.getQaContentId());
+//
+// /*
+// * editActivity-defineLater screen depends on MONITORED_CONTENT_ID
+// */
+// request.getSession().setAttribute(MONITORED_CONTENT_ID,qaContent.getQaContentId());
+//
+// /*
+// * place it into TOOL_CONTENT_ID session attribute since learningUtil.buidLearnerReport(request) depends on it
+// * to generate a report
+// */
+// request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,qaContent.getQaContentId());
+//
+// /*
+// * this is to convince jsp although usernameVisible applies only to learning mode
+// */
+// request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(true));
+//
+// logger.debug("REPORT_TITLE_MONITOR: " + qaContent.getMonitoringReportTitle());
+// request.getSession().setAttribute(REPORT_TITLE_MONITOR,qaContent.getMonitoringReportTitle());
+//
+//
+// /*
+// * check if the author requires that the all tool sessions must be COMPLETED before the report in Monitoring
+// */
+// boolean isAllSessionsCompleted=monitoringUtil.isSessionsSync(qaContent);
+// logger.debug("Monitor - contribute will be using isAllSessionsCompleted: " + isAllSessionsCompleted);
+// logger.debug("Monitor - contribute will be using isSynchInMonitor: " + qaContent.isSynchInMonitor());
+// /*
+// * if the author requires syncronization but not all the sessions are COMPLETED give an error
+// */
+// if (qaContent.isSynchInMonitor() && (!isAllSessionsCompleted))
+// {
+// request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(true));
+// request.getSession().setAttribute(IS_ALL_SESSIONS_COMPLETED, new Boolean(isAllSessionsCompleted));
+//
+// ActionMessages errors= new ActionMessages();
+// errors.add(Globals.ERROR_KEY, new ActionMessage("error.synchInMonitor"));
+// logger.debug("add synchInMonitor to ActionMessages");
+// saveErrors(request,errors);
+// }
+// else
+// {
+// request.getSession().setAttribute(CHECK_ALL_SESSIONS_COMPLETED, new Boolean(false));
+// }
+// logger.debug("IS_ALL_SESSIONS_COMPLETED:" + request.getSession().getAttribute(IS_ALL_SESSIONS_COMPLETED));
+// logger.debug("CHECK_ALL_SESSIONS_COMPLETED" + request.getSession().getAttribute(CHECK_ALL_SESSIONS_COMPLETED));
+//
+// LearningUtil learningUtil= new LearningUtil();
+// /*
+// * generate a report for the Author/Teacher
+// */
+// logger.debug("calling buidMonitoringReport with toolSessionIdCounter:" + toolSessionIdCounter);
+// learningUtil.buidLearnerReport(request, toolSessionIdCounter, qaService);
+// }
+// }
+// }
+//
+// /*
+// * store the arrayList in the session
+// */
+// if (READABLE_TOOL_SESSION_COUNT.equals(MAX_TOOL_SESSION_COUNT))
+// {
+// logger.debug("sessionList storable");
+// request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS,sessionList);
+// logger.debug("SUMMARY_TOOL_SESSIONS stored into the session:" + request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS));
+// }
+//
+// mapToolSessions=(Map)request.getSession().getAttribute(MAP_TOOL_SESSIONS);
+// logger.debug("before forwarding MAP_TOOL_SESSIONS:" + mapToolSessions);
+//
+// if (mapToolSessions.size() == 0)
+// {
+// request.getSession().setAttribute(NO_AVAILABLE_SESSIONS,new Boolean(true));
+// logger.debug("NO_AVAILABLE_SESSIONS: " +true);
+// ActionMessages errors= new ActionMessages();
+// errors.add(Globals.ERROR_KEY, new ActionMessage("error.noStudentActivity"));
+// logger.debug("add error.noStudentActivity to ActionMessages");
+// saveErrors(request,errors);
+// }
+//
+// Boolean noAvailableSessions=(Boolean) request.getSession().getAttribute(NO_AVAILABLE_SESSIONS);
+// logger.debug("before forwarding NO_AVAILABLE_SESSIONS:" + noAvailableSessions);
+//
+// Map mapMonitoringQuestions=(Map)request.getSession().getAttribute(MAP_MONITORING_QUESTIONS);
+// logger.debug("before forwarding MAP_MONITORING_QUESTIONS:" + mapMonitoringQuestions);
+//
+// String targetMode=(String )request.getSession().getAttribute(TARGET_MODE);
+// logger.debug("TARGET_MODE: " + targetMode);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+
+// /**
+// * produces the Instructions screen
+// *
+// * ActionForward generateInstructionsScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// *
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return ActionForward
+// * @throws IOException
+// * @throws ServletException
+// */
+// public ActionForward generateInstructionsScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// logger.debug(logger + " " + this.getClass().getName() + "will generateInstructionsScreen.");
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+//
+// Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// if (initialMonitoringContentId == null)
+// {
+// logger.debug("missing content id:");
+// persistError(request,"error.tab.contentId.required");
+// request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_REPORT);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+//
+// qaMonitoringForm.resetUserAction();
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+
+// /**
+// * produces the EditActivity screen
+// *
+// * ActionForward generateEditActivityScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// *
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return ActionForward
+// * @throws IOException
+// * @throws ServletException
+// */
+// public ActionForward generateEditActivityScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+//
+// request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false));
+// IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+// logger.debug("retrieving qaService: " + qaService);
+//
+// Long toolContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// logger.debug("toolContentId: " + toolContentId);
+//
+// if (toolContentId == null)
+// {
+// /*
+// * toolContentId is not available from the toolSessions passed to the monitoring url.
+// * in this case, toolContentId must have been passed separetely
+// */
+// Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID);
+// logger.debug("will generateEditActivityScreen: " + monitoredContentId);
+//
+// if (monitoredContentId == null)
+// {
+// throw new QaApplicationException("Exception occured: " +
+// "Tool expects a legitimate TOOL_CONTENT_ID from the container since it is also not available from the toolSession(s) passed. Can't continue!");
+// }
+// toolContentId=monitoredContentId;
+// }
+// request.getSession().setAttribute(MONITORED_CONTENT_ID, toolContentId);
+//
+// logger.debug("will use monitoredContentId: " + toolContentId);
+// QaContent qaContent=qaService.loadQa(toolContentId.longValue());
+// logger.debug("will use qaContent: " + qaContent);
+//
+// request.getSession().setAttribute(IS_MONITORING_DEFINE_LATER, new Boolean(qaContent.isDefineLater()));
+// logger.debug("IS_MONITORING_DEFINE_LATER: " + request.getSession().getAttribute(IS_MONITORING_DEFINE_LATER));
+//
+// logger.debug("calling studentActivityOccurredGlobal with: " + qaContent);
+// boolean studentActivity=qaService.studentActivityOccurredGlobal(qaContent);
+// logger.debug("studentActivity on content: " + studentActivity);
+//
+// qaMonitoringForm.resetUserAction();
+// if (studentActivity == false)
+// {
+// /*
+// * forward to Authoring Basic tab
+// */
+// QaStarterAction qaStarterAction = new QaStarterAction();
+// QaAuthoringForm qaAuthoringForm = new QaAuthoringForm();
+// logger.debug("forward to Authoring Basic tab ");
+// ActionForward actionForward=qaStarterAction.startMonitoringSummary(mapping, qaAuthoringForm, request, response);
+// logger.debug("actionForward: " + actionForward);
+// return (actionForward);
+// }
+// else
+// {
+// logger.debug("forward to warning screen as the content is not allowed to be modified.");
+// ActionMessages errors= new ActionMessages();
+// errors.add(Globals.ERROR_KEY, new ActionMessage("error.content.inUse"));
+// saveErrors(request,errors);
+// request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(true));
+// request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true));
+// logger.debug("forwarding to:" + LOAD);
+// return (mapping.findForward(LOAD));
+// }
+// }
- /**
- * markDataMapAsEditable(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return ActionForward
- * @throws IOException
- * @throws ServletException
- *
- *
- * marks the dataMap so that jsp renders the summary screen as editable
- */
- public ActionForward markDataMapAsEditable(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws IOException,
- ServletException
- {
- request.getSession().setAttribute(DATAMAP_EDITABLE, new Boolean(true));
- logger.debug("will generate editable summary screen");
- return generateSummaryScreen(mapping, form, request, response);
- }
+// /**
+// * produces the Stats screen
+// *
+// * ActionForward generateStatsScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// *
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return
+// * @throws IOException
+// * @throws ServletException
+// */
+// public ActionForward generateStatsScreen(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+// Boolean noToolSessionsAvailable=(Boolean)request.getSession().getAttribute(NO_TOOL_SESSIONS_AVAILABLE);
+// if ((noToolSessionsAvailable !=null) && (noToolSessionsAvailable.booleanValue()))
+// {
+// qaMonitoringForm.resetUserAction();
+// logger.debug("detected noToolSessionsAvailable:" + noToolSessionsAvailable);
+// persistError(request,"error.content.noToolSessions");
+// request.setAttribute(USER_EXCEPTION_ONLYCONTENT_ANDNOSESSIONS, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_REPORT);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+//
+// IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+// logger.debug("retrieving qaService: " + qaService);
+//
+// Map mapStats= new TreeMap(new QaStringComparator());
+// request.getSession().setAttribute(MAP_STATS,mapStats);
+//
+// Map sessionList=(Map)request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS);
+// for (int toolSessionIdCounter=1; toolSessionIdCounter < READABLE_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+// {
+// String strToolSessionId=(String)sessionList.get("Group" + toolSessionIdCounter);
+// logger.debug("strToolSessionId from http session: " + strToolSessionId);
+// if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+// {
+// QaSession qaSession=qaService.retrieveQaSessionOrNullById(new Long(strToolSessionId).longValue());
+// logger.debug("retrieving qaSession: " + qaSession);
+// if (qaSession != null)
+// {
+// logger.debug("retrieving qaSession: " + qaSession);
+// int countSessionUser=qaService.countSessionUser(qaSession);
+// logger.debug("countSessionUser: " + countSessionUser);
+// mapStats.put(strToolSessionId, new Integer(countSessionUser).toString());
+// request.getSession().setAttribute(MAP_STATS,mapStats);
+// }
+//
+// }
+// }
+// mapStats=(Map)request.getSession().getAttribute(MAP_STATS);
+// logger.debug("final MAP_STATS: " + mapStats);
+// qaMonitoringForm.resetUserAction();
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+
+// /**
+// * markDataMapAsEditable(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// *
+// * @param mapping
+// * @param form
+// * @param request
+// * @param response
+// * @return ActionForward
+// * @throws IOException
+// * @throws ServletException
+// *
+// *
+// * marks the dataMap so that jsp renders the summary screen as editable
+// */
+// public ActionForward markDataMapAsEditable(ActionMapping mapping,
+// ActionForm form,
+// HttpServletRequest request,
+// HttpServletResponse response) throws IOException,
+// ServletException
+// {
+// request.getSession().setAttribute(DATAMAP_EDITABLE, new Boolean(true));
+// logger.debug("will generate editable summary screen");
+// return generateSummaryScreen(mapping, form, request, response);
+// }
+
- /**
- * ActionForward handleInstructionsScreen(ActionMapping mapping,ActionForm form, HttpServletRequest request)
- * @param mapping
- * @param form
- * @param request
- * @return ActionForward
- */
- public ActionForward handleInstructionsScreen(ActionMapping mapping,ActionForm form, HttpServletRequest request)
- {
- /*
- * update online and offline instuctions content if there is a request.
- */
- QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
- IQaService qaService =QaUtils.getToolService(request);
- if (qaMonitoringForm.getSubmitMonitoringInstructions() != null)
- {
- logger.debug("request for prosssing Monitoring instructions :");
- qaMonitoringForm.setSubmitMonitoringInstructions(null);
-
- logger.debug("online instructions :" + qaMonitoringForm.getOnlineInstructions());
- logger.debug("offline instructions :" + qaMonitoringForm.getOfflineInstructions());
- Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
- if (initialMonitoringContentId == null)
- {
- logger.debug("missing content id:");
- persistError(request,"error.tab.contentId.required");
- request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
- logger.debug("forwarding to: " + MONITORING_ERROR);
- return (mapping.findForward(MONITORING_REPORT));
- }
- else
- {
- /*
- * update the content
- */
- logger.debug("content id: " + initialMonitoringContentId);
- QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
- logger.debug("qaContent: " + qaContent);
- qaContent.setOnlineInstructions(qaMonitoringForm.getOnlineInstructions());
- qaContent.setOfflineInstructions(qaMonitoringForm.getOfflineInstructions());
- qaService.updateQa(qaContent);
- logger.debug("qaContent updated in the db");
- request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
- request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
- logger.debug("session updated with online/offline instructions");
- request.setAttribute(MONITORING_INSTRUCTIONS_UPDATE_MESSAGE, new Boolean(true));
- return (mapping.findForward(MONITORING_REPORT));
- }
- }
- logger.debug("end of online-offline instructions content handling");
- return null;
- }
+// /**
+// * ActionForward handleInstructionsScreen(ActionMapping mapping,ActionForm form, HttpServletRequest request)
+// * @param mapping
+// * @param form
+// * @param request
+// * @return ActionForward
+// */
+// public ActionForward handleInstructionsScreen(ActionMapping mapping,ActionForm form, HttpServletRequest request)
+// {
+// /*
+// * update online and offline instuctions content if there is a request.
+// */
+// QaMonitoringForm qaMonitoringForm = (QaMonitoringForm) form;
+// IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
+// if (qaMonitoringForm.getSubmitMonitoringInstructions() != null)
+// {
+// logger.debug("request for prosssing Monitoring instructions :");
+// qaMonitoringForm.setSubmitMonitoringInstructions(null);
+//
+// logger.debug("online instructions :" + qaMonitoringForm.getOnlineInstructions());
+// logger.debug("offline instructions :" + qaMonitoringForm.getOfflineInstructions());
+// Long initialMonitoringContentId=(Long)request.getSession().getAttribute(INITIAL_MONITORING_TOOL_CONTENT_ID);
+// if (initialMonitoringContentId == null)
+// {
+// logger.debug("missing content id:");
+// persistError(request,"error.tab.contentId.required");
+// request.setAttribute(USER_EXCEPTION_MONITORINGTAB_CONTENTID_REQUIRED, new Boolean(true));
+// logger.debug("forwarding to: " + MONITORING_ERROR);
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+// else
+// {
+// /*
+// * update the content
+// */
+// logger.debug("content id: " + initialMonitoringContentId);
+// QaContent qaContent=qaService.retrieveQa(initialMonitoringContentId.longValue());
+// logger.debug("qaContent: " + qaContent);
+// qaContent.setOnlineInstructions(qaMonitoringForm.getOnlineInstructions());
+// qaContent.setOfflineInstructions(qaMonitoringForm.getOfflineInstructions());
+// qaService.updateQa(qaContent);
+// logger.debug("qaContent updated in the db");
+// request.getSession().setAttribute(MONITORED_OFFLINE_INSTRUCTIONS, qaContent.getOfflineInstructions());
+// request.getSession().setAttribute(MONITORED_ONLINE_INSTRUCTIONS, qaContent.getOnlineInstructions());
+// logger.debug("session updated with online/offline instructions");
+// request.setAttribute(MONITORING_INSTRUCTIONS_UPDATE_MESSAGE, new Boolean(true));
+// return (mapping.findForward(MONITORING_REPORT));
+// }
+// }
+// logger.debug("end of online-offline instructions content handling");
+// return null;
+// }
/**
* persists error messages to request scope
@@ -805,5 +1628,40 @@
logger.debug("add " + message +" to ActionMessages:");
saveErrors(request,errors);
}
+
+
+ /**
+ * boolean isOnlyContentIdAvailable(HttpServletRequest request)
+ * @param request
+ * @return boolean
+ */
+ public boolean isOnlyContentIdAvailable(HttpServletRequest request)
+ {
+ boolean existsContentId=false;
+ String strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ if ((strToolContentId != null) && (strToolContentId.length() > 0))
+ existsContentId=true;
+
+ boolean existsToolSession=false;
+ for (int toolSessionIdCounter=1; toolSessionIdCounter < MAX_TOOL_SESSION_COUNT.intValue(); toolSessionIdCounter++)
+ {
+ String strToolSessionId=request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID + toolSessionIdCounter);
+ if ((strToolSessionId != null) && (strToolSessionId.length() > 0))
+ {
+ existsToolSession=true;
+ }
+ }
+
+ if (existsContentId && (!existsToolSession))
+ {
+ logger.debug("OnlyContentIdAvailable");
+ return true;
+ }
+ else
+ {
+ logger.debug("Not OnlyContentIdAvailable");
+ return false;
+ }
+ }
}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/Attic/QaMonitoringForm.java,v
diff -u -r1.5 -r1.6
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java 6 Dec 2005 00:32:38 -0000 1.5
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaMonitoringForm.java 5 Jan 2006 04:36:32 -0000 1.6
@@ -51,6 +51,8 @@
protected String offlineInstructions;
protected String onlineInstructions;
+
+ private Long toolContentID;
public void resetUserAction()
{
@@ -288,4 +290,12 @@
String submitMonitoringInstructions) {
this.submitMonitoringInstructions = submitMonitoringInstructions;
}
+
+
+ public Long getToolContentID() {
+ return toolContentID;
+ }
+ public void setToolContentID(Long toolContentID) {
+ this.toolContentID = toolContentID;
+ }
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java,v
diff -u -r1.26 -r1.27
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 15 Dec 2005 08:02:52 -0000 1.26
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 5 Jan 2006 04:36:32 -0000 1.27
@@ -137,14 +137,9 @@
// request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames);
// request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames);
- IQaService qaService = QaUtils.getToolService(request);
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
logger.debug("retrieving qaService from session: " + qaService);
- if (qaService == null)
- {
- qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
- logger.debug("retrieving qaService from proxy: " + qaService);
- request.getSession().setAttribute(TOOL_SERVICE, qaService);
- }
+
/* double check if this is a good place to call */
/* needs to be called only once. */
@@ -304,7 +299,7 @@
* there is no need to check if the content is locked in this case.
* It is always unlocked since it is the default content.
*/
- if (!existsContent(contentID.longValue(), request))
+ if (!existsContent(contentID.longValue(), qaService))
{
return retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, defaultContentID);
}
@@ -390,7 +385,7 @@
protected ActionForward retrieveContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentId)
{
logger.debug("starting retrieveExistingContent for toolContentId: " + toolContentId);
- IQaService qaService =QaUtils.getToolService(request);
+ IQaService qaService = QaServiceProxy.getQaService(getServlet().getServletContext());
logger.debug("getting existing content with id:" + toolContentId);
QaContent qaContent = qaService.retrieveQa(toolContentId);
@@ -413,7 +408,7 @@
logger.debug("CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED));
QaUtils.setDefaultSessionAttributes(request, qaContent, qaAuthoringForm);
- QaUtils.populateUploadedFilesData(request, qaContent);
+ QaUtils.populateUploadedFilesData(request, qaContent, qaService);
// request.getSession().setAttribute(IS_USERNAME_VISIBLE_MONITORING, new Boolean(defaultQaContent.isUsernameVisible()));
// request.getSession().setAttribute(IS_SYNCH_INMONITOR_MONITORING, new Boolean(defaultQaContent.isSynchInMonitor()));
@@ -501,9 +496,8 @@
* @return boolean
* determine whether a specific toolContentId exists in the db
*/
- protected boolean existsContent(long toolContentId, HttpServletRequest request)
+ protected boolean existsContent(long toolContentId, IQaService qaService)
{
- IQaService qaService =QaUtils.getToolService(request);
QaContent qaContent=qaService.loadQa(toolContentId);
if (qaContent == null)
return false;
Index: lams_tool_laqa/web/BasicContent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/BasicContent.jsp,v
diff -u -r1.11 -r1.12
--- lams_tool_laqa/web/BasicContent.jsp 15 Dec 2005 08:02:52 -0000 1.11
+++ lams_tool_laqa/web/BasicContent.jsp 5 Jan 2006 04:36:32 -0000 1.12
@@ -78,7 +78,7 @@
- |
- |
- |
- |
@@ -73,28 +87,35 @@
Index: lams_tool_laqa/web/template.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/template.jsp,v
diff -u -r1.7 -r1.8
--- lams_tool_laqa/web/template.jsp 15 Dec 2005 08:01:39 -0000 1.7
+++ lams_tool_laqa/web/template.jsp 5 Jan 2006 04:36:32 -0000 1.8
@@ -22,7 +22,7 @@
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
-<%@ taglib uri="/WEB-INF/tags-lams.tld" prefix="lams" %>
+<%@ taglib uri="/WEB-INF/lams.tld" prefix="lams" %>