Index: openacs-4/packages/lors/lib/course-structure.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/lors/lib/course-structure.adp	7 Jun 2006 13:54:46 -0000	1.1
+++ openacs-4/packages/lors/lib/course-structure.adp	12 Jun 2006 01:52:19 -0000	1.2
@@ -6,28 +6,21 @@
         </th>
     </tr>
               <tr class="list-odd">
-              <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%">
+              <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%" >
                 #lorsm.Course_Name#
               </td>
               <td class="list" valign="top" style="background-color: #f0f0f0; font-weight: bold;">
-                <a href="@folder@">@course_name;noquote@</a>
+                @course_name;noquote@
+                (@identifier@)
+	 	#lorsm.Course_Versions#
               </td>
-          </tr>
+</tr>
+<tr class="list-even"><td class="list"  style="background-color: #e0e0e0; font-weight: bold; width="20%" ><a href="javascript:void(0)" onClick="document.getElementById('lors-advanced-course-structure').style.display='';">More Info</a></td><td class="list">&nbsp;</td></tr>
+</table>
+<div id="lors-advanced-course-structure" style="display:none;">
+<table class="list" cellpadding="3" cellspacing="1" width="70%">
               <tr class="list-even">
               <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%">
-                #lorsm.Version#
-              </td>
-              <td class="list" valign="top" style="background-color: #f0f0f0">
-                  <if @version@ eq "0">
-                       @version_msg;noquote@
-                  </if>
-                  <else>
-                       @version;noquote@ Course Versions
-                  </else>
-              </td>
-          </tr>
-              <tr class="list-odd">
-              <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%">
                 #lorsm.Metadata#
               </td>
               <td class="list" valign="top" style="background-color: #f0f0f0">
@@ -44,14 +37,6 @@
                 </else>
               </td>
           </tr>
-              <tr class="list-even">
-              <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%">
-                #lorsm.Identifier#
-              </td>
-              <td class="list" valign="top" style="background-color: #f0f0f0" width="80%">
-                @identifier@
-              </td>
-          </tr>
               <tr class="list-odd">
               <td class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" width="20%">
                 #lorsm.Is_SCORM#
@@ -160,6 +145,9 @@
                  </div>
               </td>
           </tr>
+</table>
+</div>
+<table class="list" cellpadding="3" cellspacing="1" width="70%">
     <tr class="list-header">
         <th class="list" valign="top" style="background-color: #e0e0e0; font-weight: bold;" colspan="2">
          #lorsm.Organizations#
Index: openacs-4/packages/lors/lib/course-structure.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.tcl,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/lors/lib/course-structure.tcl	7 Jun 2006 14:36:55 -0000	1.2
+++ openacs-4/packages/lors/lib/course-structure.tcl	12 Jun 2006 01:52:19 -0000	1.3
@@ -115,6 +115,9 @@
                       }
             if {$type eq \"webcontent\" && ![string equal $identifierref {}]} {set href \"$indent<a href='[apm_package_url_from_id_mem $fs_package_id]view/[db_string select_folder_key {select key from fs_folders where folder_id = :folder_id}]/[lorsm::fix_url -url $identifierref]'>$item_title</a>\"} else {set href \"<a href='[lors::object_url -url admin -object_id $res_identifier]'>$item_title</a>\"}]</td>" }
 	{ type   "\#lorsm.Type\#" "no_sort" "<td align=\"center\">$type</td>" }
+        { delete "\#acs-kernel.common_Delete\#" "no_sort" "<td><a href=\"[export_vars -base object-delete {item_id return_url}]\">Delete</a></td>" }
+        { move_up "Move Up" "no_sort" "<td><a href=\"[export_vars -base reorder-items {item_id return_url {dir up}}]\">Move Up</a></td>" }
+        { move_down "Move Down" "no_sort" "<td><a href=\"[export_vars -base reorder-items {item_id return_url {dir down}}]\">Move Down</a></td>" }
     }
 
     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]
@@ -135,8 +138,8 @@
 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 add_type_options [list [list Assessment assessment] [list  Wiki wiki]]
+set add_type_options [list [list Questions assessment] [list  Content wiki]]
 ad_form -name add-new -action object-new -export {man_id} -form {
     {add_type:text(select) {label ""} {options $add_type_options}}
-    {add_new:text(submit) {label "#acs-kernel.common_Add#"}}    
+    {add_new:text(submit) {label {[_ acs-kernel.common_Add]}}}    
 }
\ No newline at end of file
Index: openacs-4/packages/lors/lib/course-structure.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/course-structure.xql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/lors/lib/course-structure.xql	7 Jun 2006 13:54:46 -0000	1.1
+++ openacs-4/packages/lors/lib/course-structure.xql	12 Jun 2006 01:52:19 -0000	1.2
@@ -163,7 +163,7 @@
            AND
                 m.man_id = :man_id
         ORDER BY 
-                o.tree_sortkey, o.object_id
+                 i.sort_order,o.tree_sortkey,o.object_id
 
   </querytext>
 </fullquery>
Index: openacs-4/packages/lors/lib/object-new.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/lib/object-new.tcl,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/lors/lib/object-new.tcl	7 Jun 2006 13:54:46 -0000	1.1
+++ openacs-4/packages/lors/lib/object-new.tcl	12 Jun 2006 01:52:19 -0000	1.2
@@ -7,7 +7,9 @@
 switch $add_type {
     assessment {
         # get a list of assessment
-        set options [db_list_of_lists get_assessments "select o.title,a.assessment_id from as_assessments a, cr_items i, acs_objects o where o.object_id=a.assessment_id and i.latest_revision=a.assessment_id"]
+	set dotlrn_package_id [dotlrn_community::get_community_id]
+	set assessment_package_id [dotlrn_community::get_applet_package_id -community_id $dotlrn_package_id -applet_key dotlrn_assessment]	
+        set options [db_list_of_lists get_assessments "select o.title,a.assessment_id from as_assessments a, cr_items i, acs_objects o where o.object_id=a.assessment_id and i.latest_revision=a.assessment_id and o.package_id=:assessment_package_id"]
     }
     wiki {
         # get a list of all the wiki pages
@@ -38,7 +40,7 @@
     set search_p 1
 }
 
-set return_url [export_vars -base course_structure {man_id}]
+set return_url [export_vars -base course-structure {man_id}]
 
 # show available objects
 set options [concat [list [list "-- Choose --" ""]] $options]
@@ -56,76 +58,76 @@
             # we want one lors item per section
 
             
-            set sections [db_list_of_lists get_sections "select a.section_id,a.name,a.title from as_sectionsx a, as_assessment_section_map m where m.assessment_id=:existing_object and a.section_id=m.section_id"]
-            
+            set sections [db_list_of_lists get_sections "select a.item_id as section_item_id,a.name,a.title from cr_items ci, as_sectionsx a, as_assessment_section_map m where m.assessment_id=:existing_object and a.section_id=m.section_id and ci.latest_revision=m.assessment_id"]
+
             foreach {section} $sections {
-                foreach {section_id section_name section_title} [lrange $section 0 2] {break}
 
+                foreach {section_item_id section_name section_title} [lrange $section 0 2] {break}
+#		ad_return_complaint 1 "$section_name $section_title"
                 # make sure this section isn't already associated with this course
                 # we'll just let an admin add the assessment as many times
-                # as they like, if there a new sections they will get added
+               # as they like, if there a new sections they will get added
                 
-                if {![db_0or1row section_exists "select res_id from ims_cp_resources where identifier=:section_id and man_id=:man_id"]} {
+                if {![db_0or1row section_exists "select res_id from ims_cp_resources where identifier=:section_item_id and man_id=:man_id"]} {
+                    set res_id [lors::imscp::resource_add_from_object \
+                                    -man_id $man_id \
+                                    -object_id $section_item_id \
+                                    -folder_id $item_folder_id]
+		}
+		if {![db_0or1row item_exists "select ims_item_id as item_id from ims_cp_items where org_id=:org_id and identifier='as_sections_' || :section_item_id"]} {
                     set item_id [lors::imscp::item_add_from_object \
-                                     -object_id $section_id \
+                                     -object_id $section_item_id \
                                      -org_id $org_id \
                                      -folder_id $item_folder_id \
                                      -title $section_title]
+		    lors::imscp::item_to_resource_add \
+			-item_id $item_id \
+			-res_id $res_id
 
-                    # FIXME see if anyone is using this resource
-                    # already. objects should be # able to be resources
-                    # without being tied to one manifest, # since you can use
-                    # a resource in more than one course and # it doesn't make
-                    # sense to have a seperate row every time # we reuse an
-                    # object
+		}
+		# FIXME see if anyone is using this resource
+		# already. objects should be # able to be resources
+		# without being tied to one manifest, # since you can use
+		# a resource in more than one course and # it doesn't make
+		# sense to have a seperate row every time # we reuse an
+		# object
                     
-                    set res_id [lors::imscp::resource_add_from_object \
-                                    -man_id $man_id \
-                                    -object_id $section_id \
-                                    -folder_id $item_folder_id]
-
-                    lors::imscp::item_to_resource_add \
-                        -item_id $item_id \
-                        -res_id $res_id
-                } else {
-                    # FIXME update the title of the ims_cp_item for display
-                    # from the section title
-                }
-            }
+	    }
         }
         wiki {
-
+	    
             set page [::Generic::CrItem instantiate \
                           -item_id $existing_object]
             $page instvar {title page_title} {name page_name}
-                if {![db_0or1row section_exists "select res_id from ims_cp_resources where identifier=:existing_object and man_id=:man_id"]} {
-                    set item_id [lors::imscp::item_add_from_object \
-                                     -object_id $existing_object \
-                                     -org_id $org_id \
-                                     -folder_id $item_folder_id \
-                                     -title $page_title]
+	    if {![db_0or1row res_exists "select res_id from ims_cp_resources where identifier=:existing_object and man_id=:man_id"]} {
+		set res_id [lors::imscp::resource_add_from_object \
+				-man_id $man_id \
+				-object_id $existing_object \
+				-folder_id $item_folder_id]
 
-                    # FIXME see if anyone is using this resource
-                    # already. objects should be # able to be resources
-                    # without being tied to one manifest, # since you can use
-                    # a resource in more than one course and # it doesn't make
-                    # sense to have a seperate row every time # we reuse an
-                    # object
-                    
-                    set res_id [lors::imscp::resource_add_from_object \
-                                    -man_id $man_id \
-                                    -object_id $existing_object \
-                                    -folder_id $item_folder_id]
+	    }
+	    if {![db_0or1row item_exists "select ims_item_id from ims_cp_items where org_id=:org_id and identifier='::xowiki::Page_' || :existing_object"]} {	    
+		set item_id [lors::imscp::item_add_from_object \
+				 -object_id $existing_object \
+				 -org_id $org_id \
+				 -folder_id $item_folder_id \
+				 -title $page_title]
+	    }
+	    # FIXME see if anyone is using this resource
+	    # already. objects should be # able to be resources
+	    # without being tied to one manifest, # since you can use
+	    # a resource in more than one course and # it doesn't make
+	    # sense to have a seperate row every time # we reuse an
+	    # object
+	    
+	    lors::imscp::item_to_resource_add \
+		-item_id $item_id \
+		-res_id $res_id
 
-                    lors::imscp::item_to_resource_add \
-                        -item_id $item_id \
-                        -res_id $res_id
-                } else {
-                    # FIXME update the title of the ims_cp_item for display
-                    # from the section title
-                }
         }            
-    }
+    }	
+    ad_returnredirect $return_url
+    ad_script_abort
 }
 
 
Index: openacs-4/packages/lors/tcl/lors-imscp-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-imscp-procs.tcl,v
diff -u -r1.11 -r1.12
--- openacs-4/packages/lors/tcl/lors-imscp-procs.tcl	7 Jun 2006 18:46:42 -0000	1.11
+++ openacs-4/packages/lors/tcl/lors-imscp-procs.tcl	12 Jun 2006 01:52:19 -0000	1.12
@@ -640,7 +640,8 @@
     @option item_id item id to be removed.
     @author Ernie Ghiglione (ErnieG@mm.st)
 } {
-#    db_transaction {
+    db_transaction {
+	content::item::delete -item_id [content::revision::item_id -revision_id $item_id]
         set ret [db_exec_plsql delete_item {
                 select ims_item__delete (
                                     :item_id
@@ -819,15 +820,16 @@
     @option res_id resource id to be removed.
     @author Ernie Ghiglione (ErnieG@mm.st)
 } {
-#    db_transaction {
+    db_transaction {
+	content::item::delete -item_id [content::revision::item_id -revision_id $res_id]
         set ret [db_exec_plsql delete_resource {
                 select ims_resource__delete (
                                     :res_id
                                     );
 
         }
                 ]
-#    }
+    }
     return $ret
 }
 
@@ -1174,13 +1176,15 @@
     if {$title eq ""} {
         set title $object(title)
     }
+    
     set item_id [lors::imscp::item_add \
                      -org_id $org_id \
                      -itm_folder_id $folder_id \
                      -identifier ${object(object_type)}_${object_id} \
                      -identifierref $object_id \
                      -parent_item $parent_item \
-                     -title $object(title)]
+                     -title $title]
+    db_dml set_sort_order "update ims_cp_items set sort_order = (select coalesce(max(sort_order),0) from ims_cp_items where parent_item=:parent_item) + 1 where ims_item_id=:item_id"
 
     return $item_id
 
Index: openacs-4/packages/lors/tcl/lors-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lors/tcl/lors-procs.tcl,v
diff -u -r1.3 -r1.4
--- openacs-4/packages/lors/tcl/lors-procs.tcl	7 Jun 2006 13:52:01 -0000	1.3
+++ openacs-4/packages/lors/tcl/lors-procs.tcl	12 Jun 2006 01:52:19 -0000	1.4
@@ -43,9 +43,10 @@
                     # FIXME either 1) make this magically work
                     # or 2) find the assessment_id and use 
                     # page anchor
+		    set assessment_id [db_string get_assessment_id "select ci.item_id, m.assessment_id from cr_items ci, cr_revisions cr, as_assessment_section_map m where cr.item_id=:object_id and cr.revision_id=m.section_id and ci.latest_revision=assessment_id"]
                     return [export_vars \
                                 -base ../assessment/asm-admin/one-a \
-                                {{section_id $object_id}}]
+                                {assessment_id}]
                 }
                 "::xowiki::Page" {
                     return [export_vars \