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 -r1.13 -r1.14 --- openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 19 Jul 2006 15:06:10 -0000 1.13 +++ openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 26 Jul 2006 14:37:27 -0000 1.14 @@ -56,6 +56,30 @@ } } +ad_proc -public imsld::condition::execute_time_role_conditions { + -run_id +} { +} { +foreach condition_xml [db_list get_other_conditions { + select ici.condition_xml + from imsld_conditionsi ici, + imsld_methodsi imi, + imsld_imsldsi iii, + imsld_runs iri + where ici.item_id not in (select object_id_two + from acs_rels + where (rel_type='imsld_prop_cond_rel' or rel_type='imsld_ilm_cond_rel')) + and ici.method_id=imi.item_id + and imi.imsld_id=iii.item_id + and iri.imsld_id=iii.imsld_id + and iri.run_id=:run_id + }] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } +} + ad_proc -public imsld::expression::eval { -run_id -expression 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.33 -r1.34 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 20 Jul 2006 16:24:57 -0000 1.33 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 26 Jul 2006 14:37:27 -0000 1.34 @@ -519,6 +519,16 @@ content_item 0 {} \ content_item 0 {} + # Roles - conditions + rel_types::new imsld_role_cond_rel "Role - Condition" "Roles - Conditions" \ + content_item 0 {} \ + content_item 0 {} + + # Imsld learning material - conditions + rel_types::new imsld_ilm_cond_rel "Imsld Learning Material - Condition" "Imsld Learning Materials - Conditions" \ + content_item 0 {} \ + content_item 0 {} + } ad_proc -public imsld::uninstall::delete_rels { 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.55 -r1.56 --- openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 20 Jul 2006 16:24:57 -0000 1.55 +++ openacs-4/packages/imsld/tcl/imsld-parse-procs.tcl 26 Jul 2006 14:37:27 -0000 1.56 @@ -3244,11 +3244,12 @@ -parent_id $parent_id \ -title $title] #search properties in expression - set property_nodes_list [$expression selectNodes {//*[local-name()='property-ref']}] + set property_nodes_list [$expression selectNodes {.//*[local-name()='property-ref']}] foreach property $property_nodes_list { -#TODO que funcion la get_property_id con el play_id -# set property_id [imsld::get_property_id -identifier [$property getAttribute ref] -play_id $play_id] -# relation_add imsld_prop_whct_rel $property_id $when_condition_true_id + + + set property_id [imsld::get_property_item_id -identifier [$property getAttribute ref] -play_id $play_id] + relation_add imsld_prop_whct_rel $property_id $when_condition_true_id } } @@ -4021,13 +4022,96 @@ -parent_id $cr_folder_id \ -manifest $manifest \ -method_id $method_id ] + #search condition properties - set property_nodes_list [$imsld_if selectNodes { //*[local-name()='property-ref'] }] - + set property_nodes_list [$imsld_if selectNodes {.//*[local-name()='property-ref'] }] foreach property $property_nodes_list { -# set property_id [imsld::get_property_id -identifier [$property getAttribute ref] -imsld_id $imsld_id] -# relation_add imsld_prop_cond_rel $property_id $contition_id + + set property_id [imsld::get_property_item_id -identifier [$property getAttribute ref] -imsld_id $imsld_id] + relation_add imsld_prop_cond_rel $property_id $condition_id } + #search condition roles + #search conditional imsld learning materials + set ilm_condition_node_list [$imsld_if selectNodes {.//*[local-name()='complete']/*}] + + foreach ilm_condition_node $ilm_condition_node_list { + set ref [$ilm_condition_node getAttribute ref] + set node_name [$ilm_condition_node localName] + + switch $node_name { + learning-activity-ref { + db_1row get_la_item_id { + select ila.item_id as ilm_item_id + from imsld_learning_activitiesi ila, + imsld_componentsi ici + where ila.identifier=:ref + and ila.component_id=ici.item_id + and ici.imsld_id=:imsld_id + } + } + support-activity-ref { + db_1row get_sa_item_id { + select ila.item_id as ilm_item_id + from imsld_support_activitiesi ila, + imsld_componentsi ici + where ila.identifier=:ref + and ila.component_id=ici.item_id + and ici.imsld_id=:imsld_id + } + } + activity-structure-ref { + db_1row get_as_item_id { + select ila.item_id as ilm_item_id + from imsld_activity_structuresi ila, + imsld_componentsi ici + where ila.identifier=:ref + and ila.component_id=ici.item_id + and ici.imsld_id=:imsld_id + } + } + unit-of-learning-href { + + } + role-part-ref { + db_1row get_role_part_item_id { + select irp.item_id as ilm_item_id + from imsld_role_partsi irp, + imsld_actsi ia, + imsld_playsi ipi, + imsld_methodsi imi + where irp.identifier=:ref + and irp.act_id=ia.item_id + and ia.play_id=ipi.item_id + and ipi.method_id=imi.item_id + and imi.imsld_id=:imsld_id + } + } + act-ref { + db_1row get_act_item_id { + select ia.item_id as ilm_item_id + from imsld_actsi ia, + imsld_playsi ipi, + imsld_methodsi imi + where ia.identifier=:ref + and ia.play_id=ipi.item_id + and ipi.method_id=imi.item_id + and imi.imsld_id=:imsld_id + } + + } + play-ref { + db_1row get_play_item_id { + select ip.item_id as ilm_item_id + from imsld_playsi ip, + imsld_methodsi imi + where ip.identifier=:ref + and ip.method_id=imi.item_id + and imi.imsld_id=:imsld_id; + } + } + } + relation_add imsld_ilm_cond_rel $ilm_item_id $condition_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 -r1.80 -r1.81 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 20 Jul 2006 08:48:53 -0000 1.80 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 26 Jul 2006 14:37:27 -0000 1.81 @@ -182,6 +182,22 @@ -play_id $play_id \ -user_id $user_id } + foreach condition_xml [db_list search_related_conditions { + select ici.condition_xml + from imsld_conditionsi ici, + acs_rels ar, + imsld_playsi ilai + where ilai.item_id=ar.object_id_one + and ar.rel_type='imsld_ilm_cond_rel' + and ilai.play_id=:play_id + and ici.item_id=ar.object_id_two + }] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id } } ns_log notice "imsld::sweep_expired_activities Sweeping acts..." @@ -205,6 +221,22 @@ -act_id $act_id \ -user_id $user_id } + foreach condition_xml [db_list search_related_conditions { + select ici.condition_xml + from imsld_conditionsi ici, + acs_rels ar, + imsld_actsi ilai + where ilai.item_id=ar.object_id_one + and ar.rel_type='imsld_ilm_cond_rel' + and ilai.act_id=:act_id + and ici.item_id=ar.object_id_two + }] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id } } ns_log notice "imsld::sweep_expired_activities Sweeping support activities..." @@ -241,6 +273,22 @@ -user_id $user_id \ -code_call } + foreach condition_xml [db_list search_related_conditions { + select ici.condition_xml + from imsld_conditionsi ici, + acs_rels ar, + imsld_support_activitiesi ilai + where ilai.item_id=ar.object_id_one + and ar.rel_type='imsld_ilm_cond_rel' + and ilai.activity_id=:activity_id + and ici.item_id=ar.object_id_two + }] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id } } } @@ -279,6 +327,22 @@ -user_id $user_id \ -code_call } + foreach condition_xml [db_list search_related_conditions { + select ici.condition_xml + from imsld_conditionsi ici, + acs_rels ar, + imsld_learning_activitiesi ilai + where ilai.item_id=ar.object_id_one + and ar.rel_type='imsld_ilm_cond_rel' + and ilai.activity_id=:activity_id + and ici.item_id=ar.object_id_two + }] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id } } } @@ -644,7 +708,16 @@ set element_name "act_id" } } + if { [info exists table_name] } { + foreach condition_xml [db_list search_related_conditions ""] { + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id + #grant permissions to resources in activity if { [db_0or1row get_related_on_completion_id ""] } { if { [db_0or1row get_related_resource_id { *SQL* }] } { @@ -3046,9 +3119,10 @@ } } -ad_proc -public imsld::get_property_id { +ad_proc -public imsld::get_property_item_id { -identifier:required - -imsld_id:required + -imsld_id + -play_id } {

Get the property_id from the property_identifier in a imsld_id

@@ -3057,7 +3131,7 @@ if {[info exist play_id] & ![info exist imsld_id]} { set imsld_id [db_string get_imsld_id_from_play { - select iii.imsld_id + select iii.item_id from imsld_imsldsi iii, imsld_methodsi imi, imsld_plays ip @@ -3066,14 +3140,15 @@ and ip.play_id=:play_id }] } + return [db_string get_property_id { - select ip.property_id - from imsld_properties ip, + select ip.item_id + from imsld_propertiesi ip, imsld_componentsi ici, imsld_imsldsi iii where ip.component_id=ici.item_id and ici.imsld_id=iii.item_id - and iii.imsld_id=:imsld_id + and iii.item_id=:imsld_id and ip.identifier=:identifier }] } 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 -r1.28 -r1.29 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 20 Jul 2006 08:48:53 -0000 1.28 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 26 Jul 2006 14:37:27 -0000 1.29 @@ -607,6 +607,19 @@ + + + select ici.condition_xml + from imsld_conditionsi ici, + acs_rels ar, + ${table_name}i ilai + where ilai.item_id=ar.object_id_one + and ar.rel_type='imsld_ilm_cond_rel' + and ilai.${element_name}=:element_id + and ici.item_id=ar.object_id_two; + + + Index: openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 21 Jul 2006 13:13:42 -0000 1.12 +++ openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 26 Jul 2006 14:37:27 -0000 1.13 @@ -337,7 +337,9 @@ where ir.identifier=:ref and ir.component_id=ici.item_id and ici.imsld_id=:imsld_id - }]} + }]} { + return $role_id + } } elseif { [info exist run_id] } { if { [db_0or1row select_role_id_from_run { select ar1.object_id_one as role_id @@ -350,7 +352,7 @@ and ar2.object_id_two=:run_id and iri.item_id=ar1.object_id_one and iri.identifier=:ref - group by ar1.object_id_one;v + group by ar1.object_id_one }] } { return $role_id } Index: openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 13 Jul 2006 13:11:43 -0000 1.9 +++ openacs-4/packages/imsld/tcl/imsld-runtime-procs.tcl 26 Jul 2006 14:37:27 -0000 1.10 @@ -164,7 +164,29 @@ # recursive call only if the property value has changed if { $old_value != $value } { - imsld::condition::execute_all -run_id $run_id + set conditions_list [db_list get_conditions_from_property { + select ici.condition_id + from imsld_conditionsi ici, + acs_rels ar, + imsld_propertiesi ipi + where ipi.property_id=:property_id + and ipi.item_id=ar.object_id_one + and ar.rel_type='imsld_prop_cond_rel' + and ar.object_id_two=ici.item_id + }] + #property conditions + foreach condition_id $conditions_list { + set condition_xml [db_string get_xml_piece { + select condition_xml + from imsld_conditions + where condition_id=:condition_id + }] + dom parse $condition_xml document + $document documentElement condition_node + imsld::condition::execute -run_id $run_id -condition $condition_node + } + #role conditions, time conditions... + imsld::condition::execute_time_role_conditions -run_id $run_id } }