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.Add_your_own_course#

+

#lorsm.Create_a_new_course#

-

#lorsm.lt_We_have_detected_the_# @folder_name;noquote@ #lorsm.lt_and_we_will_import_yo#

- + + +

#lorsm.or_upload_existing_course#

+
Index: openacs-4/packages/lorsm/www/course-structure.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/course-structure.adp,v diff -u -r1.6 -r1.7 --- openacs-4/packages/lorsm/www/course-structure.adp 17 May 2005 17:03:40 -0000 1.6 +++ openacs-4/packages/lorsm/www/course-structure.adp 7 Jun 2006 14:37:24 -0000 1.7 @@ -2,186 +2,4 @@ @title;noquote@ @context;noquote@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #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.Trackable# - - - #lorsm.Yes# - - - #lorsm.No# - - -
- #lorsm.Is_shared# - - - #lorsm.Shared# - - - #lorsm.Not_Shared# - - -
- #lorsm.Course# - - @format_pretty_name@ - -
- #lorsm.Organizations# -
- -
- @orgs_list;noquote@ -
-
- -
- + \ No newline at end of file Index: openacs-4/packages/lorsm/www/course-structure.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/course-structure.tcl,v diff -u -r1.8 -r1.9 --- openacs-4/packages/lorsm/www/course-structure.tcl 20 May 2005 18:48:14 -0000 1.8 +++ openacs-4/packages/lorsm/www/course-structure.tcl 7 Jun 2006 14:37:24 -0000 1.9 @@ -1,144 +1,35 @@ -# packages/lorsm/www/course_structure.tcl +# # packages/lorsm/www/course_structure.tcl -ad_page_contract { + ad_page_contract { + + View Manifest Course Structure - View Manifest Course Structure - - @author Ernie Ghiglione (ErnieG@mm.st) - @creation-date 2004-03-31 - @arch-tag 208f2801-d110-45d3-9401-d5eae1f72c93 - @cvs-id $Id$ -} { - man_id:integer,notnull -} -properties { -} -validate { -} -errors { -} + @author Ernie Ghiglione (ErnieG@mm.st) + @creation-date 2004-03-31 + @arch-tag 208f2801-d110-45d3-9401-d5eae1f72c93 + @cvs-id $Id$ + } { + man_id:integer,notnull + } -properties { + } -validate { + } -errors { + } -set package_id [ad_conn package_id] -set community_id [dotlrn_community::get_community_id] +# set package_id [ad_conn package_id] +# set community_id [dotlrn_community::get_community_id] -ad_proc -public getFolderKey { - {-object_id:required} -} { - Gets the Folderkey for a file-storage folder_id +# ad_proc -public getFolderKey { +# {-object_id:required} +# } { +# Gets the Folderkey for a file-storage folder_id - @option object_id Folder_id for file-storage folder - @author Ernie Ghiglione (ErnieG@mm.st) +# @option object_id Folder_id for file-storage folder +# @author Ernie Ghiglione (ErnieG@mm.st) -} { - return [db_string select_folder_key "select key from fs_folders where object_id = :object_id"] -} +# } { +# return [db_string select_folder_key "select key from fs_folders where object_id = :object_id"] +# } # set context & title -set context [list "[_ lorsm.Course_Structure]"] -set title "[_ lorsm.Course_Structure]" - - -if {[db_0or1row manifest { }]} { - - # Sets the variable for display. - set display 1 - - # Course Name - if {[empty_string_p $course_name]} { - set course_name "[_ lorsm.No_course_Name]" - } - - # Version - set version [db_string get_versions { } -default 0] - - if {[string equal $version "0"]} { - set version_msg "[_ lorsm.No_version_Available]" - } - - if { ![empty_string_p $fs_package_id] } { - # Folder - set folder [apm_package_url_from_id $fs_package_id]?[export_vars folder_id] - # Instance - set instance [apm_package_key_from_id $fs_package_id] - } else { - set fs_package_id [site_node_apm_integration::get_child_package_id \ - -package_id [dotlrn_community::get_package_id $community_id] \ - -package_key "file-storage"] - # Instance - set instance [lors_central::get_course_name -man_id $man_id] - # Folder - set root_folder [lors_central::get_root_folder_id] - set folder_id [db_string get_folder_id { }] - set folder [apm_package_url_from_id $fs_package_id]?[export_vars folder_id] - } - - # Created By - set created_by [person::name -person_id $creation_user] - - # Creation Date - set creation_date [lc_time_fmt $creation_date "%x %X"] - - # Check for submanifests - if {[db_0or1row submans { }]} { - } else { - set submanifests 0 - } - - -} else { - - set display 0 - -} - - -append orgs_list "" -append orgs_list " - - - - -" -db_foreach organizations { } { - - - set total_items [db_string items_count {select count(*) from ims_cp_items where org_id=:org_id} -default 0] - # We get the indent of the items in this org_id - set indent_list [lorsm::get_items_indent -org_id $org_id] - template::util::list_of_lists_to_array $indent_list indent_array - - - append orgs_list "" } - { Edit "\#lorsm.Edit\#" "no_sort" "\"} else { set href \"Edit\" }}]"} - { metadata "\#lorsm.Metadata_1\#" "no_sort" "" } - { type "\#lorsm.Type\#" "no_sort" "" } - { shared "\#lorsm.Is_Shared\#" "no_sort" "" } - } - - 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 "" - -} if_no_rows { - append orgs_list "" -} - -append orgs_list "
[_ 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}][if {![empty_string_p $identifierref]} { if { $lorsm_p } { set href \"[_ lorsm.Edit_1][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[if {$isshared == false} {set ret \"No\"}]
" - -set enabler_url [export_vars -base enabler {man_id}] -set tracker_url [export_vars -base tracker {man_id}] -set sharer_url [export_vars -base sharer {man_id folder_id return_url}] -set formater_url [export_vars -base formater {man_id return_url}] + set context [list "[_ lorsm.Course_Structure]"] + set title "[_ lorsm.Course_Structure]"