Index: lams_tool_lamc/build.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/build.xml,v diff -u -r1.29 -r1.30 --- lams_tool_lamc/build.xml 28 Sep 2006 23:30:37 -0000 1.29 +++ lams_tool_lamc/build.xml 2 Oct 2006 01:44:18 -0000 1.30 @@ -259,15 +259,6 @@ - - - - - - - - - Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java,v diff -u -r1.123 -r1.124 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 25 Sep 2006 23:23:17 -0000 1.123 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 2 Oct 2006 01:44:14 -0000 1.124 @@ -1,4 +1,5 @@ -/* Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) * ============================================================= * License Information: http://lamsfoundation.org/licensing/lams/2.0/ * @@ -17,12 +18,17 @@ * USA * * http://www.gnu.org/licenses/gpl.txt - * ***********************************************************************/ + * **************************************************************** + */ + /* $$Id$$ */ package org.lamsfoundation.lams.tool.mc.web; +import java.io.FileNotFoundException; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -38,27 +44,34 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; +import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.mc.EditActivityDTO; import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McApplicationException; -import org.lamsfoundation.lams.tool.mc.McAttachmentDTO; +import org.lamsfoundation.lams.tool.mc.McCandidateAnswersDTO; import org.lamsfoundation.lams.tool.mc.McComparator; -import org.lamsfoundation.lams.tool.mc.McStringComparator; +import org.lamsfoundation.lams.tool.mc.McGeneralAuthoringDTO; +import org.lamsfoundation.lams.tool.mc.McQuestionContentDTO; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.pojos.McContent; -import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; -import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; +import org.lamsfoundation.lams.tool.mc.pojos.McUploadedFile; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; +import org.lamsfoundation.lams.tool.mc.util.McToolContentHandler; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + /** - * * @author Ozgur Demirtas - * *

Action class that controls the logic of tool behavior.

* *

Note that Struts action class only has the responsibility to navigate @@ -72,84 +85,72 @@ * Struts action class as all of them are handled in * CustomStrutsExceptionHandler. * - - - - - - - - - + + - - - - - + path="/AuthoringMaincontent.jsp" + redirect="false" + /> + - - - + - - + + + + -*/ + + + + + + * + */ public class McAction extends LamsDispatchAction implements McAppConstants { - /* - * when to reset define later and synchin monitor etc.. - * - * make sure the tool gets called on: - * setAsForceComplete(Long userId) throws McApplicationException - */ - static Logger logger = Logger.getLogger(McAction.class.getName()); - - /** - *

Default struts dispatch method.

+ static Logger logger = Logger.getLogger(McAction.class.getName()); + + private McToolContentHandler toolContentHandler; + + /** + *

Struts dispatch method.

* *

It is assuming that progress engine should pass in the tool access * mode and the tool session id as http parameters.

@@ -167,2806 +168,3123 @@ * @throws ServletException * @throws McApplicationException the known runtime exception * - * unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - - * 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 unspecified(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - AuthoringUtil.readData(request, mcAuthoringForm, false); - mcAuthoringForm.resetUserAction(); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); - - - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - return null; + */ + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + return (mapping.findForward(LOAD_QUESTIONS)); } - - - /** - * adds a new entry to the questions Map + + /** * - * addNewQuestion(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * @param request - * @param form + * ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + + submits content into the tool database + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward addNewQuestion(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching addNewQuestion..."); - McUtils.debugMaps(request); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); + public ActionForward submitAllContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispathcing submitAllContent :" +form); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); - AuthoringUtil.readData(request, mcAuthoringForm, false); + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - Map mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); - logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); - - logger.debug("will validate questions are not empty"); - boolean questionsNotEmptyValid=AuthoringUtil.validateQuestionsNotEmpty(mapQuestionsContent); - logger.debug("questionsNotEmptyValid:" + questionsNotEmptyValid); - - if (questionsNotEmptyValid == false) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.question.empty")); - request.getSession().setAttribute(USER_EXCEPTION_QUESTION_EMPTY, new Boolean(true).toString()); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.question.empty"); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - logger.debug("will validate weights"); - Map mapWeights= AuthoringUtil.repopulateCurrentWeightsMap(request, "questionWeight"); - logger.debug("mapWeights: " + mapWeights); - - boolean weightsValid=validateQuestionWeights(request,mapWeights, mcAuthoringForm); - logger.debug("weightsValid:" + weightsValid); - if (weightsValid == false) - { - mcAuthoringForm.resetUserAction(); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - - logger.debug("will validate SubTotalWeights"); - boolean subWeightsValid=AuthoringUtil.validateSubTotalWeights(request,mcAuthoringForm); - logger.debug("subWeightsValid:" + subWeightsValid); - if (subWeightsValid == false) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.question.weight.total")); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_TOTAL, new Boolean(true).toString()); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.question.weight.total"); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - logger.debug("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS)); - - AuthoringUtil.addQuestionMemory(request, mcAuthoringForm, mapQuestionsContent, true); - logger.debug("after addQuestionMemory"); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("resetting EDIT_OPTIONS_MODE to 0"); - mcAuthoringForm.resetUserAction(); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - - logger.debug("printing final maps..."); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); - - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent: " + mcContent); + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + Map mapQuestionContent=AuthoringUtil.extractMapQuestionContent(listQuestionContentDTO); + logger.debug("extracted mapQuestionContent: " + mapQuestionContent); + + Map mapFeedback=AuthoringUtil.extractMapFeedback(listQuestionContentDTO); + logger.debug("extracted mapFeedback: " + mapFeedback); + + Map mapWeights=new TreeMap(new McComparator()); + + Map mapMarks=AuthoringUtil.extractMapMarks(listQuestionContentDTO); + logger.debug("extracted mapMarks: " + mapMarks); - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - return (mapping.findForward(destination)); - } - - - /** - * removes an entry from the questions Map - removeQuestion(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * - * removeQuestion(HttpServletRequest request, McAuthoringForm mcAuthoringForm, ActionMapping mapping) - * @param request - * @param form - * @param mapping - * @return ActionForward - */ - public ActionForward removeQuestion(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching removeQuestion..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - - McUtils.debugMaps(request); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); + Map mapCandidatesList=AuthoringUtil.extractMapCandidatesList(listQuestionContentDTO); + logger.debug("extracted mapCandidatesList: " + mapCandidatesList); + + + ActionMessages errors = new ActionMessages(); + logger.debug("mapQuestionContent size: " + mapQuestionContent.size()); + + if (mapQuestionContent.size() == 0) + { + ActionMessage error = new ActionMessage("questions.none.submitted"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + logger.debug("errors: " + errors); + + AuthoringUtil authoringUtil= new AuthoringUtil(); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); - AuthoringUtil.readData(request, mcAuthoringForm, false); + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + List attachmentListBackup= new ArrayList(); + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + attachmentListBackup=attachmentList; + + List deletedAttachmentListBackup= new ArrayList(); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + deletedAttachmentListBackup=deletedAttachmentList; + + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOfflineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + + } - Map mapWeights= AuthoringUtil.repopulateMap(request, "questionWeight"); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - logger.debug("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS)); - + + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - Map mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); - logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); + String richTextTitle = request.getParameter(TITLE); + String richTextInstructions = request.getParameter(INSTRUCTIONS); - String questionIndex =mcAuthoringForm.getQuestionIndex(); - logger.debug("questionIndex:" + questionIndex); - String deletableQuestionEntry=(String)mapQuestionsContent.get(questionIndex); - logger.debug("deletableQuestionEntry:" + deletableQuestionEntry); + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + mcGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - if (deletableQuestionEntry != null) - { - if (!(deletableQuestionEntry.equals(""))) - { - mapQuestionsContent.remove(questionIndex); - logger.debug("removed entry:" + deletableQuestionEntry + " from the Map"); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - } + logger.debug("there are no issues with input, continue and submit data"); + + McContent mcContentTest=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContentTest: " + mcContentTest); + + logger.debug("errors: " + errors); + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); } - else - { - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - } - - - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - if (mapGeneralOptionsContent.size() > 0) - { - logger.debug("initial test: current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent= AuthoringUtil.removeFromMap(mapGeneralOptionsContent, questionIndex); - logger.debug("mapGeneralOptionsContent after remove: " + mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - } - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - if (mapGeneralSelectedOptionsContent.size() > 0) - { - logger.debug("initial test: current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent= AuthoringUtil.removeFromMap(mapGeneralSelectedOptionsContent, questionIndex); - logger.debug("mapGeneralSelectedOptionsContent after remove: " + mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - } - - mapWeights= (Map)request.getSession().getAttribute(MAP_WEIGHTS); - if (mapWeights.size() > 0) - { - logger.debug("initial test: current mapWeights: " + mapWeights); - mapWeights= AuthoringUtil.removeFromMap(mapWeights, questionIndex); - logger.debug("mapWeights after remove: " + mapWeights); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - } - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("resetting EDIT_OPTIONS_MODE to 0"); - mcAuthoringForm.resetUserAction(); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); - - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent: " + mcContent); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - } + McContent mcContent=mcContentTest; + if(errors.isEmpty()){ + logger.debug("errors is empty: " + errors); + authoringUtil.removeRedundantQuestions(mapQuestionContent, mcService, mcAuthoringForm, request, strToolContentID); + logger.debug("end of removing unused entries... "); + mcContent=authoringUtil.saveOrUpdateMcContent(mapQuestionContent, mapFeedback, mapWeights, + mapMarks, mapCandidatesList, mcService, mcAuthoringForm, request, mcContentTest, strToolContentID); + logger.debug("mcContent: " + mcContent); + + + long defaultContentID=0; + logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); + defaultContentID=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (mcContent != null) + { + mcGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + } + logger.debug("updated mcGeneralAuthoringDTO to: " + mcGeneralAuthoringDTO); + + authoringUtil.reOrganizeDisplayOrder(mapQuestionContent, mcService, mcAuthoringForm, mcContent); + logger.debug("post reOrganizeDisplayOrder: " + mcContent); - public ActionForward editOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - /* determine whether the request is from Monitoring url Edit Activity*/ - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - logger.debug("mcAuthoringForm : " + mcAuthoringForm); - - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); - IMcService mcService =McUtils.getToolService(request); - if (mcService == null) - { - logger.debug("will retrieve mcService"); - mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - logger.debug("retrieving mcService from cache: " + mcService); - } - request.getSession().setAttribute(TOOL_SERVICE, mcService); - logger.debug("mcService : " + mcService); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); - - boolean performEditOptions=performEditOptions(mapping, form, request, response, false, false); - logger.debug("performEditOptions: " + performEditOptions); + List attachments=saveAttachments(mcContent, attachmentList, deletedAttachmentList, mapping, request); + logger.debug("attachments: " + attachments); + } + + logger.debug("strToolContentID: " + strToolContentID); + McUtils.setDefineLater(request, false, strToolContentID, mcService); + logger.debug("define later set to false"); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + if (activeModule.equals(AUTHORING)) + { + logger.debug("standard authoring close"); + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG,Boolean.TRUE); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + } + else + { + logger.debug("go back to view only screen"); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + } + + } + else + { + logger.debug("errors is not empty: " + errors); + + if (mcContent != null) + { + long defaultContentID=0; + logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); + defaultContentID=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + logger.debug("retrieved tool default contentId: " + defaultContentID); + + if (mcContent != null) + { + mcGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + } + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + } + } + + + mcGeneralAuthoringDTO.setSbmtSuccess(new Integer(1).toString()); + + mcAuthoringForm.resetUserAction(); + mcGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + request.getSession().setAttribute(httpSessionID, sessionMap); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); - return (mapping.findForward(destination)); + logger.debug("forwarding to :" + LOAD_QUESTIONS); + return mapping.findForward(LOAD_QUESTIONS); } + /** - * prepares the UI so that candidate answers for a question can be edited - * editOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) * - * @param request - * @param form + * saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public boolean performEditOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, boolean defaultStarter, boolean requestByStarter) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("starting performEditOptions...requestByStarter : " + requestByStarter); - logger.debug("defaultStarter:" + defaultStarter); - McUtils.debugMaps(request); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, requestByStarter); + public ActionForward saveSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + + logger.debug("dispathcing saveSingleQuestion"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); - - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("initial test: current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); - Map mapQuestionsContent= new TreeMap(new McComparator()); - Map mapWeights= new TreeMap(new McComparator()); - if (!defaultStarter) - { - mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - mapWeights= AuthoringUtil.repopulateMap(request, "questionWeight"); - } - else - { - mapQuestionsContent= (Map)request.getSession().getAttribute(MAP_QUESTIONS_CONTENT); - mapWeights=(Map)request.getSession().getAttribute(MAP_WEIGHTS); - } - logger.debug("mapWeights: " + mapWeights); - logger.debug("mapQuestionsContent after shrinking: " + mapQuestionsContent); - logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); - + boolean validateSingleCorrectCandidate=authoringUtil.validateSingleCorrectCandidate(caList); + logger.debug("validateSingleCorrectCandidate: " + validateSingleCorrectCandidate); + + + ActionMessages errors = new ActionMessages(); + + + if (caList.size() == 0) + { + ActionMessage error = new ActionMessage("candidates.none.provided"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + + + if (!validateSingleCorrectCandidate) + { + ActionMessage error = new ActionMessage("candidates.none.correct"); + errors.add(ActionMessages.GLOBAL_MESSAGE, error); + } + logger.debug("errors: " + errors); - logger.debug("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS)); - - String questionIndex =mcAuthoringForm.getQuestionIndex(); - logger.debug("questionIndex:" + questionIndex); - - if (defaultStarter) - { - logger.debug("since the request is from default content set question index to 1:"); - questionIndex="1"; - } - - request.getSession().setAttribute(SELECTED_QUESTION_INDEX, questionIndex); - logger.debug("set SELECTED_QUESTION_INDEX to:" + questionIndex); - - Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId:" + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + if(!errors.isEmpty()){ + saveErrors(request, errors); + logger.debug("errors saved: " + errors); + } - Map mapIncorrectFeedback=new TreeMap(new McComparator()); - Map mapCorrectFeedback=new TreeMap(new McComparator()); - - logger.debug("getting feedback maps from cache, start using: feedback maps. "); - mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); - logger.debug("mapIncorrectFeedback:" + mapIncorrectFeedback); - mapCorrectFeedback=(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); - logger.debug("mapCorrectFeedback:" + mapCorrectFeedback); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("entry using mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + mcGeneralAuthoringDTO.setPassMarkValue(passmark); - if (mapIncorrectFeedback != null) - { - logger.debug("mapIncorrectFeedback, condition1 "); - String incorrectFeedback=""; - if (mapIncorrectFeedback.size() > 0) - { - logger.debug("mapIncorrectFeedback size > 0"); - incorrectFeedback=(String)mapIncorrectFeedback.get(questionIndex); - logger.debug("incorrectFeedback:" + incorrectFeedback); - request.getSession().setAttribute(RICHTEXT_INCORRECT_FEEDBACK,incorrectFeedback); - } - } + + if(errors.isEmpty()) + { + logger.debug("errors is empty: " + errors); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); - if (mapCorrectFeedback != null) - { - logger.debug("mapCorrectFeedback, condition2 "); - String correctFeedback=""; - if (mapCorrectFeedback.size() > 0) - { - logger.debug("mapCorrectFeedback size > 0"); - correctFeedback=(String)mapCorrectFeedback.get(questionIndex); - logger.debug("correctFeedback:" + correctFeedback); - request.getSession().setAttribute(RICHTEXT_CORRECT_FEEDBACK,correctFeedback); - } - } + + String editableQuestionIndex=request.getParameter("editableQuestionIndex"); + logger.debug("editableQuestionIndex: " + editableQuestionIndex); + mcAuthoringForm.setQuestionIndex(editableQuestionIndex); + + if ((newQuestion != null) && (newQuestion.length() > 0)) + { + if ((editQuestionBoxRequest != null) && (editQuestionBoxRequest.equals("false"))) + { + logger.debug("request for add and save"); + boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + logger.debug("duplicates: " + duplicates); + + if (!duplicates) + { + McQuestionContentDTO mcQuestionContentDTO= null; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + logger.debug("displayOrder:" + displayOrder); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(editableQuestionIndex)) + { + break; + } + + } + } + logger.debug("mcQuestionContentDTO found:" + mcQuestionContentDTO); + + mcQuestionContentDTO.setQuestion(newQuestion); + mcQuestionContentDTO.setFeedback(feedback); + mcQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + mcQuestionContentDTO.setMark(mark); + + logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); + mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); + + + listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, mcQuestionContentDTO, editableQuestionIndex); + logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); + } + else + { + logger.debug("duplicate question entry, not adding"); + } + } + else + { + logger.debug("request for edit and save."); + McQuestionContentDTO mcQuestionContentDTO= null; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + logger.debug("displayOrder:" + displayOrder); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(editableQuestionIndex)) + { + break; + } + + } + } + logger.debug("mcQuestionContentDTO found:" + mcQuestionContentDTO); + + mcQuestionContentDTO.setQuestion(newQuestion); + mcQuestionContentDTO.setFeedback(feedback); + mcQuestionContentDTO.setDisplayOrder(editableQuestionIndex); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + mcQuestionContentDTO.setMark(mark); + + logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); + mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); + + listQuestionContentDTO=AuthoringUtil.reorderUpdateListQuestionContentDTO(listQuestionContentDTO, mcQuestionContentDTO, editableQuestionIndex); + logger.debug("post reorderUpdateListQuestionContentDTO listQuestionContentDTO: " + listQuestionContentDTO); + } + } + else + { + logger.debug("entry blank, not adding"); + } - String editableQuestionEntry=(String)mapQuestionsContent.get(questionIndex); - logger.debug("editableQuestionEntry:" + editableQuestionEntry); - request.getSession().setAttribute(SELECTED_QUESTION, editableQuestionEntry); + logger.debug("entryusing mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); - String editableQuestionWeight=(String)mapWeights.get(questionIndex); - logger.debug("editableQuestionWeight:" + editableQuestionWeight); + commonSaveCode(request, mcGeneralAuthoringDTO, + mcAuthoringForm, sessionMap, activeModule, strToolContentID, + defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); - if (!defaultStarter) - { - logger.debug("since the request is from within the class do the check:"); - if ((editableQuestionEntry == null) || (editableQuestionEntry.equals(""))) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.emptyQuestion")); - request.getSession().setAttribute(USER_EXCEPTION_QUESTION_EMPTY, new Boolean(true).toString()); - logger.debug("add error.emptyQuestion to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - McUtils.debugMaps(request); - return false; - } - - if ((editableQuestionWeight == null) || (editableQuestionWeight.equals(""))) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.emptyWeight")); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_EMPTY, new Boolean(true).toString()); - logger.debug("add error.emptyWeight to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - McUtils.debugMaps(request); - return false; - } - } - - /*persist valid question and weights maps into session*/ - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - - String selectedQuestionIndex=(String) request.getSession().getAttribute(SELECTED_QUESTION_INDEX); - logger.debug("SELECTED_QUESTION_INDEX to:" + selectedQuestionIndex); + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + else + { + logger.debug("errors is not empty: " + errors); + + commonSaveCode(request, mcGeneralAuthoringDTO, + mcAuthoringForm, sessionMap, activeModule, strToolContentID, + defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + logger.debug("forwarding using newEditableQuestionBox"); + return newEditableQuestionBox(mapping, form, request, response); + } + + } + + + /** + * commonSaveCode(HttpServletRequest request, McGeneralAuthoringDTO mcGeneralAuthoringDTO, + McAuthoringForm mcAuthoringForm, SessionMap sessionMap, String activeModule, String strToolContentID, + String defaultContentIdStr, IMcService mcService, String httpSessionID, List listQuestionContentDTO) + * + * @param request + * @param mcGeneralAuthoringDTO + * @param mcAuthoringForm + * @param sessionMap + * @param activeModule + * @param strToolContentID + * @param defaultContentIdStr + * @param mcService + * @param httpSessionID + * @param listQuestionContentDTO + */ + protected void commonSaveCode(HttpServletRequest request, McGeneralAuthoringDTO mcGeneralAuthoringDTO, + McAuthoringForm mcAuthoringForm, SessionMap sessionMap, String activeModule, String strToolContentID, + String defaultContentIdStr, IMcService mcService, String httpSessionID, List listQuestionContentDTO) + { + String richTextTitle = request.getParameter(TITLE); + String richTextInstructions = request.getParameter(INSTRUCTIONS); + + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - logger.debug("mapGeneralOptionsContent to be checked: " + mapGeneralOptionsContent); - Iterator itMapGeneral = mapGeneralOptionsContent.entrySet().iterator(); - boolean optionsPresentationValid=false; + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); - Map mapOptionsContent= new TreeMap(new McStringComparator()); - Map mapSelectedOptions= new TreeMap(new McComparator()); - Map mapGsoc=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGsoc from the cache: " + mapGsoc); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); - /* extract the relavent question's option from the larger Map */ - boolean optionsCacheDataFound=false; - while (itMapGeneral.hasNext()) - { - optionsCacheDataFound=false; - Map.Entry pairs = (Map.Entry)itMapGeneral.next(); - logger.debug("using the pair: " + pairs); - logger.debug("using the pair entries: " + pairs.getKey() + " = " + pairs.getValue()); - - if ((pairs.getKey() != null)) - { - if (pairs.getKey().equals(selectedQuestionIndex)) - { - logger.debug("question found with options in the cache"); - mapOptionsContent=(Map) pairs.getValue(); - logger.debug("mapOptionsContent from the cache: " + mapOptionsContent); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("updated MAP_OPTIONS_CONTENT: " + mapOptionsContent); - - logger.debug("mapGsoc: " + mapGsoc); - Iterator itMapSelected = mapGsoc.entrySet().iterator(); - - while (itMapSelected.hasNext()) { - - Map.Entry spairs = (Map.Entry)itMapSelected.next(); - logger.debug("using the spairs entries: " + spairs.getKey() + " = " + spairs.getValue()); - - if ((spairs.getKey() != null)) - { - if (spairs.getKey().equals(selectedQuestionIndex)) - { - logger.debug("selected options for question found in the cache"); + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOfflineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); - mapSelectedOptions=(Map) spairs.getValue(); - logger.debug("mapSelectedOptionsContent from the cache: " + mapSelectedOptions); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - logger.debug("updated MAP_SELECTED_OPTIONS: " + mapSelectedOptions); - } - } - } - optionsCacheDataFound=true; - break; - } - } - } + } + - logger.debug("optionsCacheDataFound to be checked: " + optionsCacheDataFound); - if (optionsCacheDataFound == true) - { - logger.debug("we should not arrive here."); - } - else - { - mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); - - McQueContent mcQueContent=null; - if (mcContent != null) - { - logger.debug("mcContent is not null"); - mcQueContent=mcService.getQuestionContentByQuestionText(editableQuestionEntry, mcContent.getUid()); - logger.debug("mcQueContent:" + mcQueContent); - } - - if (mcQueContent != null) - { - logger.debug("mcQueContent is not null " + mcQueContent.getUid()); - List listOptionsContent=mcService.findMcOptionsContentByQueId(mcQueContent.getUid()); - logger.debug("listOptionsContent: " + listOptionsContent); - - mapOptionsContent= new TreeMap(new McStringComparator()); - mapSelectedOptions= new TreeMap(new McComparator()); - - /* options have been persisted before */ - if (listOptionsContent != null) - { - logger.debug("listOptionsContent not null" ); - Iterator listIteratorOptions=listOptionsContent.iterator(); - Long mapIndex=new Long(1); - while (listIteratorOptions.hasNext()) - { - McOptsContent mcOptsContent=(McOptsContent)listIteratorOptions.next(); - logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); - mapOptionsContent.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); - mapIndex=new Long(mapIndex.longValue()+1); - } - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("MAP_OPTIONS_CONTENT reconstructed from db" ); - - - /* we have to assume that some of the options are selected as this is forced in the ui. - * retrieve and present the selected options from the db - * */ - List listSelectedOptions=mcService.getPersistedSelectedOptions(mcQueContent.getUid()); - logger.debug("listSelectedOptions:" + listSelectedOptions); - - if (listSelectedOptions != null) - { - Iterator listIteratorSelectedOptions=listSelectedOptions.iterator(); - mapIndex=new Long(1); - while (listIteratorSelectedOptions.hasNext()) - { - McOptsContent mcOptsContent=(McOptsContent)listIteratorSelectedOptions.next(); - logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); - mapSelectedOptions.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); - mapIndex=new Long(mapIndex.longValue()+1); - } - } - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - logger.debug("MAP_SELECTED_OPTIONS reconstructed from db:" + mapSelectedOptions); - } - else - { - logger.debug("listOptionsContent is null: no options persisted yet" ); - logger.debug("present default options content" ); - Long queContentUID=(Long)request.getSession().getAttribute(DEFAULT_QUESTION_UID); - logger.debug("DEFAULT_QUESTION_UID: " + queContentUID); - List listDefaultOption=mcService.findMcOptionsContentByQueId(queContentUID); - logger.debug("listDefaultOption: " + listDefaultOption); - - /** normally iterates only once */ - if (listDefaultOption != null) - { - Iterator itDefaultOption=listDefaultOption.iterator(); - Long mapIndex=new Long(1); - while (itDefaultOption.hasNext()) - { - McOptsContent mcOptsContent=(McOptsContent)itDefaultOption.next(); - logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); - mapOptionsContent.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); - mapIndex=new Long(mapIndex.longValue()+1); - } - } - logger.debug("mapOptionsContent from default content: " + mapOptionsContent); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("MAP_OPTIONS_CONTENT reconstructed from default option content" ); - - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - logger.debug("MAP_SELECTED_OPTIONS set as empty list :" + mapSelectedOptions); - } + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - /* present the feedback content the same way for the conditions above*/ - logger.debug("present the feedback content the same way for the conditions above.."); - String richTextFeedbackInCorrect=mcQueContent.getFeedbackIncorrect(); - logger.debug("richTextFeedbackInCorrect: " + richTextFeedbackInCorrect); - if (richTextFeedbackInCorrect == null) richTextFeedbackInCorrect=""; - request.getSession().setAttribute(RICHTEXT_FEEDBACK_INCORRECT,richTextFeedbackInCorrect); - - String richTextFeedbackCorrect=mcQueContent.getFeedbackCorrect(); - logger.debug("richTextFeedbackCorrect: " + richTextFeedbackCorrect); - if (richTextFeedbackCorrect == null) richTextFeedbackCorrect=""; - request.getSession().setAttribute(RICHTEXT_FEEDBACK_CORRECT,richTextFeedbackCorrect); - } - else - { - logger.debug("mcQueContent is null " + mcQueContent); - logger.debug("optionsPresentationValid is false, present default content"); - logger.debug("listOptionsContent is null: no options persisted yet" ); - logger.debug("present default options content" ); - Long queContentUID=(Long)request.getSession().getAttribute(DEFAULT_QUESTION_UID); - logger.debug("DEFAULT_QUESTION_UID: " + queContentUID); - List listDefaultOption=mcService.findMcOptionsContentByQueId(queContentUID); - logger.debug("listDefaultOption: " + listDefaultOption); - - /* normally iterates only once */ - if (listDefaultOption != null) - { - Iterator itDefaultOption=listDefaultOption.iterator(); - Long mapIndex=new Long(1); - while (itDefaultOption.hasNext()) - { - McOptsContent mcOptsContent=(McOptsContent)itDefaultOption.next(); - logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); - mapOptionsContent.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); - mapIndex=new Long(mapIndex.longValue()+1); - } - } - logger.debug("mapOptionsContent from default content: " + mapOptionsContent); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("MAP_OPTIONS_CONTENT reconstructed from default option content" ); - - mapSelectedOptions.put("1",DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - logger.debug("MAP_SELECTED_OPTIONS set as empty list :" + mapSelectedOptions); - } - } - - logger.debug("final mapOptionsContent used is: " + mapOptionsContent); - if (mapOptionsContent.isEmpty()) - { - logger.debug("mapOptionsContent is empty"); - mapOptionsContent.put("1","sample answer 1"); - mapSelectedOptions = mapOptionsContent; - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("current mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - mapGeneralOptionsContent.put(questionIndex,mapOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - Map mapGeneralSelectedOptionsContent=mapGeneralOptionsContent; - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - } - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("resetting EDIT_OPTIONS_MODE to 1"); - mcAuthoringForm.resetUserAction(); - - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + - String richTextFeedbackInCorrect=(String) request.getSession().getAttribute(RICHTEXT_FEEDBACK_INCORRECT); - logger.debug("before forward2 richTextFeedbackInCorrect: " + richTextFeedbackInCorrect); - if ((richTextFeedbackInCorrect == null) || (richTextFeedbackInCorrect=="")) - { - request.getSession().setAttribute(RICHTEXT_INCORRECT_FEEDBACK,DEFAULT_FEEDBACK_INCORRECT); - } - + AuthoringUtil authoringUtil = new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + - String richTextFeedbackCorrect=(String) request.getSession().getAttribute(RICHTEXT_FEEDBACK_CORRECT); - logger.debug("before forward2 richTextFeedbackCorrect: " + richTextFeedbackCorrect); - if ((richTextFeedbackCorrect == null) || (richTextFeedbackCorrect=="")) - { - request.getSession().setAttribute(RICHTEXT_CORRECT_FEEDBACK,DEFAULT_FEEDBACK_CORRECT); - } + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + logger.debug("httpSessionID: " + httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + request.getSession().setAttribute(httpSessionID, sessionMap); + logger.debug("mcGeneralAuthoringDTO.getMapQuestionContent(); " + mcGeneralAuthoringDTO.getMapQuestionContent()); - - return true; - } + } + /** - * adds an option entry to the options Map - * addOption(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response + * addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward addOption(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching addOption..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); - - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - Map mapOptionsContent=AuthoringUtil.repopulateMap(request,"optionContent"); - logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); - logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size()); - - boolean verifyDuplicatesOptionsMap=AuthoringUtil.verifyDuplicatesOptionsMap(mapOptionsContent); - logger.debug("verifyDuplicatesOptionsMap: " + verifyDuplicatesOptionsMap); - if (verifyDuplicatesOptionsMap == false) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.answers.duplicate")); - request.getSession().setAttribute(USER_EXCEPTION_ANSWERS_DUPLICATE, new Boolean(true).toString()); - logger.debug("add error.answers.duplicate to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - boolean verifyMapNoEmptyString=AuthoringUtil.verifyMapNoEmptyString(mapOptionsContent); - logger.debug("verifyMapNoEmptyString: " + verifyMapNoEmptyString); - if (verifyDuplicatesOptionsMap == false) - { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.answers.empty")); - request.getSession().setAttribute(USER_EXCEPTION_ANSWER_EMPTY, new Boolean(true).toString()); - logger.debug("add error.answers.empty to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - - String selectedQuestionIndex=(String)request.getSession().getAttribute(SELECTED_QUESTION_INDEX); - logger.debug("selectedQuestionIndex:" + selectedQuestionIndex); + public ActionForward addSingleQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { - int mapSize=mapOptionsContent.size(); - mapOptionsContent.put(new Long(++mapSize).toString(), ""); - logger.debug("updated mapOptionsContent Map size: " + mapOptionsContent.size()); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + logger.debug("dispathcing addSingleQuestion"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent.put(selectedQuestionIndex,mapOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - logger.debug("updated MAP_GENERAL_OPTIONS_CONTENT after add: " + mapGeneralOptionsContent); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - Map mapSelectedOptions= (Map) request.getSession().getAttribute(MAP_SELECTED_OPTIONS); - mapSelectedOptions.clear(); - mapSelectedOptions = AuthoringUtil.repopulateCurrentCheckBoxStatesMap(request); - logger.debug("after add mapSelectedOptions: " + mapSelectedOptions); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent.put(selectedQuestionIndex,mapSelectedOptions); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - logger.debug("updated MAP_GENERAL_SELECTED_OPTIONS_CONTENT after add: " + mapGeneralSelectedOptionsContent); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("resetting EDIT_OPTIONS_MODE to 1"); - mcAuthoringForm.resetUserAction(); - - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); + mcGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); + AuthoringUtil authoringUtil= new AuthoringUtil(); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + mcGeneralAuthoringDTO.setPassMarkValue(passmark); + - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + List caList=new LinkedList(); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + McCandidateAnswersDTO mcCandidateAnswersDTO= new McCandidateAnswersDTO(); + mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 1"); + mcCandidateAnswersDTO.setCorrect("Incorrect"); + caList.add(mcCandidateAnswersDTO); + + mcCandidateAnswersDTO= new McCandidateAnswersDTO(); + mcCandidateAnswersDTO.setCandidateAnswer("Candidate Answer 2"); + mcCandidateAnswersDTO.setCorrect("Correct"); + caList.add(mcCandidateAnswersDTO); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - } + + + int listSize=listQuestionContentDTO.size(); + logger.debug("listSize: " + listSize); + + if ((newQuestion != null) && (newQuestion.length() > 0)) + { + boolean duplicates=AuthoringUtil.checkDuplicateQuestions(listQuestionContentDTO, newQuestion); + logger.debug("duplicates: " + duplicates); + + if (!duplicates) + { + McQuestionContentDTO mcQuestionContentDTO=new McQuestionContentDTO(); + mcQuestionContentDTO.setDisplayOrder(new Long(listSize+1).toString()); + mcQuestionContentDTO.setFeedback(feedback); + mcQuestionContentDTO.setQuestion(newQuestion); + mcQuestionContentDTO.setMark(mark); + + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + logger.debug("caList size:" + mcQuestionContentDTO.getListCandidateAnswersDTO().size()); + mcQuestionContentDTO.setCaCount(new Integer(mcQuestionContentDTO.getListCandidateAnswersDTO().size()).toString()); + + listQuestionContentDTO.add(mcQuestionContentDTO); + logger.debug("updated listQuestionContentDTO: " + listQuestionContentDTO); + } + else + { + logger.debug("entry duplicate, not adding"); + } + } + else + { + logger.debug("entry blank, not adding"); + } + + + logger.debug("entry using mark: " + mark); + mcGeneralAuthoringDTO.setMarkValue(mark); + + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + commonSaveCode(request, mcGeneralAuthoringDTO, + mcAuthoringForm, sessionMap, activeModule, strToolContentID, + defaultContentIdStr, mcService, httpSessionID,listQuestionContentDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + + } + - /** - * removes an option entry from the options Map - * removeOption(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form + * opens up an new screen within the current page for adding a new question + * + * newQuestionBox * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward removeOption(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + public ActionForward newQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching removeOption..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); + logger.debug("dispathcing newQuestionBox"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - String optionIndex =mcAuthoringForm.getDeletableOptionIndex(); - logger.debug("optionIndex:" + optionIndex); - - Map mapOptionsContent=AuthoringUtil.repopulateMap(request, "optionContent"); - logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); - logger.debug("mapOptionsContent size after shrinking: " + mapOptionsContent.size()); - int mapSize=mapOptionsContent.size(); - if ((mapSize == 1) && (optionIndex.equals("1"))) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_OPTIONS_COUNT_ZERO, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("options.count.zero")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"options.count.zero"); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE :" + 1); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - - String deletableOptionEntry=(String)mapOptionsContent.get(optionIndex); - logger.debug("deletableOptionEntry:" + deletableOptionEntry); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); - if (deletableOptionEntry != null) - { - if (!(deletableOptionEntry.equals(""))) - { - mapOptionsContent.remove(optionIndex); - logger.debug("removed entry:" + deletableOptionEntry + " from the Map"); - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("updated Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); - } - } - - String selectedQuestionIndex=(String)request.getSession().getAttribute(SELECTED_QUESTION_INDEX); - logger.debug("selectedQuestionIndex:" + selectedQuestionIndex); + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent.put(selectedQuestionIndex,mapOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - logger.debug("updated MAP_GENERAL_OPTIONS_CONTENT after remove: " + mapGeneralOptionsContent); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - Map mapSelectedOptions= (Map) request.getSession().getAttribute(MAP_SELECTED_OPTIONS); - mapSelectedOptions.clear(); - mapSelectedOptions = AuthoringUtil.repopulateCurrentCheckBoxStatesMap(request); - logger.debug("after add mapSelectedOptions: " + mapSelectedOptions); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent.put(selectedQuestionIndex,mapSelectedOptions); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - logger.debug("updated MAP_GENERAL_SELECTED_OPTIONS_CONTENT after add: " + mapGeneralSelectedOptionsContent); + /* create default mcContent object*/ + McContent mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); + logger.debug("mcContent: " + mcContent); - /* update feedback Maps*/ - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("resetting EDIT_OPTIONS_MODE to 1"); - mcAuthoringForm.resetUserAction(); + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + String richTextTitle = request.getParameter(TITLE); + String richTextInstructions = request.getParameter(INSTRUCTIONS); + + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); - - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - } - - - /** - * moves a question entry a step down the questions Map - * moveQuestionDown(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * - * @param request - * @param form - * @param mapping - * @return ActionForward - */ - public ActionForward moveQuestionDown(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching moveQuestionDown..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); + AuthoringUtil authoringUtil = new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - AuthoringUtil.readData(request, mcAuthoringForm, false); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); - - - Map mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - logger.debug("mapQuestionsContent before move down: " + mapQuestionsContent); - logger.debug("mapQuestionsContent size move down: " + mapQuestionsContent.size()); + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); - Map mapDefaultOptions= new TreeMap(new McComparator()); - mapDefaultOptions.put("1" ,DEFAULT_FIRST_OPTION); - mapDefaultOptions.put("2" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptions); + + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + String requestType=request.getParameter("requestType"); + logger.debug("requestType: " + requestType); - Map mapDefaultSelectedOptions= new TreeMap(new McComparator()); - mapDefaultSelectedOptions.put("1" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTSELECTEDOPTIONS_CONTENT, mapDefaultSelectedOptions); + List listQuestionContentDTO=new LinkedList(); - //perform a move down if there are at least 2 questions - if (mapQuestionsContent.size() > 1) - { - String questionIndex =mcAuthoringForm.getQuestionIndex(); - logger.debug("questionIndex:" + questionIndex); - String movableQuestionEntry=(String)mapQuestionsContent.get(questionIndex); - logger.debug("movableQuestionEntry:" + movableQuestionEntry); - - if (movableQuestionEntry != null && (!movableQuestionEntry.equals(""))) - { - mapQuestionsContent= AuthoringUtil.shiftMap(mapQuestionsContent, questionIndex,movableQuestionEntry, "down"); - logger.debug("mapQuestionsContent after move down: " + mapQuestionsContent); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent=AuthoringUtil.addDefaultOptionsContentToMap(request, mapGeneralOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralOptionsContent after adding default options: " + mapGeneralOptionsContent); + if ((requestType != null) && (requestType.equals("direct"))) + { + logger.debug("getting the list from the db: "); + listQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + + int count=listQuestionContentDTO.size(); + logger.debug("question count: " + count); + request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count + 1)); - if (mapGeneralOptionsContent.size() > 1) - { - logger.debug("initial test: current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent= AuthoringUtil.shiftOptionsMap(mapGeneralOptionsContent, questionIndex, "down"); - logger.debug("mapGeneralOptionsContent after move down: " + mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - } - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent=AuthoringUtil.addDefaultSelectedOptionsContentToMap(request, mapGeneralSelectedOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralSelectedOptionsContent after adding default options: " + mapGeneralOptionsContent); - - if (mapGeneralSelectedOptionsContent.size() > 1) - { - logger.debug("initial test: current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent= AuthoringUtil.shiftOptionsMap(mapGeneralSelectedOptionsContent, questionIndex, "down"); - logger.debug("mapGeneralSelectedOptionsContent after move down: " + mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - } - - Map mapWeights= AuthoringUtil.repopulateCurrentWeightsMap(request, "questionWeight"); - if (mapWeights.size() > 1) - { - logger.debug("initial test: current mapWeights: " + mapWeights); - mapWeights= AuthoringUtil.shiftWeightsMap(mapWeights, questionIndex, "down"); - logger.debug("mapWeights after move down: " + mapWeights); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - } - - Map mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); - logger.debug("mapIncorrectFeedback: " + mapIncorrectFeedback); - if (mapIncorrectFeedback.size() > 1) - { - mapIncorrectFeedback= AuthoringUtil.shiftFeedbackMap(mapIncorrectFeedback, questionIndex, "down"); - logger.debug("mapIncorrectFeedback: " + mapIncorrectFeedback); - request.getSession().setAttribute(MAP_INCORRECT_FEEDBACK, mapIncorrectFeedback); - } - - Map mapCorrectFeedback=(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); - logger.debug("mapCorrectFeedback: " + mapCorrectFeedback); - if (mapCorrectFeedback.size() > 1) - { - mapCorrectFeedback= AuthoringUtil.shiftFeedbackMap(mapCorrectFeedback, questionIndex, "down"); - logger.debug("mapCorrectFeedback: " + mapCorrectFeedback); - request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); - } - } - } - - mcAuthoringForm.resetUserAction(); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("resetting EDIT_OPTIONS_MODE to 0"); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - logger.debug("printing final maps..."); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); + } + else + { + logger.debug("getting the list from the cache: "); + listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + int count=listQuestionContentDTO.size(); + logger.debug("question count: " + count); + request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX, new Integer(count)); + + } - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); - - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + + + logger.debug("fwd ing to newQuestionBox: "); + return (mapping.findForward("newQuestionBox")); } - - + + /** - * moves a question entry a step up the questions Map - * moveQuestionUp(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form + * opens up an new screen within the current page for editing a question + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward moveQuestionUp(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + public ActionForward newEditableQuestionBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching moveQuestionUp..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); + logger.debug("dispathcing newEditableQuestionBox"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - - Map mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - logger.debug("mapQuestionsContent before move down: " + mapQuestionsContent); - - Map mapDefaultOptions= new TreeMap(new McComparator()); - mapDefaultOptions.put("1" ,DEFAULT_FIRST_OPTION); - mapDefaultOptions.put("2" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptions); - + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); - Map mapDefaultSelectedOptions= new TreeMap(new McComparator()); - mapDefaultSelectedOptions.put("1" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTSELECTEDOPTIONS_CONTENT, mapDefaultSelectedOptions); - - /* perform a move up if there are at least 2 questions */ - if (mapQuestionsContent.size() > 1) - { - String questionIndex =mcAuthoringForm.getQuestionIndex(); - logger.debug("questionIndex:" + questionIndex); - String movableQuestionEntry=(String)mapQuestionsContent.get(questionIndex); - logger.debug("movableQuestionEntry:" + movableQuestionEntry); - - if (movableQuestionEntry != null && (!movableQuestionEntry.equals(""))) - { - mapQuestionsContent= AuthoringUtil.shiftMap(mapQuestionsContent, questionIndex,movableQuestionEntry, "up"); - logger.debug("mapQuestionsContent after move down: " + mapQuestionsContent); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("updated Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent=AuthoringUtil.addDefaultOptionsContentToMap(request, mapGeneralOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralOptionsContent after adding default options: " + mapGeneralOptionsContent); - - if (mapGeneralOptionsContent.size() > 1) - { - logger.debug("initial test: current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent= AuthoringUtil.shiftOptionsMap(mapGeneralOptionsContent, questionIndex, "up"); - logger.debug("mapGeneralOptionsContent after move up: " + mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - } - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent=AuthoringUtil.addDefaultSelectedOptionsContentToMap(request, mapGeneralSelectedOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralSelectedOptionsContent after adding default options: " + mapGeneralOptionsContent); - - if (mapGeneralSelectedOptionsContent.size() > 1) - { - logger.debug("initial test: current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent= AuthoringUtil.shiftOptionsMap(mapGeneralSelectedOptionsContent, questionIndex, "up"); - logger.debug("mapGeneralSelectedOptionsContent after move down: " + mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - } - - Map mapWeights= AuthoringUtil.repopulateCurrentWeightsMap(request, "questionWeight"); - if (mapWeights.size() > 1) - { - logger.debug("initial test: current mapWeights: " + mapWeights); - mapWeights= AuthoringUtil.shiftWeightsMap(mapWeights, questionIndex, "up"); - logger.debug("mapWeights after move down: " + mapWeights); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - } - - - Map mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); - logger.debug("mapIncorrectFeedback: " + mapIncorrectFeedback); - if (mapIncorrectFeedback.size() > 1) - { - mapIncorrectFeedback= AuthoringUtil.shiftFeedbackMap(mapIncorrectFeedback, questionIndex, "up"); - logger.debug("mapIncorrectFeedback: " + mapIncorrectFeedback); - request.getSession().setAttribute(MAP_INCORRECT_FEEDBACK, mapIncorrectFeedback); - } - - - Map mapCorrectFeedback=(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); - logger.debug("mapCorrectFeedback: " + mapCorrectFeedback); - if (mapCorrectFeedback.size() > 1) - { - mapCorrectFeedback= AuthoringUtil.shiftFeedbackMap(mapCorrectFeedback, questionIndex, "up"); - logger.debug("mapCorrectFeedback: " + mapCorrectFeedback); - request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); - } + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); - } - } - - mcAuthoringForm.resetUserAction(); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("resetting EDIT_OPTIONS_MODE to 0"); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - logger.debug("printing final maps..."); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); + request.setAttribute(CURRENT_EDITABLE_QUESTION_INDEX,questionIndex); - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); + mcAuthoringForm.setEditableQuestionIndex(questionIndex); - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - return (mapping.findForward(destination)); - } - - public ActionForward doneOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - logger.debug("dispatching doneOptions..."); - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - logger.debug("mcAuthoringForm: " + mcAuthoringForm); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); + String editableQuestion=""; + String editableFeedback=""; + String editableMark=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + editableFeedback=mcQuestionContentDTO.getFeedback(); + editableQuestion=mcQuestionContentDTO.getQuestion(); + editableMark=mcQuestionContentDTO.getMark(); + logger.debug("editableFeedback found :" + editableFeedback); + + List candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + + break; + } + + } + } + logger.debug("editableFeedback found :" + editableFeedback); + logger.debug("editableQuestion found :" + editableQuestion); + logger.debug("editableMark found :" + editableMark); - IMcService mcService =McUtils.getToolService(request); - if (mcService == null) - { - logger.debug("will retrieve mcService"); - mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - logger.debug("retrieving mcService from cache: " + mcService); - } - request.getSession().setAttribute(TOOL_SERVICE, mcService); - logger.debug("mcService : " + mcService); - - - boolean performDoneOptions=performDoneOptions(mapping, form, request, response, false, false); - logger.debug("performDoneOptions: " + performDoneOptions); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - } - - /** - * completes the candidate options screen - * doneOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * - * @param request - * @param form - * @param mapping - * @return ActionForward - */ - public boolean performDoneOptions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response, boolean defaultStarter, boolean requestByStarter) throws IOException, - ServletException - { - logger.debug("starting performDoneOptions.., requestByStarter:" + requestByStarter); - logger.debug("using defaultStarter: " + defaultStarter); - McUtils.cleanUpUserExceptions(request); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, requestByStarter); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - Map mapOptionsContent= new TreeMap(new McStringComparator()); - if (!defaultStarter) - { - mapOptionsContent=AuthoringUtil.repopulateMap(request, "optionContent"); - logger.debug("mapOptionsContent after shrinking: " + mapOptionsContent); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); - logger.debug("since defaultStarter is false the call is from within the class, do the checks"); - boolean validateOptions=AuthoringUtil.validateOptions(request); - logger.debug("validateOptions:" + validateOptions); - - if (validateOptions == false) - { - ActionMessages errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_CHKBOXES_EMPTY, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.checkBoxes.empty")); - logger.debug("add error.checkBoxes.empty to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - McUtils.debugMaps(request); - return false; - } - - - if (mapOptionsContent.size() == 1) - { - logger.debug("mapOptionsContent size is 1)"); - ActionMessages errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_SINGLE_OPTION, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.singleOption")); - logger.debug("add error.singleOption to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(1).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(1)); - logger.debug("setting EDIT_OPTIONS_MODE to 1"); - - McUtils.debugMaps(request); - return false; - } - }//end of checks - else - { - mapOptionsContent=(Map)request.getSession().getAttribute(MAP_OPTIONS_CONTENT); - logger.debug("mapOptionsContent: " + mapOptionsContent); - - } - - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - logger.debug("final done MAP_OPTIONS_CONTENT: " + mapOptionsContent); - - - String selectedQuestionIndex=(String) request.getSession().getAttribute(SELECTED_QUESTION_INDEX); - logger.debug("retrieved SELECTED_QUESTION_INDEX to:" + selectedQuestionIndex); + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - if (defaultStarter) - { - logger.debug("since the request is from default content set question index to 1:"); - selectedQuestionIndex="1"; - } - + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - /** update the questions Map with the new question*/ - Map mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT); - logger.debug("mapQuestionsContent: " + mapQuestionsContent); - String selectedQuestion=(String) request.getSession().getAttribute(SELECTED_QUESTION); - logger.debug("final selectedQuestion:" + selectedQuestion); - mapQuestionsContent.put(selectedQuestionIndex,selectedQuestion); - logger.debug("updated mapQuestionsContent with:" + selectedQuestionIndex + " and " + selectedQuestion); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("updated MAP_QUESTIONS_CONTENT:" + mapQuestionsContent); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - Map mapSelectedOptions= new TreeMap(new McComparator()); - if (defaultStarter) - { - logger.debug("defaultStarter is on, getting MAP_SELECTED_OPTIONS from session: "); - mapSelectedOptions= (Map) request.getSession().getAttribute(MAP_SELECTED_OPTIONS); - } - else - { - mapSelectedOptions = AuthoringUtil.repopulateCurrentCheckBoxStatesMap(request); - logger.debug("after add mapSelectedOptions: " + mapSelectedOptions); - } - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); - - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("current mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); - mapGeneralSelectedOptionsContent.put(selectedQuestionIndex,mapSelectedOptions); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - logger.debug("updated MAP_GENERAL_SELECTED_OPTIONS_CONTENT after add: " + mapGeneralSelectedOptionsContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + mcGeneralAuthoringDTO.setMarkValue(editableMark); - Map mapIncorrectFeedback=(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); - logger.debug("mapIncorrectFeedback:" + mapIncorrectFeedback); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + - logger.debug("using feedback maps, condition 3"); + String richTextTitle = request.getParameter(TITLE); + String richTextInstructions = request.getParameter(INSTRUCTIONS); + + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); - String richTextIncorrectFeedback=(String)request.getSession().getAttribute(RICHTEXT_INCORRECT_FEEDBACK); - logger.debug("richTextIncorrectFeedback:" + richTextIncorrectFeedback); - if (richTextIncorrectFeedback == null) richTextIncorrectFeedback=""; + mcGeneralAuthoringDTO.setEditableQuestionText(editableQuestion); + mcGeneralAuthoringDTO.setEditableQuestionFeedback (editableFeedback); + mcAuthoringForm.setFeedback(editableFeedback); - mapIncorrectFeedback.put(selectedQuestionIndex,richTextIncorrectFeedback); - logger.debug("mapIncorrectFeedback:" + mapIncorrectFeedback); - request.getSession().setAttribute(MAP_INCORRECT_FEEDBACK, mapIncorrectFeedback); - + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - Map mapCorrectFeedback=(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); - logger.debug("mapCorrectFeedback:" + mapCorrectFeedback); - - String richTextCorrectFeedback=(String)request.getSession().getAttribute(RICHTEXT_CORRECT_FEEDBACK); - logger.debug("richTextCorrectFeedback:" + richTextCorrectFeedback); - if (richTextCorrectFeedback == null) richTextCorrectFeedback=""; - - mapCorrectFeedback.put(selectedQuestionIndex,richTextCorrectFeedback); - logger.debug("mapCorrectFeedback:" + mapCorrectFeedback); - request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); + AuthoringUtil authoringUtil = new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("mcGeneralAuthoringDTO now: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("current mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralOptionsContent.put(selectedQuestionIndex,mapOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - logger.debug("updated MAP_GENERAL_OPTIONS_CONTENT after done: " + mapGeneralOptionsContent); + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - mcAuthoringForm.resetUserAction(); + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); + logger.debug("final listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - return true; + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + logger.debug("fwd ing to editQuestionBox: "); + return (mapping.findForward("editQuestionBox")); } - + + /** - * In the define later mode swithes the content view from view-only to editable and sets the defineLater flag of the content. * - * ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException + * ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + + removes a question from the questions map * - * * @param mapping * @param form * @param request * @param response * @return * @throws IOException * @throws ServletException - * @throws ToolException */ - public ActionForward editActivityQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - ToolException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching editActivityQuestions..."); - + public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching removeQuestion"); McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); - - IMcService mcService =McUtils.getToolService(request); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); - request.getSession().setAttribute(DEFINE_LATER_IN_EDIT_MODE, new Boolean(true)); - McUtils.setDefineLater(request, true); + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); + - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - } - - - /** - * submits questions Map and persists questions as well as options information in the db. - * submitQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) - * - * @param request - * @param form - * @param mapping - * @return ActionForward - */ - public ActionForward submitQuestions(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + McQuestionContentDTO mcQuestionContentDTO= null; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + logger.debug("displayOrder:" + displayOrder); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + break; + } + + } + } + + logger.debug("mcQuestionContentDTO found:" + mcQuestionContentDTO); + mcQuestionContentDTO.setQuestion(""); + logger.debug("listQuestionContentDTO after remove:" + listQuestionContentDTO); + + + listQuestionContentDTO=AuthoringUtil.reorderListQuestionContentDTO(listQuestionContentDTO, questionIndex ); + logger.debug("listQuestionContentDTO reordered:" + listQuestionContentDTO); + - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching submitQuestions..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - ActionMessages errors= new ActionMessages(); + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + - Map mapQuestionsContent=AuthoringUtil.repopulateMap(request, "questionContent"); - logger.debug("mapQuestionsContent before submit: " + mapQuestionsContent); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - - Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId:" + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent: " + mcContent); + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); - logger.debug("refreshed maps..."); - - Map mapStartupGeneralOptionsContent= (Map) request.getSession().getAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapStartupGeneralOptionsContent: " + mapStartupGeneralOptionsContent); + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - Map mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - mapGeneralOptionsContent=AuthoringUtil.addDefaultOptionsContentToMap(request, mapGeneralOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralOptionsContent after adding default options: " + mapGeneralOptionsContent); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - Map mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - mapGeneralSelectedOptionsContent=AuthoringUtil.addDefaultSelectedOptionsContentToMap(request, mapGeneralSelectedOptionsContent, mapQuestionsContent); - logger.debug("mapGeneralSelectedOptionsContent after adding default options: " + mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT,mapGeneralSelectedOptionsContent); - - - Boolean isRevisitingUser= (Boolean) request.getSession().getAttribute(IS_REVISITING_USER); - logger.debug("isRevisitingUser: " + isRevisitingUser); - - Map mapTestableOptionsContent=new TreeMap(new McComparator()); - if (isRevisitingUser.booleanValue() == true) + if (mcContent == null) { - logger.debug("this is a RevisitingUser, include startup general options content in the test"); - mapTestableOptionsContent=AuthoringUtil.mergeMaps(mapStartupGeneralOptionsContent, mapGeneralOptionsContent); - logger.debug("returned merged map: " + mapTestableOptionsContent); + logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); } - else - { - logger.debug("this is a NOT RevisitingUser, don't include startup general options content in the test"); - mapTestableOptionsContent=mapGeneralOptionsContent; - } - logger.debug("final mapTestableOptionsContent: " + mapTestableOptionsContent); + logger.debug("final mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - logger.debug("remove from mapQuestionsContent the questions with no options"); - /* remove from mapQuestionsContent the questions with no options */ - //mapQuestionsContent=AuthoringUtil.updateQuestionsMapForNoOptions(request, mapQuestionsContent, mapTestableOptionsContent); - logger.debug("returned mapQuestionsContent: " + mapQuestionsContent); - logger.debug("assign mapGeneralOptionsContent post test: " + mapTestableOptionsContent); - mapGeneralOptionsContent=mapTestableOptionsContent; - logger.debug("using mapGeneralOptionsContent post test: " + mapGeneralOptionsContent); - - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("persisted MAP_QUESTIONS_CONTENT: " + mapQuestionsContent); - - Boolean questionsWithNoOptions=(Boolean) request.getSession().getAttribute(QUESTIONS_WITHNO_OPTIONS); - logger.debug("questionsWithNoOptions: " + questionsWithNoOptions); - - /* make sure the questions Map is not empty*/ - int mapSize=mapQuestionsContent.size(); - logger.debug("mapSize: " + mapSize); - - if (mapSize == 0) - { - errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.questions.submitted.none")); - - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - request.getSession().setAttribute(USER_EXCEPTION_SUBMIT_NONE, new Boolean(true).toString()); - persistError(request,"error.questions.submitted.none"); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - Map mapWeights= AuthoringUtil.repopulateCurrentWeightsMap(request, "questionWeight"); - mapWeights= AuthoringUtil.updateCurrentWeightsMapForQuestionWithNoOptions(request, mapWeights, mapQuestionsContent); - logger.debug("returned updated mapWeights: " + mapWeights); - - logger.debug("MAP_WEIGHTS is valid, persist it to session"); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - - boolean weightsValid=validateQuestionWeights(request,mapWeights, mcAuthoringForm); - logger.debug("weightsValid:" + weightsValid); - if (weightsValid == false) - { - mcAuthoringForm.resetUserAction(); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil= new AuthoringUtil(); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + - - logger.debug("mapWeights: " + mapWeights); - boolean isTotalWeightsValid=AuthoringUtil.validateTotalWeight(mapWeights); - logger.debug("isTotalWeightsValid:" + isTotalWeightsValid); - if (isTotalWeightsValid == false) - { - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_MUST_EQUAL100, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.total.invalid")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.weights.total.invalid"); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("mcQuestionContentDTO now: " + mcQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - boolean isQuestionsSequenced=false; - boolean isSynchInMonitor=false; - boolean isUsernameVisible=false; - boolean isRetries=false; - boolean isShowFeedback=false; - boolean isSln=false; - boolean isReflect=false; + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + /** + * moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * + * moves a question down in the list + * + * moveQuestionDown + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward moveQuestionDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveQuestionDown"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String monitoringReportTitle=""; - String reportTitle=""; - String endLearningMessage=""; - int passmark=0; + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); - String questionsSequenced=request.getParameter("questionsSequenced"); - logger.debug("questionsSequenced: " + questionsSequenced); - if ((questionsSequenced != null) && (questionsSequenced.equalsIgnoreCase("1"))) - isQuestionsSequenced=true; + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); - String retries=request.getParameter("retries"); - logger.debug("retries: " + retries); - if ((retries != null) && (retries.equalsIgnoreCase("1"))) - isRetries=true; - + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "down"); + logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); - String sln=request.getParameter("sln"); - logger.debug("sln: " + sln); - if ((sln != null) && (sln.equalsIgnoreCase("1"))) - isSln=true; - - - String isReflectStr=request.getParameter("reflect"); - logger.debug("isReflectStr:" + isReflectStr); - if (isReflectStr != null) - { - if (isReflectStr.equals("1")) - isReflect=true; - } - + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + - String reflectionSubject=request.getParameter(REFLECTION_SUBJECT); - logger.debug("reflectionSubject: " + reflectionSubject); - + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + - logger.debug("passmark: " + mcAuthoringForm.getPassmark()); + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - if (mcAuthoringForm.getPassmark() != null) - { - if (mcAuthoringForm.getPassmark().equals("")) - mcAuthoringForm.setPassmark("0"); - - try - { - passmark= new Integer(mcAuthoringForm.getPassmark()).intValue(); - logger.debug("tried passmark: " + passmark); - } - catch(Exception e) - { - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_PASSMARK_NOTINTEGER, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.passmark.notInteger")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.passmark.notInteger"); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - } + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - if ((mcAuthoringForm.getPassmark() != null) && (mcAuthoringForm.getPassmark().length() > 0)) - { - passmark= new Integer(mcAuthoringForm.getPassmark()).intValue(); - logger.debug("populated passmark: " + passmark); - } - else - { - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_PASSMARK_EMPTY, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.passMark.empty")); - logger.debug("add error.passMark.empty to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - passmark= new Integer(mcAuthoringForm.getPassmark()).intValue(); - logger.debug("passmark: " + passmark); - if (passmark > 100) - { - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_PASSMARK_GREATER100, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.passMark.greater100")); - logger.debug("add error.passMark.greater100to ActionMessages"); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - logger.debug("return to destination to fix error."); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - request.getSession().setAttribute(PASSMARK, new Integer(passmark).toString()); + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil= new AuthoringUtil(); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + - String richTextTitle=request.getParameter(RICHTEXT_TITLE); - logger.debug("richTextTitle: " + richTextTitle); - - String richTextInstructions=request.getParameter(RICHTEXT_INSTRUCTIONS); - logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); - if (errors.size() > 0) - { - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - mcAuthoringForm.resetUserAction(); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - return (mapping.findForward(destination)); - } + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - String richTextOfflineInstructions=(String) request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); - logger.debug("richTextOfflineInstructions: " + richTextOfflineInstructions); - if (richTextOfflineInstructions == null) richTextOfflineInstructions=""; - String richTextOnlineInstructions=(String) request.getSession().getAttribute(RICHTEXT_ONLINEINSTRUCTIONS); - logger.debug("richTextOnlineInstructions: " + richTextOnlineInstructions); - if (richTextOnlineInstructions == null) richTextOnlineInstructions=""; + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + /** + * moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * + * moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward moveQuestionUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveQuestionUp"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - String richTextReportTitle=(String)request.getSession().getAttribute(RICHTEXT_REPORT_TITLE); - logger.debug("richTextReportTitle: " + richTextReportTitle); + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); - logger.debug("existing mcContent:" + mcContent); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); - String activeModule=(String)request.getSession().getAttribute(ACTIVE_MODULE); - logger.debug("activeModule:" + activeModule); + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); - - if (mcContent != null) - { - logger.debug("updating mcContent title and instructions:" + mcContent); - mcContent.setTitle(richTextTitle); - mcContent.setInstructions(richTextInstructions); - mcContent.setPassMark(new Integer(passmark)); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + listQuestionContentDTO=AuthoringUtil.swapNodes(listQuestionContentDTO, questionIndex, "up"); + logger.debug("listQuestionContentDTO after swap: " + listQuestionContentDTO); + + listQuestionContentDTO=AuthoringUtil.reorderSimpleListQuestionContentDTO(listQuestionContentDTO); + logger.debug("listQuestionContentDTO after reordersimple: " + listQuestionContentDTO); - if (activeModule.equals(AUTHORING)) - { - mcContent.setQuestionsSequenced(isQuestionsSequenced); - mcContent.setRetries(isRetries); - mcContent.setShowReport(isSln); - mcContent.setReflect(isReflect); - mcContent.setReflectionSubject(reflectionSubject); - mcContent.setOfflineInstructions(richTextOfflineInstructions); - mcContent.setOnlineInstructions(richTextOnlineInstructions); - mcContent.setReportTitle(richTextReportTitle); - mcContent.setMonitoringReportTitle("Monitoring Report"); - } - - } - else - { - mcContent=AuthoringUtil.createContent(request, mcAuthoringForm); - logger.debug("mcContent created"); - } - - mapQuestionsContent=(Map) request.getSession().getAttribute(MAP_QUESTIONS_CONTENT); - logger.debug("Submit final MAP_QUESTIONS_CONTENT :" + mapQuestionsContent); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + - Map mapIncorrectFeedback =(Map)request.getSession().getAttribute(MAP_INCORRECT_FEEDBACK); - logger.debug("Submit final MAP_FEEDBACK_INCORRECT :" + mapIncorrectFeedback); + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); - Map mapFeedbackCorrect =(Map)request.getSession().getAttribute(MAP_CORRECT_FEEDBACK); - logger.debug("Submit final MAP_FEEDBACK_CORRECT :" + mapFeedbackCorrect); + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); - logger.debug("refreshed maps..."); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - logger.debug("start processing questions content..."); - Long mcContentId =mcContent.getUid(); - List existingQuestions = mcService.refreshQuestionContent(mcContentId); - logger.debug("existingQuestions: " + existingQuestions); + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - logger.debug("received MAP_QUESTIONS_CONTENT: " + mapQuestionsContent); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - logger.debug("will cleanupRedundantQuestions:"); - AuthoringUtil.cleanupRedundantQuestions(request, existingQuestions, mapQuestionsContent, mcContent); + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); - logger.debug("calling selectAndPersistQuestions: " + existingQuestions); - AuthoringUtil.selectAndPersistQuestions(request, existingQuestions, mapQuestionsContent, mapIncorrectFeedback, mapFeedbackCorrect, mapGeneralOptionsContent, mapWeights, mcContent); - logger.debug("finished processing questions content..."); + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + AuthoringUtil authoringUtil= new AuthoringUtil(); + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + - logger.debug("start processing options content..."); - logger.debug("mapGeneralOptionsContent: " + mapGeneralOptionsContent); - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent: " + mapGeneralSelectedOptionsContent); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); - logger.debug("will refresh maps..."); - AuthoringUtil.refreshMaps(request, toolContentId.longValue(), mcService); + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + + /** + * + * ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException + + adds a new file to content repository + + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward addNewFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispathching addNewFile"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); - mapStartupGeneralOptionsContent= (Map) request.getSession().getAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapStartupGeneralOptionsContent: " + mapStartupGeneralOptionsContent); - Map mapStartupGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_STARTUP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapStartupGeneralSelectedOptionsContent: " + mapStartupGeneralSelectedOptionsContent); - Map mapStartupGeneralOptionsQueId=(Map) request.getSession().getAttribute(MAP_STARTUP_GENERAL_OPTIONS_QUEID); - logger.debug("mapStartupGeneralOptionsQueId: " + mapStartupGeneralOptionsQueId); + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); - logger.debug("calling cleanupRedundantOptions"); - AuthoringUtil.cleanupRedundantOptions(request, mapStartupGeneralOptionsContent, mapStartupGeneralSelectedOptionsContent, mapGeneralOptionsContent, mapGeneralSelectedOptionsContent, mapStartupGeneralOptionsQueId); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + logger.debug("contentFolderID: " + contentFolderID); + mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); - logger.debug("calling selectAndPersistOptions"); - AuthoringUtil.selectAndPersistOptions(request, mapStartupGeneralOptionsContent, mapStartupGeneralSelectedOptionsContent, mapGeneralOptionsContent, mapGeneralSelectedOptionsContent, mapStartupGeneralOptionsQueId); + String onlineInstructions=request.getParameter(ONLINE_INSTRUCTIONS); + logger.debug("onlineInstructions: " + onlineInstructions); - logger.debug("start persisting offline files metadata"); - AuthoringUtil.persistFilesMetaData(request, true, mcContent); - logger.debug("start persisting online files metadata"); - AuthoringUtil.persistFilesMetaData(request, false, mcContent); + String offlineInstructions=request.getParameter(OFFLINE_INSTRUCTIONS); + logger.debug("offlineInstructions: " + offlineInstructions); - /* making sure only the filenames in the session cache are persisted and the others in the db are removed*/ - logger.debug("start removing redundant offline files metadata"); - AuthoringUtil.removeRedundantOfflineFileItems(request, mcContent); + sessionMap.put(ONLINE_INSTRUCTIONS_KEY, onlineInstructions); + sessionMap.put(OFFLINE_INSTRUCTIONS, offlineInstructions); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); - logger.debug("start removing redundant online files metadata"); - AuthoringUtil.removeRedundantOnlineFileItems(request, mcContent); + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - logger.debug("done removing redundant files"); + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); - errors.clear(); - errors.add(Globals.ERROR_KEY,new ActionMessage("sbmt.successful")); - logger.debug("add sbmt.successful to ActionMessages"); - saveErrors(request,errors); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(1)); - logger.debug("set SUBMIT_SUCCESS to 1"); + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE to 0"); - - mcAuthoringForm.resetUserAction(); - mcAuthoringForm.resetRadioBoxes(); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + mcGeneralAuthoringDTO.setSbmtSuccess(new Integer(0).toString()); - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - logger.debug("printing final maps..."); - mapGeneralOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_OPTIONS_CONTENT); - logger.debug("mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=(Map)request.getSession().getAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT); - logger.debug("mapGeneralSelectedOptionsContent " + mapGeneralSelectedOptionsContent); - - logger.debug("sequencing final maps..."); - mapGeneralOptionsContent=AuthoringUtil.sequenceMap(mapGeneralOptionsContent); - logger.debug("sequenced mapGeneralOptionsContent:"+ mapGeneralOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - mapGeneralSelectedOptionsContent=AuthoringUtil.sequenceMap(mapGeneralSelectedOptionsContent); - logger.debug("sequenced mapGeneralSelectedOptionsContent:"+ mapGeneralSelectedOptionsContent); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - logger.debug("start unsetting define later with current toolContentId: " + toolContentId); - mcService.unsetAsDefineLater(toolContentId); - logger.debug("unset defineLater with toolContentId to true: " + toolContentId); + String richTextTitle = request.getParameter(TITLE); + String richTextInstructions = request.getParameter(INSTRUCTIONS); - logger.debug("resetting defineLater flag. "); - McUtils.setDefineLater(request, false); + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + addFileToContentRepository(request, mcAuthoringForm, attachmentList, deletedAttachmentList, sessionMap, mcGeneralAuthoringDTO); + logger.debug("post addFileToContentRepository, attachmentList: " + attachmentList); + logger.debug("post addFileToContentRepository, deletedAttachmentList: " + deletedAttachmentList); + + sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); + sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, + activeModule, sessionMap, httpSessionID); + - /* switch to view-only mode in the monitoring url after the content is persisted*/ - if (destination.equals(LOAD_MONITORING_CONTENT)) - { - request.getSession().setAttribute(ACTIVE_MODULE, DEFINE_LATER); - mcAuthoringForm.setActiveModule(DEFINE_LATER); - request.getSession().setAttribute(DEFINE_LATER_IN_EDIT_MODE, new Boolean(false)); - } - - McUtils.debugMaps(request); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); - /*because button (and javascript) will display in LamsTag tab, so put it into session instead of request - it will be remove immediately in clearSessionAction.*/ - request.getSession().setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG,Boolean.TRUE); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - return (mapping.findForward(destination)); - } + AuthoringUtil authoringUtil = new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + mcAuthoringForm.resetUserAction(); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + /** - * removes offline file data - * deleteFileItem(ActionMapping mapping, + * + * ActionForward deleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) + HttpServletResponse response) throws IOException, + ServletException * - * @param request - * @param form + * deletes a file from the content repository + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward deleteOfflineFile(ActionMapping mapping, + public ActionForward deleteFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching deleteOfflineFile..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - + logger.debug("dispatching deleteFile"); McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); - - String uuid =mcAuthoringForm.getUuid(); - logger.debug("uuid:" + uuid); - - List listOfflineFilesMetaData =(List)request.getSession().getAttribute(LIST_OFFLINEFILES_METADATA); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - listOfflineFilesMetaData=AuthoringUtil.removeFileItem(listOfflineFilesMetaData, uuid); - logger.debug("listOfflineFilesMetaData after remove:" + listOfflineFilesMetaData); - request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData); - - mcAuthoringForm.resetUserAction(); + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setSbmtSuccess( new Integer(0).toString()); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + String onlineInstructions=(String) sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + + String offlineInstructions=(String) sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + mcAuthoringForm.setOnlineInstructions(onlineInstructions); + mcAuthoringForm.setOfflineInstructions(offlineInstructions); + + + String richTextTitle=(String)sessionMap.get(ACTIVITY_TITLE_KEY); + String richTextInstructions=(String)sessionMap.get(ACTIVITY_INSTRUCTIONS_KEY); + + logger.debug("richTextTitle: " + richTextTitle); + logger.debug("richTextInstructions: " + richTextInstructions); + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + long uuid = WebUtil.readLongParam(request, UUID); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); - - } + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + + if(attachmentList == null) + attachmentList = new ArrayList(); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + if(deletedAttachmentList == null) + deletedAttachmentList = new ArrayList(); + + /* move the file's details from the attachment collection to the deleted attachments collection + the attachment will be delete on saving. */ + + deletedAttachmentList = McUtils.moveToDelete(Long.toString(uuid), attachmentList, deletedAttachmentList ); + + + sessionMap.put(ATTACHMENT_LIST_KEY,attachmentList); + sessionMap.put(DELETED_ATTACHMENT_LIST_KEY,deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("3"); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + mcAuthoringForm.resetUserAction(); + logger.debug("fwd ing to LOAD_QUESTIONS: " + LOAD_QUESTIONS); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + /** - * removes online file data - * deleteFileItem(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * persistError(HttpServletRequest request, String message) * + * persists error messages to request scope + * * @param request - * @param form - * @param mapping - * @return ActionForward + * @param message */ - public ActionForward deleteOnlineFile(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + 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); + } + + + /** + * addFileToContentRepository(HttpServletRequest request, McAuthoringForm mcAuthoringForm, + List attachmentList, List deletedAttachmentList, SessionMap sessionMap, + McGeneralAuthoringDTO mcGeneralAuthoringDTO) + + * @param request + * @param mcAuthoringForm + */ + public void addFileToContentRepository(HttpServletRequest request, McAuthoringForm mcAuthoringForm, + List attachmentList, List deletedAttachmentList, SessionMap sessionMap, + McGeneralAuthoringDTO mcGeneralAuthoringDTO) + { + logger.debug("attempt addFileToContentRepository"); + logger.debug("attachmentList: " + attachmentList); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + if(attachmentList == null) + attachmentList = new ArrayList(); + + if(deletedAttachmentList == null) + deletedAttachmentList = new ArrayList(); + + FormFile uploadedFile = null; + boolean isOnlineFile = false; + String fileType = null; + if(mcAuthoringForm.getTheOfflineFile() != null && mcAuthoringForm.getTheOfflineFile().getFileSize() > 0 ){ + logger.debug("theOfflineFile is available: "); + uploadedFile = mcAuthoringForm.getTheOfflineFile(); + logger.debug("uploadedFile: " + uploadedFile); + fileType = IToolContentHandler.TYPE_OFFLINE; + } + else if(mcAuthoringForm.getTheOnlineFile() != null && mcAuthoringForm.getTheOnlineFile().getFileSize() > 0 ){ + logger.debug("theOnlineFile is available: "); + uploadedFile = mcAuthoringForm.getTheOnlineFile(); + logger.debug("uploadedFile: " + uploadedFile); + isOnlineFile = true; + fileType = IToolContentHandler.TYPE_ONLINE; + } + else + /*no file uploaded*/ + return; + + logger.debug("uploadedFile.getFileName(): " + uploadedFile.getFileName()); + + /* if a file with the same name already exists then move the old one to deleted */ + deletedAttachmentList = McUtils.moveToDelete(uploadedFile.getFileName(), isOnlineFile, attachmentList, deletedAttachmentList ); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + try + { + /* This is a new file and so is saved to the content repository. Add it to the + attachments collection, but don't add it to the tool's tables yet. + */ + NodeKey node = getToolContentHandler().uploadFile(uploadedFile.getInputStream(), uploadedFile.getFileName(), + uploadedFile.getContentType(), fileType); + McUploadedFile file = new McUploadedFile(); + String fileName=uploadedFile.getFileName(); + logger.debug("fileName: " + fileName); + logger.debug("fileName length: " + fileName.length()); + + if ((fileName != null) && (fileName.length() > 30)) + { + fileName=fileName.substring(0, 31); + logger.debug("shortened fileName: " + fileName); + } + + file.setFileName(fileName); + file.setFileOnline(isOnlineFile); + file.setUuid(node.getUuid().toString()); + /* file.setVersionId(node.getVersion()); */ + + /* add the files to the attachment collection - if one existed, it should have already been removed. */ + attachmentList.add(file); + + /* reset the fields so that more files can be uploaded */ + mcAuthoringForm.setTheOfflineFile(null); + mcAuthoringForm.setTheOnlineFile(null); + } + catch (FileNotFoundException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } catch (IOException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } catch (RepositoryCheckedException e) { + logger.error("Unable to uploadfile",e); + throw new RuntimeException("Unable to upload file, exception was "+e.getMessage()); + } + } + + + /** + * McToolContentHandler getToolContentHandler() + * + * @return + */ + private McToolContentHandler getToolContentHandler() { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching deleteOnlineFile..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); - logger.debug("contentFolderID: " + contentFolderID); - mcAuthoringForm.setContentFolderID(contentFolderID); + if ( toolContentHandler == null ) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + toolContentHandler = (McToolContentHandler) wac.getBean("mcToolContentHandler"); + } + return toolContentHandler; + } + /** + * + * Go through the attachments collections. Remove any content repository or tool objects + * matching entries in the the deletedAttachments collection, add any new attachments in the + * attachments collection. Clear the deletedAttachments collection, ready for new editing. + * + * @param mcContent + * @param attachmentList + * @param deletedAttachmentList + * @param mapping + * @param request + * @return + */ + private List saveAttachments (McContent mcContent, + List attachmentList, List deletedAttachmentList, + ActionMapping mapping, HttpServletRequest request) { - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - - AuthoringUtil.readData(request, mcAuthoringForm, false); - - String uuid =mcAuthoringForm.getUuid(); - logger.debug("uuid:" + uuid); - - List listOnlineFilesMetaData =(List)request.getSession().getAttribute(LIST_ONLINEFILES_METADATA); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - listOnlineFilesMetaData=AuthoringUtil.removeFileItem(listOnlineFilesMetaData, uuid); - logger.debug("listOnlineFilesMetaData after remove:" + listOnlineFilesMetaData); - request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData); - - mcAuthoringForm.resetUserAction(); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); + logger.debug("start saveAttachments, mcContent " + mcContent); + logger.debug("start saveAttachments, attachmentList " + attachmentList); + logger.debug("start deletedAttachmentList, deletedAttachmentList " + deletedAttachmentList); - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + if(attachmentList==null || deletedAttachmentList==null) + return null; + + IMcService voteService = McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("voteService: " + voteService); + + if ( deletedAttachmentList != null ) { + logger.debug("deletedAttachmentList is iterated..."); + Iterator iter = deletedAttachmentList.iterator(); + while (iter.hasNext()) { + McUploadedFile attachment = (McUploadedFile) iter.next(); + logger.debug("attachment: " + attachment); + + if ( attachment.getSubmissionId() != null ) { + voteService.removeFile(attachment.getSubmissionId()); + } + } + deletedAttachmentList.clear(); + logger.error("cleared attachment list."); + } + + + if ( attachmentList != null ) + { + logger.debug("attachmentList is iterated..."); + Iterator iter = attachmentList.iterator(); + while (iter.hasNext()) { + McUploadedFile attachment = (McUploadedFile) iter.next(); + logger.debug("attachment: " + attachment); + logger.debug("attachment submission id: " + attachment.getSubmissionId()); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + if ( attachment.getSubmissionId() == null ) { + /* add entry to tool table - file already in content repository */ + logger.debug("calling persistFile with attachment: " + attachment); + voteService.persistFile(mcContent, attachment); + } + } + } + + return deletedAttachmentList; } + + + + public ActionForward editActivity(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) throws IOException, + ServletException + { + logger.debug("dispatching proxy editActivity..."); + return null; + } - /** - * adds the offline file information in the content repository. - * submitOfflineFiles(ActionMapping mapping, + + /** + * + * ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) + HttpServletResponse response) throws IOException, + ServletException, + ToolException + + generates Edit Activity screen * - * @param request - * @param form * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + * @throws ToolException */ - public ActionForward submitOfflineFiles(ActionMapping mapping, + public ActionForward editActivityQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, - RepositoryCheckedException + ToolException { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching submitOfflineFile..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); + logger.debug("dispatching editActivityQuestions..."); McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); - + logger.debug("mcAuthoringForm: " + mcAuthoringForm); + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + + logger.debug("title: " + mcContent.getTitle()); + logger.debug("instructions: " + mcContent.getInstructions()); + + mcGeneralAuthoringDTO.setActivityTitle(mcContent.getTitle()); + mcAuthoringForm.setTitle(mcContent.getTitle()); + + mcGeneralAuthoringDTO.setActivityInstructions(mcContent.getInstructions()); + + sessionMap.put(ACTIVITY_TITLE_KEY, mcContent.getTitle()); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, mcContent.getInstructions()); + + /* determine whether the request is from Monitoring url Edit Activity*/ String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); - AuthoringUtil.readData(request, mcAuthoringForm, false); - - logger.debug("will uploadFile for offline file:"); - McAttachmentDTO mcAttachmentDTO=AuthoringUtil.uploadFile(request, mcAuthoringForm, true); - logger.debug("returned mcAttachmentDTO:" + mcAttachmentDTO); - - if (mcAttachmentDTO == null) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_FILENAME_EMPTY, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.fileName.empty")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.fileName.empty"); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE :" + 0); - - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - - List listOfflineFilesMetaData =(List)request.getSession().getAttribute(LIST_OFFLINEFILES_METADATA); - logger.debug("listOfflineFilesMetaData:" + listOfflineFilesMetaData); - listOfflineFilesMetaData.add(mcAttachmentDTO); - logger.debug("listOfflineFilesMetaData after add:" + listOfflineFilesMetaData); - request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData); + mcAuthoringForm.setDefineLaterInEditMode(new Boolean(true).toString()); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + boolean isContentInUse=McUtils.isContentInUse(mcContent); + logger.debug("isContentInUse:" + isContentInUse); - mcAuthoringForm.resetUserAction(); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE :" + 0); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + mcGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(false).toString()); + if (isContentInUse == true) + { + logger.debug("monitoring url does not allow editActivity since the content is in use."); + persistError(request,"error.content.inUse"); + mcGeneralAuthoringDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + + EditActivityDTO editActivityDTO = new EditActivityDTO(); + logger.debug("isContentInUse:" + isContentInUse); + if (isContentInUse == true) + { + editActivityDTO.setMonitoredContentInUse(new Boolean(true).toString()); + } + request.setAttribute(EDIT_ACTIVITY_DTO, editActivityDTO); + + McUtils.setDefineLater(request, true, strToolContentID, mcService); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + AuthoringUtil authoringUtil= new AuthoringUtil(); + List listQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + request.getSession().setAttribute(httpSessionID, sessionMap); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before fwding to jsp, mcAuthoringForm: " + mcAuthoringForm); + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + logger.debug("forwarding to : " + LOAD_QUESTIONS); + return mapping.findForward(LOAD_QUESTIONS); } + + + /** + * + * newEditableCaBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + * + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException + */ + public ActionForward newEditableCaBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching newEditableCaBox"); + return null; + } /** - * adds the online file information in the content repository. - * submitOnlineFiles(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form + * moves a candidate dwn in the list + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward submitOnlineFiles(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException, - RepositoryCheckedException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching submitOnlineFiles..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); + public ActionForward moveCandidateDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveCandidateDown"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); - AuthoringUtil.readData(request, mcAuthoringForm, false); + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + logger.debug("but we are using the repopulated caList here: " + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "down"); + logger.debug("swapped candidates :" + listCandidates); + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + + break; + } + + } + } + + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); + logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); + + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - - logger.debug("will uploadFile for online file:"); - McAttachmentDTO mcAttachmentDTO=AuthoringUtil.uploadFile(request, mcAuthoringForm, false); - logger.debug("returned mcAttachmentDTO:" + mcAttachmentDTO); - - if (mcAttachmentDTO == null) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_FILENAME_EMPTY, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.fileName.empty")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.fileName.empty"); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting EDIT_OPTIONS_MODE :" + 0); - McUtils.debugMaps(request); - return (mapping.findForward(destination)); - } - - List listOnlineFilesMetaData =(List)request.getSession().getAttribute(LIST_ONLINEFILES_METADATA); - logger.debug("listOnlineFilesMetaData:" + listOnlineFilesMetaData); - listOnlineFilesMetaData.add(mcAttachmentDTO); - logger.debug("listOnlineFilesMetaData after add:" + listOnlineFilesMetaData); - request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData); - - mcAuthoringForm.resetUserAction(); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("setting ` :" + 0); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newEditableQuestionBox(mapping, form, request, response); } - - + + /** - * moves from Advanced Tab to Basic Tab - * doneAdvancedTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form + * moves a candidate up in the list + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward doneAdvancedTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching doneAdvancedTab..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); + public ActionForward moveCandidateUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching moveCandidateUp"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); + + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); + + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + + + List candidates =new LinkedList(); + List listCandidates =new LinkedList(); + String editableQuestion=""; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + McQuestionContentDTO mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + logger.debug("displayOrder equals questionIndex :" + questionIndex); + editableQuestion=mcQuestionContentDTO.getQuestion(); + + candidates=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidates found :" + candidates); + + logger.debug("using repopulated caList:" + caList); + + listCandidates=AuthoringUtil.swapCandidateNodes(caList, candidateIndex, "up"); + logger.debug("swapped candidates :" + listCandidates); + + + mcQuestionContentDTO.setListCandidateAnswersDTO(listCandidates); + mcQuestionContentDTO.setCaCount(new Integer(listCandidates.size()).toString()); + + break; + } + + } + } + + logger.debug("candidates found :" + candidates); + logger.debug("swapped candidates is :" + listCandidates); + logger.debug("listQuestionContentDTO after swapped candidates :" + listQuestionContentDTO); + + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + + + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); - AuthoringUtil.readData(request, mcAuthoringForm, false); + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); - mcAuthoringForm.resetUserAction(); - - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newEditableQuestionBox(mapping, form, request, response); + } - - + + /** - * moves from Instructions Tab to Basic Tab - * doneInstructionsTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) + * removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * @param request - * @param form + * removes a candidate from the list + * * @param mapping - * @return ActionForward + * @param form + * @param request + * @param response + * @return + * @throws IOException + * @throws ServletException */ - public ActionForward doneInstructionsTab(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching doneInstructionsTab..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; - IMcService mcService =McUtils.getToolService(request); + public ActionForward removeCandidate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching removeCandidate"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); - logger.debug("destination: " + destination); + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); - AuthoringUtil.readData(request, mcAuthoringForm, false); + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, false); + logger.debug("repopulated caList: " + caList); + + + McQuestionContentDTO mcQuestionContentDTO= null; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + mcQuestionContentDTO= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTO:" + mcQuestionContentDTO); + logger.debug("mcQuestionContentDTO question:" + mcQuestionContentDTO.getQuestion()); + + String question=mcQuestionContentDTO.getQuestion(); + String displayOrder=mcQuestionContentDTO.getDisplayOrder(); + logger.debug("displayOrder:" + displayOrder); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + break; + } + + } + } + + logger.debug("mcQuestionContentDTO found:" + mcQuestionContentDTO); + logger.debug("setting caList for the content:"); + mcQuestionContentDTO.setListCandidateAnswersDTO(caList); + + List candidateAnswers=mcQuestionContentDTO.getListCandidateAnswersDTO(); + logger.debug("candidateAnswers:" + candidateAnswers); + + McCandidateAnswersDTO mcCandidateAnswersDTO= null; + Iterator listCaIterator=candidateAnswers.iterator(); + int caIndex=0; + while (listCaIterator.hasNext()) + { + caIndex ++; + logger.debug("caIndex:" + caIndex); + mcCandidateAnswersDTO= (McCandidateAnswersDTO)listCaIterator.next(); + logger.debug("mcCandidateAnswersDTO:" + mcCandidateAnswersDTO); + logger.debug("mcCandidateAnswersDTO question:" + mcCandidateAnswersDTO.getCandidateAnswer()); + + if (caIndex == new Integer(candidateIndex).intValue()) + { + logger.debug("candidateIndex found"); + mcCandidateAnswersDTO.setCandidateAnswer(""); + + + break; + } + } + logger.debug("candidateAnswers after resetting answer" + candidateAnswers); + + candidateAnswers=AuthoringUtil.reorderListCandidatesDTO(candidateAnswers); + logger.debug("candidateAnswers after reordering candidate nodes" + candidateAnswers); + + mcQuestionContentDTO.setListCandidateAnswersDTO(candidateAnswers); + mcQuestionContentDTO.setCaCount(new Integer(candidateAnswers.size()).toString()); + logger.debug("listQuestionContentDTO after remove: " + listQuestionContentDTO); + + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - mcAuthoringForm.resetUserAction(); + - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + + + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McContent mcContent=mcService.retrieveMc(new Long(strToolContentID)); + logger.debug("mcContent: " + mcContent); + + if (mcContent == null) + { + logger.debug("using defaultContentIdStr: " + defaultContentIdStr); + mcContent=mcService.retrieveMc(new Long(defaultContentIdStr)); + } + logger.debug("final mcContent: " + mcContent); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) + { + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(destination)); + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); + } + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("mcQuestionContentDTO now: " + mcQuestionContentDTO); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + return newEditableQuestionBox(mapping, form, request, response); + } - - /**Double check: we assume that the author have to use Cancel button to exit the authoring module. - * This is the place to remove any authoring modle related session attributes + + /** + * newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) * - * author exiting, remove any session attributes that belong to authoring module here - * cancelAuthoring(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException + * enables adding a new candidate answer * * @param mapping * @param form * @param request * @param response - * @return ActionForward + * @return * @throws IOException * @throws ServletException */ - public ActionForward cancelAuthoring(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - McUtils.cleanUpUserExceptions(request); - logger.debug("dispatching cancelAuthoring..."); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + public ActionForward newCandidateBox(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + logger.debug("dispatching newCandidateBox"); + McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + + IMcService mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + logger.debug("mcService: " + mcService); + + String httpSessionID=mcAuthoringForm.getHttpSessionID(); + logger.debug("httpSessionID: " + httpSessionID); + + SessionMap sessionMap=(SessionMap)request.getSession().getAttribute(httpSessionID); + logger.debug("sessionMap: " + sessionMap); + + String questionIndex=request.getParameter("questionIndex"); + logger.debug("questionIndex: " + questionIndex); + mcAuthoringForm.setQuestionIndex(questionIndex); - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + String candidateIndex=request.getParameter("candidateIndex"); + logger.debug("candidateIndex: " + candidateIndex); + mcAuthoringForm.setCandidateIndex(candidateIndex); + + + List listQuestionContentDTO=(List)sessionMap.get(LIST_QUESTION_CONTENT_DTO_KEY); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + + + AuthoringUtil authoringUtil = new AuthoringUtil(); + List caList=authoringUtil.repopulateCandidateAnswersBox(request, true); + logger.debug("repopulated caList: " + caList); + + int caCount=caList.size(); + logger.debug("caCount: " + caCount); + + + String newQuestion=request.getParameter("newQuestion"); + logger.debug("newQuestion: " + newQuestion); + + String mark=request.getParameter("mark"); + logger.debug("mark: " + mark); + + String passmark=request.getParameter("passmark"); + logger.debug("passmark: " + passmark); + + + String feedback=request.getParameter("feedback"); + logger.debug("feedback: " + feedback); + + int currentQuestionCount= listQuestionContentDTO.size(); + logger.debug("currentQuestionCount: " + currentQuestionCount); + + + String editQuestionBoxRequest=request.getParameter("editQuestionBoxRequest"); + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); + + + McQuestionContentDTO mcQuestionContentDTOLocal= null; + Iterator listIterator=listQuestionContentDTO.iterator(); + while (listIterator.hasNext()) + { + mcQuestionContentDTOLocal= (McQuestionContentDTO)listIterator.next(); + logger.debug("mcQuestionContentDTOLocal:" + mcQuestionContentDTOLocal); + logger.debug("mcQuestionContentDTOLocal question:" + mcQuestionContentDTOLocal.getQuestion()); + + String question=mcQuestionContentDTOLocal.getQuestion(); + String displayOrder=mcQuestionContentDTOLocal.getDisplayOrder(); + logger.debug("displayOrder:" + displayOrder); + + if ((displayOrder != null) && (!displayOrder.equals(""))) + { + if (displayOrder.equals(questionIndex)) + { + break; + } + + } + } + + logger.debug("mcQuestionContentDTOLocal found:" + mcQuestionContentDTOLocal); + + if (mcQuestionContentDTOLocal != null) + { + mcQuestionContentDTOLocal.setListCandidateAnswersDTO(caList); + mcQuestionContentDTOLocal.setCaCount(new Integer(caList.size()).toString()); + } + + + logger.debug("listQuestionContentDTO after repopulating data: " + listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - - - /* determine whether the request is from Monitoring url Edit Activity*/ - String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); - logger.debug("sourceMcStarter: " + sourceMcStarter); + - mcAuthoringForm.resetUserAction(); + String activeModule=request.getParameter(ACTIVE_MODULE); + logger.debug("activeModule: " + activeModule); + + String richTextTitle = request.getParameter(TITLE); + logger.debug("richTextTitle: " + richTextTitle); + + String richTextInstructions = request.getParameter(INSTRUCTIONS); + logger.debug("richTextInstructions: " + richTextInstructions); + - /*remove session attribues */ - McUtils.cleanUpSessionAbsolute(request); - logger.debug("removed attribues..."); + sessionMap.put(ACTIVITY_TITLE_KEY, richTextTitle); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, richTextInstructions); + + + String strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); - /* Check this: find out where to forward to*/ - McUtils.debugMaps(request); - logger.debug("final EDIT_OPTIONS_MODE: " + request.getSession().getAttribute(EDIT_OPTIONS_MODE)); - - IMcService mcService =McUtils.getToolService(request); - if (mcService == null) + String defaultContentIdStr=request.getParameter(DEFAULT_CONTENT_ID_STR); + logger.debug("defaultContentIdStr: " + defaultContentIdStr); + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + logger.debug("mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); + + mcGeneralAuthoringDTO.setActivityTitle(richTextTitle); + mcAuthoringForm.setTitle(richTextTitle); + + mcGeneralAuthoringDTO.setActivityInstructions(richTextInstructions); + + logger.debug("activeModule: " + activeModule); + if (activeModule.equals(AUTHORING)) { - logger.debug("will retrieve mcService"); - mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - logger.debug("retrieving mcService from cache: " + mcService); + String onlineInstructions=(String)sessionMap.get(ONLINE_INSTRUCTIONS_KEY); + logger.debug("onlineInstructions: " + onlineInstructions); + mcGeneralAuthoringDTO.setOnlineInstructions(onlineInstructions); + + String offlineInstructions=(String)sessionMap.get(OFFLINE_INSTRUCTIONS_KEY); + logger.debug("offlineInstructions: " + offlineInstructions); + mcGeneralAuthoringDTO.setOfflineInstructions(offlineInstructions); + + + List attachmentList=(List)sessionMap.get(ATTACHMENT_LIST_KEY); + logger.debug("attachmentList: " + attachmentList); + List deletedAttachmentList=(List)sessionMap.get(DELETED_ATTACHMENT_LIST_KEY); + logger.debug("deletedAttachmentList: " + deletedAttachmentList); + + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(deletedAttachmentList); + + String strOnlineInstructions= request.getParameter("onlineInstructions"); + String strOfflineInstructions= request.getParameter("offlineInstructions"); + logger.debug("onlineInstructions: " + strOnlineInstructions); + logger.debug("offlineInstructions: " + strOnlineInstructions); + mcAuthoringForm.setOnlineInstructions(strOnlineInstructions); + mcAuthoringForm.setOfflineInstructions(strOfflineInstructions); } - request.getSession().setAttribute(TOOL_SERVICE, mcService); - logger.debug("mcService : " + mcService); + + + mcGeneralAuthoringDTO.setEditActivityEditMode(new Boolean(true).toString()); + + request.getSession().setAttribute(httpSessionID, sessionMap); + + McUtils.setFormProperties(request, mcService, + mcAuthoringForm, mcGeneralAuthoringDTO, strToolContentID, defaultContentIdStr, activeModule, sessionMap, httpSessionID); + + + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + mcGeneralAuthoringDTO.setHttpSessionID(httpSessionID); + mcGeneralAuthoringDTO.setActiveModule(activeModule); + mcGeneralAuthoringDTO.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setToolContentID(strToolContentID); + mcAuthoringForm.setHttpSessionID(httpSessionID); + mcAuthoringForm.setActiveModule(activeModule); + mcAuthoringForm.setDefaultContentIdStr(defaultContentIdStr); + mcAuthoringForm.setCurrentTab("1"); + + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + logger.debug("mcQuestionContentDTOLocal now: " + mcQuestionContentDTOLocal); + logger.debug("listQuestionContentDTO now: " + listQuestionContentDTO); + + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("before saving final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + + logger.debug("editQuestionBoxRequest: " + editQuestionBoxRequest); - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); - - return (mapping.findForward(AUTHORING_STARTER)); + return newEditableQuestionBox(mapping, form, request, response); + } + - - /** - * ensures that the weight valued entered are valid - * validateQuestionWeights(HttpServletRequest request, McAuthoringForm mcAuthoringForm) + /** + * boolean existsContent(long toolContentID, IMcService mcService) * - * @param request - * @param mcAuthoringForm + * @param toolContentID + * @param mcService * @return */ - protected boolean validateQuestionWeights(HttpServletRequest request, Map mapWeights, McAuthoringForm mcAuthoringForm) - { - McUtils.cleanUpUserExceptions(request); - logger.debug("mapWeights: " + mapWeights); - request.getSession().setAttribute(SUBMIT_SUCCESS, new Integer(0)); - McUtils.debugMaps(request); - - Iterator itMap = mapWeights.entrySet().iterator(); - while (itMap.hasNext()) { - Map.Entry pairs = (Map.Entry)itMap.next(); - logger.debug("using the pair: " + pairs.getKey() + " = " + pairs.getValue()); - - if ((pairs.getValue() == null) || (pairs.getValue().toString().length() == 0)) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_EMPTY, new Boolean(true).toString()); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.empty")); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.weights.empty"); - - return false; - } - - try - { - int weight= new Integer(pairs.getValue().toString()).intValue(); - logger.debug("tried weight: " + weight); - } - catch(Exception e) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.notInteger")); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_NOTINTEGER, new Boolean(true).toString()); - saveErrors(request,errors); - mcAuthoringForm.resetUserAction(); - persistError(request,"error.weights.notInteger"); - return false; - } - - - int weight= new Integer(pairs.getValue().toString()).intValue(); - if (weight == 0) - { - ActionMessages errors= new ActionMessages(); - errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY,new ActionMessage("error.weights.zero")); - saveErrors(request,errors); - request.getSession().setAttribute(USER_EXCEPTION_WEIGHT_ZERO, new Boolean(true).toString()); - persistError(request,"error.weights.zero"); - return false; - } - } - mcAuthoringForm.resetUserAction(); - return true; - } - - - /** - * persists error messages to request scope - * @param request - * @param message - */ - public void persistError(HttpServletRequest request, String message) + protected boolean existsContent(long toolContentID, IMcService mcService) { - ActionMessages errors= new ActionMessages(); - errors.add(Globals.ERROR_KEY, new ActionMessage(message)); - logger.debug("add " + message +" to ActionMessages:"); - saveErrors(request,errors); + McContent mcContent=mcService.retrieveMc(new Long(toolContentID)); + if (mcContent == null) + return false; + + return true; } } - \ No newline at end of file Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java,v diff -u -r1.37 -r1.38 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 25 Sep 2006 23:23:17 -0000 1.37 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 2 Oct 2006 01:44:17 -0000 1.38 @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * * http://www.gnu.org/licenses/gpl.txt @@ -51,6 +51,7 @@ protected FormFile receivedFile; protected String offlineFile; + protected String defaultContentIdStr; protected String addContent; protected String removeContent; @@ -113,6 +114,10 @@ protected String edit; private String contentFolderID; + private String editableQuestionIndex; + private String defineLaterInEditMode; + private String feedback; + private String candidateIndex; public void resetUserAction() { @@ -892,4 +897,65 @@ public void setContentFolderID(String contentFolderID) { this.contentFolderID = contentFolderID; } + /** + * @return Returns the defaultContentIdStr. + */ + public String getDefaultContentIdStr() { + return defaultContentIdStr; + } + /** + * @param defaultContentIdStr The defaultContentIdStr to set. + */ + public void setDefaultContentIdStr(String defaultContentIdStr) { + this.defaultContentIdStr = defaultContentIdStr; + } + /** + * @return Returns the editableQuestionIndex. + */ + public String getEditableQuestionIndex() { + return editableQuestionIndex; + } + /** + * @param editableQuestionIndex The editableQuestionIndex to set. + */ + public void setEditableQuestionIndex(String editableQuestionIndex) { + this.editableQuestionIndex = editableQuestionIndex; + } + /** + * @return Returns the defineLaterInEditMode. + */ + public String getDefineLaterInEditMode() { + return defineLaterInEditMode; + } + /** + * @param defineLaterInEditMode The defineLaterInEditMode to set. + */ + public void setDefineLaterInEditMode(String defineLaterInEditMode) { + this.defineLaterInEditMode = defineLaterInEditMode; + } + /** + * @return Returns the feedback. + */ + public String getFeedback() { + return feedback; + } + /** + * @param feedback The feedback to set. + */ + public void setFeedback(String feedback) { + this.feedback = feedback; + } + /** + * @return Returns the candidateIndex. + */ + public String getCandidateIndex() { + return candidateIndex; + } + /** + * @param candidateIndex The candidateIndex to set. + */ + public void setCandidateIndex(String candidateIndex) { + this.candidateIndex = candidateIndex; + } + } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java,v diff -u -r1.86 -r1.87 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 25 Sep 2006 23:23:17 -0000 1.86 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 2 Oct 2006 01:44:17 -0000 1.87 @@ -1,4 +1,4 @@ -/*************************************************************************** +/**************************************************************** * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) * ============================================================= * License Information: http://lamsfoundation.org/licensing/lams/2.0/ @@ -18,124 +18,112 @@ * USA * * http://www.gnu.org/licenses/gpl.txt - * ***********************************************************************/ + * **************************************************************** + */ /** * @author Ozgur Demirtas * - * McStarterAction loads the default content and initializes the presentation Map. - * Initializes the tool's authoring mode - * Requests can come either from authoring environment or from the monitoring environment for Edit Activity screen. + * Created on 8/03/2005 * + */ + +/** + * Tool path The URL path for the tool should be /tool/$TOOL_SIG. * - * - * Authoring URL - * - * The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: + * CONTENT_LOCKED ->CONTENT_IN_USE + * + * McStarterAction loads the default content and initializes the presentation Map + * Requests can come either from authoring envuironment or from the monitoring environment for Edit Activity screen + * + * Check McUtils.createAuthoringUser again User Management Service is ready + * + * */ - * /&toolContentID=123 - - - * The initial data displayed on the authoring screen for a new tool content id may be the default tool content. +/** * - * Authoring UI data consists of general Activity data fields and the Tool specific data fields. - * The authoring interface will have three tabs. The mandatory (and suggested) fields are given. - * Each tool will have its own fields which it will add on any of the three tabs, as appropriate to the tabs' function. - - * Basic: Displays the basic set of fields that are needed for the tool, and it could be expected that a new LAMS user would use. - * Mandatory fields: Title, Instructions. - * - * Advanced: Displays the extra fields that would be used by experienced LAMS users. Optional fields: Lock On Finish, Make Responses Anonymous - * Instructions: Displays the "instructions" fields for teachers. Mandatory fields: Online instructions, Offline instructions, Document upload. - * See Instructions. The standard LAMS tools will use a DHTML layout for the Authoring tabs. For consistency of look and feel, - * we prefer all tools to use the DHTML, or at least make the tabs look and behave like the DHTML layout. The javascript for the tabs is - * available as "/include/javascript/tabcontroller.js" from the central web app (e.g. http://blah.org/lams/include/javascript/tabcontroller.js). + * Tool Content: * - * The "Define Later" and "Run Offline" options are set on the Flash authoring part, and not on the tool's authoring screens. - * Preview The tool must be able to show the specified content as if it was running in a lesson. It will be the learner url with tool access - * mode set to ToolAccessMode.AUTHOR. + * While tool's manage their own content, the LAMS core and the tools work together to create and use the content. + * The tool content id (toolContentID) is the key by which the tool and the LAMS core discuss data - + * it is generated by the LAMS core and supplied to the tool whenever content needs to be stored. + * The LAMS core will refer to the tool content id whenever the content needs to be used. + * Tool content will be covered in more detail in following sections. * - * Export The tool must be able to export its tool content for part of the overall learning design export. - * The format of the serialization for export is XML. Tool will define extra namespace inside the element to add a new data element (type). - * Inside the data element, it can further define more structures and types as it seems fit. + * Each tool will have one piece of content that is the default content. + * The tool content id for this content is created as part of the installation process. + * Whenever a tool is asked for some tool content that does not exist, it should supply the default tool content. + * This will allow the system to render the normal screen, albeit with useless information, rather than crashing. +*/ - * The data elements must be "version" aware. The data elements must be "type" aware if they are to be shared between Tools. - * LAMS Xpress (Ernie, could you put something in here. You explain it better than I do!) - * - * Data Exchange At present, there is no data exchange format between tools. Therefore if.. - * - * - * Tool path The URL path for the tool should be /tool/$TOOL_SIG. - * - - - - +/** +* +* Authoring URL: +* +* The tool must supply an authoring module, which will be called to create new content or edit existing content. It will be called by an authoring URL using the following format: ????? +* The initial data displayed on the authoring screen for a new tool content id may be the default tool content. +* +* Authoring UI data consists of general Activity data fields and the Tool specific data fields. +* The authoring interface will have three tabs. The mandatory (and suggested) fields are given. Each tool will have its own fields which it will add on any of the three tabs, as appropriate to the tabs' function. +* +* Basic: Displays the basic set of fields that are needed for the tool, and it could be expected that a new LAMS user would use. Mandatory fields: Title, Instructions. +* Advanced: Displays the extra fields that would be used by experienced LAMS users. Optional fields: Lock On Finish, Make Responses Anonymous +* Instructions: Displays the "instructions" fields for teachers. Mandatory fields: Online instructions, Offline instructions, Document upload. +* The "Define Later" and "Run Offline" options are set on the Flash authoring part, and not on the tool's authoring screens. +* +* Preview The tool must be able to show the specified content as if it was running in a lesson. It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR. +* Export The tool must be able to export its tool content for part of the overall learning design export. +* +* The format of the serialization for export is XML. Tool will define extra namespace inside the element to add a new data element (type). Inside the data element, it can further define more structures and types as it seems fit. +* The data elements must be "version" aware. The data elements must be "type" aware if they are to be shared between Tools. +* +* + - + + - + + + - + - - - - - - + - - The author is given warnings when the content in use by learners OR when the content is being edited in the Monitoring interface. +* */ -/* TO DO: enable show feedback on questions.*/ + /* $$Id$$ */ package org.lamsfoundation.lams.tool.mc.web; import java.io.IOException; -import java.util.Date; -import java.util.Iterator; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -156,696 +144,483 @@ import org.lamsfoundation.lams.tool.mc.McAppConstants; import org.lamsfoundation.lams.tool.mc.McApplicationException; import org.lamsfoundation.lams.tool.mc.McComparator; -import org.lamsfoundation.lams.tool.mc.McStringComparator; +import org.lamsfoundation.lams.tool.mc.McGeneralAuthoringDTO; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.pojos.McContent; -import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent; -import org.lamsfoundation.lams.tool.mc.pojos.McQueContent; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; - +/** + * + * @author Ozgur Demirtas + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + * + * A Map data structure is used to present the UI. + */ public class McStarterAction extends Action implements McAppConstants { - /* - * This class is reused by defineLater and monitoring modules as well. - */ static Logger logger = Logger.getLogger(McStarterAction.class.getName()); - + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, McApplicationException { - + McUtils.cleanUpSessionAbsolute(request); - logger.debug("init authoring mode. removed attributes..."); - + logger.debug("init authoring mode."); McAuthoringForm mcAuthoringForm = (McAuthoringForm) form; + logger.debug("mcAuthoringForm: " + mcAuthoringForm); String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); logger.debug("contentFolderID: " + contentFolderID); mcAuthoringForm.setContentFolderID(contentFolderID); - + + McGeneralAuthoringDTO mcGeneralAuthoringDTO= new McGeneralAuthoringDTO(); + mcGeneralAuthoringDTO.setContentFolderID(contentFolderID); - IMcService mcService = (IMcService)request.getSession().getAttribute(TOOL_SERVICE); - logger.debug("mcService: " + mcService); - if (mcService == null) + Map mapQuestionContent= new TreeMap(new McComparator()); + logger.debug("mapQuestionContent: " + mapQuestionContent); + + mcAuthoringForm.resetRadioBoxes(); + + IMcService mcService =null; + if ((getServlet() == null) || (getServlet().getServletContext() == null)) { - logger.debug("will retrieve mcService"); - mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - logger.debug("retrieving mcService from cache: " + mcService); + logger.debug("obtaining mcService from the form"); + mcService=mcAuthoringForm.getMcService(); } - request.getSession().setAttribute(TOOL_SERVICE, mcService); - + else + { + logger.debug("obtaining mcService via proxy"); + mcService =McServiceProxy.getMcService(getServlet().getServletContext()); + } + logger.debug("mcService: " + mcService); + + mcGeneralAuthoringDTO.setCurrentTab("1"); + logger.debug("setting currrent tab to 1:"); + + + mcGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(false).toString()); String servletPath=request.getServletPath(); logger.debug("getServletPath: "+ servletPath); + String requestedModule=null; if (servletPath.indexOf("authoringStarter") > 0) { logger.debug("request is for authoring module"); - request.getSession().setAttribute(ACTIVE_MODULE, AUTHORING); - request.getSession().setAttribute(DEFINE_LATER_IN_EDIT_MODE, new Boolean(true)); - request.getSession().setAttribute(SHOW_AUTHORING_TABS,new Boolean(true).toString()); + mcGeneralAuthoringDTO.setActiveModule(AUTHORING); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(true).toString()); + mcGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(true).toString()); + mcAuthoringForm.setActiveModule(AUTHORING); + requestedModule=AUTHORING; } else { - logger.debug("request is for define later module. either direct or by monitoring module"); - request.getSession().setAttribute(ACTIVE_MODULE, DEFINE_LATER); - request.getSession().setAttribute(DEFINE_LATER_IN_EDIT_MODE, new Boolean(false)); - request.getSession().setAttribute(SHOW_AUTHORING_TABS,new Boolean(false).toString()); + logger.debug("request is for define later module either direcly from define later url or monitoring url"); + mcGeneralAuthoringDTO.setActiveModule(DEFINE_LATER); + mcGeneralAuthoringDTO.setDefineLaterInEditMode(new Boolean(false).toString()); + mcGeneralAuthoringDTO.setShowAuthoringTabs(new Boolean(false).toString()); + mcAuthoringForm.setActiveModule(DEFINE_LATER); + requestedModule=DEFINE_LATER; + + if (servletPath.indexOf("monitoring") > 0) + { + logger.debug("request is from monitoring url."); + mcGeneralAuthoringDTO.setMonitoringOriginatedDefineLater(new Boolean(true).toString()); + } } - - initialiseAttributes(request, mcAuthoringForm); - /* determine whether the request is from Monitoring url Edit Activity. - * null sourceMcStarter indicates that the request is from authoring url. - * */ + logger.debug("requestedModule: " + requestedModule); + mcGeneralAuthoringDTO.setRequestedModule(requestedModule); + + + /* in development this needs to be called only once. */ + /* McUtils.configureContentRepository(request); */ String sourceMcStarter = (String) request.getAttribute(SOURCE_MC_STARTER); logger.debug("sourceMcStarter: " + sourceMcStarter); - - mcAuthoringForm.resetRadioBoxes(); - ActionForward validateSignature=readSignature(request,mapping); + boolean validateSignature=readSignature(request,mapping, mcService, mcGeneralAuthoringDTO, mcAuthoringForm); logger.debug("validateSignature: " + validateSignature); - if (validateSignature != null) + if (validateSignature == false) { - logger.debug("validateSignature not null : " + validateSignature); - return validateSignature; + logger.debug("error during validation"); } - else - { - logger.debug("no problems getting the default content, will render authoring screen"); - String strToolContentId=""; - /*the authoring url must be passed a tool content id*/ - strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); - logger.debug("strToolContentId: " + strToolContentId); - - if (strToolContentId == null) + + /* mark the http session as an authoring activity */ + mcGeneralAuthoringDTO.setTargetMode(TARGET_MODE_AUTHORING); + + /* + * find out whether the request is coming from monitoring module for EditActivity tab or from authoring environment url + */ + logger.debug("no problems getting the default content, will render authoring screen"); + String strToolContentID=""; + /*the authoring url must be passed a tool content id*/ + strToolContentID=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID); + logger.debug("strToolContentID: " + strToolContentID); + mcGeneralAuthoringDTO.setToolContentID(strToolContentID); + + SessionMap sessionMap = new SessionMap(); + List sequentialCheckedCa= new LinkedList(); + sessionMap.put(ATTACHMENT_LIST_KEY, new ArrayList()); + sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + sessionMap.put(ACTIVITY_TITLE_KEY, ""); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, ""); + mcAuthoringForm.setHttpSessionID(sessionMap.getSessionID()); + mcGeneralAuthoringDTO.setHttpSessionID(sessionMap.getSessionID()); + + String defaultContentId=null; + if (strToolContentID == null) + { + /*it is possible that the original request for authoring module is coming from monitoring url which keeps the + TOOL_CONTENT_ID in the session*/ + logger.debug("strToolContentID is null, handle this"); + + Long toolContentID =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentID: " + toolContentID); + if (toolContentID != null) { - /*it is possible that the original request for authoring module is coming from monitoring url which keeps the - TOOL_CONTENT_ID in the session*/ - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - if (toolContentId != null) - { - strToolContentId= toolContentId.toString(); - logger.debug("cached strToolContentId from the session: " + strToolContentId); - } - else - { - logger.debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available from the url or the session."); - /*use default content instead of giving a warning*/ - String defaultContentId=(String) request.getSession().getAttribute(DEFAULT_CONTENT_ID); - logger.debug("using MCQ defaultContentId: " + defaultContentId); - strToolContentId=defaultContentId; - } + strToolContentID= toolContentID.toString(); + logger.debug("cached strToolContentID from the session: " + strToolContentID); } - logger.debug("final strToolContentId: " + strToolContentId); - - if ((strToolContentId == null) || (strToolContentId.equals(""))) + else { - McUtils.cleanUpSessionAbsolute(request); - request.getSession().setAttribute(USER_EXCEPTION_CONTENTID_REQUIRED, new Boolean(true).toString()); - persistError(request,"error.contentId.required"); - McUtils.cleanUpSessionAbsolute(request); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); + logger.debug("we should IDEALLY not arrive here. The TOOL_CONTENT_ID is NOT available from the url or the session."); + /*use default content instead of giving a warning*/ + defaultContentId=mcAuthoringForm.getDefaultContentIdStr(); + logger.debug("using MCQ defaultContentId: " + defaultContentId); + strToolContentID=defaultContentId; } - - /* 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(TOOL_CONTENT_ID, new Long(strToolContentId)); - } - catch(NumberFormatException e) - { - McUtils.cleanUpSessionAbsolute(request); - request.getSession().setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true).toString()); - //persistError(request,"error.numberFormatException"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } + } + logger.debug("final strToolContentID: " + strToolContentID); + + if ((strToolContentID == null) || (strToolContentID.equals(""))) + { + McUtils.cleanUpSessionAbsolute(request); + logger.debug("forwarding to: " + ERROR_LIST); + //return (mapping.findForward(ERROR_LIST)); + } - /* - * find out if the passed tool content id exists in the db - * present user either a first timer screen with default content data or fetch the existing content. - * - * if the toolcontentid does not exist in the db, create the default Map, - * there is no need to check if the content is in use in this case. - * It is always unlocked -> not in use since it is the default content. - */ - - if (!existsContent(toolContentId, request)) - { - logger.debug("retrieving default content"); - retrieveDefaultContent(request, mcAuthoringForm); - McAction mcAction= new McAction(); - boolean performEditOptions=mcAction.performEditOptions(mapping, form, request, response, true, true); - logger.debug("performEditOptions: " + performEditOptions); - boolean performDoneOptions=mcAction.performDoneOptions(mapping, form, request, response, true, true); - logger.debug("performDoneOptions: " + performDoneOptions); - } - else - { - logger.debug("retrieving existing content for: " + toolContentId); - McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); - logger.debug("existing mcContent:" + mcContent); - - /* it is possible that the content is being used by some learners. In this situation, the content is marked as "in use" and - content in use is not modifiable*/ - boolean isContentInUse=McUtils.isContentInUse(mcContent); - logger.debug("isContentInUse:" + isContentInUse); - - if (isContentInUse == true) - { - McUtils.cleanUpSessionAbsolute(request); - request.getSession().setAttribute(USER_EXCEPTION_CONTENT_IN_USE, new Boolean(true).toString()); - persistError(request,"error.content.inUse"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } - - /* do not make these tests if the request is coming from monitoring url for Edit Activity*/ - if ( (sourceMcStarter == null) || - ((sourceMcStarter != null) && !sourceMcStarter.equals("monitoring")) - ) - { - - /* it is possible that the content is being EDITED in the monitoring interface. In this situation, the content is not modifiable*/ - boolean isDefineLater=McUtils.isDefineLater(mcContent); - logger.debug("isDefineLater:" + isDefineLater); - String defineLater= (String)request.getSession().getAttribute(ACTIVE_MODULE); - logger.debug("the url mode is :" + defineLater); + mcAuthoringForm.setToolContentID(strToolContentID); - /* we should allow content to be edited if the url mode is define Later*/ - if (!defineLater.equals(DEFINE_LATER)) - { - logger.debug("the url mode is :" + defineLater); - if (isDefineLater == true) - { - McUtils.cleanUpSessionAbsolute(request); - request.getSession().setAttribute(USER_EXCEPTION_CONTENT_BEING_MODIFIED, new Boolean(true).toString()); - persistError(request,"error.content.beingModified"); - logger.debug("forwarding to: " + ERROR_LIST); - return (mapping.findForward(ERROR_LIST)); - } - } - } - - retrieveExistingContent(request, mcAuthoringForm, toolContentId, mcContent); - } + /* + * find out if the passed tool content id exists in the db + * present user either a first timer screen with default content data or fetch the existing content. + * + * if the toolcontentid does not exist in the db, create the default Map, + * there is no need to check if the content is locked in this case. + * It is always unlocked since it is the default content. + */ + + String defaultContentIdStr=null; + McContent mcContent=null; + if (!existsContent(new Long(strToolContentID).longValue(), mcService)) + { + logger.debug("getting default content"); + /*fetch default content*/ + defaultContentIdStr=mcAuthoringForm.getDefaultContentIdStr(); + logger.debug("defaultContentIdStr:" + defaultContentIdStr); + mcContent=retrieveContent(request, mapping, mcAuthoringForm, mapQuestionContent, + new Long(defaultContentIdStr).longValue(), true, mcService, mcGeneralAuthoringDTO, sessionMap); + + logger.debug("post retrive content :" + sessionMap); } - mcAuthoringForm.resetUserAction(); - - Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID); - logger.debug("toolContentId: " + toolContentId); - - McContent mcContent=mcService.retrieveMc(toolContentId); - logger.debug("mcContent:" + mcContent); - + else + { + logger.debug("getting existing content"); + /* it is possible that the content is in use by learners.*/ + mcContent=mcService.retrieveMc(new Long(strToolContentID)); + + logger.debug("mcContent: " + mcContent); + if (mcService.studentActivityOccurredGlobal(mcContent)) + { + McUtils.cleanUpSessionAbsolute(request); + logger.debug("student activity occurred on this content:" + mcContent); + //persistError(request, "error.content.inUse"); + //logger.debug("add error.content.inUse to ActionMessages."); + //return (mapping.findForward(ERROR_LIST)); + } + mcContent=retrieveContent(request, mapping, mcAuthoringForm, mapQuestionContent, + new Long(strToolContentID).longValue(),false, mcService, mcGeneralAuthoringDTO, sessionMap); + + logger.debug("post retrive content :" + sessionMap); + } - MonitoringUtil.setAttributeNoToolSessions(request, mcService, mcContent); + logger.debug("mcGeneralAuthoringDTO.getOnlineInstructions() :" + mcGeneralAuthoringDTO.getOnlineInstructions()); + logger.debug("mcGeneralAuthoringDTO.getOfflineInstructions():" + mcGeneralAuthoringDTO.getOfflineInstructions()); + + if ((mcGeneralAuthoringDTO.getOnlineInstructions() == null) || (mcGeneralAuthoringDTO.getOnlineInstructions().length() == 0)) + { + mcGeneralAuthoringDTO.setOnlineInstructions(DEFAULT_ONLINE_INST); + mcAuthoringForm.setOnlineInstructions(DEFAULT_ONLINE_INST); + sessionMap.put(ONLINE_INSTRUCTIONS_KEY, DEFAULT_ONLINE_INST); + } + + if ((mcGeneralAuthoringDTO.getOfflineInstructions() == null) || (mcGeneralAuthoringDTO.getOfflineInstructions().length() == 0)) + { + mcGeneralAuthoringDTO.setOfflineInstructions(DEFAULT_OFFLINE_INST); + mcAuthoringForm.setOfflineInstructions(DEFAULT_OFFLINE_INST); + sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, DEFAULT_OFFLINE_INST); + } - if (mcAuthoringForm != null) - mcAuthoringForm.setCurrentTab("1"); + logger.debug("final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); logger.debug("will return to jsp with: " + sourceMcStarter); - String destination=McUtils.getDestination(sourceMcStarter); + String destination=McUtils.getDestination(sourceMcStarter, requestedModule); logger.debug("destination: " + destination); - logger.debug("activeModule: " + request.getSession().getAttribute("activeModule")); - logger.debug("defineLaterInEditMode: " + request.getSession().getAttribute("defineLaterInEditMode")); - logger.debug("editOptionsMode: " + request.getSession().getAttribute("editOptionsMode")); - logger.debug("richTextTitle: " + request.getSession().getAttribute("richTextTitle")); - logger.debug("richTextInstructions: " + request.getSession().getAttribute("richTextInstructions")); - logger.debug("mapQuestionsContent: " + request.getSession().getAttribute("mapQuestionsContent")); - logger.debug("mapWeights: " + request.getSession().getAttribute("mapWeights")); - logger.debug("queIndex: " + request.getSession().getAttribute("queIndex")); - logger.debug("maxQuestionIndex: " + request.getSession().getAttribute("maxQuestionIndex")); + Map mapQuestionContentLocal=mcGeneralAuthoringDTO.getMapQuestionContent(); + logger.debug("mapQuestionContentLocal: " + mapQuestionContentLocal); - return (mapping.findForward(destination)); - } - - /** - * each tool has a signature. MCQ tool's signature is stored in MY_SIGNATURE. The default tool content id and - * other depending content ids are obtained in this method. - * if all the default content has been setup properly the method persists DEFAULT_CONTENT_ID in the session. - * - * readSignature(HttpServletRequest request, ActionMapping mapping) - * @param request - * @param mapping - * @return ActionForward - */ - public ActionForward readSignature(HttpServletRequest request, ActionMapping mapping) - { - IMcService mcService =McUtils.getToolService(request); - /* retrieve the default content id based on tool signature */ - long contentId=0; - try - { - logger.debug("attempt retrieving tool with signature : " + MY_SIGNATURE); - contentId=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("retrieved tool default contentId: " + contentId); - if (contentId == 0) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - } - catch(Exception e) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - - /* retrieve uid of the content based on default content id determined above */ - long contentUID=0; - try - { - logger.debug("retrieve uid of the content based on default content id determined above: " + contentId); - McContent mcContent=mcService.retrieveMc(new Long(contentId)); - if (mcContent == null) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - logger.debug("using mcContent: " + mcContent); - logger.debug("using mcContent uid: " + mcContent.getUid()); - contentUID=mcContent.getUid().longValue(); - } - catch(Exception e) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - + logger.debug("mapQuestionContent: " + mapQuestionContent); + sessionMap.put(MAP_QUESTION_CONTENT_KEY, mapQuestionContent); - /* retrieve uid of the default question content */ - long queContentUID=0; - try - { - logger.debug("retrieve the default question content based on default content UID: " + queContentUID); - McQueContent mcQueContent=mcService.getToolDefaultQuestionContent(contentUID); - logger.debug("using mcQueContent: " + mcQueContent); - if (mcQueContent == null) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - logger.debug("using mcQueContent uid: " + mcQueContent.getUid()); - queContentUID=mcQueContent.getUid().longValue(); - request.getSession().setAttribute(DEFAULT_QUESTION_UID, new Long(queContentUID)); - logger.debug("DEFAULT_QUESTION_UID: " + queContentUID); - } - catch(Exception e) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } + logger.debug("persisting sessionMap into session: " + sessionMap); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - /* retrieve default options content */ - try - { - logger.debug("retrieve the default options content based on default question content UID: " + queContentUID); - List list=mcService.findMcOptionsContentByQueId(new Long(queContentUID)); - logger.debug("using options list: " + list); - if (list == null) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - - } - catch(Exception e) - { - McUtils.cleanUpSessionAbsolute(request); - logger.debug("Exception occured: No default options content"); - request.getSession().setAttribute(USER_EXCEPTION_DEFAULTCONTENT_NOTSETUP, new Boolean(true).toString()); - persistError(request,"error.defaultContent.notSetup"); - return (mapping.findForward(ERROR_LIST)); - } - - logger.debug("MCQ tool has the default content id: " + contentId); - request.getSession().setAttribute(DEFAULT_CONTENT_ID, new Long(contentId).toString()); - return null; - } - - - /** - * existsContent(long toolContentId) - * @param long toolContentId - * @return boolean - * determine whether a specific toolContentId exists in the db - */ - protected boolean existsContent(long toolContentId, HttpServletRequest request) - { - IMcService mcService =McUtils.getToolService(request); - McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); - if (mcContent == null) - return false; + AuthoringUtil authoringUtil= new AuthoringUtil(); + Map marksMap=authoringUtil.buildMarksMap(); + logger.debug("marksMap: " + marksMap); + mcGeneralAuthoringDTO.setMarksMap(marksMap); + mcGeneralAuthoringDTO.setMarkValue("1"); - return true; - } - - - /** - * retrieves the contents of an existing content from the db and prepares it for presentation - * retrieveExistingContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm, long toolContentId) - * - * @param request - * @param mcAuthoringForm - * @param toolContentId - */ - protected void retrieveExistingContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm, long toolContentId, McContent mcContent) - { - logger.debug("retrieving existing content:" + mcContent); - IMcService mcService =McUtils.getToolService(request); - logger.debug("mcService:" + mcService); - - request.getSession().setAttribute(IS_REVISITING_USER, new Boolean(true)); - /*to find out whether the content is being modified or not*/ - request.getSession().setAttribute(DEFINE_LATER, new Boolean(mcContent.isDefineLater())); - /*used in authoring mode basic tab*/ - request.getSession().setAttribute(RICHTEXT_TITLE,mcContent.getTitle()); - request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,mcContent.getInstructions()); - - mcAuthoringForm.setReflectionSubject(mcContent.getReflectionSubject()); - - logger.debug("passMark:" +mcContent.getPassMark()); - if (mcContent.getPassMark() == null) - mcContent.setPassMark(new Integer(0)); - - mcAuthoringForm.setPassmark(mcContent.getPassMark().toString()); - request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer - - /*used in advanced tab*/ - request.getSession().setAttribute(RICHTEXT_REPORT_TITLE,mcContent.getReportTitle()); - //request.getSession().setAttribute(RICHTEXT_END_LEARNING_MSG,mcContent.getEndLearningMessage()); - - /* used in instructions tab*/ - request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,mcContent.getOfflineInstructions()); - request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,mcContent.getOnlineInstructions()); - - Date creationDate=mcContent.getCreationDate(); - logger.debug("creationDate:" + creationDate); - request.getSession().setAttribute(CREATION_DATE,creationDate); - - logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE)); - logger.debug("getting name lists based on uid:" + mcContent.getUid()); - - List listUploadedOffFiles= mcService.retrieveMcUploadedOfflineFilesName(mcContent.getUid()); - logger.debug("existing listUploadedOfflineFileNames:" + listUploadedOffFiles); - request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOffFiles); - - List listUploadedOnFiles= mcService.retrieveMcUploadedOnlineFilesName(mcContent.getUid()); - logger.debug("existing listUploadedOnlineFileNames:" + listUploadedOnFiles); - request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnFiles); - - /* set radioboxes in Advanced tab*/ - AuthoringUtil.setRadioboxes(mcContent, mcAuthoringForm); - - McUtils.populateUploadedFilesData(request, mcContent); - logger.debug("populated UploadedFilesData"); - Map mapWeights= AuthoringUtil.rebuildWeightsMapfromDB(request, new Long(toolContentId)); - logger.debug("Check the mapWeights: " + mapWeights); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - - /*get existing feedback maps*/ - Map mapIncorrectFeedback = AuthoringUtil.rebuildIncorrectFeedbackMapfromDB(request, new Long(toolContentId)); - logger.debug("existing mapIncorrectFeedback:" + mapIncorrectFeedback); - request.getSession().setAttribute(MAP_INCORRECT_FEEDBACK, mapIncorrectFeedback); - - Map mapCorrectFeedback = AuthoringUtil.rebuildCorrectFeedbackMapfromDB(request, new Long(toolContentId)); - logger.debug("existing mapCorrectFeedback:" + mapCorrectFeedback); - request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); - - - Map mapQuestionsContent=AuthoringUtil.rebuildQuestionMapfromDB(request, new Long(toolContentId), mcService); - logger.debug("mapQuestionsContent:" + mapQuestionsContent); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("starter initialized the existing Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - - int maxQuestionIndex=mapQuestionsContent.size(); - request.getSession().setAttribute(MAX_QUESTION_INDEX, new Integer(maxQuestionIndex)); - logger.debug("MAX_QUESTION_INDEX: " + request.getSession().getAttribute(MAX_QUESTION_INDEX)); - - - AuthoringUtil.refreshMaps(request, toolContentId, mcService); - AuthoringUtil.assignStaterMapsToCurrentMaps(request); + Map passMarksMap=authoringUtil.buildPassMarkMap(); + logger.debug("passMarksMap: " + passMarksMap); + mcGeneralAuthoringDTO.setPassMarksMap(passMarksMap); + + String passMark=" "; - /*process offline files metadata*/ - List listOfflineFilesMetaData=mcService.getOfflineFilesMetaData(mcContent.getUid()); - logger.debug("existing listOfflineFilesMetaData, to be structured as McAttachmentDTO: " + listOfflineFilesMetaData); - listOfflineFilesMetaData=AuthoringUtil.populateMetaDataAsAttachments(listOfflineFilesMetaData); - logger.debug("populated listOfflineFilesMetaData: " + listOfflineFilesMetaData); - request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData); + //if (mcContent.getPassMark() != null) + // passMark=mcContent.getPassMark().toString(); - List listUploadedOfflineFileNames=AuthoringUtil.populateMetaDataAsFilenames(listOfflineFilesMetaData); - logger.debug("returned from db listUploadedOfflineFileNames: " + listUploadedOfflineFileNames); - request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES, listUploadedOfflineFileNames); + if ((mcContent.getPassMark() != null) && (mcContent.getPassMark().intValue() != 0)) + passMark=mcContent.getPassMark().toString(); - /*process online files metadata*/ - List listOnlineFilesMetaData=mcService.getOnlineFilesMetaData(mcContent.getUid()); - logger.debug("existing listOnlineFilesMetaData, to be structured as McAttachmentDTO: " + listOnlineFilesMetaData); - listOnlineFilesMetaData=AuthoringUtil.populateMetaDataAsAttachments(listOnlineFilesMetaData); - logger.debug("populated listOnlineFilesMetaData: " + listOnlineFilesMetaData); - request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData); + + mcGeneralAuthoringDTO.setPassMarkValue (passMark); + - List listUploadedOnlineFileNames=AuthoringUtil.populateMetaDataAsFilenames(listOnlineFilesMetaData); - logger.debug("returned from db listUploadedOnlineFileNames: " + listUploadedOnlineFileNames); - request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES, listUploadedOnlineFileNames); - } + + + Map correctMap=authoringUtil.buildCorrectMap(); + logger.debug("correctMap: " + correctMap); + mcGeneralAuthoringDTO.setCorrectMap(correctMap); + + + logger.debug("before fwding to jsp, mcAuthoringForm : " + mcAuthoringForm); + logger.debug("final mcGeneralAuthoringDTO: " + mcGeneralAuthoringDTO); + request.setAttribute(MC_GENERAL_AUTHORING_DTO, mcGeneralAuthoringDTO); + + return (mapping.findForward(destination)); + } + /** - * retrieves the contents of the default content from the db and prepares it for presentation - * retrieveDefaultContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm) - * + * retrives the existing content information from the db and prepares the data for presentation purposes. + * ActionForward retrieveExistingContent(HttpServletRequest request, ActionMapping mapping, McAuthoringForm mcAuthoringForm, Map mapQuestionContent, long toolContentID) + * * @param request + * @param mapping * @param mcAuthoringForm + * @param mapQuestionContent + * @param toolContentID + * @return ActionForward */ - protected void retrieveDefaultContent(HttpServletRequest request, McAuthoringForm mcAuthoringForm) + protected McContent retrieveContent(HttpServletRequest request, ActionMapping mapping, McAuthoringForm mcAuthoringForm, + Map mapQuestionContent, long toolContentID, boolean isDefaultContent, IMcService mcService, + McGeneralAuthoringDTO mcGeneralAuthoringDTO, SessionMap sessionMap) { - IMcService mcService = (IMcService)request.getSession().getAttribute(TOOL_SERVICE); - logger.debug("mcService: " + mcService); - if (mcService == null) - { - logger.debug("will retrieve mcService"); - mcService = McServiceProxy.getMcService(getServlet().getServletContext()); - logger.debug("retrieving mcService from cache: " + mcService); - } + logger.debug("starting retrieveContent: " + mcService); + logger.debug("toolContentID: " + toolContentID); + logger.debug("isDefaultContent: " + isDefaultContent); - request.getSession().setAttribute(IS_REVISITING_USER, new Boolean(false)); + logger.debug("getting content with id:" + toolContentID); + McContent mcContent = mcService.retrieveMc(new Long(toolContentID)); + logger.debug("McContent: " + mcContent); - request.getSession().setAttribute(DEFINE_LATER_EDIT_ACTIVITY, new Boolean(false)); - logger.debug("setting DEFINE_LATER_EDIT_ACTIVITY to false."); + McUtils.populateAuthoringDTO(request, mcContent, mcGeneralAuthoringDTO); - long contentId=0; - logger.debug("getting default content"); - contentId=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); - logger.debug("contentId:" + contentId); - McContent mcContent=mcService.retrieveMc(new Long(contentId)); - logger.debug("mcContent:" + mcContent); + mcAuthoringForm.setSln(mcContent.isShowReport()?"1":"0"); + mcAuthoringForm.setQuestionsSequenced(mcContent.isQuestionsSequenced()?"1":"0"); + mcAuthoringForm.setRetries(mcContent.isRetries()?"1":"0"); + mcAuthoringForm.setReflect(mcContent.isReflect()?"1":"0"); + mcAuthoringForm.setReflectionSubject(mcContent.getReflectionSubject()); - /* reset all radioboxes to false*/ - mcAuthoringForm.resetRadioBoxes(); - logger.debug("all radioboxes are reset"); - + mcGeneralAuthoringDTO.setSln(mcContent.isShowReport()?"1":"0"); + mcGeneralAuthoringDTO.setQuestionsSequenced(mcContent.isQuestionsSequenced()?"1":"0"); + mcGeneralAuthoringDTO.setRetries(mcContent.isRetries()?"1":"0"); + mcGeneralAuthoringDTO.setReflect(mcContent.isReflect()?"1":"0"); + mcGeneralAuthoringDTO.setReflectionSubject(mcContent.getReflectionSubject()); + + + List attachmentList = mcService.retrieveMcUploadedFiles(mcContent); + mcGeneralAuthoringDTO.setAttachmentList(attachmentList); + mcGeneralAuthoringDTO.setDeletedAttachmentList(new ArrayList()); + + sessionMap.put(ATTACHMENT_LIST_KEY, attachmentList); + sessionMap.put(DELETED_ATTACHMENT_LIST_KEY, new ArrayList()); + + + mcGeneralAuthoringDTO.setIsDefineLater(new Boolean(mcContent.isDefineLater()).toString()); + if (mcContent.getTitle() == null) { - request.getSession().setAttribute(RICHTEXT_TITLE,DEFAULT_MCQ_TITLE); + mcGeneralAuthoringDTO.setActivityTitle(DEFAULT_MC_TITLE); + mcAuthoringForm.setTitle(DEFAULT_MC_TITLE); } else { - request.getSession().setAttribute(RICHTEXT_TITLE,mcContent.getTitle()); + mcGeneralAuthoringDTO.setActivityTitle(mcContent.getTitle()); + mcAuthoringForm.setTitle(mcContent.getTitle()); } + if (mcContent.getInstructions() == null) { - request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,DEFAULT_MCQ_INSTRUCTIONS); + mcGeneralAuthoringDTO.setActivityInstructions(DEFAULT_MC_INSTRUCTIONS); + mcAuthoringForm.setInstructions(DEFAULT_MC_INSTRUCTIONS); } else { - request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,mcContent.getInstructions()); + mcGeneralAuthoringDTO.setActivityInstructions( mcContent.getInstructions()); + mcAuthoringForm.setInstructions(mcContent.getInstructions()); } - - mcAuthoringForm.setReflectionSubject(mcContent.getReflectionSubject()); - request.getSession().setAttribute(DEFINE_LATER, new Boolean(mcContent.isDefineLater())); - request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,mcContent.getOfflineInstructions()); - request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,mcContent.getOnlineInstructions()); - request.getSession().setAttribute(RETRIES, new Boolean(mcContent.isRetries())); - request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer - request.getSession().setAttribute(RICHTEXT_REPORT_TITLE,mcContent.getReportTitle()); - //request.getSession().setAttribute(RICHTEXT_END_LEARNING_MSG,mcContent.getEndLearningMessage()); - request.getSession().setAttribute(RICHTEXT_INCORRECT_FEEDBACK,""); - request.getSession().setAttribute(RICHTEXT_CORRECT_FEEDBACK,""); + sessionMap.put(ACTIVITY_TITLE_KEY, mcGeneralAuthoringDTO.getActivityTitle()); + sessionMap.put(ACTIVITY_INSTRUCTIONS_KEY, mcGeneralAuthoringDTO.getActivityInstructions()); - logger.debug("passMark:" +mcContent.getPassMark()); - if (mcContent.getPassMark() == null) - mcContent.setPassMark(new Integer(0)); + + AuthoringUtil authoringUtil= new AuthoringUtil(); + List listQuestionContentDTO=authoringUtil.buildDefaultQuestionContent(mcContent, mcService); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); - mcAuthoringForm.setPassmark(mcContent.getPassMark().toString()); - request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer + request.setAttribute(TOTAL_QUESTION_COUNT, new Integer(listQuestionContentDTO.size())); + logger.debug("listQuestionContentDTO: " + listQuestionContentDTO); + request.setAttribute(LIST_QUESTION_CONTENT_DTO,listQuestionContentDTO); + sessionMap.put(LIST_QUESTION_CONTENT_DTO_KEY, listQuestionContentDTO); - - logger.debug("PASSMARK:" + request.getSession().getAttribute(PASSMARK)); - logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE)); - logger.debug("getting default content"); - - mcAuthoringForm.setUsernameVisible("0"); - mcAuthoringForm.setQuestionsSequenced("0"); - mcAuthoringForm.setSynchInMonitor("0"); - mcAuthoringForm.setRetries("0"); - mcAuthoringForm.setShowFeedback("0"); - mcAuthoringForm.setSln("0"); - mcAuthoringForm.setReflect("0"); - - /* collect options for the default question content into a Map*/ - McQueContent mcQueContent=mcService.getToolDefaultQuestionContent(mcContent.getUid().longValue()); - logger.debug("mcQueContent:" + mcQueContent); - /* mcQueContent can not be null since here it was verified before*/ - - Map mapQuestionsContent= new TreeMap(new McComparator()); - mapQuestionsContent.put(new Long(1).toString(), mcQueContent.getQuestion()); - request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); - logger.debug("starter initialized the Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); - - /* hold all he options for this question*/ - List list=mcService.findMcOptionsContentByQueId(mcQueContent.getUid()); - logger.debug("options list:" + list); - - - Map mapOptionsContent= new TreeMap(new McStringComparator()); - Iterator listIterator=list.iterator(); - Long mapIndex=new Long(1); - while (listIterator.hasNext()) + if (isDefaultContent) { - McOptsContent mcOptsContent=(McOptsContent)listIterator.next(); - logger.debug("option text:" + mcOptsContent.getMcQueOptionText()); - mapOptionsContent.put(mapIndex.toString(),mcOptsContent.getMcQueOptionText()); - mapIndex=new Long(mapIndex.longValue()+1); + logger.debug("overwriting default question."); + mcGeneralAuthoringDTO.setDefaultQuestionContent("Sample Question 1?"); + } - request.getSession().setAttribute(MAP_OPTIONS_CONTENT, mapOptionsContent); - Map mapDefaultOptionsContent=mapOptionsContent; - request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptionsContent); + + logger.debug("mapQuestionContent is:" + mapQuestionContent); + mcGeneralAuthoringDTO.setMapQuestionContent(mapQuestionContent); - logger.debug("starter initialized the Options Map: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT)); + logger.debug("mcContent.getOnlineInstructions():" + mcContent.getOnlineInstructions()); + logger.debug("mcContent.getOfflineInstructions():" + mcContent.getOfflineInstructions()); + mcGeneralAuthoringDTO.setOnlineInstructions(mcContent.getOnlineInstructions()); + mcGeneralAuthoringDTO.setOfflineInstructions(mcContent.getOfflineInstructions()); - Map mapWeights= new TreeMap(new McComparator()); - long mapCounter=1; - mapWeights.put(new Long(mapCounter).toString(), new Integer(100).toString()); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - logger.debug("MAP_WEIGHTS:" + request.getSession().getAttribute(MAP_WEIGHTS)); + mcAuthoringForm.setOnlineInstructions(mcContent.getOnlineInstructions()); + mcAuthoringForm.setOfflineInstructions(mcContent.getOfflineInstructions()); + sessionMap.put(ONLINE_INSTRUCTIONS_KEY, mcContent.getOnlineInstructions()); + sessionMap.put(OFFLINE_INSTRUCTIONS_KEY, mcContent.getOfflineInstructions()); + + logger.debug("ACTIVITY_TITLE_KEY set to:" + sessionMap.get(ACTIVITY_TITLE_KEY )); + + mcAuthoringForm.resetUserAction(); + logger.debug("returning mcContent:" + mcContent); + return mcContent; } + - /** - * initialisation - * initialiseAttributes(HttpServletRequest request) + * each tool has a signature. MC tool's signature is stored in MY_SIGNATURE. The default tool content id and + * other depending content ids are obtained in this method. + * if all the default content has been setup properly the method persists DEFAULT_CONTENT_ID in the session. * + * readSignature(HttpServletRequest request, ActionMapping mapping) * @param request + * @param mapping + * @return ActionForward */ - protected void initialiseAttributes(HttpServletRequest request, McAuthoringForm mcAuthoringForm) + public boolean readSignature(HttpServletRequest request, ActionMapping mapping, IMcService mcService, + McGeneralAuthoringDTO mcGeneralAuthoringDTO, McAuthoringForm mcAuthoringForm) { - logger.debug("starting initialiseAttributes..."); - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - - /* needs to run only once per tool*/ - /* McUtils.configureContentRepository(request, mcService); */ - - /* these two are for Instructions jsp */ - LinkedList listUploadedOfflineFileNames= new LinkedList(); - LinkedList listUploadedOnlineFileNames= new LinkedList(); - - request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames); - request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames); - - LinkedList listOfflineFilesMetaData= new LinkedList(); - LinkedList listOnlineFilesMetaData= new LinkedList(); - request.getSession().setAttribute(LIST_OFFLINEFILES_METADATA, listOfflineFilesMetaData); - request.getSession().setAttribute(LIST_ONLINEFILES_METADATA, listOnlineFilesMetaData); - - Map mapGeneralOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent); - - Map mapGeneralSelectedOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_GENERAL_SELECTED_OPTIONS_CONTENT, mapGeneralSelectedOptionsContent); - - Map mapStartupGeneralOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_STARTUP_GENERAL_OPTIONS_CONTENT, mapStartupGeneralOptionsContent); - - Map mapStartupGeneralSelectedOptionsContent= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_STARTUP_GENERAL_SELECTED_OPTIONS_CONTENT, mapStartupGeneralSelectedOptionsContent); - - Map mapDisabledQuestions= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_DISABLED_QUESTIONS, mapDisabledQuestions); - - Map mapWeights= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_WEIGHTS, mapWeights); - - Map mapCheckBoxStates= new TreeMap(new McComparator()); - mapCheckBoxStates.put("1" ,"INCORRECT"); - mapCheckBoxStates.put("2" ,"CORRECT"); - request.getSession().setAttribute(MAP_CHECKBOX_STATES, mapCheckBoxStates); + logger.debug("mcService: " + mcService); + /* + * retrieve the default content id based on tool signature + */ + long defaultContentID=0; + try + { + logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); + defaultContentID=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); + logger.debug("retrieved tool default contentId: " + defaultContentID); + if (defaultContentID == 0) + { + logger.debug("default content id has not been setup"); + return false; + } + } + catch(Exception e) + { + logger.debug("error getting the default content id: " + e.getMessage()); + persistError(request,"error.defaultContent.notSetup"); + return false; + } - Map mapDefaultOptions= new TreeMap(new McComparator()); - mapDefaultOptions.put("1" ,DEFAULT_FIRST_OPTION); - mapDefaultOptions.put("2" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTOPTIONS_CONTENT, mapDefaultOptions); + /* retrieve uid of the content based on default content id determined above */ + long contentUID=0; + try + { + logger.debug("retrieve uid of the content based on default content id determined above: " + defaultContentID); + McContent mcContent=mcService.retrieveMc(new Long(defaultContentID)); + if (mcContent == null) + { + logger.debug("Exception occured: No default content"); + persistError(request,"error.defaultContent.notSetup"); + return false; + } + logger.debug("using mcContent: " + mcContent); + logger.debug("using mcContent uid: " + mcContent.getUid()); + contentUID=mcContent.getUid().longValue(); + logger.debug("contentUID: " + contentUID); + } + catch(Exception e) + { + logger.debug("Exception occured: No default question content"); + persistError(request,"error.defaultContent.notSetup"); + return false; + } - Map mapDefaultSelectedOptions= new TreeMap(new McComparator()); - mapDefaultSelectedOptions.put("1" ,DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_DEFAULTSELECTEDOPTIONS_CONTENT, mapDefaultSelectedOptions); - - Map mapSelectedOptions= new TreeMap(new McComparator()); - mapSelectedOptions.put("1",DEFAULT_SELECTED_OPTION); - request.getSession().setAttribute(MAP_SELECTED_OPTIONS, mapSelectedOptions); + logger.debug("MC tool has the default content id: " + defaultContentID); + mcGeneralAuthoringDTO.setDefaultContentIdStr(new Long(defaultContentID).toString()); + mcAuthoringForm.setDefaultContentIdStr(new Long(defaultContentID).toString()); - Map mapIncorrectFeedback= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_INCORRECT_FEEDBACK, mapIncorrectFeedback); - - Map mapCorrectFeedback= new TreeMap(new McComparator()); - request.getSession().setAttribute(MAP_CORRECT_FEEDBACK, mapCorrectFeedback); - - mcAuthoringForm.setEditOptionsMode(new Integer(0).toString()); - request.getSession().setAttribute(EDIT_OPTIONS_MODE, new Integer(0)); - logger.debug("resetting EDIT_OPTIONS_MODE to 0"); + return true; } + /** - * is reused by defineLater and monitoring urls to activate defineLater module + * existsContent(long toolContentID) + * @param long toolContentID + * @return boolean + * determine whether a specific toolContentID exists in the db + */ + protected boolean existsContent(long toolContentID, IMcService mcService) + { + McContent mcContent=mcService.retrieveMc(new Long(toolContentID)); + if (mcContent == null) + return false; + + return true; + } + + + /** + * bridges define later url request to authoring functionality * * executeDefineLater(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, IMcService mcService) @@ -856,31 +631,19 @@ * @param request * @param response * @param mcService - * @return ActionForward + * @return * @throws IOException * @throws ServletException * @throws McApplicationException */ - public ActionForward executeDefineLater(ActionMapping mapping, ActionForm form, + public ActionForward executeDefineLater(ActionMapping mapping, McAuthoringForm mcAuthoringForm, HttpServletRequest request, HttpServletResponse response, IMcService mcService) throws IOException, ServletException, McApplicationException { - logger.debug("passed mcService: " + mcService); - request.getSession().setAttribute(TOOL_SERVICE, mcService); - - return execute(mapping, form, request, response); + logger.debug("calling execute..., mcService will be needed next."); + return execute(mapping, mcAuthoringForm, request, response); } - - - public ActionForward executeGetMonitoringTab(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException, McApplicationException - { - logger.debug("CURRENT_MONITORING_TAB: " + request.getSession().getAttribute(CURRENT_MONITORING_TAB)); - logger.debug("starting executeGetMonitoringTab for: " + LOAD_MONITORING_CONTENT); - return (mapping.findForward(LOAD_MONITORING_CONTENT)); - } - /** * persists error messages to request scope * @param request @@ -894,3 +657,4 @@ saveErrors(request,errors); } } + Fisheye: Tag 1.17 refers to a dead (removed) revision in file `lams_tool_lamc/web/McErrorBox.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/web/Template.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/Attic/Template.jsp,v diff -u -r1.8 -r1.9 --- lams_tool_lamc/web/Template.jsp 28 Sep 2006 23:30:37 -0000 1.8 +++ lams_tool_lamc/web/Template.jsp 2 Oct 2006 01:44:13 -0000 1.9 @@ -1,10 +1,9 @@ -<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %> -<%-- +<%-- Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) License Information: http://lamsfoundation.org/licensing/lams/2.0/ This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as + it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, @@ -14,31 +13,14 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA http://www.gnu.org/licenses/gpl.txt --%> -<%@ taglib uri="tags-bean" prefix="bean"%> -<%@ taglib uri="tags-html" prefix="html"%> -<%@ taglib uri="tags-logic" prefix="logic" %> -<%@ taglib uri="tags-logic-el" prefix="logic-el" %> -<%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="fck-editor" prefix="FCK" %> -<%@ taglib uri="tags-lams" prefix="lams" %> - - - - - - - <bean:message key="activity.title"/> - - + Index: lams_tool_lamc/web/error.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/error.jsp,v diff -u -r1.3 -r1.4 --- lams_tool_lamc/web/error.jsp 28 Sep 2006 23:30:37 -0000 1.3 +++ lams_tool_lamc/web/error.jsp 2 Oct 2006 01:44:13 -0000 1.4 @@ -1,3 +1,24 @@ +<%-- +Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) +License Information: http://lamsfoundation.org/licensing/lams/2.0/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + http://www.gnu.org/licenses/gpl.txt +--%> + + @@ -51,7 +72,7 @@ <% } %> - + Index: lams_tool_lamc/web/WEB-INF/lams.tld =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/WEB-INF/Attic/lams.tld,v diff -u -r1.10 -r1.11 --- lams_tool_lamc/web/WEB-INF/lams.tld 28 Sep 2006 23:30:37 -0000 1.10 +++ lams_tool_lamc/web/WEB-INF/lams.tld 2 Oct 2006 01:44:13 -0000 1.11 @@ -13,26 +13,6 @@ - Converts role name into form usable as message resources key - Converts role name into form usable as message resources key - - - role - org.lamsfoundation.lams.web.tag.RoleTag - empty - - - Converts role name into form usable as message resources key - role - true - - true - - - - - - Output the Server URL as defined in the lams.xml configuration file. LAMS URL @@ -84,34 +64,6 @@ - Help tag - Help tag - - - help - org.lamsfoundation.lams.web.tag.HelpTag - empty - - - Help tag - module - true - - true - - - - Help tag - toolSignature - true - - true - - - - - - Output a random number for the learner and passon flash movies to communicate directly. generate unique ID @@ -179,15 +131,7 @@ true - - Output stylesheet based on the user preferences. - style - false - true - - - @@ -382,16 +326,6 @@ TabBody /WEB-INF/tags/TabBody.tag - - - HTMLEditor - /WEB-INF/tags/HTMLEditor.tag - - - SetEditor - /WEB-INF/tags/SetEditor.tag - - FCKEditor /WEB-INF/tags/FCKEditor.tag Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_lamc/web/WEB-INF/jstl/tlds/permittedTaglibs.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_lamc/web/WEB-INF/jstl/tlds/scriptfree.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_lamc/web/WEB-INF/struts/tlds/c.tld'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_lamc/web/WEB-INF/struts/tlds/struts-logic-el.tld'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/WEB-INF/tiles/Attic/tiles-defs.xml,v diff -u -r1.30 -r1.31 --- lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml 17 Sep 2006 06:23:45 -0000 1.30 +++ lams_tool_lamc/web/WEB-INF/tiles/tiles-defs.xml 2 Oct 2006 01:44:18 -0000 1.31 @@ -19,8 +19,7 @@ USA http://www.gnu.org/licenses/gpl.txt ---> - +--> @@ -37,76 +36,61 @@ - + - + - - + - - - + + + - + - - - - - - - - - - + + + - - + + - - - - - - - - - - + + + + - - - - + + + + + + + + + + - - - - + + + + - - - - - - - @@ -119,12 +103,6 @@ - - - - - - Fisheye: Tag 1.37 refers to a dead (removed) revision in file `lams_tool_lamc/web/authoring/AuthoringMaincontent.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/web/authoring/BasicContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/authoring/BasicContent.jsp,v diff -u -r1.29 -r1.30 --- lams_tool_lamc/web/authoring/BasicContent.jsp 28 Sep 2006 23:30:37 -0000 1.29 +++ lams_tool_lamc/web/authoring/BasicContent.jsp 2 Oct 2006 01:44:18 -0000 1.30 @@ -1,9 +1,9 @@ -<%-- +<%-- Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) License Information: http://lamsfoundation.org/licensing/lams/2.0/ This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as + it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, @@ -13,298 +13,145 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 - USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA http://www.gnu.org/licenses/gpl.txt --%> -<%@ taglib uri="tags-bean" prefix="bean"%> -<%@ taglib uri="tags-html" prefix="html"%> -<%@ taglib uri="tags-logic" prefix="logic" %> -<%@ taglib uri="tags-logic-el" prefix="logic-el" %> -<%@ taglib uri="tags-core" prefix="c"%> -<%@ taglib uri="tags-fmt" prefix="fmt" %> -<%@ taglib uri="fck-editor" prefix="FCK" %> -<%@ taglib uri="tags-lams" prefix="lams" %> +<%@ include file="/common/taglibs.jsp"%> - - - -
- - - - -
- - images/success.gif" align="left" width=20 height=20> - - - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - + + + + + - + + - + - - - - - - - - - + - - -
- -
- -
: - -
: - -
- -
- - - - - - - - - - - - - - + - - - - - + +
- -
${queIndex} : - " value="" - size="30" maxlength="255" > -
- - - -
- - - - - - - -
- - - -
-
: - + +
+ +
+
- +
+ +
+ +
-
+
+ + <%@ include file="/authoring/itemlist.jsp"%> + + + <%@ include file="/monitoring/itemlist.jsp"%> + +
+
: - + + ');" + style="float:right;width:150px" class="button-add-item">
- + ');" + style="float:right;width:150px" class="button-add-item"> +
-
- - - -
+ + + + + + + - -

- - -

-
- -

- - -

-
+ + + + + + +
 
+ +

+ + +

+ +
+ + + + + +
- -

- - -

- -
- \ No newline at end of file + + + \ No newline at end of file Index: lams_tool_lamc/web/common/header.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/common/header.jsp,v diff -u -r1.3 -r1.4 --- lams_tool_lamc/web/common/header.jsp 28 Sep 2006 23:30:37 -0000 1.3 +++ lams_tool_lamc/web/common/header.jsp 2 Oct 2006 01:44:14 -0000 1.4 @@ -1,26 +1,36 @@ <%@ include file="/common/taglibs.jsp"%> - - - + + + + + + + - - - - - - - - - - - + + + + + + + - - - - - + + + + + + + + + - \ No newline at end of file + + + + + +<%@ include file="/common/fckeditorheader.jsp"%> + Index: lams_tool_lamc/web/export/exportportfolio.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/export/exportportfolio.jsp,v diff -u -r1.13 -r1.14 --- lams_tool_lamc/web/export/exportportfolio.jsp 28 Sep 2006 23:30:37 -0000 1.13 +++ lams_tool_lamc/web/export/exportportfolio.jsp 2 Oct 2006 01:44:14 -0000 1.14 @@ -31,21 +31,26 @@ - + -

+
+ +

+
-
+
+
+

@@ -62,16 +67,16 @@ - +   : -   ( - ) +   ( + ) @@ -80,7 +85,7 @@ - +   () @@ -96,7 +101,7 @@ - + @@ -105,7 +110,7 @@

- + @@ -118,12 +123,11 @@ - + @@ -169,16 +173,16 @@
-   ( - ) +   ( )
- + @@ -187,7 +191,7 @@
 
: -   ( - ) +   ( + )
- +   () @@ -202,17 +206,17 @@
- + - + @@ -222,13 +226,13 @@ - +
- ( ) + ()
@@ -250,21 +254,21 @@
- +
- : + :
- : + :
- +
- - - - @@ -120,12 +115,19 @@
@@ -317,9 +321,11 @@ -
+ +
+ Index: lams_tool_lamc/web/includes/javascript/common.js =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/includes/javascript/Attic/common.js,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_lamc/web/includes/javascript/common.js 2 Oct 2006 01:44:13 -0000 1.1 @@ -0,0 +1,18 @@ + function launchPopup(url,title) { + var wd = null; + if(wd && wd.open && !wd.closed){ + wd.close(); + } + wd = window.open(url,title,'resizable,width=796,height=570,scrollbars'); + wd.window.focus(); + } + function showBusy(targetDiv){ + if($(targetDiv+"_Busy") != null){ + Element.show(targetDiv+"_Busy"); + } + } + function hideBusy(targetDiv){ + if($(targetDiv+"_Busy") != null){ + Element.hide(targetDiv+"_Busy"); + } + } \ No newline at end of file Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_lamc/web/includes/javascript/rsrccommon.js'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_lamc/web/includes/javascript/rsrcresourceitem.js'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_lamc/web/layout/default.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/layout/Attic/default.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_lamc/web/layout/default.jsp 28 Sep 2006 23:30:37 -0000 1.2 +++ lams_tool_lamc/web/layout/default.jsp 2 Oct 2006 01:44:19 -0000 1.3 @@ -5,7 +5,7 @@ - + Index: lams_tool_lamc/web/learning/AnswersContent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/AnswersContent.jsp,v diff -u -r1.21 -r1.22 --- lams_tool_lamc/web/learning/AnswersContent.jsp 28 Sep 2006 23:30:37 -0000 1.21 +++ lams_tool_lamc/web/learning/AnswersContent.jsp 2 Oct 2006 01:44:13 -0000 1.22 @@ -47,15 +47,16 @@ - + +
-

+

+
- -
+
@@ -78,8 +79,9 @@
- + +
Index: lams_tool_lamc/web/learning/IndividualLearnerResults.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/IndividualLearnerResults.jsp,v diff -u -r1.24 -r1.25 --- lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 28 Sep 2006 23:30:37 -0000 1.24 +++ lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 2 Oct 2006 01:44:13 -0000 1.25 @@ -37,16 +37,17 @@ <bean:message key="activity.title" /> - + +
-

+

+
+
-
- @@ -65,12 +66,6 @@
- -
+ + + + + + + + +
-  [ : - ] +
+  [ + ] +
@@ -138,15 +140,15 @@
- - -
-
- -
-
+
+     +
@@ -229,7 +231,7 @@ - + Index: lams_tool_lamc/web/learning/Notebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Notebook.jsp,v diff -u -r1.3 -r1.4 --- lams_tool_lamc/web/learning/Notebook.jsp 28 Sep 2006 23:30:37 -0000 1.3 +++ lams_tool_lamc/web/learning/Notebook.jsp 2 Oct 2006 01:44:13 -0000 1.4 @@ -38,22 +38,23 @@ <bean:message key="activity.title" /> - + +
-

+

+
- -
+
@@ -81,9 +82,10 @@ - + + Index: lams_tool_lamc/web/learning/RedoQuestions.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/RedoQuestions.jsp,v diff -u -r1.17 -r1.18 --- lams_tool_lamc/web/learning/RedoQuestions.jsp 28 Sep 2006 23:30:37 -0000 1.17 +++ lams_tool_lamc/web/learning/RedoQuestions.jsp 2 Oct 2006 01:44:13 -0000 1.18 @@ -38,15 +38,16 @@ <bean:message key="activity.title" /> - + +
-

+

+
- @@ -58,7 +59,7 @@ -
+
@@ -125,9 +126,10 @@ - + + Index: lams_tool_lamc/web/learning/ResultsSummary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/ResultsSummary.jsp,v diff -u -r1.20 -r1.21 --- lams_tool_lamc/web/learning/ResultsSummary.jsp 28 Sep 2006 23:30:37 -0000 1.20 +++ lams_tool_lamc/web/learning/ResultsSummary.jsp 2 Oct 2006 01:44:13 -0000 1.21 @@ -38,15 +38,16 @@ <bean:message key="activity.title" /> - + +
-

+

+
- -
+
@@ -152,8 +153,9 @@
- + +
Index: lams_tool_lamc/web/learning/RunOffline.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/RunOffline.jsp,v diff -u -r1.5 -r1.6 --- lams_tool_lamc/web/learning/RunOffline.jsp 28 Sep 2006 23:30:37 -0000 1.5 +++ lams_tool_lamc/web/learning/RunOffline.jsp 2 Oct 2006 01:44:13 -0000 1.6 @@ -38,20 +38,21 @@ <bean:message key="activity.title" /> - + +
-

 

+

 

+
- -
+
      @@ -78,9 +79,10 @@ - + + Index: lams_tool_lamc/web/learning/ViewAnswers.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/ViewAnswers.jsp,v diff -u -r1.30 -r1.31 --- lams_tool_lamc/web/learning/ViewAnswers.jsp 28 Sep 2006 23:30:37 -0000 1.30 +++ lams_tool_lamc/web/learning/ViewAnswers.jsp 2 Oct 2006 01:44:13 -0000 1.31 @@ -38,15 +38,17 @@ <bean:message key="activity.title" /> - + +
-

+

+
-
+
@@ -67,13 +69,7 @@ -
- - - @@ -107,12 +103,13 @@ + @@ -123,15 +120,18 @@ +
- -
@@ -96,7 +92,7 @@
- +
images/dot.jpg" align=left>   - +
+ + @@ -240,8 +240,9 @@ - + + Index: lams_tool_lamc/web/learning/defineLater.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/defineLater.jsp,v diff -u -r1.6 -r1.7 --- lams_tool_lamc/web/learning/defineLater.jsp 28 Sep 2006 23:30:37 -0000 1.6 +++ lams_tool_lamc/web/learning/defineLater.jsp 2 Oct 2006 01:44:13 -0000 1.7 @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.gnu.org/licenses/gpl.txt @@ -38,19 +38,21 @@ <bean:message key="activity.title" /> - + +
-

 

+

 

+
- -
+
- + +
Index: lams_tool_lamc/web/monitoring/LearnerNotebook.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/monitoring/LearnerNotebook.jsp,v diff -u -r1.4 -r1.5 --- lams_tool_lamc/web/monitoring/LearnerNotebook.jsp 28 Sep 2006 23:30:37 -0000 1.4 +++ lams_tool_lamc/web/monitoring/LearnerNotebook.jsp 2 Oct 2006 01:44:14 -0000 1.5 @@ -1,9 +1,9 @@ -<%-- +<%-- Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) License Information: http://lamsfoundation.org/licensing/lams/2.0/ This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as + it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, @@ -13,7 +13,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA http://www.gnu.org/licenses/gpl.txt --%> @@ -38,18 +39,19 @@ - + +
-

+

+
- -
+
@@ -143,7 +143,7 @@
- +
@@ -61,7 +63,7 @@
-

+

@@ -79,9 +81,10 @@ - + + Index: lams_tool_lamc/web/monitoring/MonitoringMaincontent.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/web/monitoring/MonitoringMaincontent.jsp,v diff -u -r1.35 -r1.36 --- lams_tool_lamc/web/monitoring/MonitoringMaincontent.jsp 28 Sep 2006 23:30:37 -0000 1.35 +++ lams_tool_lamc/web/monitoring/MonitoringMaincontent.jsp 2 Oct 2006 01:44:14 -0000 1.36 @@ -1,9 +1,9 @@ -<%-- +<%-- Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) License Information: http://lamsfoundation.org/licensing/lams/2.0/ This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as + it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, @@ -13,7 +13,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + USA http://www.gnu.org/licenses/gpl.txt --%> @@ -36,149 +37,146 @@ pageContext.setAttribute("tabs", tabs); %> - - - <fmt:message key="activity.title" /> + + + <bean:message key="label.monitoring"/> + <%@ include file="/common/header.jsp"%> + + - - + + -<%-- chooses which tab to highlight --%> - -
-

- - - - +
+

- -
- - +
+ + + + + + + + + + + - + + + + + +
- - - - - -
-
- - -
- +
+
- - - - - - -