move imscp to mods
authorgreg gay <ggay@ocad.ca>
Thu, 21 Jan 2010 14:56:12 +0000 (14:56 -0000)
committergreg gay <ggay@ocad.ca>
Thu, 21 Jan 2010 14:56:12 +0000 (14:56 -0000)
14 files changed:
docs/mods/_core/imscp/glossary.xsd [new file with mode: 0644]
docs/mods/_core/imscp/ims_export.php [new file with mode: 0644]
docs/mods/_core/imscp/ims_import.php [new file with mode: 0644]
docs/mods/_core/imscp/imscc_c1p2maeV0p15_definition.xsd [new file with mode: 0644]
docs/mods/_core/imscp/imscp_v1p2.xsd [new file with mode: 0644]
docs/mods/_core/imscp/imscp_v1p2_constraintsDocument.scmt [new file with mode: 0644]
docs/mods/_core/imscp/imscp_v1p2_localised.xsd [new file with mode: 0644]
docs/mods/_core/imscp/imsdt_v1p0_localised.xsd [new file with mode: 0644]
docs/mods/_core/imscp/imsmanifest.xml [new file with mode: 0644]
docs/mods/_core/imscp/imswl_v1p0_localised.xsd [new file with mode: 0644]
docs/mods/_core/imscp/index.php [new file with mode: 0644]
docs/mods/_core/imscp/main.xsd [new file with mode: 0644]
docs/mods/_core/imscp/module.php [new file with mode: 0644]
docs/mods/_core/imscp/ns.inc.php [new file with mode: 0644]

diff --git a/docs/mods/_core/imscp/glossary.xsd b/docs/mods/_core/imscp/glossary.xsd
new file mode 100644 (file)
index 0000000..bc78ddb
--- /dev/null
@@ -0,0 +1,14 @@
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.atutor.ca/xsd/glossary" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.atutor.ca/xsd/glossary" elementFormDefault="unqualified">
+  <xs:complexType name="glossaryItem">
+    <xs:sequence>
+       <xs:element name="term" type="xs:string"/>
+       <xs:element name="definition" type="xs:string"/>
+    </xs:sequence>
+  </xs:complexType>
+  <xs:element name="glossary" type="glossaryType"/>
+  <xs:complexType name="glossaryType">
+    <xs:sequence>
+      <xs:element name="item" type="glossaryItem" minOccurs="0" maxOccurs="unbounded" />
+    </xs:sequence>
+  </xs:complexType>
+</xs:schema>
diff --git a/docs/mods/_core/imscp/ims_export.php b/docs/mods/_core/imscp/ims_export.php
new file mode 100644 (file)
index 0000000..c73153d
--- /dev/null
@@ -0,0 +1,344 @@
+<?php
+/************************************************************************/
+/* ATutor                                                               */
+/************************************************************************/
+/* Copyright (c) 2002 - 2009                                            */
+/* Adaptive Technology Resource Centre / University of Toronto          */
+/*                                                                      */
+/* 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.                        */
+/************************************************************************/
+// $Id: ims_export.php 8935 2009-11-17 17:36:09Z hwong $
+define('AT_INCLUDE_PATH', '../../../include/');
+
+/* content id of an optional chapter */
+$cid = isset($_REQUEST['cid']) ? intval($_REQUEST['cid']) : 0;
+$c   = isset($_REQUEST['c'])   ? intval($_REQUEST['c'])   : 0;
+
+if (isset($_REQUEST['to_tile']) && !isset($_POST['cancel'])) {
+       /* for TILE */
+
+       /* redirect to TILE import servlet */
+       if (!authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)) {
+               /* user can't be authenticated */
+               header('HTTP/1.1 404 Not Found');
+               echo 'Document not found.';
+               exit;
+       }
+
+       $m = md5(DB_PASSWORD . 'x' . ADMIN_PASSWORD . 'x' . $_SERVER['SERVER_ADDR'] . 'x' . $cid . 'x' . $_SESSION['course_id'] . 'x' . date('Ymd'));
+
+       header('Location: '.AT_TILE_IMPORT. '?cp='.urlencode(AT_BASE_HREF. 'mods/_core/imscp/ims_export.php?cid='.$cid.'&c='.$_SESSION['course_id'].'&m='.$m));
+       exit;
+} else if (isset($_GET['m'])) {
+       /* for TILE */
+
+       /* request (hopefully) coming from a TILE server, send the content package */
+
+       $_user_location = 'public';
+       require(AT_INCLUDE_PATH.'vitals.inc.php');
+       $m = md5(DB_PASSWORD . 'x' . ADMIN_PASSWORD . 'x' . $_SERVER['SERVER_ADDR'] . 'x' . $cid . 'x' . $c . 'x' . date('Ymd'));
+       if (($m != $_GET['m']) || !$c) {
+               header('HTTP/1.1 404 Not Found');
+               echo 'Document not found.';
+               exit;
+       }
+       
+       $course_id = $c;
+
+} else {
+       $use_a4a = false;
+       if (isset($_REQUEST['to_a4a'])){
+               $use_a4a = true;
+       }
+       require(AT_INCLUDE_PATH.'vitals.inc.php');
+       $course_id = $_SESSION['course_id'];
+}
+//load the following after vitals is included
+require(AT_INCLUDE_PATH.'classes/testQuestions.class.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4aExport.class.php');
+
+$instructor_id   = $system_courses[$course_id]['member_id'];
+$course_desc     = htmlspecialchars($system_courses[$course_id]['description'], ENT_QUOTES, 'UTF-8');
+$course_title    = htmlspecialchars($system_courses[$course_id]['title'], ENT_QUOTES, 'UTF-8');
+$course_language = $system_courses[$course_id]['primary_language'];
+
+$courseLanguage =& $languageManager->getLanguage($course_language);
+//If course language cannot be found, use UTF-8 English
+//@author harris, Oct 30,2008
+if ($courseLanguage == null){
+       $courseLanguage =& $languageManager->getLanguage('en');
+}
+
+$course_language_charset = $courseLanguage->getCharacterSet();
+$course_language_code = $courseLanguage->getCode();
+
+require(AT_INCLUDE_PATH.'classes/zipfile.class.php');                          /* for zipfile */
+require(AT_INCLUDE_PATH.'classes/vcard.php');                                          /* for vcard */
+require(AT_INCLUDE_PATH.'classes/XML/XML_HTMLSax/XML_HTMLSax.php');    /* for XML_HTMLSax */
+require(AT_INCLUDE_PATH.'../mods/_core/imscp/include/ims_template.inc.php');                           /* for ims templates + print_organizations() */
+
+if (isset($_POST['cancel'])) {
+       $msg->addFeedback('EXPORT_CANCELLED');
+       header('Location: ../index.php');
+       exit;
+}
+
+
+$zipfile = new zipfile(); 
+$zipfile->create_dir('resources/');
+
+/*
+       the following resources are to be identified:
+       even if some of these can't be images, they can still be files in the content dir.
+       theoretically the only urls we wouldn't deal with would be for a <!DOCTYPE and <form>
+
+       img             => src
+       a               => href                         // ignore if href doesn't exist (ie. <a name>)
+       object  => data | classid       // probably only want data
+       applet  => classid | archive                    // whatever these two are should double check to see if it's a valid file (not a dir)
+       link    => href
+       script  => src
+       form    => action
+       input   => src
+       iframe  => src
+
+*/
+class MyHandler {
+    function MyHandler(){}
+    function openHandler(& $parser,$name,$attrs) {
+               global $my_files;
+
+               $name = strtolower($name);
+               $attrs = array_change_key_case($attrs, CASE_LOWER);
+
+               $elements = array(      'img'           => 'src',
+                                                       'a'                     => 'href',                              
+                                                       'object'        => array('data', 'classid'),
+                                                       'applet'        => array('classid', 'archive'),
+                                                       'link'          => 'href',
+                                                       'script'        => 'src',
+                                                       'form'          => 'action',
+                                                       'input'         => 'src',
+                                                       'iframe'        => 'src',
+                                                       'embed'         => 'src',
+                                                       'param'         => 'value');
+       
+               /* check if this attribute specifies the files in different ways: (ie. java) */
+               if (is_array($elements[$name])) {
+                       $items = $elements[$name];
+
+                       foreach ($items as $item) {
+                               if ($attrs[$item] != '') {
+
+                                       /* some attributes allow a listing of files to include seperated by commas (ie. applet->archive). */
+                                       if (strpos($attrs[$item], ',') !== false) {
+                                               $files = explode(',', $attrs[$item]);
+                                               foreach ($files as $file) {
+                                                       $my_files[] = trim($file);
+                                               }
+                                       } else {
+                                               $my_files[] = $attrs[$item];
+                                       }
+                               }
+                       }
+               } else if (isset($elements[$name]) && ($attrs[$elements[$name]] != '')) {
+                       /* we know exactly which attribute contains the reference to the file. */
+                       $my_files[] = $attrs[$elements[$name]];
+               }
+    }
+    function closeHandler(& $parser,$name) { }
+}
+
+/* get all the content */
+$content = array();
+$paths  = array();
+$top_content_parent_id = 0;
+
+$handler=new MyHandler();
+$parser = new XML_HTMLSax();
+$parser->set_object($handler);
+$parser->set_element_handler('openHandler','closeHandler');
+
+if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
+       $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
+} else {
+       $sql = "SELECT *, UNIX_TIMESTAMP(last_modified) AS u_ts FROM ".TABLE_PREFIX."content WHERE course_id=$course_id ORDER BY content_parent_id, ordering";
+}
+$result = mysql_query($sql, $db);
+while ($row = mysql_fetch_assoc($result)) {
+       if (authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) || $contentManager->isReleased($row['content_id']) === TRUE) {
+               $content[$row['content_parent_id']][] = $row;
+               if ($cid == $row['content_id']) {
+                       $top_content = $row;
+                       $top_content_parent_id = $row['content_parent_id'];
+               }
+       }
+}
+
+if ($cid) {
+       /* filter out the top level sections that we don't want */
+       $top_level = $content[$top_content_parent_id];
+       foreach($top_level as $page) {
+               if ($page['content_id'] == $cid) {
+                       $content[$top_content_parent_id] = array($page);
+               } else {
+                       /* this is a page we don't want, so might as well remove it's children too */
+                       unset($content[$page['content_id']]);
+               }
+       }
+       $ims_course_title = $course_title . ' - ' . $content[$top_content_parent_id][0]['title'];
+} else {
+       $ims_course_title = $course_title;
+}
+
+
+/* generate the imsmanifest.xml header attributes */
+$imsmanifest_xml = str_replace(array('{COURSE_TITLE}', '{COURSE_DESCRIPTION}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}'), 
+                                                         array($ims_course_title, $course_desc, $course_language_charset, $course_language_code),
+                                                         $ims_template_xml['header']);
+//debug($imsmanifest_xml);
+//exit;
+
+/* get the first content page to default the body frame to */
+$first = $content[$top_content_parent_id][0];
+
+$test_ids = array();   //global array to store all the test ids
+//if ($my_files == null) 
+//$my_files = array();
+
+/* generate the IMS QTI resource and files */
+/*
+/* in print_organizations
+foreach ($content[0] as $content_box){
+       $content_test_rs = $contentManager->getContentTestsAssoc($content_box['content_id']);   
+       while ($content_test_row = mysql_fetch_assoc($content_test_rs)){
+               //export
+               $test_ids[] = $content_test_row['test_id'];
+               //the 'added_files' is for adding into the manifest file in this zip
+               $added_files = test_qti_export($content_test_row['test_id'], '', $zipfile);
+
+               //Save all the xml files in this array, and then print_organizations will add it to the manifest file.
+               foreach($added_files as $filename=>$file_array){
+                       $my_files[] = $filename;
+                       foreach ($file_array as $garbage=>$filename2){
+                               $my_files[] = $filename2;
+                       }
+               }
+       }
+}
+*/
+
+/* generate the resources and save the HTML files */
+$used_glossary_terms = array();
+ob_start();
+print_organizations($top_content_parent_id, $content, 0, '', array(), $toc_html);
+$organizations_str = ob_get_contents();
+ob_end_clean();
+
+if (count($used_glossary_terms)) {
+       $used_glossary_terms = array_unique($used_glossary_terms);
+       sort($used_glossary_terms);
+       reset($used_glossary_terms);
+
+       $terms_xml = '';
+       foreach ($used_glossary_terms as $term) {
+               $term_key = urlencode($term);
+               $glossary[$term_key] = htmlentities($glossary[$term_key], ENT_QUOTES, 'UTF-8');
+               $glossary[$term_key] = str_replace('&', '&amp;', $glossary[$term_key]);
+               $escaped_term = str_replace('&', '&amp;', $term);
+               $terms_xml .= str_replace(      array('{TERM}', '{DEFINITION}'),
+                                                                       array($escaped_term, $glossary[$term_key]),
+                                                                       $glossary_term_xml);
+
+               $terms_html .= str_replace(     array('{ENCODED_TERM}', '{TERM}', '{DEFINITION}'),
+                                                                       array($term_key, $term, $glossary[$term_key]),
+                                                                       $glossary_term_html);
+       }
+
+       $glossary_body_html = str_replace('{BODY}', $terms_html, $glossary_body_html);
+
+       $glossary_xml = str_replace(array('{GLOSSARY_TERMS}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}'),
+                                                           array($terms_xml, $course_language_charset),
+                                                               $glossary_xml);
+       $glossary_html = str_replace(   array('{CONTENT}', '{KEYWORDS}', '{TITLE}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}'),
+                                                                       array($glossary_body_html, '', 'Glossary', $course_language_charset, $course_language_code),
+                                                                       $html_template);
+       $toc_html .= '<ul><li><a href="glossary.html" target="body">'._AT('glossary').'</a></li></ul>';
+} else {
+       unset($glossary_xml);
+}
+
+$toc_html = str_replace(array('{TOC}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}'),
+                                           array($toc_html, $course_language_charset, $course_language_code),
+                                               $html_toc);
+
+if ($first['content_path']) {
+       $first['content_path'] .= '/';
+}
+$frame = str_replace(  array('{COURSE_TITLE}',         '{FIRST_ID}', '{PATH}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}'),
+                                               array($ims_course_title, $first['content_id'], $first['content_path'], $course_language_charset, $course_language_code),
+                                               $html_frame);
+
+$html_mainheader = str_replace(array('{COURSE_TITLE}', '{COURSE_PRIMARY_LANGUAGE_CHARSET}', '{COURSE_PRIMARY_LANGUAGE_CODE}'),
+                                                          array($ims_course_title, $course_language_charset, $course_language_code),
+                                                          $html_mainheader);
+
+
+
+/* append the Organizations and Resources to the imsmanifest */
+$imsmanifest_xml .= str_replace(       array('{ORGANIZATIONS}',        '{RESOURCES}', '{COURSE_TITLE}'),
+                                                                       array($organizations_str,       $resources, $ims_course_title),
+                                                                       $ims_template_xml['final']);
+
+/* generate the vcard for the instructor/author */
+$sql = "SELECT first_name, last_name, email, website, login, phone FROM ".TABLE_PREFIX."members WHERE member_id=$instructor_id";
+$result = mysql_query($sql, $db);
+$vcard = new vCard();
+if ($row = mysql_fetch_assoc($result)) {
+       $vcard->setName($row['last_name'], $row['first_name'], $row['login']);
+       $vcard->setEmail($row['email']);
+       $vcard->setNote('Originated from an ATutor at '.AT_BASE_HREF.'. See ATutor.ca for additional information.');
+       $vcard->setURL($row['website']);
+
+       $imsmanifest_xml = str_replace('{VCARD}', $vcard->getVCard(), $imsmanifest_xml);
+} else {
+       $imsmanifest_xml = str_replace('{VCARD}', '', $imsmanifest_xml);
+}
+
+/* save the imsmanifest.xml file */
+
+$zipfile->add_file($frame,                      'index.html');
+$zipfile->add_file($toc_html,           'toc.html');
+$zipfile->add_file($imsmanifest_xml, 'imsmanifest.xml');
+$zipfile->add_file($html_mainheader, 'header.html');
+if ($glossary_xml) {
+       $zipfile->add_file($glossary_xml,  'glossary.xml');
+       $zipfile->add_file($glossary_html, 'glossary.html');
+}
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/adlcp_rootv1p2.xsd'), 'adlcp_rootv1p2.xsd');
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/ims_xml.xsd'), 'ims_xml.xsd');
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/imscp_rootv1p1p2.xsd'), 'imscp_rootv1p1p2.xsd');
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/imsmd_rootv1p2p1.xsd'), 'imsmd_rootv1p2p1.xsd');
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/ims.css'), 'ims.css');
+$zipfile->add_file(file_get_contents(AT_INCLUDE_PATH.'../mods/_core/imscp/include/footer.html'), 'footer.html');
+$zipfile->add_file(file_get_contents('../../../images/logo.gif'), 'logo.gif');
+
+$zipfile->close(); // this is optional, since send_file() closes it anyway
+
+$ims_course_title = str_replace(array(' ', ':'), '_', $ims_course_title);
+/**
+ * A problem here with the preg_replace below.
+ * Originally was designed to remove all werid symbols to avoid file corruptions.
+ * In UTF-8, all non-english chars are considered to be 'werid symbols'
+ * We can still replace it as is, or add fileid to the filename to avoid these problems
+ * Well then again people won't be able to tell what this file is about
+ * If we are going to take out the preg_replace, some OS might not be able to understand
+ * these characters and will have problems importing.
+ */
+$ims_course_title = preg_replace("{[^a-zA-Z0-9._-]}","", trim($ims_course_title));
+$zipfile->send_file($ims_course_title . '_ims');
+
+exit;
+?>
\ No newline at end of file
diff --git a/docs/mods/_core/imscp/ims_import.php b/docs/mods/_core/imscp/ims_import.php
new file mode 100644 (file)
index 0000000..0789b64
--- /dev/null
@@ -0,0 +1,1385 @@
+<?php
+/************************************************************************/
+/* ATutor                                                               */
+/************************************************************************/
+/* Copyright (c) 2002 - 2009                                            */
+/* Adaptive Technology Resource Centre / University of Toronto          */
+/*                                                                      */
+/* 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.                        */
+/************************************************************************/
+// $Id: ims_import.php 9081 2010-01-13 20:26:03Z cindy $
+define('AT_INCLUDE_PATH', '../../../include/');
+require(AT_INCLUDE_PATH.'vitals.inc.php');
+
+require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php'); /* for clr_dir() and preImportCallBack and dirsize() */
+require(AT_INCLUDE_PATH.'classes/pclzip.lib.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imsqti/lib/qti.inc.php'); 
+require(AT_INCLUDE_PATH.'../mods/_core/imsqti/classes/QTIImport.class.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4aImport.class.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imscp/ns.inc.php');     //namespace, no longer needs, delete it after it's stable.
+require(AT_INCLUDE_PATH.'../mods/_core/imscc/classes/WeblinksParser.class.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imscc/classes/DiscussionToolsParser.class.php');
+require(AT_INCLUDE_PATH.'../mods/_core/imscc/classes/DiscussionToolsImport.class.php');
+
+
+/* make sure we own this course that we're exporting */
+authenticate(AT_PRIV_CONTENT);
+
+/* to avoid timing out on large files */
+@set_time_limit(0);
+$_SESSION['done'] = 1;
+
+$html_head_tags = array("style", "script", "link");
+
+$package_base_path = '';
+$package_real_base_path = '';  //the path to save the contents
+$all_package_base_path = array();
+$xml_base_path = '';
+$element_path = array();
+$imported_glossary = array();
+$character_data = '';
+$test_message = '';
+$test_title = '';
+$content_type = '';
+$skip_ims_validation = false;
+$added_dt = array();   //the mapping of discussion tools that are added
+$avail_dt = array();   //list of discussion tools that have not been handled
+
+
+/*
+ * return the error messages represented by the given array 
+ * @author     Mike A.
+ * @ref                http://ca3.php.net/manual/en/domdocument.schemavalidate.php
+ */
+function libxml_display_error($error)
+{
+    $return = "<br/>\n";
+    switch ($error->level) {
+        case LIBXML_ERR_WARNING:
+            $return .= "<b>Warning $error->code</b>: ";
+            break;
+        case LIBXML_ERR_ERROR:
+            $return .= "<b>Error $error->code</b>: ";
+            break;
+        case LIBXML_ERR_FATAL:
+            $return .= "<b>Fatal Error $error->code</b>: ";
+            break;
+    }
+    $return .= trim($error->message);
+    if ($error->file) {
+        $return .=    " in <b>$error->file</b>";
+    }
+    $return .= " on line <b>$error->line</b>\n";
+
+    return $return;
+}
+
+/**
+ * Validate all the XML in the package, including checking XSDs, missing data.
+ * @param      string          the path of the directory that contains all the package files
+ * @return     boolean         true if every file exists in the manifest, false if any is missing.
+ */
+function checkResources($import_path){
+       global $items, $msg, $skip_ims_validation, $avail_dt;
+
+       if (!is_dir($import_path)){
+               return;
+       }
+
+       //if the package has access for all content, skip validation for now. 
+       //todo: import the XSD into our validator
+       if ($skip_ims_validation){
+               return true;
+       }
+
+       //generate a file tree
+       $data = rscandir($import_path);
+
+       //check if every file is presented in the manifest
+       foreach($data as $filepath){
+               $filepath = substr($filepath, strlen($import_path));
+
+               //validate xml via its xsd/dtds
+               if (preg_match('/(.*)\.xml/', $filepath)){
+                       libxml_use_internal_errors(true);
+                       $dom = new DOMDocument();
+                       $dom->load(realpath($import_path.$filepath));
+                       if (!@$dom->schemaValidate('main.xsd')){
+                               $errors = libxml_get_errors();
+                               foreach ($errors as $error) {
+                                       //suppress warnings
+                                       if ($error->level==LIBXML_ERR_WARNING){
+                                               continue;
+                                       }
+                                       $msg->addError(array('IMPORT_CARTRIDGE_FAILED', libxml_display_error($error)));
+                               }
+                               libxml_clear_errors();
+                       }
+                       //if this is the manifest file, we do not have to check for its existance.
+//                     if (preg_match('/(.*)imsmanifest\.xml/', $filepath)){
+//                             continue;
+//                     }
+               }
+       }
+
+       //Create an array that mimics the structure of the data array, based on the xml items
+       $filearray = array();
+       foreach($items as $name=>$fileinfo){
+               if(isset($fileinfo['file']) && is_array($fileinfo['file']) && !empty($fileinfo['file'])){
+                       foreach($fileinfo['file'] as $fn){
+                               if (!in_array(realpath($import_path.$fn), $filearray)){
+                                       $filearray[] = realpath($import_path. $fn);
+                               }
+                       }
+               }
+
+               //validate the xml by its schema
+               if (preg_match('/imsqti\_(.*)/', $fileinfo['type'])){
+                       $qti = new QTIParser($fileinfo['type']);
+                       $xml_content = @file_get_contents($import_path . $fileinfo['href']);
+                       $qti->parse($xml_content); //will add error to $msg if failed                   
+               } 
+
+               //add all dependent discussion tools to a list
+               if(isset($fileinfo['dependency']) && !empty($fileinfo['dependency'])){
+                       $avail_dt = array_merge($avail_dt, $fileinfo['dependency']);
+               }
+       }
+
+       //check if all files in the xml is presented in the archieve
+       $result = array_diff($filearray, $data);
+       //using sizeof because array_diff only 
+       //returns an array containing all the entries from array1  that are not present in any of the 
+       //other arrays. 
+       //Using sizeof make sure it's not a subset of array2.
+       //-1 on data because it always contain the imsmanifest.xml file
+       if (!empty($result) || sizeof($data)-1>sizeof($filearray)){
+               $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references')));
+       }
+       return true;
+}
+
+/*
+ * @example rscandir(dirname(__FILE__).'/'));
+ * @param string $base
+ * @param array $omit
+ * @param array $data
+ * @return array
+ */
+function rscandir($base='', &$data=array()) {
+  $array = array_diff(scandir($base), array('.', '..')); # remove ' and .. from the array */
+  foreach($array as $value) : /* loop through the array at the level of the supplied $base */
+    if (is_dir($base.$value)) : /* if this is a directory */
+//       don't save the directory name
+//       $data[] = $base.$value.'/'; /* add it to the $data array */
+      $data = rscandir($base.$value.'/', $data); /* then make a recursive call with the
+      current $value as the $base supplying the $data array to carry into the recursion */
+     
+    elseif (is_file($base.$value)) : /* else if the current $value is a file */
+      $data[] = realpath($base.$value); /* just add the current $value to the $data array */
+     
+    endif;
+   
+  endforeach;
+  return $data; // return the $data array
+}
+
+/**
+ * Function to restructure the $items.  So that old import will merge the top page into its children, and
+ * create a new folder on top of it
+ */
+function rehash($items){
+       global $order;
+       $parent_page_maps = array();    //old=>new
+       $temp_popped_items = array();
+       $rehashed_items = array();      //the reconstructed array
+       foreach($items as $id => $content){
+               $parent_obj = $items[$content['parent_content_id']];
+               $rehashed_items[$id] = $content;        //copy
+        //first check if this is the top folder of the archieve, we don't want the top folder, remove it.
+/*        if (isset($content['parent_content_id']) && !isset($parent_obj) && !isset($content['type'])){
+            //if we can get into here, it means the parent_content_id of this is empty
+            //implying this is the first folder.
+            //note: it checks content[type] cause it could be a webcontent. In that case, 
+            //      we do want to keep it.  
+                       debug($content, 'hit');
+            unset($rehashed_items[$id]);
+            continue;
+        }              
+               //then check if there exists a mapping for this item, if so, simply replace is and next.
+               else
+*/             if (isset($parent_page_maps[$content['parent_content_id']])){
+                       $rehashed_items [$id]['parent_content_id'] = $parent_page_maps[$content['parent_content_id']];
+                       $rehashed_items [$id]['ordering']++;
+               } 
+               //If its parent page is a top page and have an identiferref
+               elseif (isset($parent_obj) && isset($parent_obj['href'])){                      
+                       if (!isset($parent_obj['href'])){
+                               //check if this top page is already a folder, if so, next.
+                               continue;
+                       }
+                       //else, make its parent page to a folder
+                       $new_item['title'] = $parent_obj['title'];
+                       //check if this parent has been modified, if so, chnage it
+                       if (isset($parent_page_maps[$parent_obj['parent_content_id']])){
+                           $new_item['parent_content_id'] = $parent_page_maps[$parent_obj['parent_content_id']];
+                       } else {
+                       $new_item['parent_content_id'] = $parent_obj['parent_content_id'];
+            }
+                       //all ordering needs to be +1 because we are creating a new folder on top of
+                       //everything, except the first page.
+                       $new_item['ordering'] = $parent_obj['ordering'];
+                       if ($new_item['parent_content_id']!='0'){
+                               $new_item['ordering']++;
+                       } 
+
+               //assign this new parent folder to the pending items array
+                       $new_item_name = $content['parent_content_id'].'_FOLDER';
+                       //a not so brilliant way to append the folder in its appropriate position
+                       $reordered_hashed_items = array();  //use to store the new rehashed item with the correct item order
+                       foreach($rehashed_items as $rh_id=>$rh_content){
+                           if ($rh_id == $content['parent_content_id']){
+                               //add the folder in before the parent subpage.
+                               $reordered_hashed_items[$new_item_name] = $new_item;
+                           }
+                           $reordered_hashed_items[$rh_id] = $rh_content;  //clone
+                       }
+                       $rehashed_items = $reordered_hashed_items;  //replace it back
+                       unset($reordered_hashed_items);
+                       $parent_page_maps[$content['parent_content_id']] = $new_item_name;  //save this page on the hash map
+
+                       //reconstruct the parent
+                       $rehashed_items[$content['parent_content_id']]['parent_content_id'] = $parent_page_maps[$content['parent_content_id']];
+                       $rehashed_items[$content['parent_content_id']]['ordering'] = 0; //always the first one.
+
+                       //reconstruct itself
+                       $rehashed_items[$id]['parent_content_id'] = $parent_page_maps[$content['parent_content_id']];
+                       $rehashed_items[$id]['ordering']++;
+
+               }
+       }
+       return $rehashed_items;
+}
+
+
+/** 
+ * This function will take the test accessment XML and add these to the database.
+ * @param      string  The path of the XML, without the import_path.
+ * @param      mixed   An item singleton.  Contains the info of this item, namely, the accessment details.
+ *                                     The item must be an object created by the ims class.
+ * @param      string  the import path
+ * @return     mixed   An Array that contains all the question IDs that have been imported.
+ */
+ function addQuestions($xml, $item, $import_path){
+       global $test_title;
+       $qti_import = new QTIImport($import_path);
+       $tests_xml = $import_path.$xml;
+       
+       //Mimic the array for now.
+       $test_attributes['resource']['href'] = $item['href'];
+       $test_attributes['resource']['type'] = preg_match('/imsqti_xmlv1p2/', $item['type'])==1?'imsqti_xmlv1p2':'imsqti_xmlv1p1';
+       $test_attributes['resource']['file'] = $item['file'];
+
+       //Get the XML file out and start importing them into our database.
+       //TODO: See question_import.php 287-289.
+       $qids = $qti_import->importQuestions($test_attributes);
+       $test_title = $qti_import->title;
+
+       return $qids;
+ }
+
+
+       /* called at the start of en element */
+       /* builds the $path array which is the path from the root to the current element */
+       function startElement($parser, $name, $attrs) {
+               global $items, $path, $package_base_path, $all_package_base_path, $package_real_base_path;
+               global $element_path, $import_path;
+               global $xml_base_path, $test_message, $content_type;
+               global $current_identifier, $msg, $ns, $ns_cp;
+
+               //check if the xml is valid
+/*
+               if(isset($attrs['xsi:schemaLocation']) && $name == 'manifest'){
+                       //run the loop and check it thru the ns.inc.php
+               } elseif ($name == 'manifest' && !isset($attrs['xsi:schemaLocation'])) {
+                       //$msg->addError('MANIFEST_NOT_WELLFORM: NO NAMESPACE');
+                       $msg->addError('IMPORT_CARTRIDGE_FAILED');
+               } else {
+                       //error
+               }
+               //error if the tag names are wrong
+               if (preg_match('/^xsi\:/', $name) >= 1){
+                       //$msg->addError('MANIFEST_NOT_WELLFORM');
+                       $msg->addError('IMPORT_CARTRIDGE_FAILED');
+               }
+*/
+
+
+               //validate namespaces
+               if(isset($attrs['xsi:schemaLocation']) && $name=='manifest'){
+                       $schema_location = array();
+                       $split_location = preg_split('/[\r\n\s]+/', trim($attrs['xsi:schemaLocation']));
+
+                       //check if the namespace is actually right, have an array or some sort in IMS class
+                       if(sizeof($split_location)%2==1){
+                               //schema is not in the form of "The first URI reference in each pair is a namespace name,
+                               //and the second is the location of a schema that describes that namespace."
+                               //$msg->addError('MANIFEST_NOT_WELLFORM');
+                               $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('schema_error')));
+                       }
+
+                       //turn the xsi:schemaLocation URI into a schema that describe namespace.
+                       //name = url
+                       //http://msdn.microsoft.com/en-us/library/ms256100(VS.85).aspx
+                       //http://www.w3.org/TR/xmlschema-1/
+                       for($i=0; $i < sizeof($split_location);$i=$i+2){
+                               /*
+                               if (isset($ns[$split_location[$i]]) && $ns[$split_location[$i]] != $split_location[$i+1]){
+                                       //$msg->addError('MANIFEST_NOT_WELLFORM: SCHEMA');
+                                       $msg->addError('IMPORT_CARTRIDGE_FAILED');
+                               }
+                               */
+                               //if the key of the namespace is not defined. Throw error.
+                               if(!isset($ns[$split_location[$i]]) && !isset($ns_cp[$split_location[$i]])){
+                                       $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('schema_error')));
+                               }
+                       }
+               } else {
+                       //throw error           
+               }
+
+
+               if ($name == 'manifest' && isset($attrs['xml:base']) && $attrs['xml:base']) {
+                       $xml_base_path = $attrs['xml:base'];
+               } else if ($name == 'file') {
+                       // check if it misses file references
+                       if(!isset($attrs['href']) || $attrs['href']==''){
+                               //$msg->addError('MANIFEST_NOT_WELLFORM');
+                               $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT('ims_missing_references')));
+                       }
+
+                       // special case for webCT content packages that don't specify the `href` attribute 
+                       // with the `<resource>` element.
+                       // we take the `href` from the first `<file>` element.
+                       if (isset($items[$current_identifier]) && ($items[$current_identifier]['href'] == '')) {
+                               $attrs['href'] = urldecode($attrs['href']);
+                               $items[$current_identifier]['href'] = $attrs['href'];
+                       }
+
+                       $temp_path = pathinfo($attrs['href']);
+                       $temp_path = explode('/', $temp_path['dirname']);
+                       if (empty($package_base_path)){
+                           $package_base_path = $temp_path;
+            }
+                       if ($all_package_base_path!='' && empty($all_package_base_path)){
+                               $all_package_base_path = $temp_path;
+                       }
+                       $package_base_path = array_intersect_assoc($package_base_path, $temp_path);
+                       
+                       //calculate the depths of relative paths
+                       if ($all_package_base_path!=''){
+                               $no_relative_temp_path = $temp_path;
+                               foreach($no_relative_temp_path as $path_node){
+                                       if ($path_node=='..'){
+                                               array_pop($no_relative_temp_path);
+                                               array_pop($no_relative_temp_path); //not a typo, have to pop twice, both itself('..'), and the one before.
+                                       }
+                               }
+                               $all_package_base_path = array_intersect_assoc($all_package_base_path, $no_relative_temp_path);
+                               if (empty($all_package_base_path)){
+                                       $all_package_base_path = '';    //unset it, there is no intersection.
+                               }
+                       }
+
+                       //save the actual content base path
+                       if (in_array('..', $temp_path)){
+                               $sizeofrp = array_count_values($temp_path);
+                       }
+
+                       //for IMSCC, assume that all resources lies in the same folder, except styles.css
+                       if ($items[$current_identifier]['type']=='webcontent' || $items[$current_identifier]['type']=='imsdt_xmlv1p0'){
+                               //find the intersection of each item's related files, then that intersection is the content_path
+                               if (isset($items[$current_identifier]['file'])){
+                                       foreach ($items[$current_identifier]['file'] as $resource_path){
+                                               $temp_path = pathinfo($resource_path);
+                                               $temp_path = explode('/', $temp_path['dirname']);
+                                               $package_base_path = array_intersect_assoc($package_base_path, $temp_path);                                             
+                                       }
+                               }
+                       }
+
+                       //real content path
+                       if($sizeofrp['..'] > 0 && !empty($all_package_base_path)){
+                               for ($i=0; $i<$sizeofrp['..']; $i++){
+                                       array_pop($all_package_base_path);
+                               }
+                       }
+                       $items[$current_identifier]['new_path'] = implode('/', $package_base_path);     
+/* 
+ * @harris, reworked the package_base_path 
+                               if ($package_base_path=="") {
+                                       $package_base_path = $temp_path;
+                               } 
+                               elseif (is_array($package_base_path) && $content_type != 'IMS Common Cartridge') {
+                                       //if this is a content package, we want only intersection
+                                       $package_base_path = array_intersect($package_base_path, $temp_path);
+                                       $temp_path = $package_base_path;
+                               }
+                               //added these 2 lines in so that pictures would load.  making the elseif above redundant.
+                               //if there is a bug for pictures not load, then it's the next 2 lines.
+                               $package_base_path = array_intersect($package_base_path, $temp_path);
+                               $temp_path = $package_base_path;
+                       }
+                       $items[$current_identifier]['new_path'] = implode('/', $temp_path);     
+*/
+                       if (    isset($_POST['allow_test_import']) && isset($items[$current_identifier]) 
+                                               && preg_match('/((.*)\/)*tests\_[0-9]+\.xml$/', $attrs['href'])) {
+                               $items[$current_identifier]['tests'][] = $attrs['href'];
+                       } 
+                       if (    isset($_POST['allow_a4a_import']) && isset($items[$current_identifier])) {
+                               $items[$current_identifier]['a4a_import_enabled'] = true;
+                       }
+               } else if (($name == 'item') && ($attrs['identifierref'] != '')) {
+                       $path[] = $attrs['identifierref'];
+               } else if (($name == 'item') && ($attrs['identifier'])) {
+                       $path[] = $attrs['identifier'];
+//             } else if (($name == 'resource') && is_array($items[$attrs['identifier']]))  {
+               } else if (($name == 'resource')) {
+                       $current_identifier = $attrs['identifier'];
+                       $items[$current_identifier]['type'] = $attrs['type'];
+                       if ($attrs['href']) {
+                               $attrs['href'] = urldecode($attrs['href']);
+
+                               $items[$attrs['identifier']]['href'] = $attrs['href'];
+
+                               // href points to a remote url
+                               if (preg_match('/^http.*:\/\//', trim($attrs['href'])))
+                                       $items[$attrs['identifier']]['new_path'] = '';
+                               else // href points to local file
+                               {
+                                       $temp_path = pathinfo($attrs['href']);
+                                       $temp_path = explode('/', $temp_path['dirname']);
+//                                     if (empty($package_base_path)) {
+                                               $package_base_path = $temp_path;
+//                                     } 
+//                                     else {
+//                                             $package_base_path = array_intersect($package_base_path, $temp_path);
+//                                     }
+                                       $items[$attrs['identifier']]['new_path'] = implode('/', $temp_path);
+                               }
+                       }
+
+                       //if test custom message has not been saved
+//                     if (!isset($items[$current_identifier]['test_message'])){
+//                             $items[$current_identifier]['test_message'] = $test_message;
+//                     }
+               } else if ($name=='dependency' && $attrs['identifierref']!='') {
+                       //if there is a dependency, attach it to the item array['file']
+                       $items[$current_identifier]['dependency'][] = $attrs['identifierref'];
+               }
+               if (($name == 'item') && ($attrs['parameters'] != '')) {
+                       $items[$attrs['identifierref']]['test_message'] = $attrs['parameters'];
+               }
+               if ($name=='file'){
+                       if(!isset($items[$current_identifier]) && $attrs['href']!=''){
+                               $items[$current_identifier]['href']      = $attrs['href'];
+                       }
+                       if (file_exists($import_path.$attrs['href'])){
+                               $items[$current_identifier]['file'][] = $attrs['href'];
+                       } else {
+                               //$msg->addError('');
+                               $msg->addError(array('IMPORT_CARTRIDGE_FAILED', _AT(array('ims_files_missing', $attrs['href']))));
+                       }
+               }               
+               if ($name=='cc:authorizations'){
+                       //don't have authorization setup.
+                       //$msg->addError('');
+                       $msg->addError('IMS_AUTHORIZATION_NOT_SUPPORT');
+               }
+               array_push($element_path, $name);
+       }
+
+       /* called when an element ends */
+       /* removed the current element from the $path */
+       function endElement($parser, $name) {
+               global $path, $element_path, $my_data, $items;
+               global $current_identifier, $skip_ims_validation;
+               global $msg, $content_type;             
+               static $resource_num = 0;
+               
+               if ($name == 'item') {
+                       array_pop($path);
+               } 
+
+               //check if this is a test import
+               if ($name == 'schema'){
+                       if (trim($my_data)=='IMS Question and Test Interoperability'){
+                               $msg->addError('IMPORT_FAILED');
+                       } 
+                       $content_type = trim($my_data);
+               }
+
+               //Handles A4a
+               if ($current_identifier != ''){
+                       $my_data = trim($my_data);
+                       $last_file_name = $items[$current_identifier]['file'][(sizeof($items[$current_identifier]['file']))-1];
+
+                       if ($name=='originalAccessMode'){                               
+                               if (in_array('accessModeStatement', $element_path)){
+                                       $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['access_stmt_originalAccessMode'][] = $my_data;
+                               } elseif (in_array('adaptationStatement', $element_path)){
+                                       $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['adapt_stmt_originalAccessMode'][] = $my_data;
+                               }                       
+                       } elseif (($name=='language') && in_array('accessModeStatement', $element_path)){
+                               $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['language'][] = $my_data;
+                       } elseif ($name=='hasAdaptation') {
+                               $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['hasAdaptation'][] = $my_data;
+                       } elseif ($name=='isAdaptationOf'){
+                               $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['isAdaptationOf'][] = $my_data;
+                       } elseif ($name=='accessForAllResource'){
+                               /* the head node of accessForAll Metadata, if this exists in the manifest. Skip XSD validation,
+                                * because A4a doesn't have a xsd yet.  Our access for all is based on ISO which will not pass 
+                                * the current IMS validation.  
+                                * Also, since ATutor is the only one (as of Oct 21, 2009) that exports IMS with access for all
+                                * content, we can almost assume that any ims access for all content is by us, and is valid. 
+                                */
+                               $skip_ims_validation = true;
+                               $resource_num++;
+                       } elseif($name=='file'){
+                               $resource_num = 0;      //reset resournce number to 0 when the file tags ends
+                       }
+               }
+
+               if ($element_path === array('manifest', 'metadata', 'imsmd:lom', 'imsmd:general', 'imsmd:title', 'imsmd:langstring')) {
+                       global $package_base_name;
+                       $package_base_name = trim($my_data);
+               }
+
+               array_pop($element_path);
+               $my_data = '';
+       }
+
+       /* called when there is character data within elements */
+       /* constructs the $items array using the last entry in $path as the parent element */
+       function characterData($parser, $data){
+               global $path, $items, $order, $my_data, $element_path;
+               global $current_identifier;
+
+               $str_trimmed_data = trim($data);
+                               
+               if (!empty($str_trimmed_data)) {
+                       $size = count($path);
+                       if ($size > 0) {
+                               $current_item_id = $path[$size-1];
+                               if ($size > 1) {
+                                       $parent_item_id = $path[$size-2];
+                               } else {
+                                       $parent_item_id = 0;
+                               }
+
+                               if (isset($items[$current_item_id]['parent_content_id']) && is_array($items[$current_item_id])) {
+
+                                       /* this item already exists, append the title           */
+                                       /* this fixes {\n, \t, `, &} characters in elements */
+
+                                       /* horible kludge to fix the <ns2:objectiveDesc xmlns:ns2="http://www.utoronto.ca/atrc/tile/xsd/tile_objective"> */
+                                       /* from TILE */
+                                       if (in_array('accessForAllResource', $element_path)){
+                                               //skip this tag
+                                       } elseif ($element_path[count($element_path)-1] != 'ns1:objectiveDesc') {
+                                               $items[$current_item_id]['title'] .= $data;
+                                       }
+       
+                               } else {
+                                       $order[$parent_item_id] ++;
+                                       $item_tmpl = array(     'title'                         => $data,
+                                                                               'parent_content_id' => $parent_item_id,
+                                                                               'ordering'                      => $order[$parent_item_id]-1);
+                                       //append other array values if it exists
+                                       if (is_array($items[$current_item_id])){
+                                               $items[$current_item_id] = array_merge($items[$current_item_id], $item_tmpl);
+                                       } else {
+                                               $items[$current_item_id] = $item_tmpl;
+                                       }
+                               }
+                       }
+               }
+
+               $my_data .= $data;
+       }
+
+       /* glossary parser: */
+       function glossaryStartElement($parser, $name, $attrs) {
+               global $element_path;
+
+               array_push($element_path, $name);
+       }
+
+       /* called when an element ends */
+       /* removed the current element from the $path */
+       function glossaryEndElement($parser, $name) {
+               global $element_path, $my_data, $imported_glossary;
+               static $current_term;
+
+               if ($element_path === array('glossary', 'item', 'term') || 
+                       $element_path === array('glossary:glossary', 'item', 'term')) {
+                       $current_term = $my_data;
+
+               } else if ($element_path === array('glossary', 'item', 'definition') || 
+                                  $element_path === array('glossary:glossary', 'item', 'definition')) {
+                       $imported_glossary[trim($current_term)] = trim($my_data);
+               }
+
+               array_pop($element_path);
+               $my_data = '';
+       }
+
+       function glossaryCharacterData($parser, $data){
+               global $my_data;
+
+               $my_data .= $data;
+       }
+
+if (!isset($_POST['submit']) && !isset($_POST['cancel'])) {
+       /* just a catch all */
+       
+       $errors = array('FILE_MAX_SIZE', ini_get('post_max_size'));
+       $msg->addError($errors);
+
+       header('Location: ./index.php');
+       exit;
+} else if (isset($_POST['cancel'])) {
+       $msg->addFeedback('IMPORT_CANCELLED');
+
+       header('Location: ./index.php');
+       exit;
+}
+
+$cid = intval($_POST['cid']);
+
+if (isset($_POST['url']) && ($_POST['url'] != 'http://') ) {
+       if ($content = @file_get_contents($_POST['url'])) {
+
+               // save file to /content/
+               $filename = substr(time(), -6). '.zip';
+               $full_filename = AT_CONTENT_DIR . $filename;
+
+               if (!$fp = fopen($full_filename, 'w+b')) {
+                       echo "Cannot open file ($filename)";
+                       exit;
+               }
+
+               if (fwrite($fp, $content, strlen($content) ) === FALSE) {
+                       echo "Cannot write to file ($filename)";
+                       exit;
+               }
+               fclose($fp);
+       }       
+       $_FILES['file']['name']     = $filename;
+       $_FILES['file']['tmp_name'] = $full_filename;
+       $_FILES['file']['size']     = strlen($content);
+       unset($content);
+       $url_parts = pathinfo($_POST['url']);
+       $package_base_name_url = $url_parts['basename'];
+}
+$ext = pathinfo($_FILES['file']['name']);
+$ext = $ext['extension'];
+
+if ($ext != 'zip') {
+       $msg->addError('IMPORTDIR_IMS_NOTVALID');
+} else if ($_FILES['file']['error'] == 1) {
+       $errors = array('FILE_MAX_SIZE', ini_get('upload_max_filesize'));
+       $msg->addError($errors);
+} else if ( !$_FILES['file']['name'] || (!is_uploaded_file($_FILES['file']['tmp_name']) && !$_POST['url'])) {
+       $msg->addError('FILE_NOT_SELECTED');
+} else if ($_FILES['file']['size'] == 0) {
+       $msg->addError('IMPORTFILE_EMPTY');
+} 
+
+if ($msg->containsErrors()) {
+       if (isset($_GET['tile'])) {
+               header('Location: '.$_base_path.'tools/tile/index.php');
+       } else {
+               header('Location: index.php');
+       }
+       exit;
+}
+
+/* check if ../content/import/ exists */
+$import_path = AT_CONTENT_DIR . 'import/';
+$content_path = AT_CONTENT_DIR;
+
+if (!is_dir($import_path)) {
+       if (!@mkdir($import_path, 0700)) {
+               $msg->addError('IMPORTDIR_FAILED');
+       }
+}
+
+$import_path .= $_SESSION['course_id'].'/';
+if (is_dir($import_path)) {
+       clr_dir($import_path);
+}
+
+if (!@mkdir($import_path, 0700)) {
+       $msg->addError('IMPORTDIR_FAILED');
+}
+
+if ($msg->containsErrors()) {
+       if (isset($_GET['tile'])) {
+               header('Location: '.$_base_path.'tools/tile/index.php');
+       } else {
+               header('Location: index.php');
+       }
+       exit;
+}
+
+/* extract the entire archive into AT_COURSE_CONTENT . import/$course using the call back function to filter out php files */
+error_reporting(0);
+$archive = new PclZip($_FILES['file']['tmp_name']);
+if ($archive->extract( PCLZIP_OPT_PATH,        $import_path,
+                                               PCLZIP_CB_PRE_EXTRACT,  'preImportCallBack') == 0) {
+       $msg->addError('IMPORT_FAILED');
+       echo 'Error : '.$archive->errorInfo(true);
+       clr_dir($import_path);
+       header('Location: index.php');
+       exit;
+}
+error_reporting(AT_ERROR_REPORTING);
+
+/* get the course's max_quota */
+$sql   = "SELECT max_quota FROM ".TABLE_PREFIX."courses WHERE course_id=$_SESSION[course_id]";
+$result = mysql_query($sql, $db);
+$q_row = mysql_fetch_assoc($result);
+
+if ($q_row['max_quota'] != AT_COURSESIZE_UNLIMITED) {
+
+       if ($q_row['max_quota'] == AT_COURSESIZE_DEFAULT) {
+               $q_row['max_quota'] = $MaxCourseSize;
+       }
+       $totalBytes   = dirsize($import_path);
+       $course_total = dirsize(AT_CONTENT_DIR . $_SESSION['course_id'].'/');
+       $total_after  = $q_row['max_quota'] - $course_total - $totalBytes + $MaxCourseFloat;
+
+       if ($total_after < 0) {
+               /* remove the content dir, since there's no space for it */
+               $errors = array('NO_CONTENT_SPACE', number_format(-1*($total_after/AT_KBYTE_SIZE), 2 ) );
+               $msg->addError($errors);
+               
+               clr_dir($import_path);
+
+               if (isset($_GET['tile'])) {
+                       header('Location: '.$_base_path.'tools/tile/index.php');
+               } else {
+                       header('Location: index.php');
+               }
+               exit;
+       }
+}
+
+
+$items = array(); /* all the content pages */
+$order = array(); /* keeps track of the ordering for each content page */
+$path  = array();  /* the hierarchy path taken in the menu to get to the current item in the manifest */
+$dependency_files = array(); /* the file path for the dependency files */
+
+/*
+$items[content_id/resource_id] = array(
+                                                                       'title'
+                                                                       'real_content_id' // calculated after being inserted
+                                                                       'parent_content_id'
+                                                                       'href'
+                                                                       'ordering'
+                                                                       );
+*/
+$ims_manifest_xml = @file_get_contents($import_path.'imsmanifest.xml');
+//scan for manifest xml if it's not on the top level.
+if ($ims_manifest_xml === false){
+       $data = rscandir($import_path);
+       $manifest_array = array();
+       foreach($data as $scanned_file){
+               $scanned_file = realpath($scanned_file);
+               //change the file string to an array
+               $this_file_array = explode(DIRECTORY_SEPARATOR, $scanned_file);
+               if(empty($manifest_array)){
+                       $manifest_array = $this_file_array;
+               }
+               $manifest_array = array_intersect_assoc($this_file_array, $manifest_array);
+
+               if (strpos($scanned_file, 'imsmanifest')!==false){
+                       $ims_manifest_xml = @file_get_contents($scanned_file);
+               }
+       }
+       if ($ims_manifest_xml !== false){
+               $import_path = implode(DIRECTORY_SEPARATOR, $manifest_array) . DIRECTORY_SEPARATOR;
+       }
+}
+
+//if no imsmanifest.xml found in the entire package, throw error.
+if ($ims_manifest_xml === false) {
+       $msg->addError('NO_IMSMANIFEST');
+
+       if (file_exists($import_path . 'atutor_backup_version')) {
+               $msg->addError('NO_IMS_BACKUP');
+       }
+       clr_dir($import_path);
+
+       if (isset($_GET['tile'])) {
+               header('Location: '.$_base_path.'tools/tile/index.php');
+       } else {
+               header('Location: index.php');
+       }
+       exit;
+}
+
+$xml_parser = xml_parser_create();
+
+xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
+xml_set_element_handler($xml_parser, 'startElement', 'endElement');
+xml_set_character_data_handler($xml_parser, 'characterData');
+
+if (!xml_parse($xml_parser, $ims_manifest_xml, true)) {
+       die(sprintf("XML error: %s at line %d",
+                               xml_error_string(xml_get_error_code($xml_parser)),
+                               xml_get_current_line_number($xml_parser)));
+}
+xml_parser_free($xml_parser);
+/* check if the glossary terms exist */
+$glossary_path = '';
+if ($content_type == 'IMS Common Cartridge'){
+       $glossary_path = 'resources/GlossaryItem/';
+//     $package_base_path = '';
+}
+if (file_exists($import_path . $glossary_path . 'glossary.xml')){
+       $glossary_xml = @file_get_contents($import_path.$glossary_path.'glossary.xml');
+       $element_path = array();
+       $xml_parser = xml_parser_create();
+
+       /* insert the glossary terms into the database (if they're not in there already) */
+       /* parse the glossary.xml file and insert the terms */
+       xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); /* conform to W3C specs */
+       xml_set_element_handler($xml_parser, 'glossaryStartElement', 'glossaryEndElement');
+       xml_set_character_data_handler($xml_parser, 'glossaryCharacterData');
+
+       if (!xml_parse($xml_parser, $glossary_xml, true)) {
+               die(sprintf("XML error: %s at line %d",
+                                       xml_error_string(xml_get_error_code($xml_parser)),
+                                       xml_get_current_line_number($xml_parser)));
+       }
+       xml_parser_free($xml_parser);
+       $contains_glossary_terms = true;
+       foreach ($imported_glossary as $term => $defn) {
+               if (!$glossary[$term]) {
+                       $sql = "INSERT INTO ".TABLE_PREFIX."glossary VALUES (NULL, $_SESSION[course_id], '$term', '$defn', 0)";
+                       mysql_query($sql, $db); 
+               }
+       }
+}
+
+// Check if all the files exists in the manifest, iff it's a IMS CC package.
+if ($content_type == 'IMS Common Cartridge') {
+       checkResources($import_path);
+}
+
+// Check if there are any errors during parsing.
+if ($msg->containsErrors()) {
+       if (isset($_GET['tile'])) {
+               header('Location: '.$_base_path.'tools/tile/index.php');
+       } else {
+               header('Location: index.php');
+       }
+       exit;
+}
+
+/* generate a unique new package base path based on the package file name and date as needed. */
+/* the package name will be the dir where the content for this package will be put, as a result */
+/* the 'content_path' field in the content table will be set to this path. */
+/* $package_base_name_url comes from the URL file name (NOT the file name of the actual file we open)*/
+if (!$package_base_name && $package_base_name_url) {
+       $package_base_name = substr($package_base_name_url, 0, -4);
+} else if (!$package_base_name) {
+       $package_base_name = substr($_FILES['file']['name'], 0, -4);
+}
+
+$package_base_name = strtolower($package_base_name);
+$package_base_name = str_replace(array('\'', '"', ' ', '|', '\\', '/', '<', '>', ':'), '_' , $package_base_name);
+$package_base_name = preg_replace("/[^A-Za-z0-9._\-]/", '', $package_base_name);
+
+if (is_dir(AT_CONTENT_DIR . $_SESSION['course_id'].'/'.$package_base_name)) {
+       $package_base_name .= '_'.date('ymdHis');
+}
+
+if ($package_base_path) {
+       $package_base_path = implode('/', $package_base_path);
+} elseif (empty($package_base_path)){
+       $package_base_path = '';
+}
+
+if ($xml_base_path) {
+       $package_base_path = $xml_base_path . $package_base_path;
+
+       mkdir(AT_CONTENT_DIR .$_SESSION['course_id'].'/'.$xml_base_path);
+       $package_base_name = $xml_base_path . $package_base_name;
+}
+
+/* get the top level content ordering offset */
+$sql   = "SELECT MAX(ordering) AS ordering FROM ".TABLE_PREFIX."content WHERE course_id=$_SESSION[course_id] AND content_parent_id=$cid";
+$result = mysql_query($sql, $db);
+$row   = mysql_fetch_assoc($result);
+$order_offset = intval($row['ordering']); /* it's nice to have a real number to deal with */
+$lti_offset = array(); //since we don't need lti tools, the ordering needs to be subtracted
+//reorder the items stack
+$items = rehash($items);
+//debug($items);exit;
+foreach ($items as $item_id => $content_info) 
+{      
+       //formatting field, default 1
+       $content_formatting = 1;        //CONTENT_TYPE_CONTENT
+
+       //don't want to display glossary as a page
+       if ($content_info['href']== $glossary_path . 'glossary.xml'){
+               continue;
+       }
+
+       //if discussion tools, add it to the list of unhandled dts
+       if ($content_info['type']=='imsdt_xmlv1p0'){
+               //if it will be taken care after (has dependency), then move along.
+               if (in_array($item_id, $avail_dt)){
+                       $lti_offset[$content_info['parent_content_id']]++;
+                       continue;
+               }
+       }
+
+       //handle the special case of cc import, where there is no content association. The resource should
+       //still be imported.
+       if(!isset($content_info['parent_content_id'])){
+               //if this is a question bank 
+               if ($content_info['type']=="imsqti_xmlv1p2/imscc_xmlv1p0/question-bank"){
+                       addQuestions($content_info['href'], $content_info, $import_path);
+               }
+       }
+
+       //if it has no title, most likely it is not a page but just a normal item, skip it
+       if (!isset($content_info['title'])){
+               continue;
+       }
+       
+       //check dependency immediately, then handles it
+       $head = '';
+       if (is_array($content_info['dependency']) && !empty($content_info['dependency'])){
+               foreach($content_info['dependency'] as $dependency_ref){
+                       //handle styles 
+                       /** handled by get_html_head in vitals.inc.php
+                       if (preg_match('/(.*)\.css$/', $items[$dependency_ref]['href'])){
+                               //calculate where this is based on our current base_href. 
+                               //assuming the dependency folders are siblings of the item
+                               $head = '<link rel="stylesheet" type="text/css" href="../'.$items[$dependency_ref]['href'].'" />';
+                       }
+                       */
+                       //check if this is a discussion tool dependency
+                       if ($items[$dependency_ref]['type']=='imsdt_xmlv1p0'){
+                               $items[$item_id]['forum'][$dependency_ref] = $items[$dependency_ref]['href'];
+                       }
+                       //check if this is a QTI dependency
+                       if (strpos($items[$dependency_ref]['type'], 'imsqti_xmlv1p2/imscc_xmlv1p0') !== false){
+                               $items[$item_id]['tests'][$dependency_ref] = $items[$dependency_ref]['href'];
+                       }
+               }
+       }
+
+       //check file array, see if there are css. 
+       //edited nov 26, harris
+       //removed cuz i added link to the html_tags
+       /*
+       if (is_array($content_info['file']) && !empty($content_info['file'])){
+               foreach($content_info['file'] as $dependency_ref){
+                       //handle styles 
+                       if (preg_match('/(.*)\.css$/', $dependency_ref)){
+                               //calculate where this is based on our current base_href. 
+                               //assuming the dependency folders are siblings of the item
+                               $head = '<link rel="stylesheet" type="text/css" href="'.$dependency_ref.'" />';
+                       }
+               }
+       }
+       */
+
+       // remote href
+       if (preg_match('/^http.*:\/\//', trim($content_info['href'])) )
+       {
+               $content = '<a href="'.$content_info['href'].'" target="_blank">'.$content_info['title'].'</a>';
+       }
+       else
+       {
+               if ($content_type == 'IMS Common Cartridge'){
+                       //to handle import with purely images but nothing else
+                       //don't need a content base path for it.
+                       $content_new_path = $content_info['new_path'];
+                       $content_info['new_path'] = '';
+               }
+               if (isset($content_info['href'], $xml_base_path)) {
+                       $content_info['href'] = $xml_base_path . $content_info['href'];
+               }
+               if (!isset($content_info['href'])) {
+                       // this item doesn't have an identifierref. so create an empty page.
+                       // what we called a folder according to v1.2 Content Packaging spec
+                       // Hop over
+                       $content = '';
+                       $ext = '';
+                       $last_modified = date('Y-m-d H:i:s');
+               } else {
+                       //$file_info = @stat(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$content_info['href']);
+                       $file_info = @stat($import_path.$content_info['href']);
+                       if ($file_info === false) {
+                               continue;
+                       }
+               
+                       //$path_parts = pathinfo(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$content_info['href']);
+                       $path_parts = pathinfo($import_path.$content_info['href']);
+                       $ext = strtolower($path_parts['extension']);
+
+                       $last_modified = date('Y-m-d H:i:s', $file_info['mtime']);
+               }
+               if (in_array($ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg'))) {
+                       /* this is an image */
+                       $content = '<img src="'.$content_info['href'].'" alt="'.$content_info['title'].'" />';
+               } else if ($ext == 'swf') {
+                       /* this is flash */
+            /* Using default size of 550 x 400 */
+
+                       $content = '<object type="application/x-shockwave-flash" data="' . $content_info['href'] . '" width="550" height="400"><param name="movie" value="'. $content_info['href'] .'" /></object>';
+
+               } else if ($ext == 'mov') {
+                       /* this is a quicktime movie  */
+            /* Using default size of 550 x 400 */
+
+                       $content = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="550" height="400" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'. $content_info['href'] . '" /><param name="autoplay" value="true" /><param name="controller" value="true" /><embed src="' . $content_info['href'] .'" width="550" height="400" controller="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
+
+               /* Oct 19, 2009
+                * commenting this whole chunk out.  It's part of my test import codes, not sure why it's here, 
+                * and I don't think it should be here.  Remove this whole comment after further testing and confirmation.
+                * @harris
+                *
+                       //Mimic the array for now.
+                       $test_attributes['resource']['href'] = $test_xml_file;
+                       $test_attributes['resource']['type'] = isset($items[$item_id]['type'])?'imsqti_xmlv1p2':'imsqti_xmlv1p1';
+                       $test_attributes['resource']['file'] = $items[$item_id]['file'];
+//                     $test_attributes['resource']['file'] = array($test_xml_file);
+
+                       //Get the XML file out and start importing them into our database.
+                       //TODO: See question_import.php 287-289.
+                       $qids = $qti_import->importQuestions($test_attributes);
+               
+                */
+               } else if ($ext == 'mp3') {
+                       $content = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="200" height="15" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="'. $content_info['href'] . '" /><param name="autoplay" value="false" /><embed src="' . $content_info['href'] .'" width="200" height="15" autoplay="false" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';
+               } else if (in_array($ext, array('wav', 'au'))) {
+                       $content = '<embed SRC="'.$content_info['href'].'" autostart="false" width="145" height="60"><noembed><bgsound src="'.$content_info['href'].'"></noembed></embed>';
+
+               } else if (in_array($ext, array('txt', 'css', 'html', 'htm', 'csv', 'asc', 'tsv', 'xml', 'xsl'))) {
+                       if ($content_type == 'IMS Common Cartridge'){
+                               $content_info['new_path'] = $content_new_path;
+                       }
+
+                       /* this is a plain text file */
+                       //$content = file_get_contents(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$content_info['href']);
+                       $content = file_get_contents($import_path.$content_info['href']);
+                       if ($content === false) {
+                               /* if we can't stat() it then we're unlikely to be able to read it */
+                               /* so we'll never get here. */
+                               continue;
+                       }
+
+                       // get the contents of the 'head' element
+                       $head .= get_html_head_by_tag($content, $html_head_tags);
+                       
+                       // Specifically handle eXe package
+                       // NOTE: THIS NEEDS WORK! TO FIND A WAY APPLY EXE .CSS FILES ONLY ON COURSE CONTENT PART.
+                       // NOW USE OUR OWN .CSS CREATED SOLELY FOR EXE
+                       $isExeContent = false;
+
+                       // check xml file in eXe package
+                       if (preg_match("/<organization[ ]*identifier=\"eXe*>*/", $ims_manifest_xml))
+                       {
+                               $isExeContent = true;
+                       }
+
+                       // use ATutor's eXe style sheet as the ones from eXe conflicts with ATutor's style sheets
+                       if ($isExeContent)
+                       {
+                               $head = preg_replace ('/(<style.*>)(.*)(<\/style>)/ms', '\\1@import url(/docs/exestyles.css);\\3', $head);
+                       }
+
+                       // end of specifically handle eXe package
+
+                       $content = get_html_body($content);
+                       if ($contains_glossary_terms) 
+                       {
+                               // replace glossary content package links to real glossary mark-up using [?] [/?]
+                               // refer to bug 3641, edited by Harris
+                               $content = preg_replace('/<a href="([.\w\d\s]+[^"]+)" target="body" class="at-term">([.\w\d\s&;"]+|.*)<\/a>/i', '[?]\\2[/?]', $content);
+                       }
+
+                       /* potential security risk? */
+                       if ( strpos($content_info['href'], '..') === false && !preg_match('/((.*)\/)*tests\_[0-9]+\.xml$/', $content_info['href'])) {
+//                             @unlink(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$content_info['href']);
+                       }
+
+                       /* overwrite content if this is discussion tool. */
+                       if ($content_info['type']=='imsdt_xmlv1p0'){
+                               $dt_parser = new DiscussionToolsParser();
+                               $xml_content = @file_get_contents($import_path . $content_info['href']);
+                               $dt_parser->parse($xml_content);
+                               $forum_obj = $dt_parser->getDt();
+                               $content = $forum_obj->getText();
+                               unset($forum_obj);
+                               $dt_parser->close();
+                       }
+               } else if ($ext) {
+                       /* non text file, and can't embed (example: PDF files) */
+                       $content = '<a href="'.$content_info['href'].'">'.$content_info['title'].'</a>';
+               }       
+       }
+       $content_parent_id = $cid;
+       if ($content_info['parent_content_id'] !== 0) {
+               $content_parent_id = $items[$content_info['parent_content_id']]['real_content_id'];
+               //if it's not there, use $cid
+               if (!$content_parent_id){
+                       $content_parent_id = $cid;
+               }
+       }
+
+       $my_offset = 0;
+       if ($content_parent_id == $cid) {
+               $my_offset = $order_offset;
+       }
+
+       /* replace the old path greatest common denomiator with the new package path. */
+       /* we don't use str_replace, b/c there's no knowing what the paths may be         */
+       /* we only want to replace the first part of the path.  
+       */
+       if(is_array($all_package_base_path)){
+               $all_package_base_path = implode('/', $all_package_base_path);
+       }
+
+       if ($all_package_base_path != '') {
+               $content_info['new_path'] = $package_base_name . substr($content_info['new_path'], strlen($all_package_base_path));
+       } else {
+               $content_info['new_path'] = $package_base_name . '/' . $content_info['new_path'];
+       }
+
+       //handles weblinks
+       if ($content_info['type']=='imswl_xmlv1p0'){
+               $weblinks_parser = new WeblinksParser();
+               $xml_content = @file_get_contents($import_path . $content_info['href']);
+               $weblinks_parser->parse($xml_content);
+               $content_info['title'] = $weblinks_parser->getTitle();
+               $content = $weblinks_parser->getUrl();
+               $content_folder_type = CONTENT_TYPE_WEBLINK;
+               $content_formatting = 2;
+       }
+       $head = addslashes($head);
+       $content_info['title'] = addslashes($content_info['title']);
+       $content_info['test_message'] = addslashes($content_info['test_message']);
+
+       //if this file is a test_xml, create a blank page instead, for imscc.
+       if (preg_match('/((.*)\/)*tests\_[0-9]+\.xml$/', $content_info['href']) 
+               || preg_match('/imsqti\_(.*)/', $content_info['type'])) {
+               $content = ' ';
+       } else {
+               $content = addslashes($content);
+       }
+
+       //check for content_type
+       if ($content_formatting!=CONTENT_TYPE_WEBLINK){
+               $content_folder_type = (!isset($content_info['type'])?CONTENT_TYPE_FOLDER:CONTENT_TYPE_CONTENT);
+       }
+
+       $sql= 'INSERT INTO '.TABLE_PREFIX.'content'
+             . '(course_id, 
+                 content_parent_id, 
+                 ordering,
+                 last_modified, 
+                 revision, 
+                 formatting, 
+                 release_date,
+                 head,
+                 use_customized_head,
+                 keywords, 
+                 content_path, 
+                 title, 
+                 text,
+                         test_message,
+                         content_type) 
+              VALUES 
+                            ('.$_SESSION['course_id'].','                                                                                                                      
+                            .intval($content_parent_id).','            
+                            .($content_info['ordering'] + $my_offset - $lti_offset[$content_info['parent_content_id']] + 1).','
+                            .'"'.$last_modified.'",                                                                                                    
+                             0,'
+                            .$content_formatting.' ,
+                             NOW(),"'
+                            . $head .'",
+                            1,
+                             "",'
+                            .'"'.$content_info['new_path'].'",'
+                            .'"'.$content_info['title'].'",'
+                            .'"'.$content.'",'
+                                .'"'.$content_info['test_message'].'",'
+                                .$content_folder_type.')';
+
+       $result = mysql_query($sql, $db) or die(mysql_error());
+
+       /* get the content id and update $items */
+       $items[$item_id]['real_content_id'] = mysql_insert_id($db);
+
+       /* get the tests associated with this content */
+       if (!empty($items[$item_id]['tests']) || strpos($items[$item_id]['type'], 'imsqti_xmlv1p2/imscc_xmlv1p0') !== false){
+               $qti_import = new QTIImport($import_path);
+               if (isset($items[$item_id]['tests'])){
+                       $loop_var = $items[$item_id]['tests'];
+               } else {
+                       $loop_var = $items[$item_id]['file'];
+               }
+
+               foreach ($loop_var as $array_id => $test_xml_file){
+                       //check if this item is the qti item object, or it is the content item obj
+                       //switch it to qti obj if it's content item obj
+                       if ($items[$item_id]['type'] == 'webcontent'){
+                               $item_qti = $items[$array_id];
+                       } else {
+                               $item_qti = $items[$item_id];
+                       }
+                       //call subrountine to add the questions.
+                       $qids = addQuestions($test_xml_file, $item_qti, $import_path);
+
+                       //import test
+                       if ($test_title==''){
+                               $test_title = $content_info['title'];
+                       }
+
+                       $tid = $qti_import->importTest($test_title);
+
+                       //associate question and tests
+                       foreach ($qids as $order=>$qid){
+                               if (isset($qti_import->weights[$order])){
+                                       $weight = round($qti_import->weights[$order]);
+                               } else {
+                                       $weight = 0;
+                               }
+                               $new_order = $order + 1;
+                               $sql = "INSERT INTO " . TABLE_PREFIX . "tests_questions_assoc" . 
+                                               "(test_id, question_id, weight, ordering, required) " .
+                                               "VALUES ($tid, $qid, $weight, $new_order, 0)";
+                               $result = mysql_query($sql, $db);
+                       }
+
+                       //associate content and test
+                       $sql =  'INSERT INTO ' . TABLE_PREFIX . 'content_tests_assoc' . 
+                                       '(content_id, test_id) ' .
+                                       'VALUES (' . $items[$item_id]['real_content_id'] . ", $tid)";
+                       $result = mysql_query($sql, $db);
+               
+//                     if (!$msg->containsErrors()) {
+//                             $msg->addFeedback('IMPORT_SUCCEEDED');
+//                     }
+               }
+       }
+
+       /* get the a4a related xml */
+       if (isset($items[$item_id]['a4a_import_enabled']) && isset($items[$item_id]['a4a']) && !empty($items[$item_id]['a4a'])) {
+               $a4a_import = new A4aImport($items[$item_id]['real_content_id']);
+               $a4a_import->setRelativePath($items[$item_id]['new_path']);
+               $a4a_import->importA4a($items[$item_id]['a4a']);
+       }
+
+       /* get the discussion tools (dependent to content)*/
+       if (isset($items[$item_id]['forum']) && !empty($items[$item_id]['forum'])){
+               foreach($items[$item_id]['forum'] as $forum_ref => $forum_link){
+                       $dt_parser = new DiscussionToolsParser();
+                       $dt_import = new DiscussionToolsImport();
+
+                       //if this forum has not been added, parse it and add it.
+                       if (!isset($added_dt[$forum_ref])){
+                               $xml_content = @file_get_contents($import_path . $forum_link);
+                               $dt_parser->parse($xml_content);
+                               $forum_obj = $dt_parser->getDt();
+                               $dt_import->import($forum_obj, $items[$item_id]['real_content_id']);
+                               $added_dt[$forum_ref] = $dt_import->getFid();                           
+                       }
+                       //associate the fid and content id
+                       $dt_import->associateForum($items[$item_id]['real_content_id'], $added_dt[$forum_ref]);
+               }
+       } elseif ($items[$item_id]['type']=='imsdt_xmlv1p0'){
+               //optimize this, repeated codes as above
+               $dt_parser = new DiscussionToolsParser();
+               $dt_import = new DiscussionToolsImport();
+               $xml_content = @file_get_contents($import_path . $content_info['href']);
+               $dt_parser->parse($xml_content);
+               $forum_obj = $dt_parser->getDt();
+               $dt_import->import($forum_obj, $items[$item_id]['real_content_id']);
+               $added_dt[$item_id] = $dt_import->getFid();
+
+               //associate the fid and content id
+               $dt_import->associateForum($items[$item_id]['real_content_id'], $added_dt[$item_id]);
+       }
+}
+//exit;//harris
+if ($package_base_path == '.') {
+       $package_base_path = '';
+}
+
+// loop through the files outside the package folder, and copy them to its relative path
+if (is_dir(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/resources')) {
+       $handler = opendir(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/resources');
+       while ($file = readdir($handler)){
+               $filename = AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/resources/'.$file;
+               if(is_file($filename)){
+                       @rename($filename, AT_CONTENT_DIR .$_SESSION['course_id'].'/'.$package_base_name.'/'.$file);
+               }
+       }
+       closedir($handler);
+}
+//takes care of the condition where the whole package doesn't have any contents but question banks
+if(is_array($all_package_base_path)){
+       $all_package_base_path = implode('/', $all_package_base_path);
+}
+
+if (@rename($import_path.$all_package_base_path, AT_CONTENT_DIR .$_SESSION['course_id'].'/'.$package_base_name) === false) {
+       if (!$msg->containsErrors()) {
+               $msg->addError('IMPORT_FAILED');
+       }
+}
+//check if there are still resources missing
+foreach($items as $idetails){
+       $temp_path = pathinfo($idetails['href']);
+       @rename(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id'].'/'.$temp_path['dirname'], AT_CONTENT_DIR .$_SESSION['course_id'].'/'.$package_base_name . '/' . $temp_path['dirname']);
+}
+clr_dir(AT_CONTENT_DIR . 'import/'.$_SESSION['course_id']);
+
+if (isset($_POST['url'])) {
+       @unlink($full_filename);
+}
+
+
+if ($_POST['s_cid']){
+       if (!$msg->containsErrors()) {
+               $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+       }
+       header('Location: ../editor/edit_content.php?cid='.intval($_POST['cid']));
+       exit;
+} else {
+       if (!$msg->containsErrors()) {
+               $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
+       }
+       if ($_GET['tile']) {
+               header('Location: '.AT_BASE_HREF.'tools/tile/index.php');
+       } else {
+               header('Location: ./index.php?cid='.intval($_POST['cid']));
+       }
+       exit;
+}
+
+?>
diff --git a/docs/mods/_core/imscp/imscc_c1p2maeV0p15_definition.xsd b/docs/mods/_core/imscp/imscc_c1p2maeV0p15_definition.xsd
new file mode 100644 (file)
index 0000000..4f38ca9
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" targetNamespace="http://www.imsglobal.org/xsd/imscc/imscp_v1p1">\r
+  <xsd:import namespace="http://www.imsglobal.org/xsd/imscp_v1p1" schemaLocation="imscp_v1p2.xsd" />\r
+  <!--****************************************************************************************-->\r
+  <!--** Definition document - this document holds AP defined simpleType elements that have **-->\r
+  <!--** been referenced through a type attribute in one of the modified, resultant schema. **-->\r
+  <!--****************************************************************************************-->\r
+  <xs:simpleType name="schemaversionFixed">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="schemaFixed">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="rootedHierarchy">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="predefinedContentTypes">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+      <xs:enumeration value="imsdt_xmlv1p0" />\r
+      <xs:enumeration value="imswl_xmlv1p0" />\r
+      <xs:enumeration value="webcontent" />\r
+      <xs:enumeration value="imsqti_xmlv1p2/imscc_xmlv1p0/assessment" />\r
+      <xs:enumeration value="imsqti_xmlv1p2/imscc_xmlv1p0/question-bank" />\r
+      <xs:enumeration value="associatedcontent/imscc_xmlv1p0/learning-application-resource" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="isNotVisible">\r
+    <xs:restriction base="xs:boolean">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="defaultOrganizationProhibited">\r
+    <xs:restriction base="xs:IDREF">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="RequiredHref">\r
+    <xs:restriction base="xs:anyURI">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="ProhibitedHref">\r
+    <xs:restriction base="xs:anyURI">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="OptionalHref">\r
+    <xs:restriction base="xs:anyURI">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="NoParameters">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="NoParameter">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="NoIsVisible">\r
+    <xs:restriction base="xs:boolean">\r
+      <xs:whiteSpace value="collapse" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+  <xs:simpleType name="NoIdentifierRef">\r
+    <xs:restriction base="xs:string">\r
+      <xs:whiteSpace value="preserve" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+</xsd:schema>\r
+\r
diff --git a/docs/mods/_core/imscp/imscp_v1p2.xsd b/docs/mods/_core/imscp/imscp_v1p2.xsd
new file mode 100644 (file)
index 0000000..3260030
--- /dev/null
@@ -0,0 +1,329 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.imsglobal.org/xsd/imscp_v1p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.imsglobal.org/xsd/imscp_v1p1" version="IMS CP 1.2" elementFormDefault="qualified" attributeFormDefault="unqualified">\r
+    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" />\r
+    <xs:annotation>\r
+        <xs:documentation>\r
+            XSD Data File Information\r
+            -------------------------\r
+            Author:       CP1.2 Project Team\r
+            Date:         31st October, 2006\r
+            Version:      2.0\r
+            Status:       CM/DN Release\r
+            Description:  This is a normative representation of the IMS CP 1.2 Information Model for binding \r
+                          purposes.  Read the corresponding IMS CP Information Model for the Platform \r
+                          Independent Model representation.\r
+\r
+            History:      This is version 1 of the IMS CP v1.2 XSD.  It directly supercedes IMS CP v1.1.4 XSD.\r
+                          Note that the target namespace has NOT been changed.\r
+                          Apart from the functional additions, the main structural changes are:\r
+                          (1) All of the elements and attributes are defined as local to their host object;\r
+                          (2) Comments have been added to the complexType definitions.\r
+\r
+            Copyright:    2006 (c) IMS Global Learning Consortium Inc.  All Rights Reserved.\r
+                          IMS Global Learning Consortium, Inc. (IMS/GLC) is publishing the information\r
+                          contained in this binding ("Specification") for purposes of scientific\r
+                          experimental and scholarly collaboration only.  IMS/GLC makes no warranty or \r
+                          representation regarding the accuracy or completeness of the Specification.\r
+                          This material is provided on an "As Is" and "As Available basis".\r
+                          The Specification is at all times subject to change and revision without\r
+                          notice. It is your sole responsibility to evaluate the usefulness, accuracy\r
+                          and completeness of the Specification as it relates to you.  IMS/GLC would\r
+                          appreciate receiving your comments and suggestions.  Please contact IMS/GLC\r
+                          through our website at: http://www.imsglobal.org.\r
+\r
+            Source XSLT File Information\r
+            ----------------------------\r
+            XSL Generator:    UMLtoXSDTransformv0p7.xsl\r
+            XSLT Processor:   Xalan\r
+            Release:          1.0 Beta 1\r
+            Date:             30th November, 2005\r
+\r
+            Auto-generation Tool\r
+            --------------------\r
+            This WSDL/XSD was auto-generated using the IMS WSDL/XSD auto-generation tool.  While every attempt\r
+            has been made to ensure that this tool auto-generates the XSDs correctly, users should be aware\r
+            that this is an experimental tool.  Permission is given to make use of this tool.  IMS makes no\r
+            claim on the materials created by third party users of this tool.  Details on how to use this tool\r
+            are contained in the IMS document: "IMS General Web Services: WSDL/XSD Binding Auto-generation"\r
+            available at the IMS web-site.\r
+            Tool Copyright:  2005 (c) IMS Global Learning Consortium Inc.  All Rights Reserved.\r
+        </xs:documentation>\r
+    </xs:annotation>\r
+\r
+        <!-- Generate Global Attributes ***********************************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate Namespaced extension Group  *************************************************************  -->\r
+\r
+            <xs:group name="grpStrict.any">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        Any namespaced element from any namespace may be included within an "any" element.\r
+                        The namespace for the imported element must be defined in the instance, and the schema must be imported.\r
+                        The extension has a definition of "strict" i.e. they must have their own namespace.\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded" />\r
+                </xs:sequence>\r
+            </xs:group>\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the enumerated simpleType declarations **************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the simpleType elements based IMS data-types  *******************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the derived data-type elements **********************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the data-type elements ******************************************************************  -->\r
+\r
+            <xs:complexType name="Manifest.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A manifest element is a container for data structures whose contents describe a \r
+                        semantically complete instance of the IMS Content Packaging Information Model.  \r
+                        \r
+                        A manifest element may contain and reference child manifest elements \r
+                        in the same IMS Manifest document.  The root manifest element defines an \r
+                        entire IMS Package.  A child manifest element defines a semantically complete \r
+                        subset of that Package.\r
+\r
+                        <p>Represents a binding of the kinds of objects defined as children of ims-cp-imManifest : Manifest.[ ManifestMetadata, Organizations, Resources, Manifest, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="ManifestMetadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="organizations" type="Organizations.Type" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="resources" type="Resources.Type" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="manifest" type="Manifest.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="version" use="optional" type="xs:string" />\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Metadata.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An instance of the metadata element contains data structures \r
+                        that declare descriptive information about a metadata element's \r
+                        parent only.\r
+                        \r
+                        One or more different metadata models may be declared as\r
+                        child extensions of a metadata element.\r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imMetadata:  Metadata.[ Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="schema" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="schemaversion" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Organizations.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        The organizations element is a container for all data structures \r
+                        that describe the way or ways that information encapsulated by \r
+                        its parent manifest element is structured. \r
+\r
+                        <p>Represents of binding of the child objects of ims-cp-imOrganizations: Organizations.[ Organization, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="organization" type="Organization.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="default" use="optional" type="xs:IDREF" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Resources.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        The Resources element is a container for data structures containing \r
+                        references  to one or more assets.  Asset references may be grouped \r
+                        within a containing resources element in whatever manner seems best.\r
+                          \r
+                        The scope of referenced assets is specific to a resources element's parent \r
+                        manifest element only. \r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imResources: Resources.[ Resource, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="resource" type="Resource.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Organization.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An organization element is a container for all data structures relating \r
+                        to a particular way or view that information encapsulated by a \r
+                        grandparent manifest object is structured.  \r
+                        \r
+                        Multiple organization elements within the same parent organizations \r
+                        element are equivalent in purpose: Each shows a different way for \r
+                        structuring the same information declared within a grandparent \r
+                        manifest object.\r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-Organization: Organization[ Title, Item, Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="item" type="Item.Type" minOccurs="1" maxOccurs="unbounded" />\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="structure" use="optional" type="xs:string" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Resource.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A resource element is a container for a particular asset \r
+                        or collection of assets.  A resource may contain references \r
+                        to assets that are all of the same type or different types (i.e., file formats).\r
+                        \r
+                        The scope or boundary of an IMS Package is defined by the asset \r
+                        references collected into all resources containers associated with the\r
+                        root manifest element, whether as a child, direcdt descendant, or externally \r
+                        linked descendant. \r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imResource: Resource.[ Metadata, File, Dependency, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="file" type="File.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:element name="dependency" type="Dependency.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="type" use="required" type="xs:string" />\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:attribute name="href" use="optional" type="xs:anyURI" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Item.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An item element represents a structural node in a particular organization.  \r
+                        An item element may be a parent or sibling of other Item elements, \r
+                        each one representing a unique structural node.\r
+                        \r
+                        An organization has no meaning unless it has at least one Item element.\r
+\r
+                        <p>Represents a binding of the kinds of child objects of ims-cp-imItem: Item.[ Title, Item, Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="item" type="Item.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="identifierref" use="optional" type="xs:string" />\r
+                <xs:attribute name="isvisible" use="optional" type="xs:boolean" />\r
+                <xs:attribute name="parameters" use="optional" type="xs:string" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="File.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A file element declares a reference to a single asset.  The reference may\r
+                        be relative to the Package containing the file element or absolute \r
+                        (external to the Package).\r
+                        \r
+                        A file element may contain child extensions declaring alternative references\r
+                         to the same asset as that referenced by the file element's href attribute.\r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imFile: File.[ Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="href" use="required" type="xs:anyURI" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Dependency.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A dependency element provides a way to associate another collection of \r
+                        asset references within the scope of the dependency element's parent \r
+                        resource element.\r
+                        \r
+                        This element allows the parsimonious declaration of asset references.  \r
+                        Shared asset references can be declared once and associated many \r
+                        times through a Dependency element.\r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imDependency: Dependency.[ Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifierref" use="required" type="xs:string" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="ManifestMetadata.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        This metadata element contains data structures that declare \r
+                        descriptive information about an entire Package.\r
+                        \r
+                        One or more different metadata models may be declared as\r
+                        child extensions of a metadata element.\r
+                        \r
+                        The schema and schemaversion children define the kind or collection \r
+                        of metadata models being used.\r
+\r
+                        <p>Represents a binding of the kinds of child objects defined for ims-cp-imManifestMetadata:  ManifestMetadata.[ Schema, SchemaVersion, MetadataModel ]..</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="schema" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="schemaversion" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+            </xs:complexType>\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Declaration of the elements **********************************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Declaration of the root element(s) ***************************************************************  -->\r
+\r
+            <xs:element name="manifest" type="Manifest.Type" />\r
+\r
+        <!-- =====================================  -->\r
+\r
+</xs:schema>\r
diff --git a/docs/mods/_core/imscp/imscp_v1p2_constraintsDocument.scmt b/docs/mods/_core/imscp/imscp_v1p2_constraintsDocument.scmt
new file mode 100644 (file)
index 0000000..e23040d
--- /dev/null
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<schema xmlns="http://www.ascc.net/xml/schematron">\r
+  <ns prefix="xs" uri="http://www.w3.org/2001/XMLSchema" />\r
+  <ns prefix="xsd" uri="http://www.w3.org/2001/XMLSchema" />\r
+  <ns prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />\r
+  <ns prefix="ac" uri="http://iwm.uni-koblenz.de/xsd/tel_addc_v1p1" />\r
+  <ns prefix="ims" uri="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" />\r
+  <!--***********************************************************************************************-->\r
+  <!--** Constraints document - this document holds Schematron rules that have been generated from **-->\r
+  <!--** AP condition and assertion elements. IMPORTANT: If this document exists, it MUST be       **-->\r
+  <!--** used in the validation of instances derived from the resultant schema - failure to do so  **-->\r
+  <!--** can result in an instance that does not conform to either the base schema or the          **-->\r
+  <!--** Application Profile.                                                                      **-->\r
+  <!--***********************************************************************************************-->\r
+\r
+\r
+  <pattern name="pattern_3">\r
+    <rule context="ims:manifest/ims:resources/ims:resource/ims:dependency">\r
+      <assert test="(not(../@type='associatedcontent/imscc_xmlv1p0/learning-application-resource')) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='webcontent']/@identifier)">Assertion failed for pattern_3. A Resource object which is a Learning Object associated resource may contain Dependency objects which reference Resource objects with Type 'webcontent'.(#S03)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_4">\r
+    <rule context="ims:manifest/ims:organizations/ims:organization//ims:item">\r
+      <assert test="count(./@identifierref)=0 or count(./ims:item)=0">Assertion failed for pattern_4. An Item object which represents a folder is indicated by the absence of an IdentifierRef characteristic object. Folder Items support unlimited nesting of other folder Items and learning object link Items. Learning Application Resource Item objects may be nested by folder Item object but may not nest other folder or Learning Application resource Item objects.(#S04)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_5">\r
+       <rule context="ims:manifest/ims:resources/ims:resource">\r
+               <assert test="not((./@type='webcontent' or ./@type='associatedcontent/imscc_xmlv1p0/learning-application-resource') and ./@identifier = //ims:item/@identifierref) or count(./@href)=1">Error: Assertion failed for pattern_5: If a cartridge web content or associated content resource is linked from a Learning Application Object link Item object it must have an Href characteristic object which represents the launchable resource.(#S05)</assert>\r
+       </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_6">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsdt_xmlv1p0') or (count(./ims:file)= 1 and count(./@href)=0)">Error: Assertion failed for pattern_5: For Discussion Topic Resources the Resource object must contain a single File object which references the Discussion Topic descriptor XML file which conforms to the http://www.imsglobal.org/xsd/imsdt_v1p0 schema. Discussion Topic resources must not contain href (#S06)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_7">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imswl_xmlv1p0') or (count(./ims:file) = 1 and count(./ims:dependency)=0 and count(./@href)=0)">Error: Assertion validation failed for pattern_7: For Web Link Resources the Resource object must contain a single File object which references the Web Link descriptor XML file which conforms to the http://www.imsglobal.org/xsd/imswl_v1p0 schema.It must contain neither Dependency objects nor an href attribute.(#S07)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+\r
+  <pattern name="pattern_11a">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsqti_xmlv1p2/imscc_xmlv1p0/assessment') or (count(./ims:file) = 1 and count(./@href)=0)">Error: Assertion validation failed for pattern_11a: For Assessment resources the Resource object must contain a single File object which references the QTI XML file. This file must conform to the IMS CC profile of QTI 1.2.1. The profile is contained in the package of this profile as imscc_q*.zip. The derived schema of this QTI profile is in the package of this profile with the name ims_qtiasiv1p2_localised.xsd. The resource must not have an href attribute(#S11a)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_11b1">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank') or (count(./ims:file) = 1 )">Error: Assertion validation failed for pattern_11b1: For Question Bank resources the Resource object must contain a single File object which references the QTI XML file. (#S11b1)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_11b2">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank') or (count(./@href)=0 )">Error: Assertion validation failed for pattern_11b2: A Question Bank Resource must not have an href attribute. (#S11b2)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_11b3">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank') or ( not(//ims:item[@identifierref]=./@identifier) )">Error: Assertion validation failed for pattern_11b3:  A Question Bank Resource must not be referenced from an item. (#S11b3)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_11b4">\r
+    <rule context="ims:manifest/ims:resources/ims:resource">\r
+      <assert test="not(./@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank') or (count(//ims:resource[@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank'])=1)">Error: Assertion validation failed for pattern_11b4: There can be only one Questionbank Resource in a cartridge.(#S11b4)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_12">\r
+    <rule context="ims:manifest/ims:resources/ims:resource/ims:dependency">\r
+      <assert test="(not(../@type='imsdt_xmlv1p0')) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='webcontent']/@identifier) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='associatedcontent/imscc_xmlv1p0/learning-application-resource']/@identifier)">Assertion failed for pattern_12. A Resource object which is a Discussion Topic associated resource may contain Dependency objects which reference Resource objects with Type 'webcontent' or 'associatedcontent/imscc_xmlv1p0/learning-application-resource'.(#S12)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_14">\r
+    <rule context="ims:manifest/ims:resources/ims:resource/ims:dependency">\r
+      <assert test="(not(../@type='imsqti_xmlv1p2/imscc_xmlv1p0/assessment')) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='webcontent']/@identifier) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='associatedcontent/imscc_xmlv1p0/learning-application-resource']/@identifier)">Assertion failed for pattern_14. A Resource object which is an assessment may contain Dependency objects which reference Resource objects with Type 'webcontent' or 'associatedcontent/imscc_xmlv1p0/learning-application-resource'.(#S14)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  <pattern name="pattern_15">\r
+    <rule context="ims:manifest/ims:resources/ims:resource/ims:dependency">\r
+      <assert test="(not(../@type='imsqti_xmlv1p2/imscc_xmlv1p0/question-bank')) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='webcontent']/@identifier) or (current()/@identifierref = /ims:manifest/ims:resources/ims:resource[@type='associatedcontent/imscc_xmlv1p0/learning-application-resource']/@identifier)">Assertion failed for pattern_15. A Resource object which is a Question Bank may contain Dependency objects which reference Resource objects with Type 'webcontent' or 'associatedcontent/imscc_xmlv1p0/learning-application-resource'.(#S15)</assert>\r
+    </rule>\r
+  </pattern>\r
+\r
+  </schema>
\ No newline at end of file
diff --git a/docs/mods/_core/imscp/imscp_v1p2_localised.xsd b/docs/mods/_core/imscp/imscp_v1p2_localised.xsd
new file mode 100644 (file)
index 0000000..c8a87f1
--- /dev/null
@@ -0,0 +1,401 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--*************************************************************************-->\r
+<!--** This schema has been modified from the original base schema named - **-->\r
+<!--** imscp_v1p2.xsd                                                      **-->\r
+<!--** using the IMS SchemaProf tool. This tool is based on software from  **-->\r
+<!--** the TELCERT Project which was funded in part by the European        **-->\r
+<!--** Commission under contract IST-507128                                **-->\r
+<!--*************************************************************************-->\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" targetNamespace="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" version="IMS CP 1.2 localised_Schema_2008_6_30" elementFormDefault="qualified" attributeFormDefault="unqualified" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsccauth_v1p0 domainProfile_0\imsccauth_v1p0_localised.xsd http://ltsc.ieee.org/xsd/imscc/LOM domainProfile_1\lomLoose_localised.xsd http://ltsc.ieee.org/xsd/LOM domainProfile_2\lomLoose_localised.xsd http://www.imsglobal.org/xsd/imscp_extensionv1p2 domainProfile_3\imscp_extensionv1p2_localised.xsd">\r
+       <xsd:include xmlns:xsd="http://www.w3.org/2001/XMLSchema" schemaLocation="imscc_c1p2maeV0p15_definition.xsd" />\r
+    <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" />\r
+    <xs:annotation>\r
+        <xs:documentation>\r
+            XSD Data File Information\r
+            -------------------------\r
+            Author:       CP1.2 Project Team\r
+            Date:         31st October, 2006\r
+            Version:      2.0\r
+            Status:       CM/DN Release\r
+            Description:  This is a normative representation of the IMS CP 1.2 Information Model for binding \r
+                          purposes.  Read the corresponding IMS CP Information Model for the Platform \r
+                          Independent Model representation.\r
+\r
+            History:      This is version 1 of the IMS CP v1.2 XSD.  It directly supercedes IMS CP v1.1.4 XSD.\r
+                          Note that the target namespace has NOT been changed.\r
+                          Apart from the functional additions, the main structural changes are:\r
+                          (1) All of the elements and attributes are defined as local to their host object;\r
+                          (2) Comments have been added to the complexType definitions.\r
+\r
+            Copyright:    2006 (c) IMS Global Learning Consortium Inc.  All Rights Reserved.\r
+                          IMS Global Learning Consortium, Inc. (IMS/GLC) is publishing the information\r
+                          contained in this binding ("Specification") for purposes of scientific\r
+                          experimental and scholarly collaboration only.  IMS/GLC makes no warranty or \r
+                          representation regarding the accuracy or completeness of the Specification.\r
+                          This material is provided on an "As Is" and "As Available basis".\r
+                          The Specification is at all times subject to change and revision without\r
+                          notice. It is your sole responsibility to evaluate the usefulness, accuracy\r
+                          and completeness of the Specification as it relates to you.  IMS/GLC would\r
+                          appreciate receiving your comments and suggestions.  Please contact IMS/GLC\r
+                          through our website at: http://www.imsglobal.org.\r
+\r
+            Source XSLT File Information\r
+            ----------------------------\r
+            XSL Generator:    UMLtoXSDTransformv0p7.xsl\r
+            XSLT Processor:   Xalan\r
+            Release:          1.0 Beta 1\r
+            Date:             30th November, 2005\r
+\r
+            Auto-generation Tool\r
+            --------------------\r
+            This WSDL/XSD was auto-generated using the IMS WSDL/XSD auto-generation tool.  While every attempt\r
+            has been made to ensure that this tool auto-generates the XSDs correctly, users should be aware\r
+            that this is an experimental tool.  Permission is given to make use of this tool.  IMS makes no\r
+            claim on the materials created by third party users of this tool.  Details on how to use this tool\r
+            are contained in the IMS document: "IMS General Web Services: WSDL/XSD Binding Auto-generation"\r
+            available at the IMS web-site.\r
+            Tool Copyright:  2005 (c) IMS Global Learning Consortium Inc.  All Rights Reserved.\r
+        </xs:documentation>\r
+    </xs:annotation>\r
+\r
+        <!-- Generate Global Attributes ***********************************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate Namespaced extension Group  *************************************************************  -->\r
+\r
+            <xs:group name="grpStrict.any">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        Any namespaced element from any namespace may be included within an "any" element.\r
+                        The namespace for the imported element must be defined in the instance, and the schema must be imported.\r
+                        The extension has a definition of "strict" i.e. they must have their own namespace.\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="0" />\r
+                </xs:sequence>\r
+            </xs:group>\r
+<xs:group name="grpStrict.any3535">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        Any namespaced element from any namespace may be included within an "any" element.\r
+                        The namespace for the imported element must be defined in the instance, and the schema must be imported.\r
+                        The extension has a definition of "strict" i.e. they must have their own namespace.\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:any namespace=" http://ltsc.ieee.org/xsd/LOM" processContents="strict" minOccurs="0" maxOccurs="unbounded" />\r
+                </xs:sequence>\r
+            </xs:group>\r
+<xs:group name="grpStrict.any4935">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        Any namespaced element from any namespace may be included within an "any" element.\r
+                        The namespace for the imported element must be defined in the instance, and the schema must be imported.\r
+                        The extension has a definition of "strict" i.e. they must have their own namespace.\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:any namespace=" http://ltsc.ieee.org/xsd/imscc/LOM" processContents="strict" minOccurs="0" maxOccurs="unbounded" />\r
+                </xs:sequence>\r
+            </xs:group>\r
+<xs:group name="grpStrict.any2939">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        Any namespaced element from any namespace may be included within an "any" element.\r
+                        The namespace for the imported element must be defined in the instance, and the schema must be imported.\r
+                        The extension has a definition of "strict" i.e. they must have their own namespace.\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:any namespace=" http://www.imsglobal.org/xsd/imsccauth_v1p0" processContents="strict" minOccurs="0" maxOccurs="unbounded" />\r
+                </xs:sequence>\r
+            </xs:group>\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the enumerated simpleType declarations **************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the simpleType elements based IMS data-types  *******************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the derived data-type elements **********************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Generate the data-type elements ******************************************************************  -->\r
+\r
+            <xs:complexType name="Manifest.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A manifest element is a container for data structures whose contents describe a \r
+                        semantically complete instance of the IMS Content Packaging Information Model.  \r
+                        \r
+                        A manifest element may contain and reference child manifest elements \r
+                        in the same IMS Manifest document.  The root manifest element defines an \r
+                        entire IMS Package.  A child manifest element defines a semantically complete \r
+                        subset of that Package.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of objects defined as children of ims-cp-imManifest : Manifest.[ ManifestMetadata, Organizations, Resources, Manifest, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="ManifestMetadata.Type" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="organizations" type="Organizations.Type" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="resources" type="Resources.Type" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="manifest" type="Manifest.Type" minOccurs="0" maxOccurs="0" />\r
+                    <xs:group ref="grpStrict.any2939" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="version" use="optional" type="xs:string" />\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Metadata.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An instance of the metadata element contains data structures \r
+                        that declare descriptive information about a metadata element's \r
+                        parent only.\r
+                        \r
+                        One or more different metadata models may be declared as\r
+                        child extensions of a metadata element.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imMetadata:  Metadata.[ Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="schema" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="schemaversion" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any3535" />\r
+                </xs:sequence>\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Organizations.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        The organizations element is a container for all data structures \r
+                        that describe the way or ways that information encapsulated by \r
+                        its parent manifest element is structured. \r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents of binding of the child objects of ims-cp-imOrganizations: Organizations.[ Organization, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="organization" type="Organization.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="default" use="prohibited" type="defaultOrganizationProhibited" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Resources.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        The Resources element is a container for data structures containing \r
+                        references  to one or more assets.  Asset references may be grouped \r
+                        within a containing resources element in whatever manner seems best.\r
+                          \r
+                        The scope of referenced assets is specific to a resources element's parent \r
+                        manifest element only. \r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imResources: Resources.[ Resource, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="resource" type="Resource.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Organization.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An organization element is a container for all data structures relating \r
+                        to a particular way or view that information encapsulated by a \r
+                        grandparent manifest object is structured.  \r
+                        \r
+                        Multiple organization elements within the same parent organizations \r
+                        element are equivalent in purpose: Each shows a different way for \r
+                        structuring the same information declared within a grandparent \r
+                        manifest object.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-Organization: Organization[ Title, Item, Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="item" type="Item.Type4333" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="structure" use="required" type="rootedHierarchy" fixed="rooted-hierarchy" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <!--**Following element's attribute values altered by AP condition processing**-->\r
+<xs:complexType name="Resource.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A resource element is a container for a particular asset \r
+                        or collection of assets.  A resource may contain references \r
+                        to assets that are all of the same type or different types (i.e., file formats).\r
+                        \r
+                        The scope or boundary of an IMS Package is defined by the asset \r
+                        references collected into all resources containers associated with the\r
+                        root manifest element, whether as a child, direcdt descendant, or externally \r
+                        linked descendant. \r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imResource: Resource.[ Metadata, File, Dependency, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:element name="file" type="File.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <!--**Following element's attribute values altered by AP condition processing**-->\r
+<xs:element name="dependency" type="Dependency.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="type" use="required" type="predefinedContentTypes" />\r
+                <xs:attribute ref="xml:base" use="optional" />\r
+                <xs:attribute name="href" use="optional" type="xs:anyURI" />\r
+                <xs:anyAttribute namespace="http://www.imsglobal.org/xsd/imsccauth_v1p0 http://www.imsglobal.org/xsd/imscp_extensionv1p2" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <!--**Following element's attribute values altered by AP condition processing**-->\r
+<xs:complexType name="Item.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An item element represents a structural node in a particular organization.  \r
+                        An item element may be a parent or sibling of other Item elements, \r
+                        each one representing a unique structural node.\r
+                        \r
+                        An organization has no meaning unless it has at least one Item element.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects of ims-cp-imItem: Item.[ Title, Item, Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />\r
+                    <xs:element name="item" type="Item.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="identifierref" use="optional" type="xs:string" />\r
+                <xs:attribute name="isvisible" use="prohibited" type="NoIsVisible" />\r
+                <xs:attribute name="parameters" use="prohibited" type="NoParameters" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+<xs:complexType name="Item.Type4333">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        An item element represents a structural node in a particular organization.  \r
+                        An item element may be a parent or sibling of other Item elements, \r
+                        each one representing a unique structural node.\r
+                        \r
+                        An organization has no meaning unless it has at least one Item element.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects of ims-cp-imItem: Item.[ Title, Item, Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="0" />\r
+                    <xs:element name="item" type="Item.Type" minOccurs="0" maxOccurs="unbounded" />\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="identifier" use="required" type="xs:ID" />\r
+                <xs:attribute name="identifierref" use="prohibited" type="NoIdentifierRef" />\r
+                <xs:attribute name="isvisible" use="prohibited" type="NoIsVisible" />\r
+                <xs:attribute name="parameters" use="prohibited" type="NoParameter" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="File.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A file element declares a reference to a single asset.  The reference may\r
+                        be relative to the Package containing the file element or absolute \r
+                        (external to the Package).\r
+                        \r
+                        A file element may contain child extensions declaring alternative references\r
+                         to the same asset as that referenced by the file element's href attribute.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imFile: File.[ Metadata, Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="metadata" type="Metadata.Type" minOccurs="0" maxOccurs="1" />\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <xs:attribute name="href" use="required" type="xs:anyURI" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="Dependency.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        A dependency element provides a way to associate another collection of \r
+                        asset references within the scope of the dependency element's parent \r
+                        resource element.\r
+                        \r
+                        This element allows the parsimonious declaration of asset references.  \r
+                        Shared asset references can be declared once and associated many \r
+                        times through a Dependency element.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imDependency: Dependency.[ Extension ].</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:group ref="grpStrict.any" />\r
+                </xs:sequence>\r
+                <!--**Following element's attribute values altered by AP condition processing**-->\r
+<xs:attribute name="identifierref" use="required" type="xs:string" />\r
+                <xs:anyAttribute namespace="##other" processContents="strict" />\r
+            </xs:complexType>\r
+\r
+            <xs:complexType name="ManifestMetadata.Type">\r
+                <xs:annotation>\r
+                    <xs:documentation>\r
+                        This metadata element contains data structures that declare \r
+                        descriptive information about an entire Package.\r
+                        \r
+                        One or more different metadata models may be declared as\r
+                        child extensions of a metadata element.\r
+                        \r
+                        The schema and schemaversion children define the kind or collection \r
+                        of metadata models being used.\r
+\r
+                        <p xmlns="http://www.imsglobal.org/xsd/imscp_v1p1">Represents a binding of the kinds of child objects defined for ims-cp-imManifestMetadata:  ManifestMetadata.[ Schema, SchemaVersion, MetadataModel ]..</p>\r
+                    </xs:documentation>\r
+                </xs:annotation>\r
+                <xs:sequence>\r
+                    <xs:element name="schema" type="schemaFixed" minOccurs="1" maxOccurs="1" fixed="IMS Common Cartridge" />\r
+                    <xs:element name="schemaversion" type="schemaversionFixed" minOccurs="1" maxOccurs="1" fixed="1.0.0" />\r
+                    <xs:group ref="grpStrict.any4935" />\r
+                </xs:sequence>\r
+            </xs:complexType>\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Declaration of the elements **********************************************************************  -->\r
+\r
+        <!-- =====================================  -->\r
+\r
+        <!-- Declaration of the root element(s) ***************************************************************  -->\r
+\r
+            <xs:element name="manifest" type="Manifest.Type" />\r
+\r
+        <!-- =====================================  -->\r
+\r
+</xs:schema>\r
diff --git a/docs/mods/_core/imscp/imsdt_v1p0_localised.xsd b/docs/mods/_core/imscp/imsdt_v1p0_localised.xsd
new file mode 100644 (file)
index 0000000..4fd9bfd
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--\r
+  IPR, License and Distribution Notices\r
+  This machine readable file is derived from IMS specification IMS Common Cartridge Version 1.0 found at http://www.imsglobal.org/cc/index.html and the original IMS schema binding or code base       http://www.imsglobal.org/cc/.\r
+  \r
+  Recipients of this document are requested to submit, with their comments, notification of any relevant patent claims or other intellectual property rights of which they may be aware that might be infringed by the schema binding contained in this document.\r
+  \r
+  IMS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on IMS�s procedures with respect to rights in IMS specifications can be found at the IMS Intellectual Property Rights web page: http://www.imsglobal.org/ipr/imsipr_policyFinal.pdf.\r
+  \r
+  Copyright © IMS Global Learning Consortium 1999-2008. All Rights Reserved.\r
+  \r
+  License Notice for Users\r
+  Users of products or services that include this document are hereby granted a worldwide, royalty-free, non-exclusive license to use this document.\r
+  \r
+  Distribution Notice for Developers\r
+  Developers of products or services that are not original incorporators of this document and have not changed this document, that is, are distributing a software product that incorporates this document as is from a third-party source other than IMS, are hereby granted permission to copy, display and distribute the contents of this document in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof.\r
+  \r
+  Developers of products or services that are original incorporators of this document and wish to provide distribution of this document as is or with modifications and developers of products and services that are not original incorporators of this document and have changed this document, are required to register with the IMS community on the IMS website as described in the following two paragraphs:\r
+  \r
+  - If you wish to distribute this document as is, with no modifications, you are hereby granted permission to copy, display and distribute the contents of this document in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof, that you make and you complete a valid license registration with IMS and receive an email from IMS granting the license. To register, follow the instructions on the IMS website: http://www.imsglobal.org/specificationdownload.cfm. Once registered you are granted permission to transfer unlimited distribution rights of this document for the purposes of third-party or other distribution of your product or service that incorporates this document as long as this IPR, License and Distribution notice remains in place in its entirety.\r
+  \r
+  - If you wish to create and distribute a derived work from this document, you are hereby granted permission to copy, display and distribute the contents of the derived work in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof, that you make and you complete a valid profile registration with IMS and receive an email from IMS granting the license. To register, follow the instructions on the IMS website: http://www.imsglobal.org/profile/. Once registered you are granted permission to transfer unlimited distribution rights of the derived work for the purposes of third-party or other distribution of your product or service that incorporates the derived work as long as this IPR, License and Distribution notice remains in place in its entirety.\r
+  \r
+  The limited permissions granted above are perpetual and will not be revoked by IMS or its successors or assigns.\r
+  \r
+  THIS SPECIFICATION IS BEING OFFERED WITHOUT ANY WARRANTY WHATSOEVER, AND IN PARTICULAR, \r
+  ANY WARRANTY OF NONINFRINGEMENT IS EXPRESSLY DISCLAIMED. ANY USE OF THIS SPECIFICATION \r
+  SHALL BE MADE ENTIRELY AT THE IMPLEMENTER�S OWN RISK, AND NEITHER THE CONSORTIUM, NOR \r
+  ANY OF ITS MEMBERS OR SUBMITTERS, SHALL HAVE ANY LIABILITY WHATSOEVER TO ANY IMPLEMENTER \r
+  OR THIRD PARTY FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, DIRECTLY OR INDIRECTLY, ARISING \r
+  FROM THE USE OF THIS SPECIFICATION.\r
+-->\r
+<!--*************************************************************************-->\r
+<!--** This schema has been modified from the original base schema named - **-->\r
+<!--** imsdt_v1p0.xsd                                                      **-->\r
+<!--** using the IMS SchemaProf tool. This tool is based on software from  **-->\r
+<!--** the TELCERT Project which was funded in part by the European        **-->\r
+<!--** Commission under contract IST-507128                                **-->\r
+<!--*************************************************************************-->\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.imsglobal.org/xsd/imsdt_v1p0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.imsglobal.org/xsd/imsdt_v1p0" elementFormDefault="unqualified">\r
+\r
+  <xs:element name="topic" type="topicType" />\r
+  <xs:complexType name="topicType">\r
+    <xs:sequence>\r
+      <xs:element name="title" type="xs:string" />\r
+      <xs:element name="text">\r
+        <xs:complexType>\r
+          <xs:simpleContent>\r
+            <xs:extension base="xs:string">\r
+              <xs:attribute name="texttype" type="textTypeType" default="text/plain" />\r
+            </xs:extension>\r
+          </xs:simpleContent>\r
+        </xs:complexType>\r
+      </xs:element>\r
+      <xs:element name="attachments" minOccurs="0">\r
+        <xs:complexType>\r
+          <xs:sequence>\r
+            <xs:element name="attachment" minOccurs="1" maxOccurs="unbounded">\r
+              <xs:complexType>\r
+                <xs:attribute name="href" type="xs:string" use="required" />\r
+              </xs:complexType>\r
+            </xs:element>\r
+          </xs:sequence>\r
+        </xs:complexType>\r
+      </xs:element>\r
+    </xs:sequence>\r
+  </xs:complexType>\r
+  <xs:simpleType name="textTypeType">\r
+    <xs:restriction base="xs:string">\r
+      <xs:enumeration value="text/html" />\r
+      <xs:enumeration value="text/plain" />\r
+    </xs:restriction>\r
+  </xs:simpleType>\r
+</xs:schema>\r
diff --git a/docs/mods/_core/imscp/imsmanifest.xml b/docs/mods/_core/imscp/imsmanifest.xml
new file mode 100644 (file)
index 0000000..175e7fb
--- /dev/null
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<manifest identifier="_37634FB7-01E4-C5F3-582A-F55E1A824A63" xmlns="http://www.imsglobal.org/xsd/_imscp_v1p1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 http://www.imsglobal.org/xsd/imscp_v1p1.xsd http://ltsc.ieee.org/xsd/LOM domainProfile_0/lomStrict_localised.xsd">\r
+       <metadata>\r
+               <schema>IMS Common Cartridge</schema>\r
+               <schemaversion>1.0.0</schemaversion>\r
+       </metadata>\r
+       <organizations>\r
+               <organization identifier="_FE501A0A-9129-D906-B763-83050C0FA8D5" structure="rooted-hierarchy">\r
+                       <item identifier="_42F6AF00-DA58-4682-104C-26CF58CE5FF0">\r
+                               <item identifier="_0C3A14A9-E414-2C85-3450-33A5DB6B8F3C">\r
+                                       <title>Common Cartridge Sample Course</title>\r
+                                       <item identifier="_4278D199-B977-FBC4-2AA1-0DA6D2975BFB" identifierref="_33C55BF7-B5FC-D87B-7280-42BF7AD8577B">\r
+                                               <title>Generate Unique ID Values</title>\r
+                                       </item>\r
+                                       <item identifier="_2A8C2679-0124-149B-06AA-6E70D16BE38F" identifierref="_74D675B3-AE6D-36E4-841C-C0FE9460725E" isvisible="false">\r
+                                               <title>Test Bank</title>\r
+                                       </item>\r
+                                       <item identifier="_928A181C-113F-B1BA-B3B8-321B4EBF4024" identifierref="_56B1BEDC-A820-7AA8-A21D-F32017189445">\r
+                                               <title>Quiz</title>\r
+                                       </item>\r
+                                       <item identifier="_7B1E5C0E-8102-6D92-6DE0-DD372CF183B8" identifierref="_5923CEF3-7885-E805-59BC-858B9549B80E">\r
+                                               <title>WebLink - Google Site</title>\r
+                                       </item>\r
+                                       <item identifier="_7D7CB887-3570-759B-9E2F-9F6919B67B47" identifierref="_DB2AE381-2B95-D659-859E-ECAA65352912">\r
+                                               <title>Arctic Fox</title>\r
+                                       </item>\r
+                               </item>\r
+                       </item>\r
+               </organization>\r
+       </organizations>\r
+       <resources>\r
+               <resource identifier="_33C55BF7-B5FC-D87B-7280-42BF7AD8577B" type="webcontent" href="33C55BF7-B5FC-D87B-7280-42BF7AD8577B/33C55BF7-B5FC-D87B-7280-42BF7AD8577B.html">\r
+                       <file href="33C55BF7-B5FC-D87B-7280-42BF7AD8577B/33C55BF7-B5FC-D87B-7280-42BF7AD8577B.html"/>\r
+               </resource>\r
+               <resource identifier="_74D675B3-AE6D-36E4-841C-C0FE9460725E" type="imsqti_xmlv1p2/imscc_xmlv1p0/question-bank">\r
+                       <file href="74D675B3-AE6D-36E4-841C-C0FE9460725E/74D675B3-AE6D-36E4-841C-C0FE9460725E.xml"/>\r
+               </resource>\r
+               <resource identifier="_56B1BEDC-A820-7AA8-A21D-F32017189445" type="imsqti_xmlv1p2/imscc_xmlv1p0/assessment">\r
+                       <file href="56B1BEDC-A820-7AA8-A21D-F32017189445/56B1BEDC-A820-7AA8-A21D-F32017189445.xml"/>\r
+               </resource>\r
+               <resource identifier="_5923CEF3-7885-E805-59BC-858B9549B80E" type="imswl_xmlv1p0">\r
+                       <file href="5923CEF3-7885-E805-59BC-858B9549B80E/5923CEF3-7885-E805-59BC-858B9549B80E.xml"/>\r
+               </resource>\r
+               <resource identifier="_DB2AE381-2B95-D659-859E-ECAA65352912" type="imsdt_xmlv1p0">\r
+                       <file href="DB2AE381-2B95-D659-859E-ECAA65352912/DB2AE381-2B95-D659-859E-ECAA65352912.xml"/>\r
+                       <dependency identifierref="_E2F2AA0E-4B4A-9DD1-20A7-90034AF71745"/>\r
+                       <dependency identifierref="_71E08B51-4D95-8FEC-BD8F-D7E3253E9843"/>\r
+               </resource>\r
+               <resource identifier="_E2F2AA0E-4B4A-9DD1-20A7-90034AF71745" type="associatedcontent/imscc_xmlv1p0/learning-application-resource">\r
+                       <file href="images/arcticfoxsmall.jpg"/>\r
+               </resource>\r
+               <resource identifier="_71E08B51-4D95-8FEC-BD8F-D7E3253E9843" type="webcontent">\r
+                       <file href="images/arcticfoxfull.jpg"/>\r
+               </resource>\r
+       </resources>\r
+</manifest>\r
diff --git a/docs/mods/_core/imscp/imswl_v1p0_localised.xsd b/docs/mods/_core/imscp/imswl_v1p0_localised.xsd
new file mode 100644 (file)
index 0000000..88f14ba
--- /dev/null
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!--*************************************************************************-->\r
+<!--** This schema has been modified from the original base schema named - **-->\r
+<!--** imswl_v1p0.xsd                                                      **-->\r
+<!--** using the IMS SchemaProf tool. This tool is based on software from  **-->\r
+<!--** the TELCERT Project which was funded in part by the European        **-->\r
+<!--** Commission under contract IST-507128                                **-->\r
+<!--*************************************************************************-->\r
+<!--\r
+  IPR, License and Distribution Notices\r
+  This machine readable file is derived from IMS specification IMS Common Cartridge Version 1.0 found at http://www.imsglobal.org/cc/index.html and the original IMS schema binding or code base       http://www.imsglobal.org/cc/.\r
+  \r
+  Recipients of this document are requested to submit, with their comments, notification of any relevant patent claims or other intellectual property rights of which they may be aware that might be infringed by the schema binding contained in this document.\r
+  \r
+  IMS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on IMS�s procedures with respect to rights in IMS specifications can be found at the IMS Intellectual Property Rights web page: http://www.imsglobal.org/ipr/imsipr_policyFinal.pdf.\r
+  \r
+  Copyright © IMS Global Learning Consortium 1999-2008. All Rights Reserved.\r
+  \r
+  License Notice for Users\r
+  Users of products or services that include this document are hereby granted a worldwide, royalty-free, non-exclusive license to use this document.\r
+  \r
+  Distribution Notice for Developers\r
+  Developers of products or services that are not original incorporators of this document and have not changed this document, that is, are distributing a software product that incorporates this document as is from a third-party source other than IMS, are hereby granted permission to copy, display and distribute the contents of this document in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof.\r
+  \r
+  Developers of products or services that are original incorporators of this document and wish to provide distribution of this document as is or with modifications and developers of products and services that are not original incorporators of this document and have changed this document, are required to register with the IMS community on the IMS website as described in the following two paragraphs:\r
+  \r
+  - If you wish to distribute this document as is, with no modifications, you are hereby granted permission to copy, display and distribute the contents of this document in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof, that you make and you complete a valid license registration with IMS and receive an email from IMS granting the license. To register, follow the instructions on the IMS website: http://www.imsglobal.org/specificationdownload.cfm. Once registered you are granted permission to transfer unlimited distribution rights of this document for the purposes of third-party or other distribution of your product or service that incorporates this document as long as this IPR, License and Distribution notice remains in place in its entirety.\r
+  \r
+  - If you wish to create and distribute a derived work from this document, you are hereby granted permission to copy, display and distribute the contents of the derived work in any medium for any purpose without fee or royalty provided that you include this IPR, License and Distribution notice in its entirety on ALL copies, or portions thereof, that you make and you complete a valid profile registration with IMS and receive an email from IMS granting the license. To register, follow the instructions on the IMS website: http://www.imsglobal.org/profile/. Once registered you are granted permission to transfer unlimited distribution rights of the derived work for the purposes of third-party or other distribution of your product or service that incorporates the derived work as long as this IPR, License and Distribution notice remains in place in its entirety.\r
+  \r
+  The limited permissions granted above are perpetual and will not be revoked by IMS or its successors or assigns.\r
+  \r
+  THIS SPECIFICATION IS BEING OFFERED WITHOUT ANY WARRANTY WHATSOEVER, AND IN PARTICULAR, \r
+  ANY WARRANTY OF NONINFRINGEMENT IS EXPRESSLY DISCLAIMED. ANY USE OF THIS SPECIFICATION \r
+  SHALL BE MADE ENTIRELY AT THE IMPLEMENTER�S OWN RISK, AND NEITHER THE CONSORTIUM, NOR \r
+  ANY OF ITS MEMBERS OR SUBMITTERS, SHALL HAVE ANY LIABILITY WHATSOEVER TO ANY IMPLEMENTER \r
+  OR THIRD PARTY FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, DIRECTLY OR INDIRECTLY, ARISING \r
+  FROM THE USE OF THIS SPECIFICATION.\r
+-->\r
+<!--*************************************************************************-->\r
+<!--** This schema has been modified from the original base schema named - **-->\r
+<!--** imswl_v1p0.xsd                                                      **-->\r
+<!--** using the IMS SchemaProf tool. This tool is based on software from  **-->\r
+<!--** the TELCERT Project which was funded in part by the European        **-->\r
+<!--** Commission under contract IST-507128                                **-->\r
+<!--*************************************************************************-->\r
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.imsglobal.org/xsd/imswl_v1p0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://www.imsglobal.org/xsd/imswl_v1p0" elementFormDefault="unqualified">\r
+  <xs:element name="webLink" type="webLinkType"/>\r
+  <xs:complexType name="webLinkType">\r
+    <xs:sequence>\r
+      <xs:element name="title" type="xs:string"/>\r
+      <xs:element name="url">\r
+        <xs:complexType>\r
+          <xs:attribute name="href" type="xs:string" use="required"/>\r
+          <xs:attribute name="target" type="xs:string"/>\r
+          <xs:attribute name="windowFeatures" type="xs:string"/>\r
+        </xs:complexType>\r
+      </xs:element>\r
+    </xs:sequence>\r
+  </xs:complexType>\r
+</xs:schema>
\ No newline at end of file
diff --git a/docs/mods/_core/imscp/index.php b/docs/mods/_core/imscp/index.php
new file mode 100644 (file)
index 0000000..2688c27
--- /dev/null
@@ -0,0 +1,191 @@
+<?php
+/****************************************************************/
+/* ATutor                                                                                                              */
+/****************************************************************/
+/* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg        */
+/* Adaptive Technology Resource Centre / University of Toronto  */
+/* http://atutor.ca                                                                                            */
+/*                                                              */
+/* 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.                               */
+/****************************************************************/
+// $Id: index.php 8901 2009-11-11 19:10:19Z cindy $
+
+define('AT_INCLUDE_PATH', '../../../include/');
+require(AT_INCLUDE_PATH.'vitals.inc.php');
+
+require(AT_INCLUDE_PATH.'header.inc.php');
+
+if (!isset($_main_menu)) {
+       $_main_menu = $contentManager->getContent();
+}
+
+function print_menu_sections(&$menu, $parent_content_id = 0, $depth = 0, $ordering = '') {
+       $my_children = $menu[$parent_content_id];
+       $cid = $_GET['cid'];
+
+       if (!is_array($my_children)) {
+               return;
+       }
+       foreach ($my_children as $children) {
+               /* test content association, we don't want to display the test pages
+                * as part of the menu section.  If test, skip it.
+                */
+               if (isset($children['test_id'])){
+                       continue;
+               }
+
+               echo '<option value="'.$children['content_id'].'"';
+               if ($cid == $children['content_id']) {
+                       echo ' selected="selected"';
+               }
+               echo '>';
+               echo str_pad('', $depth, '-') . ' ';
+               if ($parent_content_id == 0) {
+                       $new_ordering = $children['ordering'];
+                       echo $children['ordering'];
+               } else {
+                       $new_ordering = $ordering.'.'.$children['ordering'];
+                       echo $ordering . '.'. $children['ordering'];
+               }
+               echo ' '.$children['title'].'</option>';
+
+               print_menu_sections($menu, $children['content_id'], $depth+1, $new_ordering);
+       }
+}
+
+if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) && ($_SESSION['packaging'] == 'none')) {
+       echo '<p>'._AT('content_packaging_disabled').'</p>';
+       require (AT_INCLUDE_PATH.'footer.inc.php'); 
+       exit;
+} else if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN) && ($_SESSION['packaging'] == 'top')) {
+       $_main_menu = array($_main_menu[0]);
+}
+?>
+<form name="exportForm" method="post" action="mods/_core/imscp/ims_export.php">
+<div class="input-form">
+       <fieldset class="group_form"><legend class="group_form"><?php echo _AT('export_content'); ?></legend>
+       <div class="row">
+               <p><?php echo _AT('export_content_info'); ?></p>
+       </div>
+
+<?php if ($_main_menu[0]): ?>
+       <div class="row">
+               <label for="select_cid"><?php echo _AT('export_content_package_what'); ?></label><br />
+               <select name="cid" id="select_cid">
+                       <option value="0"><?php echo _AT('export_entire_course_or_chap'); ?></option>
+                       <option value="0"></option>
+                       <?php
+                               print_menu_sections($_main_menu);
+                       ?>
+               </select>
+       </div>
+
+       <?php if (authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN)): ?>
+                       <div class="row">
+                               <input type="radio" name="export_as" id="to_cp" value="1" checked="checked" onclick="changeFormAction('cp');" />
+                               <label for="to_cp"><?php echo _AT('content_package'); ?></label> <br />
+                               <input type="radio" name="export_as" id="to_cc" value="1" onclick="changeFormAction('cc');" />
+                               <label for="to_cc"><?php echo _AT('common_cartridge'); ?> </label>
+                       </div>
+                       <div class="row">
+                               <!--<input type="checkbox" name="to_tile" id="to_tile" value="1" />
+                               <label for="to_tile"><?php echo _AT('tile_export'); ?></label> <br /> -->
+                               <input type="checkbox" name="to_a4a" id="to_a4a" value="1" />
+                               <label for="to_a4a"><?php echo _AT('a4a_export'); ?></label>
+                       </div>
+       <?php endif; ?>
+       
+       <div class="row buttons">
+               <input type="submit" name="submit" value="<?php echo _AT('export'); ?>" />
+               <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
+       </div>
+       </fieldset>
+<?php else: ?>
+       <div class="row">
+               <strong><?php echo _AT('none_found'); ?></strong>
+       </div>
+<?php endif; ?>
+
+</div>
+</form>
+
+<?php if (!authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
+               require (AT_INCLUDE_PATH.'footer.inc.php'); 
+               exit;
+}
+?>
+<br /><br />
+
+
+<form name="form1" method="post" action="mods/_core/imscp/ims_import.php" enctype="multipart/form-data" onsubmit="openWindow('<?php echo AT_BASE_HREF; ?>tools/prog.php');">
+<div class="input-form">
+       <fieldset class="group_form"><legend class="group_form"><?php echo _AT('import_content'); ?></legend>
+       <div class="row">
+
+               <p><?php echo _AT('import_content_info'); ?></p>
+       </div>
+
+       <div class="row">
+               <label for="select_cid2"><?php echo _AT('import_content_package_where'); ?></label><br />
+               <select name="cid" id="select_cid2">
+                       <option value="0"><?php echo _AT('import_content_package_bottom_subcontent'); ?></option>
+                       <option value="0"></option>
+                       <?php
+                               print_menu_sections($_main_menu);
+                       ?>
+               </select>
+       </div>
+
+       <div class="row">
+               <input type="checkbox" name="allow_test_import" id="allow_test_import" checked="checked" />
+               <label for="allow_test_import"><?php echo _AT('test_import_package'); ?></label> <br />
+               <input type="checkbox" name="allow_a4a_import" id="allow_a4a_import" checked="checked" />
+               <label for="allow_a4a_import"><?php echo _AT('a4a_import_package'); ?></label>          
+       </div>
+       
+       <div class="row">
+               <label for="to_file"><?php echo _AT('upload_content_package'); ?></label><br />
+               <input type="file" name="file" id="to_file" />
+       </div>
+
+       <div class="row">
+               <label for="to_url"><?php echo _AT('specify_url_to_content_package'); ?></label><br />
+               <input type="text" name="url" value="http://" size="40" id="to_url" />
+       </div>
+
+       <div class="row buttons">
+               <input type="submit" name="submit" onclick="setClickSource('submit');" value="<?php echo _AT('import'); ?>" />
+               <input type="submit" name="cancel" onclick="document.form1.enctype='';setClickSource('cancel');" value="<?php echo _AT('cancel'); ?>" />
+       </div>
+</div>
+</form>
+
+<script language="javascript" type="text/javascript">
+
+var but_src;
+function setClickSource(name) {
+       but_src = name;
+}
+
+function openWindow(page) {
+       if (but_src != "cancel") {
+               newWindow = window.open(page, "progWin", "width=400,height=200,toolbar=no,location=no");
+               newWindow.focus();
+       }
+}
+
+//Change form action 
+function changeFormAction(type){
+       var obj = document.exportForm;
+       if (type=="cc"){
+               obj.action = "mods/_core/imscc/ims_export.php";
+       } else if (type=="cp"){
+               obj.action = "mods/_core/imscp/ims_export.php";
+       }
+}
+
+</script>
+
+<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file
diff --git a/docs/mods/_core/imscp/main.xsd b/docs/mods/_core/imscp/main.xsd
new file mode 100644 (file)
index 0000000..bf8511c
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<xs:schema xmlns    ="http://dummy.libxml2.validator"
+    targetNamespace ="http://dummy.libxml2.validator"
+    xmlns:xs        ="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi       ="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:imscp     ="http://www.imsglobal.org/xsd/imscc/imscp_v1p1"
+    xmlns:imslom    ="http://ltsc.ieee.org/xsd/imscc/LOM"
+    xmlns:lom       ="http://ltsc.ieee.org/xsd/LOM"
+    xmlns:cc        ="http://www.imsglobal.org/xsd/imsccauth_v1p0"
+    xmlns:qti      ="http://www.imsglobal.org/xsd/ims_qtiasiv1p2"
+    xmlns:wl       ="http://www.imsglobal.org/xsd/imswl_v1p0"
+    xmlns:dt       ="http://www.imsglobal.org/xsd/imsdt_v1p0"  
+    xmlns:glossary  ="http://www.atutor.ca/xsd/glossary"       
+    version="1.0"
+    elementFormDefault  ="qualified"
+    attributeFormDefault="unqualified"   
+    >
+   
+    <xs:import namespace ="http://www.imsglobal.org/xsd/imscc/imscp_v1p1" schemaLocation = "imscp_v1p2_localised.xsd"                     />
+    <xs:import namespace ="http://ltsc.ieee.org/xsd/imscc/LOM"            schemaLocation = "domainProfile_1/lomLoose_localised.xsd"       />
+    <xs:import namespace ="http://ltsc.ieee.org/xsd/LOM"                  schemaLocation = "domainProfile_2/lomLoose_localised.xsd"       />
+    <xs:import namespace ="http://www.imsglobal.org/xsd/imsccauth_v1p0"   schemaLocation = "domainProfile_0/imsccauth_v1p0_localised.xsd" />
+    <xs:import namespace ="http://www.imsglobal.org/xsd/ims_qtiasiv1p2"   schemaLocation = "domainProfile_4/ims_qtiasiv1p2_localised.xsd" />
+    <xs:import namespace ="http://www.imsglobal.org/xsd/imswl_v1p0"      schemaLocation = "imswl_v1p0_localised.xsd"                     />    
+    <xs:import namespace ="http://www.imsglobal.org/xsd/imsdt_v1p0"      schemaLocation = "imsdt_v1p0_localised.xsd"                     />    
+    <xs:import namespace ="http://www.atutor.ca/xsd/glossary"            schemaLocation = "glossary.xsd"                                 />    
+</xs:schema>
diff --git a/docs/mods/_core/imscp/module.php b/docs/mods/_core/imscp/module.php
new file mode 100644 (file)
index 0000000..39dbdbb
--- /dev/null
@@ -0,0 +1,21 @@
+<?php\r
+\r
+\r
+if (!defined('AT_INCLUDE_PATH')) { exit; }\r
+if (!isset($this) || (isset($this) && (strtolower(get_class($this)) != 'module'))) { exit(__FILE__ . ' is not a Module'); }\r
+\r
+// if this module is to be made available to students on the Home or Main Navigation\r
+$_student_tool = 'export.php';\r
+\r
+//instructors\r
+//$this->_pages['mods/_core/imscp/index.php']['title_var'] = 'content_packaging';\r
+//$this->_pages['mods/_core/imscp/index.php']['parent']    = 'tools/content/index.php';\r
+//$this->_pages['mods/_core/imscp/index.php']['guide']     = 'instructor/?p=content_packages.php';\r
+\r
+//students\r
+//$this->_pages['export.php']['title_var'] = 'export_content';\r
+//$this->_pages['export.php']['img']       = 'images/home-export_content.png';\r
+//$this->_pages['export.php']['text']      = _AT('export_content_text');\r
+//$this->_pages['export.php']['guide']     = 'general/?p=export_content.php';\r
+\r
+?>
\ No newline at end of file
diff --git a/docs/mods/_core/imscp/ns.inc.php b/docs/mods/_core/imscp/ns.inc.php
new file mode 100644 (file)
index 0000000..a0b031a
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+/****************************************************************/
+/* ATutor                                                                                                              */
+/****************************************************************/
+/* Copyright (c) 2002-2008                                     */
+/* Adaptive Technology Resource Centre / University of Toronto  */
+/* http://atutor.ca                                                                                            */
+/*                                                              */
+/* 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.                               */
+/****************************************************************/
+// $Id: ims_import.php 8766 2009-08-07 01:39:05Z hwong $
+
+/**
+ * Version 1.0 -IMS Common Cartridge Final Namespaces to Schema Locations
+ * http://www.imsglobal.org/cc/index.html
+ * IMS test packages are different than the ones specified in the specification, which should we follow?  
+ * Following the online specification = failing the test
+ * Following the test = failing the online specification.
+ * Both of them are from IMS CC.
+ */
+
+/*
+$ns['http://www.imsglobal.org/xsd/imscp_v1p1'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/imscp_v1p2.xsd';
+$ns['http://www.imsglobal.org/xsd/imscc/imscp_v1p1'] = 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/imscp_v1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imsccauth_v1p0'] =   'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_0/imsccauth_v1p0_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM'] =            'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/lomLoose_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/unique'] =     'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/vocab'] =      'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/vocab/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/extend'] =     'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_1/extend/custom.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM'] =                  'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/lomLoose_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/unique'] =           'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/vocab'] =            'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/vocab/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/extend'] =           'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_2/extend/custom.xsd';
+$ns['http://www.imsglobal.org/xsd/imscp_extensionv1p2'] = 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_3/imscp_extensionv1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/ims_qtiasiv1p2'] =   'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_4/ims_qtiasiv1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imswl_v1p0'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imsdt_v1p0'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_6/imsdt_v1p0_localised.xsd';
+*/
+
+$ns['http://www.imsglobal.org/xsd/imscp_v1p1'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/imscp_v1p2.xsd';
+$ns['http://www.imsglobal.org/xsd/imscc/imscp_v1p1'] = 'http://www.imsglobal.org/profile/cc/ccv1p0/imscp_v1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imsccauth_v1p0'] =   'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_0/imsccauth_v1p0_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM'] =            'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_2/lomLoose_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/unique'] =     'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_1/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/vocab'] =      'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_1/vocab/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/imscc/LOM/extend'] =     'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_1/extend/custom.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM'] =                  'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_1/lomLoose_localised.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/unique'] =           'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_2/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/vocab'] =            'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_2/vocab/loose.xsd';
+$ns['http://ltsc.ieee.org/xsd/LOM/extend'] =           'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_2/extend/custom.xsd';
+$ns['http://www.imsglobal.org/xsd/imscp_extensionv1p2'] = 'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_3/imscp_extensionv1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/ims_qtiasiv1p2'] = 'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_4/ims_qtiasiv1p2_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imswl_v1p0'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_5/imswl_v1p0_localised.xsd';
+$ns['http://www.imsglobal.org/xsd/imsdt_v1p0'] =       'http://www.imsglobal.org/profile/cc/ccv1p0/domainProfile_6/imsdt_v1p0_localised.xsd';
+
+
+//Content packages
+$ns_cp['http://www.imsproject.org/xsd/imscp_rootv1p1p2'] = 'imscp_rootv1p1p2.xsd';
+$ns_cp['http://www.imsglobal.org/xsd/imsmd_rootv1p2p1'] = 'imsmd_rootv1p2p1.xsd';
+$ns_cp['http://www.adlnet.org/xsd/adlcp_rootv1p2'] = 'adlcp_rootv1p2.xsd';
+$ns_cp['http://www.imsglobal.org/xsd/imscp_v1p1'] = 'http://www.imsglobal.org/xsd/imscp_v1p1p4.xsd';
+$ns_cp['http://www.imsglobal.org/xsd/imsmd_v1p2'] = 'http://www.imsglobal.org/xsd/imsmd_v1p2p2.xsd';
+$ns_cp['http://www.imsglobal.org/xsd/imsqti_item_v2p0'] = 'http://www.imsglobal.org/xsd/imsqti_item_v2p0.xsd';
+
+?>