Index: openacs-4/packages/lorsm/sql/postgresql/lorsm-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/sql/postgresql/lorsm-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/lorsm/sql/postgresql/lorsm-create.sql 11 Jul 2006 02:22:17 -0000 1.5 +++ openacs-4/packages/lorsm/sql/postgresql/lorsm-create.sql 6 Apr 2007 19:30:20 -0000 1.6 @@ -106,5 +106,23 @@ This table stores the available presentation formats for the courses. Its contains the pretty name for the format, an id, and the name of an adp in packages/lorsm/www/delivery where the presentation format is stored.'; +create table lorsm_custom_pages ( + man_id integer + constraint lors_st_end_pgs_man_id_pk + primary key + constraint lors_st_end_pgs_man_id_fk + references ims_cp_manifests (man_id), + page_id integer + constraint lors_st_end_pgs_start_id_fk + references cr_items (item_id), + type varchar(100) +); + +comment on table lorsm_custom_pages is ' +Allow a course creator to designate an ims_cp_item as the start page +which appears before the couse is started, or tracking is enabled so the user +can see what the course is about. End page is a concluding page that works the +same way'; + \i lorsm-packages.sql \i lorsm-cmi-create.sql Index: openacs-4/packages/lorsm/tcl/lorsm-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/tcl/lorsm-procs.tcl,v diff -u -r1.15 -r1.16 --- openacs-4/packages/lorsm/tcl/lorsm-procs.tcl 7 Jun 2006 18:44:04 -0000 1.15 +++ openacs-4/packages/lorsm/tcl/lorsm-procs.tcl 6 Apr 2007 19:30:20 -0000 1.16 @@ -365,15 +365,16 @@ AND o.object_id = i.ims_item_id AND - cr.item_id = ( select item_id from cr_revisions where revision_id = i.ims_item_id) + cr.live_revision=i.ims_item_id AND EXISTS (select 1 from acs_object_party_privilege_map p where p.object_id = i.ims_item_id and p.party_id = :user_id and p.privilege = 'read') - + and not exists (select 1 from lorsm_custom_pages + where page_id=cr.item_id and man_id=:man_id) ORDER BY i.sort_order, o.object_id, cr.tree_sortkey } { @@ -590,20 +591,28 @@ ad_proc -public lorsm::get_items_indent { -org_id:required + {-exclude {}} } { Returns a list of the form \{ims_item_id indent\} from one org_id } { + if {[info exists exclude] && [llength $exclude]} { + set exclude_where " and ims_cp_items.ims_item_id not in ([template::util::tcl_to_sql_list $exclude]) " + } else { + set exclude_where "" + } + # We need all the count of all items (just live revisions) - set items_count [db_string get_items_count { select count(ims_item_id) - from ims_cp_items, cr_items where ims_item_id = live_revision - and org_id = :org_id - }] + set items_count [db_string get_items_count " select count(ims_item_id) + from ims_cp_items, cr_items cr where ims_item_id = live_revision + and org_id = :org_id $exclude_where + "] # Get the root items set count 0 set items_list [list] - foreach ims_item_id [db_list get_root_item "select ims_item_id from ims_cp_items where parent_item = :org_id and org_id = :org_id"] { + + foreach ims_item_id [db_list get_root_item "select ims_item_id from ims_cp_items where parent_item = :org_id and org_id = :org_id $exclude_where"] { lappend items_list [list $ims_item_id 1] set items_array($ims_item_id) 1 incr count @@ -622,7 +631,7 @@ ns_log notice "adding to array item_id $item_id" set visited_items($item_id) $item_id set indent [expr [lindex $item 1] + 1] - foreach ims_item_id [db_list get_items {select ims_item_id from ims_cp_items where parent_item = :item_id and org_id = :org_id}] { + foreach ims_item_id [db_list get_items "select ims_item_id from ims_cp_items where parent_item = :item_id and org_id = :org_id $exclude_where"] { if { ![info exist items_array($ims_item_id)] } { lappend items_list [list $ims_item_id $indent] set items_array($ims_item_id) $indent @@ -643,6 +652,7 @@ set count $items_count } } +# ad_return_complaint 1 "$items_list" return $items_list } @@ -735,3 +745,35 @@ # return $result # } # } + +ad_proc lorsm::set_custom_page { + -man_id + -item_id + -type +} { + Set one of the ims_cp_items from this manifest + as a start or end page + + @param man_id Manifest_id of the course + @item_id cr_items.item_id of the ims_cp_item page to use + @type start or end for start or end page +} { + if {![db_0or1row get_page "select 1 from lorsm_custom_pages where man_id=:man_id and type=:type"]} { + db_dml add_page "insert into lorsm_custom_pages (man_id,page_id,type) values (:man_id,:item_id,:type)" + } else { + db_dml update_page "update lorsm_custom_pages +set man_id=:man_id, +page_id=:item_id, +type=:type" + } +} + +ad_proc lorsm::get_custom_page_ims_item_id { + -man_id + -type +} { + Get the ims_item_id for a custom page if it exists + or empty string if it does not +} { + return [db_string get_custom_page "select live_revision from cr_items, lorsm_custom_pages where page_id=item_id and man_id=:man_id and type=:type" -default ""] +} \ No newline at end of file Index: openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.adp,v diff -u -r1.4 -r1.5 --- openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.adp 4 Dec 2006 18:43:23 -0000 1.4 +++ openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.adp 6 Apr 2007 19:30:21 -0000 1.5 @@ -1,23 +1,24 @@ -@current_title@ +@page_title@ +@header_stuff;noquote@

@current_title@

-

[@progress_list:item@][@progress_list:item@] -

+ + @include_content;noquote@

-Next +@next_link_text@

Index: openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.tcl 4 Dec 2006 18:43:23 -0000 1.6 +++ openacs-4/packages/lorsm/www/delivery/delivery-progress-bar.tcl 6 Apr 2007 19:30:21 -0000 1.7 @@ -6,10 +6,14 @@ {__include ""} {__include_vars ""} {next_item_id ""} + track_id:optional } -properties { } -validate { } -errors { } + +set track_id [ad_get_client_property lorsm studenttrack] +ns_log notice "DAVEB LORSM BEFORE TRACK_ID='${track_id}'" if {![info exists man_id] || $man_id eq ""} { set man_id [ad_get_client_property lorsm man_id] } @@ -21,17 +25,7 @@ set user_id [ad_conn user_id] set lorsm_url [dotlrn_community::get_community_url $community_id]lorsm/delivery -# Student tracking -set package_id [ad_conn package_id] -#if {[lorsm::track::istrackable -course_id $man_id -package_id $package_id]} { - -# set track_id [lorsm::track::new \ -\# -user_id $user_id \ -\# -community_id $community_id \ -\# -course_id $man_id] -#} else { - set track_id 0 -#} +set package_id [site_node::get_element -url $lorsm_url -element package_id] # return_url set return_url [dotlrn_community::get_community_url [dotlrn_community::get_community_id]] @@ -51,45 +45,84 @@ limit 1 } -default ""] - set first_item_id [lindex $item_list 0] set first_item_url "" -#if {$item_id eq ""} { -# set item_id $first_item_id -# ad_returnredirect [export_vars -base ${lorsm_url}/record-view {man_id item_id}] -# ad_script_abort -#} -#set curr_index [expr [lsearch -exact $item_list $last_item_viewed]] set curr_index [expr [lsearch -exact $item_list $item_id]] +set next_link_text [_ lorsm.Next] +set track_p 1 + if {$curr_index < 0} { # start course # we want the next_url to be the first item set curr_index -1 - set __include "/packages/lorsm/lib/start" + # do we have a custom start page? + set item_id [lorsm::get_custom_page_ims_item_id -man_id $man_id -type start] + if {$item_id eq ""} { + set __include "/packages/lorsm/lib/start" + set page_title [lorsm::get_course_name -manifest_id $man_id] + } else { + ad_set_client_property lorsm ims_id $item_id + set __include /packages/lorsm/lib/default + set page_title [db_string get_title "select item_title from ims_cp_items where ims_item_id=:item_id" -default ""] + } + set next_link_text [_ lorsm.Begin] + set track_p 0 } - +# Student tracking +if {[lorsm::track::istrackable -course_id $man_id -package_id $package_id] \ + && $track_p && ($track_id == 0 || $track_id eq "")} { + + set track_id [lorsm::track::new \ + -user_id $user_id \ + -community_id $community_id \ + -course_id $man_id] + ad_set_client_property lorsm studenttrack $track_id +} elseif {$track_id eq ""} { + set track_id 0 +} +ns_log notice "DAVEB LORSM AFTER TRACK_ID='${track_id}'" set prev_item_id [lindex $item_list [expr $curr_index - 1]] set next_item_id [lindex $item_list [expr $curr_index + 1]] set prev_url "" -set next_url [export_vars -base "${lorsm_url}/record-view" -url {{item_id $next_item_id} man_id}] +set next_url [export_vars -base "${lorsm_url}/record-view" -url {{item_id $next_item_id} track_id man_id}] set prev_title [db_string get_title "select item_title from ims_cp_items where ims_item_id=:prev_item_id" -default ""] set next_title [db_string get_title "select item_title from ims_cp_items where ims_item_id=:next_item_id" -default ""] set current_title [db_string get_title "select item_title from ims_cp_items where ims_item_id=:item_id" -default ""] -set progress_list [template::util::number_list [llength $item_list] 1] -set progress_index [expr {$curr_index + 1}] +set progress_total_pages [llength $item_list] +set progress_current_page [expr {$curr_index + 1}] set last_item_p [expr {$curr_index == [expr {[llength $item_list] - 1}]}] if {[string match "*assessment*" $__include] && ![string match "*assessment/lib/session*" $__include]} { set show_next 0 + set header_stuff { + } } else { if { $next_item_id eq "" } { - set next_url [dotlrn_community::get_community_url [dotlrn_community::get_community_id]] + # check for end page + set next_url ${lorsm_url}/end + set last_item_p 0 } - + set header_stuff "" set show_next 1 } +if {$__include eq "/packages/lorsm/lib/end"} { + set item_id [lorsm::get_custom_page_ims_item_id -man_id $man_id -type end] + if {$item_id ne ""} { + ad_set_client_property lorsm ims_id $item_id + set __include /packages/lorsm/lib/default + set page_title [db_string get_title "select item_title from ims_cp_items where ims_item_id=:item_id" -default ""] + } + set next_url [export_vars -base exit {man_id track_id return_url}] + set last_item_p 1 + +} + set include_content [template::adp_include $__include $__include_vars] -regsub -all {} $include_content {} include_content \ No newline at end of file +regsub -all {} $include_content {} include_content + +if {$current_title ne ""} { + set page_title $current_title +} \ No newline at end of file Index: openacs-4/packages/lorsm/www/delivery/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/index.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/lorsm/www/delivery/index.tcl 11 Jul 2006 02:22:17 -0000 1.8 +++ openacs-4/packages/lorsm/www/delivery/index.tcl 6 Apr 2007 19:30:21 -0000 1.9 @@ -34,13 +34,13 @@ } } else { ad_set_client_property lorsm ims_id "" - ns_log notice "UNSETTING LORSM IMS_ID '[ad_conn url]'" +# ns_log notice "UNSETTING LORSM IMS_ID '[ad_conn url]'" } if { [info exists ims_id] } { set item_id $ims_id ad_set_client_property lorsm ims_id $ims_id - ns_log notice "SETTING LORSM IMS_ID = '${ims_id}' '[ad_conn url]'" +# ns_log notice "SETTING LORSM IMS_ID = '${ims_id}' '[ad_conn url]'" set body_url [export_vars -base "record-view" -url {item_id man_id}] } @@ -79,8 +79,9 @@ set user_id [ad_conn user_id] ad_set_client_property lorsm currentcourse $man_id +set start_page [lorsm::get_custom_page_ims_item_id -man_id $man_id -type start] -if {[lorsm::track::istrackable -course_id $man_id -package_id $package_id]} { +if {$start_page eq "" && [lorsm::track::istrackable -course_id $man_id -package_id $package_id]} { set track_id [lorsm::track::new \ -user_id $user_id \ -community_id $community_id \ Index: openacs-4/packages/lorsm/www/delivery/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/index.vuh,v diff -u -r1.6 -r1.7 --- openacs-4/packages/lorsm/www/delivery/index.vuh 12 Jul 2006 07:06:13 -0000 1.6 +++ openacs-4/packages/lorsm/www/delivery/index.vuh 6 Apr 2007 19:30:21 -0000 1.7 @@ -6,7 +6,6 @@ set path_info [ad_conn path_info] set path_list [split $path_info /] set base [lindex $path_list 0] - set dotlrn_package_id [dotlrn_community::get_community_id] set lorsm_url [dotlrn_community::get_community_url $dotlrn_package_id]lorsm/ @@ -69,7 +68,7 @@ rp_internal_redirect /packages/assessment/www/view/index.vuh ad_script_abort } - + rp_form_put show_title_p 0 set path [join [lrange $path_list 1 end] /] if {[file exists [acs_root_dir]/packages/assessment/lib/${path}.tcl]} { rp_form_put __include /packages/assessment/lib/$path @@ -88,7 +87,11 @@ end { rp_form_put __include /packages/lorsm/lib/end rp_internal_redirect /packages/lorsm/www/delivery/${folder_name} + ad_script_abort } default { + rp_form_put __include /packages/lorsm/lib/default + rp_internal_redirect /packages/lorsm/www/delivery/${folder_name} + ad_script_abort } } Index: openacs-4/packages/lorsm/www/delivery/record-view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/record-view.tcl,v diff -u -r1.11 -r1.12 --- openacs-4/packages/lorsm/www/delivery/record-view.tcl 4 Dec 2006 19:56:41 -0000 1.11 +++ openacs-4/packages/lorsm/www/delivery/record-view.tcl 6 Apr 2007 19:30:21 -0000 1.12 @@ -143,6 +143,12 @@ if { [info exists lorsm::item_id] } { set lorsm::item_id "" } + set delivery_format [db_string get_format "select folder_name from lorsm_course_presentation_formats f, ims_cp_manifests m where f.format_id=m.course_presentation_format and m.man_id=:man_id"] + if {$delivery_format eq "delivery-progress-bar"} { + rp_form_put __include /packages/lorsm/lib/default + rp_internal_redirect /packages/lorsm/www/delivery/delivery-progress-bar + ad_script_abort + } rp_internal_redirect -absolute_path [acs_root_dir]/templates/lorsm-default } }