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.13 -r1.14 --- openacs-4/packages/lorsm/tcl/lorsm-procs.tcl 7 Jun 2006 14:05:44 -0000 1.13 +++ openacs-4/packages/lorsm/tcl/lorsm-procs.tcl 7 Jun 2006 14:37:23 -0000 1.14 @@ -596,32 +596,51 @@ # 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 where ims_item_id in ( select live_revision - from cr_items where content_type = 'ims_item_object') and - org_id = :org_id + from ims_cp_items, cr_items where ims_item_id = live_revision + and org_id = :org_id }] # Get the root items set count 0 - db_foreach 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"] { lappend items_list [list $ims_item_id 1] set items_array($ims_item_id) 1 incr count } - - + set i 0 + # setup an array so we don't have to visit items twice + # that could be expensive if the tree is long or deep. + array set visited_items [list] while { $count < $items_count } { + ns_log notice "loop [incr i]" + if {$i > 2} {break} foreach item $items_list { set item_id [lindex $item 0] - set indent [expr [lindex $item 1] + 1] - db_foreach get_items {select ims_item_id from ims_cp_items where parent_item = :item_id and org_id = :org_id } { - if { ![info exist items_array($ims_item_id)] } { - lappend items_list [list $ims_item_id $indent] - set items_array($ims_item_id) $indent - incr count - } - } + ns_log notice "item_id $item_id [info exists visited_items($item_id)]" + if {![info exists visited_items($item_id)]} { + 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}] { + if { ![info exist items_array($ims_item_id)] } { + lappend items_list [list $ims_item_id $indent] + set items_array($ims_item_id) $indent + incr count + } + } + } } + # FIXME, basically this is a hack otherwise the while loop + # will be infinite if parent_item is not set correctly in + # ims_cp_items + # We should maintain a hierarchy of parent_items in + # ims_cp_items instead, which would greatly simplify all the + # code in LORS + if {[array size visited_items] >= [llength $items_list]} { + # we have checked ever item, if the count still doesn't + # match, we'll never get there! + set count $items_count + } } return $items_list } Index: openacs-4/packages/lorsm/www/course-add.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/course-add.adp,v diff -u -r1.3 -r1.4 --- openacs-4/packages/lorsm/www/course-add.adp 29 Nov 2004 17:26:03 -0000 1.3 +++ openacs-4/packages/lorsm/www/course-add.adp 7 Jun 2006 14:37:24 -0000 1.4 @@ -17,13 +17,17 @@
-#lorsm.lt_We_have_detected_the_# @folder_name;noquote@ #lorsm.lt_and_we_will_import_yo#
-+ + + #lorsm.or_upload_existing_course#
+
-- --
-- -- #lorsm.Course_Information# - -- -- #lorsm.Course_Name# - -- @course_name;noquote@ - -- -- #lorsm.Version# - -- -- @version_msg;noquote@ - -- @version;noquote@ Course Versions - -- -- #lorsm.Metadata# - -- -- -- #lorsm.Yes# - -- #lorsm.Yes# - -- #lorsm.No# - -- -- #lorsm.Identifier# - -- @identifier@ - -- -- #lorsm.Is_SCORM# - -- #lorsm.lt_classlist_stylefont-w# - - -- class="list" - - valign="top" align="left">@isscorm;noquote@ -- -- #lorsm.Storage_Folder# - -- @instance@ - -- -- #lorsm.Created_By# - -- @created_by@ - -- -- #lorsm.Date# - -- @creation_date;noquote@ - -- - -- #lorsm.Submanifests# - -- @submanifests@ - -- - -- #lorsm.Status# - -- -- #lorsm.Enabled# - -- #lorsm.Disabled# - -- #lorsm.Change# --- - -- #lorsm.Trackable# - -- -- #lorsm.Yes# - -- #lorsm.No# - -- #lorsm.Change# --- -- #lorsm.Is_shared# - -- -- #lorsm.Shared# - -- #lorsm.Not_Shared# - -- #lorsm.Change# --- -- #lorsm.Course# - -- @format_pretty_name@ - -- #lorsm.Change# --- -- #lorsm.Organizations# - -- -- - -- -- @orgs_list;noquote@ - -
[_ lorsm.Organization] | -[_ lorsm.Metadata_1] | -[_ lorsm.Items] | -|||||
---|---|---|---|---|---|---|---|
$org_title | $hasmetadata | " - - set indent [expr $indent +1] - set missing_text "[_ lorsm.Nothing_here]" - set return_url [export_vars -base [ns_conn url] man_id] - set table_extra_html { width="100%" } - set table_extra_vars {return_url indent_array lorsm_p} - set table_def { - { title "\#lorsm.Item_Name\#" "no_sort" " | - [set indent \"\" - for { set i 0 } { $i < [expr $indent_array($item_id)-1]} { incr i } { - append indent \" \" - } - if {![empty_string_p $identifierref]} {set href \"$indent$item_title\"} else {set href $item_title}] | " } - { Edit "\#lorsm.Edit\#" "no_sort" "[if {![empty_string_p $identifierref]} { if { $lorsm_p } { set href \"[_ lorsm.Edit_1] | \"} else { set href \"Edit\" }}]"} - { metadata "\#lorsm.Metadata_1\#" "no_sort" "[if {$hasmetadata == \"f\"} { if { $lorsm_p } { set hasmetadata \"No\"} else { set hasmetadata \"No\"} } else { if { $lorsm_p } { set hasmetadata \"Yes\"} else { set hasmetadata \"Yes\"}}] | " } - { type "\#lorsm.Type\#" "no_sort" "$type | " } - { shared "\#lorsm.Is_Shared\#" "no_sort" "[if {$isshared == false} {set ret \"No\"}] | " } - } - - set table_item [ad_table -Tmissing_text $missing_text -Textra_vars $table_extra_vars -Theader_row_extra "style=\"background-color: #e0e0e0; font-weight: bold;\" class=\"list-header\"" -Ttable_extra_html $table_extra_html blah { } $table_def] - - append orgs_list "$table_item" - - - append orgs_list "