Index: openacs-4/packages/assessment/www/asm-admin/results-users.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-users.adp,v diff -u -r1.4.2.1 -r1.4.2.2 --- openacs-4/packages/assessment/www/asm-admin/results-users.adp 24 Jan 2007 20:15:30 -0000 1.4.2.1 +++ openacs-4/packages/assessment/www/asm-admin/results-users.adp 7 Jul 2007 00:27:51 -0000 1.4.2.2 @@ -4,9 +4,11 @@

@count_all_users@ users in community, @count_complete@ complete responses, @count_incomplete@ incomplete responses

+

#assessment.Responding_Users#

+ Index: openacs-4/packages/assessment/www/asm-admin/results-users.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-users.tcl,v diff -u -r1.9.2.1 -r1.9.2.2 --- openacs-4/packages/assessment/www/asm-admin/results-users.tcl 24 Jan 2007 20:15:30 -0000 1.9.2.1 +++ openacs-4/packages/assessment/www/asm-admin/results-users.tcl 7 Jul 2007 00:27:51 -0000 1.9.2.2 @@ -8,6 +8,7 @@ assessment_id {start_time:optional ""} {end_time:optional ""} + status:optional,notnull } -properties { context:onevalue page_title:onevalue @@ -21,13 +22,15 @@ # Get the assessment data as::assessment::data -assessment_id $assessment_id +set package_id [ad_conn package_id] +set folder_id [as::assessment::folder_id -package_id $package_id] if {![info exists assessment_data(assessment_id)]} { ad_return_complaint 1 "[_ assessment.Requested_assess_does]" ad_script_abort } set user_id [ad_conn user_id] -set assessment_rev_id $assessment_data(assessment_rev_id) + set page_title "[_ assessment.Results_by_user]" set context [list [list index [_ assessment.admin]] [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] set format "[lc_get formbuilder_date_format], [lc_get formbuilder_time_format]" @@ -53,19 +56,19 @@ regsub -all -- {to_date} $end_time {to_timestamp} end_time } + if {![empty_string_p $start_time]} { set start_date_sql [db_map restrict_start_date] } if {![empty_string_p $end_time]} { set end_date_sql [db_map restrict_end_date] } - #ad_returnredirect [export_vars -base results-users {assessment_id start_time end_time}] } template::list::create \ -name results \ -multirow results \ - -key sessions_id \ + -key session_id \ -elements { session_id { label {[_ assessment.View_Results]} @@ -75,7 +78,7 @@ label {[_ assessment.Name]} } status { - label {#assessment.Status#} + label {\#assessment.Status\#} } completed_datetime { label {[_ assessment.Finish_Time]} @@ -88,17 +91,37 @@ } delete { label {} - display_template {[_ assessment.Delete_Attempts]} + display_template {[_ assessment.Delete_Attempts] + } } - } -main_class { - narrow - } + } -filters { + assessment_id { + where_clause { + a.item_id = :assessment_id + } + } + subject_id { + where_clause { + cs.subject_id = :subject_id + } + } + status { + values {{"[_ assessment.Complete]" complete} {"[_ assessment.Incomplete]" incomplete} {"[_ assessment.Not_Taken]" nottaken}} + where_clause { + (case when :status = 'complete' + then not cs.completed_datetime is null + when :status = 'incomplete' + then cs.completed_datetime is null and ns.session_id is not null + else cs.completed_datetime is null and ns.session_id is null end) + } + } + } -bulk_actions {"#assessment.Send_Email#" send-mail "#assessment.Send_an_email_to_the_selected users#"} \ + -bulk_action_export_vars {assessment_id} template::multirow create subjects subject_id subject_url subject_name -db_multirow -extend { result_url subject_url status delete_url } results assessment_results { -} { +db_multirow -extend { result_url subject_url status delete_url } results assessment_results {} { # to display list of users who answered the assessment if anonymous template::multirow append subjects $subject_id [acs_community_member_url -user_id $subject_id] $subject_name @@ -133,15 +156,13 @@ } } -# FIXME -set dotlrn_installed_p [apm_package_installed_p dotlrn] -if {$dotlrn_installed_p} { - set count_all_users [llength [dotlrn_community::list_users [dotlrn_community::get_community_id]]] -} else { - # TODO get count from subsite - set count_all_users 0 -} - +set count_all_users [db_string q "select count(*) from users u + where u.user_id <> 0 + and exists (select 1 + from acs_object_party_privilege_map + where party_id = u.user_id + and object_id = :assessment_id + and privilege = 'read')" -default 0] set count_complete [template::multirow size subjects] set count_incomplete [expr {$count_all_users - $count_complete}] ad_return_template Index: openacs-4/packages/assessment/www/asm-admin/results-users.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-users.xql,v diff -u -r1.2.2.1 -r1.2.2.2 --- openacs-4/packages/assessment/www/asm-admin/results-users.xql 24 Jan 2007 20:15:30 -0000 1.2.2.1 +++ openacs-4/packages/assessment/www/asm-admin/results-users.xql 7 Jul 2007 00:27:51 -0000 1.2.2.2 @@ -1,7 +1,7 @@ - + select s.session_id, s.subject_id, s.percent_score, to_char(s.completed_datetime, :format) as completed_datetime, @@ -21,4 +21,56 @@ order by s.completed_datetime + + + + select a.title, + a.user_id, a.first_names, a.last_name, + to_char(cs.completed_datetime, :format) as completed_datetime, + to_char(coalesce(cs.last_mod_datetime, ns.last_mod_datetime), :format) as last_mod_datetime, + coalesce(cs.subject_id, ns.subject_id) as subject_id, + coalesce(cs.session_id, ns.session_id) as session_id, + cs.percent_score, + a.last_name || ', ' || a.first_names as subject_name + + from (select a.assessment_id, cr.title, cr.item_id, cr.revision_id, + u.user_id, u.first_names, u.last_name + + from as_assessments a, cr_revisions cr, cr_items ci, acs_users_all u + where a.assessment_id = cr.revision_id + and cr.revision_id = ci.latest_revision + and ci.parent_id = :folder_id + and u.user_id <> 0 + and exists ( + select 1 from acs_object_party_privilege_map + where object_id = :assessment_id + and party_id = u.user_id + and privilege = 'read')) a + left join (select as_sessions.*, cr.item_id + from as_sessions, cr_revisions cr + where session_id in (select max(session_id) + from as_sessions, acs_objects o + where not completed_datetime is null + and o.object_id = session_id + and o.package_id = :package_id + group by subject_id, assessment_id ) + and revision_id=assessment_id) cs + on (a.user_id = cs.subject_id and a.item_id = cs.item_id) + + left join (select * + from as_sessions + where session_id in (select max(session_id) + from as_sessions, acs_objects o + where completed_datetime is null + and o.object_id = session_id + and o.package_id = :package_id + group by subject_id, assessment_id)) ns + on (a.user_id = ns.subject_id and a.assessment_id = ns.assessment_id) + + where true + [list::filter_where_clauses -and -name "results"] + + order by lower(a.title), lower(a.last_name), lower(a.first_names) + + Index: openacs-4/packages/assessment/www/asm-admin/send-mail-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/send-mail-postgresql.xql,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/assessment/www/asm-admin/send-mail-postgresql.xql 1 Feb 2005 22:00:10 -0000 1.1 +++ openacs-4/packages/assessment/www/asm-admin/send-mail-postgresql.xql 7 Jul 2007 00:27:51 -0000 1.1.6.1 @@ -3,7 +3,7 @@ postgresql7.1 - + select '[db_quote $sender_email]' as from_addr, '[db_quote $sender_first_names]' as sender_first_names, @@ -31,17 +31,24 @@ else '' end) as last_name, '[db_quote $community_name]' as community_name, '[db_quote $community_url]' as community_url - from party_approved_member_map, + from parties, - acs_objects - where party_approved_member_map.party_id = $segment_id - and party_approved_member_map.member_id <> $segment_id - and party_approved_member_map.member_id = parties.party_id + acs_objects, + users + where + parties.party_id <> 0 + and parties.party_id = users.user_id and parties.party_id = acs_objects.object_id + and exists (select 1 from acs_object_party_privilege_map m + where m.object_id = $assessment_id + and m.party_id = parties.party_id + and m.privilege = 'read') + + - + select '[db_quote $sender_email]' as from_addr, '[db_quote $sender_first_names]' as sender_first_names, @@ -69,12 +76,12 @@ else '' end) as last_name, '[db_quote $community_name]' as community_name, '[db_quote $community_url]' as community_url - from party_approved_member_map, + from parties, - acs_objects - where party_approved_member_map.party_id = $segment_id - and party_approved_member_map.member_id <> $segment_id - and party_approved_member_map.member_id = parties.party_id + acs_objects, + users + where + parties.party_id = users.user_id and parties.party_id = acs_objects.object_id and parties.party_id in ( select s.subject_id @@ -85,7 +92,7 @@ - + select '[db_quote $sender_email]' as from_addr, '[db_quote $sender_first_names]' as sender_first_names, @@ -113,19 +120,24 @@ else '' end) as last_name, '[db_quote $community_name]' as community_name, '[db_quote $community_url]' as community_url - from party_approved_member_map, + from parties, - acs_objects - where party_approved_member_map.party_id = $segment_id - and party_approved_member_map.member_id <> $segment_id - and party_approved_member_map.member_id = parties.party_id + acs_objects, + users + where + parties.party_id <> 0 + and parties.party_id = users.user_id and parties.party_id = acs_objects.object_id and parties.party_id not in ( select s.subject_id from as_sessions s, cr_revisions r where s.assessment_id = r.revision_id and s.completed_datetime is not null and r.item_id = $assessment_id) + and exists (select 1 from acs_object_party_privilege_map m + where m.object_id = $assessment_id + and m.party_id = parties.party_id + and m.privilege = 'read') @@ -136,7 +148,8 @@ '[db_quote $sender_last_name]' as sender_last_name, parties.email from parties - where parties.party_id in ( + where + parties.party_id in ( select s.subject_id from as_sessions s, cr_revisions r where s.assessment_id = r.revision_id @@ -145,4 +158,17 @@ + + + select '[db_quote $sender_email]' as from_addr, + '[db_quote $sender_first_names]' as sender_first_names, + '[db_quote $sender_last_name]' as sender_last_name, + parties.email + from parties + where + parties.party_id in ([template::util::tcl_to_sql_list $user_ids]) + + + + Index: openacs-4/packages/assessment/www/asm-admin/send-mail.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/send-mail.tcl,v diff -u -r1.3 -r1.3.6.1 --- openacs-4/packages/assessment/www/asm-admin/send-mail.tcl 8 Apr 2005 00:50:40 -0000 1.3 +++ openacs-4/packages/assessment/www/asm-admin/send-mail.tcl 7 Jul 2007 00:27:51 -0000 1.3.6.1 @@ -1,115 +1,122 @@ -ad_page_contract { +# packages/assessment/www/asm-admin/send-mail-to.tcl - this page offers options for sending email regarding - an assessment to various groups - - @param assessment_id +ad_page_contract { - @author dave@thedesignexperience.org - @date July 29, 2002 - @cvs-id $Id: -} { - assessment_id:integer,notnull - {to "responded"} + Choose who to send mail to + + @author Dave Bauer (dave@thedesignexperience.org) + @creation-date 2007-07-06 + @cvs-id $Id$ + +} -query { + {assessment_id ""} + {session_id ""} + {return_url ""} } -properties { context:onevalue page_title:onevalue } set package_id [ad_conn package_id] set user_id [ad_conn user_id] -set sender_id [ad_conn user_id] -permission::require_permission -object_id $package_id -privilege create -permission::require_permission -object_id $assessment_id -privilege admin +permission::require_permission \ + -privilege "admin" \ + -party_id $user_id \ + -object_id $package_id -# Get the assessment data as::assessment::data -assessment_id $assessment_id - -if {![info exists assessment_data(assessment_id)]} { - ad_return_complaint 1 "[_ assessment.Requested_assess_does]" - ad_script_abort -} - set page_title "[_ assessment.Send_Mail]" set assessment_name $assessment_data(title) set context [list [list index [_ assessment.admin]] [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] -db_1row select_sender_info {} -set dotlrn_installed_p [apm_package_installed_p dotlrn] -if {$dotlrn_installed_p} { - set rel_type "dotlrn_member_rel" - set community_id [dotlrn_community::get_community_id] - set segment_id [db_string select_rel_segment_id {}] - set community_name [dotlrn_community::get_community_name $community_id] - set community_url "[ad_parameter -package_id [ad_acs_kernel_id] SystemURL][dotlrn_community::get_community_url $community_id]" +ad_form -name send-mail -has_submit 1 -form { + {subject:text(text) {value $assessment_name} {label "[_ assessment.Message_Subject]"} {html {size 50}}} + {message:text(textarea) {label "[_ assessment.Enter_Message]"} {html {rows 15 cols 60}}} + {assessment_id:text(hidden) {value $assessment_id}} + {formbutton_ok:text(submit) {label "[_ acs-templating.OK]"}} +} +if {[llength $session_id]} { + set options [db_list_of_lists get_session_user_options "select u.last_name || ', ' || u.first_names,user_id from acs_users_all u, as_sessions s where s.session_id in ([template::util::tcl_to_sql_list $session_id]) and u.user_id = s.subject_id"] + ad_form -extend -name send-mail -form { + {user_ids:text(checkbox) {label "[_ assessment.Send_mail_to_the_selected_users]"} {options $options}} + {session_id:text(hidden) {value $session_id}} + } +} else { set n_responses [db_string n_responses {}] + if {$n_responses > 0} { - ad_form -name send-mail -form { - {to:text(radio) {options { - {"[_ assessment.lt_Everyone_eligible_to_]" "all"} - {"[_ assessment.lt_Everyone_who_has_alre]" "responded"} - {"[_ assessment.lt_Everyone_who_has_not_]" "not_responded"}}} - {label "[_ assessment.Send_mail_to]"} - {value $to} - } - } + ad_form -extend -name send-mail -form { + {to:text(radio) {options { + {"[_ assessment.lt_Everyone_eligible_to_]" "all"} + {"[_ assessment.lt_Everyone_who_has_alre]" "responded"} + {"[_ assessment.lt_Everyone_who_has_not_]" "not_responded"}}} + {label "[_ assessment.Send_mail_to]"} + } + } } else { - ad_form -name send-mail -form { - {to:text(radio) {options { - {"[_ assessment.lt_Everyone_eligible_to_]" "all"} - {"[_ assessment.lt_Everyone_who_has_not_]" "not_responded"}}} - {label "[_ assessment.Send_mail_to]"} - {value $to} - } - } + ad_form -extend -name send-mail -form { + {to:text(radio) {options { + {"[_ assessment.lt_Everyone_eligible_to_]" "all"} + {"[_ assessment.lt_Everyone_who_has_not_]" "not_responded"}}} + {label "[_ assessment.Send_mail_to]"} + {value $to} + } + } } -} else { - ad_form -name send-mail -form { - {to:text(radio) {options { - {"[_ assessment.lt_Everyone_who_has_alre]" "responded"}}} - {label "[_ assessment.Send_mail_to]"} - {value ""} - } - } } -ad_form -extend -name send-mail -form { - {subject:text(text) {value $assessment_name} {label "[_ assessment.Message_Subject]"} {html {size 50}}} - {message:text(textarea) {label "[_ assessment.Enter_Message]"} {html {rows 15 cols 60}}} - {assessment_id:text(hidden) {value $assessment_id}} +ad_form -extend -name send-mail -on_request { + if {[info exists options]} { + set user_ids [list] + foreach elm $options { + lappend user_ids [lindex $elm 1] + } + } } -on_submit { + acs_user::get -user_id $user_id -array sender + set sender_email $sender(email) + set sender_first_names $sender(first_names) + set sender_last_name $sender(last_name) set query "" - if {$dotlrn_installed_p} { + if {[info exists to] && $to ne ""} { switch $to { all { - set query [db_map dotlrn_all] + set query [db_map all] } responded { - set query [db_map dotlrn_responded] + set query [db_map responded] } not_responded { - set query [db_map dotlrn_not_responded] + set query [db_map not_responded] } } + } elseif {[info exists user_ids] && [llength $user_ids]} { + set query [db_map list_of_user_ids] } else { set query [db_map responded] } - + bulk_mail::new \ -package_id $package_id \ -from_addr $sender_email \ -subject $subject \ -message $message \ -query $query - ad_returnredirect [export_vars -base one-a {assessment_id}] + if {$return_url eq ""} { + set return_url [export_vars -base one-a {assessment_id}] + } + set redirect_message "[_ assessment.Mail_subject_sent]" + ad_returnredirect -message $redirect_message $return_url ad_script_abort + + } -ad_return_template +m \ No newline at end of file Index: openacs-4/packages/assessment/www/asm-admin/send-mail.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/send-mail.xql,v diff -u -r1.1 -r1.1.6.1 --- openacs-4/packages/assessment/www/asm-admin/send-mail.xql 1 Feb 2005 22:00:10 -0000 1.1 +++ openacs-4/packages/assessment/www/asm-admin/send-mail.xql 7 Jul 2007 00:27:51 -0000 1.1.6.1 @@ -14,15 +14,6 @@ - - - select rel_segments.segment_id - from rel_segments - where rel_segments.group_id = :community_id - and rel_segments.rel_type = :rel_type - - - select count(*) Index: openacs-4/packages/assessment/www/asm-admin/sessions.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/sessions.adp,v diff -u -r1.2 -r1.2.2.1 --- openacs-4/packages/assessment/www/asm-admin/sessions.adp 26 Sep 2006 00:22:46 -0000 1.2 +++ openacs-4/packages/assessment/www/asm-admin/sessions.adp 7 Jul 2007 00:27:51 -0000 1.2.2.1 @@ -1,5 +1,6 @@ - #assessment.All_Users# + @page_title@ + @context@

#assessment.lt_Responses_for_assessm#

#assessment.lt_Responses_of_user_per#

Index: openacs-4/packages/assessment/www/asm-admin/sessions.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/sessions.tcl,v diff -u -r1.2.2.3 -r1.2.2.4 --- openacs-4/packages/assessment/www/asm-admin/sessions.tcl 22 Feb 2007 03:11:56 -0000 1.2.2.3 +++ openacs-4/packages/assessment/www/asm-admin/sessions.tcl 7 Jul 2007 00:27:51 -0000 1.2.2.4 @@ -6,6 +6,7 @@ @author Roel Canicula (roel@solutiongrove.com) @creation-date 2006-06-05 + @arch-tag: cdb2d596-15fc-45ba-9ce1-d648a49a20b7 @cvs-id $Id$ } { @@ -21,16 +22,15 @@ permission::require_permission -object_id $package_id -privilege create set folder_id [as::assessment::folder_id -package_id $package_id] set user_id [ad_conn user_id] - -# hack for dotlrn ideally ad_conn subsite_id would pretend dotlrn was a subsite -if {![apm_package_installed_p dotlrn] \ - || [set members_party_id [dotlrn_community::get_community_id]] eq ""} { - set members_party_id [application_group::group_id_from_package_id \ - -package_id [ad_conn subsite_id]] -} - +set context_object_id $package_id set form [rp_getform] ns_set delkey $form status +set page_title [_ assessment.All_Users] +if {[info exists assessment_id]} { + set context [list [list index [_ assessment.admin]] [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] +} else { + set context [list [list index [_ assessment.admin]] $page_title] +} set base_url [ad_return_url] set actions [list] @@ -48,7 +48,7 @@ if { [info exists assessment_id] } { as::assessment::data -assessment_id $assessment_id - + set context_object_id $assessment_id set actions [linsert $actions 0 "[_ assessment.All_Assessments]" ? "[_ assessment.All_Assessments]"] lappend actions "[_ assessment.Summary]" [export_vars -base item-stats { assessment_id {return_url [ad_return_url]} }] "[_ assessment.Summary]" } @@ -123,7 +123,7 @@ (case when :status = 'complete' then not cs.completed_datetime is null when :status = 'incomplete' - then cs.completed_datetime is null and not ns.session_id is null + then cs.completed_datetime is null and ns.session_id is not null else cs.completed_datetime is null and ns.session_id is null end) } } @@ -140,24 +140,23 @@ from (select a.assessment_id, cr.title, cr.item_id, cr.revision_id, u.user_id, u.first_names, u.last_name - from as_assessments a, cr_revisions cr, cr_items ci, acs_users_all u, - group_member_map g - + from as_assessments a, cr_revisions cr, cr_items ci, acs_users_all u where a.assessment_id = cr.revision_id and cr.revision_id = ci.latest_revision and ci.parent_id = :folder_id - - and g.group_id = :members_party_id - and g.member_id = u.user_id - and acs_permission__permission_p(cr.item_id, u.user_id, 'read')) a - + and u.user_id <> 0 + and exists ( + select 1 from acs_object_party_privilege_map + where object_id = :context_object_id + and party_id = u.user_id + and privilege = 'read')) a left join (select as_sessions.*, cr.item_id from as_sessions, cr_revisions cr where session_id in (select max(session_id) from as_sessions, acs_objects o where not completed_datetime is null - and o.object_id = session_id - and o.package_id = :package_id + and o.object_id = session_id + and o.package_id = :package_id group by subject_id, assessment_id ) and revision_id=assessment_id) cs on (a.user_id = cs.subject_id and a.item_id = cs.item_id) @@ -167,20 +166,13 @@ where session_id in (select max(session_id) from as_sessions, acs_objects o where completed_datetime is null - and o.object_id = session_id - and o.package_id = :package_id - group by subject_id, assessment_id)) ns + and o.object_id = session_id + and o.package_id = :package_id + group by subject_id, assessment_id)) ns on (a.user_id = ns.subject_id and a.assessment_id = ns.assessment_id) where true [list::filter_where_clauses -and -name "sessions"] order by lower(a.title), lower(a.last_name), lower(a.first_names) }] - - - - - - -