Fisheye: Tag 1.2 refers to a dead (removed) revision in file `openacs-4/packages/lors/change.txt'. Fisheye: No comparison available. Pass `N' to diff? Index: openacs-4/packages/lors/lors.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lors.info,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/lors.info 22 Apr 2004 03:42:06 -0000 1.1 +++ openacs-4/packages/lors/lors.info 4 Sep 2004 14:04:07 -0000 1.2 @@ -6,19 +6,21 @@ Learning Object Repository Services f t - lors - - - 0 - - - - + Ernie Ghiglione - - + IMS Content Packaging and Medata Services. +Implementation of IMS CP and MD for .LRN + 2004-08-06 + This is a service and library to manage IMS Content Packaging and Metadata. From version 0.4d onward it supports SCORM and Blackboard imports + GPL + http://www.gnu.org/copyleft/gpl.html + 1 + + + + Index: openacs-4/packages/lors/sql/postgresql/lors-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/sql/postgresql/lors-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/sql/postgresql/lors-create.sql 22 Apr 2004 03:42:06 -0000 1.1 +++ openacs-4/packages/lors/sql/postgresql/lors-create.sql 4 Sep 2004 14:04:07 -0000 1.2 @@ -18,151 +18,6 @@ -- details. -- - --- Create Learning Object Content Type -select content_type__create_type ( - 'learning_object', -- content_type - 'content_revision', -- supertype. - 'Learning Object', -- pretty_name - 'Learning Objects', -- pretty_plural - 'lors_objects', -- table_name - 'lo_id', -- id_column - 'lors__get_title' -- name_method -); - --- Register attributes --- lo_type: this could be: SCO/A, asset, etc --- according to the scheme we use (SCORM, IMS, etc). -select content_type__create_attribute ( - 'learning_object', -- content_type - 'lo_type', -- type of learning object - 'text', -- data type - 'learning object type', -- pretty - null, -- pretty plural - null, -- sort order - 'file', -- default 'f' - 'varchar(50)' -- colum spec -); - --- If the learning object has metadata --- Note: on the ims-md table we will record what the metadata --- schema that we use. ie: IMS, Dublin Core, etc -select content_type__create_attribute ( - 'learning_object', -- content_type - 'has_metadata', -- column name - 'boolean', -- data type - 'has metadata', -- pretty - null, -- pretty plural - null, -- sort order - 'f', -- default 'f' - 'boolean' -- colum spec -); - --- Add a new LO function -create or replace function lors__new_lo( - varchar, -- cr_items.name%TYPE, - integer, -- cr_items.parent_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar -- acs_objects.creation_ip%TYPE, -) returns integer as ' -- cr_items.item_id%TYPE -declare - new_lo__title alias for $1; - new_lo__folder_id alias for $2; - new_lo__user_id alias for $3; - new_lo__creation_ip alias for $4; - v_item_id integer; -begin - - v_item_id := content_item__new ( - new_lo__title, -- name - new_lo__folder_id, -- parent_id - null, -- item_id (default) - null, -- locale (default) - now(), -- creation_date (default) - new_lo__user_id, -- creation_user - new_lo__folder_id, -- context_id - new_lo__creation_ip, -- creation_ip - ''content_item'', -- item_subtype (default) - ''learning_object'', -- content_type - null, -- title (default) - null, -- description - ''text/plain'', -- mime_type (default) - null, -- nls_language (default) - null, -- text (default) - ''file'' -- storage_type - ); - - perform acs_object__update_last_modified(new_lo__folder_id,new_lo__user_id,new_lo__creation_ip); - - return v_item_id; - -end;' language 'plpgsql'; - --- Adds a new LO revision -create or replace function lors__new_lo_version ( - -- - -- Create a new version of a learning object - -- Wrapper for content_revision__new - -- - varchar, -- cr_revisions.title%TYPE, - varchar, -- cr_revisions.description%TYPE, - varchar, -- cr_revisions.mime_type%TYPE, - integer, -- cr_items.item_id%TYPE, - integer, -- acs_objects.creation_user%TYPE, - varchar -- acs_objects.creation_ip%TYPE -) returns integer as ' -- cr_revisions.revision_id -declare - new_version__filename alias for $1; - new_version__description alias for $2; - new_version__mime_type alias for $3; - new_version__item_id alias for $4; - new_version__creation_user alias for $5; - new_version__creation_ip alias for $6; - v_revision_id cr_revisions.revision_id%TYPE; - v_folder_id cr_items.parent_id%TYPE; -begin - -- Create a revision - v_revision_id := content_revision__new ( - new_version__filename, -- title - new_version__description, -- description - now(), -- publish_date - new_version__mime_type, -- mime_type - null, -- nls_language - null, -- data (default) - new_version__item_id, -- item_id - null, -- revision_id - now(), -- creation_date - new_version__creation_user, -- creation_user - new_version__creation_ip -- creation_ip - ); - - -- Make live the newly created revision - perform content_item__set_live_revision(v_revision_id); - - select cr_items.parent_id - into v_folder_id - from cr_items - where cr_items.item_id = new_version__item_id; - - perform acs_object__update_last_modified(v_folder_id,new_version__creation_user,new_version__creation_ip); - - return v_revision_id; - -end;' language 'plpgsql'; - - --- Delete a LO -create or replace function lors__delete_lo ( - integer -- cr_items.item_id%TYPE -) returns integer as ' -declare - delete_lo__lo_id alias for $1; -begin - - return content_item__delete(delete_lo__lo_id); - -end;' language 'plpgsql'; - -- Creates a folder to store LOs create or replace function lors__new_folder( -- @@ -247,7 +102,9 @@ end;' language 'plpgsql'; + -- loads IMS Metadata Data Model \i lors-imsmd-create.sql \i lors-imscp-create.sql -\i lors-imscp-package-create.sql \ No newline at end of file +\i lors-imscp-package-create.sql +\i lors-imsmd-sc-create.sql Index: openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql 22 Apr 2004 03:42:06 -0000 1.1 +++ openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql 4 Sep 2004 14:04:07 -0000 1.2 @@ -33,8 +33,8 @@ PERFORM acs_object_type__create_type ( ''ims_manifest'', -- object_type - ''Manifest'', -- pretty_name - ''Manifests'', -- pretty_plural + ''IMS_Manifest'', -- pretty_name + ''IMS_Manifests'', -- pretty_plural ''acs_object'', -- supertype ''imscp_manifests'', -- table_name ''man_id'', -- id_column @@ -45,8 +45,8 @@ ); PERFORM acs_object_type__create_type ( ''ims_organization'', -- object_type - ''Organization'', -- pretty_name - ''Organizations'', -- pretty_plural + ''IMS_Organization'', -- pretty_name + ''IMS_Organizations'', -- pretty_plural ''ims_manifest'', -- supertype ''imscp_organizations'', -- table_name ''org_id'', -- id_column @@ -57,8 +57,8 @@ ); PERFORM acs_object_type__create_type ( ''ims_item'', -- object_type - ''Item'', -- pretty_name - ''Items'', -- pretty_plural + ''IMS_Item'', -- pretty_name + ''IMS_Items'', -- pretty_plural ''ims_organization'', -- supertype ''imscp_items'', -- table_name ''item_id'', -- id_column @@ -69,8 +69,8 @@ ); PERFORM acs_object_type__create_type ( ''ims_resource'', -- object_type - ''Resource'', -- pretty_name - ''Resources'', -- pretty_plural + ''IMS_Resource'', -- pretty_name + ''IMS_Resources'', -- pretty_plural ''ims_item'', -- supertype ''imscp_resources'', -- table_name ''org_id'', -- id_column @@ -100,12 +100,13 @@ identifier varchar(1000), version varchar(100), orgs_default varchar(100), - hasmetadata boolean, + hasmetadata boolean default 'f' not null, -- A manifest could have multiple submanifests parent_man_id integer, isscorm boolean, folder_id integer, - fs_package_id integer + fs_package_id integer, + isshared boolean default 'f' not null ); comment on table ims_cp_manifests is ' @@ -155,7 +156,8 @@ identifier varchar(100), structure varchar(100), title varchar(1000), - hasmetadata boolean + hasmetadata boolean default 'f' not null, + isshared boolean default 'f' not null ); -- create index for ims_cp_organizations @@ -181,15 +183,16 @@ parameters varchar(1000), title varchar(1000), parent_item integer, - hasmetadata boolean, + hasmetadata boolean default 'f' not null, -- SCORM extensions (based on SCORM 1.2 specs) prerequisites_t varchar(100), prerequisites_s varchar(200), type varchar(1000), maxtimeallowed varchar(1000), timelimitaction varchar(1000), datafromlms varchar(200), - masteryscore varchar(255) + masteryscore varchar(255), + isshared boolean default 'f' not null ); -- create index for ims_cp_items @@ -211,7 +214,7 @@ identifier varchar(1000), type varchar(1000), href varchar(2000), - hasmetadata boolean, + hasmetadata boolean default 'f' not null, -- SCORM specific scorm_type varchar(1000) ); @@ -270,10 +273,62 @@ on delete cascade, pathtofile varchar(2000), filename varchar(2000), - hasmetadata boolean, + hasmetadata boolean default 'f' not null, constraint ims_cp_file_pk primary key (file_id, res_id) ); -- create index for ims_cp_files create index ims_cp_files__res_id_idx on ims_cp_files (res_id); + + +create table ims_cp_manifest_class ( + man_id integer + constraint ims_cp_manifest_class__man_id_fk + references ims_cp_manifests(man_id) + on delete cascade, + lorsm_instance_id integer + constraint ims_cp_manifest_class__lorsm_fk + references apm_packages (package_id), + community_id integer + constraint ims_cp_manifest_class__comm_id_fk + references dotlrn_communities_all(community_id), + class_key varchar(100) + constraint ims_cp_manifest_class__class_key_fk + references dotlrn_community_types(community_type), + isenabled boolean default 't' not null, + istrackable boolean default 'f' not null, + primary key (man_id, lorsm_instance_id) +); + +comment on table ims_cp_manifest_class is ' +This table helps us manage the relations between a manifest (course) +and its .LRN class/community +'; + +comment on column ims_cp_manifest_class.man_id is ' +This is the manifest_id for the course +'; + +comment on column ims_cp_manifest_class.lorsm_instance_id is ' +This is the package_id for the instance of LORMS in a particular +.LRN class/community. This is *NOT* the community_id. +'; + +comment on column ims_cp_manifest_class.community_id is ' +This is the package_id for the class/community that the manifest got uploaded +'; + +comment on column ims_cp_manifest_class.class_key is ' +This is the class_key for the class/community +'; + +comment on column ims_cp_manifest_class.isenabled is ' +Whether the course is enabled for that community instance. +default true +'; + +comment on column ims_cp_manifest_class.istrackable is ' +Whether the course is trackable for that community instance. +default false +'; Index: openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql 22 Apr 2004 03:42:06 -0000 1.1 +++ openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql 4 Sep 2004 14:04:07 -0000 1.2 @@ -36,7 +36,9 @@ timestamp with time zone, -- creation_date integer, -- creation_user varchar, -- creation_ip - integer -- package_id + integer, -- package_id + integer, -- community_id + varchar -- class_key ) returns integer as ' declare @@ -49,11 +51,13 @@ p_parent_man_id alias for $7; p_isscorm alias for $8; p_folder_id alias for $9; - p_fs_package_id alias for $10; + p_fs_package_id alias for $10; p_creation_date alias for $11; p_creation_user alias for $12; p_creation_ip alias for $13; p_package_id alias for $14; + p_community_id alias for $15; + p_class_key alias for $16; v_man_id integer; begin @@ -72,6 +76,14 @@ values (v_man_id, p_course_name, p_identifier, p_version, p_orgs_default, p_hasmetadata, p_parent_man_id, p_isscorm, p_folder_id, p_fs_package_id); + -- now we add it to the manifest_class relation table + + insert into ims_cp_manifest_class + (man_id, lorsm_instance_id, community_id, class_key, isenabled, istrackable) + values + (v_man_id, p_package_id, p_community_id, p_class_key, ''t'', ''f''); + + return v_man_id; end; ' language 'plpgsql'; @@ -373,4 +385,34 @@ return p_file_id; end; -' language 'plpgsql'; \ No newline at end of file +' language 'plpgsql'; + + +-- put in and correct some stuff for ims_cp_items + +-- function name +create or replace function ims_item__name (integer) +returns varchar as ' +declare + name__object_id alias for $1; + v_title ims_cp_items.title%TYPE; + v_object_id integer; +begin + + select title + into v_title + from ims_cp_items + where item_id = name__object_id; + + return v_title; + +end;' language 'plpgsql' stable strict; + + +update acs_object_types +set table_name = 'ims_cp_items', + name_method = 'ims_item__name', + pretty_name = 'IMS Item', + pretty_plural = 'IMS Items' +where object_type = 'ims_item'; + Index: openacs-4/packages/lors/sql/postgresql/lors-imsmd-sc-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/sql/postgresql/lors-imsmd-sc-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/sql/postgresql/lors-imsmd-sc-create.sql 4 Sep 2004 14:04:07 -0000 1.1 @@ -0,0 +1,163 @@ +-- This is LORS IMS Metadata implementation of the FtsContentProvider +-- service contract + + +-- for manifests metadata + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_manifest', -- impl_name + 'lors' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_manifest', -- impl_name + 'datasource', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_manifest', -- impl_name + 'url', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__url', -- impl_alias + 'TCL' -- impl_pl +); + + +create function ims_md_record__itrg () +returns opaque as ' +begin + perform search_observer__enqueue(new.ims_md_id,''INSERT''); + return null; +end;' language 'plpgsql'; + +create function ims_md_record__dtrg () +returns opaque as ' +begin + perform search_observer__enqueue(old.ims_md_id,''DELETE''); + return old; +end;' language 'plpgsql'; + +create function ims_md_record__utrg () +returns opaque as ' +begin + perform search_observer__enqueue(old.ims_md_id,''DELETE''); + perform search_observer__enqueue(old.ims_md_id,''UPDATE''); + return old; +end;' language 'plpgsql'; + + +create trigger lors_imsmd__itrg after insert on ims_md +for each row execute procedure ims_md_record__itrg (); + +create trigger lors_imsmd__dtrg after delete on ims_md +for each row execute procedure ims_md_record__dtrg (); + +create trigger pinds_blog_entries__utrg after update on ims_md +for each row execute procedure ims_md_record__utrg (); + +-- Add the binding + +select acs_sc_binding__new ( + 'FtsContentProvider', + 'ims_manifest' +); + + +-- for organization's metadata + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_organization', -- impl_name + 'lors' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_organization', -- impl_name + 'datasource', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_organization', -- impl_name + 'url', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__url', -- impl_alias + 'TCL' -- impl_pl +); + +-- Add the binding + +select acs_sc_binding__new ( + 'FtsContentProvider', + 'ims_organization' +); + + +-- for item's metadata + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_item', -- impl_name + 'lors' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_item', -- impl_name + 'datasource', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_item', -- impl_name + 'url', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__url', -- impl_alias + 'TCL' -- impl_pl +); + +-- Add the binding + +select acs_sc_binding__new ( + 'FtsContentProvider', + 'ims_item' +); + + +-- for resource's metadata + +select acs_sc_impl__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_resource', -- impl_name + 'lors' -- impl_owner_name +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_resource', -- impl_name + 'datasource', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__datasource', -- impl_alias + 'TCL' -- impl_pl +); + +select acs_sc_impl_alias__new( + 'FtsContentProvider', -- impl_contract_name + 'ims_resource', -- impl_name + 'url', -- impl_operation_name + 'lors::imsmd::sc::mdrecord__url', -- impl_alias + 'TCL' -- impl_pl +); + +-- Add the binding + +select acs_sc_binding__new ( + 'FtsContentProvider', + 'ims_resource' +); Index: openacs-4/packages/lors/tcl/lors-imscp-blackboard6-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imscp-blackboard6-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/tcl/lors-imscp-blackboard6-procs.tcl 4 Sep 2004 14:04:08 -0000 1.1 @@ -0,0 +1,1029 @@ +ad_library { + + IMS Content Packaging functions + for Blackboard 6 + + @creation-date 2003-10-13 + @author Ernie Ghiglione (ErnieG@mm.st) + @cvs-id $Id: lors-imscp-blackboard6-procs.tcl,v 1.1 2004/09/04 14:04:08 ernieg Exp $ + +} + +# +# Copyright (C) 2004 Ernie Ghiglione +# +# This package is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# It is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# + +namespace eval lors::imscp::bb6 {} + +ad_proc -public lors::imscp::bb6::isBlackboard6 { + -tmp_dir:required +} { + Checks whether the IMS CP package is a a Blackboard 6 package (or + has Blackboard6 extensions) + + Blackboard6 exports add a .bb-package-info file that contain + technical details of the Blackboard installation. Therefore, we + will check if the package comes with this file. If it does. we + return 1, otherwise 0. + + @param tmp_dir temporary directory + @author Ernie Ghiglione (ErnieG@mm.st) + +} { + return [file exists $tmp_dir/.bb-package-info] +} + + +ad_proc -public lors::imscp::bb6::getItems { + {tree} + {parent ""} +} { + Extracts data from Items + + @option tree the XML node that contains the Items to get. + @option parent parent item node (items can have subitems). + @author Ernie Ghiglione (ErnieG@mm.st) + +} { + set items "" + set itemx [$tree child all item] + + if { ![empty_string_p $itemx] } { + + if {[empty_string_p $parent]} { + set parent 0 + } + + set it_list "" + foreach itemx [$tree child all item] { + + set cc "" + #{$parent}" + # gets item identifier + set cc "[lors::imsmd::getAtt $itemx identifier]" + + # gets item identifierref + set cc [concat $cc "[lors::imsmd::getAtt $itemx identifierref]"] + + # gets xml node + set cc [concat $cc $itemx] + + set it_list [concat $it_list [list $cc]] + + set itemxx [$itemx child all item] + if { ![empty_string_p $itemxx] } { + set it_list [concat $it_list [getItems $itemx]] + } + set items [concat $items $cc] + } + } + return $it_list + #$items +} + + +ad_proc -public lors::imscp::bb6::getTitle { + -node:required +} { + Gets the title for a Blackboard course + + @option node XML node + @author Ernie Ghiglione (ErnieG@mm.st) +} { + set title_node [$node child all TITLE] + if {![empty_string_p title_node]} { + set title [lors::imsmd::getAtt $title_node value] + return $title + } else { + return "" + } +} + +ad_proc -public lors::imscp::bb6::getDescription { + -node:required +} { + Gets the description for a Blackboard course + + @option node XML node + @author Ernie Ghiglione (ErnieG@mm.st) +} { + set desc_node [$node child all DESCRIPTION] + if {![empty_string_p desc_node]} { + set desc [lors::imsmd::getElement $desc_node] + return $desc + } else { + return "" + } +} + +ad_proc -public lors::imscp::bb6::getDates { + -node:required +} { + Gets the dates for a Blackboard course + + @option node XML node + @author Ernie Ghiglione (ErnieG@mm.st) +} { + set dates_node [$node child all DATES] + if {![empty_string_p dates_node]} { + set created [$dates_node child all CREATED] + set updated [$dates_node child all UPDATED] + return [list [lors::imsmd::getAtt $created value] [lors::imsmd::getAtt $updated value]] + } else { + return "" + } +} + +ad_proc -public lors::imscp::bb6::content_getFlags { + -name:required + -node:required +} { + Gets the flags for a Blackboard course + + @option name Name of the attribute to get + @option node XML node + @author Ernie Ghiglione (ErnieG@mm.st) +} { + set flags_node [$node child all FLAGS] + if {![empty_string_p flags_node]} { + set getname [$flags_node child all [string toupper $name]] + + if {![empty_string_p getname]} { + return [lors::imsmd::getAtt $getname value] + } else { + return "" + } + + } else { + return "" + } +} + +ad_proc -public lors::imscp::bb6::content_getItemAttributes { + -node:required +} { + Gets the Navigation items for a Blackboard course + + @option name Name of the attribute to get + @option node XML node + + @author Ernie Ghiglione (ErnieG@mm.st) +} { + set navigation [$node child all [string toupper NAVIGATION]] + if {![empty_string_p flags_node]} { + + set items [$navigation child all ITEM] + set item_list [list] + + foreach item $items { + set item_value [lors::imsmd::getAtt $item value] + set item_label [lors::imsmd::getAtt $item label] + set item_issecure [lors::imsmd::getAtt $item issecure] + set item_isavailable [lors::imsmd::getAtt $item isavailable] + + lappend item_list [list $item_value $item_label $item_issecure $item_isavailable] + } + return $item_list + } else { + return "" + } +} + +ad_proc -public lors::imscp::bb6::get_coursetoc { + -file:required +} { + Gets content from Blackboard's course/x-bb-coursetoc elements + + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # open xml file + set doc [dom parse [read [open $file]]] + # coursetoc + set coursetoc [$doc documentElement] + + set list_items [list] + + # gets coursetoc elements and values + lappend list_items {id} [lors::imsmd::getAtt $coursetoc id] + lappend list_items {LABEL} [lors::imsmd::getAtt [$coursetoc getElementsByTagName LABEL] value] + lappend list_items {URL} [lors::imsmd::getAtt [$coursetoc getElementsByTagName URL] value] + lappend list_items {TARGETTYPE} [lors::imsmd::getAtt [$coursetoc getElementsByTagName TARGETTYPE] value] + lappend list_items {INTERNALHANDLE} [lors::imsmd::getAtt [$coursetoc getElementsByTagName INTERNALHANDLE ] value] + lappend list_items {LAUNCHINNEWWINDOW} [lors::imsmd::getAtt [$coursetoc getElementsByTagName LAUNCHINNEWWINDOW] value] + lappend list_items {ISENABLED} [lors::imsmd::getAtt [$coursetoc getElementsByTagName ISENABLED] value] + lappend list_items {ISENTYRPOINT} [lors::imsmd::getAtt [$coursetoc getElementsByTagName ISENTYRPOINT] value] + lappend list_items {ALLOWOBSERVERS} [lors::imsmd::getAtt [$coursetoc getElementsByTagName ALLOWOBSERVERS] value] + lappend list_items {ALLOWGUESTS} [lors::imsmd::getAtt [$coursetoc getElementsByTagName ALLOWGUESTS] value] + + # deletes the dom + $doc delete + + # return list + return $list_items + +} + + +ad_proc -public lors::imscp::bb6::get_bb_doc { + -file:required +} { + Gets content from Blackboard's resource/x-bb-documen elements + + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # open xml file + set doc [dom parse [read [open $file]]] + # content + set content [$doc documentElement] + + set list_items [list] + + # gets content elements and values + lappend list_items {id} [lors::imsmd::getAtt $content id] + lappend list_items {TITLE} [lors::imsmd::getAtt [$content getElementsByTagName TITLE] value] + lappend list_items {TITLECOLOR} [lors::imsmd::getAtt [$content getElementsByTagName TITLECOLOR] value] + lappend list_items {TEXT} [lors::imsmd::getElement [$content getElementsByTagName TEXT]] + lappend list_items {TYPE} [lors::imsmd::getAtt [$content getElementsByTagName TYPE] value] + lappend list_items {CREATED} [lors::imsmd::getAtt [$content selectNodes /CONTENT/DATES/CREATED] value] + lappend list_items {UPDATED} [lors::imsmd::getAtt [$content selectNodes /CONTENT/DATES/UPDATED] value] + lappend list_items {START} [lors::imsmd::getAtt [$content getElementsByTagName START] value] + lappend list_items {ISAVAILABLE} [lors::imsmd::getAtt [$content getElementsByTagName ISAVAILABLE] value] + lappend list_items {ISFROMCARTRIDGE} [lors::imsmd::getAtt [$content getElementsByTagName ISFROMCARTRIDGE] value] + lappend list_items {ISFOLDER} [lors::imsmd::getAtt [$content getElementsByTagName ISFOLDER] value] + lappend list_items {ISDESCRIBED} [lors::imsmd::getAtt [$content getElementsByTagName ISDESCRIBED] value] + lappend list_items {ISTRACKED} [lors::imsmd::getAtt [$content getElementsByTagName ISTRACKED] value] + lappend list_items {ISLESSON} [lors::imsmd::getAtt [$content getElementsByTagName ISLESSON] value] + lappend list_items {ISSEQUENTIAL} [lors::imsmd::getAtt [$content getElementsByTagName ISSEQUENTIAL] value] + lappend list_items {ALLOWGUESTS} [lors::imsmd::getAtt [$content getElementsByTagName ALLOWGUESTS] value] + lappend list_items {ALLOWOBSERVERS} [lors::imsmd::getAtt [$content getElementsByTagName ALLOWOBSERVERS] value] + lappend list_items {LAUNCHINNEWWINDOW} [lors::imsmd::getAtt [$content getElementsByTagName LAUNCHINNEWWINDOW] value] + lappend list_items {CONTENTHANDLER} [lors::imsmd::getAtt [$content getElementsByTagName CONTENTHANDLER] value] + lappend list_items {RENDERTYPE} [lors::imsmd::getAtt [$content getElementsByTagName RENDERTYPE] value] + lappend list_items {URL} [lors::imsmd::getAtt [$content getElementsByTagName URL] value] + + set files [list] + foreach file [[$content selectNodes /CONTENT/FILES] childNodes] { + + set file_list [list] + lappend file_list {file_id} [lors::imsmd::getAtt $file id] + lappend file_list {NAME} [lors::imsmd::getElement [$file getElementsByTagName NAME]] + lappend file_list {LINKNAME} [lors::imsmd::getAtt [$file getElementsByTagName LINKNAME] value] + lappend file_list {SIZE} [lors::imsmd::getAtt [$file getElementsByTagName SIZE] value] + lappend file_list {CREATED} [lors::imsmd::getAtt [$file getElementsByTagName CREATED] value] + lappend file_list {UPDATED} [lors::imsmd::getAtt [$file getElementsByTagName UPDATED] value] + + lappend files $file_list + + } + + lappend list_items {FILES} $files + + # deletes the dom + $doc delete + + # return list + return $list_items + +} + + +ad_proc -public lors::imscp::bb6::txt_to_html { + -txt:required + -filename:required +} { + Creates an HTML file from TXT + + @option txt Text to transform into HTML + @option filename directory and filename where we are putting the file + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # get directory info + set dirname [file dirname $filename] + + # check if directory exists + if { ![file exists $dirname] } { + # create dir + file mkdir $dirname + } + + # transforms text into html + if {[lors::imscp::bb6::looks_like_html_p -text $txt]} { +# set txt [ad_text_to_html -includes_html $txt] + } else { + set txt [ad_text_to_html -includes_html $txt] +# set txt [ad_html_text_convert -from "text/plain" -to "text/html" $txt] + } + + # saves it on a new html file + set f_handler [open $filename w+] + fconfigure $f_handler -encoding utf-8 + puts -nonewline $f_handler " \ $txt \" + close $f_handler + + # returns what is is an href for resources + return $filename + +} + + +ad_proc -public lors::imscp::bb6::looks_like_html_p { + -text:required +} { + Creates an HTML file from TXT. + This one expands ad_looks_like_html_p + + @param txt text to check for html tags + @return 1 if it looks like html, 0 if not. + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + if { [regexp -nocase {

} $text] || [regexp -nocase {
} $text] || [regexp -nocase {} $text] || [regexp -nocase {} $text] } { + return 1 + } else { + return 0 + } + +} + + +ad_proc -public lors::imscp::bb6::get_announcement { + -file:required +} { + Gets content from Blackboard's resource/x-bb-announcement elements + + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # open xml file + set doc [dom parse [read [open $file]]] + # content + set announcement [$doc documentElement] + + set list_items [list] + + # gets announcement elements and values + lappend list_items {id} [lors::imsmd::getAtt $announcement id] + lappend list_items {TITLE} [lors::imsmd::getAtt [$announcement getElementsByTagName TITLE] value] + lappend list_items {DESCRIPTION} [lors::imsmd::getElement [$announcement getElementsByTagName TEXT]] + lappend list_items {ISHTML} [lors::imsmd::getAtt [$announcement getElementsByTagName ISHTML] value] + lappend list_items {ISPERMANENT} [lors::imsmd::getAtt [$announcement getElementsByTagName ISPERMANENT] value] + lappend list_items {USERID} [lors::imsmd::getAtt [$announcement getElementsByTagName USERID] value] + lappend list_items {CREATED} [lors::imsmd::getAtt [$announcement getElementsByTagName CREATED] value] + lappend list_items {UPDATED} [lors::imsmd::getAtt [$announcement getElementsByTagName CREATED] value] + lappend list_items {RESTRICTSTART} [lors::imsmd::getAtt [$announcement getElementsByTagName RESTRICTSTART] value] + lappend list_items {RESTRICTEND} [lors::imsmd::getAtt [$announcement getElementsByTagName RESTRICTEND] value] + + + # deletes the dom + $doc delete + + # return list + return $list_items + +} + + +ad_proc -public lors::imscp::bb6::get_forum { + -file:required +} { + Gets content from Blackboard's resource/x-bb-discussionboard elements + + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # open xml file + set doc [dom parse [read [open $file]]] + # content + set forum [$doc documentElement] + + set list_items [list] + + # gets forum elements and values + lappend list_items {id} [lors::imsmd::getAtt $forum id] + lappend list_items {TITLE} [lors::imsmd::getAtt [$forum getElementsByTagName TITLE] value] + lappend list_items {DESCRIPTION} [lindex [lors::imsmd::getElement [$forum getElementsByTagName TEXT]] 0] + lappend list_items {ISHTML} [lors::imsmd::getAtt [$forum getElementsByTagName ISHTML] value] + lappend list_items {CREATED} [lors::imsmd::getAtt [$forum getElementsByTagName CREATED] value] + lappend list_items {UPDATED} [lors::imsmd::getAtt [$forum getElementsByTagName CREATED] value] + + # deletes the dom + $doc delete + + # return list + return $list_items + +} + + +### Cleanup Functions + +ad_proc -public lors::imscp::bb6::create_MD { + -tmp_dir:required + -file:required +} { + Blackboard 6 by default does not create manifest metadata. + However, it does have some sort of metadata in the res00001.dat + file, so we extract that information and create a LOM metadata record + + @param tmp_dir temporary directory where the imsmanifest.xml is located. + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + # set utf-8 system encoding + encoding system utf-8 + + # open manifest file with tDOM + set doc [dom parse [read [open $tmp_dir/$file]]] + # gets the manifest tree + set manifest [$doc documentElement] + + # Check if it has a metadata node for the manifest + # If it doesn't let's create one with the description we get from + # res00001.dat + + set metadata [$manifest child all metadata] + + if {[empty_string_p $metadata]} { + + set filex res00001.dat + set docx [dom parse [read [open $tmp_dir/$filex]]] + # gets BB's course info + set course [$docx documentElement] + + set title [lors::imsmd::getAtt [$course selectNodes /COURSE/TITLE] value] + set description [lindex [lors::imsmd::getElement [$course selectNodes /COURSE/DESCRIPTION]] 0] + + $docx delete + + # create a metadata node + set docx [dom createDocument metadata] + set metadata [$docx documentElement] + + + set general_node [lors::imsmd::create::lom_general \ + -owner $metadata \ + -title [list en $title] \ + -description [list en $description] \ + ] + + set lom_node [lors::imsmd::create::lom \ + -owner $metadata \ + -general $general_node \ + ] + + set md [lors::imsmd::create::md -owner $metadata \ + -schema "IMS Content" \ + -schemaversion "1.1.2" \ + -lom $lom_node \ + ] + + $manifest insertBefore $md [$manifest child all organizations] + + set f_handler [open /tmp/imsmanifest.xml w+] + puts -nonewline $f_handler [$manifest asXML -indent 1 -escapeNonASCII] + close $f_handler + + $doc delete + + file copy -force /tmp/imsmanifest.xml $tmp_dir/$file + + } + +} + + +ad_proc -public lors::imscp::bb6::clean_items { + -tmp_dir:required + -file:required +} { + This function cleans up a lot of the unused and empty ims_items that Blackboard has when exporting their courses. Apparently Blackboard exports all their application information and sets the availability of these applications within the .dat files. This function looks into some of the Blackboard specific resource types and based on their availability or data, we adapt it to a purer IMS CP standards. + + @param tmp_dir temporary directory where the imsmanifest.xml is located. + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + + # set utf-8 system encoding + encoding system utf-8 + + # search for manifest file + set file $file + + # set utf-8 system encoding + encoding system utf-8 + + # open xml file + set doc [dom parse [read [open $tmp_dir/$file]]] + + # gets the manifest tree + set manifest [$doc documentElement] + + # Gets the organizations + + set organizations [$manifest child all organizations] + + if { ![empty_string_p $organizations] } { + + set num_organizations [$organizations child all organization] + + set items 0 + + set items_list [list] + foreach organization $num_organizations { + + set items_list [lors::imscp::bb6::getItems $organization] + + } + + } + + + # gets the resources + set resources [$manifest child all resources] + + # Complain if there's no resources + if {[empty_string_p $resources]} { + ad_return_complaint 1 "The package you are trying to upload doesn't have resources. Please check the $file and try again" + ad_script_abort + } + + set resourcex [$resources child all resource] + + set resources_list [list] + foreach resource $resourcex { + + set res_identifier [lors::imsmd::getResource -node $resource -att identifier] + set res_type [lors::imsmd::getResource -node $resource -att type] + set res_href [lors::imsmd::getResource -node $resource -att href] + set res_dependencies [lors::imsmd::getResource -node $resource -att dependencies] + set res_hasmetadata [lors::imsmd::hasMetadata $resource] + set res_files [lors::imsmd::getResource -node $resource -att files] + set res_scormtype [lors::imsmd::getAtt $resource adlcp:scormtype] + + switch $res_type { + + "course/x-bb-coursetoc" { + + set file [lors::imsmd::getAtt $resource bb:file] + array set ernie [lors::imscp::bb6::get_coursetoc -file $tmp_dir/$file] + + set enabled_p $ernie(ISENABLED) + + } + + "resource/x-bb-document" { + + set file [lors::imsmd::getAtt $resource bb:file] + array set ernie [lors::imscp::bb6::get_bb_doc -file $tmp_dir/$file] + + set enabled_p $ernie(ISAVAILABLE) + + } + + default { + set enabled_p "no_type" + } + + + + } + + lappend resources_list [list [lors::imsmd::getAtt $resource identifier] [lors::imsmd::getAtt $resource type] $resource $enabled_p] + + } + + ns_log Notice "HERE IS THE LIST OF ITEMS: ([llength $items_list]) $items_list \nResource list ([llength $resources_list]) $resources_list" + + ns_log Notice "\n\n" + + foreach item $items_list { + + ns_log Notice "\n------Begin-----\nItem identifier [lindex $item 0]\n" + ns_log Notice "Item resource reference: [lindex $item 1]\n" + + ns_log Notice "Lsearch result: [lsearch -regexp $resources_list [lindex $item 1]]\n" + + set resource [lindex $resources_list [lsearch -regexp $resources_list [lindex $item 1]]] + + ns_log Notice "is Resource enabled?: [lindex $resource 3]\n" + + if {[lindex $resource 3] == "false"} { + + switch [lindex $resource 1] { + + "resource/x-bb-document" { + # if the resource is a document and also is false or + # disable, that means (according to my interpretation + # of Blackboard XML files, that these documents are + # only to be rendered to admins, but not to students. + + # Since IMS doesn't have anything to support + # permissions within their own items, then we added an + # attribute as an extension: dotLRN:permission. + + ns_log Notice "\tDocument Type\n" + ns_log Notice "\tAdding attribute to [lindex $item 2] \n" + [lindex $item 2] setAttributeNS dotLRN dotLRN:permission admin + } + + "course/x-bb-coursetoc" { + + ns_log Notice "\Coursetoc Type LOPEZ\n" + ns_log Notice "\tAdding attribute to [lindex $item 2] \n" + if {![empty_string_p [[lindex $item 2] child all item]]} { + [lindex $item 2] setAttributeNS dotLRN dotLRN:permission admin + } else { + ns_log Notice "\tdeleting [lindex $item 0] - [lindex $item 2] as it is false\n" + ns_log Notice "\tdeleting node [lindex $item 2] \n" + + [lindex $item 2] delete + + ns_log Notice "\tand its corresponding resource [lindex $resource 2]\n" + ns_log Notice "\tDeleting files from FS: [lors::imsmd::getResource -node [lindex $resource 2] -att files]\n" + ns_log Notice "\tDeleting dat file: [lors::imsmd::getAtt [lindex $resource 2] bb:file]\n" + file delete $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file] + [lindex $resource 2] delete + } + + } + + default { + + if {[empty_string_p [[lindex $item 2] child all item]]} { + ns_log Notice "\tdeleting [lindex $item 0] - [lindex $item 2] as it is false\n" + ns_log Notice "\tdeleting node [lindex $item 2] \n" + + [lindex $item 2] delete + + ns_log Notice "\tand its corresponding resource [lindex $resource 2]\n" + ns_log Notice "\tDeleting files from FS: [lors::imsmd::getResource -node [lindex $resource 2] -att files]\n" + ns_log Notice "\tDeleting dat file: [lors::imsmd::getAtt [lindex $resource 2] bb:file]\n" + file delete $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file] + [lindex $resource 2] delete + } + + } + } + + } else { + ns_log Notice "\tResource is enabled... therefore nothing to do here\n" + switch [lindex $resource 1] { + + "course/x-bb-coursetoc" { + + ns_log Notice "Item: [lindex $item 0] [lindex $item 1] ([lindex $item 2]) has [llength [[lindex $item 2] child all item]]] items" + if {[empty_string_p [[lindex $item 2] child all item]]} { + # this corsetoc item is childless, + # therefore we nuke it (as it is an + # empty folder + ns_log Notice "Therefore [lindex $item 0] [lindex $item 1] ([lindex $item 2]) we delete it.." + + [lindex $item 2] delete + + ns_log Notice "\tand its corresponding resource [lindex $resource 2]\n" + ns_log Notice "\tDeleting files from FS: [lors::imsmd::getResource -node [lindex $resource 2] -att files]\n" + ns_log Notice "\tDeleting dat file: [lors::imsmd::getAtt [lindex $resource 2] bb:file]\n" + file delete $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file] + [lindex $resource 2] delete + } + + } + default { + # this item has good content + ns_log Notice "\t we can't delete [lindex $item 0] - [lindex $item 2] as it has child items -- [[lindex $item 2] child all item]\n" + + } + + } + + } + ns_log Notice "------End------\n" + + } + + set f_handler [open /tmp/imsmanifest.xml w+] + puts -nonewline $f_handler [$manifest asXML -indent 1 -escapeNonASCII] + close $f_handler + + $doc delete + + file copy -force /tmp/imsmanifest.xml $tmp_dir/imsmanifest.xml + +} + + +ad_proc -public lors::imscp::bb6::extract_html { + -tmp_dir:required + -file:required +} { + This is a massive function that does a lot of things. + It extracts the HTML from Blackboard's proprietary .dat files + Cleans ups a lot of unused application data and resources. + (this should be customizable in a different functions) + + @param tmp_dir temporary directory where the imsmanifest.xml is located. + @option file filename + @author Ernie Ghiglione (ErnieG@mm.st) +} { + ## Opens imsmanifest.xml + + # set utf-8 system encoding + encoding system utf-8 + + # open manifest file with tDOM + set doc [dom parse [read [open $tmp_dir/$file]]] + # gets the manifest tree + set manifest [$doc documentElement] + + + # Gets the organizations + + set organizations [$manifest child all organizations] + + if { ![empty_string_p $organizations] } { + + set num_organizations [$organizations child all organization] + + set items 0 + + foreach organization $num_organizations { + + set items [expr $items + [lors::imscp::countItems $organization]] + + } + + } + + # gets the resources + set resources [$manifest child all resources] + + # Complain if there's no resources + if {[empty_string_p $resources]} { + ad_return_complaint 1 "The package you are trying to upload doesn't have resources. Please check the $file and try again" + ad_script_abort + } + + set resourcex [$resources child all resource] + + foreach resource $resourcex { + set res_identifier [lors::imsmd::getResource -node $resource -att identifier] + set res_type [lors::imsmd::getResource -node $resource -att type] + set res_href [lors::imsmd::getResource -node $resource -att href] + set res_dependencies [lors::imsmd::getResource -node $resource -att dependencies] + set res_hasmetadata [lors::imsmd::hasMetadata $resource] + set res_files [lors::imsmd::getResource -node $resource -att files] + set res_scormtype [lors::imsmd::getAtt $resource adlcp:scormtype] + + switch $res_type { + + "course/x-bb-coursetoc" { + + set file [lors::imsmd::getAtt $resource bb:file] + array set resourcext [lors::imscp::bb6::get_coursetoc -file $tmp_dir/$file] + + ns_log Notice "\n\n$file ($resourcext(ISENABLED)) $resourcext(LABEL)\n" + + # set content folder to be the appropiate IMS webcontent + # type instead of "couse/x-bb-coursetoc" BB's propietary type + $resource removeAttribute type + $resource removeAttribute bb:file + $resource removeAttribute bb:title + $resource setAttribute type webcontent + + } + + "resource/x-bb-document" { + + set file [lors::imsmd::getAtt $resource bb:file] + array set resourcext [lors::imscp::bb6::get_bb_doc -file $tmp_dir/$file] + + ns_log Notice "\n--resource document Begin\n" + ns_log Notice " ISFOLDER: $resourcext(ISFOLDER)" + ns_log Notice "\n\n $file [llength $resourcext(FILES)] $resourcext(FILES)" + + # change the resources type from proprietary BB's + # "resource/x-bb-document" to webcontent as defined by IMS + $resource removeAttribute type + $resource removeAttribute bb:title + $resource setAttribute type webcontent + + + if { $resourcext(ISFOLDER) == "true" } { + + if {$resourcext(TEXT) != "{}"} { + + ns_log Notice "\n it has text" + set folder [lors::imsmd::getAtt $resource identifier] + + set filename $resourcext(id).html + + set res_href [lors::imscp::bb6::txt_to_html -txt [lindex $resourcext(TEXT) 0] -filename $tmp_dir/$folder/$filename] + + regsub $tmp_dir $res_href {} res_href + ns_log Notice " \n And we set up the attribute to: href $res_href\n" + + $resource setAttribute href $res_href + + } else { + ns_log Notice "\n doesn't have text\n" + + + } + + } else { + # if it ain't a folder + + + # check if the content of TEXT tag is HTML or not + # If it is, then we need to assume that TEXT has + # embedded HTML code that references to the files + # under the FILES tag (this could be a bit tricky, but + # there's not much we can do for now + + ns_log Notice "\nlist of files: [lindex $resourcext(FILES) 0]\n" + + if { $resourcext(TYPE) == "H" } { + + + if {$resourcext(TEXT) != "{}"} { + + ns_log Notice "\n it has text" + set content [lindex $resourcext(TEXT) 0] + + # we transform the text into HTML if required + if {![lors::imscp::bb6::looks_like_html_p -text [lindex $resourcext(TEXT) 0]]} { + set content [ad_html_text_convert -from "text/plain" -to "text/html" [lindex $resourcext(TEXT) 0]] + } else { + set content [lindex $resourcext(TEXT) 0] + } + + set folder [lors::imsmd::getAtt $resource identifier] + + set filename $resourcext(id).html + + set counter 0 + set files_lister "" + + foreach file $resourcext(FILES) { + ns_log Notice "\n\t We gotta file: $file\n " + + if {[regexp [lindex $file 3] $content]} { + ns_log Notice "\t [lindex $file 5]: [lindex $file 3] is referenced\n" + } else { + if {$counter == 0} { + + append files_lister "

Files:

    \n" + } + append files_lister "\t
  • [lindex $file 5]
  • \n" + incr counter + ns_log Notice "\t [lindex $file 5]: [lindex $file 3] ISN'T referenced\n" + } + + } + + if {$counter > 0} { + append files_lister "
\n\n" + regsub -nocase "" $content $files_lister content + } + + + set res_href [lors::imscp::bb6::txt_to_html -txt $content -filename $tmp_dir/$folder/$filename] + + regsub $tmp_dir $res_href {} res_href + ns_log Notice " \n And we set up the attribute to: href $res_href\n" + + $resource setAttribute href $res_href + + } + + } else { + + + if {![empty_string_p [lindex $resourcext(FILES) 0]]} { + array set file_href [lindex $resourcext(FILES) 0] + ns_log Notice "\n the HREF for this file should be /$res_identifier/$file_href(NAME)\n" + + set res_href "/$res_identifier/$file_href(NAME)" + + $resource setAttribute href $res_href + + + } else { + set folder [lors::imsmd::getAtt $resource identifier] + + set filename $resourcext(id).html + + set res_href [lors::imscp::bb6::txt_to_html -txt [lindex $resourcext(TEXT) 0] -filename $tmp_dir/$folder/$filename] + + regsub $tmp_dir $res_href {} res_href + ns_log Notice " \n And we set up the attribute to: href $res_href\n" + + $resource setAttribute href $res_href + + + } + } + } + + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + ns_log Notice "\n--DELETED FILE $tmp_dir/[lors::imsmd::getAtt $resource bb:file]--\n" + $resource removeAttribute bb:file + ns_log Notice "\n--resource document END--\n" + + } + "assessment/x-bb-qti-survey" { + + # if it's not content, then we delete the resource and the + # dat file. + ns_log Notice "\n--resource qti-survey: [lors::imsmd::getAtt $resource bb:file] deleted\n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + ns_log Notice "Deleting qti-survey resource $resource" + $resource delete + + + } + "resource/x-bb-announcement" { + ns_log Notice "\n--resource ANNOUNCEMENT \n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + $resource delete + ns_log Notice "Deleting Announcement resource $resource" + ns_log Notice "Deleting Announcement resource $resource" + + } + "resource/x-bb-discussionboard" { + ns_log Notice "\n--resource FORUM POSTING \n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + $resource delete + + } + "course/x-bb-gradebook" { + + ns_log Notice "\n--resource gradebook: [lors::imsmd::getAtt $resource bb:file] deleted\n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + $resource delete + + } + "course/x-bb-coursenavsetting" { + + ns_log Notice "\n--resource navsettings: [lors::imsmd::getAtt $resource bb:file] deleted\n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + $resource delete + + } + "course/x-bb-courseappsetting" { + + ns_log Notice "\n--resource courseappsetting: [lors::imsmd::getAtt $resource bb:file] deleted\n" + file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file] + $resource delete + + } + } + + + } + + + set f_handler [open /tmp/imsmanifest.xml w+] + puts -nonewline $f_handler [$manifest asXML -indent 1 -escapeNonASCII] + close $f_handler + + $doc delete + + file copy -force /tmp/imsmanifest.xml $tmp_dir/imsmanifest.xml + +} + + +### End Cleanup Functions \ No newline at end of file Index: openacs-4/packages/lors/tcl/lors-imscp-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imscp-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/tcl/lors-imscp-procs.tcl 22 Apr 2004 03:42:07 -0000 1.1 +++ openacs-4/packages/lors/tcl/lors-imscp-procs.tcl 4 Sep 2004 14:04:08 -0000 1.2 @@ -38,6 +38,9 @@ @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + set items "" set itemx [$tree child all item] @@ -125,6 +128,25 @@ set cc [concat $cc "{}"] } + ## .LRN extensions + # I have added an extensions to IMS items as an attribute + # so we can define permission on different ims_items. The + # attribute is dotLRN:permission. + # if it doesn't exists it keeps default + # permissions. Otherwise it takes the permission as sets + # it accordingly + + # dotLRN:permission + set dotlrn_permission [lors::imsmd::getAtt $itemx dotLRN:permission] + + ns_log Notice "lorsm ims_item dotLRN:permission $dotlrn_permission" + + if {![empty_string_p $dotlrn_permission]} { + set cc [concat $cc "$dotlrn_permission"] + } else { + set cc [concat $cc "{}"] + } + set itemxx [$itemx child all item] if { ![empty_string_p $itemxx] } { incr parent @@ -168,6 +190,7 @@ {-folder_id ""} {-fs_package_id ""} {-package_id ""} + {-community_id ""} {-user_id ""} {-creation_ip ""} @@ -183,11 +206,16 @@ @option parent_man_id parent manifest id (for manifest with submanifests). @option isscorm wheather the manifest is SCORM compliant @option folder_id the CR folder ID we created to put the manifest on. - @option package_id Package id. + @option fs_package_id file-storage package id. + @option package_id package_id for the instance of LORSm + @option community_id Community ID @option user_id user that adds the category. [ad_conn user_id] used by default. @option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default. @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + if {[empty_string_p $user_id]} { set user_id [ad_conn user_id] } @@ -204,6 +232,8 @@ set isscorm 0 } + set class_key [dotlrn_community::get_community_type_from_community_id $community_id] + db_transaction { set manifest_id [db_exec_plsql new_manifest { select ims_manifest__new ( @@ -220,7 +250,9 @@ current_timestamp, :user_id, :creation_ip, - :package_id + :package_id, + :community_id, + :class_key ); } @@ -275,6 +307,9 @@ @option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default. @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + if {[empty_string_p $user_id]} { set user_id [ad_conn user_id] } @@ -345,6 +380,7 @@ {-timelimitaction ""} {-datafromlms ""} {-masteryscore ""} + {-dotlrn_permission ""} {-package_id ""} {-user_id ""} {-creation_ip ""} @@ -368,11 +404,15 @@ @option timelimitaction items time limit action (SCORM extension). @option datafromlms items data from LMS (SCORM extension). @option masteryscore items mastery score (SCORM extension). + @option dotlrn_permission dotlrn extension to incoporate permissions. @option package_id Package id. @option user_id user that adds the category. [ad_conn user_id] used by default. @option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default. @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + if {[empty_string_p $user_id]} { set user_id [ad_conn user_id] } @@ -421,6 +461,44 @@ ] } + + if {![empty_string_p $dotlrn_permission]} { + + permission::toggle_inherit -object_id $item_id + + + set community_id [dotlrn_community::get_community_id] + + # Set read permissions for community/class dotlrn_admin_rel + + set party_id_admin [db_string party_id {select segment_id from rel_segments \ + where group_id = :community_id \ + and rel_type = 'dotlrn_admin_rel'}] + + permission::grant -party_id $party_id_admin -object_id $item_id -privilege read + + + # Set read permissions for *all* other professors within .LRN + # (so they can see the content) + + set party_id_professor [db_string party_id {select segment_id from rel_segments \ + where rel_type = 'dotlrn_professor_profile_rel'}] + + permission::grant -party_id $party_id_professor -object_id $item_id -privilege read + + # Set read permissions for *all* other admins within .LRN + # (so they can see the content) + + set party_id_admins [db_string party_id {select segment_id from rel_segments \ + where rel_type = 'dotlrn_admin_profile_rel'}] + + permission::grant -party_id $party_id_admins -object_id $item_id -privilege read + + ns_log Notice "ims_item_id ($item_id) read permissions granted for community admins" + + + } + return $item_id } @@ -460,6 +538,9 @@ @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + set retlist "" foreach item $itemlist { @@ -478,6 +559,7 @@ set p_timelimitaction [lindex $item 9] set p_datafromlms [lindex $item 10] set p_masteryscore [lindex $item 11] + set p_dotlrn_permission [lindex $item 12] if {$p_hasmetadata != 0} { set md_node $p_hasmetadata @@ -497,7 +579,8 @@ -maxtimeallowed $p_maxtimeallowed \ -timelimitaction $p_timelimitaction \ -datafromlms $p_datafromlms \ - -masteryscore $p_masteryscore] + -masteryscore $p_masteryscore \ + -dotlrn_permission $p_dotlrn_permission] if {$p_hasmetadata == 1} { set aa [lors::imsmd::addMetadata \ @@ -508,8 +591,8 @@ lappend retlist [list $item_id $p_identifierref] - if { [llength $item] > 12} { - set subitem [lors::imscp::addItems -org_id $p_org_id [lindex $item 12] $item_id $tmp_dir] + if { [llength $item] > 13} { + set subitem [lors::imscp::addItems -org_id $p_org_id [lindex $item 13] $item_id $tmp_dir] set retlist [concat $retlist $subitem] } } @@ -544,6 +627,9 @@ @option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default. @author Ernie Ghiglione (ErnieG@mm.st) } { + # set utf-8 system encoding + encoding system utf-8 + if {[empty_string_p $user_id]} { set user_id [ad_conn user_id] } @@ -684,17 +770,29 @@ if {[empty_string_p $hasmetadata]} { set hasmetadata 0 } - db_transaction { - set file [db_exec_plsql file_add { - select ims_file__new ( + + # At times, and for some strange reason, Blackboard and Reload + # incorrectly add repeted under resources. So we need to + # catch that before we try to insert them again under the same + # resource + + set file_exists [db_0or1row file_ex "select file_id from ims_cp_files where file_id = :file_id and res_id = :res_id"] + + ns_log Notice "Fernando $file_exists" + + if {$file_exists == 0} { + db_transaction { + set file [db_exec_plsql file_add { + select ims_file__new ( :file_id, :res_id, :pathtofile, :filename, :hasmetadata ); - } - ] + } + ] + } } return $file_id } Index: openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl 22 Apr 2004 03:42:08 -0000 1.1 +++ openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl 4 Sep 2004 14:04:08 -0000 1.2 @@ -23,6 +23,8 @@ # namespace eval lors::imsmd { + # set utf-8 system encoding + encoding system utf-8 ad_proc -public getAtt {doc attr_name} { getAtt Gets attributes for an specific element @@ -31,6 +33,7 @@ @param attr_name Attribute we want to fetch } { + if {[$doc hasAttribute $attr_name] == 1} { $doc getAttribute $attr_name } else { @@ -1142,681 +1145,1093 @@ } } -ad_proc -public addMetadata { - {-acs_object:required} - {-node:required} - {-dir {}} -} { - Adds metadata for a learning resource. - This is the master function for adding metadata. This is the MD mama function. - @option acs_object acs object for resource (element) that contains metadata. - @option node XML node that contains the metadata - @option dir directory where the imsmanifest.xml file is located. This is use in the case the metadata is in a different file location (adlcp:location). - @author Ernie Ghiglione (ErnieG@mm.st). + ad_proc -public addLOM { + {-lom:required} + {-prefix} + {-acs_object:required} + {-dir {}} + } { + Adds LOM metadata for a learning resource. + This is the master function for adding metadata. + This is the MD mama function for entering LOM into the db. -} { - set p_ims_md_id $acs_object - set mdnode $node - set path_to_file $dir - #[lors::imsmd::getMDNode $manifest] + @param lom the LOM node (XML) for the learning resource + @param acs_object acs object for resource (element) that contains metadata + @param dir dir directory where the imsmanifest.xml file is located. This is use in the case the metadata is in a different file location (adlcp:location). + @author Ernie Ghiglione (ErnieG@mm.st) - set p_schema [lindex [lindex [lors::imsmd::getMDSchema $mdnode] 0] 0] - set p_schemaversion [lindex [lors::imsmd::getMDSchema $mdnode] 1] + } { + set p_ims_md_id $acs_object + set path_to_file $dir - set lom [lindex [lors::imsmd::getLOM $mdnode $path_to_file] 0] - set prefix [lindex [lors::imsmd::getLOM $mdnode $path_to_file] 1] + db_transaction { + # General - - # inserts into db - db_transaction { + # Title + set titles [lors::imsmd::mdGeneral -element title -node $lom -prefix $prefix] + # Structure + set structure_s [lindex [lindex [lindex [lors::imsmd::mdGeneral -element structure -node $lom -prefix $prefix] 0] 0] 1] + set structure_v [lindex [lindex [lindex [lors::imsmd::mdGeneral -element structure -node $lom -prefix $prefix] 0] 1] 1] - # Checks if there's a LOM record - if {$lom != 0} { + # Aggregation level + set agg_level_s [lindex [lindex [lindex [lors::imsmd::mdGeneral -element aggregationlevel -node $lom -prefix $prefix] 0] 0] 1] + set agg_level_v [lindex [lindex [lindex [lors::imsmd::mdGeneral -element aggregationlevel -node $lom -prefix $prefix] 0] 1] 1] - # Adds new MD record to ims_md - db_dml add_md { - insert into ims_md (ims_md_id, schema, schemaversion) - values - (:p_ims_md_id, :p_schema, :p_schemaversion) - } + # Catalogentry + set catalogentries [lors::imsmd::mdGeneral -element catalogentry -node $lom -prefix $prefix] - # General + # Languages + set languages [lors::imsmd::mdGeneral -element language -node $lom -prefix $prefix] + + # Descriptions + set descriptions [lors::imsmd::mdGeneral -element description -node $lom -prefix $prefix] - # Title - set titles [lors::imsmd::mdGeneral -element title -node $lom -prefix $prefix] + # Keywords + set keywords [lors::imsmd::mdGeneral -element keyword -node $lom -prefix $prefix] - # Structure - set structure_s [lindex [lindex [lindex [lors::imsmd::mdGeneral -element structure -node $lom -prefix $prefix] 0] 0] 1] - set structure_v [lindex [lindex [lindex [lors::imsmd::mdGeneral -element structure -node $lom -prefix $prefix] 0] 1] 1] + # Coverages + set coverages [lors::imsmd::mdGeneral -element coverage -node $lom -prefix $prefix] - # Aggregation level - set agg_level_s [lindex [lindex [lindex [lors::imsmd::mdGeneral -element aggregationlevel -node $lom -prefix $prefix] 0] 0] 1] - set agg_level_v [lindex [lindex [lindex [lors::imsmd::mdGeneral -element aggregationlevel -node $lom -prefix $prefix] 0] 1] 1] + # Now we insert the values into the DB + db_dml add_new_general { + insert into ims_md_general (ims_md_id, structure_s, structure_v, agg_level_s, agg_level_v) + values + (:p_ims_md_id, :structure_s, :structure_v, :agg_level_s, :agg_level_v) + } - # Catalogentry - set catalogentries [lors::imsmd::mdGeneral -element catalogentry -node $lom -prefix $prefix] - # Languages - set languages [lors::imsmd::mdGeneral -element language -node $lom -prefix $prefix] + # Adds General Titles - # Descriptions - set descriptions [lors::imsmd::mdGeneral -element description -node $lom -prefix $prefix] + foreach title $titles { + set p_ims_md_ge_ti_id [db_nextval ims_md_general_title_seq] + set p_title_l [lindex $title 0] + set p_title_s [lindex $title 1] + + db_dml add_new_general_titles { + insert into ims_md_general_title (ims_md_ge_ti_id, ims_md_id, title_l, title_s) + values + (:p_ims_md_ge_ti_id, :p_ims_md_id, :p_title_l, :p_title_s) + } - # Keywords - set keywords [lors::imsmd::mdGeneral -element keyword -node $lom -prefix $prefix] + } - # Coverages - set coverages [lors::imsmd::mdGeneral -element coverage -node $lom -prefix $prefix] + # Adds General Catalog Entries + foreach catalogentry $catalogentries { + set p_ims_md_ge_cata_id [db_nextval ims_md_general_cata_seq] + set p_catalog [lindex $catalogentry 0] + set p_entry_l [lindex [lindex $catalogentry 1] 0] + set p_entry_s [lindex [lindex $catalogentry 1] 1] + + db_dml add_new_general_catalogentries { + + insert into ims_md_general_cata (ims_md_ge_cata_id, ims_md_id, catalog, entry_l, entry_s) + values + (:p_ims_md_ge_cata_id, :p_ims_md_id, :p_catalog, :p_entry_l, :p_entry_s) + } + } - # Now we insert the values into the DB - db_dml add_new_general { - insert into ims_md_general (ims_md_id, structure_s, structure_v, agg_level_s, agg_level_v) - values - (:p_ims_md_id, :structure_s, :structure_v, :agg_level_s, :agg_level_v) - } + # Adds General Languages + foreach language $languages { + set p_ims_md_ge_lang_id [db_nextval ims_md_general_lang_seq] + db_dml add_new_general_language { + insert into ims_md_general_lang (ims_md_ge_lang_id, ims_md_id, language) + values + (:p_ims_md_ge_lang_id, :p_ims_md_id, :language) + } + } - # Adds General Titles + # Adds General Description + foreach description $descriptions { + set p_ims_md_ge_desc_id [db_nextval ims_md_general_desc_seq] + set p_descrip_l [lindex $description 0] + set p_descrip_s [lindex $description 1] + + db_dml add_new_general_description { + insert into ims_md_general_desc (ims_md_ge_desc_id, ims_md_id, descrip_l, descrip_s) + values + (:p_ims_md_ge_desc_id, :p_ims_md_id, :p_descrip_l, :p_descrip_s) + } + } + + # Adds General Keywords + foreach keyword $keywords { + set p_ims_md_ge_key_id [db_nextval ims_md_general_key_seq] + set p_keyword_l [lindex $keyword 0] + set p_keyword_s [lindex $keyword 1] + + db_dml add_new_general_keyword { + insert into ims_md_general_key (ims_md_ge_key_id, ims_md_id, keyword_l, keyword_s) + values + (:p_ims_md_ge_key_id, :p_ims_md_id, :p_keyword_l, :p_keyword_s) + } + } - foreach title $titles { - set p_ims_md_ge_ti_id [db_nextval ims_md_general_title_seq] - set p_title_l [lindex $title 0] - set p_title_s [lindex $title 1] - - db_dml add_new_general_titles { - insert into ims_md_general_title (ims_md_ge_ti_id, ims_md_id, title_l, title_s) - values - (:p_ims_md_ge_ti_id, :p_ims_md_id, :p_title_l, :p_title_s) - } + # Adds General Coverage + foreach coverage $coverages { + set p_ims_md_ge_cove_id [db_nextval ims_md_general_cover_seq] + set p_cover_l [lindex $coverage 0] + set p_cover_s [lindex $coverage 1] + + db_dml add_new_general_coverage { + insert into ims_md_general_cover (ims_md_ge_cove_id, ims_md_id, cover_l, cover_s) + values + (:p_ims_md_ge_cove_id, :p_ims_md_id, :p_cover_l, :p_cover_s) + } + } - } + # Lifecycle - # Adds General Catalog Entries - foreach catalogentry $catalogentries { - set p_ims_md_ge_cata_id [db_nextval ims_md_general_cata_seq] - set p_catalog [lindex $catalogentry 0] - set p_entry_l [lindex [lindex $catalogentry 1] 0] - set p_entry_s [lindex [lindex $catalogentry 1] 1] - - db_dml add_new_general_catalogentries { - - insert into ims_md_general_cata (ims_md_ge_cata_id, ims_md_id, catalog, entry_l, entry_s) - values - (:p_ims_md_ge_cata_id, :p_ims_md_id, :p_catalog, :p_entry_l, :p_entry_s) - } - } + # Version + set version [lors::imsmd::mdLifeCycle -element version -node $lom -prefix $prefix] + set version_l [lindex [lindex $version 0] 0] + set version_s [lindex [lindex $version 0] 1] + + # Status + set status [lors::imsmd::mdLifeCycle -element status -node $lom -prefix $prefix] + set status_s [lindex [lindex [lindex $status 0] 0] 1] + set status_v [lindex [lindex [lindex $status 0] 1] 1] + + # Contribute + set contributes [lors::imsmd::mdLifeCycle -element contribute -node $lom -prefix $prefix] + + # Adds Lifecycle Version and Status + db_dml add_new_lifecycle { + insert into ims_md_life_cycle (ims_md_id, version_l, version_s, status_s, status_v) + values + (:p_ims_md_id, :version_l, :version_s, :status_s, :status_v) + } - # Adds General Languages - foreach language $languages { - set p_ims_md_ge_lang_id [db_nextval ims_md_general_lang_seq] + # Adds Lifecycle Contributes + foreach contribute $contributes { + set p_ims_md_lf_cont_id [db_nextval ims_md_life_cycle_contrib_seq] + set p_role_s [lindex [lindex [lindex $contribute 0] 0] 1] + set p_role_v [lindex [lindex [lindex $contribute 0] 1] 1] + set p_cont_date [lindex [lindex $contribute 2] 0] + set p_cont_date_l [lindex [lindex [lindex $contribute 2] 1] 0] + set p_cont_date_s [lindex [lindex [lindex $contribute 2] 1] 1] + + set p_entities [lindex $contribute 1] + + db_dml add_new_lifecycle_contrib { + insert into ims_md_life_cycle_contrib (ims_md_lf_cont_id, ims_md_id, role_s, role_v, cont_date, cont_date_l, cont_date_s) + values + (:p_ims_md_lf_cont_id, :p_ims_md_id, :p_role_s, :p_role_v, :p_cont_date, :p_cont_date_l, :p_cont_date_s) + } - db_dml add_new_general_language { - insert into ims_md_general_lang (ims_md_ge_lang_id, ims_md_id, language) - values - (:p_ims_md_ge_lang_id, :p_ims_md_id, :language) - } - } - # Adds General Description - foreach description $descriptions { - set p_ims_md_ge_desc_id [db_nextval ims_md_general_desc_seq] - set p_descrip_l [lindex $description 0] - set p_descrip_s [lindex $description 1] - - db_dml add_new_general_description { - insert into ims_md_general_desc (ims_md_ge_desc_id, ims_md_id, descrip_l, descrip_s) - values - (:p_ims_md_ge_desc_id, :p_ims_md_id, :p_descrip_l, :p_descrip_s) - } - } - - # Adds General Keywords - foreach keyword $keywords { - set p_ims_md_ge_key_id [db_nextval ims_md_general_key_seq] - set p_keyword_l [lindex $keyword 0] - set p_keyword_s [lindex $keyword 1] - - db_dml add_new_general_keyword { - insert into ims_md_general_key (ims_md_ge_key_id, ims_md_id, keyword_l, keyword_s) - values - (:p_ims_md_ge_key_id, :p_ims_md_id, :p_keyword_l, :p_keyword_s) - } - } + foreach entity $p_entities { + set p_ims_md_lf_cont_enti_id [db_nextval ims_md_life_cycle_contrib_entity_seq] + set p_entity $entity + + db_dml add_new_lifecycle_contrib_entity { + insert into ims_md_life_cycle_contrib_entity (ims_md_lf_cont_enti_id, ims_md_lf_cont_id, entity) + values + (:p_ims_md_lf_cont_enti_id, :p_ims_md_lf_cont_id, :p_entity) + } + } + + } + + # Metadata - # Adds General Coverage - foreach coverage $coverages { - set p_ims_md_ge_cove_id [db_nextval ims_md_general_cover_seq] - set p_cover_l [lindex $coverage 0] - set p_cover_s [lindex $coverage 1] - - db_dml add_new_general_coverage { - insert into ims_md_general_cover (ims_md_ge_cove_id, ims_md_id, cover_l, cover_s) - values - (:p_ims_md_ge_cove_id, :p_ims_md_id, :p_cover_l, :p_cover_s) - } - } + # Language + set p_language [lors::imsmd::mdMetadata -element language -node $lom -prefix $prefix] + + # Catalogentry + set catalogentries [lors::imsmd::mdMetadata -element catalogentry -node $lom -prefix $prefix] + + # Contribute + set contributes [lors::imsmd::mdMetadata -element contribute -node $lom -prefix $prefix] + + # Metadatascheme + set metadataschemes [lors::imsmd::mdMetadata -element metadatascheme -node $lom -prefix $prefix] - # Lifecycle + # Adds Metadata Language + db_dml add_new_metadata { + insert into ims_md_metadata (ims_md_id, language) + values + (:p_ims_md_id, :p_language) + } - # Version - set version [lors::imsmd::mdLifeCycle -element version -node $lom -prefix $prefix] - set version_l [lindex [lindex $version 0] 0] - set version_s [lindex [lindex $version 0] 1] - - # Status - set status [lors::imsmd::mdLifeCycle -element status -node $lom -prefix $prefix] - set status_s [lindex [lindex [lindex $status 0] 0] 1] - set status_v [lindex [lindex [lindex $status 0] 1] 1] - - # Contribute - set contributes [lors::imsmd::mdLifeCycle -element contribute -node $lom -prefix $prefix] - - # Adds Lifecycle Version and Status - db_dml add_new_lifecycle { - insert into ims_md_life_cycle (ims_md_id, version_l, version_s, status_s, status_v) - values - (:p_ims_md_id, :version_l, :version_s, :status_s, :status_v) - } + # Adds Catalogentry + foreach catalogentry $catalogentries { + set p_ims_md_md_cata_id [db_nextval ims_md_metadata_cata_seq] + set p_catalog [lindex $catalogentry 0] + set p_entry_l [lindex [lindex $catalogentry 1] 0] + set p_entry_s [lindex [lindex $catalogentry 1] 1] - # Adds Lifecycle Contributes - foreach contribute $contributes { - set p_ims_md_lf_cont_id [db_nextval ims_md_life_cycle_contrib_seq] - set p_role_s [lindex [lindex [lindex $contribute 0] 0] 1] - set p_role_v [lindex [lindex [lindex $contribute 0] 1] 1] - set p_cont_date [lindex [lindex $contribute 2] 0] - set p_cont_date_l [lindex [lindex [lindex $contribute 2] 1] 0] - set p_cont_date_s [lindex [lindex [lindex $contribute 2] 1] 1] - - set p_entities [lindex $contribute 1] - - db_dml add_new_lifecycle_contrib { - insert into ims_md_life_cycle_contrib (ims_md_lf_cont_id, ims_md_id, role_s, role_v, cont_date, cont_date_l, cont_date_s) - values - (:p_ims_md_lf_cont_id, :p_ims_md_id, :p_role_s, :p_role_v, :p_cont_date, :p_cont_date_l, :p_cont_date_s) - } + db_dml add_new_metadata_catalogentries { + insert into ims_md_metadata_cata (ims_md_md_cata_id, ims_md_id, catalog, entry_l, entry_s) + values + (:p_ims_md_md_cata_id, :p_ims_md_id, :p_catalog, :p_entry_l, :p_entry_s) + } + } + # Adds Lifecycle Contributes + foreach contribute $contributes { + set p_ims_md_md_cont_id [db_nextval ims_md_metadata_contrib_seq] + set p_role_s [lindex [lindex [lindex $contribute 0] 0] 1] + set p_role_v [lindex [lindex [lindex $contribute 0] 1] 1] + set p_cont_date [lindex [lindex $contribute 2] 0] + set p_cont_date_l [lindex [lindex [lindex $contribute 2] 1] 0] + set p_cont_date_s [lindex [lindex [lindex $contribute 2] 1] 1] - foreach entity $p_entities { - set p_ims_md_lf_cont_enti_id [db_nextval ims_md_life_cycle_contrib_entity_seq] - set p_entity $entity - - db_dml add_new_lifecycle_contrib_entity { - insert into ims_md_life_cycle_contrib_entity (ims_md_lf_cont_enti_id, ims_md_lf_cont_id, entity) - values - (:p_ims_md_lf_cont_enti_id, :p_ims_md_lf_cont_id, :p_entity) - } - } - - } - - # Metadata + set p_ims_md_md_cont_enti_id [db_nextval ims_md_metadata_contrib_entity_seq] + set p_entity [lindex [lindex $contribute 1] 0] - # Language - set p_language [lors::imsmd::mdMetadata -element language -node $lom -prefix $prefix] - - # Catalogentry - set catalogentries [lors::imsmd::mdMetadata -element catalogentry -node $lom -prefix $prefix] - - # Contribute - set contributes [lors::imsmd::mdMetadata -element contribute -node $lom -prefix $prefix] - - # Metadatascheme - set metadataschemes [lors::imsmd::mdMetadata -element metadatascheme -node $lom -prefix $prefix] + db_dml add_new_metadata_contrib { + insert into ims_md_metadata_contrib (ims_md_md_cont_id, ims_md_id, role_s, role_v, cont_date, cont_date_l, cont_date_s) + values + (:p_ims_md_md_cont_id, :p_ims_md_id, :p_role_s, :p_role_v, :p_cont_date, :p_cont_date_l, :p_cont_date_s) + } - # Adds Metadata Language - db_dml add_new_metadata { - insert into ims_md_metadata (ims_md_id, language) - values - (:p_ims_md_id, :p_language) - } + db_dml add_new_metadata_contrib_entity { + insert into ims_md_metadata_contrib_entity (ims_md_md_cont_enti_id, ims_md_md_cont_id, entity) + values + (:p_ims_md_md_cont_enti_id, :p_ims_md_md_cont_id, :p_entity) + } - # Adds Catalogentry - foreach catalogentry $catalogentries { - set p_ims_md_md_cata_id [db_nextval ims_md_metadata_cata_seq] - set p_catalog [lindex $catalogentry 0] - set p_entry_l [lindex [lindex $catalogentry 1] 0] - set p_entry_s [lindex [lindex $catalogentry 1] 1] + } - db_dml add_new_metadata_catalogentries { - insert into ims_md_metadata_cata (ims_md_md_cata_id, ims_md_id, catalog, entry_l, entry_s) - values - (:p_ims_md_md_cata_id, :p_ims_md_id, :p_catalog, :p_entry_l, :p_entry_s) - } - } + # Adds Metadata Schemes + foreach metadatascheme $metadataschemes { + set p_scheme $metadatascheme + + db_dml add_new_metadata_metadatascheme { + insert into ims_md_metadata_scheme (ims_md_id, scheme) + values + (:p_ims_md_id, :p_scheme) + } + } - # Adds Lifecycle Contributes - foreach contribute $contributes { - set p_ims_md_md_cont_id [db_nextval ims_md_metadata_contrib_seq] - set p_role_s [lindex [lindex [lindex $contribute 0] 0] 1] - set p_role_v [lindex [lindex [lindex $contribute 0] 1] 1] - set p_cont_date [lindex [lindex $contribute 2] 0] - set p_cont_date_l [lindex [lindex [lindex $contribute 2] 1] 0] - set p_cont_date_s [lindex [lindex [lindex $contribute 2] 1] 1] + # Technical - set p_ims_md_md_cont_enti_id [db_nextval ims_md_metadata_contrib_entity_seq] - set p_entity [lindex [lindex $contribute 1] 0] + # format + set formats [lors::imsmd::mdTechnical -element format -node $lom -prefix $prefix] + + # location + set locations [lors::imsmd::mdTechnical -element location -node $lom -prefix $prefix] - db_dml add_new_metadata_contrib { - insert into ims_md_metadata_contrib (ims_md_md_cont_id, ims_md_id, role_s, role_v, cont_date, cont_date_l, cont_date_s) - values - (:p_ims_md_md_cont_id, :p_ims_md_id, :p_role_s, :p_role_v, :p_cont_date, :p_cont_date_l, :p_cont_date_s) - } + # size, installation remarks, otherplatformrequirements, duration + set p_size [lors::imsmd::mdTechnical -element size -node $lom -prefix $prefix] + set p_instl_rmks [lors::imsmd::mdTechnical -element installationremarks -node $lom -prefix $prefix] + set p_instl_rmks_l [lindex [lindex $p_instl_rmks 0] 0] + set p_instl_rmks_s [lindex [lindex $p_instl_rmks 0] 1] + set p_otr_plt [lors::imsmd::mdTechnical -element otherplatformrequirements -node $lom -prefix $prefix] + set p_otr_plt_l [lindex [lindex $p_otr_plt 0] 0] + set p_otr_plt_s [lindex [lindex $p_otr_plt 0] 1] + set p_durat [lors::imsmd::mdTechnical -element duration -node $lom -prefix $prefix] + set p_duration [lindex $p_durat 0] + set p_duration_l [lindex [lindex $p_durat 1] 0] + set p_duration_s [lindex [lindex $p_durat 1] 1] - db_dml add_new_metadata_contrib_entity { - insert into ims_md_metadata_contrib_entity (ims_md_md_cont_enti_id, ims_md_md_cont_id, entity) - values - (:p_ims_md_md_cont_enti_id, :p_ims_md_md_cont_id, :p_entity) - } + # requirement + set requirements [lors::imsmd::mdTechnical -element requirement -node $lom -prefix $prefix] - } + # Adds Technical size, installation remarks, otherplatformrequirements, duration + db_dml add_new_technical { + insert into ims_md_technical (ims_md_id, t_size, instl_rmrks_l, instl_rmrks_s, otr_plt_l, otr_plt_s, duration, duration_l, duration_s) + values + (:p_ims_md_id, :p_size, :p_instl_rmks_l, :p_instl_rmks_s, :p_otr_plt_l, :p_otr_plt_s, :p_duration, :p_duration_l, :p_duration_s) + } - # Adds Metadata Schemes - foreach metadatascheme $metadataschemes { - set p_scheme $metadatascheme - - db_dml add_new_metadata_metadatascheme { - insert into ims_md_metadata_scheme (ims_md_id, scheme) - values - (:p_ims_md_id, :p_scheme) - } - } + # Adds Technical Format - # Technical + foreach format $formats { + set p_ims_md_te_fo_id [db_nextval ims_md_technical_format_seq] + set p_format $format + + db_dml add_new_technical_format { + insert into ims_md_technical_format (ims_md_te_fo_id, ims_md_id, format) + values + (:p_ims_md_te_fo_id, :p_ims_md_id, :p_format) + } + } + + # Adds Technical Location + + foreach location $locations { + set p_ims_md_te_lo_id [db_nextval ims_md_technical_location_seq] + set p_type [lindex $location 1] + set p_location [lindex $location 0] - # format - set formats [lors::imsmd::mdTechnical -element format -node $lom -prefix $prefix] - - # location - set locations [lors::imsmd::mdTechnical -element location -node $lom -prefix $prefix] + db_dml add_new_technical_location { + insert into ims_md_technical_location (ims_md_te_lo_id, ims_md_id, type, location) + values + (:p_ims_md_te_lo_id, :p_ims_md_id, :p_type, :p_location) + } + } - # size, installation remarks, otherplatformrequirements, duration - set p_size [lors::imsmd::mdTechnical -element size -node $lom -prefix $prefix] - set p_instl_rmks [lors::imsmd::mdTechnical -element installationremarks -node $lom -prefix $prefix] - set p_instl_rmks_l [lindex [lindex $p_instl_rmks 0] 0] - set p_instl_rmks_s [lindex [lindex $p_instl_rmks 0] 1] - set p_otr_plt [lors::imsmd::mdTechnical -element otherplatformrequirements -node $lom -prefix $prefix] - set p_otr_plt_l [lindex [lindex $p_otr_plt 0] 0] - set p_otr_plt_s [lindex [lindex $p_otr_plt 0] 1] - set p_durat [lors::imsmd::mdTechnical -element duration -node $lom -prefix $prefix] - set p_duration [lindex $p_durat 0] - set p_duration_l [lindex [lindex $p_durat 1] 0] - set p_duration_s [lindex [lindex $p_durat 1] 1] + # Adds Technical Requirements - # requirement - set requirements [lors::imsmd::mdTechnical -element requirement -node $lom -prefix $prefix] + foreach requirement $requirements { + set p_ims_md_te_rq_id [db_nextval ims_md_technical_requirement_seq] + set p_type_s [lindex [lindex [lindex $requirement 0] 0] 1] + set p_type_v [lindex [lindex [lindex $requirement 0] 1] 1] + set p_name_s [lindex [lindex [lindex $requirement 1] 0] 1] + set p_name_v [lindex [lindex [lindex $requirement 1] 1] 1] + set p_min_version [lindex $requirement 2] + set p_max_version [lindex $requirement 3] - # Adds Technical size, installation remarks, otherplatformrequirements, duration - db_dml add_new_technical { - insert into ims_md_technical (ims_md_id, t_size, instl_rmrks_l, instl_rmrks_s, otr_plt_l, otr_plt_s, duration, duration_l, duration_s) - values - (:p_ims_md_id, :p_size, :p_instl_rmks_l, :p_instl_rmks_s, :p_otr_plt_l, :p_otr_plt_s, :p_duration, :p_duration_l, :p_duration_s) - } + db_dml add_new_technical_requirement { + insert into ims_md_technical_requirement (ims_md_te_rq_id, ims_md_id, type_s, type_v, name_s, name_v, min_version, max_version) + values + (:p_ims_md_te_rq_id, :p_ims_md_id, :p_type_s, :p_type_v, :p_name_s, :p_name_v, :p_min_version, :p_max_version) + } + } - # Adds Technical Format - foreach format $formats { - set p_ims_md_te_fo_id [db_nextval ims_md_technical_format_seq] - set p_format $format - - db_dml add_new_technical_format { - insert into ims_md_technical_format (ims_md_te_fo_id, ims_md_id, format) - values - (:p_ims_md_te_fo_id, :p_ims_md_id, :p_format) - } - } - - # Adds Technical Location - - foreach location $locations { - set p_ims_md_te_lo_id [db_nextval ims_md_technical_location_seq] - set p_type [lindex $location 1] - set p_location [lindex $location 0] + # Educational - db_dml add_new_technical_location { - insert into ims_md_technical_location (ims_md_te_lo_id, ims_md_id, type, location) - values - (:p_ims_md_te_lo_id, :p_ims_md_id, :p_type, :p_location) - } - } + # interactivitytype, interactivitylevel, semanticdensity, difficulty, typical_learning_time, description + set p_int_type [lors::imsmd::mdEducational -element interactivitytype -node $lom -prefix $prefix] + set p_int_type_s [lindex [lindex [lindex $p_int_type 0] 0] 1] + set p_int_type_v [lindex [lindex [lindex $p_int_type 0] 1] 1] + set p_int_level [lors::imsmd::mdEducational -element interactivitylevel -node $lom -prefix $prefix] + set p_int_level_s [lindex [lindex [lindex $p_int_level 0] 0] 1] + set p_int_level_v [lindex [lindex [lindex $p_int_level 0] 1] 1] + set p_sem_density [lors::imsmd::mdEducational -element semanticdensity -node $lom -prefix $prefix] + set p_sem_density_s [lindex [lindex [lindex $p_sem_density 0] 0] 1] + set p_sem_density_v [lindex [lindex [lindex $p_sem_density 0] 1] 1] + set p_difficulty [lors::imsmd::mdEducational -element difficulty -node $lom -prefix $prefix] + set p_difficulty_s [lindex [lindex [lindex $p_difficulty 0] 0] 1] + set p_difficulty_v [lindex [lindex [lindex $p_difficulty 0] 1] 1] + set p_type_lrn_tim [lors::imsmd::mdEducational -element typicallearningtime -node $lom -prefix $prefix] + set p_type_lrn_time [lindex $p_type_lrn_tim 0] + set p_type_lrn_time_l [lindex [lindex $p_type_lrn_tim 1] 0] + set p_type_lrn_time_s [lindex [lindex $p_type_lrn_tim 1] 1] + set descrips [lors::imsmd::mdEducational -element description -node $lom -prefix $prefix] - # Adds Technical Requirements + # learningresourcetype + set learningresourcetypes [lors::imsmd::mdEducational -element learningresourcetype -node $lom -prefix $prefix] - foreach requirement $requirements { - set p_ims_md_te_rq_id [db_nextval ims_md_technical_requirement_seq] - set p_type_s [lindex [lindex [lindex $requirement 0] 0] 1] - set p_type_v [lindex [lindex [lindex $requirement 0] 1] 1] - set p_name_s [lindex [lindex [lindex $requirement 1] 0] 1] - set p_name_v [lindex [lindex [lindex $requirement 1] 1] 1] - set p_min_version [lindex $requirement 2] - set p_max_version [lindex $requirement 3] - db_dml add_new_technical_requirement { - insert into ims_md_technical_requirement (ims_md_te_rq_id, ims_md_id, type_s, type_v, name_s, name_v, min_version, max_version) - values - (:p_ims_md_te_rq_id, :p_ims_md_id, :p_type_s, :p_type_v, :p_name_s, :p_name_v, :p_min_version, :p_max_version) - } - } + # intendedenduserrole + set intendedenduserroles [lors::imsmd::mdEducational -element intendedenduserrole -node $lom -prefix $prefix] + # context + set contexts [lors::imsmd::mdEducational -element context -node $lom -prefix $prefix] - # Educational + # typicalagerange + set typicalageranges [lors::imsmd::mdEducational -element typicalagerange -node $lom -prefix $prefix] - # interactivitytype, interactivitylevel, semanticdensity, difficulty, typical_learning_time, description - set p_int_type [lors::imsmd::mdEducational -element interactivitytype -node $lom -prefix $prefix] - set p_int_type_s [lindex [lindex [lindex $p_int_type 0] 0] 1] - set p_int_type_v [lindex [lindex [lindex $p_int_type 0] 1] 1] - set p_int_level [lors::imsmd::mdEducational -element interactivitylevel -node $lom -prefix $prefix] - set p_int_level_s [lindex [lindex [lindex $p_int_level 0] 0] 1] - set p_int_level_v [lindex [lindex [lindex $p_int_level 0] 1] 1] - set p_sem_density [lors::imsmd::mdEducational -element semanticdensity -node $lom -prefix $prefix] - set p_sem_density_s [lindex [lindex [lindex $p_sem_density 0] 0] 1] - set p_sem_density_v [lindex [lindex [lindex $p_sem_density 0] 1] 1] - set p_difficulty [lors::imsmd::mdEducational -element difficulty -node $lom -prefix $prefix] - set p_difficulty_s [lindex [lindex [lindex $p_difficulty 0] 0] 1] - set p_difficulty_v [lindex [lindex [lindex $p_difficulty 0] 1] 1] - set p_type_lrn_tim [lors::imsmd::mdEducational -element typicallearningtime -node $lom -prefix $prefix] - set p_type_lrn_time [lindex $p_type_lrn_tim 0] - set p_type_lrn_time_l [lindex [lindex $p_type_lrn_tim 1] 0] - set p_type_lrn_time_s [lindex [lindex $p_type_lrn_tim 1] 1] - set descrips [lors::imsmd::mdEducational -element description -node $lom -prefix $prefix] + # language + set languages [lors::imsmd::mdEducational -element language -node $lom -prefix $prefix] - # learningresourcetype - set learningresourcetypes [lors::imsmd::mdEducational -element learningresourcetype -node $lom -prefix $prefix] + # Adds Educational interactivitytype, interactivitylevel, semanticdensity, difficulty, typical_learning_time + db_dml add_new_educational { + insert into ims_md_educational (ims_md_id, int_type_s, int_type_v, int_level_s, int_level_v, sem_density_s, sem_density_v, difficulty_s, difficulty_v, type_lrn_time, type_lrn_time_l, type_lrn_time_s) + values + (:p_ims_md_id, :p_int_type_s, :p_int_type_v, :p_int_level_s, :p_int_level_v, :p_sem_density_s, :p_sem_density_v, :p_difficulty_s, :p_difficulty_v, :p_type_lrn_time, :p_type_lrn_time_l, :p_type_lrn_time_s) + } - # intendedenduserrole - set intendedenduserroles [lors::imsmd::mdEducational -element intendedenduserrole -node $lom -prefix $prefix] + # Adds descriptions + foreach descrip $descrips { + set p_ims_md_ed_de_id [db_nextval ims_md_educational_descrip_seq] + set p_descrip_l [lindex $descrip 0] + set p_descrip_s [lindex $descrip 1] - # context - set contexts [lors::imsmd::mdEducational -element context -node $lom -prefix $prefix] + db_dml add_new_descriptions { + insert into ims_md_educational_descrip (ims_md_ed_de_id, ims_md_id, descrip_l, descrip_s) + values + (:p_ims_md_ed_de_id, :p_ims_md_id, :p_descrip_l, :p_descrip_s) + } + } - # typicalagerange - set typicalageranges [lors::imsmd::mdEducational -element typicalagerange -node $lom -prefix $prefix] + # Adds learningresourcetype + foreach lrt $learningresourcetypes { + set p_ims_md_ed_lr_id [db_nextval ims_md_educational_lrt_seq] + set p_lrt_s [lindex [lindex $lrt 0] 1] + set p_lrt_v [lindex [lindex $lrt 1] 1] + + db_dml add_new_learningresourcetypes { + insert into ims_md_educational_lrt (ims_md_ed_lr_id, ims_md_id, lrt_s, lrt_v) + values + (:p_ims_md_ed_lr_id, :p_ims_md_id, :p_lrt_s, :p_lrt_v) + } + } - # language - set languages [lors::imsmd::mdEducational -element language -node $lom -prefix $prefix] + # Adds intendedenduserrole + foreach ieur $intendedenduserroles { + set p_ims_md_ed_ie_id [db_nextval ims_md_educational_ieur_seq] + set p_ieur_s [lindex [lindex $ieur 0] 1] + set p_ieur_v [lindex [lindex $ieur 1] 1] + db_dml add_new_intendedenduserroles { + insert into ims_md_educational_ieur (ims_md_ed_ie_id, ims_md_id, ieur_s, ieur_v) + values + (:p_ims_md_ed_ie_id, :p_ims_md_id, :p_ieur_s, :p_ieur_v) + } + } - # Adds Educational interactivitytype, interactivitylevel, semanticdensity, difficulty, typical_learning_time - db_dml add_new_educational { - insert into ims_md_educational (ims_md_id, int_type_s, int_type_v, int_level_s, int_level_v, sem_density_s, sem_density_v, difficulty_s, difficulty_v, type_lrn_time, type_lrn_time_l, type_lrn_time_s) - values - (:p_ims_md_id, :p_int_type_s, :p_int_type_v, :p_int_level_s, :p_int_level_v, :p_sem_density_s, :p_sem_density_v, :p_difficulty_s, :p_difficulty_v, :p_type_lrn_time, :p_type_lrn_time_l, :p_type_lrn_time_s) - } + # Adds context + foreach context $contexts { + set p_ims_md_ed_co_id [db_nextval ims_md_educational_context_seq] + set p_context_s [lindex [lindex $context 0] 1] + set p_context_v [lindex [lindex $context 1] 1] + + db_dml add_new_context { + insert into ims_md_educational_context (ims_md_ed_co_id, ims_md_id, context_s, context_v) + values + (:p_ims_md_ed_co_id, :p_ims_md_id, :p_context_s, :p_context_v) + } + } - # Adds descriptions - foreach descrip $descrips { - set p_ims_md_ed_de_id [db_nextval ims_md_educational_descrip_seq] - set p_descrip_l [lindex $descrip 0] - set p_descrip_s [lindex $descrip 1] + # Adds typicalagerange + foreach tar $typicalageranges { + set p_ims_md_ed_ta_id [db_nextval ims_md_educational_tar_seq] + set p_tar_l [lindex $tar 0] + set p_tar_s [lindex $tar 1] - db_dml add_new_descriptions { - insert into ims_md_educational_descrip (ims_md_ed_de_id, ims_md_id, descrip_l, descrip_s) - values - (:p_ims_md_ed_de_id, :p_ims_md_id, :p_descrip_l, :p_descrip_s) - } - } + db_dml add_new_typicalagerange { + insert into ims_md_educational_tar (ims_md_ed_ta_id, ims_md_id, tar_l, tar_s) + values + (:p_ims_md_ed_ta_id, :p_ims_md_id, :p_tar_l, :p_tar_s) + } + } - # Adds learningresourcetype - foreach lrt $learningresourcetypes { - set p_ims_md_ed_lr_id [db_nextval ims_md_educational_lrt_seq] - set p_lrt_s [lindex [lindex $lrt 0] 1] - set p_lrt_v [lindex [lindex $lrt 1] 1] - - db_dml add_new_learningresourcetypes { - insert into ims_md_educational_lrt (ims_md_ed_lr_id, ims_md_id, lrt_s, lrt_v) - values - (:p_ims_md_ed_lr_id, :p_ims_md_id, :p_lrt_s, :p_lrt_v) - } - } + # Adds Languages + foreach lang $languages { + set p_ims_md_ed_la_id [db_nextval ims_md_educational_lang_seq] + set p_language $lang + + db_dml add_new_language { + insert into ims_md_educational_lang (ims_md_ed_la_id, ims_md_id, language) + values + (:p_ims_md_ed_la_id, :p_ims_md_id, :p_language) + } + } - # Adds intendedenduserrole - foreach ieur $intendedenduserroles { - set p_ims_md_ed_ie_id [db_nextval ims_md_educational_ieur_seq] - set p_ieur_s [lindex [lindex $ieur 0] 1] - set p_ieur_v [lindex [lindex $ieur 1] 1] + # Rights + # cost, copyrightsandotherrights, description + set p_cost [lors::imsmd::mdRights -element cost -node $lom -prefix $prefix] + set p_caor [lors::imsmd::mdRights -element copyrightandotherrestrictions -node $lom -prefix $prefix] + set p_descrip [lors::imsmd::mdRights -element description -node $lom -prefix $prefix] + + set p_cost_s [lindex [lindex [lindex $p_cost 0] 0] 1] + set p_cost_v [lindex [lindex [lindex $p_cost 0] 1] 1] - db_dml add_new_intendedenduserroles { - insert into ims_md_educational_ieur (ims_md_ed_ie_id, ims_md_id, ieur_s, ieur_v) - values - (:p_ims_md_ed_ie_id, :p_ims_md_id, :p_ieur_s, :p_ieur_v) - } - } + set p_caor_s [lindex [lindex [lindex $p_caor 0] 0] 1] + set p_caor_v [lindex [lindex [lindex $p_caor 0] 1] 1] - # Adds context - foreach context $contexts { - set p_ims_md_ed_co_id [db_nextval ims_md_educational_context_seq] - set p_context_s [lindex [lindex $context 0] 1] - set p_context_v [lindex [lindex $context 1] 1] - - db_dml add_new_context { - insert into ims_md_educational_context (ims_md_ed_co_id, ims_md_id, context_s, context_v) - values - (:p_ims_md_ed_co_id, :p_ims_md_id, :p_context_s, :p_context_v) - } - } + set p_descrip_l [lindex [lindex $p_descrip 0] 0] + set p_descrip_s [lindex [lindex $p_descrip 0] 1] - # Adds typicalagerange - foreach tar $typicalageranges { - set p_ims_md_ed_ta_id [db_nextval ims_md_educational_tar_seq] - set p_tar_l [lindex $tar 0] - set p_tar_s [lindex $tar 1] + db_dml add_new_rights { + insert into ims_md_rights (ims_md_id, cost_s, cost_v, caor_s, caor_v, descrip_l, descrip_s) + values + (:p_ims_md_id, :p_cost_s, :p_cost_v, :p_caor_s, :p_caor_v, :p_descrip_l, :p_descrip_s) + } - db_dml add_new_typicalagerange { - insert into ims_md_educational_tar (ims_md_ed_ta_id, ims_md_id, tar_l, tar_s) - values - (:p_ims_md_ed_ta_id, :p_ims_md_id, :p_tar_l, :p_tar_s) - } - } + # Relation - # Adds Languages - foreach lang $languages { - set p_ims_md_ed_la_id [db_nextval ims_md_educational_lang_seq] - set p_language $lang - - db_dml add_new_language { - insert into ims_md_educational_lang (ims_md_ed_la_id, ims_md_id, language) - values - (:p_ims_md_ed_la_id, :p_ims_md_id, :p_language) - } - } + # Relation returns all in one large list + set relations [lors::imsmd::mdRelation -node $lom -prefix $prefix] + + foreach relation $relations { + + set p_ims_md_re_id [db_nextval ims_md_relation_seq] + set p_kind_s [lindex [lindex [lindex [lindex $relation 0] 0] 0] 1] + set p_kind_v [lindex [lindex [lindex [lindex $relation 0] 0] 1] 1] + + # Adds kind + db_dml add_new_relation { + insert into ims_md_relation (ims_md_re_id, ims_md_id, kind_s, kind_v) + values + (:p_ims_md_re_id, :p_ims_md_id, :p_kind_s, :p_kind_v) + } + + set p_ims_md_re_re_id [db_nextval ims_md_relation_resource_seq] + set p_descrip_l [lindex [lindex [lindex $relation 1] 0] 0] + set p_descrip_s [lindex [lindex [lindex $relation 1] 0] 1] - # Rights - # cost, copyrightsandotherrights, description - set p_cost [lors::imsmd::mdRights -element cost -node $lom -prefix $prefix] - set p_caor [lors::imsmd::mdRights -element copyrightandotherrestrictions -node $lom -prefix $prefix] - set p_descrip [lors::imsmd::mdRights -element description -node $lom -prefix $prefix] - - set p_cost_s [lindex [lindex [lindex $p_cost 0] 0] 1] - set p_cost_v [lindex [lindex [lindex $p_cost 0] 1] 1] + # adds description to resource + db_dml add_new_relation_descrip { + insert into ims_md_relation_resource (ims_md_re_re_id, ims_md_re_id, identifier, descrip_l, descrip_s) + values + (:p_ims_md_re_re_id, :p_ims_md_re_id, null, :p_descrip_l, :p_descrip_s) + } - set p_caor_s [lindex [lindex [lindex $p_caor 0] 0] 1] - set p_caor_v [lindex [lindex [lindex $p_caor 0] 1] 1] + # catalogentries + set catalogentries [lindex $relation 2] - set p_descrip_l [lindex [lindex $p_descrip 0] 0] - set p_descrip_s [lindex [lindex $p_descrip 0] 1] + # adds catalogentries + foreach catalogentry $catalogentries { - db_dml add_new_rights { - insert into ims_md_rights (ims_md_id, cost_s, cost_v, caor_s, caor_v, descrip_l, descrip_s) - values - (:p_ims_md_id, :p_cost_s, :p_cost_v, :p_caor_s, :p_caor_v, :p_descrip_l, :p_descrip_s) - } + set p_ims_md_re_re_ca_id [db_nextval ims_md_relation_resource_catalog_seq] + set p_catalog [lindex $catalogentry 0] + set p_entry_l [lindex [lindex $catalogentry 1] 0] + set p_entry_s [lindex [lindex $catalogentry 1] 1] + + db_dml add_new_catalogentry { + + insert into ims_md_relation_resource_catalog (ims_md_re_re_ca_id, ims_md_re_re_id, catalog, entry_l, entry_s) + values + (:p_ims_md_re_re_ca_id, :p_ims_md_re_re_id, :p_catalog, :p_entry_l, :p_entry_s) + } + } - # Relation + } - # Relation returns all in one large list - set relations [lors::imsmd::mdRelation -node $lom -prefix $prefix] - - foreach relation $relations { - - set p_ims_md_re_id [db_nextval ims_md_relation_seq] - set p_kind_s [lindex [lindex [lindex [lindex $relation 0] 0] 0] 1] - set p_kind_v [lindex [lindex [lindex [lindex $relation 0] 0] 1] 1] - - # Adds kind - db_dml add_new_relation { - insert into ims_md_relation (ims_md_re_id, ims_md_id, kind_s, kind_v) - values - (:p_ims_md_re_id, :p_ims_md_id, :p_kind_s, :p_kind_v) - } - - set p_ims_md_re_re_id [db_nextval ims_md_relation_resource_seq] - set p_descrip_l [lindex [lindex [lindex $relation 1] 0] 0] - set p_descrip_s [lindex [lindex [lindex $relation 1] 0] 1] + # Annotation + + set annotations [lors::imsmd::mdAnnotation -node $lom -prefix $prefix] - # adds description to resource - db_dml add_new_relation_descrip { - insert into ims_md_relation_resource (ims_md_re_re_id, ims_md_re_id, identifier, descrip_l, descrip_s) - values - (:p_ims_md_re_re_id, :p_ims_md_re_id, null, :p_descrip_l, :p_descrip_s) - } + foreach annotation $annotations { + set p_ims_md_an_id [db_nextval ims_md_annotation_seq] + set p_entity [lindex [lindex $annotation 0] 0] + set p_date [lindex [lindex $annotation 1] 0] + set p_date_l [lindex [lindex [lindex $annotation 1] 1] 0] + set p_date_s [lindex [lindex [lindex $annotation 1] 1] 1] - # catalogentries - set catalogentries [lindex $relation 2] + set p_descriptions [lindex $annotation 2] - # adds catalogentries - foreach catalogentry $catalogentries { + db_dml add_new_annotation { + insert into ims_md_annotation (ims_md_an_id, ims_md_id, entity, date, date_l, date_s) + values + (:p_ims_md_an_id, :p_ims_md_id, :p_entity, :p_date, :p_date_l, :p_date_s) + } - set p_ims_md_re_re_ca_id [db_nextval ims_md_relation_resource_catalog_seq] - set p_catalog [lindex $catalogentry 0] - set p_entry_l [lindex [lindex $catalogentry 1] 0] - set p_entry_s [lindex [lindex $catalogentry 1] 1] - - db_dml add_new_catalogentry { - - insert into ims_md_relation_resource_catalog (ims_md_re_re_ca_id, ims_md_re_re_id, catalog, entry_l, entry_s) - values - (:p_ims_md_re_re_ca_id, :p_ims_md_re_re_id, :p_catalog, :p_entry_l, :p_entry_s) - } - } + foreach description $p_descriptions { - } + set p_ims_md_an_de_id [db_nextval ims_md_annotation_descrip_seq] + set p_descrip_l [lindex $description 0] + set p_descrip_s [lindex $description 1] + + db_dml add_new_ann_descriptions { + insert into ims_md_annotation_descrip (ims_md_an_de_id, ims_md_an_id, descrip_l, descrip_s) + values + (:p_ims_md_an_de_id, :p_ims_md_an_id, :p_descrip_l, :p_descrip_s) + } - # Annotation - - set annotations [lors::imsmd::mdAnnotation -node $lom -prefix $prefix] + } - foreach annotation $annotations { - set p_ims_md_an_id [db_nextval ims_md_annotation_seq] - set p_entity [lindex [lindex $annotation 0] 0] - set p_date [lindex [lindex $annotation 1] 0] - set p_date_l [lindex [lindex [lindex $annotation 1] 1] 0] - set p_date_s [lindex [lindex [lindex $annotation 1] 1] 1] - set p_descriptions [lindex $annotation 2] + } - db_dml add_new_annotation { - insert into ims_md_annotation (ims_md_an_id, ims_md_id, entity, date, date_l, date_s) - values - (:p_ims_md_an_id, :p_ims_md_id, :p_entity, :p_date, :p_date_l, :p_date_s) - } + # Classification - foreach description $p_descriptions { + set classifications [lors::imsmd::mdClassification -node $lom -prefix $prefix] - set p_ims_md_an_de_id [db_nextval ims_md_annotation_descrip_seq] - set p_descrip_l [lindex $description 0] - set p_descrip_s [lindex $description 1] - - db_dml add_new_ann_descriptions { - insert into ims_md_annotation_descrip (ims_md_an_de_id, ims_md_an_id, descrip_l, descrip_s) - values - (:p_ims_md_an_de_id, :p_ims_md_an_id, :p_descrip_l, :p_descrip_s) - } + foreach class $classifications { - } + # purpose + set p_ims_md_cl_id [db_nextval ims_md_classification_seq] + set p_purpose_s [lindex [lindex [lindex [lindex [lindex $class 0] 0] 0] 0] 1] + set p_purpose_v [lindex [lindex [lindex [lindex [lindex $class 0] 0] 0] 1] 1] + + db_dml add_new_classification { + insert into ims_md_classification (ims_md_cl_id, ims_md_id, purpose_s, purpose_v) + values + (:p_ims_md_cl_id, :p_ims_md_id, :p_purpose_s, :p_purpose_v) + } + # description + set descriptions [lindex [lindex $class 0] 1] - } + foreach desc $descriptions { + set p_ims_md_cl_de_id [db_nextval ims_md_classification_desc_seq] + set p_descrip_l [lindex $desc 0] + set p_descrip_s [lindex $desc 1] + + db_dml add_new_description { + insert into ims_md_classification_descrip (ims_md_cl_de_id, ims_md_cl_id, descrip_l, descrip_s) + values + (:p_ims_md_cl_de_id, :p_ims_md_cl_id, :p_descrip_l, :p_descrip_s) + } + } - # Classification + # taxonpath + set taxonpaths [lindex [lindex $class 0] 2] - set classifications [lors::imsmd::mdClassification -node $lom -prefix $prefix] + foreach taxonpath $taxonpaths { + + set p_source [lindex $taxonpath 0] + + set p_source_l [lindex [lindex $p_source 0] 0] + set p_source_s [lindex [lindex $p_source 0] 1] + set p_ims_md_cl_ta_id [db_nextval ims_md_classification_taxpath_seq] - foreach class $classifications { + set taxons [lindex $taxonpath 1] - # purpose - set p_ims_md_cl_id [db_nextval ims_md_classification_seq] - set p_purpose_s [lindex [lindex [lindex [lindex [lindex $class 0] 0] 0] 0] 1] - set p_purpose_v [lindex [lindex [lindex [lindex [lindex $class 0] 0] 0] 1] 1] - - db_dml add_new_classification { - insert into ims_md_classification (ims_md_cl_id, ims_md_id, purpose_s, purpose_v) - values - (:p_ims_md_cl_id, :p_ims_md_id, :p_purpose_s, :p_purpose_v) - } + db_dml add_new_taxonpaths { + insert into ims_md_classification_taxpath (ims_md_cl_ta_id, ims_md_cl_id, source_l, source_v) + values + (:p_ims_md_cl_ta_id, :p_ims_md_cl_id, :p_source_l, :p_source_s) + } - # description - set descriptions [lindex [lindex $class 0] 1] + foreach taxon $taxons { - foreach desc $descriptions { - set p_ims_md_cl_de_id [db_nextval ims_md_classification_desc_seq] - set p_descrip_l [lindex $desc 0] - set p_descrip_s [lindex $desc 1] - - db_dml add_new_description { - insert into ims_md_classification_descrip (ims_md_cl_de_id, ims_md_cl_id, descrip_l, descrip_s) - values - (:p_ims_md_cl_de_id, :p_ims_md_cl_id, :p_descrip_l, :p_descrip_s) - } - } + set p_ims_md_cl_ta_ta_id [db_nextval ims_md_classification_taxpath_taxon_seq] + set p_hierarchy [lindex $taxon 0] + set p_identifier [lindex $taxon 1] + set p_entry_l [lindex [lindex $taxon 2] 0] + set p_entry_s [lindex [lindex $taxon 2] 1] + + db_dml add_new_taxons { + insert into ims_md_classification_taxpath_taxon (ims_md_cl_ta_ta_id, ims_md_cl_ta_id, hierarchy, identifier, entry_l, entry_s) + values + (:p_ims_md_cl_ta_ta_id, :p_ims_md_cl_ta_id, :p_hierarchy, :p_identifier, :p_entry_l, :p_entry_s) + } - # taxonpath - set taxonpaths [lindex [lindex $class 0] 2] + } + } - foreach taxonpath $taxonpaths { - - set p_source [lindex $taxonpath 0] - - set p_source_l [lindex [lindex $p_source 0] 0] - set p_source_s [lindex [lindex $p_source 0] 1] - set p_ims_md_cl_ta_id [db_nextval ims_md_classification_taxpath_seq] + # keywords + set keywords [lindex [lindex $class 0] 3] + + foreach keyword $keywords { + set p_ims_md_cl_ke_id [db_nextval ims_md_classification_keyword_seq] + set p_keyword_l [lindex $keyword 0] + set p_keyword_s [lindex $keyword 1] + + db_dml add_new_keywords { + insert into ims_md_classification_keyword (ims_md_cl_ke_id, ims_md_cl_id, keyword_l, keyword_s) + values + (:p_ims_md_cl_ke_id, :p_ims_md_cl_id, :p_keyword_l, :p_keyword_s) + } + } + } + } on_error { + ad_return_error "Transaction Error in LOM" "The error was: $errmsg" + } + + } - set taxons [lindex $taxonpath 1] - db_dml add_new_taxonpaths { - insert into ims_md_classification_taxpath (ims_md_cl_ta_id, ims_md_cl_id, source_l, source_v) - values - (:p_ims_md_cl_ta_id, :p_ims_md_cl_id, :p_source_l, :p_source_s) - } + ad_proc -public addMetadata { + {-acs_object:required} + {-node:required} + {-dir {}} + } { + Adds metadata for a learning resource. + + @option acs_object acs object for resource (element) that contains metadata. + @option node XML node that contains the metadata + @option dir directory where the imsmanifest.xml file is located. This is use in the case the metadata is in a different file location (adlcp:location). + @author Ernie Ghiglione (ErnieG@mm.st). - foreach taxon $taxons { + } { + set p_ims_md_id $acs_object + set mdnode $node + set path_to_file $dir + #[lors::imsmd::getMDNode $manifest] + + set p_schema [lindex [lindex [lors::imsmd::getMDSchema $mdnode] 0] 0] + set p_schemaversion [lindex [lors::imsmd::getMDSchema $mdnode] 1] - set p_ims_md_cl_ta_ta_id [db_nextval ims_md_classification_taxpath_taxon_seq] - set p_hierarchy [lindex $taxon 0] - set p_identifier [lindex $taxon 1] - set p_entry_l [lindex [lindex $taxon 2] 0] - set p_entry_s [lindex [lindex $taxon 2] 1] - - db_dml add_new_taxons { - insert into ims_md_classification_taxpath_taxon (ims_md_cl_ta_ta_id, ims_md_cl_ta_id, hierarchy, identifier, entry_l, entry_s) - values - (:p_ims_md_cl_ta_ta_id, :p_ims_md_cl_ta_id, :p_hierarchy, :p_identifier, :p_entry_l, :p_entry_s) - } + set lom [lindex [lors::imsmd::getLOM $mdnode $path_to_file] 0] + set prefix [lindex [lors::imsmd::getLOM $mdnode $path_to_file] 1] - } - } + + # inserts into db + db_transaction { - # keywords - set keywords [lindex [lindex $class 0] 3] - - foreach keyword $keywords { - set p_ims_md_cl_ke_id [db_nextval ims_md_classification_keyword_seq] - set p_keyword_l [lindex $keyword 0] - set p_keyword_s [lindex $keyword 1] - - db_dml add_new_keywords { - insert into ims_md_classification_keyword (ims_md_cl_ke_id, ims_md_cl_id, keyword_l, keyword_s) - values - (:p_ims_md_cl_ke_id, :p_ims_md_cl_id, :p_keyword_l, :p_keyword_s) - } + # Checks if there's a LOM record + if {$lom != 0} { + + # Adds new MD record to ims_md + + lors::imsmd::addMDSchemaVersion -acs_object $p_ims_md_id -schema $p_schema -schemaversion $p_schemaversion + + lors::imsmd::addLOM -lom $lom -prefix $prefix -acs_object $p_ims_md_id -dir $path_to_file + + } + } on_error { + ad_return_error "Transaction Error while Adding Metadata" "The error was: $errmsg" + } + return 1 + } + + + ad_proc -public addMDSchemaVersion { + {-acs_object:required} + {-schema:required} + {-schemaversion:required} + + } { + Adds MD schema and schema version to db + If the metedata record already exists, then it deletes it + and creates a new one. + + @param acs_object acs object for resource (element) that contains metadata. + @param schema MD schema used for the learning resource. + @param schemaversion MD schemaversion used for the learning resource. + @author Ernie Ghiglione (ErnieG@mm.st) + } { + set p_ims_md_id $acs_object + set p_schema $schema + set p_schemaversion $schemaversion + + # we check if the MD record we are about to insert already + # exists. If that is the case, then we delete it first. + # Yes, we are not versioning metadata (as I believe there's no + # real point on doing so. + + lors::imsmd::delMD -acs_object $p_ims_md_id + + db_transaction { + db_dml add_md { + insert into ims_md (ims_md_id, schema, schemaversion) + values + (:p_ims_md_id, :p_schema, :p_schemaversion) } - } + } on_error { + ad_return_error "Transaction Error in MD schema shemaversion " "The error was: $errmsg" + } } - } - return 1 + + ad_proc -public delMD { + {-acs_object:required} + } { + Deletes an MD record (deletes it ALL from the db). + + @param acs_object the acs object metadata we are deleting. + @author Ernie Ghiglione (ErnieG@mm.st). + } { + set p_ims_md_id $acs_object + + # if record exists... + if {[db_0or1row check_md_record {select ims_md_id from ims_md where ims_md_id = :p_ims_md_id}]} { + + # ... then delete it + db_transaction { + db_dml add_md { + delete from ims_md where ims_md_id = :p_ims_md_id + } + } on_error { + ad_return_error "Transaction deleting MD record" "The error was: $errmsg" + } + } + } + + + + + + +} + + + +namespace eval lors::imsmd::xml { + +### Generic XML creating tDOM functions +# Created just to make the super-tedious XML creation with tDOM a bit +# easier + + ad_proc -public newElement { + {-owner:required} + {-name:required} + } { + Creates an XML element node + + @param owner owner node + @param name element name + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + return [[$owner ownerDocument] createElement $name] + + } + + ad_proc -public newElementText { + {-owner:required} + {-name:required} + {-text:required} + } { + Creates an XML element with a text node + + @param owner owner node + @param name element name + @param text text + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + set node_text [lors::imsmd::xml::newText -owner $owner -text $text] + set node [lors::imsmd::xml::newElement -owner $owner -name $name] + $node appendChild $node_text -} \ No newline at end of file + return $node + + } + + ad_proc -public newText { + {-owner:required} + {-text:required} + } { + Creates an XML Text node + + @param owner owner node + @param text text + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + return [[$owner ownerDocument] createTextNode $text] + + } + + ad_proc -public newComment { + {-owner:required} + {-comment:required} + } { + Creates an XML Text node + + @param owner owner node + @param comment Comment + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + return [[$owner ownerDocument] createComment $comment] + + } + + +### End Generic XML creating tDOM functions +} + + + + +namespace eval lors::imsmd::create { + +### IMS MD XML creation + + +## LOM data types + +# langstring + + ad_proc -public newLangString { + {-owner:required} + {-lang:required} + {-string:required} + } { + Creates an LangString data type XML node + + @param owner owner node + @param lang language + @param string String + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + set ls_string [lors::imsmd::xml::newText -owner $owner -text $string] + set lang_string_node [lors::imsmd::xml::newElement -owner $owner -name langstring] + $lang_string_node setAttribute xml:lang $lang + $lang_string_node appendChild $ls_string + return $lang_string_node + + } + + + ad_proc -public md { + {-owner:required} + {-schema:required} + {-schemaversion:required} + {-lom:required} + } { + Creates a metadata node. + + @param owner Owner node + @param schema schema + @param schemaversion schemaversion + @param lom lom node + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + set metadata [lors::imsmd::xml::newElement -owner $owner -name metadata] + + $metadata appendChild [lors::imsmd::xml::newComment -owner $owner -comment "Generated by LORSm"] + + set schema [lors::imsmd::xml::newElementText -owner $owner -name schema -text $schema] + set schemaversion [lors::imsmd::xml::newElementText -owner $owner -name schemaversion -text $schemaversion] + + $metadata appendChild $schema + $metadata appendChild $schemaversion + $metadata appendChild $lom + + return $metadata + + } + + + ad_proc -public lom { + {-owner:required} + {-general {}} + {-lifecycle {}} + {-metametadata {}} + {-technical {}} + {-educational {}} + {-rights {}} + {-relation {}} + {-annotation {}} + {-classification {}} + } { + Creates a LOM node. + It puts together all the nodes and returns a LOMs node. + + @param owner ownerDocument node + @param general General node + @param lifecycle Lifecycle node + @param metametadata Metametadata node + @param technical Technical node + @param educational Educational node + @param rights Rights node + @param relation Relation node + @param annotation Annotation node + @param classification Classification node + + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + set lom [lors::imsmd::xml::newElement -owner $owner -name lom] + + if {![empty_string_p $general]} { + $lom appendChild $general + } + + if {![empty_string_p $lifecycle]} { + $lom appendChild $lifecycle + } + + if {![empty_string_p $metametadata]} { + $lom appendChild $metametadata + } + + if {![empty_string_p $technical]} { + $lom appendChild $technical + } + + if {![empty_string_p $educational]} { + $lom appendChild $educational + } + + if {![empty_string_p $rights]} { + $lom appendChild $rights + } + + if {![empty_string_p $relation]} { + $lom appendChild $relation + } + + if {![empty_string_p $annotation]} { + $lom appendChild $annotation + } + + if {![empty_string_p $classification]} { + $lom appendChild $classification + } + + return $lom + + + } + + + ad_proc -public lom_general { + {-owner:required} + {-identifier {}} + {-title {}} + {-catalogentry {}} + {-language {}} + {-description {}} + {-keyword {}} + {-coverage {}} + {-structure {}} + {-aggregationlevel {}} + } { + Creates a LOM general node. + It puts together all the general nodes + + refer to http://www.imsglobal.org/metadata/imsmdv1p2p1/imsmd_bindv1p2p1.html + for further details. + + + @param owner ownerDocument node + @param identifier identifier + @param title Name given to the learning object. element occurs 0 or 1 time within the element. + @param catalogentry This data element defines an entry within a catalog. element occurs 0 or more times. + @param language The primary human language or languages used within this learning object to communicate to the intended user.element occurs 0 or more times + @param description A textual description of the content of this learning object.element occurs 0 or more times + @param keyword A collection of keywords or phrases describing this learning object. element occurs 0 or more times + @param coverage The span or extent of such things as time, culture, geography or region that applies to this learning object.element occurs 0 or more times + @param structure Underlying organizational structure element occur 0 or 1 time + @param aggregationlevel The functional granularity. element occurs 0 or 1 time + + @author Ernie Ghiglione (ErnieG@mm.st). + } { + + + set general [lors::imsmd::xml::newElement -owner $owner -name general] + + # identifier + + if {![empty_string_p $identifier]} { + + set identifier_node [lors::imsmd::xml::newElementText \ + -owner $owner \ + -name indentifier \ + -text $identifier] + + $general appendChild $identifier_node + } + + + # title + + if {![empty_string_p $title]} { + + set title_node [lors::imsmd::xml::newElement -owner $owner -name title] + + foreach {y z} $title { + set langstring_node [lors::imsmd::create::newLangString \ + -owner $owner \ + -lang $y \ + -string $z \ + ] + + + $title_node appendChild $langstring_node + + } + + + $general appendChild $title_node + } + + # description + if {![empty_string_p $description]} { + + set description_node [lors::imsmd::xml::newElement -owner $owner -name description] + + foreach {y z} $description { + set langstring_node [lors::imsmd::create::newLangString \ + -owner $owner \ + -lang $y \ + -string $z \ + ] + + + $description_node appendChild $langstring_node + + } + + + $general appendChild $description_node + } + + + return $general + + } + + +} + Index: openacs-4/packages/lors/tcl/lors-imsmd-sc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imsmd-sc-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/lors/tcl/lors-imsmd-sc-procs.tcl 4 Sep 2004 14:04:08 -0000 1.1 @@ -0,0 +1,108 @@ +# packages/lors/tcl/lorsm-imsmd-sc-procs.tcl + +ad_library { + + LORS metadata search procedures + + @author Ernie Ghiglione (ErnieG@mm.st) + @creation-date 2004-05-21 + @arch-tag c74bf9d3-ec3b-423f-808b-fc41e6f32cc5 + @cvs-id $Id: lors-imsmd-sc-procs.tcl,v 1.1 2004/09/04 14:04:08 ernieg Exp $ +} + + +namespace eval lors::imsmd::sc { + + ad_proc mdrecord__datasource { + {ims_md_id} + } { + @param ims_md_id Metadata Record Identifier + @author Ernie Ghiglione (ErnieG@mm.st) + } { + + # Get Object_id + set object_id $ims_md_id + + + # Get Titles + # LOM General Title can have a bunch of titles in different + # languages. We get them all here. + set titles "" + + db_foreach title {select title_l, title_s from ims_md_general_title where ims_md_id = :ims_md_id} { + + if {![empty_string_p $title_l]} { + append titles "$title_s ($title_l) " + } else { + append titles "$title_s " + } + } + + # Get content + # we will pass LOM General description as content (we should + # improve this a bit more in the future with feedback + + set descriptions "" + + db_foreach description {select descrip_l, descrip_s from ims_md_general_desc where ims_md_id = :ims_md_id} { + + if {![empty_string_p $descrip_l]} { + append descriptions "$descrip_s ($descrip_l) " + } else { + append descriptions "$descrip_s " + } + } + + + # Get MIME + # LOM is just text therefore.. + set mime "text/plain" + + # Get Keywords + # LOM General Keywords + + set keywords "" + db_foreach keyword {select keyword_l, keyword_s from ims_md_general_key where ims_md_id = :ims_md_id} { + + if {![empty_string_p $keyword_l]} { + append keywords "$keyword_s ($keyword_l) " + } else { + append keywords "$keyword_s " + } + } + + # Storage type + set storage_type "text" + + # the contact of titles and descriptions is because the search + # functionality only indexes content (for some reasons), so I + # put the titles as well so they can be indexes too. Sames as + # keywords, actually. + + set data_list [list object_id $object_id title $titles content [concat $titles $descriptions $keywords] mime $mime keywords $keywords storage_type $storage_type] + array set datasource $data_list + + + return [array get datasource] + + } + + + ad_proc mdrecord__url { + {ims_md_id} + } { + @param ims_md_id Metadata Record Identifier + @author Ernie Ghiglione (ErnieG@mm.st) + } { + +# set url_stub [apm_package_url_from_id [apm_package_id_from_key "lorsm"]] +# set url "${url_stub}md/?ims_md_id=$ims_md_id" + + set url "/lorsm/md/?ims_md_id=$ims_md_id" + + return $url + + } +} + +