learning-activity.tcl
Displays Learing Activity Statistics based on workflow instances in the hidden global instance of the tlf-lrn package.
- Location:
- /packages/xotcl-request-monitor/www/learning-activity.tcl
- Author:
- Gustaf Neumann
Related Files
- packages/xotcl-request-monitor/www/learning-activity.tcl
- packages/xotcl-request-monitor/www/learning-activity.adp
[ hide source ] | [ make this the default ]
File Contents
ad_page_contract { Displays Learing Activity Statistics based on workflow instances in the hidden global instance of the tlf-lrn package. @param package_id Package id of the xowiki instance of the course to be displayed @param page_id Optional id of a activity form for filtering @author Gustaf Neumann } -query { {package_id:naturalnum 75595941} {page_id:naturalnum ""} {user_id:naturalnum ""} {limit:naturalnum 10} } -properties { title:onevalue context:onevalue } set title "Learning Activities" set context [list $title] set swa [acs_user::site_wide_admin_p] if {!$swa} { ad_return_forbidden "Permission Denied" \ "<blockquote><p>You don't have permissions to view this page</blockquote>" ad_script_abort } set dimensional { { package_id "Course:" 75595941 { {75595941 "BIS1 ws 2015"} {75611112 "Distributed Development"} } } { limit "Limit:" 10 { {10 "10"} {100 "100"} {300 "300"} {500 "500"} {1000 "1000"} } } } set dimensional_html [ad_dimensional $dimensional] set filter_html "" set filter_clause true if {$user_id ne ""} { append filter_clause " and ic.hkey->'creator_id' = :user_id" acs_user::get -user_id $user_id -array user_info set user_label "$user_info(first_names) $user_info(last_name)" set no_filter_url [export_vars -base learning-activity [list package_id]] append filter_html [subst { <li>Learning activities of $user_info(first_names) $user_info(last_name) (stop <a href="[ns_quotehtml $no_filter_url]">filtering</a>)</li> }] } if {$page_id ne ""} { append filter_clause " and ic.hkey->'form_id' = :page_id" ::xo::db::CrClass get_instance_from_db -item_id $page_id set page_label [$page_id title] set no_filter_url [export_vars -base learning-activity [list package_id user_id]] append filter_html [subst { <li>Users performed activity $page_label (stop <a href="[ns_quotehtml $no_filter_url]">filtering</a>)</li> }] } # Slides of Session 1 # ::99323473 set page_template 67758408 # ::99323473 set hkey {"form_id"=>"99280082", "creator_id"=>"21369757"} # ::99324602 set hkey {"form_id"=>"99280618", "creator_id"=>"21369757"} # ::99307430 set page_template 67758408 # ::99307430 set hkey {"form_id"=>"99280082", "creator_id"=>"5957712"} source $::acs::rootdir/packages/xotcl-request-monitor/www/hkey-parser.tcl if {1} { ################################################################## # # Activity Statistics # ################################################################## TableWidget create t1 \ -columns { AnchorField user -label User AnchorField page -label "Page" AnchorField show -label "Show" AnchorField obj -label "Obj" Field state -label "State" Field last_access -label "Last Modified" Field count -label "Count" -html {align right} Field hkey -label "HKey" } set sql { With RECURSIVE items AS ( select ic.*,o.last_modified from xowiki_form_instance_item_index ic, cr_items cp, acs_objects o where cp.name = :package_id and ic.parent_id = cp.item_id and o.object_id = ic.item_id UNION ALL select ic.*, o.last_modified from xowiki_form_instance_item_index ic, acs_objects o, items where items.item_id = ic.parent_id and o.object_id = ic.item_id ) select ic.item_id as page_id, ic.hkey->'form_id' as activity_id, ic.hkey->'creator_id' as creator_id, ic.last_modified, ic.hkey from items ic where $filter_clause order by ic.last_modified desc limit $limit } set items [::xo::db::Object instantiate_objects \ -sql [subst $sql] \ -initialize false] foreach t [$items children] { set user_id [$t set creator_id] set page_id [$t set page_id] set activity_id [$t set activity_id] acs_user::get -user_id $user_id -array user_info set user_label "$user_info(first_names) $user_info(last_name)" set user_link [export_vars -base learning-activity [list user_id package_id]] set page_link [export_vars -base learning-activity [list [list page_id $activity_id] package_id]] regexp {^([^.]+)[.]} [$t set last_modified] _ time set nice_time [::xowiki::utility pretty_age -timestamp [clock scan $time]] ::xo::db::CrClass get_instance_from_db -item_id $page_id set pretty_link [$page_id pretty_link] set count [::xo::dc get_value count {select count(*) from cr_revisions where item_id = :page_id}] t1 add \ -user $user_label \ -page [$page_id title] \ -page.href $page_link \ -show show \ -show.href $pretty_link \ -obj obj \ -obj.href $pretty_link?m=show-object \ -state [$page_id state] \ -count $count \ -last_access $nice_time \ -hkey [dict remove [::hkey::State parse [$t set hkey]] creator_id form_id] if {$user_link ne ""} { [::template::t1 last_child] set user.href $user_link } } } set t1 [t1 asHTML] # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: