Index: openacs-4/packages/lorsm/lib/include.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/lib/include.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/lib/include.adp 12 Jun 2006 02:06:09 -0000 1.1
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: openacs-4/packages/lorsm/lib/include.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/lib/include.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/lib/include.tcl 12 Jun 2006 02:06:09 -0000 1.1
@@ -0,0 +1,13 @@
+ad_page_contract {
+ Include a page from another package
+ wrapped in minimal template
+} {
+ __include:optional
+}
+
+if {![info exists __include] || $__include eq ""} {
+ #dont' return anything
+ ad_script_abort
+}
+
+ad_return_template
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/object-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/object-delete.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/object-delete.tcl 12 Jun 2006 02:06:10 -0000 1.1
@@ -0,0 +1,15 @@
+ad_page_contract {
+ Delete a learning object
+} {
+ item_id
+ return_url
+}
+
+permission::require_permission \
+ -object_id [ad_conn package_id] \
+ -party_id [ad_conn user_id] \
+ -privilege "admin"
+
+lors::imscp::item_delete -item_id $item_id
+
+ad_returnredirect $return_url
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/reorder-items.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/reorder-items.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/reorder-items.tcl 12 Jun 2006 02:06:10 -0000 1.1
@@ -0,0 +1,45 @@
+ad_page_contract {
+ Reorders all the items according to sort_order
+} {
+ item_id:integer,notnull
+ dir:notnull
+}
+
+# Checking privilege over lors-central
+permission::require_permission \
+ -party_id [ad_conn user_id] \
+ -privilege "admin" \
+ -object_id [ad_conn package_id]
+
+set ims_item_id $item_id
+set man_id [db_string get_man_id ""]
+db_1row get_item_sort_and_parent { }
+
+db_transaction {
+ db_list lock_rows "select ims_item_id from ims_cp_items where parent_item=:parent_item for update"
+
+ if { $dir eq "up" } {
+ set next_sort_order [expr { $sort_order - 1 }]
+ } else {
+ set next_sort_order [expr { $sort_order + 1 }]
+ }
+
+ db_dml swap_sort_orders "
+update ims_cp_items
+set sort_order = (case when sort_order = :sort_order :: integer then :next_sort_order :: integer when sort_order = :next_sort_order ::integer then :sort_order end)
+where parent_item=:parent_item
+and sort_order in (:sort_order, :next_sort_order)
+"
+
+ } on_error {
+
+ ad_return_error "Database error" "A database error occured while trying
+to swap your items. Here's the error:
+
+$errmsg
+
+"
+ ad_script_abort
+}
+
+ad_returnredirect "course-structure?man_id=$man_id"
\ No newline at end of file
Index: openacs-4/packages/lorsm/www/reorder-items.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/Attic/reorder-items.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/reorder-items.xql 12 Jun 2006 02:06:10 -0000 1.1
@@ -0,0 +1,28 @@
+
+
+
+
+
+ select
+ man_id
+ from
+ ims_cp_organizations o, ims_cp_items i
+ where
+ ims_item_id=:item_id
+ and o.org_id=i.org_id
+
+
+
+
+
+ select
+ sort_order, parent_item
+ from
+ ims_cp_items
+ where
+ ims_item_id = :ims_item_id
+
+
+
+
+
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.5 -r1.6
--- openacs-4/packages/lorsm/www/delivery/index.tcl 7 Jun 2006 14:05:44 -0000 1.5
+++ openacs-4/packages/lorsm/www/delivery/index.tcl 12 Jun 2006 02:06:10 -0000 1.6
@@ -91,3 +91,4 @@
set track_id 0
ad_set_client_property lorsm studenttrack 0
}
+
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
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/lorsm/www/delivery/index.vuh 12 Jun 2006 02:06:10 -0000 1.1
@@ -0,0 +1,80 @@
+ad_page_contract {
+ check if the page has recorded a redirect url
+}
+
+#get base url
+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/delivery
+##########
+# figure out the next page after we are done with this...
+set ims_item_id [ad_get_client_property lorsm ims_od]
+set man_id [ad_get_client_property lorsm man_id]
+set user_id [ad_conn user_id]
+set item_list [lorsm::get_item_list $man_id $user_id]
+
+set last_item_viewed [db_string select_last_item_viewed {
+ select ims_item_id
+ 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
+} -default "no_item"]
+
+set first_item_id [lindex $item_list 0]
+set first_item_url ""
+
+set curr_index [expr [lsearch -exact $item_list $last_item_viewed]]
+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 [export_vars -base "${lorsm_url}/record-view" -url {{item_id $prev_item_id} man_id}]
+set next_url [export_vars -base "${lorsm_url}/record-view" -url {{item_id $next_item_id} man_id}]
+if {$next_item_id eq ""} {
+ set next_url [export_vars -base ${lorsm_url}/body {man_id}]
+}
+rp_form_put next_url $next_url
+#
+##########
+upvar #[template::adp_level] __adp_master adp_master
+set adp_master [template::util::url_to_file "/www/blank-master"]
+switch $base {
+ assessment {
+ # find assessment package_id
+ # get dotlrn package_id
+ set assessment_package_id [dotlrn_community::get_applet_package_id -community_id $dotlrn_package_id -applet_key dotlrn_assessment]
+ ns_log notice " RESETTING ad conn package id $assessment_package_id"
+ ad_conn -set package_id $assessment_package_id
+
+ if {[string match *view* $path_info]} {
+ rp_internal_redirect /packages/assessment/www/view/index.vuh
+ ad_script_abort
+ }
+
+ 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
+ rp_internal_redirect /packages/lorsm/lib/include
+ } else {
+ ns_log notice "NOPE $path"
+ rp_internal_redirect "/packages/assessment/www/$path"
+ }
+ ad_script_abort
+ }
+ wiki {
+ rp_form_put __include /packages/xowiki/lib/view
+ rp_internal_redirect "/packages/assessment/www/$path"
+ ad_script_abort
+ }
+ default {
+
+ }
+}
Index: openacs-4/packages/lorsm/www/delivery/menu.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/www/delivery/menu.tcl,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/lorsm/www/delivery/menu.tcl 7 Jun 2006 20:03:08 -0000 1.5
+++ openacs-4/packages/lorsm/www/delivery/menu.tcl 12 Jun 2006 02:06:10 -0000 1.6
@@ -145,6 +145,7 @@
# Counter starts at 1 coz Course Index isn't part of the list
db_foreach organizations { } {
+ ns_log notice "menu.tcl org_id=$org_id"
# If the course is from lors-central we need an extra query
if {[apm_package_installed_p lors-central] && [empty_string_p $fs_package_id] } {
@@ -159,8 +160,28 @@
} else {
set extra_query ""
}
- db_foreach sql { } {
+
+ db_foreach sql { SELECT
+
+ i.parent_item,
+ i.ims_item_id,
+ i.item_title as item_title
+ FROM
+ ims_cp_items i, cr_items ci, cr_revisions cr
+ WHERE
+ i.org_id = :org_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 ci.tree_sortkey
+
+ } {
set indent $items_array($ims_item_id)
+ ns_log notice "ims_item_id='${ims_item_id}'"
lappend js [list $indent $ims_item_id $item_title]
}
}
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 -r1.1 -r1.2
--- openacs-4/packages/lorsm/www/delivery/menu.xql 17 May 2005 17:23:27 -0000 1.1
+++ openacs-4/packages/lorsm/www/delivery/menu.xql 12 Jun 2006 02:06:10 -0000 1.2
@@ -1,36 +1,6 @@
-
-
- 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
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.4 -r1.5
--- openacs-4/packages/lorsm/www/delivery/record-view.tcl 7 Jun 2006 14:05:44 -0000 1.4
+++ openacs-4/packages/lorsm/www/delivery/record-view.tcl 12 Jun 2006 02:06:10 -0000 1.5
@@ -26,96 +26,119 @@
set revision_id $item_id
ad_set_client_property lorsm ims_id $item_id
-
+ad_set_client_property lorsm man_id $man_id
set item_id [lorsm::delivery::get_item_id -revision_id $revision_id]
set folder_id [lorsm::delivery::get_folder_id_from_man_id -man_id $man_id]
set lors_root [lorsm::get_root_folder_id]
set folder_name [lorsm::delivery::get_folder_name -folder_id $folder_id]
set content_root [lorsm::delivery::get_item_id_from_name_parent -name $folder_name -parent_id $lors_root]
-ns_log notice "record-view folder_id='${folder_id}' lors_root='${lors_root}' folder_name='${folder_name}' content_root='${content_root}'"
+#ns_log notice "record-view folder_id='${folder_id}' lors_root='${lors_root}' folder_name='${folder_name}' content_root='${content_root}'"
if {[empty_string_p $content_root]} {
# This was uploaded with lorsm so we use the folder_id from the table
set content_root [lorsm::delivery::get_folder_id_from_man_id -man_id $man_id]
}
-ns_log notice "record-view content_root='${content_root}'"
+#ns_log notice "record-view content_root='${content_root}'"
set url2 $folder_name
# Get the href of the item
set href [lorsm::delivery::get_href -ims_item_id $revision_id]
+# handle regular acs_object here since it's not stored in the CR
+
+set type [db_string get_type "select type from ims_cp_resources r, ims_cp_items_to_resources i2r where i2r.ims_item_id=:revision_id and i2r.res_id=r.res_id" -default webcontent]
+
# Get the item title
set item_title [lorsm::delivery::get_ims_item_title -ims_item_id $revision_id]
-set cr_item_id [lors::cr::get_item_id -folder_id $content_root -name $href]
+switch $type {
+ as_sections {
+ # FIXME stupidly assume that a section can only be in one assessment
+ set section_item_id [string trimleft $href "/o/"]
+ db_1row get_assessment_id "select ci.item_id as assessment_id, m.section_id from as_assessment_section_map m, cr_items ci, cr_items ci2 where ci.latest_revision = m.assessment_id and m.section_id=ci2.latest_revision and ci2.item_id=:section_item_id"
+# rp_form_put assessment_id $assessment_id
+# ad_return_complaint 1 "assessment_id = '${assessment_id}' section_id='${section_id}'"
+ ad_returnredirect [export_vars -base assessment/assessment {assessment_id section_id}]
+ ad_script_abort
+ }
+ ::xowiki::Page {
+ set form [rp_getform]
+ ns_set delkey $form item_id
+ rp_form_put item_id [string trimleft $href "/o/"]
+ rp_internal_redirect "/packages/xowiki/lib/view"
+ }
+ default {
+ set cr_item_id [lors::cr::get_item_id -folder_id $content_root -name $href]
-if { [empty_string_p $cr_item_id] } {
- set res_id [lorsm::delivery::get_res_id -ims_item_id $revision_id]
- if { ![empty_string_p $res_id] } {
- set file_id [lorsm::delivery::get_file_id -res_id $res_id]
- if { [empty_string_p $file_id]} {
- set cr_item_id ""
- } else {
- set cr_item_id [lorsm::delivery::get_item_id -revision_id $file_id]
+ if { [empty_string_p $cr_item_id] } {
+ set res_id [lorsm::delivery::get_res_id -ims_item_id $revision_id]
+ if { ![empty_string_p $res_id] } {
+ set file_id [lorsm::delivery::get_file_id -res_id $res_id]
+ if { [empty_string_p $file_id]} {
+ set cr_item_id ""
+ } else {
+ set cr_item_id [lorsm::delivery::get_item_id -revision_id $file_id]
+ }
+ } else {
+ set cr_item_id ""
+ }
}
- } else {
- set cr_item_id ""
- }
-}
-# get already imported data (like an assessment)
-# it normally points relatively to the correct location in some parent folder
-if {[regexp {^\.\.} $href]} {
- ad_returnredirect $href
-}
+ # get already imported data (like an assessment)
+ # it normally points relatively to the correct location in some parent folder
+ if {[regexp {^\.\.} $href]} {
+ ad_returnredirect $href
+ }
-# If no cr_item_id, this item is probably a folder
-# Else deliver the page
+ # If no cr_item_id, this item is probably a folder
+ # Else deliver the page
-if { ![empty_string_p $cr_item_id] } {
+ if { ![empty_string_p $cr_item_id] } {
- # This is the revision of the file (html, jpg, etc)
- set cr_revision_id [item::get_best_revision $cr_item_id]
- set cr_item_mime [item::get_mime_info $cr_revision_id mime_info]
+ # This is the revision of the file (html, jpg, etc)
+ set cr_revision_id [item::get_best_revision $cr_item_id]
+ set cr_item_mime [item::get_mime_info $cr_revision_id mime_info]
- if { ![string equal -length 4 "text" $mime_info(mime_type)] } {
- # It's a file.
- cr_write_content -revision_id $cr_revision_id
- ad_script_abort
+ if { ![string equal -length 4 "text" $mime_info(mime_type)] } {
+ # It's a file.
+ cr_write_content -revision_id $cr_revision_id
+ ad_script_abort
- } else {
-
- set href "$url2/$href"
- regsub -all {//} $href {/} href
- set ims_item_id $cr_revision_id
-
- # lorsm::set_content_root content_root
- lorsm::set_ims_item_id $item_id
+ } else {
+
+ set href "$url2/$href"
+ regsub -all {//} $href {/} href
+ set ims_item_id $cr_revision_id
+
+ # lorsm::set_content_root content_root
+ lorsm::set_ims_item_id $item_id
- # we use nsv variables to set the delivery environment this is a
- # temporary solution until we find something a bit better
+ # we use nsv variables to set the delivery environment this is a
+ # temporary solution until we find something a bit better
- if {[nsv_exists delivery_vars [ad_conn session_id]]} {
- nsv_unset delivery_vars [ad_conn session_id]
- }
+ if {[nsv_exists delivery_vars [ad_conn session_id]]} {
+ nsv_unset delivery_vars [ad_conn session_id]
+ }
- nsv_set delivery_vars [ad_conn session_id] [list]
+ nsv_set delivery_vars [ad_conn session_id] [list]
- nsv_lappend delivery_vars [ad_conn session_id] $content_root
- ad_returnredirect [export_vars -base view/$href {ims_item_id man_id} ]
- ad_script_abort
- }
-} else {
- lorsm::set_ims_item_id $item_id
+ nsv_lappend delivery_vars [ad_conn session_id] $content_root
+ ad_returnredirect [export_vars -base view/$href {ims_item_id man_id} ]
+ ad_script_abort
+ }
+ } else {
+ lorsm::set_ims_item_id $item_id
- # We have no content, so wipe item_id from the lorsm namespace
- # This fixes a strange bug if you click a 'no content' menu item
- # repeatedly and different content appears!
- if { [info exists lorsm::item_id] } {
- set lorsm::item_id ""
+ # We have no content, so wipe item_id from the lorsm namespace
+ # This fixes a strange bug if you click a 'no content' menu item
+ # repeatedly and different content appears!
+ if { [info exists lorsm::item_id] } {
+ set lorsm::item_id ""
+ }
+ rp_internal_redirect -absolute_path [acs_root_dir]/templates/lorsm-default
+ }
}
- rp_internal_redirect -absolute_path [acs_root_dir]/templates/lorsm-default
-}
+}
\ No newline at end of file