Index: openacs-4/packages/imsld/imsld.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/imsld.info,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/imsld.info 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/imsld.info 5 Aug 2005 15:25:33 -0000 1.2 @@ -16,8 +16,11 @@ + + + Index: openacs-4/packages/imsld/sql/postgresql/imsld-cp-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-cp-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-cp-create.sql 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,115 @@ +-- +-- IMS-LD Package Data Model (Content Packagin) Create +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date jul-2005 +-- + +-- Manifests +create table imsld_cp_manifests ( + manifest_id integer + constraint imsld_man_fk + references cr_revisions + on delete cascade + constraint imsld_man_pk + primary key, + identifier varchar(1000), + version varchar(100), + is_shared_p char(1) + check (is_shared_p in ('t','f')) + default 't', + -- A manifest could have multiple submanifests + parent_manifest_id integer +); + +-- create index for imsld_cp_organizations +create index imsld_cp_manifests_man_id_idx on imsld_cp_manifests(parent_manifest_id); + +comment on table imsld_cp_manifests is ' +This table stores all the available manifests (that could be courses) in the system.'; + +comment on column imsld_cp_manifests.identifier is ' +Manifest identifier +Identifier get from the imsmanifest.xml file. '; + +comment on column imsld_cp_manifests.parent_manifest_id is ' +Parent manifest. +A manifest could have submanifests. If the manifest doesnt have a parent +then we put 0'; + +comment on column imsld_cp_manifests.is_shared_p is ' +This field indicates if the manifest can be shared between other dotLRN classes'; + +-- Organizations +create table imsld_cp_organizations ( + organization_id integer + constraint imsld_cp_org_fk + references cr_revisions + on delete cascade + constraint imsld_cp_org_pk + primary key, + manifest_id integer + constraint imsld_cp_org_man_id_fk + references cr_items +); + +-- create index for imsld_cp_organizations +create index imsld_cp_organizations_man_id_idx on imsld_cp_organizations(manifest_id); + +-- Resources +create table imsld_cp_resources ( + resource_id integer + constraint imsld_cp_resources_fk + references cr_revisions + on delete cascade + constraint imsld_cp_resources_pk + primary key, + manifest_id integer + constraint imsld_cp_resources_man_id_fk + references cr_items + on delete cascade, + identifier varchar(100), + type varchar(1000), + href varchar(2000) +); + +-- create index for imsld_cp_resources +create index imsld_cp_resources_man_id_idx on imsld_cp_resources(manifest_id); + +-- Resource dependencies +create table imsld_cp_dependencies ( + dependency_id integer + constraint imsld_cp_dependencies_fk + references cr_revisions + on delete cascade + constraint imsld_cp_dependencies_pk + primary key, + resource_id integer + constraint imsld_cp_dependencies_res_id_fk + references cr_items, + identifierref varchar(2000) +); + +-- create index for imsld_cp_dependencies +create index imsld_cp_dependencies_res_id_idx on imsld_cp_dependencies(resource_id); + +-- Resource files +create table imsld_cp_files ( + imsld_file_id integer + constraint imsld_cp_files_fk + references cr_revisions(revision_id) + on delete cascade + constraint imsld_cp_files_pk + primary key, + resource_id integer + constraint imsld__file_res_id_fk + references cr_items, + path_to_file varchar(2000), + file_name varchar(2000), + href varchar(2000) +); + +-- create index for imsld_cp_files +create index imsld_cp_files_res_id_idx on imsld_cp_files(resource_id); + + Index: openacs-4/packages/imsld/sql/postgresql/imsld-cp-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-cp-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-cp-drop.sql 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,16 @@ +-- +-- IMS-LD Package Data Model (Content Packagin) Drop +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date jul-2005 +-- + +drop table imsld_cp_manifests cascade; + +drop table imsld_cp_organizations cascade; + +drop table imsld_cp_resources cascade; + +drop table imsld_cp_dependencies cascade; + +drop table imsld_cp_files cascade; Index: openacs-4/packages/imsld/sql/postgresql/imsld-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-create.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-create.sql 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,592 @@ +-- +-- IMS-LD Package Data Model +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date jul-2005 +-- + +create table imsld_learning_objects ( + learning_object_id integer + constraint imsld_lo_id_fk + references cr_revisions + on delete cascade + constraint imsld_lo_id_pk + primary key, + class varchar(4000), + environment_id integer + constraint imsld_lo_envid_fk + references cr_items(item_id), --imsld_environments + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + type varchar(100), + schema_version varchar(100), + parameters varchar(4000) +); + +create index imsld_learning_o_env_id_idx on imsld_learning_objects(environment_id); + +comment on table imsld_learning_objects is ' +Learning objects are incorporated (in dotLRN) by referencing resources through the item elements.'; + +comment on column imsld_learning_objects.class is ' +The class attribute refers to the value of class attributes available in learning-design or content elements.'; + +comment on column imsld_learning_objects.type is ' +The type of learning object (e.g. knowledge-object, tool-object test-object). Vocabulary used can be the one of ''learning resource type'' element from the IEEE LTSC LOM.'; + +comment on column imsld_learning_objects.schema_version is ' +Indicate the version of the schema to be used.'; + +comment on column imsld_learning_objects.is_visible_p is ' +Initial visibility attribute'; + +comment on column imsld_learning_objects.parameters is ' +Parameters to be passed during runtime.'; + +create table imsld_imslds ( + imsld_id integer + constraint imsld_id_fk + references cr_revisions + on delete cascade + constraint imsld_id_pk + primary key, + identifier varchar(100) + not null, + version varchar(10), + level char(1) + constraint imsld_level_ck + check (level in ('a','b','c')), + sequence_used_p char(1) + constraint imsld_seq_ck + check (sequence_used_p in ('t','f')) + default 'f' +); + +comment on table imsld_imslds is ' +IMS-LD main table, where the imsld general information is stored.'; + +comment on column imsld_imslds.version is ' +A version number of the document'; + +comment on column imsld_imslds.level is ' +The level of the document. It can only be A, B or C'; + +comment on column imsld_imslds.sequence_used_p is ' +If the value is true, IMS Simple Sequencing is included at the appropriate places in the document instance, default is false.'; + +create table imsld_learning_objectives ( + learning_object_id integer + constraint imsld_leo_fk + references cr_revisions + on delete cascade + constraint imsld_leo_pk + primary key, + imsld_id integer + constraint ismld_leo_imsldid_fk + references cr_items --imsld_imslds +); + +comment on table imsld_learning_objectives is ' +This table holds the learning objectives of the IMS-LD. +Technically it is just a mapping table between items and the imsld_id, but this table was created to provide simplicity and clarification in the data model'; + +create table imsld_prerequisites ( + prerequisite_id integer + constraint imsld_prereq_fk + references cr_revisions + on delete cascade + constraint imsld_prereq_pk + primary key, + imsld_id integer + constraint ismld_prereq_imsldid_fk + references cr_items --imsld_imslds +); + +comment on table imsld_prerequisites is ' +This table holds the prerequisites of the IMS-LD. +Technically it is just a mapping table between items and the imsld_id, but this table was created to provide simplicity and clarification in the data model'; + +create table imsld_items ( + imsld_item_id integer + constraint imsld_items_id_fk + references cr_revisions + on delete cascade + constraint imsld_items_id_pk + primary key, + identifier varchar(100), + identifierref varchar(100), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + parameters varchar(4000) +); + +comment on table imsld_items is ' +This table holds the imsld items of the unit of learning'; + +comment on column imsld_items.identifier is ' +Unique identifier of the item in the unit of learning'; + +comment on column imsld_items.is_visible_p is ' +Initial visibility attribute'; + +comment on column imsld_items.parameters is ' +Parameters to be passed during runtime.'; + +create table imsld_components ( + component_id integer + constraint imsld_comp_fk + references cr_revisions + on delete cascade + constraint imsld_comp_pk + primary key, + imsld_id integer + constraint imsld_comp_ldid_fk + references cr_items --imsld_imslds + not null +); + +create index imsld_comp_imsld_id_idx on imsld_components(imsld_id); + +comment on table imsld_components is ' +This table holds the components of the learning activity, which conists of activities, roles and environments. +The environments, roles and activities tables references this one since the relationship is one to many.'; + +create table imsld_roles ( + role_id integer + constraint imsld_roles_id_fk + references cr_revisions + on delete cascade + constraint imsld_roles_id_pk + primary key, + identifier varchar(100), + role_type varchar(100) + not null, + parent_role_id integer + constraint imsld_roles_proleid_fk + references cr_items, --imsld_roles + create_new_p char(1) + check (create_new_p in ('t','f')) + default 't', + match_persons_p char(1) + check (match_persons_p in ('t','f')), + max_persons integer, + min_persons integer +); + +create index imsld_roles_parent_id_idx on imsld_roles(parent_role_id); + +comment on table imsld_roles is ' +Roles of the unit of learning. Whenever possible, they are treated just like the roles in dotLRN'; + +comment on column imsld_roles.role_type is ' +Role type to know if the role is of type learner or staff'; + +comment on column imsld_roles.parent_role_id is ' +According to the IMS-LD spec, a role can have sub-roles, i.e. a role can have a parent role'; + +comment on column imsld_roles.create_new_p is ' +This attribute indicates whether multiple occurrences of this role may be created during runtime. +True means allowed and false means not-allowed'; + +comment on column imsld_roles.match_persons_p is ' +This attribute is used when there are several sub roles (e.g. chair, secretary, member). Persons can be matched exclusively to the sub roles, meaning that a person, who has the role of chair, may not be bound to one of the other roles at the same time. When it is not exclusive, persons may be bound to more than one sub role (this is the default situation). +True means exclusively-in-roles and false means not-exlusively.'; + +create table imsld_learning_activities ( + activity_id integer + constraint imsld_la_id_fk + references cr_revisions + on delete cascade + constraint imsld_la_id_pk + primary key, + identifier varchar(100), + component_id integer + constraint imsld_la_component_id_fk + references cr_items --imsld_components + not null, + parameters varchar(4000), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + user_choice_p char(1) + check (user_choice_p in ('t','f')), + time_limit_id integer + constraint imdls_la_timelid_fk + references cr_items, --imsld_time_limits + on_completion_id integer + constraint imdls_la_oncompid_fk + references cr_items --imsld_on_completion +); + +create index imsld_la_comp_id_idx on imsld_learning_activities(component_id); +create index imsld_la_timel_id_idx on imsld_learning_activities(time_limit_id); +create index imsld_la_oncomp_id_idx on imsld_learning_activities(on_completion_id); + +comment on table imsld_learning_activities is ' +This table stores the learning activitis of the component of the unit of learning.'; + +comment on column imsld_learning_activities.parameters is ' +Parameters to be passed during runtime.'; + +comment on column imsld_learning_activities.user_choice_p is ' +This element specifies that the user may decide him or herself when the activity is completed. This means that a control must be available in the user-interface to set the activity status to ''completed''. A user can do this once (no undo). Once he/she indicated the activity to be completed, then this activity stays completed in the run.'; + +comment on column imsld_learning_activities.time_limit_id is ' +The time limit specifies that it is completed when a certain amount of time has passed, relative to the start of the run of the current unit of learning. +In runtime the time limit of the play overrules the time limit on act and that one on the role-parts. +This unit is curretnly treated in seconds in dotLRN.'; + +comment on column imsld_learning_activities.on_completion_id is ' +When an activity, act, play or unit-of-learning is completed, the optional actions contained in this element are executed. In level A it contains only one element. The wrapper is available for the extensions of level B and C.'; + +create table imsld_support_activities ( + activity_id integer + constraint imsld_sa_fk + references cr_revisions + on delete cascade + constraint imsld_sa_pk + primary key, + component_id integer + constraint imsld_sa_componenid_fk + references cr_items --imsld_components + not null, + identifier varchar(100), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + parameters varchar(4000), + user_choice_p char(1) + check (user_choice_p in ('t','f')), + time_limit_id integer + constraint imdls_sa_timelid_fk + references cr_items, --imsld_time_limits + on_completion_id integer + constraint imdls_sa_oncompid_fk + references cr_items --imsld_on_completion +); + +create index imsld_sa_comp_id_idx on imsld_support_activities(component_id); +create index imsld_sa_timel_id_idx on imsld_support_activities(time_limit_id); +create index imsld_sa_oncomp_id_idx on imsld_support_activities(on_completion_id); + +comment on table imsld_support_activities is ' +This table stores the support activitis of the component of the unit of learning. +For comments on specific fields see the table imsld_learning_activities. +The talbes imsld_learning_activities and imsld_support_activities are treated separatedly +because it was too confusing using only one, because there are references to only learning activities +and to only support activities, besides, a support activity can have roles mapped to it.'; + +create table imsld_activity_structures ( + structure_id integer + constraint imsld_as_fk + references cr_revisions + on delete cascade + constraint imsld_as_pk + primary key, + component_id integer + constraint imsld_as_component_id_fk + references cr_items --imsld_components + not null, + identifier varchar(100), + number_to_select integer, + structure_type char(9) + check (structure_type in ('selection','sequence')) +); + +create index imsld_as_comp_id_idx on imsld_activity_structures(component_id); + +comment on table imsld_activity_structures is ' +The activity structures of a component determine the sets and order of activities in the unit of learning, as well as the +structure type of such sets'; + +comment on column imsld_activity_structures.number_to_select is ' +When the attribute ''number-to-select'' is set, the activity-structure is completed when the number of activities completed equals the number set. The number-to-select must be the same as or smaller than the number of activities (including unit-of-learnings) which are at the immediate child level. When the number-to-select isn''t set, the activity-structure is completed when all the activities in the structure are completed. +The field ''information'' (specified in the IMS-LD spec) is just a set of items, maped to this table trhough a mapping table.'; + +comment on column imsld_activity_structures.structure_type is ' +Indicates whether the activity-structure represents a sequence or a selection.'; + +create table imsld_environments ( + environment_id integer + constraint imsld_env_fk + references cr_revisions + on delete cascade + constraint imsld_env_pk + primary key, + component_id integer + constraint imsld_env_compid_fk + references cr_items --imsld_components + not null, + identifier varchar(100) +); + +create index imsld_envs_comp_id_idx on imsld_environments(component_id); + +comment on table imsld_environments is ' +The environments are learning objects, services or more environments that complement a given activity. +The learning objects and services are mapped to this table through those tables +and the nested environments are mapped through a mapping table.'; + +create table imsld_send_mail_services ( + mail_id integer + constraint imsld_emailserv_fk + references cr_revisions + on delete cascade + constraint imsld_emailserv_pk + primary key, + environment_id integer + constraint imsld_emailsevr_env_fk + references cr_items --imsld_environments + not null, + recipients char(11) + check (recipients in ('all-in-role','selection')), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + parameters varchar(4000) +); + +create index imsld_send_m_env_id_idx on imsld_send_mail_services(environment_id); + +comment on column imsld_send_mail_services.recipients is ' +Fixed choice: ''all-in-role'' or ''selection''. With the first choice, the user agent only allows messages to be sent to the role, indicating that all persons in the role get the message. With the second choice, the user agent allows a user to select one or more individuals within the specified role to send the message to'; + +comment on column imsld_send_mail_services.is_visible_p is ' +Initial visibility attribute'; + +create table imsld_send_mail_data ( + data_id integer + constraint imsld_semaildata_fk + references cr_revisions + on delete cascade + constraint imsld_semaildata_pk + primary key, + send_mail_id integer + constraint imsld_semaildata_smailid_fk + references cr_items --imsld_send_mail_services + not null, + role_id integer + constraint imsld_semaildata_roleid_fk + references cr_items --imsld_roles + not null, + mail_data text +); + +create index imsld_sm_data_sm_id_idx on imsld_send_mail_data(send_mail_id); +create index imsld_sm_data_role_id_idx on imsld_send_mail_data(role_id); + +create table imsld_conference_services ( + conference_id integer + constraint imsld_confs_fk + references cr_revisions + on delete cascade + constraint imsld_confs_pk + primary key, + environment_id integer + constraint imsld_confs_env_fk + references cr_items --imsld_environments + not null, + conference_type char(12) + check (conference_type in ('synchronous','asynchronous','announcement')), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + imsld_item_id integer + constraint imsld_confs_item_itemid_fk + references cr_items, --imsld_items + manager_id integer + constraint imsld_confs_manager_fk + references cr_items, --imsld_roles + moderator_id integer + constraint imsld_confs_moderator_fk + references cr_items, --imsld_roles + parameters varchar(4000) +); + +create index imsld_confs_env_id on imsld_conference_services(environment_id); +create index imsld_confs_item_id on imsld_conference_services(imsld_item_id); +create index imsld_confs_manag_id on imsld_conference_services(manager_id); +create index imsld_confs_moder_id on imsld_conference_services(moderator_id); + +comment on table imsld_conference_services is ' +Conferences in the unit of learning. The conference can be synchronous (chat), asynchronous (forum) or announcement (notice). +The conference has a manager and a moderator associate to it. Besides, there are the participants, +which are mapped to the conference through a mapping table.'; + +comment on column imsld_conference_services.imsld_item_id is ' +A node in a structure, referring to a resource.'; + +-- TO DO: INDEX SEARCH SERVICE + +create table imsld_methods ( + method_id integer + constraint imsld_methods_fk + references cr_revisions + on delete cascade + constraint imsld_methods_pk + primary key, + imsld_id integer + constraint imsld_methods_imsldid_fk + references cr_items, --imsld_imslds + time_limit_id integer + constraint imsld_methods_timel_fk + references cr_items, --imsld_time_limits + on_completion_id integer + constraint imsld_methods_oncomp_fk + references cr_items --imsld_on_completion +); + +create index imsld_methods_imsld_id_idx on imsld_methods(imsld_id); +create index imsld_methods_timel_id_idx on imsld_methods(time_limit_id); +create index imsld_methods_oncomp_id_idx on imsld_methods(on_completion_id); + +comment on table imsld_methods is ' +This table holds the methods of the unit of learning. +The methods are the ones that specifies the sequence of activities. +Theese activities are grouped with their corresponding roles and form a play, which is mapped to the method. +The method is completed when all the ''plays to complete method'' mapped to this table are completed or +when the time indicated by time_limit has been completed.'; + +create table imsld_plays ( + play_id integer + constraint imsld_plays_fk + references cr_revisions + on delete cascade + constraint imsld_plays_pk + primary key, + method_id integer + constraint imsld_plays_methodid_fk + references cr_items, --imsld_methods + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + identifier varchar(100), + when_last_act_completed_id integer + constraint imsld_plays_lastact_fk + references cr_items, --imsld_acts + time_limit_id integer + constraint imsld_plays_timelid_fk + references cr_items, --imsld_time_limits + on_completion_id integer + constraint imsld_plays_oncomp_fk + references cr_items --imsld_on_completion +); + +create index imsld_plays_meth_id_idx on imsld_plays(method_id); +create index imsld_plays_act_id_idx on imsld_plays(when_last_act_completed_id); +create index imsld_plays_timel_id_idx on imsld_plays(time_limit_id); +create index imsld_plays_oncomp_id_idx on imsld_plays(on_completion_id); + +comment on table imsld_plays is ' +This table stores the plays of the method in the unit of learning. +The play is completed when the act (in imsld_acts) referenced by ''when_last_act_completed_id'' is completed or +when the time indicated by ''time_limit_id'' has fihished. If theese two fields are empty, the play is ''ulimited.'''; + +create table imsld_acts ( + act_id integer + constraint imsld_acts_fk + references cr_revisions + on delete cascade + constraint imsld_acts_pk + primary key, + play_id integer + constraint imsld_plays_itemid_fk + references cr_items --imsld_plays + not null, + time_limit_id integer + constraint imsld_acts_timelid_fk + references cr_items, --imsld_time_limits + identifier varchar(100), + on_completion_id integer + constraint imsld_acts_oncomp_fk + references cr_items --imsld_on_completion +); + +create index imsld_acts_play_id_idx on imsld_acts(play_id); +create index imsld_acts_timel_id_idx on imsld_acts(time_limit_id); +create index imsld_acts_oncomp_id_idx on imsld_acts(on_completion_id); + +comment on table imsld_acts is ' +The mapping of activities and roles is done in the table ''imsld_role_parts''. +This table is the wrapper of the role parts of the unit of learning.'; + +create table imsld_role_parts ( + role_part_id integer + constraint imsld_rp_fk + references cr_revisions + on delete cascade + constraint imsld_rp_pk + primary key, + identifier varchar(100), + role_id integer + constraint imsld_rp_roleid_fk + references cr_items, --imsld_roles + learning_activity_id integer + constraint imsld_rp_laid_fk + references cr_items, --imsld_learning_activities + support_activity_id integer + constraint imsld_rp_said_fk + references cr_items, --imsld_support_activities + unit_of_learning_id integer + constraint imsld_rp_imslds_fk + references cr_items, --imsld_imslds + activity_structure_id integer + constraint imsld_rp_asid_fk + references cr_items, --imsld_activity_structures + environment_id integer + constraint imsld_rp_envid_fk + references cr_items --imsld_environments +); + +create index imsld_rp_role_id_idx on imsld_role_parts(role_id); +create index imsld_rp_la_id_idx on imsld_role_parts(learning_activity_id); +create index imsld_rp_sa_id_idx on imsld_role_parts(support_activity_id); +create index imsld_rp_imsld_id_idx on imsld_role_parts(unit_of_learning_id); +create index imsld_rp_as_id_idx on imsld_role_parts(activity_structure_id); +create index imsld_rp_env_id_idx on imsld_role_parts(environment_id); + +comment on table imsld_role_parts is ' +This table holds the actual mapping bewteen activities and roles. +There are also mappings between roles and environments or units of learning'; + +create table imsld_time_limits ( + time_limit_id integer + constraint imsld_time_limits_fk + references cr_revisions + on delete cascade + constraint imsld_time_limits__pk + primary key, + time_in_seconds integer + not null +); + +comment on table imsld_time_limits is ' +The time limit specifies that an activity is completed when a certain amount of time has passed, +relative to the start of the run of the current unit of learning. +This unit is curretnly treated in seconds in dotLRN. +Note: This table will be modificated when implementing level B.'; + +create table imsld_on_completion ( + on_completion_id integer + constraint imsld_oncomp_id_fk + references cr_revisions + on delete cascade + constraint imsld_oncomp_id_pk + primary key, + feedback_id integer -- a feedback is an imsld_item + constraint imsld_oncomp_feedbid_fk + references cr_items(item_id) + not null +); + +create index imsld_oncomp_feedb_id_idx on imsld_on_completion(feedback_id); + +comment on table imsld_on_completion is' +The underlying item elements point to a resource (of type webcontent or imsldcontent), where the feedback description can be found. After completion (of the component pointing to this row) this text becomes visible.'; + +comment on column imsld_on_completion.feedback_id is ' +Reference to the item that holds the feedback.'; + +\i imsld-cp-create.sql \ No newline at end of file Index: openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,48 @@ +-- +-- IMS-LD Package Data Model Drop +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date jul-2005 +-- + +drop table imsld_learning_objects cascade; + +drop table imsld_imslds cascade; + +drop table imsld_learning_objectives cascade; + +drop table imsld_prerequisites cascade; + +drop table imsld_items cascade; + +drop table imsld_components cascade; + +drop table imsld_roles cascade; + +drop table imsld_learning_activities cascade; + +drop table imsld_support_activities cascade; + +drop table imsld_activity_structures cascade; + +drop table imsld_environments cascade; + +drop table imsld_send_mail_services cascade; + +drop table imsld_send_mail_data cascade; + +drop table imsld_conference_services cascade; + +drop table imsld_methods cascade; + +drop table imsld_plays cascade; + +drop table imsld_acts cascade; + +drop table imsld_role_parts cascade; + +drop table imsld_time_limits cascade; + +drop table imsld_on_completion cascade; + +\i imsld-cp-drop.sql \ No newline at end of file Index: openacs-4/packages/imsld/tcl/apm-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/apm-callback-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/apm-callback-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,29 @@ +# /packages/imsld/tcl/apm-callback-procs.tcl + +ad_library { + Callback library for the apm + + @creation-date Jul 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: apm-callback-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} +namespace eval imsld::apm_callback {} + +ad_proc -public imsld::apm_callback::after_install { +} { + Proc calls and tasks needed to be donde after the installation of the imsld package. +} { + # initalize the cr + imsld::install::init_content_repository +} + +ad_proc -public imsld::apm_callback::before_uninstall { +} { + Proc calls and tasks needed to be donde before the uninstallation of the imsld package. +} { + # clean the cr + imsld::uninstall::empty_content_repository +} + Index: openacs-4/packages/imsld/tcl/imsld-cp-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-cp-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/imsld-cp-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,280 @@ +# /packages/imsld/tcl/imsld-cp-procs.tcl + +ad_library { + Procedures in the imsld namespace that have to do with Content Packagin. + + @creation-date Aug 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: imsld-cp-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} +namespace eval imsld::cp {} + + # IMS CP database transaction functions + +ad_proc -public imsld::cp::manifest_new { + -identifier + {-item_id ""} + {-version "null"} + {-parent_manifest_id ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + {-is_shared_p f} + -edit:boolean + -parent_id +} { + Inserts a new manifest according to the imsmanifest.xml file. + + @param identifier intrinsic manifest identifier. + @option item_id Item_id of the manifest. [db_nextval "acs_object_id_seq"] used by default. + @option version version. + @option parent_manifest_id parent manifest id (for manifest with submanifests). + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the manifest. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the manifest. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the manifest. [dt_sysdate] used by default. + @option is_shared_p Is this manifest shared? + @option edit Are we editing the manifest? + @param parent_id Identifier of the parent folder +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set prent_manifest_id [expr { [empty_string_p $parent_manifest_id] ? 0 : $parent_manifest_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + set content_type imsld_cp_manifest + set item_name "${item_id}_[string tolower $identifier]" + + ns_log notice "edit p viene $edit_p !!!!!!!!!!! y version $version" + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $identifier \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list identifier $identifier] \ + [list version $version] \ + [list parent_manifest_id $parent_manifest_id] \ + [list is_shared_p $is_shared_p]]] + + return $item_id +} + +ad_proc -public imsld::cp::organization_new { + -manifest_id + {-item_id ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + {-parent_id ""} + -edit:boolean +} { + Inserts a new organization in the database. + + @param manifest_id ID of the manifest which the organization is part of. + @option item_id Item_id of the organization. [db_nextval "acs_object_id_seq"] used by default. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the organization. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the organization. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the organization. [dt_sysdate] used by default. + @param parent_id Identifier of the parent folder + @option edit Are we editing the organization? +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + if { [empty_string_p $parent_id] } { + set parent_id [content::item::get_id -item_path "cr_manifest_${manifest_id}" -resolve_index f] + if { [empty_string_p $parent_id] } { + return -code error "IMSLD::imsld::cp::organization_new: No parent folder for organization $item_id" + } + } + + set content_type imsld_cp_organization + set item_name "${item_id}_organization" + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list manifest_id $manifest_id]]] + + return $item_id +} + +ad_proc -public imsld::cp::resource_new { + -manifest_id + -identifier + -type + {-href ""} + {-item_id ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + {-parent_id ""} + -edit:boolean +} { + Inserts a new organization in the database. + + @param manifest_id ID of the manifest which the resource is part of. + @param identifier Resource identifier in the manifest. + @param type A string that identifies the type of resource. + @option href A reference to the "entry point" of this resource. + @option item_id Item_id of the resource. [db_nextval "acs_object_id_seq"] used by default. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the resource. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the resource. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the resource. [dt_sysdate] used by default. + @param parent_id Identifier of the parent folder + @option edit Are we editing the resource? +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + if { [empty_string_p $parent_id] } { + set parent_id [content::item::get_id -item_path "cr_manifest_${manifest_id}" -resolve_index f] + if { [empty_string_p $parent_id] } { + return -code error "IMSLD::imsld::cp::resource_new: No parent folder for organization $item_id" + } + } + + set content_type imsld_cp_resource + set item_name "${item_id}_[string tolower $identifier]" + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list manifest_id $manifest_id] \ + [list identifier $identifier] \ + [list type $type] \ + [list href $href]]] + + return $item_id +} + +ad_proc -public imsld::cp::dependency_new { + -resource_id + -identifierref + {-item_id ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + {-parent_id ""} + -edit:boolean +} { + Inserts a new organization in the database. + + @param resource_id ID of the resource to which the dependency is part of. + @param identifierref Pointer to a resource identifier in the manifest. + @option item_id Item_id of the dependency. [db_nextval "acs_object_id_seq"] used by default. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the dependency. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the dependency. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the dependency. [dt_sysdate] used by default. + @param parent_id Identifier of the parent folder + @option edit Are we editing the dependency? +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + if { [empty_string_p $parent_id] } { + set manifest_id [db_string get_manifest { + select icr.manifest_id + from imsld_cp_resources icr, cr_items cri + where icr.resource_id = cri.live_revision + and cri.item_id = :resource_id + }] + set parent_id [content::item::get_id -item_path "cr_manifest_${manifest_id}" -resolve_index f] + if { [empty_string_p $parent_id] } { + return -code error "IMSLD::imsld::cp::dependency_new: No parent folder for organization $item_id" + } + } + + set content_type imsld_cp_dependency + set item_name "${item_id}_imsld_cp_dependency" + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list resource_id $resource_id] \ + [list identifierref $identifierref]]] + + return $item_id +} Index: openacs-4/packages/imsld/tcl/imsld-cr-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-cr-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/imsld-cr-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,133 @@ +# /packages/imsld/tcl/imsld-cr-procs.tcl + +ad_library { + Procedures in the imsld namespace that interact with the cr. + + @creation-date Jul 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: imsld-cr-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} +namespace eval imsld::cr {} + +ad_proc -public imsld::cr::folder_new { + -folder_name:required + {-parent_id ""} + {-folder_label ""} + {-folder_id ""} +} { + Adds the folder to the CR. Returns the folder_id + + @param folder_name Name of the folder + @option parent_id Parent ID Folder where the folder will be created + @option label Label for the folder to create + @option folder_id folder_id. Default value is [db_nextval "acs_object_id_seq"] +} { + # gets the user_id and IP + set user_id [ad_conn user_id] + set creation_ip [ad_conn peeraddr] + set folder_id [expr { [empty_string_p $folder_id] ? [db_nextval "acs_object_id_seq"] : $folder_id }] + + set folder_label [expr { [empty_string_p $folder_label] ? $folder_name : $folder_label }] + + db_transaction { + # create the folder + set folder_id [content::folder::new -folder_id $folder_id \ + -name $folder_name \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -label $folder_label] + content::folder::register_content_type -folder_id $folder_id -content_type content_revision -include_subtypes t + content::folder::register_content_type -folder_id $folder_id -content_type content_folder -include_subtypes t + content::folder::register_content_type -folder_id $folder_id -content_type content_extlink -include_subtypes t + content::folder::register_content_type -folder_id $folder_id -content_type content_simlink -include_subtypes t + permission::grant -party_id $user_id -object_id $folder_id -privilege admin + } on_error { + ad_return_error "<#_ Error creating folder #>" "<#_ There was an error creating the folder. Aborting. #>
$errmsg
" + ad_script_abort + } + return $folder_id +} + +ad_proc -public imsld::cr::file_new { + -href + -resource_id + -path_to_file + -file_name + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id + {-mime_type "text/plain"} + {-storage_type "lob"} +} { + Creates a new file in the file storage. Returns the item_id for that file. + + @param href href of the file (the path to the item in the file system) + @param resource_id resource id to which the resource belongs to + @param path_to_file path to file in the fs + @param file_name file name + @option item_id Item_id of the file. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the file. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the file. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the file. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the file. [dt_sysdate] used by default. + @option edit Are we editing the file? + @param parent_id Identifier of the parent folder +} { + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + set content_type imsld_cp_file + set item_name "${item_id}_imsld_cp_file" + set title [expr { [empty_string_p $title] ? $item_name : $title }] + + if { !$edit_p } { + # create + + # double-click protection + set file_exists_p [db_0or1row file_exists { + select 1 + from imsld_cp_files icf, cr_items cri + where cri.item_id = :item_id + and cri.live_revision = icf.imsld_file_id + and icf.resource_id = :resource_id}] + + if { !$file_exists_p } { + set item_id [content::item::new -item_id $item_id \ + -name $file_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -mime_type $mime_type \ + -storage_type $storage_type \ + -context_id $package_id] + } + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $file_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -mime_type $mime_type \ + -is_live "t" \ + -attributes [list [list resource_id $resource_id] \ + [list path_to_file $path_to_file] \ + [list file_name $file_name] \ + [list href $href]]] + + return $item_id +} Index: openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/imsld-fs-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,180 @@ +# /packages/imsld/tcl/imsld-cr-procs.tcl + +ad_library { + Procedures in the imsld namespace that interact with the cr. + + @creation-date Aug 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: imsld-fs-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} +namespace eval imsld::fs {} + +ad_proc -public imsld::fs::file_new { + {-href ""} + {-resource_id ""} + -path_to_file + {-file_name ""} + -type:required + {-parent_id ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -complete_path +} { + Creates a file (file or directory) in the fs. If the type is file, the file is created with its attributes that are: href, resource_id, file_name, path_to_file and parent_id. + + All the parent dirs (lindex 0) of the corresponding file (path_to_file) that are found in the files_struct_list are created too (if they haven't been created yet). The file structure is the one created with the imsld::parse::get_files_structure proc. + + Returns the file_id of the created file. + + @option href File href + @option resource_id Resource identifier of which the file belongs to. + @param path_to_file Path to file + @option file_name File name + @param type File or dir + @option parent_id Parent folder identifier + @option title Title of the file. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the file. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the file. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the file. [dt_sysdate] used by default. + @option edit Are we editing the file? + @param complete_path Complete path to file +} { + upvar files_struct_list files_struct_list + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + + # search the file and while doing so, create all the parent folders for that file (if they were not already creatd) + set found_p 0 + + # structx = directory loop, count_y and count_x are going to be used to update the files_structure_list + set structx $files_struct_list + set count_y 0 + while { [llength $structx] > 0 && $found_p == 0 } { + # for each directory + set dirx [lindex $structx 0] + set count_x 0 + # search in the dir contents + foreach contentsx [lindex $dirx 1] { + if { [lsearch -exact $contentsx [string tolower $complete_path]] >= 0 && [string eq [lindex $contentsx 1] $type] } { + # file found, see if the parent dir is created + set found_p 1 + set parent_id [lindex [lindex $dirx 0] 1] + if { !$parent_id } { + # the dir hasn't been created + set parent_id [imsld::fs::file_new -path_to_file [lindex [lindex $dirx 0] 0] \ + -type dir \ + -complete_path [lindex [lindex $dirx 0] 0]] + # update file structure + set dirx_parent_list [list [lindex [lindex $dirx 0] 0] $parent_id] + set dirx [list $dirx_parent_list [lindex $dirx 1]] + set files_struct_list [lreplace $files_struct_list $count_y $count_y $dirx] + } + break + } + incr count_x + } + if { !$found_p } { + # proceed only if the file hasn't been found, since we will use the counter later + incr count_y + set structx [lrange $structx 1 [expr [llength $structx] -1]] + } + } + if { $found_p } { + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + # create the file with the parent_id found + switch $type { + file { + # insert file into the CR + db_transaction { + if { [empty_string_p $file_name] } { + regexp {[^//\\]+$} $path_to_file file_name + set file_name [imsld::safe_url_name -name $file_name] + } + set mime_type [cr_filename_to_mime_type -create $file_name] + # database_p according to the file storage parameter + set fs_package_id [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id [dotlrn_community::get_community_id]] \ + -package_key "file-storage"] + set database_p [parameter::get -parameter "StoreFilesInDatabaseP" -package_id $fs_package_id] + if { !$database_p } { + set storage_type file + } else { + set storabe_tupe lob + } + set file_id [imsld::cr::file_new -file_name $file_name \ + -resource_id $resource_id \ + -path_to_file $path_to_file \ + -href $href \ + -parent_id $parent_id \ + -mime_type $mime_type \ + -storage_type $storage_type \ + -item_id $item_id \ + -user_id $user_id \ + -creation_date $creation_date \ + -package_id $package_id \ + -creation_ip $creation_ip] + + set revision_id [content::item::get_live_revision -item_id $file_id] + set content_length [file size $complete_path] + + if { !$database_p } { + # create the new item + set filename [cr_create_content_file $file_id $revision_id $complete_path] + db_dml set_file_content { + update cr_revisions + set content = :filename, + mime_type = :mime_type, + content_length = :content_length + where revision_id = :revision_id} + } else { + # create the new item + db_dml lob_content " + update cr_revisions + set lob = [set __lob_id [db_string get_lob_id "select empty_lob()"]] + where revision_id = :revision_id" -blob_files [list $complete_path] + + # Unfortunately, we can only calculate the file size after the lob is uploaded + db_dml lob_size { + update cr_revisions + set content_length = :content_length + where revision_id = :revision_id + } + } + } + # update file structure + set file_list [list $complete_path file $file_id] + set content_list [lreplace [lindex [lindex $files_struct_list $count_y] 1] $count_x $count_x $file_list] + set dir_list [list [lindex [lindex $files_struct_list $count_y] 0] $content_list] + set files_struct_list [lreplace $files_struct_list $count_y $count_y $dir_list] + } + dir { + # create dir + regexp {[^//\\]+$} $path_to_file folder_label + set folder_label [imsld::safe_url_name -name $folder_label] + set folder_name ${folder_label}_${item_id} + set file_id [imsld::cr::folder_new -folder_id $item_id \ + -parent_id $parent_id \ + -folder_name $folder_name \ + -folder_label $folder_label] + } + default { + return -code error "IMSLD::imsld::fs::file_new: Error searching file of type $type. Not valid type." + ad_script_abort + } + } + return $file_id + } else { + # no luck, the file doesn't exist + return 0 + } +} Index: openacs-4/packages/imsld/tcl/imsld-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-install-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,419 @@ +# /packages/imsld/tcl/imsld-install-procs.tcl + +ad_library { + Callback library for installing porpouses. + + @creation-date Jul 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: imsld-install-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} +namespace eval imsld::install {} +namespace eval imsld::uninstall {} + +ad_proc -public imsld::install::init_content_repository { +} { + Creates content types and attributes +} { + + ### IMS-LD + + # learning objects + content::type::new -content_type imsld_learning_object -supertype content_revision -pretty_name "<#_ Learning Object #>" -pretty_plural "<#_ Learning Objects #>" -table_name imsld_learning_objects -id_column learning_object_id + + content::type::attribute::new -content_type imsld_learning_object -attribute_name class -datatype string -pretty_name "<#_ Class #>" -column_spec "varchar(4000)" + content::type::attribute::new -content_type imsld_learning_object -attribute_name environment_id -datatype number -pretty_name "<#_ Environment #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_object -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_learning_object -attribute_name type -datatype string -pretty_name "<#_ Type #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_learning_object -attribute_name schema_version -datatype string -pretty_name "<#_ Schema Version #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_learning_object -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # imsld + content::type::new -content_type imsld_imsld -supertype content_revision -pretty_name "<#_ IMS-LD #>" -pretty_plural "<#_ IMS-LDs #>" -table_name imsld_imslds -id_column imsld_id + + content::type::attribute::new -content_type imsld_imsld -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_imsld -attribute_name version -datatype string -pretty_name "<#_ Version #>" -column_spec "varchar(10)" + content::type::attribute::new -content_type imsld_imsld -attribute_name level -datatype string -pretty_name "<#_ Level #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_imsld -attribute_name sequence_used_p -datatype string -pretty_name "<#_ Sequence Used #>" -column_spec "char(1)" + + # learning objectives + content::type::new -content_type imsld_learning_objective -supertype content_revision -pretty_name "<#_ IMS-LD Learning Objective #>" -pretty_plural "<#_ IMS-LD Learning Objectives #>" -table_name imsld_learning_objectives -id_column learning_object_id + + content::type::attribute::new -content_type imsld_learning_objective -attribute_name imsld_id -datatype number -pretty_name "<#_ IMS-LD Identifier #>" -column_spec "integer" + + # imsld prerequisites + content::type::new -content_type imsld_prerequisite -supertype content_revision -pretty_name "<#_ IMS-LD Prerequisite #>" -pretty_plural "<#_ IMS-LD Prerequisites #>" -table_name imsld_prerequisites -id_column prerequisite_id + + content::type::attribute::new -content_type imsld_prerequisite -attribute_name imsld_id -datatype number -pretty_name "<#_ IMS-LD Identifier #>" -column_spec "integer" + + # imsld items + content::type::new -content_type imsld_item -supertype content_revision -pretty_name "<#_ IMS-LD Item #>" -pretty_plural "<#_ IMS-LD Items #>" -table_name imsld_items -id_column imsld_item_id + + content::type::attribute::new -content_type imsld_item -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_item -attribute_name identifierref -datatype string -pretty_name "<#_ Identifier Reference #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_item -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_item -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # components + content::type::new -content_type imsld_component -supertype content_revision -pretty_name "<#_ IMS-LD Component #>" -pretty_plural "<#_ IMS-LD Components #>" -table_name imsld_components -id_column component_id + + content::type::attribute::new -content_type imsld_component -attribute_name imsld_id -datatype number -pretty_name "<#_ IMS-LD Identifier #>" -column_spec "integer" + + # imsld roles + content::type::new -content_type imsld_role -supertype content_revision -pretty_name "<#_ IMS-LD Role #>" -pretty_plural "<#_ IMS-LD Roles #>" -table_name imsld_roles -id_column role_id + + content::type::attribute::new -content_type imsld_role -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_role -attribute_name role_type -datatype string -pretty_name "<#_ Role Type #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_role -attribute_name parent_role_id -datatype number -pretty_name "<#_ Parent Role Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role -attribute_name create_new_p -datatype string -pretty_name "<#_ Create New? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_role -attribute_name match_persons_p -datatype string -pretty_name "<#_ Match Persons? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_role -attribute_name max_persons -datatype number -pretty_name "<#_ Max Persons #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role -attribute_name min_persons -datatype number -pretty_name "<#_ Min Persons#>" -column_spec "integer" + + # learning activities + content::type::new -content_type imsld_learning_activity -supertype content_revision -pretty_name "<#_ IMS-LD Learning Activity #>" -pretty_plural "<#_ IMS-LD Learning Activities #>" -table_name imsld_learning_activities -id_column activity_id + + content::type::attribute::new -content_type imsld_learning_activity -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name component_id -datatype number -pretty_name "<#_ Component Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name parameter_id -datatype number -pretty_name "<#_ Parameter Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name user_choice_p -datatype string -pretty_name "<#_ User Choice? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name time_limit_id -datatype number -pretty_name "<#_ Time Limit Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name on_completion_id -datatype number -pretty_name "<#_ On Completion Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # support activities + content::type::new -content_type imsld_support_activity -supertype content_revision -pretty_name "<#_ IMS-LD Support Activity #>" -pretty_plural "<#_ IMS-LD Support Activities #>" -table_name imsld_support_activities -id_column activity_id + + content::type::attribute::new -content_type imsld_support_activity -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_support_activity -attribute_name component_id -datatype number -pretty_name "<#_ Component Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_support_activity -attribute_name parameter_id -datatype number -pretty_name "<#_ Parameter Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_support_activity -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_support_activity -attribute_name user_choice_p -datatype string -pretty_name "<#_ User Choice? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_support_activity -attribute_name time_limit_id -datatype number -pretty_name "<#_ Time Limit Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_support_activity -attribute_name on_completion_id -datatype number -pretty_name "<#_ On Completion Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_support_activity -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # activity structures + content::type::new -content_type imsld_activity_structure -supertype content_revision -pretty_name "<#_ IMS-LD Activity Structure #>" -pretty_plural "<#_ IMS-LD Activity Structures #>" -table_name imsld_activity_structures -id_column structure_id + + content::type::attribute::new -content_type imsld_activity_structure -attribute_name component_id -datatype number -pretty_name "<#_Component Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_activity_structure -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_activity_structure -attribute_name number_to_select -datatype number -pretty_name "<#_ Number to Select #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_activity_structure -attribute_name structure_type -datatype string -pretty_name "<#_ Structure Type #>" -column_spec "char(9)" + + # environments + content::type::new -content_type imsld_environment -supertype content_revision -pretty_name "<#_ IMD-LD Environment #>" -pretty_plural "<#_ IMD-LD Environments #>" -table_name imsld_environments -id_column environment_id + + content::type::attribute::new -content_type imsld_environment -attribute_name component_id -datatype number -pretty_name "<#_ Component Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_environment -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + + # send mail services + content::type::new -content_type imsld_send_mail_service -supertype content_revision -pretty_name "<#_ IMS-LD Sendmail Service #>" -pretty_plural "<#_ IMS-LD Sendmail Services #>" -table_name imsld_send_mail_services -id_column mail_id + + content::type::attribute::new -content_type imsld_send_mail_service -attribute_name environment_id -datatype number -pretty_name "<#_ Environment Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_send_mail_service -attribute_name recipients -datatype string -pretty_name "<#_ Recipients #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_send_mail_service -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_send_mail_service -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # send mail data + content::type::new -content_type imsld_send_mail_data -supertype content_revision -pretty_name "<#_ IMS-LD Sendmail Data #>" -pretty_plural "<#_ IMS-LD Sendmail Data #>" -table_name imsld_send_mail_data -id_column data_id + + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name send_mail_id -datatype number -pretty_name "<#_ Sendmail Identifier #>" -column_spec "itneger" + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name role_id -datatype number -pretty_name "<#_ Role Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name mail_data -datatype string -pretty_name "<#_ Mail Data #>" -column_spec "varchar(4000)" + + # conference services + content::type::new -content_type imsld_conference_service -supertype content_revision -pretty_name "<#_ IMS-LD Conference Service #>" -pretty_plural "<#_ IMS-LD Conference Services #>" -table_name imsld_conference_services -id_column conference_id + + content::type::attribute::new -content_type imsld_conference_service -attribute_name environment_id -datatype number -pretty_name "<#_ Environment Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_conference_service -attribute_name conference_type -datatype string -pretty_name "<#_ Conference Type #>" -column_spec "char(12)" + content::type::attribute::new -content_type imsld_conference_service -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_conference_service -attribute_name imsld_item_id -datatype number -pretty_name "<#_ Item Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_conference_service -attribute_name manager_id -datatype number -pretty_name "<#_ Manager Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_conference_service -attribute_name moderator_id -datatype number -pretty_name "<#_ Moderator Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_conference_service -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + + # methods + content::type::new -content_type imsld_method -supertype content_revision -pretty_name "<#_ IMS-LD Method #>" -pretty_plural "<#_ IMS-LD Methods #>" -table_name imsld_methods -id_column method_id + + content::type::attribute::new -content_type imsld_method -attribute_name imsld_id -datatype number -pretty_name "<#_ IMS-LD Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_method -attribute_name time_limit_id -datatype number -pretty_name "<#_ Time Limit Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_method -attribute_name on_completion_id -datatype number -pretty_name "<#_ On Completion Identifier #>" -column_spec "integer" + + # plays + content::type::new -content_type imsld_play -supertype content_revision -pretty_name "<#_ IMS-LD Play #>" -pretty_plural "<#_ IMS-LD Plays #>" -table_name imsld_plays -id_column play_id + + content::type::attribute::new -content_type imsld_play -attribute_name method_id -datatype number -pretty_name "<#_ Method Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_play -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_play -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_play -attribute_name when_last_act_completed_id -datatype number -pretty_name "<#_ When Last Act Completed Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_play -attribute_name time_limit_id -datatype number -pretty_name "<#_ Time Limit Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_play -attribute_name on_completion_id -datatype number -pretty_name "<#_ On Completion Identifier #>" -column_spec "integer" + + # acts + content::type::new -content_type imsld_act -supertype content_revision -pretty_name "<#_ IMS-LD Act #>" -pretty_plural "<#_ IMS-LD Acts #>" -table_name imsld_acts -id_column act_id + + content::type::attribute::new -content_type imsld_act -attribute_name play_id -datatype number -pretty_name "<#_ Play Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_act -attribute_name time_limit_id -datatype number -pretty_name "<#_ Time Limit Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_act -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_act -attribute_name on_completion_id -datatype number -pretty_name "<#_ On Completion Identifier #>" -column_spec "integer" + + # role parts + content::type::new -content_type imsld_role_part -supertype content_revision -pretty_name "<#_ IMS-LD Role Part #>" -pretty_plural "<#_ IMS-LD Role Parts #>" -table_name imsld_role_parts -id_column role_part_id + + content::type::attribute::new -content_type imsld_role_part -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_role_part -attribute_name role_id -datatype number -pretty_name "<#_ Role Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role_part -attribute_name learning_activity_id -datatype number -pretty_name "<#_ Learning Activity Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role_part -attribute_name support_activity_id -datatype number -pretty_name "<#_ Support Activity Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role_part -attribute_name unit_of_learning_id -datatype number -pretty_name "<#_ IMS-LD Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role_part -attribute_name activity_structure_id -datatype number -pretty_name "<#_ Activity Structure Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_role_part -attribute_name environment_id -datatype number -pretty_name "<#_ Environment Identifier #>" -column_spec "integer" + + # parameters + content::type::new -content_type imsld_parameter -supertype content_revision -pretty_name "<#_ IMS-LD Parameter #>" -pretty_plural "<#_ IMS-LD Parameters #>" -table_name imsld_parameters -id_column parameter_id + + content::type::attribute::new -content_type imsld_parameter -attribute_name value -datatype string -pretty_name "<#_ Value #>" -column_spec "varchar(4000)" + + + # time limits + content::type::new -content_type imsld_time_limit -supertype content_revision -pretty_name "<#_ IMS-LD Time Limit #>" -pretty_plural "<#_ IMS-LD Time Limits #>" -table_name imsld_time_limits -id_column time_limit_id + + content::type::attribute::new -content_type imsld_time_limit -attribute_name time_in_seconds -datatype number -pretty_name "<#_ Time in Seconds #>" -column_spec "integer" + + # on completion + content::type::new -content_type imsld_on_completion -supertype content_revision -pretty_name "<#_ IMS-LD On Completion #>" -pretty_plural "<#_ IMS-LD On Completions #>" -table_name imsld_on_completion -id_column on_completion_id + + content::type::attribute::new -content_type imsld_on_completion -attribute_name feedback_id -datatype number -pretty_name "<#_ Feedbach Identifier #>" -column_spec "integer" + + ### IMS-LD Content Packagin + + # manifests + content::type::new -content_type imsld_cp_manifest -supertype content_revision -pretty_name "<#_ IMS-LD CP Manifest #>" -pretty_plural "<#_ IMS-LD CP Manifests #>" -table_name imsld_cp_manifests -id_column manifest_id + + content::type::attribute::new -content_type imsld_cp_manifest -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(1000)" + content::type::attribute::new -content_type imsld_cp_manifest -attribute_name version -datatype string -pretty_name "<#_ Version #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_cp_manifest -attribute_name parent_manifest_id -datatype number -pretty_name "<#_ Parent Manifest Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_cp_manifest -attribute_name is_shared_p -datatype string -pretty_name "<#_ Is shared? #>" -column_spec "char(1)" + + # organizations + content::type::new -content_type imsld_cp_organization -supertype content_revision -pretty_name "<#_ IMS-LD CP Organization #>" -pretty_plural "<#_ IMS-LD CP Organizations #>" -table_name imsld_cp_organizations -id_column organization_id + + content::type::attribute::new -content_type imsld_cp_organization -attribute_name manifest_id -datatype number -pretty_name "<#_ Manifest Identifier #>" -column_spec "integer" + + # resources + content::type::new -content_type imsld_cp_resource -supertype content_revision -pretty_name "<#_ IMS-LD CP Resource #>" -pretty_plural "<#_ IMS-LD CP Resources #>" -table_name imsld_cp_resources -id_column resource_id + + content::type::attribute::new -content_type imsld_cp_resource -attribute_name manifest_id -datatype number -pretty_name "<#_ Manifest Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_cp_resource -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_cp_resource -attribute_name type -datatype string -pretty_name "<#_ Type #>" -column_spec "varchar(1000)" + content::type::attribute::new -content_type imsld_cp_resource -attribute_name href -datatype string -pretty_name "<#_ Href #>" -column_spec "varchar(2000)" + + # dependencies + content::type::new -content_type imsld_cp_dependency -supertype content_revision -pretty_name "<#_ IMS-LD CP Dependency #>" -pretty_plural "<#_ IMS-LD CP Dependencies #>" -table_name imsld_cp_dependencies -id_column dependency_id + + content::type::attribute::new -content_type imsld_cp_dependency -attribute_name resource_id -datatype number -pretty_name "<#_ Resource Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_cp_dependency -attribute_name identifierref -datatype string -pretty_name "<#_ Identifierref #>" -column_spec "varchar(100)" + + # imsld cp files + content::type::new -content_type imsld_cp_file -supertype content_revision -pretty_name "<#_ IMS-LD CP File #>" -pretty_plural "<#_ IMS-LD CP Filed #>" -table_name imsld_cp_files -id_column imsld_file_id + + content::type::attribute::new -content_type imsld_cp_file -attribute_name resource_id -datatype number -pretty_name "<#_ Resource Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_cp_file -attribute_name path_to_file -datatype string -pretty_name "<#_ Path to File #>" -column_spec "varchar(2000)" + content::type::attribute::new -content_type imsld_cp_file -attribute_name file_name -datatype string -pretty_name "<#_ File name #>" -column_spec "varchar(2000)" + content::type::attribute::new -content_type imsld_cp_file -attribute_name href -datatype string -pretty_name "<#_ Href #>" -column_spec "varchar(2000)" +} + +ad_proc -public imsld::uninstall::empty_content_repository { +} { + Deletes content types and attributes +} { + + ### Attributes + ### IMS-LD + + # learning objects + content::type::attribute::delete -content_type imsld_learning_object -attribute_name class + content::type::attribute::delete -content_type imsld_learning_object -attribute_name environment_id + content::type::attribute::delete -content_type imsld_learning_object -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_learning_object -attribute_name type + content::type::attribute::delete -content_type imsld_learning_object -attribute_name schema_version + content::type::attribute::delete -content_type imsld_learning_object -attribute_name parameters + + # imsld + content::type::attribute::delete -content_type imsld_imsld -attribute_name identifier + content::type::attribute::delete -content_type imsld_imsld -attribute_name version + content::type::attribute::delete -content_type imsld_imsld -attribute_name level + content::type::attribute::delete -content_type imsld_imsld -attribute_name sequence_used_p + + # learning objectives + content::type::attribute::delete -content_type imsld_learning_objective -attribute_name imsld_id + + # imsld prerequisites + content::type::attribute::delete -content_type imsld_prerequisite -attribute_name imsld_id + + # imsld items + content::type::attribute::delete -content_type imsld_item -attribute_name identifier + content::type::attribute::delete -content_type imsld_item -attribute_name identifierref + content::type::attribute::delete -content_type imsld_item -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_item -attribute_name parameters + + # componets + content::type::attribute::delete -content_type imsld_component -attribute_name imsld_id + + # imsld roles + content::type::attribute::delete -content_type imsld_role -attribute_name identifier + content::type::attribute::delete -content_type imsld_role -attribute_name role_type + content::type::attribute::delete -content_type imsld_role -attribute_name parent_role_id + content::type::attribute::delete -content_type imsld_role -attribute_name create_new_p + content::type::attribute::delete -content_type imsld_role -attribute_name match_persons_p + content::type::attribute::delete -content_type imsld_role -attribute_name max_persons + content::type::attribute::delete -content_type imsld_role -attribute_name min_persons + + # learning activities + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name identifier + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name component_id + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name parameter_id + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name user_choice_p + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name time_limit_id + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name on_completion_id + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name parameters + + # support activities + content::type::attribute::delete -content_type imsld_support_activity -attribute_name identifier + content::type::attribute::delete -content_type imsld_support_activity -attribute_name component_id + content::type::attribute::delete -content_type imsld_support_activity -attribute_name parameter_id + content::type::attribute::delete -content_type imsld_support_activity -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_support_activity -attribute_name user_choice_p + content::type::attribute::delete -content_type imsld_support_activity -attribute_name time_limit_id + content::type::attribute::delete -content_type imsld_support_activity -attribute_name on_completion_id + content::type::attribute::delete -content_type imsld_support_activity -attribute_name parameters + + # activity structures + content::type::attribute::delete -content_type imsld_activity_structure -attribute_name component_id + content::type::attribute::delete -content_type imsld_activity_structure -attribute_name identifier + content::type::attribute::delete -content_type imsld_activity_structure -attribute_name number_to_select + content::type::attribute::delete -content_type imsld_activity_structure -attribute_name structure_type + + # environments + content::type::attribute::delete -content_type imsld_environment -attribute_name component_id + content::type::attribute::delete -content_type imsld_environment -attribute_name identifier + + # send mail service + content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name environment_id + content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name recipients + content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name parameters + + # send mail data + content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name send_mail_id + content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name role_id + content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name mail_data + + # conference service + content::type::attribute::delete -content_type imsld_conference_service -attribute_name environment_id + content::type::attribute::delete -content_type imsld_conference_service -attribute_name conference_type + content::type::attribute::delete -content_type imsld_conference_service -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_conference_service -attribute_name imsld_item_id + content::type::attribute::delete -content_type imsld_conference_service -attribute_name manager_id + content::type::attribute::delete -content_type imsld_conference_service -attribute_name moderator_id + content::type::attribute::delete -content_type imsld_conference_service -attribute_name parameters + + # methods + content::type::attribute::delete -content_type imsld_method -attribute_name imsld_id + content::type::attribute::delete -content_type imsld_method -attribute_name time_limit_id + content::type::attribute::delete -content_type imsld_method -attribute_name on_completion_id + + # plays + content::type::attribute::delete -content_type imsld_play -attribute_name method_id + content::type::attribute::delete -content_type imsld_play -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_play -attribute_name identifier + content::type::attribute::delete -content_type imsld_play -attribute_name when_last_act_completed_id + content::type::attribute::delete -content_type imsld_play -attribute_name time_limit_id + content::type::attribute::delete -content_type imsld_play -attribute_name on_completion_id + + # acts + content::type::attribute::delete -content_type imsld_act -attribute_name play_id + content::type::attribute::delete -content_type imsld_act -attribute_name time_limit_id + content::type::attribute::delete -content_type imsld_act -attribute_name identifier + content::type::attribute::delete -content_type imsld_act -attribute_name on_completion_id + + # role parts + content::type::attribute::delete -content_type imsld_role_part -attribute_name identifier + content::type::attribute::delete -content_type imsld_role_part -attribute_name role_id + content::type::attribute::delete -content_type imsld_role_part -attribute_name learning_activity_id + content::type::attribute::delete -content_type imsld_role_part -attribute_name support_activity_id + content::type::attribute::delete -content_type imsld_role_part -attribute_name unit_of_learning_id + content::type::attribute::delete -content_type imsld_role_part -attribute_name activity_structure_id + content::type::attribute::delete -content_type imsld_role_part -attribute_name environment_id + + # parameters + content::type::attribute::delete -content_type imsld_parameter -attribute_name value + + # time limits + content::type::attribute::delete -content_type imsld_time_limit -attribute_name time_in_seconds + + # on completion + content::type::attribute::delete -content_type imsld_on_completion -attribute_name feedback_id + + ### IMS-LD Content Packagin + + # manifests + content::type::attribute::delete -content_type imsld_cp_manifest -attribute_name identifier + content::type::attribute::delete -content_type imsld_cp_manifest -attribute_name version + content::type::attribute::delete -content_type imsld_cp_manifest -attribute_name parent_manifest_id + content::type::attribute::delete -content_type imsld_cp_manifest -attribute_name is_shared_p + + # organizations + content::type::attribute::delete -content_type imsld_cp_organization -attribute_name manifest_id + + # resources + content::type::attribute::delete -content_type imsld_cp_resource -attribute_name manifest_id + content::type::attribute::delete -content_type imsld_cp_resource -attribute_name identifier + content::type::attribute::delete -content_type imsld_cp_resource -attribute_name type + content::type::attribute::delete -content_type imsld_cp_resource -attribute_name href + + # dependencies + content::type::attribute::delete -content_type imsld_cp_dependency -attribute_name resource_id + content::type::attribute::delete -content_type imsld_cp_dependency -attribute_name identifierref + + # imsld cp files + content::type::attribute::delete -content_type imsld_cp_file -attribute_name resource_id + content::type::attribute::delete -content_type imsld_cp_file -attribute_name path_to_file + content::type::attribute::delete -content_type imsld_cp_file -attribute_name file_name + content::type::attribute::delete -content_type imsld_cp_file -attribute_name href + + ### Content Types + ### IMS-LD + content::type::delete -content_type imsld_learning_object -drop_table_p t + content::type::delete -content_type imsld_imsld -drop_table_p t + content::type::delete -content_type imsld_learning_objective -drop_table_p t + content::type::delete -content_type imsld_prerequisite -drop_table_p t + content::type::delete -content_type imsld_item -drop_table_p t + content::type::delete -content_type imsld_component -drop_table_p t + content::type::delete -content_type imsld_role -drop_table_p t + content::type::delete -content_type imsld_learning_activity -drop_table_p t + content::type::delete -content_type imsld_support_activity -drop_table_p t + content::type::delete -content_type imsld_activity_structure -drop_table_p t + content::type::delete -content_type imsld_environment -drop_table_p t + content::type::delete -content_type imsld_send_mail_service -drop_table_p t + content::type::delete -content_type imsld_send_mail_data -drop_table_p t + content::type::delete -content_type imsld_conference_service -drop_table_p t + content::type::delete -content_type imsld_method -drop_table_p t + content::type::delete -content_type imsld_play -drop_table_p t + content::type::delete -content_type imsld_act -drop_table_p t + content::type::delete -content_type imsld_role_part -drop_table_p t + content::type::delete -content_type imsld_parameter -drop_table_p t + content::type::delete -content_type imsld_time_limit -drop_table_p t + content::type::delete -content_type imsld_on_completion -drop_table_p t + + ### IMS-LD Content Packagin + content::type::delete -content_type imsld_cp_manifest -drop_table_p t + content::type::delete -content_type imsld_cp_organization -drop_table_p t + content::type::delete -content_type imsld_cp_resource -drop_table_p t + content::type::delete -content_type imsld_cp_dependency -drop_table_p t + content::type::delete -content_type imsld_cp_file -drop_table_p t +} + Index: openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 5 Aug 2005 15:25:33 -0000 1.2 @@ -45,7 +45,7 @@ set man_attribute [$tree hasAttribute xmlns:imsld] # Check manifest organizations - set organizations [$tree child all organizations] + set organizations [$tree child all imscp:organizations] if { [llength $organizations] == 1 } { @@ -95,15 +95,15 @@ set upload_file [string trim [string tolower $upload_file]] - if {[regexp {(.tar.gz|.tgz)$} $upload_file]} { + if { [regexp {(.tar.gz|.tgz)$} $upload_file] } { set type tgz - } elseif {[regexp {.tar.z$} $upload_file]} { + } elseif { [regexp {.tar.z$} $upload_file] } { set type tgZ - } elseif {[regexp {.tar$} $upload_file]} { + } elseif { [regexp {.tar$} $upload_file] } { set type tar - } elseif {[regexp {(.tar.bz2|.tbz2)$} $upload_file]} { + } elseif { [regexp {(.tar.bz2|.tbz2)$} $upload_file] } { set type tbz2 - } elseif {[regexp {.zip$} $upload_file]} { + } elseif { [regexp {.zip$} $upload_file] } { set type zip } else { set type "<#_ Uknown type #>" @@ -159,52 +159,67 @@ } ad_proc -public imsld::parse::get_title { - -tree + -node + {-prefix ""} } { - Gets the title of the given doc. If the title is not found (because it's optional), the identifier (which is mandatory) is returned. + Returns the tile of the given node or empty string if not found. - @param doc XML document to analyze. + @param node Node + @option prefix Prefix for the "title" + } { - set title_list [$tree child all title] - if { [llength $title_list] } { - return [imsld::parse::get_element -tree $title_list]] + set prefix [expr { [empty_string_p $prefix] ? "" : "${prefix}:" }] + set titles_list [$node child all ${prefix}title] + if { [llength $titles_list] } { + imsld::parse::validate_multiplicity -tree $titles_list -multiplicity 1 -element_name title -equal + return [imsld::parse::get_element_text -node $titles_list] } else { - return [imsld::parse::get_attribute -tree $tree -attr_name identifier] + return "" } } -ad_proc -public imsld::parse::get_element { - -tree - {-attr_name ""} +ad_proc -public imsld::parse::get_element_text { + -node } { + Returns the text of the given node + + @param node Node + +} { + return [$node text] +} + +ad_proc -public imsld::parse::get_attribute { + -node + -attr_name +} { Taken from the one with the same name in the LORS package. - Datatype Element extractor + Gets attributes for an specific element. Returns the attribute value if found, emtpy string otherwise - @param tree Node - @param att Attribute - + @param node Node + @param attr_name Attribute we want to fetch } { - if { ![empty_string_p $attr_name] } { - return [list "{[$tree text]} {[imsld::parse::get_attribute -tree $tree -attr_name $attr_name]}"] + if { [$node hasAttribute $attr_name] == 1 } { + $node getAttribute $attr_name } else { - return [list [$tree text]] + return "" } } -ad_proc -public imsld::parse::get_attribute { +ad_proc -public imsld::parse::get_bool_attribute { -tree -attr_name + -default } { - Taken from the one with the same name in the LORS package. - Gets attributes for an specific element. Returns the attribute value if fond, emtpy string otherwise + Gets a boolean attribute for an specific element. Returns the tcl true or false value attribute value if found, -default otherwise. @param tree Document @param attr_name Attribute we want to fetch } { if { [$tree hasAttribute $attr_name] == 1 } { - $tree getAttribute $attr_name + return [imsld::parse::sql_boolean -bool [$tree getAttribute $attr_name]] } else { - return "" + return $default } } @@ -271,10 +286,10 @@ return 1 } -ad_proc -public imsld::parse::tcl_boolean { +ad_proc -public imsld::parse::sql_boolean { -bool:required } { - Convets a boolean string to its corresponding boolean value 0 or 1. + Convets a boolean string to its corresponding boolean value f or t. @param bool The boolean value to convert } { @@ -287,65 +302,427 @@ n - no - false { - set result 0 + set result f } 1 - t - y - yes - true { - set result 1 + set result t } default { set result 0 - ns_log error "Invalid option in imsld::parse::tcl_boolean - $bool" + ns_log error "Invalid option in imsld::parse::sql_boolean - $bool" } } return $result } -ad_proc -public imsld::parse::parse_and_create_imsld { +ad_proc -public imsld::parse::get_folder_contents { + -dir:required + -type:required +} { + Checks if the fs_dir has files or directories, nd returns the list of them in a list. + + @param dir File System directory + @param type file or directory. If type is file it returns the list of files in the dir. If type is directory it returns the list of directories in the dir. +} { + set return_list [list] + foreach f [glob -no complain [file join $dir * ]] { + if { [string eq $type [file type $f]] } { + lappend return_list $f + } + } + return $return_list +} + +ad_proc -public imsld::parse::get_files_structure { + -tmp_dir:required +} { + Returns a list of lists with the structure of the files that are being parsed which is used to find the files and subdirs in the parsing process. + + @param tmp_dir The dir where the files where uncompressed to. +} { + if { [file exists $tmp_dir] } { + set files_structure [list] + + # get all the directories and files under those dirs + # dirx = directory loop + set dirx [list $tmp_dir] + + # for each directory found.. + while { [llength $dirx] != 0 } { + set dir [lindex $dirx 0] + set dir_content [list] + + foreach subdirx [imsld::parse::get_folder_contents -dir $dir -type directory] { + lappend dir_content [list [string tolower "$subdirx"] dir] + lappend dirx $subdirx + } + foreach filex [imsld::parse::get_folder_contents -dir $dir -type file] { + lappend dir_content [list [string tolower "$filex"] file 0] + } + lappend files_structure [list [list [string tolower $dir] 0] $dir_content] + set dirx [lrange $dirx 1 [expr [llength $dirx] -1]] + } + return $files_structure + } +} + +ad_proc -public imsld::parse::initialize_folders { + -community_id:required + -manifest_id:required + {-manifest_identifier ""} +} { + Initializes the cr folders where all the cr items of the manifest will be stored in, and sets the respective permissions. There are two folders for each imsld. One to store the files and show them in the fs, and the other to store the items.. + It won't create the files in the cr since not every file will be handled by the cr (some files may be handled by other packages). + + Returns a list of two elements, the firs one is the folder_id in the fs of the root folder for that manifest, and the ohter one is the folder_id where the cr items and revisions are stored. + + @param community_id The community_id that owns the folder. + @option manifest_identifier The identifier of the manifest that is being parsed uset to create the label of the fs folder. + @param manifest_id Id of the manifest being parsed. +} { + if { ![empty_string_p $manifest_identifier] } { + set folder_label $manifest_identifier + # gets rid of the path and leaves the name of the directory + regexp { ([^/\\]+)$ } $folder_label match folder_label + # strips out spaces from the name + regsub -all { +} $folder_label {_} folder_label + } else { + set folder_label "IMS-Learning-Design-Folder" + } + + # Gets file-storage root folder_id + set fs_package_id [site_node_apm_integration::get_child_package_id \ + -package_id [dotlrn_community::get_package_id $community_id] \ + -package_key "file-storage"] + + set root_folder_id [fs::get_root_folder -package_id $fs_package_id] + + + set fs_folder_id [content::item::get_id -item_path "manifest_${manifest_id}" -root_folder_id $root_folder_id -resolve_index f] + set cr_folder_id [content::item::get_id -item_path "cr_manifest_${manifest_id}" -resolve_index f] + + if { [empty_string_p $fs_folder_id] } { + db_transaction { + set folder_name "manifest_${manifest_id}" + + # checks for write permission on the parent folder + ad_require_permission $root_folder_id write + + # create the root cr dir + set fs_folder_id [imsld::cr::folder_new -parent_id $root_folder_id -folder_name $folder_name -folder_label $folder_label] + + # PERMISSIONS FOR FILE-STORAGE + + # Before we go about anything else, lets just set permissions straight. + # Disable folder permissions inheritance + permission::toggle_inherit -object_id $fs_folder_id + + # Set read permissions for community/class dotlrn_member_rel + set party_id_member [dotlrn_community::get_rel_segment_id -community_id $community_id -rel_type dotlrn_member_rel] + permission::grant -party_id $party_id_member -object_id $fs_folder_id -privilege read + + # Set read permissions for community/class dotlrn_admin_rel + set party_id_admin [dotlrn_community::get_rel_segment_id -community_id $community_id -rel_type dotlrn_admin_rel] + permission::grant -party_id $party_id_admin -object_id $fs_folder_id -privilege read + + # Set read permissions for *all* other professors within .LRN + # (so they can see the content) + set party_id_professor [dotlrn::user::type::get_segment_id -type professor] + permission::grant -party_id $party_id_professor -object_id $fs_folder_id -privilege read + + # Set read permissions for *all* other admins within .LRN + # (so they can see the content) + set party_id_admins [dotlrn::user::type::get_segment_id -type admin] + permission::grant -party_id $party_id_admins -object_id $fs_folder_id -privilege read + } + # register content types + content::folder::register_content_type -folder_id $fs_folder_id \ + -content_type imsld_cp_file + + # allow subfolders inside our parent test folder + content::folder::register_content_type -folder_id $fs_folder_id \ + -content_type content_folder + } + + if { [empty_string_p $cr_folder_id] } { + set folder_label "cr_${folder_label}" + set folder_name "cr_manifest_${manifest_id}" + # create the cr dir + set cr_folder_id [imsld::cr::folder_new -folder_name $folder_name -folder_label $folder_label] + + # register content types + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_learning_object + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_imsld + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_learning_objective + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_prerequisite + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_item + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_component + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_role + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_learning_activity + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_support_activity + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_activity_structure + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_environment + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_send_mail_service + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_send_mail_data + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_conference_service + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_method + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_play + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_act + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_role_part + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_parameter + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_time_limit + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_on_completion + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_cp_manifest + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_cp_organization + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_cp_resource + content::folder::register_content_type -folder_id $cr_folder_id -content_type imsld_cp_dependency + } + + return [list $fs_folder_id $cr_folder_id] +} + +ad_proc -public imsld::parse::parse_and_create_resource { + -manifest + -manifest_id + -resource_node + -parent_id + -tmp_dir +} { + Parses an IMS-LD resource and stores all the information in the database, such as files, dependencies, etc + + Returns a list with the new resource_id created if there were no errors, or 0 and an error explanation. + + @param manifest Manifest tree + @param manifestid Manifest ID or the manifest being parsed + @param resource_node Resource tree being parsed + @param parent_id Parent folder ID + @tmp_dir Temporary directory where the files were exctracted +} { + upvar files_struct_list files_struct_list + # now we proceed to get all the info of the resource + set resource_type [imsld::parse::get_attribute -node $resource_node -attr_name type] + set resource_href [imsld::parse::get_attribute -node $resource_node -attr_name href] + set resource_identifier [imsld::parse::get_attribute -node $resource_node -attr_name identifier] + set resource_id [imsld::cp::resource_new -manifest_id $manifest_id \ + -identifier $resource_identifier \ + -type $resource_type \ + -href $resource_href \ + -parent_id $parent_id] + + set found_p 0 + foreach filex [$resource_node child all imscp:file] { + set filex_href [imsld::parse::get_attribute -node $filex -attr_name href] + if { ![empty_string_p $resource_href] && [string eq $resource_href $filex_href] } { + # check if the referenced file in the resource exists + # if we finish with the files and the referenced one doesn't exist we raise an error + set found_p 1 + } + set filex_id [imsld::fs::file_new -href $filex_href \ + -resource_id $resource_id \ + -path_to_file $filex_href \ + -type file \ + -complete_path "${tmp_dir}/${filex_href}"] + if { !$filex_id } { + # an error ocurred when creating the file + return [list 0 "<#_ The file $filex_href % was not created, it wasn't found in the manifest #>"] + } + } + + if { ![empty_string_p $resource_href] && !$found_p } { + # we should have fond the referenced file, aborting + return [list 0 "<#_ The resource %resource_identifier% has a reference to a non existing file (%resource_href%). #>"] + } + + set resource_dependencies [$resource_node child all imscp:dependency] + foreach dependency $resource_dependencies { + set dependency_identifierref [imsld::parse::get_attribute -node $dependency -attr_name identifierref] + set dependency_id [imsld::cp::dependency_new -resource_id $resource_id \ + -identifierref $dependency] + # look for the resource in the manifest and add it to the CR + set resources [$manifest child all imscp:resources] + + # there must be at least one reource for the learning objective + imsld::parse::validate_multiplicity -tree $resources -multiplicity 0 -element_name "resources (dependency)" -greather_than + + set resourcex [$resources find identifier $dependency_identifierref] + # this resourcex must match with exactly one resource + imsld::parse::validate_multiplicity -tree $resourcex -multiplicity 1 -element_name "resource ($dependency_identifierref) en $resourcex" -equal + set dependency_resource_list [imsld::parse::parse_and_create_resource -resource_node $resourcex \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + if { ![lindex $dependency_resource_list 0] } { + # return this value and let the user know there was an error (becuase if succeded, it does nothing here) + return $dependency_resource_list + } + } + return [list $resource_id {}] +} + +ad_proc -public imsld::parse::parse_and_create_item { + -manifest + -manifest_id + -item_node + -parent_id + -tmp_dir +} { + Parse IMS-LD item node and stores all the information in the database, such as the resources, resources items, etc. + + Returns a list with the new imsld_item_id created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param manifest Manifest tree + @param manifestid Manifest ID or the manifest being parsed + @param item_node The item node to parse + @param parent_id Parent folder ID + @tmp_dir Temporary directory where the files were exctracted +} { + upvar files_struct_list files_struct_list + set item_title [imsld::parse::get_title -node $item_node -prefix imsld] + set item_identifier [imsld::parse::get_attribute -node $item_node -attr_name identifier] + set item_is_visible_p [imsld::parse::get_bool_attribute -tree $item_node -attr_name isvisible -default t] + set item_parameters [imsld::parse::get_attribute -node $item_node -attr_name parameters] + set item_identifierref [imsld::parse::get_attribute -node $item_node -attr_name identifierref] + set item_id [imsld::item_new -title $item_title \ + -identifier $item_identifier \ + -is_visible_p $item_is_visible_p \ + -parameters $item_parameters \ + -identifierref $item_identifierref \ + -parent_id $parent_id] + + if { ![empty_string_p $item_identifierref] } { + # look for the resource in the manifest and add it to the CR + set resources [$manifest child all imscp:resources] + + # there must be at least one reource for the learning objective + imsld::parse::validate_multiplicity -tree $resources -multiplicity 0 -element_name "resources (learning objective)" -greather_than + + set resourcex [$resources find identifier $item_identifierref] + # this resourcex must match with exactly one resource + imsld::parse::validate_multiplicity -tree $resourcex -multiplicity 1 -element_name "resources ($item_identifierref)" -equal + set resource_list [imsld::parse::parse_and_create_resource -resource_node $resourcex \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + if { ![lindex $resource_list 0] } { + # return the error + return $resource_list + } + # MAPEAR RESOURCE A SU ITEM (UN ITEM - N RESOURCES) !!!!!!!!!!!!!!!!!!!!!!!!!! + } + return [list $item_id {}] +} + +ad_proc -public imsld::parse::parse_and_create_imsld_manifest { -xmlfile:required - -imsld_id:optional + -manifest_id:required + {-community_id ""} + -tmp_dir:required } { - Parse a XML IMS LD file. + Parse a XML IMS LD file and store all the information found in the database, such as the manifest, the organization, the imsld with its components, method, activities, etc. - Returns the new imsld_id created if there was no errors. Otherwise it returns 0. + Returns the new manifest_id created if there was no errors. Otherwise it returns 0. @param xmlfile The file to parse. This file must be compliant with the IMS LD spec - @option imsld_id The imsld_id of the new ims-ld + @param manifest_id The manifest_id that is being created + @option community_id community_id of the community where the manifest and its contents will be created. Default value is + @param tmp_dir tmp dir where the files were extracted to } { + set community_id [expr { [empty_string_p $community_id] ? [dotlrn_community::get_community_id] : $community_id }] + # get the files structure + set files_struct_list [imsld::parse::get_files_structure -tmp_dir $tmp_dir] + # Parser # XML => DOM document dom parse [::tDOM::xmlReadFile $xmlfile] document # DOM document => DOM root - $document documentElement root - set organizations [$manifest child all organizations] + $document documentElement manifest + # manifest + set manifest_identifier [imsld::parse::get_attribute -node $manifest -attr_name identifier] + set manifest_version [imsld::parse::get_attribute -node $manifest -attr_name version] + + # initialize folders + set folders_list [imsld::parse::initialize_folders -community_id $community_id \ + -manifest_id $manifest_id \ + -manifest_identifier $manifest_identifier] + set fs_folder_id [lindex $folders_list 0] + set cr_folder_id [lindex $folders_list 1] + + # update file structure + set dir_parent_list [list [lindex [lindex [lindex $files_struct_list 0] 0] 0] $fs_folder_id] + set dir_list [list $dir_parent_list [lindex [lindex $files_struct_list 0] 1]] + set files_struct_list [lreplace $files_struct_list 0 0 $dir_list] + + set manifest_id [imsld::cp::manifest_new -item_id $manifest_id \ + -identifier $manifest_identifier \ + -version $manifest_version \ + -parent_id $cr_folder_id] + + # organizaiton + set organizations [$manifest child all imscp:organizations] + set organization_id [imsld::cp::organization_new -manifest_id $manifest_id] + # IMS-LD set imsld [$organizations child all imsld:learning-design] - set imsld_title [imsld::parse::get_title -tree $imsld] - set imsld_level [imsld::parse::get_attribute -tree $imsld -attr_name level] - set imsld_level [expr { [empty_string_p $imsld_level] ? "null" : [string tolower $imsld_level] }] - set imsld_version [imsld::parse::get_attribute -tree $imsld -attr_name version] - set imsld_sequence_used [imsld::parse::get_attribute -tree $imsld -attr_name sequence-used] - set imsld_sequence_p [expr { [empty_string_p $imsld_sequence_used] ? 0 : [imsld::parse::tcl_boolean -bool $imsld_sequence_used] }] + set imsld_title [imsld::parse::get_title -node $imsld -prefix imsld] + set imsld_identifier [imsld::parse::get_attribute -node $imsld -attr_name identifier] + set imsld_level [imsld::parse::get_attribute -node $imsld -attr_name level] + set imsld_level [expr { [empty_string_p $imsld_level] ? "" : [string tolower $imsld_level] }] + set imsld_version [imsld::parse::get_attribute -node $imsld -attr_name version] + set imsld_sequence_p [imsld::parse::get_bool_attribute -tree $imsld -attr_name sequence_used -default f] + set imsld_id [imsld::imsld_new -identifier $imsld_identifier \ + -title $imsld_title \ + -level $imsld_level \ + -version $imsld_version \ + -sequence_p $imsld_sequence_p \ + -parent_id $cr_folder_id] # IMS-LD: Learning Objectives (which is an imsld_item that can have a text resource associated.) set learning_objectives [$imsld child all imsld:learning-objectives] - imsld::parse::validate_multiplicity -tree $learning_objectives -multiplicity 1 -element_name learning-objectives -lower_than - + if { [llength $learning_objectives] } { + imsld::parse::validate_multiplicity -tree $learning_objectives -multiplicity 1 -element_name learning-objectives -lower_than + set learning_objective_title [imsld::parse::get_title -node $learning_objectives -prefix imsld] + set learning_objective_id [imsld::learning_objective_new -title $learning_objective_title \ + -imsld_id $imsld_id \ + -parent_id $cr_folder_id] + # IMD-LD: Learning Objectives: Items + set learning_objectives_items [$learning_objectives child all imsld:item] + if { [llength $learning_objectives_items] } { + foreach imsld_item $learning_objectives_items { + + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort + return $item_list + } + # MAPEAR ITEMS AL OBJECTIVE !! + } + } + } + # Components set components [$imsld child all imsld:components] imsld::parse::validate_multiplicity -tree $components -multiplicity 1 -element_name components -equal # Components: Roles set roles [$components child all imsld:roles] - set learners [$roles child all imsld:learner] - set staff [$roles child all imsld:staff] +# set learners [$roles child all imsld:learner] +# set staff [$roles child all imsld:staff] # Componetns: Activities set activities [$components child all imsld:activities] @@ -360,321 +737,14 @@ imsld::parse::validate_multiplicity -tree $methods -multiplicity 1 -element_name methods -equal # Method: Play - set plays [$methods child all imsld:play] - imsld::parse::validate_multiplicity -tree $plays -multiplicity 1 -element_name plays -equal +# set plays [$methods child all imsld:play] +# imsld::parse::validate_multiplicity -tree $plays -multiplicity 1 -element_name plays -equal - # Method: Acts - set acts [$plays child all imsld:act] - imsld::parse::validate_multiplicity -tree $acts -multiplicity 0 -element_name acts -greather_than +# # Method: Acts +# set acts [$plays child all imsld:act] +# imsld::parse::validate_multiplicity -tree $acts -multiplicity 0 -element_name acts -greather_than - - - - set questestinteropNodes [$root selectNodes {/questestinterop}] - foreach questestinterop $questestinteropNodes { - # Looks for assessments - set assessmentNodes [$questestinterop selectNodes {assessment}] - if { [llength $assessmentNodes] > 0 } { - # There are assessments - foreach assessment $assessmentNodes { - set as_assessments__title [$assessment getAttribute {title} {Assessment}] - #get assessment's children: section, (qticomment, duration, qtimetadata, objectives, assessmentcontrol, - #rubric, presentation_material, outcomes_processing, assessproc_extension, assessfeedback, - #selection_ordering, reference, sectionref) - set nodesList [$assessment childNodes] - set as_assessments__definition "" - set as_assessments__instructions "" - set as_assessments__duration "" - #for each assessment's child - foreach node $nodesList { - set nodeName [$node nodeName] - #as_assessmentsx.description = or - if {$nodeName == "qticomment"} { - set definitionNodes [$assessment selectNodes {qticomment}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_assessments__definition [as::qti::mattext_gethtml $definition] - } - } elseif {$nodeName == "objectives"} { - set definitionNodes [$assessment selectNodes {objectives/material/mattext}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_assessments__definition [as::qti::mattext_gethtml $definition] - } - #as_assessments.instructions = - } elseif {$nodeName == "rubric"} { - set instructionNodes [$assessment selectNodes {rubric/material/mattext}] - if {[llength $instructionNodes] != 0} { - set instruction [lindex $instructionNodes 0] - set as_assessments__instructions [as::qti::mattext_gethtml $instruction] - } - #as_assessments.time_for_response = - } elseif {$nodeName == "duration"} { - set durationNodes [$assessment selectNodes {duration/text()}] - if {[llength $durationNodes] != 0} { - set duration [lindex $durationNodes 0] - set as_assessments__duration [$duration nodeValue] - } - } - } - set qtimetadataNodes [$assessment selectNodes {qtimetadata}] - set as_assessments__run_mode "" - set as_assessments__anonymous_p f - set as_assessments__secure_access_p f - set as_assessments__reuse_responses_p f - set as_assessments__show_item_name_p f - set as_assessments__consent_page "" - set as_assessments__return_url "" - set as_assessments__start_time "" - set as_assessments__end_time "" - set as_assessments__number_tries "" - set as_assessments__wait_between_tries "" - set as_assessments__ip_mask "" - set as_assessments__show_feedback "none" - set as_assessments__section_navigation "default path" - - set itemfeedbacknodes [$root selectNodes {/questestinterop/assessment/section/item/itemfeedback}] - if { [llength $itemfeedbacknodes] >0} { - set as_assessments__show_feedback "all" - } - set resprocessNodes [$root selectNodes {/questestinterop/assessment/section/item/resprocessing}] - set as_assessments__survey_p {f} - if { [llength $resprocessNodes] == 0 } { - set as_assessments__survey_p {t} - #if it's a survey don't show feedback - set as_assessments__show_feedback "none" - } - - if {[llength $qtimetadataNodes] > 0} { - #nodes qtimetadatafield - set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] - foreach qtimetadatafieldnode $qtimetadatafieldNodes { - set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] - set label [$label nodeValue] - set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] - set value [$value nodeValue] - - switch -exact -- $label { - run_mode { - set as_assessments__run_mode $value - } - anonymous_p { - set as_assessments__anonymous_p $value - } - secure_access_p { - set as_assessments__secure_access_p $value - } - reuse_responses_p { - set as_assessments__reuse_responses_p $value - } - show_item_name_p { - set as_assessments__show_item_name_p $value - } - consent_page { - set as_assessments__consent_page $value - } - start_time { - set as_assessments__start_time $value - } - end_time { - set as_assessments__end_time $value - } - number_tries { - set as_assessments__number_tries $value - } - wait_between_tries { - set as_assessments__wait_between_tries $value - } - ip_mask { - set as_assessments__ip_mask $value - } - show_feedback { - set as_assessments__show_feedback $value - } - section_navigation { - set as_assessments__section_navigation $value - } - } - - } - } - - # Insert assessment in the CR (and as_assessments table) getting the revision_id (assessment_id) - set as_assessments__assessment_id [as::assessment::new \ - -title $as_assessments__title \ - -description $as_assessments__definition \ - -instructions $as_assessments__instructions \ - -run_mode $as_assessments__run_mode \ - -anonymous_p $as_assessments__anonymous_p \ - -secure_access_p $as_assessments__secure_access_p \ - -reuse_responses_p $as_assessments__reuse_responses_p \ - -show_item_name_p $as_assessments__show_item_name_p \ - -consent_page $as_assessments__consent_page \ - -return_url $as_assessments__return_url \ - -start_time $as_assessments__start_time \ - -end_time $as_assessments__end_time \ - -number_tries $as_assessments__number_tries \ - -wait_between_tries $as_assessments__wait_between_tries \ - -time_for_response $as_assessments__duration \ - -ip_mask $as_assessments__ip_mask \ - -show_feedback $as_assessments__show_feedback \ - -section_navigation $as_assessments__section_navigation \ - -survey_p $as_assessments__survey_p ] - - # Section - set sectionNodes [$assessment selectNodes {section}] - set as_assessment_section_map__sort_order 0 - foreach section $sectionNodes { - set as_sections__title [$section getAttribute {title} {Section}] - #get section's children (qticomment, duration, qtimetadata, objectives, sectioncontrol, - #sectionprecondition, sectionpostcondition, rubric, presentation_material, outcomes_processing, - #sectionproc_extension, sectionfeedback, selection_ordering, reference, itemref, item, sectionref, - #section) - set nodesList [$section childNodes] - set as_sections__definition "" - set as_sections__instructions "" - set as_sections__duration "" - set as_sections__sectionfeedback "" - #for each section's child - foreach node $nodesList { - set nodeName [$node nodeName] - #as_sectionsx.description = or - if {$nodeName == "qticomment"} { - set definitionNodes [$section selectNodes {qticomment}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_sections__definition [as::qti::mattext_gethtml $definition] - } - } elseif {$nodeName == "objectives"} { - set definitionNodes [$section selectNodes {objectives/material/mattext}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_sections__definition [as::qti::mattext_gethtml $definition] - } - #as_sections.max_time_to_complete = - } elseif {$nodeName == "duration"} { - set section_durationNodes [$section selectNodes {duration/text()}] - if {[llength $section_durationNodes] != 0} { - set section_duration [lindex $section_durationNodes 0] - set as_sections__duration [$section_duration nodeValue] - } - #as_sections.instructions = - } elseif {$nodeName == "rubric"} { - set section_instructionNodes [$section selectNodes {rubric/material/mattext}] - if {[llength $section_instructionNodes] != 0} { - set section_instruction [lindex $section_instructionNodes 0] - set as_sections__instructions [as::qti::mattext_gethtml $section_instruction] - } - #as_sections.feedback_text = - } elseif {$nodeName == "sectionfeedback"} { - set sectionfeedbackNodes [$section selectNodes {sectionfeedback/material/mattext}] - if {[llength $sectionfeedbackNodes] != 0} { - set sectionfeedback [lindex $sectionfeedbackNodes 0] - set as_sections__sectionfeedback [as::qti::mattext_gethtml $sectionfeedback] - } - } - } - - set qtimetadataNodes [$section selectNodes {qtimetadata}] - set as_sections__num_items "" - set as_sections__points "" - set asdt__display_type none - set asdt__s_num_items "" - set asdt__adp_chunk "" - set asdt__branched_p f - set asdt__back_button_p t - set asdt__submit_answer_p f - set asdt__sort_order_type order_of_entry - - if {[llength $qtimetadataNodes] > 0} { - #nodes qtimetadatafield - set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] - foreach qtimetadatafieldnode $qtimetadatafieldNodes { - set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] - set label [$label nodeValue] - set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] - set value [$value nodeValue] - - switch -exact -- $label { - num_items { - set as_sections__num_items $value - } - points { - set as_sections__points $value - } - display_type { - set asdt__display_type $value - } - s_num_items { - set asdt__s_num_items $value - } - adp_chunk { - set asdt__adp_chunk $value - } - branched_p { - set asdt__branched_p $value - } - back_button_p { - set asdt__back_button_p $value - } - submit_answer_p { - set asdt__submit_answer_p $value - } - sort_order_type { - set asdt__sort_order_type $value - } - } - } - } - - #section display type - set display_type_id [as::section_display::new \ - -title $asdt__display_type \ - -num_items $asdt__s_num_items \ - -adp_chunk $asdt__adp_chunk \ - -branched_p $asdt__branched_p \ - -back_button_p $asdt__back_button_p \ - -submit_answer_p $asdt__submit_answer_p \ - -sort_order_type $asdt__sort_order_type] - # Insert section in the CR (and in the as_sections table) getting the revision_id (section_id) - set section_id [as::section::new \ - -title $as_sections__title \ - -description $as_sections__definition \ - -instructions $as_sections__instructions \ - -feedback_text $as_sections__sectionfeedback \ - -max_time_to_complete $as_sections__duration \ - -num_items $as_sections__num_items \ - -points $as_sections__points \ - -display_type_id $display_type_id] - - # Relation between as_sections and as_assessments - db_dml as_assessment_section_map_insert {} - incr as_assessment_section_map__sort_order - set as_item_section_map__sort_order 0 - # Process the items - set as_items [as::qti::parse_item $section [file dirname $xmlfile]] - # Relation between as_items and as_sections - foreach as_item_list $as_items { - array set as_item $as_item_list - set as_item_id $as_item(as_item_id) - set as_item__duration $as_item(duration) - set as_item__points $as_item(points) - db_dml as_item_section_map_insert {} - incr as_item_section_map__sort_order - } - - #get points from a section - db_0or1row get_section_points {} - #update as_assessment_section_map with section points - db_dml update_as_assessment_section_map {} - } - } - } else { - # Just items (no assessments) - as::qti::parse_item $questestinterop [file dirname $xmlfile]] - } - } - return $as_assessments__assessment_id + return [list $manifest_id {}] } Index: openacs-4/packages/imsld/tcl/imsld-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,209 @@ +# /packages/imsld/tcl/imsld-procs.tcl + +ad_library { + Procedures in the imsld namespace. + + @creation-date Aug 2005 + @author jopez@inv.it.uc3m.es + @cvs-id $Id: imsld-procs.tcl,v 1.1 2005/08/05 15:25:33 josee Exp $ +} + +namespace eval imsld {} + +ad_proc -public imsld::safe_url_name { + -name:required +} { + returns the filename replacing some characters +} { + regsub -all {[<>:\"|/@\\\#%&+\\ ,\?]} $name {_} name + return $name +} + +ad_proc -public imsld::imsld_new { + -identifier + {-item_id ""} + {-title ""} + {-level ""} + {-version ""} + -sequence_p + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id +} { + Inserts a new manifest according to the imsmanifest.xml file. + + @param identifier intrinsic manifest identifier. + @option item_id Item_id of the imsld. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the IMS-LD. + @option version version. + @param sequence_p Indicates if the imsld uses simple sequencing (true if yes, false otherwise) + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the imsld. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the imsld. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the imsld. [dt_sysdate] used by default. + @option edit Are we editing the manifest? + @param parent_id Identifier of the parent folder +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + set content_type imsld_imsld + set item_name "${item_id}_[string tolower $identifier]" + set title [expr { [empty_string_p $title] ? $item_name : $title }] + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list identifier $identifier] \ + [list version $version] \ + [list level $level] \ + [list sequence_p $sequence_p]]] + + return $item_id +} + +ad_proc -public imsld::learning_objective_new { + -imsld_id + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new learning objective for the given imsld_id. + + @param imsld_id imsld_id of the imsld that this learning objective belongs to. + @option item_id Item_id of the learning objective. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the learning objective. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the learning objective. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the learning objective. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the learning objective. [dt_sysdate] used by default. + @option edit Are we editing the learning object? + @param parent_id Identifier of the parent folder +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + set content_type imsld_learning_objective + set item_name "${item_id}_imsld_learning_objective" + set title [expr { [empty_string_p $title] ? $item_name : $title }] + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list imsld_id $imsld_id]]] + + return $item_id +} + +ad_proc -public imsld::item_new { + -identifier + {-identifierref ""} + {-is_visible_p t} + {-parameters ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new learning objective for the given imsld_id. + + @param identifier Item identifier in the manifest. + @option identifierref A reference to a identifier (within the same package). + @option is_visible_p Initial visibility value of the item. Defaults to true. + @option parameters Parameters to be passed during runtime. + @option item_id Item_id of the item. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the item. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the item. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the item. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the item. [dt_sysdate] used by default. + @option edit Are we editing the item? + @param parent_id Identifier of the parent folder +} { + + set user_id [expr { [empty_string_p $user_id] ? [ad_conn user_id] : $user_id }] + set creation_ip [expr { [empty_string_p $creation_ip] ? [ad_conn peeraddr] : $creation_ip }] + set creation_date [expr { [empty_string_p $creation_date] ? [dt_sysdate] : $creation_date }] + set package_id [expr { [empty_string_p $package_id] ? [ad_conn package_id] : $package_id }] + set item_id [expr { [empty_string_p $item_id] ? [db_nextval "acs_object_id_seq"] : $item_id }] + + set content_type imsld_item + set item_name "${item_id}_[string tolower $identifier]" + set title [expr { [empty_string_p $title] ? $item_name : $title }] + + if { !$edit_p } { + # create + set item_id [content::item::new -item_id $item_id \ + -name $item_name \ + -content_type $content_type \ + -parent_id $parent_id \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -context_id $package_id] + } + + set revision_id [content::revision::new -item_id $item_id \ + -title $title \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list identifier $identifier] \ + [list identifierref $identifierref] \ + [list is_visible_p $is_visible_p] \ + [list parameters $parameters]]] + + return $item_id +} + Index: openacs-4/packages/imsld/www/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/www/index.adp 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,5 @@ + + @page_title;noquote@ + @context;noquote@ + +index \ No newline at end of file Index: openacs-4/packages/imsld/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/www/index.tcl 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,6 @@ +ad_page_contract { +} + +set page_title index +set context {} + Index: openacs-4/packages/imsld/www/admin/imsld-new-2.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new-2.adp,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/www/admin/imsld-new-2.adp 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/imsld-new-2.adp 5 Aug 2005 15:25:33 -0000 1.2 @@ -11,3 +11,5 @@ + +@msg;noquote@ \ No newline at end of file Index: openacs-4/packages/imsld/www/admin/imsld-new-2.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new-2.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/www/admin/imsld-new-2.tcl 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/imsld-new-2.tcl 5 Aug 2005 15:25:33 -0000 1.2 @@ -10,6 +10,7 @@ upload_file:trim upload_file.tmpfile:tmpfile return_url + manifest_id:notnull } -properties { upload_file context:onevalue @@ -22,10 +23,9 @@ set context [list [list "<#_ New IMS-LD #>" "new-imsld"] [list "<#_ Confirm: New IMS-LD #>"]] set user_id [ad_conn user_id] -set imsld_id [db_nextval acs_object_id_seq] # expand file -set tmp_dir [imsld::parse::expand_file -upload_file $upload_file -tmpfile ${upload_file.tmpfile} -dest_dir_base imsld-${imsld_id}] +set tmp_dir [imsld::parse::expand_file -upload_file $upload_file -tmpfile ${upload_file.tmpfile} -dest_dir_base manifest-${manifest_id}] # search for manifest file set manifest [imsld::parse::find_manifest -dir $tmp_dir -file_name "imsmanifest.xml"] @@ -65,12 +65,12 @@ } # Get the info from the manifest - set organizations [$manifest child all organizations] + set organizations [$manifest child all imscp:organizations] multirow append imsld_info "<#_ Number of Organizations: #>" [llength $organizations] set imsld [$organizations child all imsld:learning-design] multirow append imsld_info "<#_ Number of IMD LDs #>" [llength $imsld] - set imsld_title [imsld::parse::get_title -tree $imsld] - set imsld_level [imsld::parse::get_attribute -tree $imsld -attr_name level] + set imsld_title [imsld::parse::get_title -node $imsld -prefix imsld] + set imsld_level [imsld::parse::get_attribute -node $imsld -attr_name level] set imsld_level [expr { [empty_string_p $imsld_level] ? "<#_ Not defined #>" : $imsld_level }] multirow append imsld_info "<#_ IMD LD Title #>" [llength $imsld] multirow append imsld_info "<#_ IMD LD Level #>" "$imsld_level" @@ -80,11 +80,13 @@ imsld::parse::validate_multiplicity -tree $components -multiplicity 1 -element_name components -equal set roles [$components child all imsld:roles] - set learners [llength [$roles child all imsld:learner]] - set staff [llength [$roles child all imsld:staff]] - multirow append imsld_info "<#_ Total Roles #>" [expr $learners + $staff] - multirow append imsld_info "<#_ Learners Roles #>" $learners - multirow append imsld_info "<#_ Staff Roels #>" $staff + if { [llength $roles] } { + set learners [llength [$roles child all imsld:learner]] + set staff [llength [$roles child all imsld:staff]] + multirow append imsld_info "<#_ Total Roles #>" [expr $learners + $staff] + multirow append imsld_info "<#_ Learners Roles #>" $learners + multirow append imsld_info "<#_ Staff Roels #>" $staff + } set activities [$components child all imsld:activities] if { [llength $activities] } { @@ -102,11 +104,14 @@ imsld::parse::validate_multiplicity -tree $methods -multiplicity 1 -element_name methods -equal set plays [$methods child all imsld:play] - imsld::parse::validate_multiplicity -tree $plays -multiplicity 1 -element_name plays -equal + imsld::parse::validate_multiplicity -tree $plays -multiplicity 0 -element_name plays -greather_than - set acts [$plays child all imsld:act] - imsld::parse::validate_multiplicity -tree $acts -multiplicity 0 -element_name acts -greather_than - multirow append imsld_info "<#_ Acts #>" [llength $acts] + foreach play $plays { + set play_identifier [imsld::parse::get_attribute -node $play -attr_name identifier] + set acts [$play child all imsld:act] + imsld::parse::validate_multiplicity -tree $acts -multiplicity 0 -element_name acts -greather_than + multirow append imsld_info "<#_ Acts in play %play_identifier% #>" [llength $acts] + } } else { # Not valid (or supported?) IMS LD @@ -115,7 +120,16 @@ } ad_form -name imsld_upload -cancel_url $return_url -action imsld-new-3 -html { enctype multipart/form-data } -form { - imsld_id:key - {tmp_dir:text {widget hidden} {value $tmp_dir}} + {return_url:text {widget hidden} {value $return_url}} + {manifest_id:integer {widget hidden} {value $manifest_id}} } + +set file_str [imsld::parse::get_files_structure -tmp_dir $tmp_dir] + + +set msg "vamoaver .... $file_str \n\n en $tmp_dir con largo [llength $file_str] !!" +append msg "
la lista es:" +foreach fix $file_str { + append msg "
$fix --FIN--" +} Index: openacs-4/packages/imsld/www/admin/imsld-new-3.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/Attic/imsld-new-3.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/www/admin/imsld-new-3.adp 5 Aug 2005 15:25:33 -0000 1.1 @@ -0,0 +1,5 @@ + + titulin + contextin + +success Index: openacs-4/packages/imsld/www/admin/imsld-new-3.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/Attic/imsld-new-3.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/www/admin/imsld-new-3.tcl 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/imsld-new-3.tcl 5 Aug 2005 15:25:33 -0000 1.2 @@ -8,7 +8,7 @@ @creation-date jul 2005 } { tmp_dir - imsld_id:integer,notnull + manifest_id:integer,notnull return_url } -properties { context:onevalue @@ -23,21 +23,27 @@ set user_id [ad_conn user_id] # Display progress bar -ad_progress_bar_begin \ - -title "<#_ Uploading IMS LD #>" \ - -message_1 "<#_ Uploading and processing your course, please wait... #>" \ - -message_2 "<#_ We will continue automatically when processing is complete. #>" +# ad_progress_bar_begin \ +# -title "<#_ Uploading IMS LD #>" \ +# -message_1 "<#_ Uploading and processing your course, please wait... #>" \ +# -message_2 "<#_ We will continue automatically when processing is complete. #>" # Atempting to create the new IMS LD. -# The proc imsld::parse::parse_and_create_imsldl return a pair of values (success_p and a message) -set create_ismld_atempt_list [imsld::parse::parse_and_create_imsld -xmlfile $tmp_dir/imsmanifest.xml -imsld_id $imsld_id] +# The proc imsld::parse::parse_and_create_imsld_manifest return a pair of values (manifest_id and a message) +set manifest_list [imsld::parse::parse_and_create_imsld_manifest -xmlfile $tmp_dir/imsmanifest.xml \ + -manifest_id $manifest_id \ + -tmp_dir $tmp_dir \ + -community_id 2040] -set success_p [lindex $create_ismld_atempt_list 0] -set message [lindex $create_ismld_atempt_list 1] +set manifest_id [lindex $manifest_list 0] -if { $success_p } { - # Hats off! -} else { - # Error -} \ No newline at end of file +if { !$manifest_id } { + set errmsg [lindex $manifest_list 1] + ad_return_error "<#_ Error parsing manifest. #>" "<#_ There was an error parsing the manifest. Please correct it and try again.
$errmsg % #>" + ad_script_abort +} + +# delete the tmpdir +imsld::parse::remove_dir -dir $tmp_dir + Index: openacs-4/packages/imsld/www/admin/imsld-new.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/imsld-new.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/www/admin/imsld-new.tcl 26 Jul 2005 08:05:35 -0000 1.1 +++ openacs-4/packages/imsld/www/admin/imsld-new.tcl 5 Aug 2005 15:25:33 -0000 1.2 @@ -18,13 +18,14 @@ set context [list "<#_ New IMS-LD #>"] set user_id [ad_conn user_id] +set manifest_id [db_nextval acs_object_id_seq] # form to upload an IMS LD ZIP file ad_form -name upload_file_form -html {enctype multipart/form-data} -cancel_url $return_url -action imsld-new-2 -form { - imsld_id:key {upload_file:file {label "<#_ IMS-LD ZIP File #>"}} {return_url:text {widget hidden} {value $return_url}} + {manifest_id:integer {widget hidden} {value $manifest_id}} }