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 -r1.1 -r1.2 --- openacs-4/packages/imsld/sql/postgresql/imsld-create.sql 5 Aug 2005 15:25:33 -0000 1.1 +++ openacs-4/packages/imsld/sql/postgresql/imsld-create.sql 13 Sep 2005 13:15:02 -0000 1.2 @@ -12,16 +12,14 @@ on delete cascade constraint imsld_lo_id_pk primary key, + identifier varchar(100) + not null, 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) + parameters varchar(4000) ); create index imsld_learning_o_env_id_idx on imsld_learning_objects(environment_id); @@ -60,7 +58,13 @@ sequence_used_p char(1) constraint imsld_seq_ck check (sequence_used_p in ('t','f')) - default 'f' + default 'f', + learning_objective_id integer + constraint imsld_lobj_id_fk + references cr_items, --imsld_learning_objectives + prerequisite_id integer + constraint imsld_prereq_id_fk + references cr_items --imsld_prerequisites ); comment on table imsld_imslds is ' @@ -82,14 +86,12 @@ on delete cascade constraint imsld_leo_pk primary key, - imsld_id integer - constraint ismld_leo_imsldid_fk - references cr_items --imsld_imslds + pretty_title varchar(200) ); 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'; +Technically it is just a mapping table between items and the imsld_id or learning_activity_id, but this table was created to provide simplicity and clarification in the data model'; create table imsld_prerequisites ( prerequisite_id integer @@ -98,14 +100,12 @@ on delete cascade constraint imsld_prereq_pk primary key, - imsld_id integer - constraint ismld_prereq_imsldid_fk - references cr_items --imsld_imslds + pretty_title varchar(200) ); 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'; +Technically it is just a mapping table between items and the imsld_id or learning_activity_id, but this table was created to provide simplicity and clarification in the data model'; create table imsld_items ( imsld_item_id integer @@ -114,6 +114,9 @@ on delete cascade constraint imsld_items_id_pk primary key, + parent_item_id integer + constraint imsld_items_pid_fk + references cr_items, --imsld_items identifier varchar(100), identifierref varchar(100), is_visible_p char(1) @@ -125,6 +128,9 @@ comment on table imsld_items is ' This table holds the imsld items of the unit of learning'; +comment on column imsld_items.parent_item_id is ' +In case it is a nested item.'; + comment on column imsld_items.identifier is ' Unique identifier of the item in the unit of learning'; @@ -160,8 +166,13 @@ on delete cascade constraint imsld_roles_id_pk primary key, + component_id integer + constraint imsld_roles_comp_id_fk + references cr_items --imsld_components + not null, identifier varchar(100), - role_type varchar(100) + role_type varchar(7) + check (role_type in ('learner','staff')) not null, parent_role_id integer constraint imsld_roles_proleid_fk @@ -170,9 +181,11 @@ check (create_new_p in ('t','f')) default 't', match_persons_p char(1) - check (match_persons_p in ('t','f')), + check (match_persons_p in ('t','f')) + default 'f', max_persons integer, - min_persons integer + min_persons integer, + href varchar(2000) ); create index imsld_roles_parent_id_idx on imsld_roles(parent_role_id); @@ -194,6 +207,20 @@ 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_activity_description ( + description_id integer + constraint imsld_act_desc_fk + references cr_revisions + on delete cascade + constraint imsld_act_desc_pk + primary key, + pretty_title varchar(200) +); + +comment on table iimsld_activity_description is ' +This table holds the descrition of a learning activity. +Technically it is just a mapping table between items and the learning activity, but this table was created to provide simplicity and clarification in the data model'; + create table imsld_learning_activities ( activity_id integer constraint imsld_la_id_fk @@ -217,7 +244,13 @@ references cr_items, --imsld_time_limits on_completion_id integer constraint imdls_la_oncompid_fk - references cr_items --imsld_on_completion + references cr_items, --imsld_on_completion + learning_objective_id integer + constraint imsld_la_lobjid_fk + references cr_items, --imsld_learning_objectives + prerequisite_id integer + constraint imsld_la_prereqid_fk + references cr_items --imsld_prerequisites ); create index imsld_la_comp_id_idx on imsld_learning_activities(component_id); @@ -319,7 +352,10 @@ constraint imsld_env_compid_fk references cr_items --imsld_components not null, - identifier varchar(100) + identifier varchar(100), + learning_object_id integer + constraint imsld_env_loid_fk + references cr_items, --imsld_learning_objects ); create index imsld_envs_comp_id_idx on imsld_environments(component_id); @@ -329,33 +365,61 @@ 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_services ( + service_id integer + constraint imsld_serv_fk + references cr_revisions + on delete cascade + constraint imsld_serv_pk + primary key, + environment_id integer + constraint imsld_serv_env_fk + references cr_items --imsld_environments + not null, + identifier varchar(100), + class varchar(4000), + is_visible_p char(1) + check (is_visible_p in ('t','f')) + default 't', + parameters varchar(4000), + service_type varchar(10) + check (service_type in ('send-mail','conference')) +); + +create index imsld_serv_env_id_idx on imsld_services(environment_id); + +comment on table imsld_services is ' +This table stores all the services that are found in the IMS-LD. +The services are supposed to use the other .LRN packages (because that is how +the service is provided) but we also hold the information in this table.' + +comment on column imsld_services.is_visible_p is ' +Initial visibility attribute'; + +comment on column imsld_services.service_type is ' +Service type. Currently only send-mail and conference service types are supported +and their respective information is sotred in the tables imsld_send_mail_services and imsld_conference_services, respectively.'; + 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 + service_id integer + constraint imsld_emailsevr_service_fk + references cr_items --imsld_services not null, - recipients char(11) + recipients varchar(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); +create index imsld_send_m_serv_id_idx on imsld_send_mail_services(service_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 @@ -384,30 +448,22 @@ on delete cascade constraint imsld_confs_pk primary key, - environment_id integer - constraint imsld_confs_env_fk - references cr_items --imsld_environments - not null, + service_id integer + constraint imsld_emailsevr_service_fk + references cr_items --imsld_services + 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) + references cr_items --imsld_roles ); -create index imsld_confs_env_id on imsld_conference_services(environment_id); +create index imsld_confs_serv_id on imsld_conference_services(service_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 ' @@ -575,18 +631,14 @@ 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 + feedback_title varchar(200) ); 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 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.'; +Feedback are items that are mapped to this table with the imsld_feedback_rel.'; \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 -r1.1 -r1.2 --- openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql 5 Aug 2005 15:25:33 -0000 1.1 +++ openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql 13 Sep 2005 13:15:02 -0000 1.2 @@ -27,6 +27,8 @@ drop table imsld_environments cascade; +drop table imsld_services cascade; + drop table imsld_send_mail_services cascade; drop table imsld_send_mail_data cascade; 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 -r1.1 -r1.2 --- openacs-4/packages/imsld/tcl/apm-callback-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 +++ openacs-4/packages/imsld/tcl/apm-callback-procs.tcl 13 Sep 2005 13:15:03 -0000 1.2 @@ -17,12 +17,18 @@ } { # initalize the cr imsld::install::init_content_repository + + # create default relationships + ismld::install::init_rels } ad_proc -public imsld::apm_callback::before_uninstall { } { Proc calls and tasks needed to be donde before the uninstallation of the imsld package. } { + # clean rels + imsld::uninstall::delete_rels + # clean the cr imsld::uninstall::empty_content_repository } 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 -r1.1 -r1.2 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 13 Sep 2005 13:15:03 -0000 1.2 @@ -22,11 +22,10 @@ # 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 identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" 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 @@ -36,20 +35,23 @@ 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)" + content::type::attribute::new -content_type imsld_imsld -attribute_name learning_object_id -datatype number -pretty_name "<#_ Learning Objects ID #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_imsld -attribute_name prerequisite_id -datatype number -pretty_name "<#_ Prerequistes ID #>" -column_spec "integer" # 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" + content::type::attribute::new -content_type imsld_learning_objective -attribute_name pretty_title -datatype string -pretty_name "<#_ Pretty Title #>" -column_spec "varchar(200)" # 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" + content::type::attribute::new -content_type imsld_prerequisite -attribute_name pretty_title -datatype title -pretty_name "<#_ Pretty Title #>" -column_spec "varchar(200)" # 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 parent_item_id -datatype integer -pretty_name "<#_ Parent Item Identifier #>" -column_spec "integer" 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)" @@ -63,25 +65,33 @@ # 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 component_id -datatype string -pretty_name "<#_ Component Identifier #>" -column_spec "integer" 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" + content::type::attribute::new -content_type imsld_role -attribute_name href -datatype string -pretty_name "<#_ Href #>" -column_spec "varchar(2000)" + # imsld activity description + content::type::new -content_type imsld_activity_description -supertype content_revision -pretty_name "<#_ IMS-LD Activity Description #>" -pretty_plural "<#_ IMS-LD Activity Descriptions #>" -table_name imsld_activity_description -id_column description_id + + content::type::attribute::new -content_type imsld_activity_description -attribute_name pretty_title -datatype title -pretty_name "<#_ Pretty Title #>" -column_spec "varchar(200)" + # 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)" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name learning_objective_id -datatype number -pretty_name "<#_ Learning Objective ID #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_learning_activity -attribute_name prerequisite_id -datatype number -pretty_name "<#_ Prerequistes ID #>" -column_spec "integer" # 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 @@ -108,12 +118,23 @@ 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)" + content::type::attribute::new -content_type imsld_environment -attribute_name learning_object_id -datatype number -pretty_name "<#_ Learning Object Identifier #>" -column_spec "integer" + # services + content::type::new -content_type imsld_service -supertype content_revision -pretty_name "<#_ IMS-LD Service #>" -pretty_plural "<#_ IMS-LD Services #>" -table_name imsld_services -id_column service_id + + content::type::attribute::new -content_type imsld_service -attribute_name environment_id -datatype number -pretty_name "<#_ Environment Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_service -attribute_name identifier -datatype string -pretty_name "<#_ Identifier #>" -column_spec "varchar(100)" + content::type::attribute::new -content_type imsld_service -attribute_name class -datatype string -pretty_name "<#_ Class #>" -column_spec "varchar(4000)" + content::type::attribute::new -content_type imsld_service -attribute_name is_visible_p -datatype string -pretty_name "<#_ Is Visible? #>" -column_spec "char(1)" + content::type::attribute::new -content_type imsld_service -attribute_name parameters -datatype string -pretty_name "<#_ Parameters #>" -column_spec "varchar(4000)" + content::type::attribute::new -content_type imsld_service -attribute_name service_type -datatype string -pretty_name "<#_ Service Type #>" -column_spec "varchar(10)" + # 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 service_id -datatype number -pretty_name "<#_ Service Identifier #>" -column_spec "integer" + content::type::attribute::new -content_type imsld_send_mail_service -attribute_name recipients -datatype string -pretty_name "<#_ Recipients #>" -column_spec "varchar(11)" 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)" @@ -127,13 +148,10 @@ # 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 service_id -datatype number -pretty_name "<#_ Service 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 @@ -185,7 +203,7 @@ # 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" + content::type::attribute::new -content_type imsld_on_completion -attribute_name feedback_title -datatype string -pretty_name "<#_ Feedbach Title #>" -column_spec "varchar(200)" ### IMS-LD Content Packagin @@ -225,6 +243,94 @@ 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::install::init_rels { +} { + Create default rels between imsld items +} { + # Learing Objetcives - IMS-LD Items + rel_types::new imsld_lo_item_rel "Learing Objective - Imsld Item rel" "Learing Objective - Imsld Item rels" \ + imsld_learning_objective 0 {} \ + imsld_item 0 {} + + # Prerequisites - IMS-LD Items + rel_types::new imsld_preq_item_rel "Prerequisite - Imsld Item rel" "Prerequisite - Imsld Item rels" \ + imsld_prerequisite 0 {} \ + imsld_item 0 {} + + # IMS-LD Items - Resources + rel_types::new imsld_item_res_rel "Imsld Item - Resources rel" "Imsld Item - Resources rels" \ + imsld_item 0 {} \ + imsld_cp_resource 0 {} + + # Role - IMS-LD Items + rel_types::new imsld_role_item_rel "Role - Imslds Item rel" "Role - Imsld items rels" \ + imsld_role 0 {} \ + imsld_item 0 {} + + # IMS-LD - Learning Objectives + rel_types::new imsld_imsld_lob_rel "IMS-LD - Learning Objectives rel" "IMS-LD - Learning Objectives rels" \ + imsld_imsld 0 {} \ + imsld_learning_objective 0 {} + + # Learning Object - IMS-LD Item + rel_types::new imsld_lobject_item_rel "Learning Object - IMS-LD Item rel" "Learning Object - IMS-LD Item rels" \ + imsld_learning_object 0 {} \ + imsld_item 0 {} + + # Conference Service - Participants + rel_types::new imsld_conf_part_rel "Conference Serice - Participants rel" "Conference Serice - Participants rels" \ + imsld_conference_service 0 {} \ + imsld_role 0 {} + + # Conference Service - Observers + rel_types::new imsld_conf_obser_rel "Conference Serice - Observers rel" "Conference Serice - Observers rels" \ + imsld_conference_service 0 {} \ + imsld_role 0 {} + + # Conference Service - Moderators + rel_types::new imsld_conf_moder_rel "Conference Serice - Moderators rel" "Conference Serice - Moderators rels" \ + imsld_conference_service 0 {} \ + imsld_role 0 {} + + # Environment - Environment + rel_types::new imsld_env_env_rel "Environment - Environment rel" "Environment - Environment rels" \ + imsld_environment 0 {} \ + imsld_environment 0 {} + + # Activity Description - IMS-LD Items + rel_types::new imsld_actdesc_item_rel "Activity Description - Imsld Item rel" "Activity Description - Imsld Item rels" \ + imsld_activity_description 0 {} \ + imsld_item 0 {} + + # Learning Activity - Environment + rel_types::new imsld_la_env_rel "Learning Activity - Environment rel" "Learning Activity - Environment rels" \ + imsld_learning_activity 0 {} \ + imsld_environment 0 {} + + # On Completion - Feedback + rel_types::new imsld_feedback_rel "On Completion - Feedback rel" "On Completion - Feedback rels" \ + imsld_on_completion 0 {} \ + imsld_item 0 {} + +} + +ad_proc -public imsld::install::delete_rels { +} { + Delete default rels between imsld items +} { + imsld::rel_type_delete -rel_type imsld_lo_item_rel + imsld::rel_type_delete -rel_type imsld_preq_item_rel + imsld::rel_type_delete -rel_type imsld_item_res_rel + imsld::rel_type_delete -rel_type imsld_role_item_rel + imsld::rel_type_delete -rel_type imsld_lobject_item_rel + imsld::rel_type_delete -rel_type imsld_conf_part_rel + imsld::rel_type_delete -rel_type imsld_conf_obser_rel + imsld::rel_type_delete -rel_type imsld_conf_moder_rel + imsld::rel_type_delete -rel_type imsld_env_env_rel + imsld::rel_type_delete -rel_type imsld_la_env_rel + imsld::rel_type_delete -rel_type imsld_actdesc_item_rel +} + ad_proc -public imsld::uninstall::empty_content_repository { } { Deletes content types and attributes @@ -234,26 +340,28 @@ ### IMS-LD # learning objects + content::type::attribute::delete -content_type imsld_learning_object -attribute_name identifier 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 + content::type::attribute::delete -content_type imsld_imsld -attribute_name learning_objective_id + content::type::attribute::delete -content_type imsld_imsld -attribute_name prerequisite_id # learning objectives - content::type::attribute::delete -content_type imsld_learning_objective -attribute_name imsld_id + content::type::attribute::delete -content_type imsld_learning_objective -attribute_name pretty_title # imsld prerequisites - content::type::attribute::delete -content_type imsld_prerequisite -attribute_name imsld_id + content::type::attribute::delete -content_type imsld_prerequisite -attribute_name pretty_title # imsld items + content::type::attribute::delete -content_type imsld_item -attribute_name parent_item_id 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 @@ -263,23 +371,29 @@ content::type::attribute::delete -content_type imsld_component -attribute_name imsld_id # imsld roles + content::type::attribute::delete -content_type imsld_role -attribute_name component_id 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 + content::type::attribute::delete -content_type imsld_role -attribute_name href + # imsld prerequisites + content::type::attribute::delete -content_type imsld_activity_description -attribute_name pretty_title + # 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 + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name learning_objective_id + content::type::attribute::delete -content_type imsld_learning_activity -attribute_name prerequisite_id # support activities content::type::attribute::delete -content_type imsld_support_activity -attribute_name identifier @@ -300,9 +414,18 @@ # environments content::type::attribute::delete -content_type imsld_environment -attribute_name component_id content::type::attribute::delete -content_type imsld_environment -attribute_name identifier + content::type::attribute::delete -content_type imsld_environment -attribute_name learning_object_id # send mail service - content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name environment_id + content::type::attribute::delete -content_type imsld_service -attribute_name environment_id + content::type::attribute::delete -content_type imsld_service -attribute_name identifier + content::type::attribute::delete -content_type imsld_service -attribute_name class + content::type::attribute::delete -content_type imsld_service -attribute_name is_visible_p + content::type::attribute::delete -content_type imsld_service -attribute_name parameters + content::type::attribute::delete -content_type imsld_service -attribute_name service_type + + # send mail service + content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name service_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 @@ -313,13 +436,10 @@ 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 service_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 @@ -356,7 +476,7 @@ 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 + content::type::attribute::delete -content_type imsld_on_completion -attribute_name feedback_title ### IMS-LD Content Packagin @@ -394,10 +514,12 @@ 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_activity_description -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_service -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 @@ -409,7 +531,7 @@ 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 + ### IMS-LD Content Packaging 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 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.2 -r1.3 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 5 Aug 2005 15:25:33 -0000 1.2 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 13 Sep 2005 13:15:03 -0000 1.3 @@ -36,7 +36,7 @@ } { Checks it the given tree has the IMS LD extension and if the IMS LD comes in the organization. - Returns a list (pair of values): 1 + OK if succeeded, 0 + error message otherwise. + Returns a list (pair of values): 1 + empty if succeeded, 0 + error message otherwise. @param tree XML tree to analyze. } { @@ -62,7 +62,7 @@ } # After validating the cases above, we can say that this seems a well formed IMS LD - return [list 1 "<#_ OK #>"] + return [list 1 {}] } ad_proc -public imsld::parse::expand_file { @@ -207,17 +207,17 @@ } ad_proc -public imsld::parse::get_bool_attribute { - -tree + -node -attr_name -default } { 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 node Document @param attr_name Attribute we want to fetch } { - if { [$tree hasAttribute $attr_name] == 1 } { - return [imsld::parse::sql_boolean -bool [$tree getAttribute $attr_name]] + if { [$node hasAttribute $attr_name] == 1 } { + return [imsld::parse::sql_boolean -bool [$node getAttribute $attr_name]] } else { return $default } @@ -497,7 +497,7 @@ 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 manifest_id 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 @@ -570,36 +570,38 @@ -item_node -parent_id -tmp_dir + {-parent_item_id ""} } { 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 manifest_id 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 + @param tmp_dir Temporary directory where the files were exctracted + @option parent_item_id In case it's a nested item. Default null } { 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_is_visible_p [imsld::parse::get_bool_attribute -node $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] - + -parent_id $parent_id \ + -parent_item_id $parent_item_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 + imsld::parse::validate_multiplicity -tree $resources -multiplicity 0 -element_name "resources (item)" -greather_than set resourcex [$resources find identifier $item_identifierref] # this resourcex must match with exactly one resource @@ -609,15 +611,753 @@ -manifest_id $manifest_id \ -parent_id $parent_id \ -tmp_dir $tmp_dir] - if { ![lindex $resource_list 0] } { + set resource_id [lindex $resource_list 0] + if { !$resource_id } { # return the error return $resource_list } - # MAPEAR RESOURCE A SU ITEM (UN ITEM - N RESOURCES) !!!!!!!!!!!!!!!!!!!!!!!!!! + # map item with resource + relation_add imsld_item_res_rel $item_id $resource_id } - return [list $item_id {}] + + # nested or sub items + set nested_item_list [$item_node child all imsld:item] + if { [llength $nested_item_list] } { + foreach nested_item $nested_item_list { + set nested_item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $information_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir \ + -parent_item_id $item_id] + + set item_id [lindex $nested_item_list 0] + if { !$nested_item_id } { + # an error happened, abort and return the list whit the error + return $nested_item_list + } + } + } + return $item_id } +ad_proc -public imsld::parse::parse_and_create_role { + -role_type + -component_id + -manifest + -manifest_id + -roles_node + -parent_id + -tmp_dir + {-parent_role_id ""} +} { + Parse IMS-LD role node and stores all the information in the database. + + Returns a list with the new role_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param role_type staff or learner + @param component_id Component identifier which this role belongs to + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param roles_node The role node to parse + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted + @option parent_role_id Parent role identifier. Default to null +} { + # get the info of the role node and create the respective role + set role_create_new [imsld::parse::get_attribute -node $role -attr_name create-new] + switch [string tolower $role_create_new] { + allowed { + set role_create_new_p t + } + not-allowed { + set role_create_new_p f + } + default { + set role_create_new_p t + } + } + set role_href [imsld::parse::get_attribute -node $role -attr_name href] + set role_identifier [imsld::parse::get_attribute -node $role -attr_name identifier] + set role_match_persons [imsld::parse::get_attribute -node $role -attr_name identifier] + switch [string tolower $role_match_persons] { + exclusively-in-roles { + set role_match_persons_p t + } + not-exclusively { + set role_match_persons_p f + } + default { + set role_match_persons_p f + } + } + set role_max_persons [imsld::parse::get_attribute -node $role -attr_name max-persons] + set role_min_persons [imsld::parse::get_attribute -node $role -attr_name min-persons] + set role_title [imsld::parse::get_title -node $role -prefix imsld] + + # create the role + set role_id [imsld::role_new -identifier $role_identifier \ + -role_type $role_type \ + -parent_role_id $parent_role_id \ + -create_new_p $role_create_new_p \ + -match_persons_p $role_match_persons_p \ + -max_persons $role_max_persons \ + -min_persons $role_min_persons \ + -href $role_href \ + -component_id $component_id \ + -title $title] + + # continue with the role information and nested roles + set role_information [$role child all imsld:information] + if { [llength $role_information] } { + # parse the item, create it and map it to the role + set information_item [$role_information child all imsld:item] + if { ![llength $information_item] } { + return [list 0 "<#_ Information given but no item associated to it for the role %role_title% #>"] + } + + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $information_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map information item with the role + relation_add imsld_role_item_rel $role_id $item_id + } + + # nested roles + set nested_role [$role child all "imsld:${role_type}"] + if { [llength $nested_role] } { + imsld::parse::parse_and_create_role -role_type $role_type \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir \ + -roles_node $nested_role \ + -parent_role_id $role_id \ + -component_id $component_id + } + + return $role_id +} + +ad_proc -public imsld::parse::parse_and_create_learning_objective { + -learning_objective_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a learning objective and stores all the information in the database. + + Returns a list with the new learning_objective_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param learning_objective_node learning objective node to parse + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get learning objective info + set learning_objective_title [imsld::parse::get_title -node $learning_objective_node -prefix imsld] + set learning_objective_id [imsld::learning_objective_new -title $learning_objective_title \ + -parent_id $parent_id] + + # learning objective: imsld_items + set learning_objective_items [$learning_objective_node child all imsld:item] + if { [llength $learning_objective_items] } { + foreach imsld_item $learning_objective_items { + + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map item with the learning objective + relation_add imsld_lo_item_rel $learning_objective_id $item_id + } + } + return $learning_objective_id +} + +ad_proc -public imsld::parse::parse_and_create_prerequisite { + -prerequisite_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a prerequisite and stores all the information in the database. + + Returns a list with the new prerequisite_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param prerequisite_node prerequisite node to parse + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get prerequisite info + set prerequisite_title [imsld::parse::get_title -node $prerequisite_node -prefix imsld] + set prerequisite_id [imsld::prerequisite_new -title $prerequisite_title \ + -parent_id $parent_id] + + # prerequisite: imsld_items + set prerequisite_items [$prerequisite_node child all imsld:item] + if { [llength $prerequisite_items] } { + foreach imsld_item $prerequisite_items { + + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map item with the prerequisite + relation_add imsld_lo_item_rel $prerequisite_id $item_id + } + } + return $prerequisite_id +} + +ad_proc -public imsld::parse::parse_and_create_activity_description { + -activity_description_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a activity description and stores all the information in the database. + + Returns a list with the new activity_description_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param activity_description_node activity description node to parse + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get activity description info + set activity_description_title [imsld::parse::get_title -node $activity_description_node -prefix imsld] + set activity_description_id [imsld::activity_description_new -title $activity_description_title \ + -parent_id $parent_id] + + # activity description: imsld_items + set activity_description_items [$activity_description_node child all imsld:item] + if { [llength $activity_description_items] } { + foreach imsld_item $activity_description_items { + + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map item with the activity description + relation_add imsld_actdesc_item_rel $activity_description_id $item_id + } + } + return $activity_description_id +} + +ad_proc -public imsld::parse::parse_and_create_learning_object { + -learning_object_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a learning object and stores all the information in the database. + + Returns a list with the new learning_object_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param learning_object_node learning object node to parse + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get learning object info + set learning_object_class [imsld::parse::get_attribute -node $learning_object_node -attr_name class] + set identifier [imsld::parse::get_attribute -node $learning_object_node -attr_name identifier] + set is_visible_p [imsld::parse::get_bool_attribute -node $learning_object_node -attr_name isvisible -default t] + set parameters [imsld::parse::get_attribute -node $learning_object_node -attr_name parameters] + set type [imsld::parse::get_attribute -node $learning_object_node -attr_name type] + set title [imsld::parse::get_title -node $learning_object_node -prefix imsld] + + set learning_object_id [imsld::learning_object_new -class $learning_object_class \ + -identifier $identifier \ + -is_visible_p $is_visible_p \ + -parameters $parameters \ + -type $type \ + -title $title \ + -parent_id $parent_id] + + # learning object: imsld_items + set learning_object_item [$learning_object_node child all imsld:item] + if { [llength $learning_object_item] } { + imsld::parse::validate_multiplicity -tree $learning_object_node -multiplicity 1 -element_name item(learning-object) -equal + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map item with the learning_object + relation_add imsld_lobject_item_rell $learning_object_id $item_id + } + return $learning_object_id +} + +ad_proc -public imsld::parse::parse_and_create_service { + -service_node + -environment_id + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a service and stores all the information in the database. + + Returns a list with the new service_ids (item_ids) created if there were no errors, or 0 and an explanatio messge if there was an error. The service element can have conference or send-mail services (index service is currently not supported in .LRN), and they are created directly as a service, i.e. there is no table for storing the services, they are stored directly in the send-mail or conference tables. + + @param service_node service node to parse + @param environment_id + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get service info + set service_class [imsld::parse::get_attribute -node $service_node -attr_name class] + set identifier [imsld::parse::get_attribute -node $service_node -attr_name identifier] + set is_visible_p [imsld::parse::get_bool_attribute -node $service_node -attr_name isvisible -default t] + set parameters [imsld::parse::get_attribute -node $service_node -attr_name parameters] + + set send_mail [$service_node child all imsld:send-mail] + if { [llength $send_mail] } { + # it's a send mail service, get the info and create the service + imsld::parse::validate_multiplicity -tree $send_mail -multiplicity 1 -element_name send-mail -equal + set select [imsld::parse::get_attribute -node $send_mail -attr_name select] + expr { [string eq [string tolower $select] all-persons-in-role] ? [set recipients all-in-role] : [set recipients selection] } + ns_log notice "!!!recipients es $recipients \n\n" + set title [imsld::parse::get_title -node $send_mail -prefix imsld] + # create the service + set service_id [imsld::service_new -environment_id $environment_id \ + -class $service_class \ + -identifier $identifier \ + -is_visible_p $is_visible_p \ + -parameters $parameters \ + -service_type send-mail \ + -parent_id $parent_id] + # create the send mail service + set send_mail_id [imsld::send_mail_service_new -service_id $service_id \ + -is_visible_p $is_visible_p \ + -parameters $parameters \ + -recipients $recipients \ + -parent_id $parent_id \ + -title $title] + + set email_data_list [$send_mail child all imsld:email-data] + imsld::parse::validate_multiplicity -tree $email_data_list -multiplicity 1 -element_name email-data -greather_than + foreach email_data $email_data_list { + set role_ref [$email_data child all imsld:role-ref] + imsld::parse::validate_multiplicity -tree $email_data -multiplicity 1 -element_name role-ref(email-data) -equal + set ref [string tolower [imsld::parse::get_attribute -node $role_ref -attr_name ref]] + if { ![db_0or1row get_role_id {select role_id from imsld_roles where identifier = :ref and content_revision__is_live(role_id) = 't' }] } { + # there is no role with that identifier, return the error + return [list 0 "<#_ There is no role with the identifier %ref% (referenced by an email data) #>"] + } + set email_data_id [imsld::email_data_new -send_mail_service_id $send_mail_id \ + -role_id $role_id \ + -mail_data {}] + } + } + + set conference [$service_node child all imsld:conference] + if { [llength $conference] } { + # it's a conference service, get the info an create the service + imsld::parse::validate_multiplicity -tree $conference -multiplicity 1 -element_name conference -equal + set conference_type [string tolower [imsld::parse::get_attribute -node $conference -attr_name conference-type]] + set title [imsld::parse::get_title -node $conference -prefix imsld] + + # manager + set manager [$conference child all imsld:manager] + if { [llength $manager] } { + imsld::parse::validate_multiplicity -tree $manager -multiplicity 1 -element_name conference-manager -equal + set role_ref [string tolower [imsld::parse::get_attribute -node $manager -attr_name role-ref]] + if { ![db_0or1row get_role_id {select role_id as manager_id from imsld_roles where identifier = :role_ref and content_revision__is_live(role_id) = 't' }] } { + # there is no role with that identifier, return the error + return [list 0 "<#_ There is no role with the identifier %ref% (referenced by: manager) #>"] + } + } + + # item + set conference_item [$conference child all imsld:item] + imsld::parse::validate_multiplicity -tree $conference_item -multiplicity 1 -element_name conference-item -equal + set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $conference_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set imsld_item_id [lindex $item_list 0] + if { !$imsld_item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + + # create the service + set service_id [imsld::service_new -environment_id $environment_id \ + -class $service_class \ + -identifier $identifier \ + -is_visible_p $is_visible_p \ + -parameters $parameters \ + -service_type conferencel \ + -parent_id $parent_id] + + # create the conference service + set conference_id [imsld::conference_service_new -service_id $service_id \ + -manager_id $manager_id \ + -conference_type $conference_type \ + -imsld_item_id $imsld_item_id \ + -parent_id $parent_id] + + # participants + set participant_list [$conference child all imsld:participant] + imsld::parse::validate_multiplicity -tree $participant_list -multiplicity 1 -element_name conference-participant -greather_than + foreach participant $participant_list { + set role_ref [string tolower [imsld::parse::get_attribute -node $participant -attr_name role-ref]] + if { ![db_0or1row get_role_id {select role_id as participant_id from imsld_roles where identifier = :role_ref and content_revision__is_live(role_id) = 't' }] } { + # there is no role with that identifier, return the error + return [list 0 "<#_ There is no role with the identifier %ref% (referenced by: participant) #>"] + } + # map conference with participant role + relation_add imsld_conf_part_rel $conference_id $participant_id + } + + # observer + set observer_list [$conference child all imsld:observer] + if { [llength $observer_list] } { + foreach observer $observer_list { + set role_ref [string tolower [imsld::parse::get_attribute -node $observer -attr_name role-ref]] + if { ![db_0or1row get_role_id {select role_id as observer_id from imsld_roles where identifier = :role_ref and content_revision__is_live(role_id) = 't' }] } { + # there is no role with that identifier, return the error + return [list 0 "<#_ There is no role with the identifier %ref% (referenced by: observer) #>"] + } + # map conference with observer role + relation_add imsld_conf_obser_rel $conference_id $observer_id + } + } + + # moderator + set moderator_list [$conference child all imsld:moderator] + if { [llength $moderator_list] } { + foreach moderator $moderator_list { + set role_ref [string tolower [imsld::parse::get_attribute -node $moderator -attr_name role-ref]] + if { ![db_0or1row get_role_id {select role_id as moderator_id from imsld_roles where identifier = :role_ref and content_revision__is_live(role_id) = 't' }] } { + # there is no role with that identifier, return the error + return [list 0 "<#_ There is no role with the identifier %ref% (referenced by: moderator) #>"] + } + # map conference with moderator role + relation_add imsld_conf_moder_rel $conference_id $moderator_id + } + } + } + + # index service (not supported) + set index_search [$service_node child all imsld:index-search] + if { [llength $index_search] } { + ns_log error "Index-search service not supported" + return [list 0 "<#_ Index search service not supported #>"] + } + return $service_id +} + +ad_proc -public imsld::parse::parse_and_create_environment { + -environment_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a environment and stores all the information in the database. + + Returns a list with the new environment_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param environment_node environment node to parse + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + # get environment info + set identifier [imsld::parse::get_attribute -node $environment_node -attr_name identifier] + set title [imsld::parse::get_title -node $environment_node -prefix imsld] + + # environment: learning object + set learning_object [$environment_node child all imsld:learning_object] + imsld::parse::validate_multiplicity -tree $learning_object -multiplicity 1 -element_name learning-object -equal + set learning_object_list [imsld::parse::parse_and_create_learning_object -learning_object_node $learning_object \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set learning_object_id [lindex $learning_object_list 0] + if { !$learning_object_id } { + # there is an error, abort and return the list with the error + return $learning_object_list + } + + # create the environment + set environment_id [imsld::environment_new -component_id $component_id \ + -identifier $identifier \ + -learning_object_id $learning_object_id \ + -parent_id $parent_id] + + # environment: service + set service [$environment_node child all imsld:service] + imsld::parse::validate_multiplicity -tree $service -multiplicity 1 -element_name service(environment) -equal + set service_list [imsld::parse::parse_and_create_service -service_node $service \ + -environment_id $environment_id \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set service_id [lindex $service_list 0] + if { !$service_id } { + # there is an error, abort and return the list with the error + return $service_list + } + + # environment: environment ref + set environment_ref_list [$environment_node child all imsld:environment-ref] + if { [llength $environment_ref_list] } { + foreach environment_ref $environment_ref_list { + set ref [string tolower [imsld::parse::get_attribute -node $environment_ref -attr_name ref]] + # we have to search for the referenced environment and there are two cases: + # 1. the referenced environment has been created: get the id from the database and do the mappings + # 2. the referenced environment hasn't been created: invoke the parse_and_create_environment proc, + # but first verify that the environment exists in the manifest + if { [db_0or1row get_env_id {select environment_id as refrenced_env_id from imsld_environments where identifier = :ref and content_revision__is_live(environment_id) = 't'}] } { + # case one, just do the mappings + relation_add imsld_env_env_rel $environment_id $refrenced_env_id + } else { + # case two, first verify that the referenced environment exists + set environments [[[[$manifest child all imscp:organizations] child all imsld:learning-design] child all imsld:components] child all imsld:environments] + + set found_p 0 + foreach referenced_environment $environments { + set referenced_identifier [string tolower [imsld::parse::get_attribute -node $referenced_environment -attr_name identifier]] + if { [string eq $ref $referenced_identifier] } { + set found_p 1 + } + } + if { $found_p } { + # ok, let's create the environment + set environment_ref_list [imsld::parse::parse_and_create_environment -environment_node $environment \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set environment_ref_id [lindex $environment_ref_list 0] + if { !$environment_ref_id } { + # there is an error, abort and return the list with the error + return $environment_ref_list + } + # finally, do the mappings + relation_add imsld_env_env_rel $environment_id $environment_ref_id + } else { + # error, return + return [list 0 "<#_ Referenced environment %referenced_identifier% does not exist #>"] + } + } + } + } + return $environment_id +} + +ad_proc -public imsld::parse::parse_and_create_learning_activity { + -component_id + -activity_node + -manifest + -manifest_id + -parent_id + -tmp_dir +} { + Parse a learning activity and stores all the information in the database. + + Returns a list with the new activity_id (item_id) created if there were no errors, or 0 and an explanatio messge if there was an error. + + @param role_type staff or learner + @param component_id Component identifier which this role belongs to + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param roles_node The role node to parse + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted + @option parent_role_id Parent role identifier. Default to null +} { + # get the info of the learning activity and create it + set identifier [imsld::parse::get_attribute -node $activity_node -attr_name identifier] + set is_visible_p [imsld::parse::get_bool_attribute -tree $activity_node -attr_name isvisible -default t] + set parameters [imsld::parse::get_attribute -node $activity_node -attr_name parameters] + set title [imsld::parse::get_title -node $activity_node -prefix imsld] + + # Learning Activity: Learning Objectives (which are really an imsld_item that can have resource associated.) + set learning_objectives [$activity_node child all imsld:learning-objectives] + if { [llength $learning_objectives] } { + imsld::parse::validate_multiplicity -tree $learning_objectives -multiplicity 1 -element_name learning-objectives(learning-activity) -equal + set learning_objective_list [imsld::parse::parse_and_create_learning_objective -learning_objective_node $learning_objectives \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set learning_objective_id [lindex $learning_objective_list 0] + if { !$learning_objective_id } { + # there is an error, abort and return the list with the error + return $learning_objective_list + } + } else { + set learning_objective_id "" + } + + # Learning Activity: Prerequisites (which are really an imsld_item that can have resource associated.) + set prerequisites [$activity_node child all imsld:prerequisites] + if { [llength $prerequisites] } { + imsld::parse::validate_multiplicity -tree $prerequisites -multiplicity 1 -element_name prerequisites(learning-activity) -equal + set prerequisite_list [imsld::parse::parse_and_create_perequiste -prerequisite_node $prerequisites \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set prerequisite_id [lindex $prerequisite_list 0] + if { !$prerequisite_id } { + # there is an error, abort and return the list with the error + return $prerequisite_list + } + } else { + set prerequisite_id "" + } + + # Learning Activity: Complete Activity + # If the learning activity has a "user choice" node, the learner decides when the activity is completed + # otherwise, the activity ends when "time-limit" is complete. + # When this element does not occur, the activity is set to 'completed' by default. + + set complete_activity [$activity_node child all imsld:complete-activity] + set user_choice_p f + set time_limit_id "" + if { [llength $complete_activity] } { + imsld::parse::validate_multiplicity -tree $complete_activity -multiplicity 1 -element_name complete-activity(learning-activity) -equal + + # Learning Activity: Complete Activity: User Choice + set user_choice [$complete_activity child all imsld:user-choice] + if { [llength $user_choice] } { + imsld::parse::validate_multiplicity -tree $user_choice -multiplicity 1 -element_name user-choice(learning-activity) -equal + # that's it, the learner decides when the activity is completed + set user_choice_p t + } + + # Learning Activity: Complete Activity: Time Limit + set time_limit [$complete_activity child all imsld:time-limit] + if { [llength $time_limit] } { + imsld::parse::validate_multiplicity -tree $time_limit -multiplicity 1 -element_name time-limit(learning-activity) -equal + set time_amount [imsld::parse::get_element_text -node $time_limit] + set time_limit_id [imsld::time_limit_new -time_in_seconds $time_amount] + } + } + + # Learning Activity: On completion + set on_completion [$activity_node child all imsld:on-completion] + set on_completion_id "" + if { [llength $on_completion] } { + set feedback_desc [$on_completion child all imsld:feedback-description] + if { [llength $feedback_desc] } { + imsld::parse::validate_multiplicity -tree $feedback_desc -multiplicity 1 -element_name feedback(learning-activity) -equal + set feedback_title [imsld::parse::get_title -node $feedback_desc -prefix imsld] + set on_completion_id [imsld::on_completion_new -feedback_title $feedback_title] + set feedback_items [$feedback_desc child all imsld:item] + foreach feedback_item $feedback_items { + set item_list [imsld::parse_and_create_item -manifest $manifest \ + -manifest_id $manifest_id \ + -item_node $feedback_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set item_id [lindex $item_list 0] + if { !$item_id } { + # an error happened, abort and return the list whit the error + return $item_list + } + # map item with the learning objective + relation_add imsld_feedback_rel $on_completion_id $item_id + } + } + } + + # crete learning activity + set learning_activity_id [imsld::learning_activity_new -identifier $identifier \ + -component_id $component_id \ + -parameters $parameters \ + -is_visible_p $is_visible_p \ + -user_choice_p $user_choice_p \ + -time_limit_id $time_limit_id \ + -on_completion_id $on_completion_id \ + -learning_objective_id $learning_objective_id \ + -prerequisite_id $prerequisite_id \ + -title $title] + + # Learning Activity: Environments + set environment_refs [$activity_node child all imsld:environment-ref] + if { [llength $environment_refs] } { + foreach environment_ref_node $environment_refs { + # the environments have been already parsed by now, + # so the referenced environment has to be in the database. + # If not found, return the error + set environment_ref [string tolower [imsld::parse::get_attribute -node $environment_ref_node -attr_name ref]] + if { ![db_0or1row get_environment_id {select environment_id from imsld_environments where identifier = :environment_ref}] } { + # error, referenced environment does not exist + return [list 0 "<#_ Referenced environment (%environment_ref%) in learning activity does not exist. #>"] + } + + # map environment with learning-activity + relation_add imsld_la_env_rel $learning_activity_id $environment_id + } + } + + +} + ad_proc -public imsld::parse::parse_and_create_imsld_manifest { -xmlfile:required -manifest_id:required @@ -677,57 +1417,130 @@ 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] + set imsld_sequence_p [imsld::parse::get_bool_attribute -node $imsld -attr_name sequence_used -default f] - # IMS-LD: Learning Objectives (which is an imsld_item that can have a text resource associated.) + # IMS-LD: Learning Objectives (which are really an imsld_item that can have resource associated.) set learning_objectives [$imsld child all imsld:learning-objectives] 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] + imsld::parse::validate_multiplicity -tree $learning_objectives -multiplicity 1 -element_name learning-objectives(ims-ld) -equal + set learning_objective_list [imsld::parse::parse_and_create_learning_objective -learning_objective_node $learning_objectives \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir] - # 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 learning_objective_id [lindex $learning_objective_list 0] + if { !$learning_objective_id } { + # there is an error, abort and return the list with the error + return $learning_objective_list + } + } else { + set learning_objective_id "" + } - set item_list [imsld::parse::parse_and_create_item -manifest $manifest \ + # IMS-LD: Prerequisites (which are really an imsld_item that can have resource associated.) + set prerequisites [$imsld child all imsld:prerequisites] + if { [llength $learning_objectives] } { + imsld::parse::validate_multiplicity -tree $prerequisites -multiplicity 1 -element_name prerequisites(ims-ld) -equal + set prerequisite_list [imsld::parse::parse_and_create_perequiste -prerequisite_node $prerequisites \ -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 !! - } + set prerequisite_id [lindex $prerequiste_list 0] + if { !$prerequisite_id } { + # there is an error, abort and return the list with the error + return $prerequisite_list } + } else { + set prerequisite_id "" } + # now that we have all the necessary information, let's create the imsld + 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 \ + -learning_objectives $learning_objective_id \ + -prerequisite_id $prerequisite_id] + # Components set components [$imsld child all imsld:components] imsld::parse::validate_multiplicity -tree $components -multiplicity 1 -element_name components -equal + set component_id [imsld::component_new -imsld_id $imsld_id \ + -parent_id $cr_folder_id] # Components: Roles set roles [$components child all imsld:roles] -# set learners [$roles child all imsld:learner] -# set staff [$roles child all imsld:staff] + # Components: Roles: Learners + set learner_list [$roles child all imsld:learner] + imsld::parse::validate_multiplicity -tree $learner_list -multiplicity 1 -element_name components -greather_than + + foreach learner $learner_list { + imsld::parse::parse_and_create_role -role_type learner \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir \ + -roles_node $learner \ + -component_id $component_id + } + + # Components: Roles: Staff + set staff_list [$roles child all imsld:staff] + if { [llength $staff_list] } { + foreach staff $staff_list { + imsld::parse::parse_and_create_role -role_type staff \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir \ + -roles_node $staff \ + -component_id $component_id + } + } + + # Components: Environments + # The environments are parsed now, and not the activities, because the activities may reference + # the environments so they have to be in the database already. + + set environment_component [$components child all imsld:environments] + if { [llength $environment_component] } { + imsld::parse::validate_multiplicity -tree $environment_component -multiplicity 1 -element_name environments -equal + set environments [$environment_component child all imsld:environment] + imsld::parse::validate_multiplicity -tree $environments -multiplicity 1 -element_name environments -greather than + foreach environment $environments { + imsld::parse::parse_and_create_environment -environment_node $environment \ + -manifest_id $manifest_id \ + -item_node $imsld_item \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir + } + } + + # Componetns: Activities set activities [$components child all imsld:activities] if { [llength $activities] } { + imsld::parse::validate_multiplicity -tree $activities -multiplicity 1 -element_name components -equal + + # Componets: Activities: Learning Activities set learning_activities [$activities child all imsld:learning-activity] + imsld::parse::validate_multiplicity -tree $learning_activities -multiplicity 1 -element_name learning-activities -greather_than + + foreach learning_activity $learning_atcivities { + imsld::parse::parse_and_create_learning_activity -component_id $component_id \ + -activity_node $learning_activity \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir + } + set support_activities [$activities child all imsld:support-activity] set activity_structures [$activities child all imsld:activity-structure] } 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 -r1.1 -r1.2 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 5 Aug 2005 15:25:33 -0000 1.1 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 13 Sep 2005 13:15:03 -0000 1.2 @@ -19,13 +19,59 @@ return $name } +ad_proc -public imsld::rel_type_delete { + -rel_type:required +} { + Deletes a rel type (since the rel_types does not have a delete proc) +} { + + db_1row select_type_info { + select t.table_name + from acs_object_types t + where t.object_type = :rel_type + } + + set rel_id_list [db_list select_rel_ids { + select r.rel_id + from acs_rels r + where r.rel_type = :rel_type + }] + + # delete all relations and drop the relationship + # type. + + db_transaction { + foreach rel_id $rel_id_list { + relation_remove $rel_id + } + + db_exec_plsql drop_relationship_type { + BEGIN + acs_rel_type.drop_type( rel_type => :rel_type, + cascade_p => 't' ); + END; + } + } on_error { + ad_return_error "Error deleting relationship type" "We got the following error trying to delete this relationship type:
$errmsg
" + ad_script_abort + } + # If we successfully dropped the relationship type, drop the table. + # Note that we do this outside the transaction as it commits all + # transactions anyway + if { [db_table_exists $table_name] } { + db_exec_plsql drop_type_table "drop table $table_name" + } +} + ad_proc -public imsld::imsld_new { -identifier {-item_id ""} {-title ""} {-level ""} {-version ""} -sequence_p + {-learning_objective_id ""} + {-prerequisite_id ""} {-package_id ""} {-user_id ""} {-creation_ip ""} @@ -76,16 +122,17 @@ -creation_ip $creation_ip \ -item_id $item_id \ -is_live "t" \ - -attributes [list [list identifier $identifier] \ + -attributes [list [list identifier [string tolower $identifier]] \ [list version $version] \ [list level $level] \ - [list sequence_p $sequence_p]]] + [list sequence_p $sequence_p] \ + [list learning_object_id $learning_object_id] \ + [list prerequisite_id $prerequisite_id]]] return $item_id } ad_proc -public imsld::learning_objective_new { - -imsld_id {-item_id ""} {-title ""} {-package_id ""} @@ -97,7 +144,6 @@ } { 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 @@ -136,16 +182,182 @@ -creation_ip $creation_ip \ -item_id $item_id \ -is_live "t" \ - -attributes [list [list imsld_id $imsld_id]]] + -attributes [list [list pretty_title $title]]] return $item_id } +ad_proc -public imsld::prerequisite_new { + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new prerequisite for the given imsld_id. + + @option item_id Item_id of the prerequisite. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the prerequisite. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the prerequisite. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the prerequisite. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the prerequisite. [dt_sysdate] used by default. + @option edit Are we editing the prerequiste? + @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_prerequisite + set item_name "${item_id}_imsld_prerequisite" + 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 pretty_title $pretty_title]]] + + return $item_id +} + +ad_proc -public imsld::activity_description_new { + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new activity description for the given imsld_id. + + @option item_id Item_id of the activity description. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the activity description. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the activity description. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the activity description. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the activity description. [dt_sysdate] used by default. + @option edit Are we editing the prerequiste? + @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_activity_description + set item_name "${item_id}_imsld_activity_description" + 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 pretty_title $pretty_title]]] + + return $item_id +} + +ad_proc -public imsld::_new { + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new activity description for the given imsld_id. + + @option item_id Item_id of the activity description. [db_nextval "acs_object_id_seq"] used by default. + @option title Title of the activity description. + @option package_id package_id for the instance of IMS-LD + @option user_id user that adds the activity description. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the activity description. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the activity description. [dt_sysdate] used by default. + @option edit Are we editing the prerequiste? + @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_activity_description + set item_name "${item_id}_imsld_activity_description" + 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 pretty_title $pretty_title]]] + + return $item_id +} + ad_proc -public imsld::item_new { -identifier {-identifierref ""} {-is_visible_p t} {-parameters ""} + {-parent_item_id ""} {-item_id ""} {-title ""} {-package_id ""} @@ -155,12 +367,13 @@ -edit:boolean -parent_id:required } { - Creates a new learning objective for the given imsld_id. + Creates a new item 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 parent_item_id In case it's a nested item. Default null @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 @@ -199,11 +412,729 @@ -creation_ip $creation_ip \ -item_id $item_id \ -is_live "t" \ - -attributes [list [list identifier $identifier] \ + -attributes [list [list identifier [string tolower $identifier]] \ [list identifierref $identifierref] \ [list is_visible_p $is_visible_p] \ + [list parameters $parameters] \ + [list parent_item_id $parent_item_id]]] + + return $item_id +} + +ad_proc -public imsld::component_new { + -imsld_id + {-item_id ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new component for the given imsld_id. + + @param imsld_id imsld_id of the imsld that this component belongs to. + @option item_id Item_id of the component. [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 component. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the component. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the component. [dt_sysdate] used by default. + @option edit Are we editing the prerequiste? + @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_component + set item_name "${item_id}_imsld_component" + + 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 imsld_id $imsld_id]]] + + return $item_id +} + +ad_proc -public imsld::role_new { + -component_id + -identifier + {-parent_role_id ""} + -role_type + -create_new_p + {-match_persons_p 0} + {-max_persons ""} + {-min_persons ""} + {-href ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new role. + + @param component_id component_id of the component wich this role belongs to. + @param identifier Role identifier in the manifest. + @option parent_role_id role_id of the parent role (in case this is a nested role). + @param role_type staff or learner + @param create_new_p Can users with this role create other roles? true for allowed and false for not allowed. + @option max_persons + @option min_persons + @option href + @option item_id Item_id of the role. [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 role. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the role. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the role. [dt_sysdate] used by default. + @option edit Are we editing the prerequiste? + @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_role + set item_name "${item_id}_imsld_role" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list component_id $component_id] \ + [list identifier [string tolower $identifier]] \ + [list parent_role_id $parent_role_id] \ + [list role_tye $role_type] \ + [list create_new_p $create_new_p] \ + [list max_persons $max_persons] \ + [list min_persons $min_persons] \ + [list href $href]]] + return $item_id +} + +ad_proc -public imsld::learning_object_new { + -environment_id + {-class ""} + -identifier + -is_visible_p + {-parameters ""} + {-type ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new learning object. + + @param environment_id Environment where to which learning object belongs + @option class + @param identifier Learning object identifier + @param is_visible_p Initial visibility attribute + @option parameters Parameters to be passed during runtime + @option type The type of learning object + @option item_id Item_id of the learning_object. [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 learning object. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the learning object. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the learning object. [dt_sysdate] used by default. + @param edit Are we editing the prerequiste? + @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_object + set item_name "${item_id}_imsld_learning_object" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list class $class] \ + [list environment_id $environment_id] \ + [list is_visible_p $-is_visible_p] \ + [list type $type] \ + [list identifier [string tolower $identifier]] \ [list parameters $parameters]]] + return $item_id +} + +ad_proc -public imsld::service_new { + -environment_id + {-class ""} + -identifier + -is_visible_p + {-parameters ""} + -service_type + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new service. + + @param environment_id Environment where to which service belongs + @option class + @param identifier service identifier + @param is_visible_p Initial visibility attribute + @option parameters Parameters to be passed during runtime + @param service_type The type of service + @option item_id Item_id of the service. [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 service. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the service. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the service. [dt_sysdate] used by default. + @param edit Are we editing the prerequiste? + @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_service + set item_name "${item_id}_imsld_service" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list class $class] \ + [list environment_id $environment_id] \ + [list is_visible_p $-is_visible_p] \ + [list service_type $type] \ + [list identifier [string tolower $identifier]] \ + [list parameters $parameters]]] return $item_id } +ad_proc -public imsld::send_mail_service_new { + -service_id + -is_visible_p + {-parameters ""} + -recipients + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new send mail serivce. + + @param service_id service where to which send mail service belongs + @param is_visible_p Initial visibility attribute + @option parameters Parameters to be passed during runtime + @param recipients Select: 'all-persons-in-role' or 'persons-in-role' + @option item_id Item_id of the send mail serivce. [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 send mail serivce. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the send mail serivce. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the send mail serivce. [dt_sysdate] used by default. + @param edit Are we editing the prerequiste? + @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_send_mail_service + set item_name "${item_id}_imsld_send_mail_service" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list class $class] \ + [list service_id $service_id] \ + [list recipients $recipients] \ + [list is_visible_p $-is_visible_p] \ + [list parameters $parameters]]] + return $item_id +} + +ad_proc -public imsld::send_mail_data_new { + -send_mail_service_id + -role_id + {-mail_data ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new send mail data + + @param send_mail_service_id send mail service to which send mail data belongs + @param role_id + @option mail_data + @option item_id Item_id of the send mail data. [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 send mail data. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the send mail data. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the send mail data. [dt_sysdate] used by default. + @param edit Are we editing the send mail data? + @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_send_mail_service + set item_name "${item_id}_imsld_send_mail_service" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list -send_mail_service_id -send_mail_service_id] \ + [list -role_id -role_id] \ + [list -mail_data -mail_data]]] + return $item_id +} + +ad_proc -public imsld::conference_service_new { + -service_id + -manager_id + {-imsld_item_id ""} + -conference_type + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new conference service + + @param service_id Service to which conference service belongs + @param manager_id role_id of the conference manager + @option item_id Item_id of the conference service. [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 conference service. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the conference service. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the conference service. [dt_sysdate] used by default. + @param edit Are we editing the conference service? + @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_conference_service + set item_name "${item_id}_imsld_conference_service" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list -send_mail_service_id -send_mail_service_id] \ + [list -role_id -role_id] \ + [list -mail_data -mail_data]]] + return $item_id +} + +ad_proc -public imsld::environment_new { + -component_id + -identifier + {-learning_object_id ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new environment + + @param component_id Component id of the one that owns the environment. + @param identifier Unique identifier in the manifest. + @option learning_object_id In case the environment has one. + @option item_id Item_id of the environment. [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 environment. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the environment. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the environment. [dt_sysdate] used by default. + @param edit Are we editing the environment? + @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_environment + set item_name "${item_id}_imsld_environment" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list -component_id $component_id] \ + [list -identifier $identifier] \ + [list -learning_object_id $learning_object_id]]] + return $item_id +} + +ad_proc -public imsld::time_limit_new { + -time_in_seconds + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new time limit + + @param time_in_seconds Amount of time in seconds + @option item_id Item_id of the time limit. [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 time limit. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the time limit. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the time limit. [dt_sysdate] used by default. + @param edit Are we editing the time limit? + @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_time_limit + set item_name "${item_id}_imsld_time_limit" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list -time_in_seconds]]] + return $item_id +} + +ad_proc -public imsld::on_completion_new { + -feedback_title + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new on completion + + @param feedback_title + @option item_id Item_id of the on completion. [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 on completion. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the on completion. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the on completion. [dt_sysdate] used by default. + @param edit Are we editing the on completion? + @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_on_completion + set item_name "${item_id}_imsld_on_completion" + 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 $item_name \ + -content_type $content_type \ + -creation_user $user_id \ + -creation_ip $creation_ip \ + -item_id $item_id \ + -is_live "t" \ + -attributes [list [list -feedback_title $feedback_title]]] + return $item_id +} + +ad_proc -public imsld::learning_activity_new { + -identifier + -component_id + {-parameters ""} + -is_visible_p + -user_choice_p + {-time_limit_id ""} + {-on_completion_id ""} + {-learning_objective_id ""} + {-prerequisite_id ""} + {-item_id ""} + {-title ""} + {-package_id ""} + {-user_id ""} + {-creation_ip ""} + {-creation_date ""} + -edit:boolean + -parent_id:required +} { + Creates a new learning activity + + @param identifier learning activity unique identifier in the manifest + @param component_id component_id where the activity belongs + @option parameters Parameters to be passed during runtime + @param is_visible_p Initial visibility attribute + @param user_choice_p Will the learner decide when the activity ends? + @option time_limt_id Possible time limit associated with the activity + @option on_completion_id Learning activity actions to be executed after the activity is finished + @option learning_objective_id Possible learning objectives associated with the acitivty + @option prerequisite_id Possible prerequisites associated with the acitivty + @option item_id Item_id of the learning activity. [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 learning activity. [ad_conn user_id] used by default. + @option creation_ip ip-address of the user that adds the learning activity. [ad_conn peeraddr] used by default. + @option creation_date Creation date of the learning activity. [dt_sysdate] used by default. + @param edit Are we editing the learning activity? + @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_activity + set item_name "${item_id}_imsld_learning_activity" + 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 $item_name \ + -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 -component_id $component_id] \ + [list -parameters $parameters] \ + [list -is_visible_p $is_visible_p] \ + [list -user_choice_p $user_choice_p] \ + [list -time_limit_id $time_limit_id] \ + [list -on_completion_id $on_completion_id] \ + [list -learning_objective_id $learning_objective_id] \ + [list -prerequisite_id $prerequisite_id]]] + return $item_id +}