Index: openacs-4/packages/imsld/lib/imsld-chunk.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/lib/imsld-chunk.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/imsld/lib/imsld-chunk.xql 29 May 2006 15:11:32 -0000 1.1 +++ openacs-4/packages/imsld/lib/imsld-chunk.xql 6 Jun 2006 13:24:46 -0000 1.2 @@ -20,7 +20,7 @@ and imsld.organization_id = cr2.item_id and cr2.live_revision = ico.organization_id and cr3.live_revision = imsld.imsld_id - and run.status = 'active' + and ( run.status = 'active' or run.status = 'stopped') $orderby 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.66 -r1.67 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 29 May 2006 15:10:52 -0000 1.66 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 6 Jun 2006 13:24:46 -0000 1.67 @@ -1084,6 +1084,60 @@ return 0 } +ad_proc -public imsld::run_finished_p { + -run_id:required + {-user_id "" } +} { + @param run_id + @oprion user_id + + @return 0 if all the activities in the run hasn't been finished. 1 otherwise +} { + #get users involved in test + if {![string eq "" $user_id]} { + set user_id [ad_conn user_id] + } else { + set user_id [db_list get_users_in_run { + select gmm.member_id + from group_member_map gmm, + imsld_run_users_group_ext iruge, + acs_rels ar1 + where iruge.run_id=:run_id + and ar1.object_id_two=iruge.group_id + and ar1.object_id_one=gmm.group_id + group by member_id + }] + } + #get acts in run + set acts_list [db_list get_acts_in_run { + select iai.act_id, + iai.item_id + from imsld_runs ir, + imsld_imsldsi iii, + imsld_methodsi imi, + imsld_playsi ipi, + imsld_actsi iai + where ir.run_id=:run_id + and iii.imsld_id=ir.imsld_id + and imi.imsld_id=iii.item_id + and imi.item_id=ipi.method_id + and iai.play_id=ipi.item_id + }] + + set all_finished_p 1 + foreach user $user_id { + foreach act $acts_list { + if {![imsld::act_finished_p -run_id $run_id -act_id $act -user_id $user]} { + set all_finished_p 0 + } + } + } + + return $all_finished_p +} + + + ad_proc -public imsld::act_finished_p { -act_id:required -run_id:required @@ -2378,6 +2432,7 @@ @return The list of next activity_ids of each role_part and play in the IMS-LD. } { + # get the imsld info db_1row get_ismld_info { select ii.imsld_id, ii.item_id as imsld_item_id @@ -2425,7 +2480,6 @@ continue } if { ![imsld::act_finished_p -run_id $run_id -act_id $act_id -user_id $user_id] } { - # if the act hasn't been completed, this is the next act of the play lappend next_act_item_id_list [content::revision::item_id -revision_id $act_id] continue } @@ -2442,7 +2496,32 @@ and ia.sort_order = :act_sort_order + 1 }] } { # get the current play_id's sort_order and sarch in the next play in the current method_id - lappend next_act_item_id_list $act_item_id + set all_users_finished 1 + #the act is only showed as next activity when all users in roles has finished the previous act + + if {[db_0or1row get_last_act { select ia2.act_id as last_act_id from imsld_actsi ia1, imsld_acts ia2 where ia1.item_id=:act_item_id and ia2.sort_order=(ia1.sort_order -1) and ia1.play_id=ia2.play_id}] + } { + #get list of involved roles + set roles_list [imsld::roles::get_list_of_roles -imsld_id $imsld_id] + + #get list of involved users + set users_list [list] + foreach role $roles_list { + set users_in_role [imsld::roles::get_users_in_role -role_id [lindex $role 0] -run_id $run_id] + set users_list [concat $users_list $users_in_role] + } + + #check if all has finished the act + foreach user $users_list { + if {![imsld::act_finished_p -act_id $last_act_id -run_id $run_id -user_id $user]} { + set all_users_finished 0 + } + } + } + + if {$all_users_finished} { + lappend next_act_item_id_list $act_item_id + } } } @@ -2500,7 +2579,6 @@ lappend next_activity_id_list $next_activity_id } } - # return the next_activity_id_list return $next_activity_id_list } 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.4 -r1.5 --- openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 29 May 2006 15:10:52 -0000 1.4 +++ openacs-4/packages/imsld/tcl/imsld-roles-procs.tcl 6 Jun 2006 13:24:46 -0000 1.5 @@ -240,4 +240,48 @@ return $roles_list } +ad_proc -public imsld::roles::get_users_in_role { + -role_id:required + -run_id +} { + Returns a list with all the users in a role. If run_id is given, restrict the list to the roles of the run. +} { + if {[info exist run_id]} { + set groups_list [db_list get_groups_in_run { + select ar1.object_id_two as groups + from acs_rels ar1, + acs_rels ar2, + imsld_rolesi iri, + imsld_run_users_group_ext iruge2 + where ar1.rel_type='imsld_role_group_rel' + and ar1.object_id_one=iri.item_id + and iri.role_id=:role_id + and ar2.object_id_one=ar1.object_id_two + and ar2.rel_type='imsld_roleinstance_run_rel' + and ar2.object_id_two=iruge2.group_id + and iruge2.run_id=:run_id + }] + } else { + set groups_list [db_list get_groups_in_role { + select ar.object_id_two + from acs_rels ar, + imsld_rolesi iri + where ar.rel_type='imsld_role_group_rel' + and ar.object_id_one=iri.item_id + and iri.role_id=:role_id + }] + } + + set users_list [list] + foreach group $groups_list { + set users_in_group [db_list get_users_in_group { + select member_id + from group_member_map + where group_id=:group + group by member_id + }] + set users_list [concat $users_list $users_in_group] + } + return $users_list +} 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.7 -r1.8 --- openacs-4/packages/imsld/www/imsld-tree.adp 21 Apr 2006 13:41:07 -0000 1.7 +++ openacs-4/packages/imsld/www/imsld-tree.adp 6 Jun 2006 13:24:46 -0000 1.8 @@ -22,6 +22,9 @@ @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 -r1.7 -r1.8 --- openacs-4/packages/imsld/www/imsld-tree.tcl 16 May 2006 09:24:35 -0000 1.7 +++ openacs-4/packages/imsld/www/imsld-tree.tcl 6 Jun 2006 13:24:46 -0000 1.8 @@ -21,13 +21,37 @@ and run.run_id = :run_id } +set user_message "" set next_activity_id [imsld::get_next_activity_list -run_id $run_id -user_id $user_id] +set remaining_activities [llength [join $next_activity_id]] + +if {!$remaining_activities} { + set all_finished [imsld::run_finished_p -run_id $run_id] + if {$all_finished} { + db_dml stop_run { + update imsld_runs + set status='stopped' + where run_id=:run_id + } + } else { + set user_message "Please wait for other users ..." + } +} + set run_status [db_string get_run_status { + select status + from imsld_runs + where run_id=:run_id + }] + + if {[string eq "stopped" $run_status]} { + set user_message "The course has been finished" + } + dom createDocument ul doc set dom_root [$doc documentElement] $dom_root setAttribute class "mktree" $dom_root setAttribute style "white-space: nowrap;" - set imsld_title_node [$doc createElement li] $imsld_title_node setAttribute class "liOpen" set text [$doc createTextNode "$imsld_title"] Index: openacs-4/packages/imsld/www/support-activity-roles.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/support-activity-roles.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/imsld/www/support-activity-roles.tcl 19 May 2006 17:26:02 -0000 1.2 +++ openacs-4/packages/imsld/www/support-activity-roles.tcl 6 Jun 2006 13:24:46 -0000 1.3 @@ -38,6 +38,6 @@ } set lista [template::util::multirow_to_list supported_users_in_role] -ns_log Notice "lista generada: $lista" + Index: openacs-4/packages/imsld/www/admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/admin/index.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/imsld/www/admin/index.tcl 31 May 2006 16:20:54 -0000 1.8 +++ openacs-4/packages/imsld/www/admin/index.tcl 6 Jun 2006 13:24:46 -0000 1.9 @@ -137,9 +137,12 @@ db_multirow -extend { manage delete_template } imsld_runs get_runs { *SQL* } { - if { [string eq $status "deleted"] || [string eq $status active]} { + if { [string eq $status "deleted"] } { set delete_template "[_ imsld.Deleted] [_ imsld.Make_it_live]" set manage "" + } elseif {[string eq $status "active"]} { + set delete_template "" + set manage "" } else { set delete_template "" set create_run " [_ imsld.create_new_run] "