Index: openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml,v diff -u -r1.28 -r1.29 --- openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 25 Jan 2005 21:59:55 -0000 1.28 +++ openacs-4/packages/assessment/catalog/assessment.en_US.ISO-8859-1.xml 26 Jan 2005 11:06:45 -0000 1.29 @@ -144,6 +144,10 @@ Correct Answer Choice Is this the correct answer? Created by + CSV Export + CSV Export Format + Question Identifier + Question Text CSV file Data Type Boolean Index: openacs-4/packages/assessment/tcl/as-assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-assessment-procs.tcl,v diff -u -r1.17 -r1.18 --- openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 23 Jan 2005 20:23:58 -0000 1.17 +++ openacs-4/packages/assessment/tcl/as-assessment-procs.tcl 26 Jan 2005 11:06:45 -0000 1.18 @@ -485,6 +485,18 @@ } } +ad_proc -private as::assessment::quote_export { + -text:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-26 + + Quotes a string for csv export +} { + regsub -all {;} $text {,,} text + return $text +} + ad_proc -private as::assessment::compare_numbers {a b} { @author Timo Hentschel (timo@timohentschel.de) @creation-date 2005-01-18 Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 19 Jan 2005 16:49:14 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.tcl 26 Jan 2005 11:06:45 -0000 1.13 @@ -321,3 +321,33 @@ as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -choice_answer $response -points $points -allow_overwrite_p $allow_overwrite_p } + +ad_proc -public as::item_type_mc::results { + -as_item_item_id:required + -section_item_id:required + -data_type:required + -sessions:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-26 + + Return the results of a given item in a given list of sessions as an array +} { + db_foreach get_results {} { + if {[empty_string_p $text_value]} { + lappend results($session_id) [as::assessment::quote_export -text $title] + } else { + lappend results($session_id) [as::assessment::quote_export -text $text_value] + } + } + + foreach session_id [array names results] { + set results($session_id) [join $results($session_id) ","] + } + + if {[array exists results]} { + return [array get results] + } else { + return + } +} Index: openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql,v diff -u -r1.8 -r1.9 --- openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 7 Jan 2005 16:10:44 -0000 1.8 +++ openacs-4/packages/assessment/tcl/as-item-type-mc-procs.xql 26 Jan 2005 11:06:45 -0000 1.9 @@ -94,4 +94,24 @@ + + + + select d.session_id, d.item_data_id, c.text_value, rc.title + from as_item_data d, as_session_item_map m, cr_revisions ri, cr_revisions rs, + as_item_data_choices dc, as_item_choices c, cr_revisions rc + where d.session_id in ([join $sessions ,]) + and d.as_item_id = ri.revision_id + and ri.item_id = :as_item_item_id + and d.section_id = rs.revision_id + and rs.item_id = :section_item_id + and m.session_id = d.session_id + and m.item_data_id = d.item_data_id + and dc.item_data_id = d.item_data_id + and c.choice_id = dc.choice_id + and c.choice_id = rc.revision_id + + + + Index: openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 19 Jan 2005 16:49:14 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.tcl 26 Jan 2005 11:06:45 -0000 1.13 @@ -122,3 +122,25 @@ } { as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -clob_answer [lindex $response 0] -points "" -allow_overwrite_p $allow_overwrite_p } + +ad_proc -public as::item_type_oq::results { + -as_item_item_id:required + -section_item_id:required + -data_type:required + -sessions:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-26 + + Return the results of a given item in a given list of sessions as an array +} { + db_foreach get_results {} { + set results($session_id) $clob_answer + } + + if {[array exists results]} { + return [array get results] + } else { + return + } +} Index: openacs-4/packages/assessment/tcl/as-item-type-oq-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-oq-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-item-type-oq-procs.xql 25 Dec 2004 13:11:55 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-item-type-oq-procs.xql 26 Jan 2005 11:06:45 -0000 1.4 @@ -32,4 +32,20 @@ + + + + select d.session_id, d.clob_answer + from as_item_data d, as_session_item_map m, cr_revisions ri, cr_revisions rs + where d.session_id in ([join $sessions ,]) + and d.as_item_id = ri.revision_id + and ri.item_id = :as_item_item_id + and d.section_id = rs.revision_id + and rs.item_id = :section_item_id + and m.session_id = d.session_id + and m.item_data_id = d.item_data_id + + + + Index: openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 19 Jan 2005 16:49:14 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-item-type-sa-procs.tcl 26 Jan 2005 11:06:45 -0000 1.13 @@ -122,3 +122,25 @@ } { as::item_data::new -session_id $session_id -subject_id $subject_id -staff_id $staff_id -as_item_id $as_item_id -section_id $section_id -text_answer [lindex $response 0] -points "" -allow_overwrite_p $allow_overwrite_p } + +ad_proc -public as::item_type_sa::results { + -as_item_item_id:required + -section_item_id:required + -data_type:required + -sessions:required +} { + @author Timo Hentschel (timo@timohentschel.de) + @creation-date 2005-01-26 + + Return the results of a given item in a given list of sessions as an array +} { + db_foreach get_results {} { + set results($session_id) $text_answer + } + + if {[array exists results]} { + return [array get results] + } else { + return + } +} Index: openacs-4/packages/assessment/tcl/as-item-type-sa-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-type-sa-procs.xql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/tcl/as-item-type-sa-procs.xql 8 Dec 2004 15:30:34 -0000 1.1 +++ openacs-4/packages/assessment/tcl/as-item-type-sa-procs.xql 26 Jan 2005 11:06:45 -0000 1.2 @@ -22,4 +22,20 @@ + + + + select d.session_id, d.text_answer + from as_item_data d, as_session_item_map m, cr_revisions ri, cr_revisions rs + where d.session_id in ([join $sessions ,]) + and d.as_item_id = ri.revision_id + and ri.item_id = :as_item_item_id + and d.section_id = rs.revision_id + and rs.item_id = :section_item_id + and m.session_id = d.session_id + and m.item_data_id = d.item_data_id + + + + Index: openacs-4/packages/assessment/www/admin/one-a.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/one-a.adp,v diff -u -r1.12 -r1.13 --- openacs-4/packages/assessment/www/admin/one-a.adp 25 Jan 2005 22:03:44 -0000 1.12 +++ openacs-4/packages/assessment/www/admin/one-a.adp 26 Jan 2005 11:06:45 -0000 1.13 @@ -20,11 +20,9 @@ #assessment.View_Responses# #assessment.All# | - #assessment.By_user# - #assessment.CSV_file##assessment.CSV_file# ---> Index: openacs-4/packages/assessment/www/admin/results-export.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/results-export.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/results-export.adp 26 Jan 2005 11:06:45 -0000 1.1 @@ -0,0 +1,7 @@ + +@page_title;noquote@ +@context_bar;noquote@ + +
+ +
Index: openacs-4/packages/assessment/www/admin/results-export.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/results-export.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/results-export.tcl 26 Jan 2005 11:06:45 -0000 1.1 @@ -0,0 +1,88 @@ +ad_page_contract { + Export assessment responses as csv file. + + @author Timo Hentschel (timo@timohentschel.de) + @cvs-id $Id: +} { + assessment_id:integer +} -properties { + context_bar:onevalue + page_title:onevalue +} + +permission::require_permission -object_id $assessment_id -privilege admin + +# 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 assessment_rev_id $assessment_data(assessment_rev_id) +set page_title "[_ assessment.csv_export]" +set context_bar [ad_context_bar [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] + +set export_options [list [list "[_ assessment.csv_export_name]" name] [list "[_ assessment.csv_export_title]" title]] + + +ad_form -name assessment_export -action results-export -form { + {assessment_id:key} + {column_format:text(radio) {label "[_ assessment.csv_export_format]"} {options $export_options} {help_text "[_ assessment.csv_export_format_help]"}} +} -edit_request { +} -on_submit { + if {$assessment_data(anonymous_p) == "t"} { + set csv_first_row [list score submission_date] + } else { + set csv_first_row [list score submission_date user_id email first_names last_name] + } + + set column_list "" + db_foreach all_items {} { + lappend item_list [list $as_item_item_id $section_item_id [string range $object_type end-1 end] $data_type] + if {$column_format == "name"} { + lappend csv_first_row [as::assessment::quote_export -text $name] + } else { + lappend csv_first_row [as::assessment::quote_export -text $title] + } + } + + set session_list "" + db_foreach all_sessions {} { + lappend session_list $session_id + + if {$assessment_data(anonymous_p) == "t"} { + set csv($session_id) [list $percent_score $submission_date] + } else { + set csv($session_id) [list $percent_score $submission_date $subject_id [as::assessment::quote_export -text $email] [as::assessment::quote_export -text $first_names] [as::assessment::quote_export -text $last_name]] + } + } + + foreach one_item $item_list { + util_unlist $one_item as_item_item_id section_item_id item_type data_type + array set results [as::item_type_$item_type\::results -as_item_item_id $as_item_item_id -section_item_id $section_item_id -data_type $data_type -sessions $session_list] + + foreach session_id $session_list { + if {[info exists results($session_id)]} { + lappend csv($session_id) [as::assessment::quote_export -text $results($session_id)] + } else { + lappend csv($session_id) "" + } + } + + array unset results + } + + set csv_text "[join $csv_first_row ";"]\r\n" + foreach session_id $session_list { + append csv_text "[join $csv($session_id) ";"]\r\n" + } +} -after_submit { + ReturnHeaders "text/comma-separated-values" + ns_write $csv_text + ns_conn close + ad_script_abort +} + +ad_return_template Index: openacs-4/packages/assessment/www/admin/results-export.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/admin/Attic/results-export.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/admin/results-export.xql 26 Jan 2005 11:06:45 -0000 1.1 @@ -0,0 +1,46 @@ + + + + + + + select ci.name, cr.title, o.object_type, i.data_type, ci.item_id as as_item_item_id, + rs.item_id as section_item_id + from as_assessment_section_map asm, as_item_section_map ism, cr_revisions cr, + cr_items ci, as_items i, as_item_rels ir, acs_objects o, cr_revisions rs + where asm.assessment_id = :assessment_rev_id + and ism.section_id = asm.section_id + and cr.revision_id = ism.as_item_id + and ci.item_id = cr.item_id + and i.as_item_id = ism.as_item_id + and ir.item_rev_id = i.as_item_id + and ir.rel_type = 'as_item_type_rel' + and o.object_id = ir.target_rev_id + and rs.revision_id = ism.section_id + order by asm.sort_order, ism.sort_order + + + + + + + + select s.session_id, s.percent_score, s.subject_id, p.first_names, p.last_name, + to_char(s.completed_datetime, 'YYYY-MM-DD HH24:MI:SS') as submission_date, + y.email + from as_sessions s, persons p, parties y, + (select max(s2.session_id) as session_id, s2.subject_id + from as_sessions s2, cr_revisions r + where r.item_id = :assessment_id + and s2.assessment_id = r.revision_id + and s2.completed_datetime is not null + group by s2.subject_id) sub + where s.session_id = sub.session_id + and sub.subject_id = p.person_id + and sub.subject_id = y.party_id + order by s.session_id + + + + +