Index: openacs-4/packages/lorsm/lib/user-lorsm.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/lib/user-lorsm.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/lib/user-lorsm.xql 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,74 @@
+
+
+
+
+
+ select
+ cp.man_id,
+ cp.course_name,
+ cp.identifier,
+ cp.version,
+ cp.fs_package_id,
+ cp.folder_id,
+ acs.creation_user,
+ acs.creation_date,
+ pf.folder_name,
+ pf.format_name,
+ acs.context_id,
+ cpmc.community_id,
+ cpmc.lorsm_instance_id
+ from
+ ims_cp_manifests cp,
+ acs_objects acs,
+ ims_cp_manifest_class cpmc,
+ lorsm_course_presentation_formats pf
+ where
+ cp.man_id = acs.object_id
+ and
+ cp.man_id = cpmc.man_id
+ and
+ cpmc.lorsm_instance_id = :package
+ $extra_query
+ and
+ cpmc.isenabled = 't'
+ and
+ pf.format_id = cp.course_presentation_format
+ order by acs.creation_date desc
+
+
+
+
+
+ select v.last_viewed
+ from views v,
+ ims_cp_items i,
+ ims_cp_organizations o
+ where v.viewer_id = :user_id
+ and v.object_id = i.ims_item_id
+ and i.org_id = o.org_id
+ and o.man_id = :man_id
+ order by v.last_viewed desc
+ limit 1
+
+
+
+
+
+ select i.ims_item_id
+ from ims_cp_items i,
+ ims_cp_organizations o
+ where o.man_id = :man_id
+ and i.org_id = o.org_id
+
+
+
+
+
+ select v.object_id
+ from views v
+ where v.viewer_id = :user_id
+ and v.object_id in ([join $all_items ,])
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.tcl 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,114 @@
+# packages/lorsm/tcl/lorsm-delivery-procs.tcl
+ad_library {
+ LORS Management Procedures for delivery pages
+
+ @author Miguel Mairn (miguelmarin@viaro.net)
+ @author Viaro Networks www.viaro.net
+}
+
+namespace eval lorsm::delivery {}
+
+ad_proc -private lorsm::delivery::get_item_other_folder {
+ -url:required
+} {
+ Check if the item exists in other folders using the url, returns the item_id or "" fro the especific url
+ @url@ url of the file to check of format folder_name/filename.extension where multiple folders can be add
+} {
+ set item_id ""
+ set folder_part [lindex [split $url "/"] 0]
+
+ # We get a list of all folders that have name equal to folder_part
+ set content_folders [db_list_of_lists get_folders { }]
+
+ # Foreach folder that has that name we are going to check for the file name inside
+ foreach folder $content_folders {
+ set parent_folder [db_string get_parent_folder { } -default ""]
+ set aux [content::item::get_id -item_path $url -root_folder_id $parent_folder -resolve_index "f"]
+ if { ![empty_string_p $aux] } {
+ # This is a match
+ set item_id $aux
+ }
+ }
+ return $item_id
+}
+
+ad_proc -private lorsm::delivery::get_item_id {
+ -revision_id:required
+} {
+ Return the item_id for the especific revision_id
+} {
+ return [db_string get_item_id { }]
+}
+
+ad_proc -private lorsm::delivery::get_folder_id_from_man_id {
+ -man_id:required
+} {
+ Return the folder_id for the especific man_id
+} {
+ return [db_string manifest_info { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_folder_name {
+ -folder_id:required
+} {
+ Returns the folder name for an especific folder_id
+} {
+ return [db_string get_folder_name { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_item_id_from_name_parent {
+ -parent_id:required
+ -name:required
+} {
+ Return the item_id using parent_id and the item name
+} {
+ return [db_string get_content_root { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_href {
+ -ims_item_id:required
+} {
+ Return the href on ims_cp_resources for an especific ims_item_id
+} {
+ return [db_string href { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_ims_item_title {
+ -ims_item_id:required
+} {
+ Returns the item_title stored ons ims_cp_items table for an especific ims_item_id
+} {
+ return [db_string get_item_title { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_res_id {
+ -ims_item_id:required
+} {
+ Returns the associated resource id (res_id) for one ims_item_id
+} {
+ return [db_string get_res_id { } -default ""]
+}
+
+ad_proc -private lorsm::delivery::get_file_id {
+ -res_id:required
+} {
+ Returns the associated file_id to one resource (res_id)
+} {
+ return [db_string get_file_id { } -default ""]
+
+}
+
+ad_proc -private lorsm::delivery::get_file_id_from_ims_item_id {
+ -ims_item_id:required
+ -item_id:required
+} {
+ Returns the file associated to @item_id@ and @ims_item_id@, returns empty string if nothing found
+
+ @ims_item_id@ The ims_item_id that is associated to this file (This is the one comming from the
+ menu on delivery pages )
+ @item_id@ The item_id that has all revisions of one file ( This is fetch from the url and content
+ root variables )
+ returns file_id or empty string
+} {
+ return [db_string get_file { } -default ""]
+}
\ No newline at end of file
Index: openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/tcl/lorsm-delivery-procs.xql 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,139 @@
+
+
+
+
+
+ select
+ folder_id
+ from
+ cr_folders
+ where
+ label = :folder_part
+
+
+
+
+
+ select
+ parent_id
+ from
+ cr_items
+ where
+ item_id = :folder
+
+
+
+
+
+ select
+ item_id
+ from
+ cr_revisions
+ where
+ revision_id = :revision_id
+
+
+
+
+
+ select
+ folder_id
+ from
+ ims_cp_manifests
+ where
+ man_id = :man_id
+
+
+
+
+
+ select
+ name
+ from
+ cr_items
+ where
+ item_id = :folder_id
+
+
+
+
+
+ select
+ item_id
+ from
+ cr_items
+ where
+ name = :name
+ and parent_id = :parent_id
+
+
+
+
+
+ select
+ href
+ from
+ ims_cp_resources r, ims_cp_items_to_resources ir
+ where
+ ir.ims_item_id = :ims_item_id
+ and ir.res_id = r.res_id
+
+
+
+
+
+ select
+ item_title
+ from
+ ims_cp_items
+ where
+ ims_item_id = :ims_item_id
+
+
+
+
+
+ select
+ res_id
+ from
+ ims_cp_items_to_resources
+ where
+ ims_item_id = :ims_item_id
+
+
+
+
+
+ select
+ file_id
+ from
+ ims_cp_files
+ where
+ res_id = :res_id
+
+
+
+
+
+ select
+ revision_id
+ from
+ cr_revisions
+ where
+ item_id = :item_id and
+ revision_id in (
+ select
+ f.file_id
+ from
+ ims_cp_files f,
+ ims_cp_resources r,
+ ims_cp_items_to_resources ir
+ where
+ f.res_id = r.res_id and
+ r.res_id = ir.res_id and
+ ir.ims_item_id = :ims_item_id
+ )
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/course-structure.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/course-structure.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/course-structure.xql 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,184 @@
+
+
+
+
+
+ select
+ cp.man_id,
+ cp.course_name,
+ cp.identifier,
+ text 'Yes' as hello,
+ case
+ when hasmetadata = 't' then 'Yes'
+ else 'No'
+ end as man_metadata,
+ case
+ when isscorm = 't' then 'Yes'
+ else 'No'
+ end as isscorm,
+ cp.fs_package_id,
+ case
+ when fs_package_id is null then 'f'
+ else 't'
+ end as lorsm_p,
+ cp.folder_id,
+ cp.isshared,
+ acs.creation_user,
+ acs.creation_date,
+ acs.context_id,
+ cpmc.isenabled,
+ pf.format_pretty_name,
+ cpmc.istrackable
+ from
+ ims_cp_manifests cp, acs_objects acs, ims_cp_manifest_class cpmc, lorsm_course_presentation_formats pf
+ where
+ cp.man_id = acs.object_id
+ and cp.man_id = :man_id
+ and cp.man_id = cpmc.man_id
+ and cpmc.lorsm_instance_id = :package_id
+ and cp.parent_man_id = 0
+ and cp.course_presentation_format = pf.format_id
+
+
+
+
+
+ select
+ count(revision_id)
+ from
+ cr_revisions
+ where
+ item_id = (
+ select
+ item_id
+ from
+ cr_revisions
+ where
+ revision_id = :man_id
+ )
+
+
+
+
+
+ select
+ item_id
+ from
+ cr_items
+ where
+ name = :instance and
+ parent_id = :root_folder
+
+
+
+
+
+ select
+ count(*) as submanifests
+ from
+ ims_cp_manifests
+ where
+ man_id = :man_id
+ and
+ parent_man_id = :man_id
+
+
+
+
+
+
+ select
+ org.org_id,
+ org.org_title as org_title,
+ org.hasmetadata,
+ tree_level(o.tree_sortkey) as indent
+ from
+ ims_cp_organizations org, acs_objects o
+ where
+ org.org_id = o.object_id
+ and
+ man_id = :man_id
+ order by
+ org_id
+
+
+
+
+
+ SELECT
+ o.object_id,
+ repeat(' ', (tree_level(tree_sortkey) - :indent)* 3) as indent,
+ i.ims_item_id as item_id,
+ i.item_title as item_title,
+ i.hasmetadata,
+ i.org_id,
+ case
+ when i.isshared = 'f' then (
+ 'false'
+ )
+ else 'true'
+ end as isshared,
+ case
+ when i.identifierref <> '' then (
+ SELECT
+ res.href
+ FROM
+ ims_cp_items_to_resources i2r,
+ ims_cp_resources res
+ WHERE
+ i2r.res_id = res.res_id
+ AND
+ i2r.ims_item_id = i.ims_item_id
+)
+ else ''
+ end as identifierref,
+ case
+ when i.identifierref <> '' then (
+ SELECT
+ res.type
+ FROM
+ ims_cp_items_to_resources i2r,
+ ims_cp_resources res
+ WHERE
+ i2r.res_id = res.res_id
+ AND
+ i2r.ims_item_id = i.ims_item_id
+)
+ else ''
+ end as type,
+ m.fs_package_id,
+ m.folder_id,
+ m.course_name
+ FROM
+ acs_objects o, ims_cp_items i, ims_cp_manifests m
+ WHERE
+ o.object_type = 'ims_item_object'
+ AND
+ i.org_id = :org_id
+ AND
+ o.object_id = i.ims_item_id
+ AND
+ i.ims_item_id = (
+ select
+ live_revision
+ from
+ cr_items
+ where
+ item_id = (
+ select
+ item_id
+ from
+ cr_revisions
+ where
+ revision_id = i.ims_item_id
+ )
+ )
+ AND
+ m.man_id = :man_id
+ ORDER BY
+ tree_sortkey, object_id
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/delivery/menu-mk.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/menu-mk.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/delivery/menu-mk.adp 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+ #lorsm.Exit_Course#
#lorsm.return_to_LRN#
+
+
+
+
+
+target="@tree_items.target@">@tree_items.label@
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/delivery/menu-mk.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/menu-mk.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/delivery/menu-mk.tcl 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,247 @@
+# packages/lorsm/www/delivery/index.tcl
+
+ad_page_contract {
+
+ Course Delivery Table of Content
+
+ @author Ernie Ghiglione (ErnieG@mm.st)
+ @creation-date 2004-04-09
+ @arch-tag 553390f0-450e-48db-99f0-c5dcb17978b8
+ @cvs-id $Id: menu-mk.tcl,v 1.1 2005/05/17 17:23:27 miguelm Exp $
+} {
+ man_id:integer,notnull
+ ims_id:integer,notnull,optional
+ track_id:integer,notnull
+} -properties {
+} -validate {
+} -errors {
+}
+
+
+set items_list [list]
+set control_list [list]
+
+set org_id [db_string get_org_id { select org_id from ims_cp_organizations where man_id = :man_id} ]
+# 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
+}]
+
+# 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 } {
+ lappend items_list [list $ims_item_id 1]
+ lappend control_list $ims_item_id
+ incr count
+}
+
+template::multirow create tree_items link label indent last_indent target
+
+while { $count < $items_count } {
+ 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 { [string equal [lsearch -exact $control_list $ims_item_id] "-1"] } {
+ lappend items_list [list $ims_item_id $indent]
+ lappend control_list $ims_item_id
+ incr count
+ }
+ }
+ }
+}
+
+set community_id [dotlrn_community::get_community_id]
+set counter 1
+set user_id [ad_conn user_id]
+
+proc generate_tree_menu { items index rlevel } {
+ # This function is recursive
+
+ set adp_level [template::adp_level]
+ upvar TREE_HASH TREE_HASH
+ upvar index localindex
+ upvar #$adp_level counter counter
+ upvar #$adp_level ims_id ims_id
+ set itemcount [llength $items]
+
+ # Loop through first level items
+ # Sub-items are recursed
+ while { $index < $itemcount } {
+ set one [lindex $items $index]
+ set level [lindex $one 0]
+ set item_id [lindex $one 1]
+ set title [lindex $one 2]
+
+ set title [fs::remove_special_file_system_characters -string $title]
+ regsub {'} $title {\'} title
+
+ # as suggested by Michele Slocovich (michele@sii.it)
+ # http://openacs.org/bugtracker/openacs/com/lors/bug?bug%5fnumber=2100
+ #
+ set title [string map { \{ \\{ \} \\} } $title ]
+
+ upvar #$adp_level man_id man_id
+ set url "[export_vars -base "record-view" \
+ -url {item_id man_id}]"
+
+ if { $index < [expr $itemcount - 1] } {
+ # Get the tree level of the next item
+ set nextlevel [lindex [lindex $items [incr index]] 0]
+
+ # Loop through each item until an item with a different
+ # level is encountered
+ if { $level == $nextlevel } {
+ # Another item in the same level, just add to the list
+ lappend TREE_HASH "TREE_HASH\[\"ims_id.$item_id\"\] = $counter;"
+ lappend levelitems "\['$title', $url\]"
+ template::multirow append tree_items $url $title $level
+ incr counter
+ } elseif { $level < $nextlevel } {
+ # Next item is a sub-item
+ set ocounter $counter
+ incr counter
+ set submenu "[generate_tree_menu $items $index [expr $rlevel + 1]]"
+ lappend TREE_HASH "TREE_HASH\[\"ims_id.$item_id\"\] = $ocounter;"
+ template::multirow append tree_items $url $title $level
+ if { [llength $submenu] } {
+ # There's a submenu
+ lappend levelitems \
+ "\['$title', $url,\n$submenu\n\]"
+ } else {
+ # Child is a lone leaf node, if so, it should have
+ # replace the url, the item_id and decremented counter
+ lappend levelitems \
+ "\['$title', $url\]"
+ }
+
+ # The index should have been adjusted by now to point
+ # to the next item, let's see if the next item has a
+ # lower level, if so, it's time to return
+ if { $index < $itemcount } {
+ set nextlevel [lindex [lindex $items $index] 0]
+ if { $level > $nextlevel } {
+ set localindex $index
+ return [join $levelitems ",\n"]
+ }
+ }
+
+ } else {
+ # Next item has lower level
+ set localindex $index
+
+ # If i'm alone in this level, there's really no point
+ # for my existence, i'll just give my URL to my parent
+ if { ![info exists levelitems] } {
+ upvar url my_url
+ upvar item_id my_item_id
+ set my_url $url
+ set my_item_id $item_id
+
+ return [list]
+ } else {
+ lappend TREE_HASH "TREE_HASH\[\"ims_id.$item_id\"\] = $counter;"
+ template::multirow append tree_items $url $title $level
+ incr counter
+ return [join \
+ [lappend levelitems \
+ "\['$title', $url\]"
+ ] ",\n"
+ ]
+ }
+ }
+ } else {
+ # Terminator, end of the list
+ set localindex [expr $index + 1]
+ lappend TREE_HASH "TREE_HASH\[\"ims_id.$item_id\"\] = $counter;"
+ incr counter
+ return [join \
+ [lappend levelitems \
+ "\['$title', $url\]"
+ ] ",\n"
+ ]
+ }
+ }
+
+ set localindex $index
+ return [join $levelitems ",\n"]
+}
+
+# Counter starts at 1 coz Course Index isn't part of the list
+
+db_foreach organizations {
+ select
+ org.org_id,
+ org.org_title as org_title,
+ org.hasmetadata,
+ man_id,
+ tree_level(o.tree_sortkey) as indent
+ from
+ ims_cp_organizations org, acs_objects o
+ where
+ org.org_id = o.object_id
+ and
+ man_id = :man_id
+ order by
+ org_id
+} {
+
+ db_foreach sql {
+ SELECT
+ -- (tree_level(ci.tree_sortkey) - :indent) as indent,
+ i.parent_item,
+ i.ims_item_id,
+ i.item_title as item_title,
+ cr.mime_type
+ FROM
+ acs_objects o, ims_cp_items i, cr_items ci, cr_revisions cr,
+ ims_cp_items_map im
+ WHERE
+ o.object_type = 'ims_item_object'
+ AND
+ i.org_id = :org_id
+ AND
+ o.object_id = i.ims_item_id
+ AND
+ i.ims_item_id = im.ims_item_id
+ and im.man_id=:man_id
+ and im.org_id=:org_id
+ and im.hide_p='f'
+ and im.community_id=:community_id
+ and ci.item_id=cr.item_id
+ and cr.revision_id=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')
+
+ ORDER BY
+ i.sort_order, o.object_id, ci.tree_sortkey
+ } {
+ foreach item $items_list {
+ set item_id [lindex $item 0]
+ set indent [lindex $item 1]
+ if { [string equal $item_id $ims_item_id] } {
+ lappend js [list $indent $ims_item_id $item_title $man_id $mime_type]
+ }
+ }
+ }
+}
+
+if { [info exists js] } {
+ set last_indent 1
+ foreach l $js {
+ foreach {indent item_id title man_id mime_type} $l {break}
+ template::multirow append tree_items [export_vars -base "record-view" \
+ -url {item_id man_id}] "$title $mime_type" $indent $last_indent
+ set last_indent $indent
+ }
+}
+# return_url
+set return_url [dotlrn_community::get_community_url [dotlrn_community::get_community_id]]
Index: openacs-4/packages/lorsm/www/delivery/menu.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/menu.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/delivery/menu.xql 17 May 2005 17:23:27 -0000 1.1
@@ -0,0 +1,75 @@
+
+
+
+
+
+ SELECT
+ i.parent_item,
+ i.ims_item_id,
+ i.item_title as item_title
+ FROM
+ acs_objects o, ims_cp_items i, cr_items cr
+ WHERE
+ o.object_type = 'ims_item_object'
+ AND
+ i.org_id = :org_id
+ AND
+ o.object_id = i.ims_item_id
+ $extra_query
+ AND
+ cr.item_id = ( select item_id from cr_revisions where revision_id = 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')
+
+ ORDER BY
+ i.sort_order, o.object_id, cr.tree_sortkey
+
+
+
+
+
+ select
+ org_id
+ from
+ ims_cp_organizations
+ where
+ man_id = :man_id
+
+
+
+
+
+ select
+ org.org_id,
+ org.org_title as org_title,
+ org.hasmetadata,
+ tree_level(o.tree_sortkey) as indent
+ from
+ ims_cp_organizations org, acs_objects o
+ where
+ org.org_id = o.object_id
+ and
+ man_id = :man_id
+ order by
+ org_id
+
+
+
+
+
+ select
+ fs_package_id
+ from
+ ims_cp_manifests
+ where
+ man_id = :man_id
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/images/file.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/images/Attic/file.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/lorsm/www/images/folder.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/images/Attic/folder.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/lorsm/www/images/golive.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/images/Attic/golive.gif,v
diff -u
Binary files differ
Index: openacs-4/packages/lorsm/www/images/live.gif
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/images/Attic/live.gif,v
diff -u
Binary files differ