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.23 -r1.24 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 29 Nov 2005 05:41:23 -0000 1.23 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaAppConstants.java 15 Dec 2005 08:02:52 -0000 1.24 @@ -229,7 +229,7 @@ public static final String START_MONITORING_SUMMARY_REQUEST ="startMonitoringSummaryRequest"; public static final String STOP_RENDERING_QUESTIONS ="stopRenderingQuestions"; public static final String EDITACTIVITY_EDITMODE ="editActivityEditMode"; - public static final String FORM_INDEX ="formIndex"; +// 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"; 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.19 -r1.20 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 29 Nov 2005 05:41:23 -0000 1.19 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaUtils.java 15 Dec 2005 08:02:52 -0000 1.20 @@ -154,24 +154,30 @@ public static void setDefaultSessionAttributes(HttpServletRequest request, QaContent defaultQaContent, QaAuthoringForm qaAuthoringForm) { /*should never be null anyway as default content MUST exist in the db*/ - if (defaultQaContent != null) - { - qaAuthoringForm.setTitle(defaultQaContent.getTitle()); - qaAuthoringForm.setInstructions(defaultQaContent.getInstructions()); - qaAuthoringForm.setReportTitle(defaultQaContent.getReportTitle()); - qaAuthoringForm.setEndLearningMessage(defaultQaContent.getEndLearningMessage()); - qaAuthoringForm.setOnlineInstructions(defaultQaContent.getOnlineInstructions()); - qaAuthoringForm.setOfflineInstructions(defaultQaContent.getOfflineInstructions()); - qaAuthoringForm.setMonitoringReportTitle(defaultQaContent.getMonitoringReportTitle()); - - request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle()); - request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions()); - - request.getSession().setAttribute(RICHTEXT_TITLE, defaultQaContent.getTitle()); - request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS, defaultQaContent.getInstructions()); - request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,defaultQaContent.getOfflineInstructions()); - request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,defaultQaContent.getOnlineInstructions()); - } + if(defaultQaContent == null) + throw new NullPointerException("Default QaContent cannot be null"); + + qaAuthoringForm.setTitle(defaultQaContent.getTitle()); + qaAuthoringForm.setInstructions(defaultQaContent.getInstructions()); + qaAuthoringForm.setReportTitle(defaultQaContent.getReportTitle()); + qaAuthoringForm.setMonitoringReportTitle(defaultQaContent.getMonitoringReportTitle()); + qaAuthoringForm.setEndLearningMessage(defaultQaContent.getEndLearningMessage()); + qaAuthoringForm.setOnlineInstructions(defaultQaContent.getOnlineInstructions()); + qaAuthoringForm.setOfflineInstructions(defaultQaContent.getOfflineInstructions()); + qaAuthoringForm.setMonitoringReportTitle(defaultQaContent.getMonitoringReportTitle()); + + //determine the status of radio boxes + qaAuthoringForm.setUsernameVisible(defaultQaContent.isUsernameVisible()?ON:OFF); + qaAuthoringForm.setSynchInMonitor(defaultQaContent.isSynchInMonitor()?ON:OFF); + qaAuthoringForm.setQuestionsSequenced(defaultQaContent.isQuestionsSequenced()?ON:OFF); + +// request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle()); +// request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions()); +// +// request.getSession().setAttribute(RICHTEXT_TITLE, defaultQaContent.getTitle()); +// request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS, defaultQaContent.getInstructions()); +// request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,defaultQaContent.getOfflineInstructions()); +// request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,defaultQaContent.getOnlineInstructions()); } Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java,v diff -u -r1.23 -r1.24 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 9 Dec 2005 12:05:30 -0000 1.23 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java 15 Dec 2005 08:02:52 -0000 1.24 @@ -20,6 +20,7 @@ */ package org.lamsfoundation.lams.tool.qa.service; import java.io.InputStream; +import java.io.Serializable; import java.util.Date; import java.util.Iterator; import java.util.List; @@ -88,8 +89,8 @@ * */ -public class QaServicePOJO implements - IQaService, ToolContentManager, ToolSessionManager, QaAppConstants +public class QaServicePOJO + implements IQaService, ToolContentManager, ToolSessionManager, QaAppConstants { static Logger logger = Logger.getLogger(QaServicePOJO.class.getName()); 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.19 -r1.20 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 6 Dec 2005 00:32:38 -0000 1.19 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/AuthoringUtil.java 15 Dec 2005 08:02:52 -0000 1.20 @@ -153,101 +153,101 @@ } - /** - * findSelectedTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * - * @param mapping - * @param form - * @param request - * @param response - * - * determines which tab in the UI is the active one - */ - protected void findSelectedTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - { - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - String choiceBasic=qaAuthoringForm.getChoiceBasic(); - String choiceAdvanced=qaAuthoringForm.getChoiceAdvanced(); - String choiceInstructions=qaAuthoringForm.getChoiceInstructions(); - - /* make the Basic tab the default one */ - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC); - - if (choiceBasic != null) - { - logger.debug("CHOICE_TYPE_BASIC"); - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC); - } - else if (choiceAdvanced != null) - { - logger.debug("CHOICE_TYPE_ADVANCED"); - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_ADVANCED); - } - else if (choiceInstructions != null) - { - logger.debug("CHOICE_TYPE_INSTRUCTIONS"); - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); - } - - logger.debug("CHOICE is:" + request.getSession().getAttribute(CHOICE)); - /* reset tab controllers */ - qaAuthoringForm.choiceBasic=null; - qaAuthoringForm.choiceAdvanced=null; - qaAuthoringForm.choiceInstructions=null; - - - /* - * if the presentation is for monitoring EditActivity screen, keep preserving request scope START_MONITORING_SUMMARY_REQUEST - */ - Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); - if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue())) - { - request.setAttribute(FORM_INDEX, "1"); - request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true)); - } - else - { - request.setAttribute(FORM_INDEX, "0"); - request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(false)); - } - - logger.debug("START_MONITORING_SUMMARY_REQUEST: " + request.getAttribute(START_MONITORING_SUMMARY_REQUEST)); - logger.debug("formIndex:" + request.getAttribute(FORM_INDEX)); - - request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false)); - if (qaAuthoringForm.getEdit() != null) - { - logger.debug("request for editActivity - editmode"); - IQaService qaService =QaUtils.getToolService(request); - Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); - logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); - - try - { - qaService.setAsDefineLater(monitoredContentId); - } - catch (ToolException e) - { - logger.debug("We should never come here."); - logger.debug("Warning! ToolException occurred"); - } - - - logger.debug("MONITORED_CONTENT_ID has been marked as defineLater: "); - request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); - } - else - { - request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle()); - request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions()); - } - } +// /** +// * findSelectedTab(ActionMapping mapping, +// ActionForm form, +// HttpServletRequest request, +// HttpServletResponse response) +// * +// * @param mapping +// * @param form +// * @param request +// * @param response +// * +// * determines which tab in the UI is the active one +// */ +// protected void findSelectedTab(ActionMapping mapping, +// ActionForm form, +// HttpServletRequest request, +// HttpServletResponse response) +// { +// QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; +// String choiceBasic=qaAuthoringForm.getChoiceBasic(); +// String choiceAdvanced=qaAuthoringForm.getChoiceAdvanced(); +// String choiceInstructions=qaAuthoringForm.getChoiceInstructions(); +// +// /* make the Basic tab the default one */ +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC); +// +// if (choiceBasic != null) +// { +// logger.debug("CHOICE_TYPE_BASIC"); +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_BASIC); +// } +// else if (choiceAdvanced != null) +// { +// logger.debug("CHOICE_TYPE_ADVANCED"); +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_ADVANCED); +// } +// else if (choiceInstructions != null) +// { +// logger.debug("CHOICE_TYPE_INSTRUCTIONS"); +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); +// } +// +// logger.debug("CHOICE is:" + request.getSession().getAttribute(CHOICE)); +// /* reset tab controllers */ +// qaAuthoringForm.choiceBasic=null; +// qaAuthoringForm.choiceAdvanced=null; +// qaAuthoringForm.choiceInstructions=null; +// +// +// /* +// * if the presentation is for monitoring EditActivity screen, keep preserving request scope START_MONITORING_SUMMARY_REQUEST +// */ +// Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); +// if ((renderMonitoringEditActivity != null) && (renderMonitoringEditActivity.booleanValue())) +// { +// request.setAttribute(FORM_INDEX, "1"); +// request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(true)); +// } +// else +// { +// request.setAttribute(FORM_INDEX, "0"); +// request.setAttribute(START_MONITORING_SUMMARY_REQUEST, new Boolean(false)); +// } +// +// logger.debug("START_MONITORING_SUMMARY_REQUEST: " + request.getAttribute(START_MONITORING_SUMMARY_REQUEST)); +// logger.debug("formIndex:" + request.getAttribute(FORM_INDEX)); +// +// request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false)); +// if (qaAuthoringForm.getEdit() != null) +// { +// logger.debug("request for editActivity - editmode"); +// IQaService qaService =QaUtils.getToolService(request); +// Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); +// logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); +// +// try +// { +// qaService.setAsDefineLater(monitoredContentId); +// } +// catch (ToolException e) +// { +// logger.debug("We should never come here."); +// logger.debug("Warning! ToolException occurred"); +// } +// +// +// logger.debug("MONITORED_CONTENT_ID has been marked as defineLater: "); +// request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); +// } +// else +// { +// request.getSession().setAttribute(TITLE,qaAuthoringForm.getTitle()); +// request.getSession().setAttribute(INSTRUCTIONS,qaAuthoringForm.getInstructions()); +// } +// } // /** 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.18 -r1.19 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 9 Dec 2005 12:05:30 -0000 1.18 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QAction.java 15 Dec 2005 08:02:52 -0000 1.19 @@ -55,6 +55,7 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -98,7 +99,7 @@ */ /** make sure the tool gets called on: - * setAsForceComplete(Long userId) throws QaApplicationException + * setAsForceComplete(Long userId) throws QaApplicationException */ @@ -136,7 +137,7 @@ * Authoring environment: toolContentId * Learning environment: toolSessionId + toolContentId * Monitoring environment: toolContentId / Contribute tab:toolSessionId(s) - * + * * */ @@ -180,12 +181,12 @@ * * @author Ozgur Demirtas */ -public class QAction extends DispatchAction implements QaAppConstants +public class QAction extends LamsDispatchAction implements QaAppConstants { - static Logger logger = Logger.getLogger(QAction.class.getName()); + static Logger logger = Logger.getLogger(QAction.class.getName()); private QaToolContentHandler toolContentHandler; - + /** *

Struts dispatch method.

* @@ -207,177 +208,300 @@ * */ - /** - * loadQ(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - - * return ActionForward - * main content/question content management and workflow logic - * - * if the passed toolContentId exists in the db, we need to get the relevant data into the Map - * if not, create the default Map - */ - - public ActionForward loadQ(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - - AuthoringUtil authoringUtil= new AuthoringUtil(); - - authoringUtil.findSelectedTab(mapping, - form, - request, - response); - - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - IQaService qaService =QaUtils.getToolService(request); - - /* - * the status of define later is determined from the property inspector and - * by now, we know whether it is on or off - * - * enable-disable tool html elements based on "define later" status - */ - - /* - * double check QaUtils.getDefineLaterStatus() - */ - boolean defineLaterStatus=QaUtils.getDefineLaterStatus(); - - Boolean defineLater=new Boolean(defineLaterStatus); - logger.debug("defineLater: " + defineLater); - if (defineLater.equals(new Boolean(false))) - { - request.getSession().setAttribute(IS_DEFINE_LATER,"false"); - request.getSession().setAttribute(DISABLE_TOOL,""); - } - else - { - request.getSession().setAttribute(IS_DEFINE_LATER,"true"); - request.getSession().setAttribute(DISABLE_TOOL,"disabled"); - } - - /*retrieve the default question content map */ +// /** +// * loadQ(ActionMapping mapping, +// ActionForm form, +// HttpServletRequest request, +// HttpServletResponse response) throws IOException, +// ServletException +// +// * return ActionForward +// * main content/question content management and workflow logic +// * +// * if the passed toolContentId exists in the db, we need to get the relevant data into the Map +// * if not, create the default Map +// */ +// +// public ActionForward loadQ(ActionMapping mapping, +// ActionForm form, +// HttpServletRequest request, +// HttpServletResponse response) throws IOException, +// ServletException +// { +// +// AuthoringUtil authoringUtil= new AuthoringUtil(); +// +// authoringUtil.findSelectedTab(mapping, +// form, +// request, +// response); +// +// QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; +// IQaService qaService =QaUtils.getToolService(request); +// +// /* +// * the status of define later is determined from the property inspector and +// * by now, we know whether it is on or off +// * +// * enable-disable tool html elements based on "define later" status +// */ +// +// /* +// * double check QaUtils.getDefineLaterStatus() +// */ +// boolean defineLaterStatus=QaUtils.getDefineLaterStatus(); +// +// Boolean defineLater=new Boolean(defineLaterStatus); +// logger.debug("defineLater: " + defineLater); +// if (defineLater.equals(new Boolean(false))) +// { +// request.getSession().setAttribute(IS_DEFINE_LATER,"false"); +// request.getSession().setAttribute(DISABLE_TOOL,""); +// } +// else +// { +// request.getSession().setAttribute(IS_DEFINE_LATER,"true"); +// request.getSession().setAttribute(DISABLE_TOOL,"disabled"); +// } +// +// /*retrieve the default question content map */ +// Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT); +// logger.debug("MAP_QUESTION_CONTENT:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT)); +// +// String userAction=""; +// userAction=getUserAction(qaAuthoringForm); +// logger.debug("returned userAction:" + userAction); +// +// QaUtils.persistRichText(request); +// +// /* add a new question to Map */ +// if (userAction.equalsIgnoreCase(ADD_NEW_QUESTION)) +// { +// request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); +// authoringUtil.reconstructQuestionContentMapForAdd(mapQuestionContent, request); +// }/* delete a question*/ +// else if (userAction.equalsIgnoreCase(REMOVE_QUESTION)) +// { +// request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); +// authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm); +// } /* remove selected content*/ +//// else if (userAction.equalsIgnoreCase(REMOVE_ALL_CONTENT)) +//// { +//// authoringUtil.removeAllDBContent(request); +//// QaUtils.cleanupSession(request); +//// qaAuthoringForm.resetUserAction(); +//// return (mapping.findForward(LOAD_STARTER)); +//// } +// else if (userAction.equalsIgnoreCase(SUBMIT_OFFLINE_FILE)) +// { +// logger.debug("will submit offline file: " + userAction); +// addFileToContentRepository(request, qaAuthoringForm, true); +// logger.debug("offline file added to repository successfully."); +// qaAuthoringForm.resetUserAction(); +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); +// logger.debug("forward back to instructions screen"); +// return (mapping.findForward(LOAD_QUESTIONS)); +// } +// else if (userAction.equalsIgnoreCase(SUBMIT_ONLINE_FILE)) +// { +// logger.debug("will submit online file: " + userAction); +// addFileToContentRepository(request, qaAuthoringForm, false); +// logger.debug("online file added to repository successfully."); +// qaAuthoringForm.resetUserAction(); +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); +// logger.debug("forward back to instructions screen"); +// return (mapping.findForward(LOAD_QUESTIONS)); +// } +// else if (userAction.equalsIgnoreCase(SUBMIT_TAB_DONE)) +// { +// logger.debug("user is done with this tab."); +// qaAuthoringForm.resetUserAction(); +// return (mapping.findForward(LOAD_QUESTIONS)); +// }/*submit questions contained in the Map*/ +// else if (userAction.equalsIgnoreCase(SUBMIT_ALL_CONTENT)) +// { +// ActionMessages errors= new ActionMessages(); +// /* full form validation should be performed only in standard authoring mode, but not in monitoring EditActivity */ +// errors=validateSubmit(request, errors, qaAuthoringForm); +// +// if (errors.size() > 0) +// { +// logger.debug("returning back to from to fix errors:"); +// request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); +// return (mapping.findForward(LOAD_QUESTIONS)); +// } +// +// /* +// * look after defineLater flag +// */ +// Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); +// logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); +// if (monitoredContentId != null) +// { +// qaService.unsetAsDefineLater(monitoredContentId); +// logger.debug("MONITORED_CONTENT_ID has been unset as defineLater: "); +// } +// +// List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); +// List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); +// +// +// /*delete existing content from the database*/ +//// authoringUtil.removeAllDBContent(request); +// +//// QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm); +// +// /*delete-recreate the questions in the db*/ +// authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request); +// +// QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, request, qaAuthoringForm); +// +// saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); +// +// /*give the user a feedback*/ +// errors.clear(); +// errors.add(Globals.ERROR_KEY, new ActionMessage("submit.successful")); +// logger.debug("submit successful."); +// saveErrors(request,errors); +// } +// else +// { +// logger.debug("Warning!: Uncatered-for user action: " + userAction); +// } +// +// qaAuthoringForm.resetUserAction(); +// +// /* +// ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, WebUtil.PARAM_MODE,MODE_OPTIONAL); +// logger.debug("retrieving mode: " + mode); +// */ +// return (mapping.findForward(LOAD_QUESTIONS)); +// } + + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + return (mapping.findForward(LOAD_QUESTIONS)); + } + + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + IQaService qaService =QaUtils.getToolService(request); + AuthoringUtil authoringUtil= new AuthoringUtil(); Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT); - logger.debug("MAP_QUESTION_CONTENT:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT)); - String userAction=""; - userAction=getUserAction(qaAuthoringForm); - logger.debug("returned userAction:" + userAction); - - QaUtils.persistRichText(request); - - /* add a new question to Map */ - if (userAction.equalsIgnoreCase(ADD_NEW_QUESTION)) - { - request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); - authoringUtil.reconstructQuestionContentMapForAdd(mapQuestionContent, request); - }/* delete a question*/ - else if (userAction.equalsIgnoreCase(REMOVE_QUESTION)) - { - request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); - authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm); - } /* remove selected content*/ -// else if (userAction.equalsIgnoreCase(REMOVE_ALL_CONTENT)) -// { -// authoringUtil.removeAllDBContent(request); -// QaUtils.cleanupSession(request); -// qaAuthoringForm.resetUserAction(); -// return (mapping.findForward(LOAD_STARTER)); -// } - else if (userAction.equalsIgnoreCase(SUBMIT_OFFLINE_FILE)) + ActionMessages errors= new ActionMessages(); + /* full form validation should be performed only in standard authoring mode, but not in monitoring EditActivity */ + errors=validateSubmit(request, errors, qaAuthoringForm); + + if (errors.size() > 0) { - logger.debug("will submit offline file: " + userAction); - addFileToContentRepository(request, qaAuthoringForm, true); - logger.debug("offline file added to repository successfully."); - qaAuthoringForm.resetUserAction(); - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); - logger.debug("forward back to instructions screen"); - return (mapping.findForward(LOAD_QUESTIONS)); + logger.debug("returning back to from to fix errors:"); + request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); + return (mapping.findForward(LOAD_QUESTIONS)); } - else if (userAction.equalsIgnoreCase(SUBMIT_ONLINE_FILE)) + + /* + * look after defineLater flag + */ + Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); + logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); + if (monitoredContentId != null) { - logger.debug("will submit online file: " + userAction); - addFileToContentRepository(request, qaAuthoringForm, false); - logger.debug("online file added to repository successfully."); - qaAuthoringForm.resetUserAction(); - request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); - logger.debug("forward back to instructions screen"); - return (mapping.findForward(LOAD_QUESTIONS)); + qaService.unsetAsDefineLater(monitoredContentId); + logger.debug("MONITORED_CONTENT_ID has been unset as defineLater: "); } - else if (userAction.equalsIgnoreCase(SUBMIT_TAB_DONE)) - { - logger.debug("user is done with this tab."); - qaAuthoringForm.resetUserAction(); - return (mapping.findForward(LOAD_QUESTIONS)); - }/*submit questions contained in the Map*/ - else if (userAction.equalsIgnoreCase(SUBMIT_ALL_CONTENT)) - { - ActionMessages errors= new ActionMessages(); - /* full form validation should be performed only in standard authoring mode, but not in monitoring EditActivity */ - errors=validateSubmit(request, errors, qaAuthoringForm); + + List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); + List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); - if (errors.size() > 0) - { - logger.debug("returning back to from to fix errors:"); - request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); - return (mapping.findForward(LOAD_QUESTIONS)); - } + + /*delete existing content from the database*/ +// authoringUtil.removeAllDBContent(request); + +// QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm); - /* - * look after defineLater flag - */ - Long monitoredContentId=(Long)request.getSession().getAttribute(MONITORED_CONTENT_ID); - logger.debug("MONITORED_CONTENT_ID: " + monitoredContentId); - if (monitoredContentId != null) - { - qaService.unsetAsDefineLater(monitoredContentId); - logger.debug("MONITORED_CONTENT_ID has been unset as defineLater: "); - } - - List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); - List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); + /*delete-recreate the questions in the db*/ + authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request); + + QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, request, qaAuthoringForm); - - /*delete existing content from the database*/ -// authoringUtil.removeAllDBContent(request); - -// QaContent qaContent=authoringUtil.createContent(mapQuestionContent, request, qaAuthoringForm); + saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); + + /*give the user a feedback*/ + errors.clear(); + errors.add(Globals.ERROR_KEY, new ActionMessage("submit.successful")); + logger.debug("submit successful."); + saveErrors(request,errors); + + qaAuthoringForm.resetUserAction(); + return mapping.findForward(LOAD_QUESTIONS); + } + +// public ActionForward submitTabDone(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) +// throws IOException, ServletException { +// QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; +// qaAuthoringForm.resetUserAction(); +// return mapping.findForward(LOAD_QUESTIONS); +// } + + public ActionForward addNewQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + AuthoringUtil authoringUtil= new AuthoringUtil(); + Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT); + + request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); //FIXME: ?? + authoringUtil.reconstructQuestionContentMapForAdd(mapQuestionContent, request); + + return (mapping.findForward(LOAD_QUESTIONS)); + } + + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + AuthoringUtil authoringUtil= new AuthoringUtil(); + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + Map mapQuestionContent=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT); + + request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(true)); //FIXME: ?? + authoringUtil.reconstructQuestionContentMapForRemove(mapQuestionContent, request, qaAuthoringForm); + + return (mapping.findForward(LOAD_QUESTIONS)); + } - /*delete-recreate the questions in the db*/ - authoringUtil.reconstructQuestionContentMapForSubmit(mapQuestionContent, request); - - QaContent qaContent = authoringUtil.saveOrUpdateQaContent(mapQuestionContent, request, qaAuthoringForm); - - saveAttachments(qaContent, attachmentList, deletedAttachmentList, mapping, request); - - /*give the user a feedback*/ - errors.clear(); - errors.add(Globals.ERROR_KEY, new ActionMessage("submit.successful")); - logger.debug("submit successful."); - saveErrors(request,errors); - } - else - { - logger.debug("Warning!: Uncatered-for user action: " + userAction); - } - + public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; + + addFileToContentRepository(request, qaAuthoringForm); qaAuthoringForm.resetUserAction(); - - /* - ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, WebUtil.PARAM_MODE,MODE_OPTIONAL); - logger.debug("retrieving mode: " + mode); - */ +// request.getSession().setAttribute(CHOICE,CHOICE_TYPE_INSTRUCTIONS); //FIXME: ?? return (mapping.findForward(LOAD_QUESTIONS)); } + public ActionForward deleteFile(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + long uuid = WebUtil.readLongParam(request, UUID); + + // move the file's details from the attachment collection to the deleted attachments collection + // the attachment will be delete on saving. + List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); + List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); + if(deletedAttachmentList == null) + deletedAttachmentList = new ArrayList(); + + deletedAttachmentList = QaUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + + + + /** * perform error validation on form submit * @@ -389,100 +513,102 @@ */ protected ActionMessages validateSubmit(HttpServletRequest request, ActionMessages errors, QaAuthoringForm qaAuthoringForm) { - String richTextTitle=(String) request.getSession().getAttribute(RICHTEXT_TITLE); - logger.debug("richTextTitle: " + richTextTitle); - String richTextInstructions=(String) request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); - - if ((richTextTitle == null) || (richTextTitle.length() == 0) || richTextTitle.equalsIgnoreCase(RICHTEXT_BLANK)) - { - errors.add(Globals.ERROR_KEY,new ActionMessage("error.title")); - logger.debug("add title to ActionMessages"); - } - - if ((richTextInstructions == null) || (richTextInstructions.length() == 0) || richTextInstructions.equalsIgnoreCase(RICHTEXT_BLANK)) - { - errors.add(Globals.ERROR_KEY, new ActionMessage("error.instructions")); - logger.debug("add instructions to ActionMessages: "); - } - - /* - * enforce that the first (default) question entry is not empty - */ - String defaultQuestionEntry =request.getParameter("questionContent0"); - if ((defaultQuestionEntry == null) || (defaultQuestionEntry.length() == 0)) - { - errors.add(Globals.ERROR_KEY, new ActionMessage("error.defaultquestion.empty")); - logger.debug("add error.defaultquestion.empty to ActionMessages: "); - } - - Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); - if ((renderMonitoringEditActivity != null) && (!renderMonitoringEditActivity.booleanValue())) - { - - if ((qaAuthoringForm.getReportTitle() == null) || (qaAuthoringForm.getReportTitle().length() == 0)) - { - errors.add(Globals.ERROR_KEY, new ActionMessage("error.reportTitle")); - logger.debug("add reportTitle to ActionMessages: "); - } - - if ((qaAuthoringForm.getMonitoringReportTitle() == null) || (qaAuthoringForm.getMonitoringReportTitle().length() == 0)) - { - errors.add(Globals.ERROR_KEY, new ActionMessage("error.monitorReportTitle")); - logger.debug("add monitorReportTitle to ActionMessages: "); - } - } - - /* end of error validation */ - - saveErrors(request,errors); - return errors; - } - - - /** - * determine the chosen user action - * - * String getUserAction(QaAuthoringForm qaAuthoringForm) - * @param qaAuthoringForm - * @return - */ - protected String getUserAction(QaAuthoringForm qaAuthoringForm) - { - String userAction=""; - if (qaAuthoringForm.getAddContent() != null) +// String richTextTitle=(String) request.getSession().getAttribute(RICHTEXT_TITLE); + String title = qaAuthoringForm.getTitle(); + logger.debug("title: " + title); +// String richTextInstructions=(String) request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS); + String instructions = qaAuthoringForm.getInstructions(); + logger.debug("instructions: " + instructions); + + if ((title == null) || (title.trim().length() == 0) || title.equalsIgnoreCase(RICHTEXT_BLANK)) { - userAction=ADD_NEW_QUESTION; + errors.add(Globals.ERROR_KEY,new ActionMessage("error.title")); + logger.debug("add title to ActionMessages"); } - else if (qaAuthoringForm.getRemoveContent() != null) + + if ((instructions == null) || (instructions.trim().length() == 0) || instructions.equalsIgnoreCase(RICHTEXT_BLANK)) { - userAction=REMOVE_QUESTION; + errors.add(Globals.ERROR_KEY, new ActionMessage("error.instructions")); + logger.debug("add instructions to ActionMessages: "); } - else if (qaAuthoringForm.getRemoveAllContent() != null) + + /* + * enforce that the first (default) question entry is not empty + */ + String defaultQuestionEntry =request.getParameter("questionContent0"); + if ((defaultQuestionEntry == null) || (defaultQuestionEntry.length() == 0)) { - userAction=REMOVE_ALL_CONTENT; + errors.add(Globals.ERROR_KEY, new ActionMessage("error.defaultquestion.empty")); + logger.debug("add error.defaultquestion.empty to ActionMessages: "); } - else if (qaAuthoringForm.getSubmitTabDone() != null) + + Boolean renderMonitoringEditActivity=(Boolean)request.getSession().getAttribute(RENDER_MONITORING_EDITACTIVITY); + if ((renderMonitoringEditActivity != null) && (!renderMonitoringEditActivity.booleanValue())) { - userAction=SUBMIT_TAB_DONE; + + if ((qaAuthoringForm.getReportTitle() == null) || (qaAuthoringForm.getReportTitle().length() == 0)) + { + errors.add(Globals.ERROR_KEY, new ActionMessage("error.reportTitle")); + logger.debug("add reportTitle to ActionMessages: "); + } + + if ((qaAuthoringForm.getMonitoringReportTitle() == null) || (qaAuthoringForm.getMonitoringReportTitle().length() == 0)) + { + errors.add(Globals.ERROR_KEY, new ActionMessage("error.monitorReportTitle")); + logger.debug("add monitorReportTitle to ActionMessages: "); + } } - else if (qaAuthoringForm.getSubmitAllContent() != null) - { - userAction=SUBMIT_ALL_CONTENT; - } - else if (qaAuthoringForm.getSubmitOfflineFile() != null) - { - userAction=SUBMIT_OFFLINE_FILE; - } - else if (qaAuthoringForm.getSubmitOnlineFile() != null) - { - userAction=SUBMIT_ONLINE_FILE; - } - logger.debug("user action is: " + userAction); - return userAction; + + /* end of error validation */ + + saveErrors(request,errors); + return errors; } +// /** +// * determine the chosen user action +// * +// * String getUserAction(QaAuthoringForm qaAuthoringForm) +// * @param qaAuthoringForm +// * @return +// */ +// protected String getUserAction(QaAuthoringForm qaAuthoringForm) +// { +// String userAction=""; +// if (qaAuthoringForm.getAddContent() != null) +// { +// userAction=ADD_NEW_QUESTION; +// } +// else if (qaAuthoringForm.getRemoveContent() != null) +// { +// userAction=REMOVE_QUESTION; +// } +// else if (qaAuthoringForm.getRemoveAllContent() != null) +// { +// userAction=REMOVE_ALL_CONTENT; +// } +// else if (qaAuthoringForm.getSubmitTabDone() != null) +// { +// userAction=SUBMIT_TAB_DONE; +// } +// else if (qaAuthoringForm.getSubmitAllContent() != null) +// { +// userAction=SUBMIT_ALL_CONTENT; +// } +// else if (qaAuthoringForm.getSubmitOfflineFile() != null) +// { +// userAction=SUBMIT_OFFLINE_FILE; +// } +// else if (qaAuthoringForm.getSubmitOnlineFile() != null) +// { +// userAction=SUBMIT_ONLINE_FILE; +// } +// logger.debug("user action is: " + userAction); +// return userAction; +// } + + /** * This method manages the presentation Map for the learner mode. * The dispatch method to decide which view should be shown to the user. @@ -511,123 +637,123 @@ HttpServletResponse response) throws IOException, ServletException, ToolException { - /* - * if the content is not ready yet, don't even proceed. - * check the define later status - */ - Boolean defineLater=(Boolean)request.getSession().getAttribute(IS_DEFINE_LATER); - logger.debug("learning-defineLater: " + defineLater); - if (defineLater.booleanValue() == true) - { - persistError(request,"error.defineLater"); - return (mapping.findForward(LOAD)); - } - - LearningUtil learningUtil= new LearningUtil(); - QaLearningForm qaLearningForm = (QaLearningForm) form; - - /*retrieve the default question content map*/ + /* + * if the content is not ready yet, don't even proceed. + * check the define later status + */ + Boolean defineLater=(Boolean)request.getSession().getAttribute(IS_DEFINE_LATER); + logger.debug("learning-defineLater: " + defineLater); + if (defineLater.booleanValue() == true) + { + persistError(request,"error.defineLater"); + return (mapping.findForward(LOAD)); + } + + LearningUtil learningUtil= new LearningUtil(); + QaLearningForm qaLearningForm = (QaLearningForm) form; + + /*retrieve the default question content map*/ Map mapQuestions=(Map)request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER); logger.debug("MAP_QUESTION_CONTENT_LEARNER:" + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER)); - Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS); + Map mapAnswers=(Map)request.getSession().getAttribute(MAP_ANSWERS); logger.debug("MAP_ANSWERS:" + mapAnswers); /*obtain author's question listing preference*/ - String questionListingMode=(String) request.getSession().getAttribute(QUESTION_LISTING_MODE); - /* maintain Map either based on sequential listing or based on combined listing*/ - if (questionListingMode.equalsIgnoreCase(QUESTION_LISTING_MODE_SEQUENTIAL)) - { - logger.debug("QUESTION_LISTING_MODE_SEQUENTIAL"); - - int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue(); - logger.debug("currentQuestionIndex is: " + currentQuestionIndex); - logger.debug("getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer()); - logger.debug("mapAnswers size:" + mapAnswers.size()); - - if (mapAnswers.size() >= currentQuestionIndex) - { - logger.debug("mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex); - mapAnswers.remove(new Long(currentQuestionIndex).toString()); - } - logger.debug("before adding to mapAnswers: " + mapAnswers); - mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer()); - logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers."); - - if (qaLearningForm.getGetNextQuestion() != null) - currentQuestionIndex++; - else if (qaLearningForm.getGetPreviousQuestion() != null) - currentQuestionIndex--; - - request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString())); - logger.debug("currentQuestionIndex will be: " + currentQuestionIndex); - request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex)); - learningUtil.feedBackAnswersProgress(request,currentQuestionIndex); - qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */ - } - else - { - logger.debug(logger + " " + this.getClass().getName() + "QUESTION_LISTING_MODE_COMBINED"); - for (int questionIndex=INITIAL_QUESTION_COUNT.intValue(); questionIndex<= mapQuestions.size(); questionIndex++ ) - { - String answer=request.getParameter("answer" + questionIndex); - logger.debug("answer for question " + questionIndex + " is:" + answer); - mapAnswers.put(new Long(questionIndex).toString(), answer); - } - } + String questionListingMode=(String) request.getSession().getAttribute(QUESTION_LISTING_MODE); + /* maintain Map either based on sequential listing or based on combined listing*/ + if (questionListingMode.equalsIgnoreCase(QUESTION_LISTING_MODE_SEQUENTIAL)) + { + logger.debug("QUESTION_LISTING_MODE_SEQUENTIAL"); + + int currentQuestionIndex=new Long(qaLearningForm.getCurrentQuestionIndex()).intValue(); + logger.debug("currentQuestionIndex is: " + currentQuestionIndex); + logger.debug("getting answer for question: " + currentQuestionIndex + "as: " + qaLearningForm.getAnswer()); + logger.debug("mapAnswers size:" + mapAnswers.size()); + + if (mapAnswers.size() >= currentQuestionIndex) + { + logger.debug("mapAnswers size:" + mapAnswers.size() + " and currentQuestionIndex: " + currentQuestionIndex); + mapAnswers.remove(new Long(currentQuestionIndex).toString()); + } + logger.debug("before adding to mapAnswers: " + mapAnswers); + mapAnswers.put(new Long(currentQuestionIndex).toString(), qaLearningForm.getAnswer()); + logger.debug("adding new answer:" + qaLearningForm.getAnswer() + " to mapAnswers."); + + if (qaLearningForm.getGetNextQuestion() != null) + currentQuestionIndex++; + else if (qaLearningForm.getGetPreviousQuestion() != null) + currentQuestionIndex--; + + request.getSession().setAttribute(CURRENT_ANSWER, mapAnswers.get(new Long(currentQuestionIndex).toString())); + logger.debug("currentQuestionIndex will be: " + currentQuestionIndex); + request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Long(currentQuestionIndex)); + learningUtil.feedBackAnswersProgress(request,currentQuestionIndex); + qaLearningForm.resetUserActions(); /*resets all except submitAnswersContent */ + } + else + { + logger.debug(logger + " " + this.getClass().getName() + "QUESTION_LISTING_MODE_COMBINED"); + for (int questionIndex=INITIAL_QUESTION_COUNT.intValue(); questionIndex<= mapQuestions.size(); questionIndex++ ) + { + String answer=request.getParameter("answer" + questionIndex); + logger.debug("answer for question " + questionIndex + " is:" + answer); + mapAnswers.put(new Long(questionIndex).toString(), answer); + } + } - /* - * At this point the Map holding learner responses is ready. So place that into the session. - */ - request.getSession().setAttribute(MAP_ANSWERS, mapAnswers); - - /* - * Learner submits the responses to the questions. - */ + /* + * At this point the Map holding learner responses is ready. So place that into the session. + */ + request.getSession().setAttribute(MAP_ANSWERS, mapAnswers); + + /* + * Learner submits the responses to the questions. + */ if (qaLearningForm.getSubmitAnswersContent() != null) { - logger.debug(logger + " " + this.getClass().getName() + "submit the responses: " + mapAnswers); - /*recreate the users and responses*/ - learningUtil.createUsersAndResponses(mapAnswers, request); + logger.debug(logger + " " + this.getClass().getName() + "submit the responses: " + mapAnswers); + /*recreate the users and responses*/ + learningUtil.createUsersAndResponses(mapAnswers, request); qaLearningForm.resetUserActions(); qaLearningForm.setSubmitAnswersContent(null); /*start generating a report for the Learner*/ learningUtil.buidLearnerReport(request,1); learningUtil.lockContent(request); logger.debug("content has been locked"); - return (mapping.findForward(LEARNER_REPORT)); + return (mapping.findForward(LEARNER_REPORT)); } /* - * Simulate learner leaving the current tool session. This will normally gets called by the container by - * leaveToolSession(toolSessionId, user) - */ + * Simulate learner leaving the current tool session. This will normally gets called by the container by + * leaveToolSession(toolSessionId, user) + */ else if (qaLearningForm.getEndLearning() != null) { - /* - * The learner is done with the tool session. The tool needs to clean-up. - */ - + /* + * The learner is done with the tool session. The tool needs to clean-up. + */ + Long toolSessionId=(Long)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID); - HttpSession ss = SessionManager.getSession(); - /*get back login user DTO*/ - UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + HttpSession ss = SessionManager.getSession(); + /*get back login user DTO*/ + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); logger.debug("simulating container behaviour by calling " + - "leaveToolSession() with toolSessionId: " + toolSessionId + " and user: " + user); + "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; - + return null; + - } - + } + /* Also cleanup session attributes */ QaUtils.cleanupSession(request); qaLearningForm.resetUserActions(); - return (mapping.findForward(LOAD)); + return (mapping.findForward(LOAD)); } @@ -654,10 +780,10 @@ HttpServletResponse response) throws IOException, ServletException { - QaAuthoringForm qaAuthoringForm = (QaAuthoringForm) form; - - if (qaAuthoringForm.getSummaryMonitoring() != null) - { + 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)); @@ -666,47 +792,47 @@ 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)); + 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); + 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; + } + 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; } @@ -718,15 +844,15 @@ * @param message */ public void persistError(HttpServletRequest request, String message) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - logger.debug("add " + message +" to ActionMessages:"); - saveErrors(request,errors); - } + { + ActionMessages errors= new ActionMessages(); + errors.add(Globals.ERROR_KEY, new ActionMessage(message)); + logger.debug("add " + message +" to ActionMessages:"); + saveErrors(request,errors); + } - public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm, boolean isOfflineFile) + public void addFileToContentRepository(HttpServletRequest request, QaAuthoringForm qaAuthoringForm) { logger.debug("attempt addFileToContentRepository"); IQaService qaService =QaUtils.getToolService(request); @@ -741,28 +867,30 @@ if(deletedAttachmentList == null) deletedAttachmentList = new ArrayList(); - FormFile uploadedFile = (isOfflineFile)?qaAuthoringForm.getTheOfflineFile():qaAuthoringForm.getTheOnlineFile(); - String fileType = isOfflineFile ? IToolContentHandler.TYPE_OFFLINE : IToolContentHandler.TYPE_ONLINE; + FormFile uploadedFile = null; + boolean isOnlineFile = false; + String fileType = null; + if(qaAuthoringForm.getTheOfflineFile() != null && qaAuthoringForm.getTheOfflineFile().getFileSize() > 0 ){ + uploadedFile = qaAuthoringForm.getTheOfflineFile(); + fileType = IToolContentHandler.TYPE_OFFLINE; + } + else if(qaAuthoringForm.getTheOnlineFile() != null && qaAuthoringForm.getTheOnlineFile().getFileSize() > 0 ){ + uploadedFile = qaAuthoringForm.getTheOnlineFile(); + isOnlineFile = true; + fileType = IToolContentHandler.TYPE_ONLINE; + } + else + //no file uploaded + return; + logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); - //String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); + // String toolContentId=(String)request.getSession().getAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID); //QaContent qaContent = qaService.loadQa(Long.parseLong(toolContentId)); -// if a file with the same name already exists then move the old one to deleted - deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), !isOfflineFile, attachmentList, deletedAttachmentList ); -// Iterator iter = attachmentList.iterator(); -// while(iter.hasNext()){ -// QaUploadedFile file = (QaUploadedFile)iter.next(); -// //if uploaded file already exist in the attachmentList then, remove it -// if(file.getFileName().equals(uploadedFile.getFileName())){ -// //if file exist in contentRepository then, move it to deleteAttachmentList else, just remove it. -// if(file.getUuid() != null){ -// -// } -// else -// iter.remove(); -// } -// } + // if a file with the same name already exists then move the old one to deleted + deletedAttachmentList = QaUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, deletedAttachmentList ); + try { @@ -772,7 +900,7 @@ uploadedFile.getContentType(), fileType); QaUploadedFile file = new QaUploadedFile(); file.setFileName(uploadedFile.getFileName()); - file.setFileOnline(!isOfflineFile); + file.setFileOnline(isOnlineFile); //file.setQaContent(qaContent); file.setUuid(node.getUuid().toString()); //file.setVersionId(node.getVersion()); @@ -866,23 +994,5 @@ return deletedAttachmentList; } - public ActionForward deleteFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - long uuid = WebUtil.readLongParam(request, UUID); - - // move the file's details from the attachment collection to the deleted attachments collection - // the attachment will be delete on saving. - List attachmentList = (List) request.getSession().getAttribute(ATTACHMENT_LIST); - List deletedAttachmentList = (List) request.getSession().getAttribute(DELETED_ATTACHMENT_LIST); - if(deletedAttachmentList == null) - deletedAttachmentList = new ArrayList(); - - deletedAttachmentList = QaUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); - return (mapping.findForward(LOAD_QUESTIONS)); - } } 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.25 -r1.26 --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 6 Dec 2005 00:32:38 -0000 1.25 +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaStarterAction.java 15 Dec 2005 08:02:52 -0000 1.26 @@ -169,35 +169,35 @@ /* * retrieve the default content id based on tool signature */ - long contentId=0; + long defaultContentID=0; try { logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); - contentId=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + contentId); - if (contentId == 0) + defaultContentID=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + logger.debug("retrieved tool default contentId: " + defaultContentID); + if (defaultContentID == 0) { logger.debug("default content id has not been setup"); persistError(request,"error.defaultContent.notSetup"); request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true)); - return (mapping.findForward(LOAD_QUESTIONS)); + return (mapping.findForward(LOAD_QUESTIONS)); //TODO: forward to error page } } catch(Exception e) { logger.debug("error getting the default content id: " + e.getMessage()); persistError(request,"error.defaultContent.notSetup"); request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true)); - return (mapping.findForward(LOAD_QUESTIONS)); + return (mapping.findForward(LOAD_QUESTIONS)); //TODO: forward to error page } /* * retrieve the default question content id based on default content id determined above */ try { - logger.debug("retrieve the default question content based on default contentId: " + contentId); - QaQueContent qaQueContent=qaService.getToolDefaultQuestionContent(contentId); + logger.debug("retrieve the default question content based on default contentId: " + defaultContentID); + QaQueContent qaQueContent=qaService.getToolDefaultQuestionContent(defaultContentID); logger.debug("using QaQueContent: " + qaQueContent); if (qaQueContent == null) { @@ -227,20 +227,21 @@ /* * define tab controllers for jsp */ - request.getSession().setAttribute(CHOICE_TYPE_BASIC,CHOICE_TYPE_BASIC); - request.getSession().setAttribute(CHOICE_TYPE_ADVANCED,CHOICE_TYPE_ADVANCED); - request.getSession().setAttribute(CHOICE_TYPE_INSTRUCTIONS,CHOICE_TYPE_INSTRUCTIONS); +// request.getSession().setAttribute(CHOICE_TYPE_BASIC,CHOICE_TYPE_BASIC); +// request.getSession().setAttribute(CHOICE_TYPE_ADVANCED,CHOICE_TYPE_ADVANCED); +// request.getSession().setAttribute(CHOICE_TYPE_INSTRUCTIONS,CHOICE_TYPE_INSTRUCTIONS); request.getSession().setAttribute(EDITACTIVITY_EDITMODE, new Boolean(false)); - request.getSession().setAttribute(FORM_INDEX, "0"); - logger.debug("FORM_INDEX set to: " + request.getSession().getAttribute(FORM_INDEX)); +// request.getSession().setAttribute(FORM_INDEX, "0"); +// logger.debug("FORM_INDEX set to: " + request.getSession().getAttribute(FORM_INDEX)); /* * find out whether the request is coming from monitoring module for EditActivity tab or from authoring environment url */ String strToolContentId=""; Long contentID =new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + qaAuthoringForm.setToolContentId(contentID.toString()); Boolean isMonitoringEditActivityVisited=(Boolean)request.getSession().getAttribute(MONITORING_EDITACTIVITY_VISITED); logger.debug("isMonitoringEditActivityVisited: " + isMonitoringEditActivityVisited); @@ -275,24 +276,24 @@ } logger.debug("usable strToolContentId: " + strToolContentId); - /* - * Process incoming tool content id - * Either exists or not exists in the db yet, a toolContentId must be passed to the tool from the container - */ - long toolContentId=0; - try - { - toolContentId=new Long(strToolContentId).longValue(); - logger.debug("passed TOOL_CONTENT_ID : " + toolContentId); - request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,strToolContentId); - } - catch(NumberFormatException e) - { - persistError(request,"error.numberFormatException"); - request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true)); - logger.debug("forwarding to: " + LOAD_QUESTIONS); - return (mapping.findForward(LOAD_QUESTIONS)); - } +// /* +// * Process incoming tool content id +// * Either exists or not exists in the db yet, a toolContentId must be passed to the tool from the container +// */ +// long toolContentId=0; +// try +// { +// toolContentId=new Long(strToolContentId).longValue(); +// logger.debug("passed TOOL_CONTENT_ID : " + toolContentId); +// request.getSession().setAttribute(AttributeNames.PARAM_TOOL_CONTENT_ID,strToolContentId); +// } +// catch(NumberFormatException e) +// { +// persistError(request,"error.numberFormatException"); +// request.setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true)); +// logger.debug("forwarding to: " + LOAD_QUESTIONS); +// return (mapping.findForward(LOAD_QUESTIONS)); +// } /* @@ -303,86 +304,78 @@ * 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(toolContentId, request)) + if (!existsContent(contentID.longValue(), request)) { - /* get default content from db, user never created any content before */ - logger.debug("retrieve default content: " + toolContentId); - return retrieveDefaultContent(request, mapping, qaAuthoringForm, mapQuestionContent); + return retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, defaultContentID); } - else - { - /* - * fetch the existing content from db, user will be presented with her previously created content data - * Note that the content might have been LOCKED(content in use) if one or more learner has started activities with this content - */ - logger.debug("retrieve existing content: " + toolContentId); - return retrieveExistingContent(request, mapping, qaAuthoringForm, mapQuestionContent, toolContentId); - } + else{ + return retrieveContent(request, mapping, qaAuthoringForm, mapQuestionContent, contentID.longValue()); + } } - /** - * returns the default content to jsp - * ActionForward retrieveDefaultContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent) - * - * @param request - * @param mapping - * @param qaAuthoringForm - * @param mapQuestionContent - * @return ActionForward - */ - protected ActionForward retrieveDefaultContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent) - { - logger.debug("starting retrieveDefaultContent for toolContentId:"); - IQaService qaService =QaUtils.getToolService(request); - - long contentId=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("getting default content with id:" + contentId); - - QaContent defaultQaContent = qaService.retrieveQa(contentId); - logger.debug("defaultQaContent: " + defaultQaContent); - - /* - * this is a new content creation, the content must always be unlocked - * CONTENT_LOCKED means CONTENT_IN_USE - */ - request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false)); - logger.debug("CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED)); - - if (defaultQaContent == null) - { - logger.debug("Exception occured: No default content"); - request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE, new Boolean(true)); - persistError(request,"error.defaultContent.notAvailable"); - return (mapping.findForward(LOAD_QUESTIONS)); - } - - QaUtils.setDefaultSessionAttributes(request, defaultQaContent, qaAuthoringForm); - qaAuthoringForm.setUsernameVisible(OFF); - logger.debug("UsernameVisible: " + qaAuthoringForm.getUsernameVisible()); - qaAuthoringForm.setQuestionsSequenced(OFF); - qaAuthoringForm.setSynchInMonitor(OFF); - - mapQuestionContent.clear(); - /* - * place the default question as the first entry in the Map - */ - mapQuestionContent.put(INITIAL_QUESTION_COUNT,request.getSession().getAttribute(DEFAULT_QUESTION_CONTENT)); - logger.debug("Map initialized with default contentid to: " + mapQuestionContent); - -// /* set uploaded offline file names to empty list*/ -// List listOfflineFileNames=new LinkedList(); +// /** +// * returns the default content to jsp +// * ActionForward retrieveDefaultContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent) +// * +// * @param request +// * @param mapping +// * @param qaAuthoringForm +// * @param mapQuestionContent +// * @return ActionForward +// */ +// protected ActionForward retrieveDefaultContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent) +// { +// logger.debug("starting retrieveDefaultContent for toolContentId:"); +// IQaService qaService =QaUtils.getToolService(request); // -// /* set uploaded online file names to empty list*/ -// List listOnlineFileNames=new LinkedList(); +// long contentId=qaService.getToolDefaultContentIdBySignature(MY_SIGNATURE); +// logger.debug("getting default content with id:" + contentId); +// +// QaContent defaultQaContent = qaService.retrieveQa(contentId); +// logger.debug("defaultQaContent: " + defaultQaContent); +// +// /* +// * this is a new content creation, the content must always be unlocked +// * CONTENT_LOCKED means CONTENT_IN_USE +// */ +// request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(false)); +// logger.debug("CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED)); +// +// if (defaultQaContent == null) +// { +// logger.debug("Exception occured: No default content"); +// request.setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOT_AVAILABLE, new Boolean(true)); +// persistError(request,"error.defaultContent.notAvailable"); +// return (mapping.findForward(LOAD_QUESTIONS)); +// } +// +// QaUtils.setDefaultSessionAttributes(request, defaultQaContent, qaAuthoringForm); +// qaAuthoringForm.setUsernameVisible(OFF); +// logger.debug("UsernameVisible: " + qaAuthoringForm.getUsernameVisible()); +// qaAuthoringForm.setQuestionsSequenced(OFF); +// qaAuthoringForm.setSynchInMonitor(OFF); +// +// mapQuestionContent.clear(); +// /* +// * place the default question as the first entry in the Map +// */ +// mapQuestionContent.put(INITIAL_QUESTION_COUNT,request.getSession().getAttribute(DEFAULT_QUESTION_CONTENT)); +// logger.debug("Map initialized with default contentid to: " + mapQuestionContent); +// +//// /* set uploaded offline file names to empty list*/ +//// List listOfflineFileNames=new LinkedList(); +//// +//// /* set uploaded online file names to empty list*/ +//// List listOnlineFileNames=new LinkedList(); +// +// +// request.getSession().setAttribute(ATTACHMENT_LIST, new ArrayList()); +// +// logger.debug("callling presentInitialUserInterface for the default content."); +// return presentInitialUserInterface(request, mapping, qaAuthoringForm, mapQuestionContent); +// } - - request.getSession().setAttribute(ATTACHMENT_LIST, new ArrayList()); - - logger.debug("callling presentInitialUserInterface for the default content."); - return presentInitialUserInterface(request, mapping, qaAuthoringForm, mapQuestionContent); - } - /** * retrives the existing content information from the db and prepares the data for presentation purposes. * ActionForward retrieveExistingContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentId) @@ -394,16 +387,16 @@ * @param toolContentId * @return ActionForward */ - protected ActionForward retrieveExistingContent(HttpServletRequest request, ActionMapping mapping, QaAuthoringForm qaAuthoringForm, Map mapQuestionContent, long toolContentId) + 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); logger.debug("getting existing content with id:" + toolContentId); - QaContent defaultQaContent = qaService.retrieveQa(toolContentId); - logger.debug("defaultQaContent: " + defaultQaContent); + QaContent qaContent = qaService.retrieveQa(toolContentId); + logger.debug("QaContent: " + qaContent); - boolean studentActivity=qaService.studentActivityOccurredGlobal(defaultQaContent); + boolean studentActivity=qaService.studentActivityOccurredGlobal(qaContent); logger.debug("studentActivity on content: " + studentActivity); if (studentActivity) { @@ -416,60 +409,41 @@ return (mapping.findForward(LOAD)); } - request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(isContentLocked(defaultQaContent))); + request.getSession().setAttribute(CONTENT_LOCKED, new Boolean(qaContent.isContentLocked())); logger.debug("CONTENT_LOCKED: " + request.getSession().getAttribute(CONTENT_LOCKED)); - QaUtils.setDefaultSessionAttributes(request, defaultQaContent, qaAuthoringForm); - - /* - * determine the status of radio boxes - */ - logger.debug("IS_USERNAME_VISIBLE: " + defaultQaContent.isUsernameVisible()); - logger.debug("set UsernameVisible to : " + defaultQaContent.isUsernameVisible()); - if (defaultQaContent.isUsernameVisible()) - qaAuthoringForm.setUsernameVisible(ON); - else - qaAuthoringForm.setUsernameVisible(OFF); - logger.debug("UsernameVisible: " + qaAuthoringForm.getUsernameVisible()); - if (defaultQaContent.isSynchInMonitor()) - qaAuthoringForm.setSynchInMonitor(ON); - else - qaAuthoringForm.setSynchInMonitor(OFF); - - if (defaultQaContent.isQuestionsSequenced()) - qaAuthoringForm.setQuestionsSequenced(ON); - else - qaAuthoringForm.setQuestionsSequenced(OFF); + QaUtils.setDefaultSessionAttributes(request, qaContent, qaAuthoringForm); + QaUtils.populateUploadedFilesData(request, qaContent); + +// request.getSession().setAttribute(IS_USERNAME_VISIBLE_MONITORING, new Boolean(defaultQaContent.isUsernameVisible())); +// request.getSession().setAttribute(IS_SYNCH_INMONITOR_MONITORING, new Boolean(defaultQaContent.isSynchInMonitor())); +// request.getSession().setAttribute(IS_QUESTIONS_SEQUENCED_MONITORING,new Boolean(defaultQaContent.isQuestionsSequenced())); + request.getSession().setAttribute(IS_DEFINE_LATER, new Boolean(qaContent.isDefineLater())); +// request.getSession().setAttribute(REPORT_TITLE, defaultQaContent.getReportTitle()); +// request.getSession().setAttribute(MONITORING_REPORT_TITLE, defaultQaContent.getMonitoringReportTitle()); +// request.getSession().setAttribute(OFFLINE_INSTRUCTIONS, defaultQaContent.getOfflineInstructions()); +// request.getSession().setAttribute(ONLINE_INSTRUCTIONS, defaultQaContent.getOnlineInstructions()); +// request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS, defaultQaContent.getOfflineInstructions()); +// request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS, defaultQaContent.getOnlineInstructions()); +// request.getSession().setAttribute(RICHTEXT_TITLE, defaultQaContent.getTitle()); +// request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS, defaultQaContent.getInstructions()); +// logger.debug("QaStarter set all 4 rich text properties"); +// +// request.getSession().setAttribute(END_LEARNING_MESSSAGE, defaultQaContent.getEndLearningMessage()); +// request.getSession().setAttribute(CREATION_DATE, defaultQaContent.getCreationDate()); +// +// logger.debug("IS_QUESTIONS_SEQUENCED_MONITORING: " + request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING)); +// logger.debug("IS_DEFINE_LATER: " + request.getSession().getAttribute(IS_DEFINE_LATER)); +// - request.getSession().setAttribute(IS_USERNAME_VISIBLE_MONITORING, new Boolean(defaultQaContent.isUsernameVisible())); - request.getSession().setAttribute(IS_SYNCH_INMONITOR_MONITORING, new Boolean(defaultQaContent.isSynchInMonitor())); - request.getSession().setAttribute(IS_QUESTIONS_SEQUENCED_MONITORING,new Boolean(defaultQaContent.isQuestionsSequenced())); - request.getSession().setAttribute(IS_DEFINE_LATER, new Boolean(defaultQaContent.isDefineLater())); - request.getSession().setAttribute(REPORT_TITLE, defaultQaContent.getReportTitle()); - request.getSession().setAttribute(MONITORING_REPORT_TITLE, defaultQaContent.getMonitoringReportTitle()); - request.getSession().setAttribute(OFFLINE_INSTRUCTIONS, defaultQaContent.getOfflineInstructions()); - request.getSession().setAttribute(ONLINE_INSTRUCTIONS, defaultQaContent.getOnlineInstructions()); - request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS, defaultQaContent.getOfflineInstructions()); - request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS, defaultQaContent.getOnlineInstructions()); - request.getSession().setAttribute(RICHTEXT_TITLE, defaultQaContent.getTitle()); - request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS, defaultQaContent.getInstructions()); - logger.debug("QaStarter set all 4 rich text properties"); - request.getSession().setAttribute(END_LEARNING_MESSSAGE, defaultQaContent.getEndLearningMessage()); - request.getSession().setAttribute(CREATION_DATE, defaultQaContent.getCreationDate()); - logger.debug("IS_QUESTIONS_SEQUENCED_MONITORING: " + request.getSession().getAttribute(IS_QUESTIONS_SEQUENCED_MONITORING)); - logger.debug("IS_DEFINE_LATER: " + request.getSession().getAttribute(IS_DEFINE_LATER)); - - QaUtils.populateUploadedFilesData(request, defaultQaContent); - - /* * get the existing question content */ logger.debug("setting existing content data from the db"); mapQuestionContent.clear(); - Iterator queIterator=defaultQaContent.getQaQueContents().iterator(); + Iterator queIterator=qaContent.getQaQueContents().iterator(); Long mapIndex=new Long(1); logger.debug("mapQuestionContent: " + mapQuestionContent); while (queIterator.hasNext()) @@ -537,19 +511,19 @@ return true; } - /** - * find out if the content is locked or not. If it is a locked content, the author can not modify it. - * The idea of content being locked is, once any one learner starts using a particular content - * that content should become unmodifiable. - * boolean isContentLocked(QaContent qaContent) - * @param qaContent - * @return boolean - */ - protected boolean isContentLocked(QaContent qaContent) - { - logger.debug("is content locked: " + qaContent.isContentLocked()); - return qaContent.isContentLocked(); - } +// /** +// * find out if the content is locked or not. If it is a locked content, the author can not modify it. +// * The idea of content being locked is, once any one learner starts using a particular content +// * that content should become unmodifiable. +// * boolean isContentLocked(QaContent qaContent) +// * @param qaContent +// * @return boolean +// */ +// protected boolean isContentLocked(QaContent qaContent) +// { +// logger.debug("is content locked: " + qaContent.isContentLocked()); +// return qaContent.isContentLocked(); +// } /** * mark the request scope to generate monitoring summary screen Index: lams_tool_laqa/web/AdvancedContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/AdvancedContent.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_laqa/web/AdvancedContent.jsp 8 Jul 2005 03:59:25 -0000 1.2 +++ lams_tool_laqa/web/AdvancedContent.jsp 15 Dec 2005 08:02:52 -0000 1.3 @@ -73,17 +73,6 @@ - -
- - - - -
- - - -
Index: lams_tool_laqa/web/BasicContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/BasicContent.jsp,v diff -u -r1.10 -r1.11 --- lams_tool_laqa/web/BasicContent.jsp 29 Nov 2005 05:48:03 -0000 1.10 +++ lams_tool_laqa/web/BasicContent.jsp 15 Dec 2005 08:02:52 -0000 1.11 @@ -13,20 +13,20 @@ : - - + : - - + @@ -40,8 +40,12 @@ ">   - + @@ -59,30 +63,23 @@ " value="" size="50" maxlength="255">   - + - + - + - -
- - - - -
- - - -
@@ -157,11 +154,12 @@ - function removeQuestion(formIndex, questionIndex) + function removeQuestion(questionIndex) { - document.forms[formIndex].questionIndex.value=questionIndex; - document.forms[formIndex].isRemoveQuestion.value='1'; - document.forms[formIndex].submit(); + document.QaAuthoringForm.questionIndex.value=questionIndex; + //document.QaAuthoringForm.isRemoveQuestion.value='1'; + submitMethod('removeQuestion'); + //document.forms[formIndex].submit(); } Index: lams_tool_laqa/web/InstructionsContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/InstructionsContent.jsp,v diff -u -r1.11 -r1.12 --- lams_tool_laqa/web/InstructionsContent.jsp 29 Nov 2005 05:49:16 -0000 1.11 +++ lams_tool_laqa/web/InstructionsContent.jsp 15 Dec 2005 08:02:52 -0000 1.12 @@ -15,10 +15,10 @@ : - - + @@ -30,7 +30,11 @@ - + @@ -49,10 +53,10 @@ - - + @@ -63,7 +67,11 @@ - + @@ -79,16 +87,6 @@ -
- - - - -
- - - -
@@ -142,7 +140,7 @@ - Index: lams_tool_laqa/web/author_page.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/Attic/author_page.jsp,v diff -u -r1.1 -r1.2 --- lams_tool_laqa/web/author_page.jsp 30 Sep 2005 05:51:10 -0000 1.1 +++ lams_tool_laqa/web/author_page.jsp 15 Dec 2005 08:02:52 -0000 1.2 @@ -38,10 +38,35 @@ MM_reloadPage(true); //--> + + + - -

Noticeboard

+ + +

Question & Answers

@@ -92,11 +117,13 @@

Basic tab content

-The basic contents should go here +

-Cancel +Cancel +Save +
@@ -106,8 +133,10 @@

Advanced tab content

-The advanced contents should go here +
+Cancel +Save
@@ -116,20 +145,17 @@

Instructions tab content

-Instructions are here +

-Cancel +Cancel +Save -
- - - -

- +
- + + \ No newline at end of file Index: lams_tool_laqa/web/WEB-INF/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_laqa/web/WEB-INF/struts-config.xml,v diff -u -r1.4 -r1.5 --- lams_tool_laqa/web/WEB-INF/struts-config.xml 13 Jul 2005 03:12:28 -0000 1.4 +++ lams_tool_laqa/web/WEB-INF/struts-config.xml 15 Dec 2005 08:02:53 -0000 1.5 @@ -47,17 +47,30 @@ - - + + + @@ -105,14 +118,14 @@ type="org.lamsfoundation.lams.tool.qa.web.QAction" name="QaAuthoringForm" scope="session" - input=".questions" - parameter="method" + input="/author_page.jsp" + parameter="dispatch" unknown="false" validate="true" >