Index: lams_tool_sbmt/conf/xdoclet/struts-forms.xml =================================================================== diff -u -r917358423e83fc323518885887537421fd0afafb -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision 917358423e83fc323518885887537421fd0afafb) +++ lams_tool_sbmt/conf/xdoclet/struts-forms.xml (.../struts-forms.xml) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -22,6 +22,9 @@ + + Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/Learner.java =================================================================== diff -u -r87916b2e9c4406342e26149d731a5ab070f4d4e0 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/Learner.java (.../Learner.java) (revision 87916b2e9c4406342e26149d731a5ab070f4d4e0) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/Learner.java (.../Learner.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -100,7 +100,7 @@ try { obj = super.clone(); } catch (CloneNotSupportedException e) { - log.error("When clone " + SubmitFilesReport.class + " failed"); + log.error("When clone " + Learner.class + " failed"); } return obj; } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java =================================================================== diff -u -r12363516e3d2a82823dca22cf7cafa91a4c8f9a6 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision 12363516e3d2a82823dca22cf7cafa91a4c8f9a6) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/ISubmitFilesService.java (.../ISubmitFilesService.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -56,7 +56,9 @@ /** * Returns the SubmitFilesContent object corresponding to the - * given contentID + * given contentID. If could not find out corresponding + * SubmitFilesContent by given contentID, return a not-null + * but emtpy SubmitFilesContent instance. * * @param contentID * The content_id of the object to be looked up Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java =================================================================== diff -u -r0bab69ca213843b109a46bf4834d736cb956cf6f -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision 0bab69ca213843b109a46bf4834d736cb956cf6f) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesService.java (.../SubmitFilesService.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -233,8 +233,8 @@ + " based on null toolContentId"); try { - SubmitFilesContent content = submitFilesContentDAO.getContentByID(toolContentId); - if ( content == null ) { + SubmitFilesContent content = getSubmitFilesContent(toolContentId); + if ( content == null || !toolContentId.equals(content.getContentID())) { content = duplicateDefaultToolContent(toolContentId); } content.setRunOffline(true); @@ -248,6 +248,9 @@ } /** + * If the toolContentID does not exist, then get default tool content id from tool core and + * initialize a emtpy SubmitFilesContent return. + * * @param toolContentId * @return */ @@ -269,8 +272,8 @@ + " based on null toolContentId"); try { - SubmitFilesContent content = submitFilesContentDAO.getContentByID(toolContentId); - if ( content == null ) { + SubmitFilesContent content = getSubmitFilesContent(toolContentId); + if ( content == null || !toolContentId.equals(content.getContentID())) { content = duplicateDefaultToolContent(toolContentId); } content.setDefineLater(true); @@ -427,8 +430,11 @@ + toolContentId.longValue() + "]"); try { - SubmitFilesContent submitContent = submitFilesContentDAO.getContentByID(toolContentId); - + SubmitFilesContent submitContent = getSubmitFilesContent(toolContentId); + if ( submitContent == null || !toolContentId.equals(submitContent.getContentID())) { + submitContent = new SubmitFilesContent(); + submitContent.setContentID(toolContentId); + } SubmitFilesSession submitSession = new SubmitFilesSession (); submitSession.setSessionID(toolSessionId); @@ -527,17 +533,21 @@ if(uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) throw new SubmitFilesException("Could not find upload file: " + uploadFile); - SubmitFilesContent content = submitFilesContentDAO.getContentByID(contentID); - if (content == null) - throw new SubmitFilesException( - "No such content with a contentID of: " + contentID - + " found."); - + SubmitFilesContent content = getSubmitFilesContent(contentID); + if ( content == null || !contentID.equals(content.getContentID())) { + content = new SubmitFilesContent(); + content.setContentID(contentID); + //user firstly upload file without any other input, even the not-null + //field "title". Set title as default title. + content.setTitle(SbmtConstants.DEFAULT_TITLE); + } NodeKey nodeKey = processFile(uploadFile,fileType); Set fileSet = content.getInstructionFiles(); - if(fileSet == null) + if(fileSet == null){ fileSet = new HashSet(); + content.setInstructionFiles(fileSet); + } InstructionFiles file = new InstructionFiles(); file.setType(fileType); file.setUuID(nodeKey.getUuid()); Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesServiceProxy.java =================================================================== diff -u -r12363516e3d2a82823dca22cf7cafa91a4c8f9a6 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesServiceProxy.java (.../SubmitFilesServiceProxy.java) (revision 12363516e3d2a82823dca22cf7cafa91a4c8f9a6) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/service/SubmitFilesServiceProxy.java (.../SubmitFilesServiceProxy.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -1,9 +1,26 @@ -/* - * Created on May 24, 2005 - * - * TODO To change the template for this generated file go to - * Window - Preferences - Java - Code Style - Code Templates +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** */ + package org.lamsfoundation.lams.tool.sbmt.service; import javax.servlet.ServletContext; Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SbmtConstants.java =================================================================== diff -u -r0bab69ca213843b109a46bf4834d736cb956cf6f -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SbmtConstants.java (.../SbmtConstants.java) (revision 0bab69ca213843b109a46bf4834d736cb956cf6f) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/util/SbmtConstants.java (.../SbmtConstants.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -24,5 +24,6 @@ public static final String AUTHORING_DTO = "authoring"; public static final String TOOLSIGNNATURE = "lasbmt11"; + public static final String DEFAULT_TITLE = "Submit Files Title"; } Index: lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/AuthoringAction.java =================================================================== diff -u -rdf6ad7b34421631085b2ad7a68fa779c550e6a24 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/AuthoringAction.java (.../AuthoringAction.java) (revision df6ad7b34421631085b2ad7a68fa779c550e6a24) +++ lams_tool_sbmt/src/java/org/lamsfoundation/lams/tool/sbmt/web/AuthoringAction.java (.../AuthoringAction.java) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -1,6 +1,24 @@ -/* - * Created on May 19, 2005 - * +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** */ package org.lamsfoundation.lams.tool.sbmt.web; @@ -50,7 +68,7 @@ public ISubmitFilesService submitFilesService; /** - * Update content + * Update all content for submit tool except online/offline instruction files list. * * @param mapping * @param form @@ -83,7 +101,9 @@ return mapping.findForward("success"); } /** - * Handle upload online instruction files request. + * Handle upload online instruction files request. Once the file uploaded successfully, database + * will update accordingly. + * * @param mapping * @param form * @param request @@ -95,7 +115,8 @@ return uploadFile(mapping, form, IToolContentHandler.TYPE_ONLINE,request); } /** - * Handle upload offline instruction files request. + * Handle upload offline instruction files request. Once the file uploaded successfully, database + * will update accordingly. * @param mapping * @param form * @param request @@ -144,18 +165,11 @@ return mapping.getInputForward(); } - protected Map getKeyMethodMap() { - Map map = new HashMap(); - map.put("label.authoring.upload.online.button", "uploadOnline"); - map.put("label.authoring.upload.offline.button", "uploadOffline"); - map.put("label.authoring.save.button", "updateContent"); - - return map; - } - /* - * (non-Javadoc) - * + /** + * This page will display initial submit tool content. Or just a blank page if the toolContentID does not + * exist before. + * * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, * org.apache.struts.action.ActionForm, * javax.servlet.http.HttpServletRequest, @@ -171,10 +185,12 @@ .getServlet().getServletContext()); SubmitFilesContent persistContent = submitFilesService.getSubmitFilesContent(contentID); - //if this content does not exist, then reset the contentID to current value to keep it on HTML page. - if(persistContent == null) + //if this content does not exist(empty without id), or find out wrong content(id not match), + //then reset the contentID to current value in order to keep it on HTML page. + if(!contentID.equals(persistContent.getContentID())){ persistContent = new SubmitFilesContent(); - persistContent.setContentID(contentID); + persistContent.setContentID(contentID); + } setUp(request,persistContent); //set back STRUTS component value @@ -184,9 +200,20 @@ authForm.set("lockOnFinished",persistContent.isLockOnFinished()?"1":null); return mapping.getInputForward(); } + /** + * Just for STRUTS LookupDispatchAction mapping function. + */ + protected Map getKeyMethodMap() { + Map map = new HashMap(); + map.put("label.authoring.upload.online.button", "uploadOnline"); + map.put("label.authoring.upload.offline.button", "uploadOffline"); + map.put("label.authoring.save.button", "updateContent"); + + return map; + } /** - * Get content from ActionForm parameters. + * The private method to get content from ActionForm parameters (web page). * * @param form * @return @@ -222,6 +249,8 @@ * @param content */ private void setUp(HttpServletRequest request, SubmitFilesContent content) { + String currTab = request.getParameter("currentTab"); + request.setAttribute("currentTab",currTab); AuthoringDTO authorDto = new AuthoringDTO(content); request.setAttribute(SbmtConstants.AUTHORING_DTO,authorDto); } Index: lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml =================================================================== diff -u -r12363516e3d2a82823dca22cf7cafa91a4c8f9a6 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 12363516e3d2a82823dca22cf7cafa91a4c8f9a6) +++ lams_tool_sbmt/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -30,6 +30,9 @@ type="org.apache.struts.upload.FormFile"/> + + Index: lams_tool_sbmt/web/authoring/authoring.jsp =================================================================== diff -u -rdf6ad7b34421631085b2ad7a68fa779c550e6a24 -rc5a014333e76581f2872fd7c2731e493fcf2caee --- lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision df6ad7b34421631085b2ad7a68fa779c550e6a24) +++ lams_tool_sbmt/web/authoring/authoring.jsp (.../authoring.jsp) (revision c5a014333e76581f2872fd7c2731e493fcf2caee) @@ -10,20 +10,23 @@ + - - + + - - + - @@ -32,9 +35,9 @@
- - - + + +
BasicBasic
@@ -43,9 +46,9 @@ - - - + + +
AdvancedAdvanced
@@ -54,9 +57,9 @@ - - - + + +
InstructionsInstructions
@@ -203,10 +206,8 @@ - - - +
@@ -226,16 +227,14 @@ - -
+
- - +
@@ -247,6 +246,7 @@
+