Index: openacs-4/packages/lors/lors.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lors.info,v
diff -u -r1.6 -r1.7
--- openacs-4/packages/lors/lors.info 25 Apr 2005 08:12:42 -0000 1.6
+++ openacs-4/packages/lors/lors.info 17 May 2005 16:35:10 -0000 1.7
@@ -6,16 +6,17 @@
Learning Object Repository Services
f
t
-
-
+
+
Ernie Ghiglione
IMS Content Packaging and Medata Services.
Implementation of IMS CP and MD for .LRN
- 2005-04-25
+ 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.2 -r1.3
--- openacs-4/packages/lors/sql/postgresql/lors-create.sql 4 Sep 2004 14:04:07 -0000 1.2
+++ openacs-4/packages/lors/sql/postgresql/lors-create.sql 17 May 2005 16:35:10 -0000 1.3
@@ -108,3 +108,4 @@
\i lors-imscp-create.sql
\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.6 -r1.7
--- openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql 21 Apr 2005 16:29:06 -0000 1.6
+++ openacs-4/packages/lors/sql/postgresql/lors-imscp-create.sql 17 May 2005 16:35:10 -0000 1.7
@@ -24,76 +24,13 @@
-----
--- Create the object types
------
-
-create function inline_0 ()
-returns integer as '
-begin
-
- PERFORM acs_object_type__create_type (
- ''ims_manifest'', -- object_type
- ''IMS_Manifest'', -- pretty_name
- ''IMS_Manifests'', -- pretty_plural
- ''acs_object'', -- supertype
- ''imscp_manifests'', -- table_name
- ''man_id'', -- id_column
- null , -- name_method
- ''f'',
- null,
- null
- );
- PERFORM acs_object_type__create_type (
- ''ims_organization'', -- object_type
- ''IMS_Organization'', -- pretty_name
- ''IMS_Organizations'', -- pretty_plural
- ''ims_manifest'', -- supertype
- ''imscp_organizations'', -- table_name
- ''org_id'', -- id_column
- null, -- name_method
- ''f'',
- null,
- null
- );
- PERFORM acs_object_type__create_type (
- ''ims_item'', -- object_type
- ''IMS_Item'', -- pretty_name
- ''IMS_Items'', -- pretty_plural
- ''ims_organization'', -- supertype
- ''imscp_items'', -- table_name
- ''item_id'', -- id_column
- null, -- name_method
- ''f'',
- null,
- null
- );
- PERFORM acs_object_type__create_type (
- ''ims_resource'', -- object_type
- ''IMS_Resource'', -- pretty_name
- ''IMS_Resources'', -- pretty_plural
- ''ims_item'', -- supertype
- ''imscp_resources'', -- table_name
- ''org_id'', -- id_column
- null, -- name_method
- ''f'',
- null,
- null
- );
- return 0;
-end;' language 'plpgsql';
-
-select inline_0 ();
-drop function inline_0 ();
-
------
-- Create tables
----
-
-- Manifests
create table ims_cp_manifests (
man_id integer
constraint ims_cp_man_id_fk
- references acs_objects(object_id)
+ references cr_revisions
on delete cascade
constraint ims_cp_man_id_pk
primary key,
@@ -143,11 +80,28 @@
belongs to.
';
+-- create ims manifest content type
+-- we do not use CR for content storage (at least not for ims_* objects) as these are just abstract aggregations
+-- and organization of objects. We use content types for the sake of versioning
+--
+select content_type__create_type (
+ 'ims_manifest_object', -- content_type
+ 'content_revision', -- supertype. We search revision content
+ -- first, before item metadata
+ 'IMS Manifest Object', -- pretty_name
+ 'IMS Manifest Objects', -- pretty_plural
+ 'ims_cp_manifests', -- table_name
+ 'man_id', -- id_column
+ 'ims_manifest__get_title' -- name_method
+);
+
+
+
-- Organizations
create table ims_cp_organizations (
org_id integer
constraint ims_cp_org_id_fk
- references acs_objects(object_id)
+ references cr_revisions
on delete cascade
constraint ims_cp_org_id_pk
primary key,
@@ -157,7 +111,7 @@
on delete cascade,
identifier varchar(100),
structure varchar(100),
- title varchar(1000),
+ org_title varchar(1000),
hasmetadata boolean default 'f' not null,
isshared boolean default 'f' not null
);
@@ -166,11 +120,27 @@
create index ims_cp_organizations__man_id_idx on ims_cp_organizations (man_id);
+-- create ims organization content type
+--
+select content_type__create_type (
+ 'ims_organization_object', -- content_type
+ 'content_revision', -- supertype. We search revision content
+ -- first, before item metadata
+ 'IMS Organization Object', -- pretty_name
+ 'IMS Organization Objects', -- pretty_plural
+ 'ims_cp_organizations', -- table_name
+ 'org_id', -- id_column
+ 'ims_organization__get_title' -- name_method
+);
+
+
+
+
-- Items
create table ims_cp_items (
- item_id integer
+ ims_item_id integer
constraint ims_cp_items_item_id_fk
- references acs_objects(object_id)
+ references cr_revisions
on delete cascade
constraint ims_cp_items_item_id_pk
primary key,
@@ -183,7 +153,7 @@
-- isvisible 1 = Yes, 0 = No
isvisible boolean,
parameters varchar(1000),
- title varchar(1000),
+ item_title varchar(1000),
parent_item integer,
hasmetadata boolean default 'f' not null,
-- SCORM extensions (based on SCORM 1.2 specs)
@@ -200,12 +170,27 @@
-- create index for ims_cp_items
create index ims_cp_items__org_id_idx on ims_cp_items (org_id);
+-- create ims items content type
+--
+select content_type__create_type (
+ 'ims_item_object', -- content_type
+ 'content_revision', -- supertype. We search revision content
+ -- first, before item metadata
+ 'IMS Item Object', -- pretty_name
+ 'IMS Item Objects', -- pretty_plural
+ 'ims_cp_items', -- table_name
+ 'ims_item_id', -- id_column
+ 'ims_item__get_title' -- name_method
+);
+
+
+
-- Resources
create table ims_cp_resources (
res_id integer
constraint ims_cp_resources_res_id_fk
- references acs_objects(object_id)
+ references cr_revisions
on delete cascade
constraint ims_cp_resources_res_id_pk
primary key,
@@ -224,24 +209,38 @@
-- create index for ims_cp_resources
create index ims_cp_resources__man_id_idx on ims_cp_resources (man_id);
+-- create ims resources content type
+--
+select content_type__create_type (
+ 'ims_resource_object', -- content_type
+ 'content_revision', -- supertype. We search revision content
+ -- first, before item metadata
+ 'IMS Resource Object', -- pretty_name
+ 'IMS Resource Objects', -- pretty_plural
+ 'ims_cp_resources', -- table_name
+ 'res_id', -- id_column
+ 'ims_resource__get_title' -- name_method
+);
+
+
-- An item can have reference to one of more resources
-- therefore we need a table that takes care of this multiple
-- relationship
create table ims_cp_items_to_resources (
- item_id integer
+ ims_item_id integer
constraint ims_cp_items_to_res_item_id_fk
- references ims_cp_items(item_id)
+ references ims_cp_items(ims_item_id)
on delete cascade,
res_id integer
constraint ims_cp_items_to_resources_fk
references ims_cp_resources(res_id)
on delete cascade,
- primary key (item_id, res_id)
+ primary key (ims_item_id, res_id)
);
-- create index for ims_cp_items_to_resources
-create index ims_cp_items_to_resources__item_id_idx on ims_cp_items_to_resources (item_id);
+create index ims_cp_items_to_resources__item_id_idx on ims_cp_items_to_resources (ims_item_id);
create index ims_cp_items_to_resources__res_id_idx on ims_cp_items_to_resources (res_id);
-- Resource dependencies
@@ -333,4 +332,4 @@
comment on column ims_cp_manifest_class.istrackable is '
Whether the course is trackable for that community instance.
default false
-';
+';
\ No newline at end of file
Index: openacs-4/packages/lors/sql/postgresql/lors-imscp-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/sql/postgresql/lors-imscp-drop.sql,v
diff -u -r1.4 -r1.5
--- openacs-4/packages/lors/sql/postgresql/lors-imscp-drop.sql 24 Feb 2005 18:41:12 -0000 1.4
+++ openacs-4/packages/lors/sql/postgresql/lors-imscp-drop.sql 17 May 2005 16:35:10 -0000 1.5
@@ -19,5 +19,5 @@
drop table ims_cp_items;
drop table ims_cp_organizations;
drop table ims_cp_manifests;
-drop table lors_available_presentation_formats;
+
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.3 -r1.4
--- openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql 21 Apr 2005 15:36:29 -0000 1.3
+++ openacs-4/packages/lors/sql/postgresql/lors-imscp-package-create.sql 17 May 2005 16:35:10 -0000 1.4
@@ -23,7 +23,6 @@
-- SCORM 1.2 Specs
create or replace function ims_manifest__new (
- integer, -- manifest_id
varchar, -- course_name
varchar, -- identifier
varchar, -- version
@@ -39,54 +38,47 @@
integer, -- package_id
integer, -- community_id
varchar, -- class_key
- integer -- course_presentation_format
+ integer, -- new revision_id for the item in the CR
+ boolean, -- is shared
+ integer -- course_presentation_format
)
returns integer as '
declare
- p_man_id alias for $1;
- p_course_name alias for $2;
- p_identifier alias for $3;
- p_version alias for $4;
- p_orgs_default alias for $5;
- p_hasmetadata alias for $6;
- 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_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;
- p_course_presentation_format alias for $17;
-
- v_man_id integer;
+ p_course_name alias for $1;
+ p_identifier alias for $2;
+ p_version alias for $3;
+ p_orgs_default alias for $4;
+ p_hasmetadata alias for $5;
+ p_parent_man_id alias for $6;
+ p_isscorm alias for $7;
+ p_folder_id alias for $8;
+ p_fs_package_id alias for $9;
+ p_creation_date alias for $10;
+ p_creation_user alias for $11;
+ p_creation_ip alias for $12;
+ p_package_id alias for $13;
+ p_community_id alias for $14;
+ p_class_key alias for $15;
+ p_revision_id alias for $16;
+ p_isshared alias for $17;
+ p_course_presentation_format alias for $18;
begin
- v_man_id := acs_object__new (
- p_man_id, -- object_id
- ''ims_manifest'', -- object_type
- p_creation_date, -- creation_date
- p_creation_user, -- creation_user
- p_creation_ip, -- creation_ip
- p_package_id, -- context_id
- ''t'' -- security_inherit_p
- );
-
- insert into ims_cp_manifests
- (man_id, course_name, identifier, version, orgs_default, hasmetadata, parent_man_id, isscorm, folder_id, fs_package_id, course_presentation_format)
- 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, p_course_presentation_format);
-
+
+ -- we make an update here because the content::item::new already inserts a row in the ims_cp_manifests
+ update ims_cp_manifests
+ set course_name=p_course_name, identifier=p_identifier, version=p_version,
+ orgs_default=p_orgs_default, hasmetadata=p_hasmetadata, parent_man_id=p_parent_man_id,
+ isscorm=p_isscorm, folder_id=p_folder_id, fs_package_id=p_fs_package_id, isshared = p_isshared,
+ course_presentation_format=p_course_presentation_format
+ where man_id = p_revision_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;
+ (p_revision_id, p_package_id, p_community_id, p_class_key, ''t'', ''f'');
+
+ return p_revision_id;
end;
' language 'plpgsql';
@@ -114,7 +106,8 @@
timestamp with time zone, -- creation_date
integer, -- creation_user
varchar, -- creation_ip
- integer -- package_id
+ integer, -- package_id
+ integer -- revision_id
)
returns integer as '
declare
@@ -128,25 +121,15 @@
p_creation_user alias for $8;
p_creation_ip alias for $9;
p_package_id alias for $10;
-
- v_org_id integer;
+ p_revision_id alias for $11;
begin
- v_org_id := acs_object__new (
- p_org_id, -- object_id
- ''ims_organization'', -- object_type
- p_creation_date, -- creation_date
- p_creation_user, -- creation_user
- p_creation_ip, -- creation_ip
- p_man_id, -- context_id
- ''t'' -- security_inherit_p
- );
+ -- we make an update here because the content::item::new already inserts a row in the ims_cp_organizations
+ update ims_cp_organizations
+ set man_id=p_man_id, identifier=p_identifier, structure=p_structure,
+ org_title=p_title, hasmetadata=p_hasmetadata
+ where org_id = p_revision_id;
- insert into ims_cp_organizations
- (org_id, man_id, identifier, structure, title, hasmetadata)
- values
- (v_org_id, p_man_id, p_identifier, p_structure, p_title, p_hasmetadata);
-
- return v_org_id;
+ return p_revision_id;
end;
' language 'plpgsql';
@@ -184,7 +167,8 @@
timestamp with time zone, -- creation_date
integer, -- creation_user
varchar, -- creation_ip
- integer -- package_id
+ integer, -- package_id
+ integer -- revision_id
)
returns integer as '
declare
@@ -208,25 +192,17 @@
p_creation_user alias for $18;
p_creation_ip alias for $19;
p_package_id alias for $20;
-
- v_item_id integer;
+ p_revision_id alias for $21;
begin
- v_item_id := acs_object__new (
- p_item_id, -- object_id
- ''ims_item'', -- object_type
- p_creation_date, -- creation_date
- p_creation_user, -- creation_user
- p_creation_ip, -- creation_ip
- p_parent_item, -- context_id
- ''t'' -- security_inherit_p
- );
+ update ims_cp_items
+ set org_id=p_org_id, identifier=p_identifier, identifierref=p_identifierref,
+ isvisible=p_isvisible, parameters=p_parameters, item_title=p_title, parent_item=p_parent_item,
+ hasmetadata=p_hasmetadata, prerequisites_t=p_prerequisites_t, prerequisites_s=p_prerequisites_s,
+ type=p_type, maxtimeallowed=p_maxtimeallowed, timelimitaction=p_timelimitaction,
+ datafromlms=p_datafromlms, masteryscore=p_masteryscore
+ where ims_item_id = p_revision_id;
- insert into ims_cp_items
- (item_id, org_id, identifier, identifierref, isvisible, parameters, title, parent_item, hasmetadata, prerequisites_t, prerequisites_s, type, maxtimeallowed, timelimitaction, datafromlms, masteryscore)
- values
- (v_item_id, p_org_id, p_identifier, p_identifierref, p_isvisible, p_parameters, p_title, p_parent_item, p_hasmetadata, p_prerequisites_t, p_prerequisites_s, p_type, p_maxtimeallowed, p_timelimitaction, p_datafromlms, p_masteryscore);
-
- return v_item_id;
+ return p_revision_id;
end;
' language 'plpgsql';
@@ -255,7 +231,8 @@
timestamp with time zone, -- creation_date
integer, -- creation_user
varchar, -- creation_ip
- integer -- package_id
+ integer, -- package_id
+ integer -- revision_id
)
returns integer as '
declare
@@ -270,25 +247,14 @@
p_creation_user alias for $9;
p_creation_ip alias for $10;
p_package_id alias for $11;
-
- v_res_id integer;
+ p_revision_id alias for $12;
begin
- v_res_id := acs_object__new (
- p_res_id, -- object_id
- ''ims_resource'', -- object_type
- p_creation_date, -- creation_date
- p_creation_user, -- creation_user
- p_creation_ip, -- creation_ip
- p_man_id, -- context_id
- ''t'' -- security_inherit_p
- );
-
- insert into ims_cp_resources
- (res_id, man_id, identifier, type, href, scorm_type, hasmetadata)
- values
- (v_res_id, p_man_id, p_identifier, p_type, p_href, p_scorm_type, p_hasmetadata);
-
- return v_res_id;
+ update ims_cp_resources
+ set man_id=p_man_id, identifier=p_identifier, type=p_type,
+ href=p_href, scorm_type=p_scorm_type, hasmetadata=p_hasmetadata
+ where res_id = p_revision_id;
+
+ return p_revision_id;
end;
' language 'plpgsql';
@@ -317,7 +283,7 @@
p_res_id alias for $2;
begin
- insert into ims_cp_items_to_resources (item_id, res_id)
+ insert into ims_cp_items_to_resources (ims_item_id, res_id)
values
(p_item_id, p_res_id);
@@ -393,18 +359,18 @@
-- put in and correct some stuff for ims_cp_items
-- function name
-create or replace function ims_item__name (integer)
+create or replace function ims_item__get_title (integer)
returns varchar as '
declare
name__object_id alias for $1;
- v_title ims_cp_items.title%TYPE;
+ v_title ims_cp_items.item_title%TYPE;
v_object_id integer;
begin
- select title
+ select item_title
into v_title
from ims_cp_items
- where item_id = name__object_id;
+ where ims_item_id = name__object_id;
return v_title;
@@ -413,7 +379,7 @@
update acs_object_types
set table_name = 'ims_cp_items',
- name_method = 'ims_item__name',
+ name_method = 'ims_item__get_title',
pretty_name = 'IMS Item',
pretty_plural = 'IMS Items'
where object_type = 'ims_item';
Index: openacs-4/packages/lors/tcl/lors-assessment-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/Attic/lors-assessment-procs.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/lors/tcl/lors-assessment-procs.tcl 23 Nov 2004 19:13:27 -0000 1.2
+++ openacs-4/packages/lors/tcl/lors-assessment-procs.tcl 17 May 2005 16:35:11 -0000 1.3
@@ -43,7 +43,7 @@
}
# Delete the temporary directory
- file delete -force $tmpdirectory
+ exec rm -fr $tmpdirectory
# Restore the package_id
ad_conn -set package_id $current_package_id
Index: openacs-4/packages/lors/tcl/lors-cr-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-cr-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/lors/tcl/lors-cr-procs.tcl 17 Nov 2004 22:43:58 -0000 1.3
+++ openacs-4/packages/lors/tcl/lors-cr-procs.tcl 17 May 2005 16:35:11 -0000 1.4
@@ -110,6 +110,7 @@
return $folder_id
}
+
ad_proc -public lors::cr::add_files {
{-parent_id:required}
{-files:required}
@@ -135,57 +136,21 @@
foreach fle $files {
regexp {[^//\\]+$} $fle filename
- # Get the filename part of the upload file
-# if { ![regexp {[^//\\]+$} $fle filename] } {
- # no match
-# set filename $fle
-# }
-
- # Get the title
- #if { [empty_string_p $title] } {
- set title $filename
- #}
-
+ set title $filename
set mime_type [cr_filename_to_mime_type -create $fle]
- #return [list $filename $parent_id $user_id $creation_ip $mime_type]
-
# insert file into the CR
db_transaction {
-
- # create the file_id
-# set file_id [db_exec_plsql file_add {
-# select lors__new_lo (:filename, :parent_id, :user_id, :creation_ip);
-# }]
set description "uploaded using LORs"
# add file
- set file_id [db_exec_plsql file_add {
- select file_storage__new_file (
- :title, -- title
- :parent_id, -- parent_id
- :user_id, -- creation_user
- :creation_ip, -- creation_ip
- false -- indb_p
- );
- }]
+ set file_id [content::item::new -name $title -parent_id $parent_id -creation_user $user_id \
+ -creation_ip $creation_ip]
- # create the revision
- # set version_id [db_exec_plsql new_version {
- # select lors__new_lo_version (:filename, :filename, :mime_type, :file_id, :user_id, :creation_ip);
- # }]
# add revision
- set version_id [db_exec_plsql new_version {
- select file_storage__new_version (
- :filename, -- filename
- :description, -- description
- :mime_type, -- mime_type
- :file_id, -- item_id
- :user_id, -- creation_user
- :creation_ip -- creation_ip
- );
- }]
+ set version_id [content::revision::new -title $title -description $description -mime_type $mime_type \
+ -creation_user $user_id -creation_ip $creation_ip -item_id $file_id -is_live "t"]
# move the actual file into the CR
set cr_file [cr_create_content_file $file_id $version_id $fle]
@@ -200,4 +165,18 @@
lappend retlist [list $fle $mime_type $parent_id $file_id $version_id $cr_file $file_size]
}
return $retlist
+}
+
+
+ad_proc -public lors::cr::get_item_id {
+ -name:required
+ -folder_id:required
+} {
+ Get the item_id of a file
+} {
+ if {[empty_string_p $folder_id]} {
+ set package_id [ad_conn package_id]
+ set folder_id [fs_get_root_folder -package_id $package_id]
+ }
+ return [db_exec_plsql get_item_id "select content_item__get_id ( :name, :folder_id, 'f' )"]
}
\ No newline at end of file
Index: openacs-4/packages/lors/tcl/lors-imscp-blackboard5-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imscp-blackboard5-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/lors/tcl/lors-imscp-blackboard5-procs.tcl 26 Apr 2005 16:45:21 -0000 1.3
+++ openacs-4/packages/lors/tcl/lors-imscp-blackboard5-procs.tcl 17 May 2005 16:35:11 -0000 1.4
@@ -165,7 +165,7 @@
@author Ernie Ghiglione (ErnieG@mm.st)
} {
- set docx [dom parse [::tDOM::xmlReadFile $file]]
+ set docx [dom parse [read [open $file]]]
set usersnode [$docx documentElement]
set userlist [list]
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 -r1.3 -r1.4
--- openacs-4/packages/lors/tcl/lors-imscp-blackboard6-procs.tcl 26 Apr 2005 16:33:14 -0000 1.3
+++ openacs-4/packages/lors/tcl/lors-imscp-blackboard6-procs.tcl 17 May 2005 16:35:11 -0000 1.4
@@ -207,8 +207,12 @@
@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 [::tDOM::xmlReadFile $file]]
+ set doc [dom parse [read [open $file]]]
# coursetoc
set coursetoc [$doc documentElement]
@@ -243,8 +247,12 @@
@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 [::tDOM::xmlReadFile $file]]
+ set doc [dom parse [read [open $file]]]
# content
set content [$doc documentElement]
@@ -320,6 +328,10 @@
@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]
@@ -377,8 +389,12 @@
@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 [::tDOM::xmlReadFile $file]]
+ set doc [dom parse [read [open $file]]]
# content
set announcement [$doc documentElement]
@@ -481,7 +497,7 @@
# Now we delete the zip file as we
# don't need it any more
- file delete -force $path/$zipfile
+ exec rm -fr $path/$zipfile
# Also we remove the actual file
# children for the resource as
@@ -536,8 +552,12 @@
@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 [::tDOM::xmlReadFile $file]]
+ set doc [dom parse [read [open $file]]]
# content
set forum [$doc documentElement]
@@ -574,8 +594,11 @@
@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 [::tDOM::xmlReadFile $tmp_dir/$file]]
+ set doc [dom parse [read [open $tmp_dir/$file]]]
# gets the manifest tree
set manifest [$doc documentElement]
# we add the xml namespace for dotLRN
@@ -590,7 +613,7 @@
if {[empty_string_p $metadata]} {
set filex res00001.dat
- set docx [dom parse [::tDOM::xmlReadFile $tmp_dir/$filex]]
+ set docx [dom parse [read [open $tmp_dir/$filex]]]
# gets BB's course info
set course [$docx documentElement]
@@ -646,8 +669,18 @@
@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 [::tDOM::xmlReadFile $tmp_dir/$file]]
+ set doc [dom parse [read [open $tmp_dir/$file]]]
# gets the manifest tree
set manifest [$doc documentElement]
@@ -775,7 +808,7 @@
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]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file]
[lindex $resource 2] delete
}
@@ -792,7 +825,7 @@
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]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file]
[lindex $resource 2] delete
}
@@ -817,7 +850,7 @@
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]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt [lindex $resource 2] bb:file]
[lindex $resource 2] delete
}
@@ -865,9 +898,12 @@
@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 [::tDOM::xmlReadFile $tmp_dir/$file]]
+ set doc [dom parse [read [open $tmp_dir/$file]]]
# gets the manifest tree
set manifest [$doc documentElement]
@@ -1128,7 +1164,7 @@
}
}
- file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
+ exec rm -fr $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"
@@ -1139,58 +1175,58 @@
# 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]
+ exec rm -fr $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]
+ exec rm -fr $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]
+ exec rm -fr $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]
+ exec rm -fr $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]
+ exec rm -fr $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]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
$resource delete
}
"course/x-bb-coursesetting" {
ns_log Notice "\n--resource coursesetting: [lors::imsmd::getAtt $resource bb:file] deleted\n"
- file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
$resource delete
}
"resource/x-bb-conference" {
ns_log Notice "\n--resource conference: [lors::imsmd::getAtt $resource bb:file] deleted\n"
- file delete $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
+ exec rm -fr $tmp_dir/[lors::imsmd::getAtt $resource bb:file]
$resource delete
}
@@ -1211,4 +1247,4 @@
}
-### End Cleanup Functions
+### 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.6 -r1.7
--- openacs-4/packages/lors/tcl/lors-imscp-procs.tcl 26 Apr 2005 16:33:14 -0000 1.6
+++ openacs-4/packages/lors/tcl/lors-imscp-procs.tcl 17 May 2005 16:35:11 -0000 1.7
@@ -38,6 +38,7 @@
@author Ernie Ghiglione (ErnieG@mm.st)
} {
+
set items ""
set itemx [$tree child all item]
@@ -190,7 +191,10 @@
{-community_id ""}
{-user_id ""}
{-creation_ip ""}
- {-course_presentation_format "-1"}
+ {-version_id ""}
+ {-course_presentation_format "-1"}
+ {-man_folder_id ""}
+ {-content_folder_id ""}
} {
Inserts a new manifest according to the imsmanifest.xml file.
@@ -211,6 +215,7 @@
@option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default.
@author Ernie Ghiglione (ErnieG@mm.st)
} {
+
if {[empty_string_p $user_id]} {
set user_id [ad_conn user_id]
}
@@ -226,35 +231,77 @@
if {[empty_string_p $isscorm]} {
set isscorm 0
}
+ if {[empty_string_p $content_folder_id]} {
+ set content_folder_id $folder_id
+ }
set class_key [dotlrn_community::get_community_type_from_community_id $community_id]
+ #########################################################################################
+ # Since now we dont use acs-objects for the manifest, then a new cr_item and revision
+ # needs to be done to store the manifest. The cr_item and cr_revision are created here
+ # in orther to use the CR API.
+
+ if { ![empty_string_p $man_folder_id]} {
+ # Get LORSM Manifest Folder folder_id
+ set parent_id $man_folder_id
+ } else {
+ set parent_id $folder_id
+ }
+ set content_type "ims_manifest_object"
+ set name "$course_name"
+ if {[empty_string_p $version_id]} {
+ set item_id [content::item::new -name $name -item_id $man_id -content_type $content_type -parent_id $parent_id \
+ -creation_date [dt_sysdate] -creation_user $user_id -creation_ip $creation_ip -context_id $package_id]
+
+ # We give the user_id admin privilege over the item_id so only he/she can make changes to
+ # this course, unless it grants other user privileges
+ permission::grant -party_id $user_id -object_id $item_id -privilege admin
+
+ # The new course has for default its isshared value false
+ set isshared f
+
+ } else {
+ set item_id $version_id
+ set isshared [db_string get_isshared "select im.isshared from ims_cp_manifests im where im.man_id = (
+ select live_revision from cr_items where item_id = :version_id
+ ) "]
+ }
+
+ set revision_id [content::revision::new -title $name -content_type $content_type -creation_user $user_id \
+ -creation_ip $creation_ip -item_id $item_id -is_live "t"]
+
+ # Now the new revision_id will be sent to the sql function with the
+ # additional information as before
+
db_transaction {
set manifest_id [db_exec_plsql new_manifest {
select ims_manifest__new (
- :man_id,
:course_name,
:identifier,
:version,
:orgs_default,
:hasmetadata,
:parent_man_id,
:isscorm,
- :folder_id,
+ :content_folder_id,
:fs_package_id,
current_timestamp,
:user_id,
:creation_ip,
:package_id,
:community_id,
:class_key,
- :course_presentation_format
+ :revision_id,
+ :isshared,
+ :course_presentation_format
);
}
]
}
+
return $manifest_id
}
@@ -288,6 +335,7 @@
{-package_id ""}
{-user_id ""}
{-creation_ip ""}
+ {-org_folder_id ""}
} {
Inserts a new organizations according to the imsmanifest.xml file.
@@ -303,7 +351,8 @@
@option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default.
@author Ernie Ghiglione (ErnieG@mm.st)
} {
- if {[empty_string_p $user_id]} {
+
+ if {[empty_string_p $user_id]} {
set user_id [ad_conn user_id]
}
if {[empty_string_p $creation_ip]} {
@@ -312,7 +361,23 @@
if {[empty_string_p $package_id]} {
set package_id [ad_conn package_id]
}
+
+ #--------------------------------------------------------------------------------------#
+ # Since now we dont use acs-objects for the organizations, then a new cr_item and revision
+ # needs to be done to store it. The cr_item and cr_revision are created here
+ # in orther to use the CR API. The item name probably has to change
+
+ # Get LORSM Organizations Folder folder_id
+ set parent_id $org_folder_id
+ set content_type "ims_organization_object"
+ set name "$identifier"
+ set item_id [content::item::new -name $name -item_id $org_id -content_type $content_type -parent_id $parent_id \
+ -creation_date [dt_sysdate] -creation_user $user_id -creation_ip $creation_ip -context_id $package_id]
+
+ set revision_id [content::revision::new -title $name -content_type $content_type -creation_user $user_id \
+ -creation_ip $creation_ip -item_id $item_id -is_live "t"]
+
db_transaction {
set organization_id [db_exec_plsql new_organization {
select ims_organization__new (
@@ -325,7 +390,8 @@
current_timestamp,
:user_id,
:creation_ip,
- :package_id
+ :package_id,
+ :revision_id
);
}
@@ -377,6 +443,7 @@
{-package_id ""}
{-user_id ""}
{-creation_ip ""}
+ -itm_folder_id:required
} {
Inserts a new item according to the info retrieved from the imsmanifest.xml file.
@@ -403,6 +470,7 @@
@option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default.
@author Ernie Ghiglione (ErnieG@mm.st)
} {
+
if {[empty_string_p $user_id]} {
set user_id [ad_conn user_id]
}
@@ -422,6 +490,24 @@
set title "No Title"
}
+ #--------------------------------------------------------------------------------------#
+ # Since now we dont use acs-objects for the item, then a new cr_item and revision
+ # needs to be done to store it. The cr_item and cr_revision are created here
+ # in orther to use the CR API. The item name probably has to change
+
+ # Get LORSM Item Folder folder_id
+ set parent_id $itm_folder_id
+ set content_type "ims_item_object"
+ set sysdate [dt_sysdate]
+ set name "$identifier"
+ set cr_item_id [content::item::new -name $name -item_id $item_id -content_type $content_type -parent_id $parent_id \
+ -creation_date [dt_sysdate] -creation_user $user_id -creation_ip $creation_ip \
+ -context_id $package_id -description $title]
+
+
+ set revision_id [content::revision::new -title $name -content_type $content_type -creation_user $user_id \
+ -creation_ip $creation_ip -item_id $cr_item_id -is_live "t"]
+
db_transaction {
set item_id [db_exec_plsql new_item {
select ims_item__new (
@@ -444,7 +530,8 @@
current_timestamp,
:user_id,
:creation_ip,
- :package_id
+ :package_id,
+ :revision_id
);
}
@@ -457,34 +544,34 @@
permission::toggle_inherit -object_id $item_id
- set community_id [dotlrn_community::get_community_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 \
+ #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
+ #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 \
+ #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
+ #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 \
+ #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
+ #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"
+ #ns_log Notice "ims_item_id ($item_id) read permissions granted for community admins"
}
@@ -514,6 +601,7 @@
}
ad_proc -public lors::imscp::addItems {
+ -itm_folder_id:required
{-org_id:required}
{itemlist}
{parent ""}
@@ -528,6 +616,7 @@
@author Ernie Ghiglione (ErnieG@mm.st)
} {
+
set retlist ""
foreach item $itemlist {
@@ -552,7 +641,7 @@
set md_node $p_hasmetadata
set p_hasmetadata 1
}
-
+
set item_id [lors::imscp::item_add \
-org_id $p_org_id \
-parent_item $p_parent_item \
@@ -567,7 +656,8 @@
-timelimitaction $p_timelimitaction \
-datafromlms $p_datafromlms \
-masteryscore $p_masteryscore \
- -dotlrn_permission $p_dotlrn_permission]
+ -dotlrn_permission $p_dotlrn_permission \
+ -itm_folder_id $itm_folder_id]
if {$p_hasmetadata == 1} {
set aa [lors::imsmd::addMetadata \
@@ -579,7 +669,8 @@
lappend retlist [list $item_id $p_identifierref]
if { [llength $item] > 13} {
- set subitem [lors::imscp::addItems -org_id $p_org_id [lindex $item 13] $item_id $tmp_dir]
+ set subitem [lors::imscp::addItems -itm_folder_id $itm_folder_id \
+ -org_id $p_org_id [lindex $item 13] $item_id $tmp_dir]
set retlist [concat $retlist $subitem]
}
}
@@ -598,6 +689,8 @@
{-package_id ""}
{-user_id ""}
{-creation_ip ""}
+ {-num ""}
+ {-res_folder_id ""}
} {
Inserts a new resource according to the imsmanifest.xml file.
@@ -614,6 +707,7 @@
@option creation_ip ip-address of the user that adds the category. [ad_conn peeraddr] used by default.
@author Ernie Ghiglione (ErnieG@mm.st)
} {
+
if {[empty_string_p $user_id]} {
set user_id [ad_conn user_id]
}
@@ -624,6 +718,22 @@
set package_id [ad_conn package_id]
}
+ #--------------------------------------------------------------------------------------#
+ # Since now we dont use acs-objects for the resource, then a new cr_item and revision
+ # needs to be done to store it. The cr_item and cr_revision are created here
+ # in orther to use the CR API. The item name probably has to change
+
+ # Get LORSM Resource Folder folder_id
+ set parent_id $res_folder_id
+ set content_type "ims_resource_object"
+ set name "$identifier"
+ set item_id [content::item::new -name $name -content_type $content_type -parent_id $parent_id \
+ -creation_date [dt_sysdate] -creation_user $user_id -creation_ip $creation_ip -context_id $package_id]
+
+
+ set revision_id [content::revision::new -title $name -content_type $content_type -creation_user $user_id \
+ -creation_ip $creation_ip -item_id $item_id -is_live "t"]
+
db_transaction {
set resource_id [db_exec_plsql new_resource {
select ims_resource__new (
@@ -637,7 +747,8 @@
current_timestamp,
:user_id,
:creation_ip,
- :package_id
+ :package_id,
+ :revision_id
);
}
@@ -876,7 +987,7 @@
}
if {$errp} {
- file delete -force $tmp_dir
+ exec rm -fr $tmp_dir
ns_log Notice "lors::imscp::expand_file: extract type $type failed $errMsg"
return -code error "lors::imscp::expand_file: extract type $type failed $errMsg"
}
@@ -945,7 +1056,7 @@
#Now that we are done working on the upload we delete the tmp directory and files
if [info exists tmp_dir] {
ns_log Notice "lors::imscp: Deleting $tmp_dir"
- file delete -force $tmp_dir
+ exec rm -fr $tmp_dir
}
}
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.5 -r1.6
--- openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl 26 Apr 2005 16:33:14 -0000 1.5
+++ openacs-4/packages/lors/tcl/lors-imsmd-procs.tcl 17 May 2005 16:35:11 -0000 1.6
@@ -140,8 +140,7 @@
set prefix [[$tree child all imsmd:record] prefix]
set lom [$tree child all $var_lom]
} elseif { ![empty_string_p [$tree child all adlcp:location]] } {
- dom parse [::tDOM::xmlReadFile $dir/[[$tree child all adlcp:location] text]] doc
- set lom [$doc documentElement]
+ set lom [[dom parse [read [open $dir/[[$tree child all adlcp:location] text]]]] documentElement]
set prefix [$lom prefix]
} else {
set lom 0