Index: openacs-4/packages/imsld/sql/postgresql/imsld-production-delivery-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/sql/postgresql/imsld-production-delivery-create.sql,v diff -u -r1.7 -r1.8 --- openacs-4/packages/imsld/sql/postgresql/imsld-production-delivery-create.sql 25 Sep 2006 13:13:31 -0000 1.7 +++ openacs-4/packages/imsld/sql/postgresql/imsld-production-delivery-create.sql 27 Sep 2006 14:41:34 -0000 1.8 @@ -141,3 +141,14 @@ initializated according to the initial parsed values from the manifest, not being affected by a previous run.'; +create table imsld_run_users_group_rels ( + rel_id integer + constraint imsld_rug_rels_fk + references acs_rels + constraint imsld_rug_rels_pk + primary key +); + +comment on table imsld_run_users_group_rels is ' +This table stores the relationships between users and runs. It is also used to store the current role of the users in the run.'; + 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.35 -r1.36 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 20 Sep 2006 08:26:30 -0000 1.35 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 27 Sep 2006 14:41:35 -0000 1.36 @@ -329,27 +329,32 @@ create default rels between imsld items and acs objects } { # ims-ld roles - oacs groups - rel_types::new imsld_role_group_rel "ims-ld role - imsld_role_group" "ims-ld roles - imsld_role_groups" \ + rel_types::new imsld_role_group_rel "ims-ld role - imsld_role_group" "ims-ld roles - imsld_role_groups" \ content_item 0 {} \ imsld_role_group 0 {} - + # ims-ld role instance - ims-ld run - rel_types::new imsld_roleinstance_run_rel "imsld role instance - imsld run" "imsld role instances - ims_ld_run_groups" \ + rel_types::new imsld_roleinstance_run_rel "imsld role instance - imsld run" "imsld role instances - ims_ld_run_groups" \ imsld_role_group 0 {} \ imsld_run_users_group 0 {} - - + # ims-ld run - oacs users - rel_types::new imsld_run_users_group_rel "ims_ld_run_group - acs_users" "ims_ld_run_group - acs_users" \ + rel_types::new -table_name imsld_run_users_group_rels \ + -create_table_p 0 \ + imsld_run_users_group_rel \ + "ims_ld_run_group - acs_users" "ims_ld_run_group - acs_users" \ imsld_run_users_group 0 {} \ party 0 {} + attribute::add -min_n_values 0 -max_n_values 0 imsld_run_users_group_rel integer "active_role_id" "Active Roles IDs" + # FIX ME (there is no way to add attributes to the rels without creating the whole plsql code) + package_recreate_hierarchy imsld_run_users_group } ad_proc -public imsld::install::init_rels { } { Create default rels between imsld items } { - + # Learning Objetcives - IMS-LD Items rel_types::new imsld_lo_item_rel "Learing Objective - Imsld Item rel" "Learing Objective - Imsld Item rels" \ content_item 0 {} \ 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.84 -r1.85 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 25 Sep 2006 13:13:31 -0000 1.84 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 27 Sep 2006 14:41:35 -0000 1.85 @@ -2533,7 +2533,16 @@ } # start with the role parts - set user_roles_list [imsld::roles::get_user_roles -user_id $user_id -run_id $run_id] + set user_role_id [db_string current_role { + 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 + }] 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] 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.31 -r1.32 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 25 Sep 2006 13:13:31 -0000 1.31 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 27 Sep 2006 14:41:35 -0000 1.32 @@ -1791,6 +1791,21 @@ + + + + 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 + + + + @@ -1815,7 +1830,7 @@ and im.imsld_id = ii.item_id and ii.imsld_id = :imsld_id and rp.role_id = iri.item_id - and iri.role_id in ([join $user_roles_list ","]) + and iri.role_id = :user_role_id and content_revision__is_live(rp.role_part_id) = 't' and attr.owner_id = ip.play_id and attr.run_id = :run_id 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 -r1.10 -r1.11 --- openacs-4/packages/imsld/www/imsld-content-serve.tcl 25 Sep 2006 13:13:31 -0000 1.10 +++ openacs-4/packages/imsld/www/imsld-content-serve.tcl 27 Sep 2006 14:41:35 -0000 1.11 @@ -511,7 +511,7 @@ with_control_p from imsld_attribute_instances where run_id = :run_id - and user_id = :user_id + and user_id = :owner_user_id and identifier = :class_name and type = 'class' }] } { 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 -r1.8 -r1.9 --- openacs-4/packages/imsld/www/imsld-tree.adp 6 Jun 2006 13:24:46 -0000 1.8 +++ openacs-4/packages/imsld/www/imsld-tree.adp 27 Sep 2006 14:41:35 -0000 1.9 @@ -5,6 +5,13 @@ + + + +
+
+ + +
+
@html_tree;noquote@ @user_message@ @@ -41,4 +66,9 @@ } } + + + 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 -r1.10 -r1.11 --- openacs-4/packages/imsld/www/imsld-tree.tcl 22 Sep 2006 10:58:13 -0000 1.10 +++ openacs-4/packages/imsld/www/imsld-tree.tcl 27 Sep 2006 14:41:35 -0000 1.11 @@ -3,6 +3,7 @@ @creation-date Mar 2006 } { run_id:integer,notnull + {current_role_id ""} } # initialize variables @@ -21,6 +22,49 @@ and run.run_id = :run_id } +# current role information. +# the user must have an active role in the run + +if { ![empty_string_p $current_role_id] } { + # a role has been selected, update in db + db_dml update_current_role { + update imsld_run_users_group_rels + set active_role_id = :current_role_id + where rel_id = (select ar.rel_id + from acs_rels ar, imsld_run_users_group_ext iruge + where ar.object_id_one = iruge.group_id + and ar.object_id_two = :user_id + and iruge.run_id = :run_id) + } +} + +set possible_user_roles [imsld::roles::get_user_roles -user_id $user_id -run_id $run_id] +set possible_user_role_names [imsld::roles::get_roles_names -roles_list $possible_user_roles] +# remove   added in the previous proc +regsub -all " " $possible_user_role_names "" $possible_user_role_names + +if { ![db_0or1row get_current_role { + 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 +}] } { + # generate the first option + set possible_user_roles [linsert $possible_user_roles 0 0] + set possible_user_role_names [linsert $possible_user_role_names 0 "<#_ Select role... #>"] + set user_role_id -1 +} + +template::multirow create possible_roles role_id role_name + +foreach role $possible_user_roles { + template::multirow append possible_roles $role [lindex $possible_user_role_names [lsearch -exact $possible_user_roles $role]] +} + set user_message "" set next_activity_id [imsld::get_next_activity_list -run_id $run_id -user_id $user_id] @@ -62,12 +106,17 @@ set activities_node [$doc createElement ul] -imsld::generate_activities_tree -run_id $run_id \ - -user_id $user_id \ - -next_activity_id_list $next_activity_id \ - -dom_node $activities_node \ - -dom_doc $doc - -$imsld_title_node appendChild $activities_node - -set html_tree [$dom_root asXML] +if { $user_role_id == -1 } { + set html_tree "" +} else { + + imsld::generate_activities_tree -run_id $run_id \ + -user_id $user_id \ + -next_activity_id_list $next_activity_id \ + -dom_node $activities_node \ + -dom_doc $doc + + $imsld_title_node appendChild $activities_node + + set html_tree [$dom_root asXML] +}