Index: openacs-4/packages/imsld/imsld.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/imsld.info,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/imsld/imsld.info 20 Feb 2006 15:01:03 -0000 1.6 +++ openacs-4/packages/imsld/imsld.info 24 Oct 2006 10:09:50 -0000 1.7 @@ -7,27 +7,28 @@ f f - + Jose Pablo Escobedo Del Cid IMS LD integration with dotLRN. - 2005-07-07 + 2006-10-20 This package is the implementation of IMS LD in dotLRN. The course admin can create a sequence of activities for the students, as well as decide who does what, when and using what resources. 0 - + - - + + + Index: openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml,v diff -u -N -r1.30 -r1.31 --- openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 29 Sep 2006 10:28:02 -0000 1.30 +++ openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 24 Oct 2006 10:09:50 -0000 1.31 @@ -1,9 +1,10 @@ - + Component Identifier Act Identifier active + Activity Identifier Activity Structures Acts in play %count% Admin IMS LD @@ -35,6 +36,7 @@ Error parsing file Existing href Expression + Extra Activities Feedbach Title Feedback File name @@ -115,13 +117,20 @@ <li> impozzible </li> Activity Description Identifier Activity Structure Identifier + <br>\ + Go to the activity <a href=\"%activity_url%\">%activity_title%</a> (of the UoL <a href=\"%imsld_url%\">%imsld_title%</a> in the community <a href=\"$community_url\">%community_name%</a>) for further details. + <br>\ + Go to the UoL <a href=\"%imsld_url%\">$imsld_title</a> (in the <a href=\"%community_url%\">%community_name%</a> community) for further details. <br /> Warnings: <ul> %warnings% </ul> Change Property Value Identifier Change Property Value XML + %community_name%: %imsld_title% Complete Act Identifier Could not determine whit what program uncompress the file %upload_file% has. Aborting Couldn't determine if this is a well formed IMS-LD: %message% Creaginting new IMS-LD + Dear %recepient_name% <br> \ + %sender_name has% triggered this notification. Please do not replay to this email. <br> Email Propery Identifier Environment Identifier Error creating folder @@ -204,6 +213,7 @@ Referenced learning activity (%learning_activity_ref_ref%) in role part %identifier% does not exist. Referenced learning activity %learning_activity_ref_ref% in role part %identifier% is actually an activity structure. Referenced learning activity %learning_activity_ref_ref% in role part %identifier% is actually a support activity. + Referenced learning activity (%learning_activity_ref%) from notification does not exist Referenced role (%role_ref_ref%) in role part %identifier% does not exist. Referenced support activity %learning_activity_ref% is actually an activity structure!. Referenced support activity %support_activity_ref% is actually an activity structure!. @@ -223,6 +233,8 @@ The length must be %restriction_value% The referenced play in 'when play completed' in the method does not exist The referenced role part in 'when role part completed' of the act %identifier% does not exist + The refernced learning activity in the notification is actually a support activity! + The refernced support activity in the notification is actually a learning activity! The resource %resource_identifier% has a reference to a non existing file (%resource_href%). The value must be greather than %restriction_value% (inclusive) The value must be greather than %restriction_value% @@ -249,7 +261,7 @@ There must be exactly %multiplicity% %element_name% and there are %tree_length%. This is not supported, sorry. There was an error creating the folder. Aborting. There was an error creating the tmp_dir to unzip the file. - There was an error deleting the IMS LD $imsld_id. This is the error: <pre>%errmsg%</pre> + There was an error deleting the IMS LD %imsld_id%. This is the error: <pre>%errmsg%</pre> There was an error deleting the Run %run_id%. This is what the database said: <pre> %errmsg%</pre> There was an error generating the tmp_dir to unzip the file. There was an error parsing the manifest. Please correct it and try again. <br /><code>%errmsg%</code> @@ -259,6 +271,9 @@ <ul> Completed Activities <br /> <ul> %first_or_next% Activity: %activity_name% Uploading and processing your course, please wait... + %username% <br> \ + %sender_name% has triggered this notification. Please do not replay to this email. <br><br> \ + Go to the UoL: <a href=\"%imsld_url%\">%imsld_title%</a> (in the community: <a href=\"%community_url%\">%community_name%</a> community) for further details. Username Property Identifier Valid types are learning, support and structure More than one learning object in environment %identifier%. Just one used (the first one) @@ -276,6 +291,7 @@ Max Persons Method Identifier Min Persons + Moderator_Identifier User &nbsp;&nbsp;&nbsp;done New IMS-LD @@ -284,6 +300,9 @@ None None, please select Not defined + Notification + Notification Subject + Notifications Number of IMD LDs Number to Select Objectives 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 -N -r1.15 -r1.16 --- openacs-4/packages/imsld/sql/postgresql/imsld-create.sql 16 May 2006 09:24:35 -0000 1.15 +++ openacs-4/packages/imsld/sql/postgresql/imsld-create.sql 24 Oct 2006 10:09:50 -0000 1.16 @@ -11,3 +11,4 @@ \i imsld-production-delivery-create.sql \i imsld-production-delivery-package-create.sql \i imsld-tree-create.sql +\i imsld-level-c-create.sql 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 -N -r1.9 -r1.10 --- openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql 16 May 2006 09:24:35 -0000 1.9 +++ openacs-4/packages/imsld/sql/postgresql/imsld-drop.sql 24 Oct 2006 10:09:50 -0000 1.10 @@ -15,4 +15,6 @@ \i imsld-production-delivery-package-drop.sql -\i imsld-level-b-drop.sql \ No newline at end of file +\i imsld-level-b-drop.sql + +\i imsld-level-c-drop.sql Index: openacs-4/packages/imsld/sql/postgresql/imsld-level-a-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-level-a-create.sql,v diff -u -N -r1.7 -r1.8 --- openacs-4/packages/imsld/sql/postgresql/imsld-level-a-create.sql 20 Jul 2006 16:24:57 -0000 1.7 +++ openacs-4/packages/imsld/sql/postgresql/imsld-level-a-create.sql 24 Oct 2006 10:09:50 -0000 1.8 @@ -453,18 +453,13 @@ on delete cascade constraint imsld_semaildata_pk primary key, - send_mail_id integer - constraint imsld_semaildata_smailid_fk - references cr_items --imsld_send_mail_services - not null, role_id integer constraint imsld_semaildata_roleid_fk references cr_items --imsld_roles not null, mail_data text ); -create index imsld_sm_data_sm_id_idx on imsld_send_mail_data(send_mail_id); create index imsld_sm_data_role_id_idx on imsld_send_mail_data(role_id); create table imsld_conference_services ( Index: openacs-4/packages/imsld/sql/postgresql/imsld-level-b-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-level-b-create.sql,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/imsld/sql/postgresql/imsld-level-b-create.sql 20 Sep 2006 08:26:29 -0000 1.9 +++ openacs-4/packages/imsld/sql/postgresql/imsld-level-b-create.sql 24 Oct 2006 10:09:50 -0000 1.10 @@ -128,8 +128,8 @@ alter table imsld_on_completion add column change_property_value_xml text; -alter table imsld_send_mail_services add column email_property_id integer constraint imsld_emailprop_fk references cr_items; --imsld_properties -alter table imsld_send_mail_services add column username_property_id integer constraint imsld_unameprop_fk references cr_items; --imsld_properties +alter table imsld_send_mail_data add column email_property_id integer constraint imsld_semailprop_fk references cr_items; --imsld_properties +alter table imsld_send_mail_data add column username_property_id integer constraint imsld_sunameprop_fk references cr_items; --imsld_properties alter table imsld_complete_acts add column time_property_id integer constraint imsld_compa_timepropv_fk references cr_items; --imsld_properties Index: openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-level-c-create.sql 24 Oct 2006 10:09:50 -0000 1.1 @@ -0,0 +1,46 @@ +-- +-- IMS-LD Package Data Model for Level C +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date oct-2006 +-- + +create table imsld_notifications ( + notification_id integer + constraint imsld_notif_id_fk + references cr_revisions + on delete cascade + constraint imsld_notif_id_pk + primary key, + imsld_id integer + constraint imsld_notif_ii_fk + references cr_items --imsld_imslds + not null, + activity_id integer + constraint imsld_notif_act_fk + references cr_items --imsld_learning_activities/imsld_support_activities + not null, + subject text +); + +create index imsld_notif_ii_idx on imsld_notifications(imsld_id); +create index imsld_notif_act_idx on imsld_notifications(activity_id); + +comment on table imsld_notifications is ' +Notifications of the on_completion elements are stored in this table. The rest of notificacions are stored along with the XML which contains them and dealed with in the running stage.'; + +create table imsld_notifications_history ( + run_id integer + references imsld_runs, + from_user_id integer + references parties, + notification_date timestamptz, + target_activity_id integer + references cr_revisions, + to_user_id integer + references parties +); + +comment on table imsld_notifications_history is ' +Table used to keep track of the notifications'; + Index: openacs-4/packages/imsld/sql/postgresql/imsld-level-c-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-level-c-drop.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/imsld/sql/postgresql/imsld-level-c-drop.sql 24 Oct 2006 10:09:50 -0000 1.1 @@ -0,0 +1,10 @@ +-- +-- IMS-LD Package Data Model Drop for Level C +-- +-- @author jopez@inv.it.uc3m.es +-- @creation-date oct-2006 +-- + +drop table imsld_notifications cascade; + +drop table imsld_notifications_history cascade; Index: openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl,v diff -u -N -r1.19 -r1.20 --- openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 10 Oct 2006 10:58:02 -0000 1.19 +++ openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 24 Oct 2006 10:09:51 -0000 1.20 @@ -739,7 +739,79 @@ } imsld::runtime::property::property_value_set -run_id $run_id -user_id $user_id -identifier [$propertyref getAttribute {ref}] -value $propertyValue } - {notification} {} + {notification} { + set activity_id "" + set subjectValue "" + set subjectNode [$executeNode selectNodes {*[local-name()='subject']}] + if { [llength $subjectNode] } { + set subjectValue [$subjectNode text] + } + + set larefNode [$executeNode selectNodes {*[local-name()='learning-activity-ref']}] + if { [llength $larefNode] } { + set larefValue [$larefNode getAttribute ref ""] + set activityIdentifier $larefValue + } + + set sarefNode [$executeNode selectNodes {*[local-name()='support-activity-ref']}] + if { [llength $sarefNode] } { + set sarefValue [$sarefNode getAttribute ref ""] + set activityIdentifier $sarefValue + } + + if { [info exists activityIdentifier] } { + set activity_id [db_string get_activity_id { + select owner_id + from imsld_attribute_instances + where identifier = :activityIdentifier + and run_id = :run_id + and user_id = :user_id + }] + } + + foreach emailDataNode [$executeNode selectNodes {*[local-name()='email-data']}] { + + set emailPropertyRef [$emailDataNode getAttribute email-property-ref ""] + set usernamePropertyRef [$emailDataNode getAttribute username-property-ref ""] + set roleRef [[$emailDataNode selectNodes {*[local-name()='role-ref']}] getAttribute ref ""] + set username "" + set email_address "" + + if { ![empty_string_p $usernamePropertyRef] } { + # get the username proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single username + set username [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -identifier $usernamePropertyRef] + } + + if { ![empty_string_p $emailPropertyRef] } { + # get the email proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single email address. + # we also send the notificaiton to the rest of the role members + set email_address [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -identifier $emailPropertyRef] + } + + db_1row get_context_info { + select role_id, ii.imsld_id + from imsld_roles ir, imsld_componentsi ic, imsld_imsldsi ii, imsld_runs run + where ir.identifier = :roleRef + and ir.component_id = ic.item_id + and ic.imsld_id = ii.item_id + and ii.imsld_id = run.imsld_id + and run.run_id = :run_id + } + + imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subjectValue \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $user_id + } + } } } } 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 -N -r1.37 -r1.38 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 4 Oct 2006 14:31:13 -0000 1.37 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 24 Oct 2006 10:09:51 -0000 1.38 @@ -145,7 +145,6 @@ # send mail data content::type::new -content_type imsld_send_mail_data -supertype content_revision -pretty_name "#imsld.IMS-LD_Sendmail_Data#" -pretty_plural "#imsld.IMS-LD_Sendmail_Data#" -table_name imsld_send_mail_data -id_column data_id - content::type::attribute::new -content_type imsld_send_mail_data -attribute_name send_mail_id -datatype number -pretty_name "#imsld.Sendmail_Identifier#" -column_spec "integer" content::type::attribute::new -content_type imsld_send_mail_data -attribute_name role_id -datatype number -pretty_name "#imsld.Role_Identifier#" -column_spec "integer" content::type::attribute::new -content_type imsld_send_mail_data -attribute_name mail_data -datatype string -pretty_name "#imsld.Mail_Data#" -column_spec "varchar(4000)" @@ -156,7 +155,7 @@ content::type::attribute::new -content_type imsld_conference_service -attribute_name conference_type -datatype string -pretty_name "#imsld.Conference_Type#" -column_spec "char(12)" content::type::attribute::new -content_type imsld_conference_service -attribute_name imsld_item_id -datatype number -pretty_name "#imsld.Item_Identifier#" -column_spec "integer" content::type::attribute::new -content_type imsld_conference_service -attribute_name manager_id -datatype number -pretty_name "#imsld.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 moderator_id -datatype number -pretty_name "#imsld.Moderator_Identifier#" -column_spec "integer" # methods content::type::new -content_type imsld_method -supertype content_revision -pretty_name "#imsld.IMS-LD_Method#" -pretty_plural "#imsld.IMS-LD_Methods#" -table_name imsld_methods -id_column method_id @@ -282,10 +281,10 @@ # complete acts content::type::attribute::new -content_type imsld_complete_act -attribute_name time_property_id -datatype number -pretty_name "#imsld.lt_Time_Property_Identif#" -column_spec "integer" content::type::attribute::new -content_type imsld_complete_act -attribute_name when_condition_true_id -datatype number -pretty_name "#imsld.When_Condition_True#" -column_spec "integer" - content::type::attribute::new -content_type imsld_complete_act -attribute_name when_prop_val_is_set_xml -datatype string -pretty_name "[_ imsld.lt_When_property_value_i]" -column_spec "varchar(4000)" + content::type::attribute::new -content_type imsld_complete_act -attribute_name when_prop_val_is_set_xml -datatype string -pretty_name "#imsld.lt_When_property_value_i#" -column_spec "varchar(4000)" # on completion - content::type::attribute::new -content_type imsld_on_completion -attribute_name change_property_value_xml -datatype string -pretty_name "[_ imsld.lt_Change_Property_Value_1]" -column_spec "varchar(4000)" + content::type::attribute::new -content_type imsld_on_completion -attribute_name change_property_value_xml -datatype string -pretty_name "#imsld.lt_Change_Property_Value_1#" -column_spec "varchar(4000)" # monitor service content::type::new -content_type imsld_monitor_service -supertype content_revision -pretty_name "#imsld.lt_IMS-LD_Monitor_Servic#" -pretty_plural "#imsld.lt_IMS-LD_Monitor_Servic_1#" -table_name imsld_monitor_services -id_column monitor_id @@ -295,9 +294,9 @@ content::type::attribute::new -content_type imsld_monitor_service -attribute_name self_p -datatype string -pretty_name "#imsld.Self#" -column_spec "char(1)" content::type::attribute::new -content_type imsld_monitor_service -attribute_name imsld_item_id -datatype number -pretty_name "#imsld.lt_IMS-LD_Item_Identifie#" -column_spec "integer" - # send mail service - content::type::attribute::new -content_type imsld_send_mail_service -attribute_name email_property_id -datatype number -pretty_name "#imsld.lt_Email_Propery_Identif#" -column_spec "integer" - content::type::attribute::new -content_type imsld_send_mail_service -attribute_name username_property_id -datatype number -pretty_name "#imsld.lt_Username_Property_Ide#" -column_spec "integer" + # send mail data + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name email_property_id -datatype number -pretty_name "#imsld.lt_Email_Propery_Identif#" -column_spec "integer" + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name username_property_id -datatype number -pretty_name "#imsld.lt_Username_Property_Ide#" -column_spec "integer" # when condition true content::type::new -content_type imsld_when_condition_true -supertype content_revision -pretty_name "#imsld.lt_IMS-LD_When_Condition#" -pretty_plural "#imsld.lt_IMS-LD_When_Condition_1#" -table_name imsld_when_condition_true -id_column when_condition_true_id @@ -310,6 +309,15 @@ content::type::attribute::new -content_type imsld_condition -attribute_name method_id -datatype number -pretty_name "#imsld.Method_Identifier#" -column_spec "integer" content::type::attribute::new -content_type imsld_condition -attribute_name condition_xml -datatype string -pretty_name "#imsld.Condition#" -column_spec "varchar(4000)" + + ### IMS-LD LEVEL C + + # notifications + content::type::new -content_type imsld_notification -supertype content_revision -pretty_name "#imsld.Notification#" -pretty_plural "#imsld.Notifications#" -table_name imsld_notifications -id_column notification_id + + content::type::attribute::new -content_type imsld_notification -attribute_name imsld_id -datatype number -pretty_name "#imsld.IMS-LD_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_notification -attribute_name activity_id -datatype number -pretty_name "#imsld.Activity_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_notification -attribute_name subject -datatype string -pretty_name "#imsld.Notification_Subject#" -column_spec "varchar(4000)" } ad_proc -public imsld::install::create_group_types { @@ -530,6 +538,28 @@ content_item 0 {} \ content_item 0 {} + # Imsld on completion - notifications + rel_types::new imsld_on_comp_notif_rel "On Completion - Notification" "On Completion - Notifications" \ + content_item 0 {} \ + content_item 0 {} + + # Imsld notification - email datas + rel_types::new imsld_notif_email_rel "Notification - Email Data" "Notification - Email Datas" \ + content_item 0 {} \ + content_item 0 {} + + # Imsld send mail service - email datas + rel_types::new imsld_send_mail_serv_data_rel "Send Mail Service - Email Data" "Send Mail Service - Email Datas" \ + content_item 0 {} \ + content_item 0 {} + + # Level C, notifications: Runtime assigned activities + # Notifications may set to TRUE the visibility attribute of ANY activity for a given role, + # and by any we mean that the activity does not have to be assigned to a role part associated with that role. + # Therefore we crate this rel type where we map the role with the runtime assigned activities + rel_types::new imsld_run_time_activities_rel "Role - Activity" "Role - Activities" \ + content_revision 0 {} \ + content_revision 0 {} } ad_proc -public imsld::uninstall::delete_rels { @@ -566,6 +596,9 @@ imsld::rel_type_delete -rel_type imsld_prop_wpv_is_rel imsld::rel_type_delete -rel_type imsld_role_cond_rel imsld::rel_type_delete -rel_type imsld_ilm_cond_rel + imsld::rel_type_delete -rel_type imsld_on_comp_notif_rel + imsld::rel_type_delete -rel_type imsld_notif_email_rel + imsld::rel_type_delete -rel_type imsld_send_mail_serv_data_rel } ad_proc -public imsld::uninstall::delete_ext_rels { @@ -582,7 +615,12 @@ } { ### Attributes - + + ### IMS-LD Level C + content::type::attribute::delete -content_type imsld_notification -attribute_name imsld_id + content::type::attribute::delete -content_type imsld_notification -attribute_name activity_id + content::type::attribute::delete -content_type imsld_notification -attribute_name subject + ### IMS-LD level B # properties @@ -615,9 +653,9 @@ content::type::attribute::delete -content_type imsld_monitor_service -attribute_name self_p content::type::attribute::delete -content_type imsld_monitor_service -attribute_name imsld_item_id - # send mail service - content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name email_property_id - content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name username_property_id + # send mail data + content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name email_property_id + content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name username_property_id # when condition true content::type::attribute::delete -content_type imsld_when_condition_true -attribute_name role_id @@ -731,7 +769,6 @@ content::type::attribute::delete -content_type imsld_send_mail_service -attribute_name parameters # send mail data - content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name send_mail_id content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name role_id content::type::attribute::delete -content_type imsld_send_mail_data -attribute_name mail_data @@ -822,6 +859,9 @@ ### Content Types + ### IMS-LD Level C + content::type::delete -content_type imsld_notification -drop_table_p t + ### IMS-LD Level B content::type::delete -content_type imsld_property -drop_table_p t content::type::delete -content_type imsld_property_groups -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 -N -r1.60 -r1.61 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 4 Oct 2006 14:31:13 -0000 1.60 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 24 Oct 2006 10:09:51 -0000 1.61 @@ -935,7 +935,7 @@ } ad_proc -public imsld::parse::parse_and_create_global_def { - -global_def_node + {-global_def_node ""} -identifier -existing_href -component_id @@ -949,10 +949,10 @@ Returns a list with the new global_definition_id (item_id, actually a property_id) created if there were no errors, or 0 and an explanation messge if there was an error. - @param global_def_node global_def node to parse + @option global_def_node global_def node to parse @param identifier @param existing_href - @component_id Comoponent id of the one which owns the property + @param component_id Comoponent id of the one which owns the property @param type Type of the property defined by this global definition, which can be globpers or glob @param manifest Manifest tree @param manifest_id Manifest ID or the manifest being parsed @@ -961,19 +961,27 @@ } { upvar files_struct_list files_struct_list - set uri [imsld::parse::get_attribute -node $global_def_node -attr_name uri] - set title [imsld::parse::get_title -node $global_def_node -prefix imsld] - set datatype [$global_def_node selectNodes "*\[local-name()='datatype'\]" ] - imsld::parse::validate_multiplicity -tree $global_def_node -multiplicity 1 -element_name "global-definition datatype" -equal - set datatype [string tolower [imsld::parse::get_attribute -node $global_def_node -attr_name datatype]] - set initial_value [$global_def_node selectNodes "*\[local-name()='initial-value'\]"] - imsld::parse::validate_multiplicity -tree $initial_value -multiplicity 1 -element_name "global-definition initial-value" -lower_than - if { [llength $initial_value] } { - set initial_value [imsld::parse::get_element_text -node $initial_value] + if { ![empty_string_p $global_def_node] } { + set uri [imsld::parse::get_attribute -node $global_def_node -attr_name uri] + set title [imsld::parse::get_title -node $global_def_node -prefix imsld] + set datatype [$global_def_node selectNodes "*\[local-name()='datatype'\]" ] + imsld::parse::validate_multiplicity -tree $global_def_node -multiplicity 1 -element_name "global-definition datatype" -equal + set datatype [string tolower [imsld::parse::get_attribute -node $global_def_node -attr_name datatype]] + set initial_value [$global_def_node selectNodes "*\[local-name()='initial-value'\]"] + imsld::parse::validate_multiplicity -tree $initial_value -multiplicity 1 -element_name "global-definition initial-value" -lower_than + if { [llength $initial_value] } { + set initial_value [imsld::parse::get_element_text -node $initial_value] + } else { + set initial_value "" + } } else { + set uri "" + set datatype "" set initial_value "" + set title "" } + set globpers_property_id [imsld::item_revision_new -attributes [list [list component_id $component_id] \ [list identifier $identifier] \ [list existing_href $existing_href] \ @@ -985,19 +993,21 @@ -title $title \ -parent_id $parent_id] - set restrictions [$global_def_node selectNodes "*\[local-name()='restriction'\]"] - foreach restriction $restrictions { - set restriction_list [imsld::parse::parse_and_create_restriction -manifest $manifest \ - -property_id $globpers_property_id \ - -manifest_id $manifest_id \ - -restriction_node $restriction \ - -parent_id $parent_id \ - -tmp_dir $tmp_dir] - - set restriction_id [lindex $restriction_list 0] - if { !$restriction_id } { - # an error happened, abort and return the list whit the error - return $restriction_list + if { ![empty_string_p $global_def_node] } { + set restrictions [$global_def_node selectNodes "*\[local-name()='restriction'\]"] + foreach restriction $restrictions { + set restriction_list [imsld::parse::parse_and_create_restriction -manifest $manifest \ + -property_id $globpers_property_id \ + -manifest_id $manifest_id \ + -restriction_node $restriction \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set restriction_id [lindex $restriction_list 0] + if { !$restriction_id } { + # an error happened, abort and return the list whit the error + return $restriction_list + } } } return $globpers_property_id @@ -1275,12 +1285,15 @@ set gp_existing [$globpers_property selectNodes "*\[local-name()='existing'\]"] imsld::parse::validate_multiplicity -tree $gp_existing -multiplicity 1 -element_name "existing(globpers)" -lower_than if { [llength $gp_existing] } { - set gp_existing_href [imsld::parse::get_attribute -node $gp_exiting -attr_name href] + set gp_existing_href [imsld::parse::get_attribute -node $gp_existing -attr_name href] } else { set gp_existing_href "" } set global_def [$globpers_property selectNodes "*\[local-name()='global-definition'\]"] + if { ![empty_string_p $global_def] } { + imsld::parse::validate_multiplicity -tree $global_def -multiplicity 1 -element_name "global-definition(globpers)" -equal + } set global_def_list [imsld::parse::parse_and_create_global_def -type globpers \ -identifier $gp_identifier \ -existing_href $gp_existing_href \ @@ -1686,13 +1699,14 @@ set username_property_id "" } - set email_data_id [imsld::item_revision_new -attributes [list [list send_mail_id $send_mail_id] \ - [list role_id $role_id] \ + set email_data_id [imsld::item_revision_new -attributes [list [list role_id $role_id] \ [list mail_data {}] \ [list email_property_id $email_property_id] \ [list username_property_id $username_property_id]] \ -content_type imsld_send_mail_data \ -parent_id $parent_id] + # map email_data with the service + relation_add imsld_send_mail_serv_data_rel $send_mail_id $email_data_id } } @@ -1874,7 +1888,7 @@ # monitor: role-ref set role_ref [$monitor_service selectNodes "*\[local-name()='role-ref'\]"] - imsld::parse::validate_multiplicity -tree $role_ref -multiplicity 1 -element_name role-ref -equal + imsld::parse::validate_multiplicity -tree $role_ref -multiplicity 1 -element_name "role-ref (monitor service)" -equal set ref [imsld::parse::get_attribute -node $role_ref -attr_name ref] if { ![db_0or1row get_role_id { select ir.item_id as role_id @@ -2151,6 +2165,7 @@ @param tmp_dir Temporary directory where the files were exctracted } { upvar files_struct_list files_struct_list + upvar warnings warnings # get the info of the learning activity and create it set identifier [imsld::parse::get_attribute -node $activity_node -attr_name identifier] @@ -2329,6 +2344,29 @@ -content_type imsld_learning_activity \ -title $title \ -parent_id $parent_id] + + # to avoid infinite loops, take the notifications parsing out + if { [llength $on_completion] } { + # Learning Activity: On Completion: Notifications + set notifications_list [$on_completion selectNodes "*\[local-name()='notification'\]"] + if { [llength $notifications_list] } { + foreach notification $notifications_list { + set notification_list [imsld::parse::parse_and_create_notification -component_id $component_id \ + -notification_node $notification \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set notification_id [lindex $notification_list 0] + if { !$notification_id } { + # an error occurred, return it + return $notification_list + } + # map on_completion with the notif + relation_add imsld_on_comp_notif_rel $on_completion_id $notification_id + } + } + } # Learning Activity: Environments set environment_refs [$activity_node selectNodes "*\[local-name()='environment-ref'\]"] @@ -2378,6 +2416,7 @@ @option parent_role_id Parent role identifier. Default to null } { upvar files_struct_list files_struct_list + upvar warnings warnings # get the info of the support activity and create it set identifier [imsld::parse::get_attribute -node $activity_node -attr_name identifier] @@ -2520,6 +2559,30 @@ -title $title \ -parent_id $parent_id] + # to avoid infinite loops, take the notifications parsing out + if { [llength $on_completion] } { + # Support Activity: On Completion: Notifications + set notifications_list [$on_completion selectNodes "*\[local-name()='notification'\]"] + if { [llength $notifications_list] } { + foreach notification $notifications_list { + set notification_list [imsld::parse::parse_and_create_notification -component_id $component_id \ + -notification_node $notification \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set notification_id [lindex $notification_list 0] + if { !$notification_id } { + # an error occurred, return it + return $notification_list + } + + # map on_completion with the notif + relation_add imsld_on_comp_notif_rel $on_completion_id $notification_id + } + } + } + # Support Activity: Role ref set role_ref_list [$activity_node selectNodes "*\[local-name()='role-ref'\]"] foreach role_ref $role_ref_list { @@ -2815,7 +2878,6 @@ # search in the manifest ... set organizations [$manifest selectNodes {*[local-name()='organizations']}] set activity_structures [$organizations selectNodes {*[local-name()='learning-design']/*[local-name()='components']/*[local-name()='activities']/*[local-name()='activity-structure']}] -# set activity_structures [[[[$organizations child all imsld:learning-design] child all imsld:components] child all imsld:activities] child all imsld:activity-structure] set found_p 0 foreach referenced_activity_structure $activity_structures { @@ -3359,7 +3421,31 @@ -content_type imsld_act \ -parent_id $parent_id \ -title $title] + + # to avoid infinite loops, take the notifications parsing out + if { [llength $on_completion] } { + # Act: On Completion: Notifications + set notifications_list [$on_completion selectNodes "*\[local-name()='notification'\]"] + if { [llength $notifications_list] } { + foreach notification $notifications_list { + set notification_list [imsld::parse::parse_and_create_notification -component_id $component_id \ + -notification_node $notification \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set notification_id [lindex $notification_list 0] + if { !$notification_id } { + # an error occurred, return it + return $notification_list + } + # map on_completion with the notif + relation_add imsld_on_comp_notif_rel $on_completion_id $notification_id + } + } + } + # Act: Role Parts set role_parts [$act_node selectNodes "*\[local-name()='role-part'\]"] imsld::parse::validate_multiplicity -tree $role_parts -multiplicity 1 -element_name role-parts -greather_than @@ -3543,6 +3629,29 @@ -title $title \ -parent_id $parent_id] + # to avoid infinite loops, take the notifications parsing out + if { [llength $on_completion] } { + # Play: On Completion: Notifications + set notifications_list [$on_completion selectNodes "*\[local-name()='notification'\]"] + if { [llength $notifications_list] } { + foreach notification $notifications_list { + set notification_list [imsld::parse::parse_and_create_notification -method_id $method_id \ + -notification_node $notification \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + set notification_id [lindex $notification_list 0] + if { !$notification_id } { + # an error occurred, return it + return $notification_list + } + # map on_completion with the notif + relation_add imsld_on_comp_notif_rel $on_completion_id $notification_id + } + } + } + # Play: Acts set acts [$play_node selectNodes "*\[local-name()='act'\]"] imsld::parse::validate_multiplicity -tree $acts -multiplicity 1 -element_name acts -greather_than @@ -3568,6 +3677,196 @@ return $play_id } +ad_proc -public imsld::parse::parse_and_create_notification { + -component_id + -method_id + -notification_node:required + -manifest:required + -manifest_id:required + -parent_id:required + -tmp_dir:required +} { + Parse a notification and stores all the information in the database. + + Returns a list with the new notification_id (item_id) created if there were no errors, or 0 and an explanation messge if there was an error. + + @option component_id Component identifier which the notification belongs + @option imsld_id IMS-LD identifier which this notification belongs + @param manifest Manifest tree + @param manifest_id Manifest ID or the manifest being parsed + @param notification_node The notification node to parse + @param parent_id Parent folder ID + @param tmp_dir Temporary directory where the files were exctracted +} { + upvar files_struct_list files_struct_list + upvar warnings warnings + + if { [info exists component_id] } { + db_1row get_info_from_comp { *SQL* } + } + if { [info exists method_id] } { + db_1row get_info_from_method { *SQL* } + } + + set subject_node [$notification_node selectNodes "*\[local-name()='subject'\]"] + imsld::parse::validate_multiplicity -tree $subject_node -multiplicity 1 -element_name "subject (notification)" -equal + set subject [imsld::parse::get_element_text -node $subject_node] + + # notification: learning-activity-ref + set la_ref [$notification_node selectNodes "*\[local-name()='learning-activity-ref'\]"] + set activity_id "" + if { [llength $la_ref] } { + imsld::parse::validate_multiplicity -tree $la_ref -multiplicity 1 -element_name learning-activity-ref(notification) -equal + # search in the already parsed activities + + set learning_activity_ref [imsld::parse::get_attribute -node $la_ref -attr_name ref] + if { ![db_0or1row la_get_learning_activity_id { *SQL* }] } { + # may be the reference is wrong, search in the support activityes before returning an error + if { [db_0or1row la_get_learning_support_activity_id { *SQL* }] } { + # warning message + append warnings "
  • [_ imsld.lt_The_refernced_learnin]
  • " + + } else { + # search in the manifest ... + set organizations [$manifest selectNodes {*[local-name()='organizations']}] + set learning_activities [$organizations selectNodes {*[local-name()='learning-design']/*[local-name()='components']/*[local-name()='activities']/*[local-name()='learning-activity']}] + + set found_p 0 + foreach referenced_learning_activity $learning_activities { + set referenced_identifier [imsld::parse::get_attribute -node $referenced_learning_activity -attr_name identifier] + if { [string eq $learning_activity_ref $referenced_identifier] } { + set found_p 1 + set referenced_learning_activity_node $referenced_learning_activity + } + } + if { $found_p } { + # ok, let's create the learning activity + set learning_activity_ref_list [imsld::parse::parse_and_create_learning_activity -activity_node $referenced_learning_activity_node \ + -component_id $component_id \ + -manifest_id $manifest_id \ + -manifest $manifest \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set activity_id [lindex $learning_activity_ref_list 0] + if { !$activity_id } { + # there is an error, abort and return the list with the error + return $learning_activity_ref_list + } + } else { + # error, referenced learning activity does not exist + return [list 0 "[_ imsld.lt_Referenced_learning_a_6]"] + } + + } + } + } + + # notification: support-activity-ref + set sa_ref [$notification_node selectNodes "*\[local-name()='support-activity-ref'\]"] + if { [llength $sa_ref] } { + imsld::parse::validate_multiplicity -tree $sa_ref -multiplicity 1 -element_name support-activity-ref(notification) -equal + # search in the already parsed activities + + set support_activity_ref [imsld::parse::get_attribute -node $sa_ref -attr_name ref] + if { ![db_0or1row sa_get_support_activity_id { *SQL* }] } { + # may be the reference is wrong, search in the learning activityes before returning an error + if { [db_0or1row sa_get_learning_activity_id { *SQL* }] } { + # warning message + append warnings "
  • [_ imsld.lt_The_refernced_support]
  • " + + } else { + # search in the manifest ... + set organizations [$manifest selectNodes {*[local-name()='organizations']}] + set support_activities [$organizations selectNodes {*[local-name()='learning-design']/*[local-name()='components']/*[local-name()='activities']/*[local-name()='support-activity']}] + + set found_p 0 + foreach referenced_support_activity $support_activities { + set referenced_identifier [imsld::parse::get_attribute -node $referenced_support_activity -attr_name identifier] + if { [string eq $support_activity_ref $referenced_identifier] } { + set found_p 1 + set referenced_support_activity_node $referenced_support_activity + } + } + if { $found_p } { + # ok, let's create the support activity + set support_activity_ref_list [imsld::parse::parse_and_create_support_activity -activity_node $referenced_support_activity_node \ + -component_id $component_id \ + -manifest_id $manifest_id \ + -manifest $manifest \ + -parent_id $parent_id \ + -tmp_dir $tmp_dir] + + set activity_id [lindex $learning_activity_ref_list 0] + if { !$activity_id } { + # there is an error, abort and return the list with the error + return $support_activity_ref_list + } + } else { + # error, referenced learning activity does not exist + return [list 0 "<#_ Referenced support activity (%support_activity_ref%) from notification does not exist"] + } + + } + } + } + + # if we reached this point, the referenced activity is stored in the variable activity_id + # lets create create the notification + set notification_id [imsld::item_revision_new -attributes [list [list activity_id $activity_id] \ + [list subject $subject] \ + [list imsld_id $imsld_id]] \ + -content_type imsld_notification \ + -parent_id $parent_id] + + # notification: email data + set email_data_list [$notification_node selectNodes "*\[local-name()='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 selectNodes "*\[local-name()='role-ref'\]"] + imsld::parse::validate_multiplicity -tree $role_ref -multiplicity 1 -element_name role-ref(email-data) -equal + set ref [imsld::parse::get_attribute -node $role_ref -attr_name ref] + + if { ![db_0or1row get_role_id_from_ref { *SQL* }] } { + # there is no role with that identifier, return the error + return [list 0 "[_ imsld.lt_There_is_no_role_with]"] + } + + # email-property-ref + set email_property_ref [imsld::parse::get_attribute -node $email_data -attr_name email-property-ref] + if { ![string eq $email_property_ref ""] } { + if { ![db_0or1row get_email_property_id { *SQL* }] } { + # there is no property with that identifier, return the error + return [list 0 "[_ imsld.lt_There_is_no_property__1]"] + } + } else { + set email_property_id "" + } + + # username-property-ref + set username_property_ref [imsld::parse::get_attribute -node $email_data -attr_name username-property-ref] + if { ![string eq $username_property_ref ""] } { + if { ![db_0or1row get_username_property_id { *SQL* }] } { + # there is no property with that identifier, return the error + return [list 0 "[_ imsld.lt_There_is_no_property__2]"] + } + } else { + set username_property_id "" + } + + set email_data_id [imsld::item_revision_new -attributes [list [list role_id $role_id] \ + [list mail_data {}] \ + [list email_property_id $email_property_id] \ + [list username_property_id $username_property_id]] \ + -content_type imsld_send_mail_data \ + -parent_id $parent_id] + + # do the mappings + relation_add imsld_notif_email_rel $notification_id $email_data_id + } + return $notification_id +} + ad_proc -public imsld::parse::parse_and_create_if_then_else { -condition_node -manifest @@ -3867,6 +4166,8 @@ } # Componetns: Activities + # N.B.: With the level C and notificaitons, it is possible to make a reference to an 'uncreated' + # learning or support activity. Therefore we must check before if the activity has not been created set activities [$components selectNodes "*\[local-name()='activities'\]"] if { [llength $activities] } { imsld::parse::validate_multiplicity -tree $activities -multiplicity 1 -element_name components -equal @@ -3876,31 +4177,49 @@ imsld::parse::validate_multiplicity -tree $learning_activities -multiplicity 1 -element_name learning-activities -greather_than foreach learning_activity $learning_activities { - set learning_activity_list [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] - if { ![lindex $learning_activity_list 0] } { + set la_identifier [imsld::parse::get_attribute -node $learning_activity -attr_name identifier] + + if { ![db_0or1row already_crated_la_p { + select 1 + from imsld_learning_activities + where identifier = :la_identifier + and component_id = :component_id + }] } { + set learning_activity_list [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] + if { ![lindex $learning_activity_list 0] } { # an error happened, abort and return the list whit the error - return $learning_activity_list + return $learning_activity_list + } } } # Componets: Activities: Support Activities set support_activities [$activities selectNodes "*\[local-name()='support-activity'\]"] foreach support_activity $support_activities { - set support_activity_list [imsld::parse::parse_and_create_support_activity -component_id $component_id \ - -activity_node $support_activity \ - -manifest $manifest \ - -manifest_id $manifest_id \ - -parent_id $cr_folder_id \ - -tmp_dir $tmp_dir] - if { ![lindex $support_activity_list 0] } { + set sa_identifier [imsld::parse::get_attribute -node $support_activity -attr_name identifier] + + if { ![db_0or1row already_crated_sa_p { + select 1 + from imsld_support_activities + where identifier = :sa_identifier + and component_id = :component_id + }] } { + set support_activity_list [imsld::parse::parse_and_create_support_activity -component_id $component_id \ + -activity_node $support_activity \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir] + if { ![lindex $support_activity_list 0] } { # an error happened, abort and return the list whit the error - return $support_activity_list + return $support_activity_list + } } } @@ -4020,6 +4339,29 @@ [list complete_act_id $complete_act_id] \ [list on_completion_id $on_completion_id]]] + # to avoid infinite loops, take the notifications parsing out + if { [llength $on_completion] } { + # Method: On Completion: Notifications + set notifications_list [$on_completion selectNodes "*\[local-name()='notification'\]"] + if { [llength $notifications_list] } { + foreach notification $notifications_list { + set notification_list [imsld::parse::parse_and_create_notification -method_id $method_id \ + -notification_node $notification \ + -manifest $manifest \ + -manifest_id $manifest_id \ + -parent_id $cr_folder_id \ + -tmp_dir $tmp_dir] + set notification_id [lindex $notification_list 0] + if { !$notification_id } { + # an error occurred, return it + return $notification_list + } + # map on_completion with the notif + relation_add imsld_on_comp_notif_rel $on_completion_id $notification_id + } + } + } + # Method: Plays set plays [$method selectNodes "*\[local-name()='play'\]"] imsld::parse::validate_multiplicity -tree $plays -multiplicity 1 -element_name plays -greather_than Index: openacs-4/packages/imsld/tcl/imsld-parse-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-parse-procs.xql,v diff -u -N -r1.5 -r1.6 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.xql 13 Jul 2006 13:11:43 -0000 1.5 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.xql 24 Oct 2006 10:09:51 -0000 1.6 @@ -424,7 +424,117 @@ + + + select imsld_id + from imsld_componentsi + where item_id = :component_id + + + + + + + + select ico.item_id as component_id + im.imsld_id + from imsld_methodsi im, + imsld_componetnsi ico + where im.item_id = :method_id + and im.imsld_id = ico.imsld_id + + + + + + + + select item_id as activity_id, + activity_id as learning_activity_id + from imsld_learning_activitiesi + where identifier = :learning_activity_ref + and content_revision__is_live(activity_id) = 't' + and component_id = :component_id + + + + + + + + select item_id as activity_id, + activity_id as support_activity_id + from imsld_support_activitiesi + where identifier = :learning_activity_ref + and content_revision__is_live(activity_id) = 't' + and component_id = :component_id + + + + + + + + select item_id as activity_id, + activity_id as support_activity_id + from imsld_support_activitiesi + where identifier = :support_activity_ref + and content_revision__is_live(activity_id) = 't' + and component_id = :component_id + + + + + + + + select item_id as activity_id, + activity_id as learning_activity_id + from imsld_learning_activitiesi + where identifier = :support_activity_ref + and content_revision__is_live(activity_id) = 't' + and component_id = :component_id + + + + + + + + select ir.item_id as role_id + from imsld_rolesi ir + where ir.identifier = :ref + and content_revision__is_live(ir.role_id) = 't' + and ir.component_id = :component_id + + + + + + + + select item_id as email_property_id + from imsld_propertiesi + where identifier = :email_property_ref + and content_revision__is_live(property_id) = 't' + and component_id = :component_id + + + + + + + + select item_id as username_property_id + from imsld_propertiesi + where identifier = :username_property_ref + and content_revision__is_live(property_id) = 't' + and component_id = :component_id + + + + select item_id as play_id Index: openacs-4/packages/imsld/tcl/imsld-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.tcl,v diff -u -N -r1.88 -r1.89 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 10 Oct 2006 10:58:02 -0000 1.88 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 24 Oct 2006 10:09:51 -0000 1.89 @@ -644,10 +644,119 @@ -is_live "t" \ -package_id $package_id] } - return $item_id } +ad_proc -public imsld::do_notification { + -imsld_id + -run_id + -subject + -activity_id + {-username ""} + {-email_address ""} + -role_id + {-user_id ""} +} { + @param imsld_id +} { + set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] + + # notifications + set community_id [dotlrn_community::get_community_id] + set community_name [dotlrn_community::get_community_name $community_id] + set community_url [ns_conn location][dotlrn_community::get_community_url $community_id] + set imsld_title [content::revision::revision_name -revision_id $imsld_id] + set imsld_url "[ns_conn location][lindex [site_node::get_url_from_object_id -object_id [ad_conn package_id]] 0]imsld-frameset?run_id=$run_id" + set sender_name [party::name -party_id $user_id] + set sender_email [party::email -party_id $user_id] + + if { [string eq "" $subject] } { + set subject "[_ imsld.lt_community_name_imsld_]" + } + + # get the activity type + if { ![empty_string_p $activity_id] } { + # get the activity_type + if { [db_0or1row learning_activity_p { *SQL* }] } { + set activity_type learning + set where_clause [db_map learning_activity] + } else { + set activity_type support + set where_clause [db_map support_activity] + } + } + + if { ![empty_string_p $email_address] && [util_email_valid_p $email_address] } { + # Use this to build up extra mail headers + set extra_headers [ns_set new] + + # This should disable most auto-replies. + ns_set put $extra_headers Precedence list + + set body_html "[_ imsld.lt_username_br__________]" + + set message_data [build_mime_message [ad_html_to_text $body_html] $body_html] + ns_set put $extra_headers MIME-Version [ns_set get $message_data MIME-Version] + ns_set put $extra_headers Content-ID [ns_set get $message_data Content-ID] + ns_set put $extra_headers Content-Type [ns_set get $message_data Content-Type] + set content [ns_set get $message_data body] + + acs_mail_lite::send -to_addr $email_address \ + -from_addr $sender_email \ + -subject $subject \ + -body $content \ + -extraheaders $extra_headers + } else { + # invalid mail! + ns_log notice "imsld::do_notification: Not sending notification because the email is invalid!" + } + + # if activity_id is not null: + # add the activity to the rel imsld_run_time_activities_rel + if { ![string eq "" $activity_id] && ![db_0or1row already_mapped { *SQL* }] } { + # map the activity to the role + relation_add imsld_run_time_activities_rel $role_id $activity_id + } + # send a notification (email) to each user in the role + foreach recipient_user_id [imsld::roles::get_users_in_role -role_id $role_id -run_id $run_id] { + set recepient_name [party::name -party_id $recipient_user_id] + set body_html "[_ imsld.lt_Dear_recepient_name_b]" + # if activity_id is not null: + # 1. make it visible + # 2. get the activity url in order to send it in the email + if { ![empty_string_p $activity_id] } { + # 1. make it visible + db_dml make_activity_visible { *SQL* } + # 2. get the activity url for the recipient user_id + set activity_url [imsld::activity_url -run_id $run_id -activity_id $activity_id -user_id $recipient_user_id] + set activity_title [content::revision::revision_name -revision_id $activity_id] + append body_html "[_ imsld.lt_br___________________]" + } else { + append body_html "[_ imsld.lt_br____________________1]" + } + # Use this to build up extra mail headers + set extra_headers [ns_set new] + + # This should disable most auto-replies. + ns_set put $extra_headers Precedence list + + set message_data [build_mime_message [ad_html_to_text $body_html] $body_html] + ns_set put $extra_headers MIME-Version [ns_set get $message_data MIME-Version] + ns_set put $extra_headers Content-ID [ns_set get $message_data Content-ID] + ns_set put $extra_headers Content-Type [ns_set get $message_data Content-Type] + set content [ns_set get $message_data body] + + acs_mail_lite::send -to_addr [party::email -party_id $recipient_user_id] \ + -from_addr $sender_email \ + -subject $subject \ + -body $content \ + -extraheaders $extra_headers + } + + # log the notification + db_dml log_notification { *SQL* } +} + ad_proc -public imsld::finish_component_element { -imsld_id -run_id @@ -730,11 +839,58 @@ from imsld_on_completioni where item_id = :related_on_completion and content_revision__is_live(on_completion_id) = 't' + and change_property_value_xml is not null }] } { imsld::condition::eval_change_property_value -change_property_value_xml $change_property_value_xml -run_id $run_id } + # notifications + foreach notification_list [db_list_of_lists get_notifications { *SQL* }] { + set subject [lindex $notification_list 0] + set activity_id [content::item::get_live_revision -item_id [lindex $notification_list 1]] + set notification_id [lindex $notification_list 2] + set notification_item_id [lindex $notification_list 3] + + # send an email for each email-data associated to the notification + foreach email_data [db_list_of_lists get_email_datas { *SQL* }] { + set role_id [lindex $email_data 0] + set mail_data [lindex $email_data 1] + set email_property_id [lindex $email_data 2] + set username_property_id [lindex $email_data 3] + + if { ![empty_string_p $username_property_id] } { + # get the username proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single username + db_1row get_username_property_id { *SQL* } + set username [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -property_id $property_id] + } else { + set username "" + } + + if { ![empty_string_p $email_property_id] } { + # get the email proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single email address. + # we also send the notificaiton to the rest of the role members + db_1row get_email_property_id { *SQL* } + set email_address [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -property_id $property_id] + } else { + set email_address "" + } + + imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subject \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $user_id + } + } } } + if { [string eq $type "learning"] || [string eq $type "support"] || [string eq $type "structure"] } { foreach referencer_structure_list [db_list_of_lists referencer_structure { *SQL* }] { set structure_id [lindex $referencer_structure_list 0] @@ -1453,7 +1609,7 @@ } send-mail { - # FIX ME: when roles are supported, fix this so the mail is sent to the propper role + # FIX ME: Currently only one send-mail-data is supported set resource_item_list [list] db_1row get_send_mail_info { *SQL* } @@ -1771,6 +1927,24 @@ } } +ad_proc -public imsld::activity_url { + -activity_id:required + -run_id:required + {-user_id ""} +} { + @param activity_id + @param run_id + @option user_id + + @returns the url for the given activity +} { + + set user_id [expr { [string eq $user_id ""] ? [ad_conn user_id] : $user_id }] + + return "[export_vars -base "activity-frame" -url {activity_id run_id user_id}]" + +} + ad_proc -public imsld::process_resource_as_ul { -resource_item_id -run_id @@ -1904,19 +2078,20 @@ -dom_doc {-resource_mode "f"} {-user_id ""} - } { @param activity_item_id @param run_id @option resource_mode default f @param dom_node @param dom_doc - + @option user_id default ad_conn user_id + @return The html list (activity_name, list of associated urls, using tdom) of the activity in the IMS-LD. It only works whith the learning and support activities, since it will only return the objectives, prerequistes, associated resources but not the environments. } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] + if { [db_0or1row is_imsld { select 1 from imsld_imsldsi where item_id = :activity_item_id }] } { @@ -2402,7 +2577,7 @@ $activity_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2443,7 +2618,7 @@ set activity_node [$dom_doc createElement li] $activity_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2484,7 +2659,7 @@ set structure_node [$dom_doc createElement li] $structure_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {{activity_id $structure_id} run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2542,6 +2717,7 @@ and ar.object_id_two = :user_id and iruge.run_id = :run_id }] + # get the referenced role parts foreach role_part_list [db_list_of_lists referenced_role_parts { *SQL* }] { set type [lindex $role_part_list 0] set activity_id [lindex $role_part_list 1] @@ -2563,7 +2739,7 @@ set activity_node [$dom_doc createElement li] $activity_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2603,7 +2779,7 @@ set activity_node [$dom_doc createElement li] $activity_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {activity_id run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2646,7 +2822,7 @@ set structure_node [$dom_doc createElement li] $structure_node setAttribute class "liOpen" set a_node [$dom_doc createElement a] - $a_node setAttribute href "[export_vars -base "activity-frame" -url {{activity_id $structure_id} run_id}]" + $a_node setAttribute href "[imsld::activity_url -activity_id $structure_id -run_id $run_id -user_id $user_id]" $a_node setAttribute target "content" set text [$dom_doc createTextNode "$activity_title"] $a_node appendChild $text @@ -2670,6 +2846,113 @@ } } +ad_proc -public imsld::generate_runtime_assigned_activities_tree { + -run_id:required + -user_id + -dom_node + -dom_doc +} { + @param run_id + @param user_id + @param dom_node + @param dom_doc + + @return A list of lists of the activities +} { + # context info + db_1row imsld_info { *SQL* } + + # 1. get the current role of the user + # 2. get any related activities to the role with the rel imsld_run_time_activities_rel + # 3. get the info of those activities (role_part_id, act_id, play_id) and generate the list + # NOTE: the activity will be shown only once, no matter from how many role parts it is referenced + + set user_role_id [db_string current_role { *SQL* }] + + + # get the referenced activities to the role, assigned at runtime (notifications, level C) + + foreach activity_id [db_list runtime_activities { *SQL* } ] { + # get the activity_type + if { [db_0or1row learning_activity_p { *SQL* }] } { + set activity_type learning + } else { + set activity_type support + } + set role_part_id [imsld::get_role_part_from_activity -activity_type $activity_type -leaf_id [content::revision::item_id -revision_id $activity_id]] + + # role_part context info + db_1row role_part_context { *SQL* } + + switch $activity_type { + learning { + # add the learning activity to the tree + db_1row get_learning_activity_info { *SQL* } + set completed_activity_p [db_0or1row la_already_completed { *SQL* }] + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + + if { !$completed_activity_p } { + set input_node [$dom_doc createElement input] + $input_node setAttribute type "checkbox" + $input_node setAttribute style "vertical-align: bottom;" + $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-learning.imsld\"" + $activity_node appendChild $input_node + } else { + set input_node [$dom_doc createElement input] + $input_node setAttribute type "checkbox" + $input_node setAttribute checked "true" + $input_node setAttribute disabled "true" + $activity_node appendChild $input_node + } + + $dom_node appendChild $activity_node + } + support { + # add the support activity to the tree + db_1row get_support_activity_info { *SQL* } + set completed_activity_p [db_0or1row sa_already_completed { *SQL* }] + set activity_node [$dom_doc createElement li] + $activity_node setAttribute class "liOpen" + set a_node [$dom_doc createElement a] + $a_node setAttribute href "[imsld::activity_url -activity_id $activity_id -run_id $run_id -user_id $user_id]" + $a_node setAttribute target "content" + set text [$dom_doc createTextNode "$activity_title"] + $a_node appendChild $text + $activity_node appendChild $a_node + + set text [$dom_doc createTextNode " "] + $activity_node appendChild $text + + if { !$completed_activity_p } { + set input_node [$dom_doc createElement input] + $input_node setAttribute type "checkbox" + $input_node setAttribute style "vertical-align: bottom;" + $input_node setAttribute onclick "window.location=\"finish-component-element-${imsld_id}-${run_id}-${play_id}-${act_id}-${role_part_id}-${activity_id}-support.imsld\"" + $activity_node appendChild $input_node + } else { + set input_node [$dom_doc createElement input] + $input_node setAttribute type "checkbox" + $input_node setAttribute checked "true" + $input_node setAttribute disabled "true" + $activity_node appendChild $input_node + } + + $dom_node appendChild $activity_node + } + } + } +} + ad_proc -public imsld::get_next_activity_list { -run_id:required {-user_id ""} Index: openacs-4/packages/imsld/tcl/imsld-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.xql,v diff -u -N -r1.32 -r1.33 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 27 Sep 2006 14:41:35 -0000 1.32 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 24 Oct 2006 10:09:51 -0000 1.33 @@ -494,7 +494,6 @@ - BEGIN @@ -505,6 +504,64 @@ + + + + select 1 + from imsld_learning_activities + where activity_id = :activity_id + + + + + + + + where learning_activity_id = :activity_id + + + + + + + + where support_activity_id = :activity_id + + + + + + + + select 1 + from acs_rels + where object_id_one = :role_id + and object_id_two = :activity_id + and rel_type = 'imsld_run_time_activities_rel' + + + + + + + + update imsld_attribute_instances + set is_visible_p = 't' + where user_id = :recipient_user_id + and owner_id = :activity_id + + + + + + + + insert into imsld_notifications_history (run_id, from_user_id, notification_date, target_activity_id, to_user_id) + values (:run_id, :user_id, now(), :activity_id, :recipient_user_id) + + + + @@ -587,6 +644,63 @@ + + + + select ino.subject, + ino.activity_id, + ino.notification_id, + ino.item_id as notification_item_id + from imsld_notificationsi ino, + acs_rels ar + where ar.object_id_two = ino.item_id + and ar.object_id_one = :related_on_completion + and ar.rel_type = 'imsld_on_comp_notif_rel' + + + + + + + + select ir.role_id, + data.mail_data, + data.email_property_id, + data.username_property_id + from imsld_send_mail_datai data, + acs_rels ar, + imsld_rolesi ir + where ar.object_id_two = data.item_id + and ar.rel_type = 'imsld_notif_email_rel' + and ar.object_id_one = :notification_item_id + and ir.item_id = data.role_id + and content_revision__is_live(ir.role_id) = 't' + + + + + + + + select property_id + from imsld_propertiesi + where item_id = :username_property_id + and content_revision__is_live(property_id) = 't' + + + + + + + + select property_id + from imsld_propertiesi + where item_id = :email_property_id + and content_revision__is_live(property_id) = 't' + + + + insert into imsld_status_user ( @@ -1021,9 +1135,11 @@ - select sm.title as send_mail_title, sm.mail_id as sendmail_id + select sm.title as send_mail_title, ar.object_id_two as sendmail_id from imsld_send_mail_servicesi sm where sm.service_id = :service_item_id + and sm.item_id = ar.object_id_one + and ar.rel_type = 'imsld_send_mail_serv_data_rel' and content_revision__is_live(sm.mail_id) = 't' @@ -1903,6 +2019,128 @@ + + + + select imsld_id + from imsld_runs + where run_id = :run_id + + + + + + + + select map.active_role_id as user_role_id + from imsld_run_users_group_rels map, + acs_rels ar, + imsld_run_users_group_ext iruge + where ar.rel_id = map.rel_id + and ar.object_id_one = iruge.group_id + and ar.object_id_two = :user_id + and iruge.run_id = :run_id + + + + + + + + select ar.object_id_two as activity_id + from acs_rels ar + where ar.object_id_one = :user_role_id + and ar.rel_type = 'imsld_run_time_activities_rel' + + + + + + + + select 1 + from imsld_learning_activities + where activity_id = :activity_id + + + + + + + + select ia.act_id, + ip.play_id + from imsld_role_parts rp, + imsld_actsi ia, + imsld_playsi ip + where rp.act_id = ia.item_id + and ia.play_id = ip.item_id + and rp.role_part_id = :role_part_id + and content_revision__is_live(ip.play_id) = 't' + + + + + + + + select la.title as activity_title, + la.item_id as activity_item_id, + la.activity_id, + attr.is_visible_p, + la.complete_act_id + from imsld_learning_activitiesi la, imsld_attribute_instances attr + where activity_id = :activity_id + and attr.owner_id = la.activity_id + and attr.run_id = :run_id + and attr.user_id = :user_id + and attr.type = 'isvisible' + + + + + + + + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + + + + + + + + select sa.title as activity_title, + sa.item_id as activity_item_id, + sa.activity_id, + attr.is_visible_p, + sa.complete_act_id + from imsld_support_activitiesi sa, imsld_attribute_instances attr + where sa.activity_id = :activity_id + and attr.owner_id = sa.activity_id + and attr.run_id = :run_id + and attr.user_id = :user_id + and attr.type = 'isvisible' + + + + + + + + select 1 from imsld_status_user + where related_id = :activity_id + and user_id = :user_id + and run_id = :run_id + and status = 'finished' + + + + select acs_object_id as assessment_id Index: openacs-4/packages/imsld/www/activity-frame.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/activity-frame.tcl,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/imsld/www/activity-frame.tcl 25 Jul 2006 17:28:18 -0000 1.12 +++ openacs-4/packages/imsld/www/activity-frame.tcl 24 Oct 2006 10:09:51 -0000 1.13 @@ -11,10 +11,12 @@ activity_id:integer,notnull {role_id ""} {supported_user_id ""} + {user_id ""} } +set user_id [expr { [string eq $user_id ""] ? [ad_conn user_id] : $user_id }] + set roles_template_p 0 -set user_id [ad_conn user_id] db_1row context_info { select r.imsld_id, case @@ -72,6 +74,7 @@ set activity_item_id [content::revision::item_id -revision_id $activity_id] imsld::process_activity_as_ul -activity_item_id $activity_item_id -run_id $run_id -dom_doc $doc -dom_node $dom_root + if { ![string eq $activity_id ""] && [db_0or1row get_table_name { select case Index: openacs-4/packages/imsld/www/imsld-content-serve.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-content-serve.tcl,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/imsld/www/imsld-content-serve.tcl 17 Oct 2006 10:22:26 -0000 1.15 +++ openacs-4/packages/imsld/www/imsld-content-serve.tcl 24 Oct 2006 10:09:51 -0000 1.16 @@ -337,8 +337,83 @@ set parent_node [$set_property_node parentNode] # first, replace property node with the form node $parent_node replaceChild $form_node $set_property_node - # FIXME: tDOME apparently adds automathically the attribute xmlns when replacing a node... + # FIXME: tDOME apparently(??) adds automathically the attribute xmlns when replacing a node... $form_node removeAttribute xmlns + + # level C: notifications + foreach notification_node [$set_property_node selectNodes "*\[local-name()='notification'\]"] { + set activity_id "" + set subjectValue "" + set subjectNode [$notification_node selectNodes {*[local-name()='subject']}] + if { [llength $subjectNode] } { + set subjectValue [$subjectNode text] + } + + set larefNode [$notification_node selectNodes {*[local-name()='learning-activity-ref']}] + if { [llength $larefNode] } { + set larefValue [$larefNode getAttribute ref ""] + set activityIdentifier $larefValue + } + + set sarefNode [$notification_node selectNodes {*[local-name()='support-activity-ref']}] + if { [llength $sarefNode] } { + set sarefValue [$sarefNode getAttribute ref ""] + set activityIdentifier $sarefValue + } + + if { [info exists activityIdentifier] } { + set activity_id [db_string get_activity_id { + select owner_id + from imsld_attribute_instances + where identifier = :activityIdentifier + and run_id = :run_id + and user_id = :owner_user_id + }] + } + + foreach emailDataNode [$notification_node selectNodes {*[local-name()='email-data']}] { + + set emailPropertyRef [$emailDataNode getAttribute email-property-ref ""] + set usernamePropertyRef [$emailDataNode getAttribute username-property-ref ""] + set roleRef [[$emailDataNode selectNodes {*[local-name()='role-ref']}] getAttribute ref ""] + set username "" + set email_address "" + + if { ![empty_string_p $usernamePropertyRef] } { + # get the username proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single username + set username [imsld::runtime::property::property_value_get -run_id $run_id -user_id $owner_user_id -identifier $usernamePropertyRef] + } + + if { ![empty_string_p $emailPropertyRef] } { + # get the email proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single email address. + # we also send the notificaiton to the rest of the role members + set email_address [imsld::runtime::property::property_value_get -run_id $run_id -user_id $owner_user_id -identifier $emailPropertyRef] + } + + db_1row get_context_info { + select role_id, ii.imsld_id + from imsld_roles ir, imsld_componentsi ic, imsld_imsldsi ii, imsld_runs run + where ir.identifier = :roleRef + and ir.component_id = ic.item_id + and ic.imsld_id = ii.item_id + and ii.imsld_id = run.imsld_id + and run.run_id = :run_id + } + + imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subjectValue \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $owner_user_id + } + } } # 4. set-property-group nodes @@ -498,6 +573,81 @@ $parent_node replaceChild $form_node $set_property_group_node # FIXME: tDOME apparently adds automathically the attribute xmlns when replacing a node... $form_node removeAttribute xmlns + + # level C: notifications + foreach notification_node [$set_property_group_node selectNodes "*\[local-name()='notification'\]"] { + set activity_id "" + set subjectValue "" + set subjectNode [$notification_node selectNodes {*[local-name()='subject']}] + if { [llength $subjectNode] } { + set subjectValue [$subjectNode text] + } + + set larefNode [$notification_node selectNodes {*[local-name()='learning-activity-ref']}] + if { [llength $larefNode] } { + set larefValue [$larefNode getAttribute ref ""] + set activityIdentifier $larefValue + } + + set sarefNode [$notification_node selectNodes {*[local-name()='support-activity-ref']}] + if { [llength $sarefNode] } { + set sarefValue [$sarefNode getAttribute ref ""] + set activityIdentifier $sarefValue + } + + if { [info exists activityIdentifier] } { + set activity_id [db_string get_activity_id { + select owner_id + from imsld_attribute_instances + where identifier = :activityIdentifier + and run_id = :run_id + and user_id = :owner_user_id + }] + } + + foreach emailDataNode [$notification_node selectNodes {*[local-name()='email-data']}] { + + set emailPropertyRef [$emailDataNode getAttribute email-property-ref ""] + set usernamePropertyRef [$emailDataNode getAttribute username-property-ref ""] + set roleRef [[$emailDataNode selectNodes {*[local-name()='role-ref']}] getAttribute ref ""] + set username "" + set email_address "" + + if { ![empty_string_p $usernamePropertyRef] } { + # get the username proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single username + set username [imsld::runtime::property::property_value_get -run_id $run_id -user_id $owner_user_id -identifier $usernamePropertyRef] + } + + if { ![empty_string_p $emailPropertyRef] } { + # get the email proprty value + # NOTE: there is no specification for the format of the email property value + # so we assume it is a single email address. + # we also send the notificaiton to the rest of the role members + set email_address [imsld::runtime::property::property_value_get -run_id $run_id -user_id $owner_user_id -identifier $emailPropertyRef] + } + + db_1row get_context_info { + select role_id, ii.imsld_id + from imsld_roles ir, imsld_componentsi ic, imsld_imsldsi ii, imsld_runs run + where ir.identifier = :roleRef + and ir.component_id = ic.item_id + and ic.imsld_id = ii.item_id + and ii.imsld_id = run.imsld_id + and run.run_id = :run_id + } + + imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subjectValue \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $owner_user_id + } + } } # 6. class nodes Index: openacs-4/packages/imsld/www/imsld-tree.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-tree.adp,v diff -u -N -r1.10 -r1.11 --- openacs-4/packages/imsld/www/imsld-tree.adp 3 Oct 2006 15:18:07 -0000 1.10 +++ openacs-4/packages/imsld/www/imsld-tree.adp 24 Oct 2006 10:09:51 -0000 1.11 @@ -48,6 +48,7 @@ @html_tree;noquote@ +@aux_html_tree;noquote@ @user_message@ Index: openacs-4/packages/imsld/www/imsld-tree.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-tree.tcl,v diff -u -N -r1.13 -r1.14 --- openacs-4/packages/imsld/www/imsld-tree.tcl 16 Oct 2006 15:07:12 -0000 1.13 +++ openacs-4/packages/imsld/www/imsld-tree.tcl 24 Oct 2006 10:09:51 -0000 1.14 @@ -122,4 +122,35 @@ $imsld_title_node appendChild $activities_node set html_tree [$dom_root asXML] + + # runtime generated activities (notifications, level C) + if { [db_string generated_acitivties_p { + select count(*) + from acs_rels + where object_id_one = :current_role_id + and rel_type = 'imsld_run_time_activities_rel' + } -default 0] > 0 } { + dom createDocument ul aux_doc + set aux_dom_root [$aux_doc documentElement] + $aux_dom_root setAttribute class "mktree" + $aux_dom_root setAttribute style "white-space: nowrap;" + set aux_title_node [$aux_doc createElement li] + $aux_title_node setAttribute class "liOpen" + set text [$doc createTextNode "[_ imsld.Extra_Activities]"] + $aux_title_node appendChild $text + $aux_dom_root appendChild $aux_title_node + + set aux_activities_node [$aux_doc createElement ul] + imsld::generate_runtime_assigned_activities_tree -run_id $run_id \ + -user_id $user_id \ + -dom_node $aux_activities_node \ + -dom_doc $aux_doc + + $aux_title_node appendChild $aux_activities_node + + set aux_html_tree [$aux_dom_root asXML] + } else { + set aux_html_tree "" + } + }