http://www.atutor.ca/atutor/mantis/view.php?id=4186
authorharris wong <hwong@ocad.ca>
Thu, 1 Apr 2010 21:37:10 +0000 (21:37 -0000)
committerharris wong <hwong@ocad.ca>
Thu, 1 Apr 2010 21:37:10 +0000 (21:37 -0000)
docs/mods/_core/imsafa/classes/A4a.tmpl.php
docs/mods/_core/imsafa/classes/A4aExport.class.php
docs/mods/_core/imsafa/classes/A4aImport.class.php
docs/mods/_core/imscc/include/ims_template.inc.php
docs/mods/_core/imscp/ims_import.php

index b248dd6..a5e8bdb 100644 (file)
                                case 1:
                                        $orig_access_mode = 'auditory';
                                        break;
+                               case 2:
+                                       $orig_access_mode = 'visual';
+                                       $representation_form = 'sign_language';
+                                       break;
                                case 3:
                                        $orig_access_mode = 'textual';
-                                       break;
-                               case 2:
+                                       break;                          
                                case 4:
                                        //sign language, and visual
                                        $orig_access_mode = 'visual';
@@ -44,6 +47,9 @@
                        }
                ?>
                <originalAccessMode><?php echo $orig_access_mode; ?></originalAccessMode>
+               <?php if (isset($representation_form) && $representation_form!=''): ?>
+               <representationForm><?php echo $representation_form; ?></representationForm>
+               <?php endif; ?>
        </adaptationStatement>
        <?php endforeach; ?>
        <?php endif; ?>
index 495bff4..9433645 100644 (file)
@@ -40,6 +40,7 @@ class A4aExport extends A4a {
                        $secondary_array = array();
                        foreach($resources_types as $rtid){
                                $sec_resources['secondary_resources'] = parent::getSecondaryResources($rid);
+
                                //determine secondary resource type
                                foreach ($sec_resources['secondary_resources'] as $sec_id => $sec_resource){
                                        $current_sec_file = $sec_resource['resource'];
@@ -49,14 +50,13 @@ class A4aExport extends A4a {
                                        if (!isset($this->original_files[$current_sec_file]) || empty($this->original_files[$current_sec_file]) ){
                                                //TODO merge these values i think
                                                $this->original_files[$current_sec_file ] = $sec_resource;
-                                               $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']] = parent::getSecondaryResourcesTypes($sec_id);
+                                               $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id);
                                        } else {
-                                               $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']] = parent::getSecondaryResourcesTypes($sec_id);
+                                               $this->original_files[$current_sec_file ]['resource_type'][$prop['resource']][] = parent::getSecondaryResourcesTypes($sec_id);
                                        }
                                        //add this primary file ref, and the resources type to the secondary file
                                        $this->original_files[$current_sec_file]['primary_resources'][$prop['resource']] = $rtid;
 //                                     $this->original_files[$current_sec_file]['primary_resources'][$prop['resource']]['language_code'] = $sec_resource['language_code'];
-
                                }
                                $res_type['resource_type'] = $rtid;     //could be 1+
                                $temp = array_merge($prop, $res_type, $secondary_array);
@@ -102,11 +102,14 @@ class A4aExport extends A4a {
                // Get original files' xml 
                foreach($this->original_files as $id=>$resource){
                        $orig_access_mode = array();
-
                        foreach($resource['resource_type'] as $type_id){
                                if (!is_array($type_id)){
                                        //primary resource will always have just on type
                                        $orig_access_mode[] = $this->getResourceNameById($type_id);
+                               } else {
+                                       foreach($type_id as $k=>$type_id2){
+                                               $orig_access_mode[] = $this->getResourceNameById($type_id2[0]);
+                                       }
                                }
                        }
                        $savant->assign('relative_path', $this->relative_path); //the template will need the relative path
@@ -128,9 +131,10 @@ class A4aExport extends A4a {
                                        $orig_access_mode = array(); //reinitialize
                                        foreach($resource['resource_type'][$uri] as $type_id){
                                                $orig_access_mode[] = $this->getResourceNameById($type_id);
+                                               $savant->assign('orig_access_mode', $orig_access_mode);
+                                               $xml_array[$id.' to '.$uri][] = $savant->fetch(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.tmpl.php');
                                        }
-                                       $savant->assign('orig_access_mode', $orig_access_mode);
-                                       $xml_array[$id.' to '.$uri] = $savant->fetch(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.tmpl.php');
+                                       
                                }
                        } else {
                                $savant->assign('primary_resource_uri', '');
@@ -147,7 +151,9 @@ class A4aExport extends A4a {
         */
        function getResourceNameById($type_id){
                $orig_access_mode = '';
-
+               if (is_array($type_id)) {
+                       $type_id = $type_id[0];
+               }
                switch($type_id){
                        case 1:
                                $orig_access_mode = 'auditory';
@@ -156,6 +162,8 @@ class A4aExport extends A4a {
                                $orig_access_mode = 'textual';
                                break;
                        case 2:
+                               $orig_access_mode = 'sign_language';
+                               break;
                        case 4:
                                $orig_access_mode = 'visual';
                                break;
index c2fe130..7d738c4 100644 (file)
@@ -33,6 +33,9 @@ class A4aImport extends A4a {
         * @param       array   XML items generated by the IMS import
         */
        function importA4a($items){
+               //imported files, keep track of what file path that's been processed. Do not add repeated ones
+               $imported_files = array();
+
                //use the items array data and insert it into the database.
                foreach ($items as $file_path => $a4a_resources){
                        foreach ($a4a_resources as $resource){
@@ -62,6 +65,10 @@ class A4aImport extends A4a {
                                                //we can safely take it out.
                                                //@edited Dec 6th, imscc import uses relative paths, ims doesn't.
                                                $secondary_files = $items[$this->relative_path.$secondary_resource];
+                                               if (in_array($this->relative_path.$secondary_resource, $imported_files)){
+                                                       continue;
+                                               }
+                                               $imported_files[] = $this->relative_path.$secondary_resource;
                                                if (empty($secondary_files)){
                                                    //tweak: if this is empty, then most likely it is an ims import.
                                                    $secondary_resource = preg_replace('/^\.\.\//', '', $secondary_resource);
@@ -77,15 +84,15 @@ class A4aImport extends A4a {
                                                                //access_stmt_originalAccessMode cause we want the language for the secondary file.
                                                                $secondary_attr = $this->toResourceTypeId($secondary_file['access_stmt_originalAccessMode']);
                                                                $secondary_id = $this->setSecondaryResource($primary_id, $secondary_resource, $secondary_lang);
-
                                                                //insert secondary resource type associations
                                                                foreach ($secondary_attr as $secondary_resource_type_id){
                                                                        $this->setSecondaryResourceType($secondary_id, $secondary_resource_type_id);
                                                                }
-                                                               break;  //1-to-1 mapping, no need to go further
+                                                               //break;        //1-to-1 mapping, no need to go further
                                                        }
                                                }
                                        } //foreach of secondary_resources
+                                       $imported_files = array(); //reset the imported file for the next resource 
                                }                               
                        } //foreach of resources
                } //foreach of item array
@@ -93,9 +100,10 @@ class A4aImport extends A4a {
 
        /**
         * By the given attrs array, decide which resource type it is
-        *      auditory = type 1
-        *      textual  = type 3
-        *      visual   = type 4
+        *      auditory                = type 1
+        *  sign_language       = type 2
+        *      textual                 = type 3
+        *      visual                  = type 4
         * @param       array
         * return type id array
         */
@@ -106,17 +114,31 @@ class A4aImport extends A4a {
                 if (empty($resources_attrs)){
                         return $result;
                 }
-
-                if (in_array('auditory', $resources_attrs)){
-                        $result[] = 1;
-                }
-                if (in_array('textual', $resources_attrs)){
-                        $result[] = 3;
-                }
-                if (in_array('visual', $resources_attrs)){
-                        $result[] = 4;
-                }
-                return $result;
+               if (is_array($resources_attrs)) {
+                                if (in_array('auditory', $resources_attrs)){
+                                        $result[] = 1;
+                                }
+                                if (in_array('sign_language', $resources_attrs)){
+                                        $result[] = 2;
+                                }
+                                if (in_array('textual', $resources_attrs)){
+                                        $result[] = 3;
+                                }
+                                if (in_array('visual', $resources_attrs)){
+                                        $result[] = 4;
+                                }              
+               } else {
+                       if ($resources_attrs=='auditory'){
+                               $result[] = 1;
+                       } elseif ($resources_attrs=='sign_language'){
+                               $result[] = 2;
+                       } elseif ($resources_attrs=='textual'){
+                               $result[] = 3;
+                       } elseif ($resources_attrs=='visual'){
+                               $result[] = 4;
+                       }
+               }
+               return $result;
         }
 }
 
index f520143..369a301 100644 (file)
@@ -39,8 +39,7 @@ function get_import_files($text)
                        array_push($files, $file);
                }
        
-       }
-       
+       }       
        return $files;
 }
        
@@ -325,7 +324,9 @@ function print_organizations($parent_id,
                                                if (is_array($a4a_secondary_files[$file])){
                                                        $all_secondary_files_md = '';   //reinitialize string to null
                                                        foreach ($a4a_secondary_files[$file] as $v){
-                                                               $all_secondary_files_md .= $a4a_xml_array[$v];  //all the meta data                                                             
+                                                               foreach($a4a_xml_array[$v] as $v2){
+                                                                       $all_secondary_files_md .= $v2; //all the meta data             
+                                                               }                                                               
                                                        }
                                                        $content_files .= str_replace(  array('{FILE}', '{FILE_META_DATA}'), 
                                                        array('resources/'.$content['content_path'] . $file, $all_secondary_files_md), 
@@ -344,7 +345,6 @@ function print_organizations($parent_id,
                                                }
                                        }
                                }
-
                                /* check if this file is one of the test xml file, if so, we need to add the dependency
                                 * Note:  The file has already been added to the archieve before this is called.
                                 */
index 0bae270..0c75507 100644 (file)
@@ -530,10 +530,10 @@ function rehash($items){
 
                        if ($name=='originalAccessMode'){                               
                                if (in_array('accessModeStatement', $element_path)){
-                                       $items[$current_identifier]['a4a'][$last_file_name][$resource_num]['access_stmt_originalAccessMode'][] = $my_data;
+                                       $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;
-                               }                       
+                                       $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') {