Index: lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/Attic/McQueContent.hbm.xml,v diff -u -r1.10 -r1.11 --- lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml 20 Oct 2005 09:35:18 -0000 1.10 +++ lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml 25 Oct 2005 17:19:19 -0000 1.11 @@ -40,6 +40,14 @@ + + + - + @@ -267,11 +267,24 @@ + + + + + + + + + + + + + - + Index: lams_tool_lamc/db/sql/create_lams_tool_lamc.sql =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/db/sql/Attic/create_lams_tool_lamc.sql,v diff -u -r1.13 -r1.14 Binary files differ Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/Attic/McQueContent.java,v diff -u -r1.9 -r1.10 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java 20 Oct 2005 09:35:18 -0000 1.9 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McQueContent.java 25 Oct 2005 17:19:10 -0000 1.10 @@ -44,7 +44,10 @@ /** nullable persistent field */ private Integer displayOrder; - + + /** nullable persistent field */ + private Integer weight; + /** persistent field */ private boolean disabled; @@ -78,6 +81,17 @@ this.mcOptionsContents = mcOptionsContents; } + public McQueContent(String question, Integer displayOrder, Integer weight, boolean disabled, McContent mcContent, Set mcUsrAttempts, Set mcOptionsContents) { + this.question = question; + this.displayOrder = displayOrder; + this.weight = weight; + this.disabled = disabled; + this.mcContent=mcContent; + this.mcUsrAttempts = mcUsrAttempts; + this.mcOptionsContents = mcOptionsContents; + } + + public McQueContent(Long mcQueContentId, String question, Integer displayOrder, Set mcUsrAttempts, Set mcOptionsContents) { this.mcQueContentId = mcQueContentId; this.question = question; @@ -86,6 +100,17 @@ this.mcOptionsContents = mcOptionsContents; } + public McQueContent(Long mcQueContentId, String question, Integer displayOrder, Integer weight, Set mcUsrAttempts, Set mcOptionsContents) { + this.mcQueContentId = mcQueContentId; + this.question = question; + this.displayOrder = displayOrder; + this.weight=weight; + this.mcUsrAttempts = mcUsrAttempts; + this.mcOptionsContents = mcOptionsContents; + } + + + public McQueContent(String question, Integer displayOrder, Set mcUsrAttempts, Set mcOptionsContents) { this.question = question; this.displayOrder = displayOrder; @@ -116,12 +141,14 @@ * @return the new qa question content object */ public static McQueContent newInstance(McQueContent queContent, - McContent newQaContent, + McContent newMcContent, McQueContent parentQuestion) { McQueContent newQueContent = new McQueContent(queContent.getQuestion(), queContent.getDisplayOrder(), - newQaContent, + queContent.getWeight(), + queContent.isDisabled(), + newMcContent, new TreeSet(), new TreeSet()); return newQueContent; @@ -219,4 +246,16 @@ public void setDisabled(boolean disabled) { this.disabled = disabled; } + /** + * @return Returns the weight. + */ + public Integer getWeight() { + return weight; + } + /** + * @param weight The weight to set. + */ + public void setWeight(Integer weight) { + this.weight = weight; + } } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java,v diff -u -r1.4 -r1.5 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 21 Oct 2005 13:20:45 -0000 1.4 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java 25 Oct 2005 17:19:10 -0000 1.5 @@ -6,15 +6,25 @@ */ package org.lamsfoundation.lams.tool.mc; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.text.DateFormat; import java.util.Date; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.Random; import java.util.TimeZone; +import java.util.TreeMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.web.McAuthoringForm; import org.lamsfoundation.lams.usermanagement.User; @@ -200,7 +210,6 @@ public static void persistRichText(HttpServletRequest request) { - /* String richTextOfflineInstructions=request.getParameter(RICHTEXT_OFFLINEINSTRUCTIONS); logger.debug("read parameter richTextOfflineInstructions: " + richTextOfflineInstructions); String richTextOnlineInstructions=request.getParameter(RICHTEXT_ONLINEINSTRUCTIONS); @@ -216,7 +225,7 @@ request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,richTextOnlineInstructions); } - */ + String richTextTitle=request.getParameter(RICHTEXT_TITLE); logger.debug("read parameter richTextTitle: " + richTextTitle); String richTextInstructions=request.getParameter(RICHTEXT_INSTRUCTIONS); @@ -233,6 +242,252 @@ } } + public static void addFileToContentRepository(HttpServletRequest request, McAuthoringForm mcAuthoringForm, boolean isOfflineFile) + { + logger.debug("attempt addFileToContentRepository"); + IMcService mcService =McUtils.getToolService(request); + logger.debug("mcService: " + mcService); + + Boolean populateUploadedFilesData=(Boolean)request.getSession().getAttribute(POPULATED_UPLOADED_FILESDATA); + logger.debug("boolean populateUploadedFilesData: " + populateUploadedFilesData); + + if ((populateUploadedFilesData !=null) && (populateUploadedFilesData.booleanValue())) + { + Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID); + logger.debug("toolContentId: " + toolContentId); + McContent defaultMcContent=mcService.retrieveMc(toolContentId); + logger.debug("defaultMcContent: " + defaultMcContent); + + //populateUploadedFilesMetaDataFromDb(request, defaultMcContent); + logger.debug("done populateUploadedFilesMetaDataFromDb"); + } + + + List listUploadedOfflineFilesUuid = (List) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILES_UUID); + logger.debug("listUploadedOfflineFilesUuid: " + listUploadedOfflineFilesUuid); + + List listUploadedOfflineFilesName = (List) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILES_NAME); + logger.debug("listUploadedOfflineFilesName: " + listUploadedOfflineFilesName); + + List listUploadedOnlineFilesUuid = (List) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILES_UUID); + logger.debug("listUploadedOnlineFilesUuid: " + listUploadedOnlineFilesUuid); + + List listUploadedOnlineFilesName = (List) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILES_NAME); + logger.debug("listUploadedOnlineFilesName: " + listUploadedOnlineFilesName); + + List listUploadedOfflineFiles= (List) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILES); + logger.debug("listUploadedOfflineFiles: " + listUploadedOfflineFiles); + + List listUploadedOfflineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILENAMES); + logger.debug("listUploadedOfflineFiles: " + listUploadedOfflineFiles); + + List listUploadedOnlineFileNames=(List)request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILENAMES); + logger.debug("listUploadedOnlineFileNames: " + listUploadedOnlineFileNames); + + + if (listUploadedOfflineFileNames == null) + listUploadedOfflineFileNames = new LinkedList(); + logger.debug("listUploadedOfflineFileNames: " + listUploadedOfflineFileNames); + + if (listUploadedOnlineFileNames == null) + listUploadedOnlineFileNames = new LinkedList(); + logger.debug("listUploadedOnlineFileNames: " + listUploadedOnlineFileNames); + + Map allOfflineUuids= new TreeMap(new McComparator()); + if ((listUploadedOfflineFilesUuid != null) && (listUploadedOfflineFilesName != null)) + { + logger.debug("listUploadedOfflineFilesUuid and listUploadedOfflineFilesName are not null"); + Iterator listUploadedOfflineFilesUuidIterator=listUploadedOfflineFilesUuid.iterator(); + int counter=1; + logger.debug("allOfflineUuids: " + allOfflineUuids); + while (listUploadedOfflineFilesUuidIterator.hasNext()) + { + String uuid = (String)listUploadedOfflineFilesUuidIterator.next(); + allOfflineUuids.put(new Integer(counter).toString(), uuid); + counter++; + } + logger.debug("allOfflineUuids: " + allOfflineUuids); + Iterator listUploadedOfflineFilesNameIterator=listUploadedOfflineFilesName.iterator(); + + counter=1; + while (listUploadedOfflineFilesNameIterator.hasNext()) + { + String fileName = (String)listUploadedOfflineFilesNameIterator.next(); + /* + if (!offLineFileNameExists(request,fileName)) + { + logger.debug("reading with counter: " + new Integer(counter).toString()); + String uuid=(String)allOfflineUuids.get(new Integer(counter).toString()); + logger.debug("parsed uuid: " + uuid); + listUploadedOfflineFiles.add(uuid + '~'+ fileName); + counter++; + } + else + { + logger.debug("offline fileName exists: " +fileName); + } + */ + } + logger.debug("final listUploadedOfflineFiles: " + listUploadedOfflineFiles); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES,listUploadedOfflineFiles); + } + /* + List listUploadedOfflineFileNames = (List) request.getSession().getAttribute(LIST_UPLOADED_OFFLINE_FILENAMES); + logger.debug("listUploadedOfflineFileNames: " + listUploadedOfflineFileNames); + + + List listUploadedOnlineFileNames = (List) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILENAMES); + logger.debug("listUploadedOnlineFileNames: " + listUploadedOnlineFileNames); + */ + + + /**holds final online files list */ + List listUploadedOnlineFiles= (List) request.getSession().getAttribute(LIST_UPLOADED_ONLINE_FILES); + logger.debug("listUploadedOnlineFiles: " + listUploadedOnlineFiles); + + Map allOnlineUuids= new TreeMap(new McComparator()); + if ((listUploadedOnlineFilesUuid != null) && (listUploadedOnlineFilesName != null)) + { + logger.debug("listUploadedOnlineFilesUuid and listUploadedOnlineFilesName are not null"); + Iterator listUploadedOnlineFilesUuidIterator=listUploadedOnlineFilesUuid.iterator(); + int counter=1; + logger.debug("allOnlineUuids: " + allOnlineUuids); + while (listUploadedOnlineFilesUuidIterator.hasNext()) + { + String uuid = (String)listUploadedOnlineFilesUuidIterator.next(); + allOnlineUuids.put(new Integer(counter).toString(), uuid); + counter++; + + } + logger.debug("allOnlineUuids: " + allOnlineUuids); + Iterator listUploadedOnlineFilesNameIterator=listUploadedOnlineFilesName.iterator(); + + counter=1; + while (listUploadedOnlineFilesNameIterator.hasNext()) + { + String fileName = (String)listUploadedOnlineFilesNameIterator.next(); + /* + if (!onLineFileNameExists(request,fileName)) + { + logger.debug("reading with counter: " + new Integer(counter).toString()); + String uuid=(String)allOnlineUuids.get(new Integer(counter).toString()); + logger.debug("parsed uuid: " + uuid); + listUploadedOnlineFiles.add(uuid + '~'+ fileName); + counter++; + } + else + { + logger.debug("online fileName exists: " +fileName); + } + */ + } + logger.debug("final listUploadedOnlineFiles: " + listUploadedOnlineFiles); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES,listUploadedOnlineFiles); + } + + + if (isOfflineFile) + { + /** read uploaded file informtion - offline file*/ + logger.debug("retrieve theOfflineFile."); + FormFile theOfflineFile = mcAuthoringForm.getTheOfflineFile(); + logger.debug("retrieved theOfflineFile: " + theOfflineFile); + + String offlineFileName=""; + NodeKey nodeKey=null; + String offlineFileUuid=""; + try + { + InputStream offlineFileInputStream = theOfflineFile.getInputStream(); + logger.debug("retrieved offlineFileInputStream: " + offlineFileInputStream); + offlineFileName=theOfflineFile.getFileName(); + logger.debug("retrieved offlineFileName: " + offlineFileName); + nodeKey=mcService.uploadFileToRepository(offlineFileInputStream, offlineFileName); + logger.debug("repository returned nodeKey: " + nodeKey); + logger.debug("repository returned offlineFileUuid nodeKey uuid: " + nodeKey.getUuid()); + offlineFileUuid=nodeKey.getUuid().toString(); + logger.debug("offline file added to contentRepository"); + logger.debug("using listUploadedOfflineFiles: " + listUploadedOfflineFiles); + listUploadedOfflineFiles.add(offlineFileUuid + "~" + offlineFileName); + logger.debug("listUploadedOfflineFiles updated: " + listUploadedOfflineFiles); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES,listUploadedOfflineFiles); + + listUploadedOfflineFileNames.add(offlineFileName); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES,listUploadedOfflineFileNames); + } + catch(FileNotFoundException e) + { + logger.debug("exception occured, offline file not found : " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(IOException e) + { + logger.debug("exception occured in offline file transfer: " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(McApplicationException e) + { + logger.debug("exception occured in accessing the repository server: " + e.getMessage()); + //possibly give warning to user in request scope + } + } + else + { + /** read uploaded file information - online file*/ + logger.debug("retrieve theOnlineFile"); + FormFile theOnlineFile = mcAuthoringForm.getTheOnlineFile(); + logger.debug("retrieved theOnlineFile: " + theOnlineFile); + + String onlineFileName=""; + NodeKey nodeKey=null; + String onlineFileUuid=""; + try + { + InputStream onlineFileInputStream = theOnlineFile.getInputStream(); + logger.debug("retrieved onlineFileInputStream: " + onlineFileInputStream); + onlineFileName=theOnlineFile.getFileName(); + logger.debug("retrieved onlineFileName: " + onlineFileName); + nodeKey=mcService.uploadFileToRepository(onlineFileInputStream, onlineFileName); + logger.debug("repository returned nodeKey: " + nodeKey); + logger.debug("repository returned onlineFileUuid nodeKey uuid: " + nodeKey.getUuid()); + onlineFileUuid=nodeKey.getUuid().toString(); + logger.debug("online file added to contentRepository"); + listUploadedOnlineFiles.add(onlineFileUuid + "~" + onlineFileName); + logger.debug("listUploadedOnlineFiles updated: " + listUploadedOnlineFiles); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES,listUploadedOnlineFiles); + + listUploadedOnlineFileNames.add(onlineFileName); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES,listUploadedOnlineFileNames); + } + catch(FileNotFoundException e) + { + logger.debug("exception occured, online file not found : " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(IOException e) + { + logger.debug("exception occured in online file transfer: " + e.getMessage()); + //possibly give warning to user in request scope + } + catch(McApplicationException e) + { + logger.debug("exception occured in accessing the repository server: " + e.getMessage()); + //possibly give warning to user in request scope + } + } + + + if ((populateUploadedFilesData != null) && (populateUploadedFilesData.booleanValue())) + { + logger.debug("removing ofline + online file list attributes"); + request.getSession().removeAttribute(LIST_UPLOADED_OFFLINE_FILES_UUID); + request.getSession().removeAttribute(LIST_UPLOADED_OFFLINE_FILES_NAME); + request.getSession().removeAttribute(LIST_UPLOADED_ONLINE_FILES_UUID); + request.getSession().removeAttribute(LIST_UPLOADED_ONLINE_FILES_NAME); + } + } + + public static void configureContentRepository(HttpServletRequest request) { logger.debug("attempt configureContentRepository"); @@ -242,5 +497,51 @@ mcService.configureContentRepository(); logger.debug("configureContentRepository ran successfully"); } + + + public static void populateUploadedFilesMetaDataFromDb(HttpServletRequest request, McContent defaultMcContent) + { + logger.debug("attempt populateUploadedFilesData"); + IMcService mcService =McUtils.getToolService(request); + logger.debug("mcService: " + mcService); + + /** just for jsp purposes ** + /** read the uploaded offline uuid + file name pair */ + List listOfflineFilesUuid=new LinkedList(); + listOfflineFilesUuid=mcService.retrieveMcUploadedOfflineFilesUuid(defaultMcContent); + logger.debug("initial listOfflineFilesUuid: " + listOfflineFilesUuid); + request.getSession().removeAttribute(LIST_UPLOADED_OFFLINE_FILES_UUID); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES_UUID, listOfflineFilesUuid); + + /** read the uploaded online uuid + file name pair */ + List listOnlineFilesUuid=new LinkedList(); + listOnlineFilesUuid=mcService.retrieveMcUploadedOnlineFilesUuid(defaultMcContent); + logger.debug("initial listOnlineFilesUuid: " + listOnlineFilesUuid); + request.getSession().removeAttribute(LIST_UPLOADED_ONLINE_FILES_UUID); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES_UUID, listOnlineFilesUuid); + + + /** read the uploaded offline uuid + file name pair */ + List listOfflineFilesName=new LinkedList(); + listOfflineFilesName=mcService.retrieveMcUploadedOfflineFilesName(defaultMcContent); + logger.debug("initial listOfflineFilesName: " + listOfflineFilesName); + request.getSession().removeAttribute(LIST_UPLOADED_OFFLINE_FILES_NAME); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILES_NAME, listOfflineFilesName); + + + /** read the uploaded online uuid + file name pair */ + List listOnlineFilesName=new LinkedList(); + listOnlineFilesName=mcService.retrieveMcUploadedOnlineFilesName(defaultMcContent); + logger.debug("initial listOnlineFilesName: " + listOnlineFilesName); + request.getSession().removeAttribute(LIST_UPLOADED_ONLINE_FILES_NAME); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILES_NAME, listOnlineFilesName); + + + request.getSession().removeAttribute(LIST_UPLOADED_OFFLINE_FILENAMES); + request.getSession().removeAttribute(LIST_UPLOADED_ONLINE_FILENAMES); + request.getSession().setAttribute(LIST_UPLOADED_OFFLINE_FILENAMES, listOfflineFilesName); + request.getSession().setAttribute(LIST_UPLOADED_ONLINE_FILENAMES, listOnlineFilesName); + } + } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java,v diff -u -r1.11 -r1.12 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 22 Oct 2005 19:08:23 -0000 1.11 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 25 Oct 2005 17:19:10 -0000 1.12 @@ -174,6 +174,14 @@ public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws McApplicationException; public InputStream downloadFile(Long uuid, Long versionID)throws McApplicationException; + + public List retrieveMcUploadedOfflineFilesUuid(McContent mc); + + public List retrieveMcUploadedOnlineFilesUuid(McContent mc); + + public List retrieveMcUploadedOfflineFilesName(McContent mc); + + public List retrieveMcUploadedOnlineFilesName(McContent mc); } Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java,v diff -u -r1.12 -r1.13 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 22 Oct 2005 19:08:23 -0000 1.12 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 25 Oct 2005 17:19:10 -0000 1.13 @@ -1493,8 +1493,26 @@ logger.debug("files meta data has been cleaned up"); */ } - + + public List retrieveMcUploadedOfflineFilesUuid(McContent mc) throws McApplicationException { + return null; + + } + + public List retrieveMcUploadedOnlineFilesUuid(McContent mc) throws McApplicationException { + return null; + } + + public List retrieveMcUploadedOfflineFilesName(McContent mc) throws McApplicationException { + return null; + } + + public List retrieveMcUploadedOnlineFilesName(McContent mc) throws McApplicationException { + return null; + } + + /** * @return Returns the logger. */ Fisheye: Tag 1.2 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java'. Fisheye: No comparison available. Pass `N' to diff? 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.19 -r1.20 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 24 Oct 2005 10:25:48 -0000 1.19 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAction.java 25 Oct 2005 17:19:10 -0000 1.20 @@ -26,6 +26,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -43,7 +44,6 @@ import org.apache.struts.action.ActionMessages; import org.apache.struts.actions.DispatchAction; import org.lamsfoundation.lams.tool.mc.McAppConstants; -import org.lamsfoundation.lams.tool.mc.McApplicationException; import org.lamsfoundation.lams.tool.mc.McComparator; import org.lamsfoundation.lams.tool.mc.McContent; import org.lamsfoundation.lams.tool.mc.McOptsContent; @@ -241,7 +241,6 @@ logger.debug("updated SELECTED_QUESTION"); } - String userAction=null; if (mcAuthoringForm.getAddQuestion() != null) { @@ -362,15 +361,21 @@ McQueContent mcQueContent =mcService.getQuestionContentByQuestionText(editableQuestionEntry, mcContent.getUid()); logger.debug("mcQueContent:" + mcQueContent); + //FIX THIS!!!! + int weight=0; if (mcQueContent == null) { logger.debug("convenience add mcQueContent"); mcQueContent= new McQueContent(editableQuestionEntry, new Integer(questionIndex), + new Integer(weight), + true, mcContent, new HashSet(), new HashSet() ); + + mcService.createMcQue(mcQueContent); logger.debug("persisted convenience mcQueContent: " + mcQueContent); } @@ -701,7 +706,12 @@ return (mapping.findForward(LOAD_QUESTIONS)); } - + String richTextOfflineInstructions=(String) request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); + logger.debug("richTextOfflineInstructions: " + richTextOfflineInstructions); + + String richTextOnlineInstructions=(String) request.getSession().getAttribute(RICHTEXT_ONLINEINSTRUCTIONS); + logger.debug("richTextOnlineInstructions: " + richTextOnlineInstructions); + Map mapQuestionsContent=repopulateMap(request, "questionContent"); logger.debug("FINAL mapQuestionsContent after shrinking: " + mapQuestionsContent); logger.debug("mapQuestionsContent size after shrinking: " + mapQuestionsContent.size()); @@ -727,8 +737,9 @@ mcContent.setReportTitle(reportTitle); mcContent.setMonitoringReportTitle(monitoringReportTitle); mcContent.setEndLearningMessage(endLearningMessage); + mcContent.setOfflineInstructions(richTextOfflineInstructions); + mcContent.setOnlineInstructions(richTextOnlineInstructions); - mcService.resetAllQuestions(mcContent.getUid()); logger.debug("all question reset for :" + mcContent.getUid()); @@ -770,8 +781,32 @@ mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } + else if (mcAuthoringForm.getInstructionsTabDone() != null) + { + userAction="instructionsTabDone"; + request.setAttribute(USER_ACTION, userAction); + logger.debug("userAction:" + userAction); + mcAuthoringForm.resetUserAction(); + return (mapping.findForward(LOAD_QUESTIONS)); + } + else if (mcAuthoringForm.getSubmitOfflineFile() != null) + { + userAction="submitOfflineFile"; + request.setAttribute(USER_ACTION, userAction); + logger.debug("userAction:" + userAction); + + //McUtils.addFileToContentRepository(request, mcAuthoringForm, true); + //logger.debug("offline file added to repository successfully."); + + + mcAuthoringForm.resetUserAction(); + return (mapping.findForward(LOAD_QUESTIONS)); + } + + + mcAuthoringForm.resetUserAction(); return (mapping.findForward(LOAD_QUESTIONS)); } @@ -877,14 +912,7 @@ if ((reportTitle == null) || (reportTitle.length() == 0)) reportTitle=(String)request.getSession().getAttribute(REPORT_TITLE); - logger.debug("OFFLINE_INSTRUCTIONS: " + mcAuthoringForm.getOfflineInstructions()); - if (mcAuthoringForm.getOfflineInstructions() == null) - offlineInstructions=(String)request.getSession().getAttribute(OFFLINE_INSTRUCTIONS); - - logger.debug("ONLINE_INSTRUCTIONS: " + mcAuthoringForm.getOnlineInstructions()); - if (mcAuthoringForm.getOnlineInstructions() == null) - onlineInstructions=(String)request.getSession().getAttribute(ONLINE_INSTRUCTIONS); - + endLearningMessage=mcAuthoringForm.getEndLearningMessage(); logger.debug("END_LEARNING_MESSAGE: " + mcAuthoringForm.getEndLearningMessage()); if ((endLearningMessage == null) || (endLearningMessage.length() == 0)) @@ -899,7 +927,17 @@ richTextInstructions = (String)request.getSession().getAttribute(RICHTEXT_INSTRUCTIONS); logger.debug("createContent richTextInstructions from session: " + richTextInstructions); if (richTextInstructions == null) richTextInstructions=""; + + String richTextOfflineInstructions=""; + richTextOfflineInstructions = (String)request.getSession().getAttribute(RICHTEXT_OFFLINEINSTRUCTIONS); + logger.debug("createContent richTextOfflineInstructions from session: " + richTextOfflineInstructions); + if (richTextOfflineInstructions == null) richTextOfflineInstructions=""; + String richTextOnlineInstructions=""; + richTextOnlineInstructions = (String)request.getSession().getAttribute(RICHTEXT_ONLINEINSTRUCTIONS); + logger.debug("createContent richTextOnlineInstructions from session: " + richTextOnlineInstructions); + if (richTextOnlineInstructions == null) richTextOnlineInstructions=""; + creationDate=(String)request.getSession().getAttribute(CREATION_DATE); if (creationDate == null) creationDate=new Date(System.currentTimeMillis()).toString(); @@ -926,8 +964,8 @@ mc.setCreatedBy(userId); /**make sure we are setting the userId from the User object above*/ mc.setUsernameVisible(isUsernameVisible); mc.setQuestionsSequenced(isQuestionsSequenced); /**the default question listing in learner mode will be all in the same page*/ - mc.setOnlineInstructions(onlineInstructions); - mc.setOfflineInstructions(offlineInstructions); + mc.setOnlineInstructions(richTextOnlineInstructions); + mc.setOfflineInstructions(richTextOfflineInstructions); mc.setRunOffline(false); mc.setDefineLater(false); mc.setSynchInMonitor(isSynchInMonitor); @@ -993,16 +1031,23 @@ McQueContent mcQueContent=mcService.getQuestionContentByQuestionText(pairs.getValue().toString(), mcContent.getUid()); logger.debug("mcQueContent: " + mcQueContent); + //FIX THIS!!!!! + int weight=0; + if (mcQueContent == null) { mcQueContent= new McQueContent(pairs.getValue().toString(), - new Integer(pairs.getKey().toString()), - mcContent, - new HashSet(), - new HashSet() - ); + new Integer(pairs.getKey().toString()), + new Integer(weight), + true, + mcContent, + new HashSet(), + new HashSet() + ); mcService.createMcQue(mcQueContent); logger.debug("persisted mcQueContent: " + mcQueContent); + + } else { 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.12 -r1.13 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 24 Oct 2005 10:25:48 -0000 1.12 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McAuthoringForm.java 25 Oct 2005 17:19:10 -0000 1.13 @@ -40,6 +40,7 @@ protected String editDefaultQuestion; protected String removeOptionContent; protected String advancedTabDone; + protected String instructionsTabDone; protected String addContent; protected String removeContent; @@ -106,6 +107,7 @@ this.doneOptions=null; this.submitQuestions=null; this.advancedTabDone=null; + this.instructionsTabDone=null; this.addContent=null; this.removeContent=null; @@ -135,6 +137,7 @@ this.doneOptions=null; this.submitQuestions=null; this.advancedTabDone=null; + this.instructionsTabDone=null; this.addContent=null; this.removeContent=null; @@ -784,4 +787,16 @@ public void setAdvancedTabDone(String advancedTabDone) { this.advancedTabDone = advancedTabDone; } + /** + * @return Returns the instructionsTabDone. + */ + public String getInstructionsTabDone() { + return instructionsTabDone; + } + /** + * @param instructionsTabDone The instructionsTabDone to set. + */ + public void setInstructionsTabDone(String instructionsTabDone) { + this.instructionsTabDone = instructionsTabDone; + } } 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.10 -r1.11 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 24 Oct 2005 10:25:48 -0000 1.10 +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McStarterAction.java 25 Oct 2005 17:19:10 -0000 1.11 @@ -92,7 +92,6 @@ import org.lamsfoundation.lams.tool.mc.McContent; import org.lamsfoundation.lams.tool.mc.McOptsContent; import org.lamsfoundation.lams.tool.mc.McQueContent; -//import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.tool.mc.McUtils; import org.lamsfoundation.lams.tool.mc.service.IMcService; import org.lamsfoundation.lams.tool.mc.service.McServiceProxy; @@ -136,7 +135,7 @@ long contentId=0; try { - logger.debug("attempt retrieving tool with signatute : " + MY_SIGNATURE); + logger.debug("attempt retrieving tool with signature : " + MY_SIGNATURE); contentId=mcService.getToolDefaultContentIdBySignature(MY_SIGNATURE); logger.debug("retrieved tool default contentId: " + contentId); if (contentId == 0) @@ -290,6 +289,11 @@ McContent mcContent=mcService.retrieveMc(new Long(contentId)); logger.debug("mcContent:" + mcContent); + /** reset all radioboxes to false*/ + mcAuthoringForm.resetRadioBoxes(); + logger.debug("all radioboxes arec reset"); + + if (mcContent == null) { logger.debug("Exception occured: No default content"); @@ -319,10 +323,6 @@ McUtils.setDefaultSessionAttributes(request, mcContent, mcAuthoringForm); - /** reset all radioboxes to false*/ - mcAuthoringForm.resetRadioBoxes(); - logger.debug("all radioboxes arec reset"); - logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE)); logger.debug("getting default content"); /** @@ -380,6 +380,94 @@ else { logger.debug("getting existing content with id:" + toolContentId); + McContent mcContent=mcService.retrieveMc(new Long(toolContentId)); + logger.debug("existing mcContent:" + mcContent); + + request.getSession().setAttribute(RICHTEXT_TITLE,mcContent.getTitle()); + request.getSession().setAttribute(RICHTEXT_INSTRUCTIONS,mcContent.getInstructions()); + request.getSession().setAttribute(QUESTIONS_SEQUENCED,new Boolean(mcContent.isQuestionsSequenced())); + request.getSession().setAttribute(USERNAME_VISIBLE,new Boolean(mcContent.isUsernameVisible())); + request.getSession().setAttribute(CREATED_BY, new Long(mcContent.getCreatedBy())); + request.getSession().setAttribute(MONITORING_REPORT_TITLE,mcContent.getMonitoringReportTitle()); + request.getSession().setAttribute(REPORT_TITLE,mcContent.getReportTitle()); + request.getSession().setAttribute(RUN_OFFLINE, new Boolean(mcContent.isRunOffline())); + request.getSession().setAttribute(DEFINE_LATER, new Boolean(mcContent.isDefineLater())); + request.getSession().setAttribute(SYNCH_IN_MONITOR, new Boolean(mcContent.isSynchInMonitor())); + request.getSession().setAttribute(OFFLINE_INSTRUCTIONS,mcContent.getOfflineInstructions()); + request.getSession().setAttribute(ONLINE_INSTRUCTIONS,mcContent.getOnlineInstructions()); + request.getSession().setAttribute(END_LEARNING_MESSAGE,mcContent.getEndLearningMessage()); + request.getSession().setAttribute(CONTENT_IN_USE, new Boolean(mcContent.isContentInUse())); + request.getSession().setAttribute(RETRIES, new Boolean(mcContent.isRetries())); + request.getSession().setAttribute(PASSMARK, mcContent.getPassMark()); //Integer + request.getSession().setAttribute(SHOW_FEEDBACK, new Boolean(mcContent.isShowFeedback())); + + + McUtils.setDefaultSessionAttributes(request, mcContent, mcAuthoringForm); + logger.debug("RICHTEXT_TITLE:" + request.getSession().getAttribute(RICHTEXT_TITLE)); + + if (mcContent.isUsernameVisible()) + { + mcAuthoringForm.setUsernameVisible(ON); + logger.debug("setting userNameVisible to true"); + } + else + { + mcAuthoringForm.setUsernameVisible(OFF); + logger.debug("setting userNameVisible to false"); + } + + + if (mcContent.isQuestionsSequenced()) + { + mcAuthoringForm.setQuestionsSequenced(ON); + logger.debug("setting questionsSequenced to true"); + } + else + { + mcAuthoringForm.setQuestionsSequenced(OFF); + logger.debug("setting questionsSequenced to false"); + } + + + if (mcContent.isSynchInMonitor()) + { + mcAuthoringForm.setSynchInMonitor(ON); + logger.debug("setting SynchInMonitor to true"); + } + else + { + mcAuthoringForm.setSynchInMonitor(OFF); + logger.debug("setting SynchInMonitor to false"); + } + + if (mcContent.isRetries()) + { + mcAuthoringForm.setRetries(ON); + logger.debug("setting retries to true"); + } + else + { + mcAuthoringForm.setRetries(OFF); + logger.debug("setting retries to false"); + } + + if (mcContent.isShowFeedback()) + { + mcAuthoringForm.setShowFeedback(ON); + logger.debug("setting showFeedback to false"); + } + else + { + mcAuthoringForm.setShowFeedback(OFF); + logger.debug("setting showFeedback to false"); + } + + AuthoringUtil authoringUtil = new AuthoringUtil(); + mapQuestionsContent=authoringUtil.rebuildQuestionMapfromDB(request, new Long(toolContentId)); + System.out.print("mapQuestionsContent:" + mapQuestionsContent); + + request.getSession().setAttribute(MAP_QUESTIONS_CONTENT, mapQuestionsContent); + logger.debug("starter initialized the existing Questions Map: " + request.getSession().getAttribute(MAP_QUESTIONS_CONTENT)); } Index: lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/Attic/McQueContent.hbm.xml,v diff -u -r1.9 -r1.10 --- lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml 20 Oct 2005 09:35:18 -0000 1.9 +++ lams_tool_lamc/test/java/org/lamsfoundation/lams/tool/mc/McQueContent.hbm.xml 25 Oct 2005 17:19:10 -0000 1.10 @@ -40,6 +40,14 @@ + + + - + @@ -165,7 +165,7 @@ - + @@ -334,18 +334,86 @@

Instructions

+
+ + + + -
+ : + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ + + +
  • +
    +
    + + + + + +
    + + + + + + +
    + + + +
  • +
    +
    +    +
    - +
    - -