Index: openacs-4/packages/lorsm/lib/user-lorsm.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/lorsm/lib/user-lorsm.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/lorsm/lib/user-lorsm.tcl 23 Apr 2004 01:26:41 -0000 1.2 +++ openacs-4/packages/lorsm/lib/user-lorsm.tcl 4 Sep 2004 14:51:19 -0000 1.3 @@ -1,18 +1,23 @@ -# packages/lorsm/lib/user-lorsm.tcl -# -# User portlet view -# -# @author Ernie Ghiglione (ErnieG@mm.st) -# @creation-date 2004-04-10 -# @arch-tag c4c3448b-3f12-43cc-9f96-19b4c4a72a58 -# @cvs-id $Id$ +# packages/lorsm/www/test.tcl -foreach required_param {package_id} { - if {![info exists $required_param]} { - return -code error "$required_param is a required parameter." - } +ad_page_contract { + + testing background + + @author Ernie Ghiglione (ErnieG@mm.st) + @creation-date 2004-06-15 + @arch-tag: 9d893919-9a02-45cd-b6ad-19e3a34ba747 + @cvs-id $Id$ +} { + +} -properties { +} -validate { +} -errors { } +#set package_id $list_of_packages_ids + + template::list::create \ -name d_courses \ -multirow d_courses \ @@ -23,38 +28,89 @@ course_name { label "Course Name" display_col course_name - link_url_eval {[site_node::get_url_from_object_id -object_id $context_id]delivery/?[export_vars man_id]} + html { width 70% } + link_url_eval {[site_node::get_url_from_object_id -object_id $lorsm_instance_id]delivery/?[export_vars man_id]} link_html {title "Access Course"} } - creation_user { - label "Owner" - display_eval {[person::name -person_id $creation_user]} - link_url_eval {[acs_community_member_url -user_id $creation_user]} + subject { + label "Subject" + display_eval {[dotlrn_community::get_community_name $community_id]} + html { align center width 20% } + link_url_eval {[dotlrn_community::get_community_url $community_id]} + link_html {title "Access Course"} } - creation_date { - label "Creation Date" - display_eval {[lc_time_fmt $creation_date "%x %X"]} + last_viewed { + label "Last Viewed On" + html { align center width 10% } + display_eval {[lc_time_fmt $last_viewed "%x"]} } + viewed_percent { + label "% Viewed" + html { align right } + display_eval {[lc_numeric $viewed_percent "%.2f"]} + } } -db_multirow -extend { ims_md_id } d_courses select_d_courses { - select - cp.man_id, +set user_id [ad_conn user_id] + +foreach package $package_id { + + db_multirow -extend { ims_md_id last_viewed total_item_count viewed_item_count viewed_percent} -append d_courses select_d_courses { + select + cp.man_id, cp.course_name, cp.identifier, cp.version, cp.fs_package_id, cp.folder_id, acs.creation_user, acs.creation_date, - acs.context_id - from - ims_cp_manifests cp, acs_objects acs - where + acs.context_id, + cpmc.community_id, + cpmc.lorsm_instance_id + from + ims_cp_manifests cp, acs_objects acs, ims_cp_manifest_class cpmc + where cp.man_id = acs.object_id - and - acs.context_id = :package_id -} { - set ims_md_id $man_id + and + cp.man_id = cpmc.man_id + and +-- acs.context_id = :package + cpmc.lorsm_instance_id = :package + and + cpmc.isenabled = 't' + order by acs.creation_date desc + } { + set ims_md_id $man_id + # DEDS: these are expensive + # and for demo purposes only + db_0or1row get_last_viewed { + 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.item_id + and i.org_id = o.org_id + and o.man_id = :man_id + order by v.last_viewed desc + limit 1 + } + set all_items [db_list get_total_items { + select i.item_id + from ims_cp_items i, + ims_cp_organizations o + where o.man_id = :man_id + and i.org_id = o.org_id + }] + set total_item_count [llength $all_items] + set viewed_items [db_list get_viewed_items " + select v.object_id + from views v + where v.viewer_id = :user_id + and v.object_id in ([join $all_items ,]) + "] + set viewed_item_count [llength $viewed_items] + set viewed_percent [expr [expr $viewed_item_count * 1.00] / $total_item_count * 100] + } } -