Index: lams_central/web/toolcontent/IMS_LD_Level_A.xsd
===================================================================
diff -u
--- lams_central/web/toolcontent/IMS_LD_Level_A.xsd (revision 0)
+++ lams_central/web/toolcontent/IMS_LD_Level_A.xsd (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -0,0 +1,697 @@
+
+
+
+
+
+ Last update 17 December 2002
+
+ 24 October 2002
+ Restructured the schemas that were submitted as public draft.
+ Created attribute groups for those attributes that are used in multiple element definitions.
+ Created re-usable attribute groups.
+ Defined groups for those content models that need to be extended in levels B and C.
+ Designed modules for those elements and attributes that are re-used in levels B and C or in the global elements.
+ Changed the namespace.
+
+
+
+
+
+
+
+ This module contains elements and attributes that are used in the other levels and in the global elements.
+
+
+
+
+ This module contains the email-data model.
+
+
+
+
+
+
+ The attributes are declared here as reusable attribute groups, because most are re-used in several elements.
+ Additional attributes are declared in the modules.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Implementations should provide a default value (a, b or c) for each of the schema levels.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This attribute is also used in level B.
+
+
+
+
+
+
+
+
+
+ This attribute is also used in level B.
+
+
+
+
+
+
+ This attribute is also used in level B.
+
+
+
+
+
+
+
+ Also used in global elements
+
+
+
+
+
+
+
+
+ This content model is used in several elements that refer to resources.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This group is used to indicate the metadata schema. The schema to be used and its version must be indicated and the schema must be imported.
+
+
+
+
+
+
+
+
+
+
+
+ These groups are needed for extension in level B.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Include IMS Metadata here, using the correct namespace
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A named complex type is needed because this element is redefined in level B. Format is duration datatype (PnYnMnDTnHnMnS)
+ Format is duration datatype: PnYnMnDTnHnMnS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Simple Sequencing can be included here, using its namespace. The namespace must be defined in the instance, and the schema must be imported.
+
+
+
+
+
+
+
+
+
+
+
+
+ Used to provide the relevant schema.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Used for those elements that refer to resources.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This placeholder can be used to import elements from another namespace. The namespace for the imported element must be defined in the instance, and the schema must be imported.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This placeholder can be used to import elements from another namespace. The namespace for the imported element must be defined in the instance, and the schema must be imported.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This simple type is defined as simple content because it needs to be extended with an attribute in level B.
+
+ Format is duration datatype: PnYnMnDTnHnMnS
+
+
+
+
+
+
+
Index: lams_central/web/toolcontent/IMS_LD_Level_B.xsd
===================================================================
diff -u
--- lams_central/web/toolcontent/IMS_LD_Level_B.xsd (revision 0)
+++ lams_central/web/toolcontent/IMS_LD_Level_B.xsd (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -0,0 +1,404 @@
+
+
+
+
+
+ 24 October 2002
+ Restructured the schemas that were submitted as public draft.
+ Defined groups for those content models that need to be extended in level C.
+ Nearly all attributes for the level B elements are declared inline, because they are not re-used in other elements.
+ Changed the namespace.
+
+
+
+
+
+
+
+
+ Include the email-data element.
+
+
+
+
+ Include the expression schema.
+
+
+
+
+
+
+
+
+
+ Add properties into the content model of components, after roles.
+
+
+
+
+
+
+
+
+
+ Add when-condition-ture and when-property-value-is-set into the choice group of complete-act.
+
+
+
+
+
+
+
+
+
+
+ Add when-property-value-is-set into the choice group of complete-activity.
+
+
+
+
+
+
+
+
+
+ Add when-property-value-is-set into the choice group of complete-play.
+
+
+
+
+
+
+
+
+
+ Add when-property-value-is-set into the choice group of complete-unit-of-learning.
+
+
+
+
+
+
+
+
+
+ Add change-property-value to on-completion.
+
+
+
+
+
+
+
+
+
+ Add conditions to method.
+
+
+
+
+
+
+
+
+
+ Add monitor into the choice group of service.
+
+
+
+
+
+
+
+
+
+ Add the attribute property-ref to "simple type" time-limit.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The element property-value should contain either text, or langstring, or calculate, or property-ref.
+
+
+
+
+
+
+
+
Index: lams_central/web/toolcontent/IMS_LD_Level_C.xsd
===================================================================
diff -u
--- lams_central/web/toolcontent/IMS_LD_Level_C.xsd (revision 0)
+++ lams_central/web/toolcontent/IMS_LD_Level_C.xsd (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -0,0 +1,42 @@
+
+
+
+
+
+ 4 November 2002
+ Restructured the schemas that were submitted as public draft.
+ Redefined on-completion and then.
+ Changed the namespace.
+
+
+
+
+
+
+
+
+ Include the notification element.
+
+
+
+
+
+
+
+
+ The notification element need to be added to on-completion and into the then choice group.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: lams_central/web/toolcontent/imscp_v1p1.xsd
===================================================================
diff -u
--- lams_central/web/toolcontent/imscp_v1p1.xsd (revision 0)
+++ lams_central/web/toolcontent/imscp_v1p1.xsd (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -0,0 +1,381 @@
+
+
+
+
+
+ DRAFT XSD for IMS Content Packaging version 1.1 DRAFT
+ Copyright (c) 2001 IMS GLC, Inc.
+ 2000-04-21, Adjustments by T.D. Wason from CP 1.0.
+ 2001-02-22, T.D.Wason: Modify for 2000-10-24 XML-Schema version.
+ Modified to support extension.
+ 2001-03-12, T.D.Wason: Change filename, target and meta-data namespaces
+ and meta-data filename.
+ Add meta-data to itemType, fileType and organizationType.
+ Do not define namespaces for xml in XML instances generated from this xsd.
+ Imports IMS meta-data xsd, lower case element names.
+ This XSD provides a reference to the IMS meta-data root element as imsmd:record
+ If the IMS meta-data is to be used in the XML instance then the instance
+ must definean IMS meta-data prefix with a namespace.
+ The meta-data targetNamespace should be used.
+ 2001-03-20, Thor Anderson: Remove manifestref, change resourceref back to
+ identifierref, change manifest back to contained by manifest.
+ --Tom Wason: manifest may contain _none_ or more manifests.
+ 2001-04-13 Tom Wason: corrected attirbute name structure. Was misnamed type.
+ 2001-05-14 Schawn Thropp: Made all complexType extensible with the group.any
+ Added the anyAttribute to all complexTypes.
+ Changed the href attribute on the fileType and resourceType to xsd:string
+ Changed the maxLength of the href, identifierref, parameters, structure
+ attributes to match the Information model.
+ 2001-07-25 Schawn Thropp: Changed the namespace for the Schema of Schemas to
+ the 5/2/2001 W3C XML Schema Recommendation.
+ attributeGroup attr.imsmd deleted, was not used anywhere.
+ Any attribute declarations that have use = "default"
+ changed to use="optional" - attr.structure.req.
+ Any attribute declarations that have value="somevalue" changed to
+ default="somevalue" - attr.structure.req (hierarchical).
+ Removed references to IMS MD Version 1.1.
+ Modified attribute group "attr.resourcetype.req" to change use from optional
+ to required to match the information model. As a result the default value
+ also needed to be removed
+ Name change for XSD. Changed to match version of CP Spec
+ 2001-11-04 Chris Moffatt:
+ 1. Refer to the xml namespace using the "x" abbreviation instead of "xml".
+ This changes enables the schema to work with commercial XML Tools
+ 2. Revert to original IMS CP version 1.1 namespace.
+ i.e. "http://www.imsglobal.org/xsd/imscp_v1p1"
+ This change done to support the decision to only change the XML namespace with
+ major revisions of the specification i.e. where the information model or binding
+ changes (as opposed to addressing bugs or omissions). A stable namespace is
+ necessary to the increasing number of implementors.
+ 3. Changed name of schema file to "imscp_v1p1p3.xsd" and
+ version attribute to "IMS CP 1.1.3" to reflect minor version change
+ Inclusions and Imports
+ Attribute Declarations
+ element groups
+
+
+ 2003-03-21 Schawn Thropp
+ The following updates were made to the Version 1.1.3 "Public Draft" version:
+ 1. Updated name of schema file (imscp_v1p1.xsd) to match to IMS naming guideance
+ 2. Updated the import statement to reference the xml.xsd found at
+ "http://www.w3.org/2001/03/xml.xsd". This is the current W3C schema
+ recommended by the W3C to reference.
+ 3. Removed all maxLength's facets. The maxLength facets was an incorrect binding
+ implementation. These lengths were supposed, according to the information
+ model, to be treated as smallest permitted maximums.
+ 4. Added the variations content model to support the addition in the information
+ model.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Any namespaced element from any namespace may be included within an "any" element. The namespace for the imported element must be defined in the instance, and the schema must be imported.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_central/web/toolcontent/learning-design-ims.xslt
===================================================================
diff -u -r3a955b4e8d331618d2f92341e28c4452040e2003 -r534d8b05f0646a33c5eb6e11be9a32d97b3014dd
--- lams_central/web/toolcontent/learning-design-ims.xslt (.../learning-design-ims.xslt) (revision 3a955b4e8d331618d2f92341e28c4452040e2003)
+++ lams_central/web/toolcontent/learning-design-ims.xslt (.../learning-design-ims.xslt) (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -19,7 +19,7 @@
http://www.gnu.org/licenses/gpl.txt
-->
-
+
@@ -31,7 +31,7 @@
1.2
-
+
@@ -40,7 +40,7 @@
-
+
@@ -107,7 +107,7 @@
-
+
@@ -119,15 +119,15 @@
-
+
-
+
-
+
@@ -147,7 +147,7 @@
-
+
@@ -165,7 +165,7 @@
-
+
URN:LAMS:-
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java
===================================================================
diff -u -r309415c53c81c7251e537a6832b6ead2d6a2a84a -r534d8b05f0646a33c5eb6e11be9a32d97b3014dd
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 309415c53c81c7251e537a6832b6ead2d6a2a84a)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 534d8b05f0646a33c5eb6e11be9a32d97b3014dd)
@@ -33,8 +33,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
-import java.io.PipedInputStream;
-import java.io.PipedOutputStream;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
@@ -44,7 +42,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.net.URL;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collection;
@@ -154,7 +151,7 @@
public static final String EXPORT_TOOLCONTNET_ZIP_SUFFIX = ".zip";
public static final String EXPORT_LDCONTENT_ZIP_SUFFIX = ".zip";
public static final String LEARNING_DESIGN_FILE_NAME = "learning_design.xml";
- private static final String LEARNING_DESIGN_IMS_FILE_NAME = "learning_design_ims.xml";
+ private static final String LEARNING_DESIGN_IMS_FILE_NAME = "imsmanifest.xml";
public static final String TOOL_FILE_NAME = "tool.xml";
public static final String TOOL_FAILED_FILE_NAME = "export_failed.xml";
@@ -188,6 +185,18 @@
private static final String IMS_TOOL_NS_PREFIX = "http://www.lamsfoundation/xsd/lams_tool_";
private static final String IMS_TAG_LEARING_ACTIIVTY_REF = "learning-activity-ref";
+
+ private static final String IMS_TOOL_MAIN_OBJECT = "mainObject";
+
+ //2 dirs for zip file and temporary IMS XSLT
+ private static final String DIR_CONTENT = "content";
+ private static final String DIR_XSLT_TEMP = "xslttmp";
+
+ //files name of IMS SCHEMA
+ private static final String SCHEMA_FILE_IMSCP = "imscp_v1p1.xsd";
+ private static final String SCHEMA_FILE_IMS_LD_LEVEL_A = "IMS_LD_Level_A.xsd";
+ private static final String SCHEMA_FILE_IMS_LD_LEVEL_B = "IMS_LD_Level_B.xsd";
+ private static final String SCHEMA_FILE_IMS_LD_LEVEL_C = "IMS_LD_Level_C.xsd";
//Other fields
private Logger log = Logger.getLogger(ExportToolContentService.class);
@@ -369,18 +378,31 @@
//root temp directory, put target zip file
String targetZipFileName = null;
String rootDir = FileUtil.createTempDirectory(EXPORT_TOOLCONTNET_FOLDER_SUFFIX);
- String contentDir = FileUtil.getFullPath(rootDir, "content");
+ String contentDir = FileUtil.getFullPath(rootDir,DIR_CONTENT);
FileUtil.createDirectory(contentDir);
+ //this folder put all IMS XSLT transform temporary files, so try to keep content is clean for final package!
+ //The reason use temporary folder instead of delete temporary files from content folder is, sometimes, delete file does not work well
+ //this makes the final zip file should contain some rubbish files.
+ String xsltTempDir = FileUtil.getFullPath(rootDir, DIR_XSLT_TEMP);
+ if(format == PACKAGE_FORMAT_IMS){
+ FileUtil.createDirectory(xsltTempDir);
+ }
//learing design file name with full path
- String ldFileName = FileUtil.getFullPath(contentDir,LEARNING_DESIGN_FILE_NAME);
+ String ldFileName;
+ if(format == PACKAGE_FORMAT_IMS)
+ ldFileName = FileUtil.getFullPath(xsltTempDir,LEARNING_DESIGN_FILE_NAME);
+ else
+ ldFileName = FileUtil.getFullPath(contentDir,LEARNING_DESIGN_FILE_NAME);
Writer ldFile = new OutputStreamWriter(new FileOutputStream(ldFileName),"UTF-8");
//get learning desing and serialize it to XML file.
ILearningDesignService service = getLearningDesignService();
LearningDesignDTO ldDto = service.getLearningDesignDTO(learningDesignId);
XStream designXml = new XStream();
designXml.toXML(ldDto,ldFile);
+ ldFile.close();
+
log.debug("Learning design xml export success");
//iterator all activities in this learning design and export their content to given folder.
@@ -417,14 +439,14 @@
//create resource node list for this activity
if(format == PACKAGE_FORMAT_IMS){
- handleIMS(contentDir, activity,resChildren);
+ handleIMS(rootDir, activity,resChildren);
}
} //end all acitivites export
try {
//handle IMS format
if(format == PACKAGE_FORMAT_IMS){
- transformIMS(resChildren,contentDir,ldDto,xslt);
+ transformIMS(resChildren,rootDir,ldDto,xslt);
}
//create zip file for fckeditor unique content folder
@@ -463,24 +485,42 @@
}
/**
* Generate temporary files: resources.xml and transitions.xml.
- * Transform LAMS format learning_design.xml with resources.xml and transitions.xml into ims_learning_design.xml file, and cleaning temporary files.
+ * Transform LAMS format learning_design.xml with resources.xml and transitions.xml into ims_learning_design.xml file.
* @param resChildren
- * @param contentDir
+ * @param rootDir
* @param ldDto
* @throws Exception
*/
- private void transformIMS(List resChildren, String contentDir,LearningDesignDTO ldDto,File xsltIn) throws Exception {
- String ldFileName = FileUtil.getFullPath(contentDir,LEARNING_DESIGN_FILE_NAME);
+ private void transformIMS(List resChildren, String rootDir,LearningDesignDTO ldDto,File xsltIn) throws Exception {
+ String contentDir = FileUtil.getFullPath(rootDir, DIR_CONTENT);
+ String xsltDir = FileUtil.getFullPath(rootDir, DIR_XSLT_TEMP);
+
+ String ldFileName = FileUtil.getFullPath(xsltDir,LEARNING_DESIGN_FILE_NAME);
//copy XSLT file to contentDir, so that the XSLT document() function does not need absolute path file.
- File xslt = new File(FileUtil.getFullPath(contentDir, "ims.xslt"));
+ File xslt = new File(FileUtil.getFullPath(xsltDir, "ims.xslt"));
FileUtil.copyFile(xsltIn, xslt);
+ //copy schema files to content folder
+ String path = FileUtil.getFileDirectory(xslt.getCanonicalPath());
+ File imscpSrc = new File(FileUtil.getFullPath(path,SCHEMA_FILE_IMSCP));
+ File imsldaSrc = new File(FileUtil.getFullPath(path,SCHEMA_FILE_IMS_LD_LEVEL_A));
+ File imsldbSrc = new File(FileUtil.getFullPath(path,SCHEMA_FILE_IMS_LD_LEVEL_B));
+ File imsldcSrc = new File(FileUtil.getFullPath(path,SCHEMA_FILE_IMS_LD_LEVEL_C));
+ File imscpTar = new File(FileUtil.getFullPath(contentDir,SCHEMA_FILE_IMSCP));
+ File imsldaTar = new File(FileUtil.getFullPath(contentDir,SCHEMA_FILE_IMS_LD_LEVEL_A));
+ File imsldbTar = new File(FileUtil.getFullPath(contentDir,SCHEMA_FILE_IMS_LD_LEVEL_B));
+ File imsldcTar = new File(FileUtil.getFullPath(contentDir,SCHEMA_FILE_IMS_LD_LEVEL_C));
+ FileUtil.copyFile(imscpSrc, imscpTar);
+ FileUtil.copyFile(imsldaSrc, imsldaTar);
+ FileUtil.copyFile(imsldbSrc, imsldbTar);
+ FileUtil.copyFile(imsldcSrc, imsldcTar);
+
//create resources.xml file
Document resourcesDom = new Document();
Element resRoot = new Element(IMS_TAG_RESOURCES);
resRoot.setChildren(resChildren);
resourcesDom.setRootElement(resRoot);
- File resFile = new File(FileUtil.getFullPath(contentDir,IMS_RESOURCES_FILE_NAME));
+ File resFile = new File(FileUtil.getFullPath(xsltDir,IMS_RESOURCES_FILE_NAME));
XMLOutputter resOutput = new XMLOutputter();
resOutput.output(resourcesDom, new FileOutputStream(resFile));
@@ -492,6 +532,18 @@
List transChildren = new ArrayList();
//create transitions DOM file
List sortedActList = getSortedActivities(ldDto);
+ //remove activities inside complex activities, the IMS package does not need that.
+ //I don't want to disturb getSortedActivities() method, so that I removed them here.
+ Iterator iter = sortedActList.iterator();
+ while(iter.hasNext()){
+ AuthoringActivityDTO activityDTO = iter.next();
+ if(activityDTO.getParentActivityID() != null)
+ iter.remove();
+ if(activityDTO.getActivityTypeID() == Activity.SEQUENCE_ACTIVITY_TYPE
+ || activityDTO.getActivityTypeID() == Activity.PARALLEL_ACTIVITY_TYPE
+ || activityDTO.getActivityTypeID() == Activity.OPTIONS_ACTIVITY_TYPE)
+ iter.remove();
+ }
for (AuthoringActivityDTO actDto : sortedActList) {
log.debug("Export IMS: Put actitivies " + actDto.getActivityTitle() + "[" +actDto.getToolContentID()+"] into Transition tag.");
@@ -519,32 +571,12 @@
log.debug("Export IMS: Transform IMS XML by XSLT sucess.");
//output IMS format LD XML
- String imsLdFileName = FileUtil.getFullPath(contentDir,LEARNING_DESIGN_IMS_FILE_NAME);
+ String imsLdFileName = FileUtil.getFullPath(xsltDir,LEARNING_DESIGN_IMS_FILE_NAME);
XMLOutputter output = new XMLOutputter();
output.output(odoc, new FileOutputStream(new File(imsLdFileName)));
log.debug("Export IMS: IMS XML is saved sucessfully.");
- //delete temporary files
- resFile.delete();
- transFile.delete();
- xslt.delete();
- File ldFile = new File(ldFileName);
- if(ldFile.exists()){
- ldFile.delete();
- }else{
- log.warn("Export IMS: Can not delete learing_design XML:"+ldFileName);
- }
- List activities = ldDto.getActivities();
- for (AuthoringActivityDTO activityDTO : activities) {
- File toolFile = new File(FileUtil.getFullPath(contentDir,activityDTO.getToolContentID()+".xml"));
- if(toolFile.exists()){
- toolFile.delete();
- }else{
- log.warn("Export IMS: Can not delete tool file XML "+ activityDTO.getToolContentID()+".xml");
- }
- }
- log.debug("Export IMS: Temporary files (resources.xml,transitions.xml, learing_design.xml etc.) are removed.");
}
@@ -658,13 +690,16 @@
* Move LAMS tool.xml from tool folder to export content root folder and modify it to {toolContentID}.xml file. Cache all attachement files
* from this tool into ArrayList, which will be save into a temporary file (resources.xml) and used by XSLT.
*
- * @param contentDir
+ * @param rootDir
* @param activity
* @param resChildren
* @throws IOException
* @throws FileNotFoundException
*/
- private void handleIMS(String contentDir, AuthoringActivityDTO activity, List resChildren) throws IOException, FileNotFoundException {
+ private void handleIMS(String rootDir, AuthoringActivityDTO activity, List resChildren) throws IOException, FileNotFoundException {
+ String contentDir = FileUtil.getFullPath(rootDir, DIR_CONTENT);
+ String xsltDir = FileUtil.getFullPath(rootDir, DIR_XSLT_TEMP);
+
String toolPath = FileUtil.getFullPath(contentDir,activity.getToolContentID().toString());
File toolDir = new File(toolPath);
if(toolDir != null){
@@ -680,13 +715,21 @@
Document doc = sax.build(new FileInputStream(toolFile));
Element root = doc.getRootElement();
+ //cache DTO object class and transform it into a tag : for later import use by XStream.
+ String mainObject = root.getName();
root.setName(activity.getToolSignature());
Namespace ns = Namespace.getNamespace(IMS_TOOL_NS_PREFIX+activity.getToolSignature()+"_ims_" + activity.getToolVersion() + ".xsd");
root.setNamespace(ns);
+
+ //add mainObject tag: it save the Tool DTO class name. It is useful when importing by XStream (perhaps a future function)
+ Element mainObjectEle = new Element(IMS_TOOL_MAIN_OBJECT);
+ mainObjectEle.setText(mainObject);
+ root.addContent(mainObjectEle);
+
//create a new tools.xml file with toolContentID.xml as name.
- File toolsFile = new File(FileUtil.getFullPath(contentDir,activity.getToolContentID().toString()+".xml"));
+ File imsToolFile = new File(FileUtil.getFullPath(xsltDir,activity.getToolContentID().toString()+".xml"));
XMLOutputter toolOutput = new XMLOutputter();
- toolOutput.output(doc, new FileOutputStream(toolsFile));
+ toolOutput.output(doc, new FileOutputStream(imsToolFile));
log.debug("Export IMS: Tool.xml in " + activity.getActivityTitle() + "[" +activity.getToolContentID()+"] transform success.");
} catch (JDOMException e) {