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.70 -r1.71 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 29 Jun 2006 11:21:55 -0000 1.70 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 5 Jul 2006 14:59:10 -0000 1.71 @@ -300,10 +300,11 @@ if { [imsld::role_part_finished_p -run_id $run_id -role_part_id $role_part_id -user_id $user_id] } { return } - db_1row role_part_info { - select item_id as role_part_item_id - from imsld_role_partsi - where role_part_id = :role_part_id + db_1row role_part_info { *SQL* } + + # first, verify that the role part is marked as started + if { ![db_0or1row marked_as_started { *SQL* }] } { + db_dml mark_role_part_started { *SQL* } } db_dml insert_role_part { *SQL* } @@ -615,6 +616,10 @@ set url [ns_conn url] regexp {finish-component-element-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)-([a-z]+).imsld$} $url match imsld_id run_id play_id act_id role_part_id element_id type } + if { ![db_0or1row marked_as_started { *SQL* }] } { + # NOTE: this should not happen... UNLESS the activity is marked as finished automatically + db_dml mark_element_started { *SQL* } + } # now that we have the necessary info, mark the finished element completed and return db_dml insert_element_entry { *SQL* } 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.25 -r1.26 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 29 Jun 2006 11:21:55 -0000 1.25 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 5 Jul 2006 14:59:10 -0000 1.26 @@ -203,7 +203,48 @@ + + + select 1 + from imsld_status_user + where run_id = :run_id + and user_id = :user_id + and status = 'started' + and act_id = :act_id + and related_id = :role_part_id + + + + + + + + insert into imsld_status_user (imsld_id, + run_id, + play_id, + act_id, + related_id, + user_id, + type, + status_date, + status) + ( + select :imsld_id, + :run_id, + :play_id, + :act_id, + :role_part_id, + :user_id, + 'act', + now(), + 'started' + where not exists (select 1 from imsld_status_user where run_id = :run_id and user_id = :user_id and related_id = :role_part_id and status = 'started') + ) + + + + insert into imsld_status_user (imsld_id, @@ -464,6 +505,55 @@ + + + + select 1 + from imsld_status_user + where run_id = :run_id + and user_id = :user_id + and status = 'started' + and related_id = :element_id + and imsld_id = :imsld_id + and play_id = :play_id + and role_part_id = :role_part_id + + + + + + + + + insert into imsld_status_user ( + imsld_id, + run_id, + play_id, + act_id, + role_part_id, + related_id, + user_id, + type, + status_date, + status + ) + ( + select :imsld_id, + :run_id, + :play_id, + :act_id, + :role_part_id, + :element_id, + :user_id, + :type, + now(), + 'started' + where not exists (select 1 from imsld_status_user where run_id = :run_id and user_id = :user_id and related_id = :element_id and status = 'started') + ) + + + + select on_completion_id as related_on_completion