Index: openacs-4/packages/assessment/www/asm-admin/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/index.adp,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/asm-admin/index.adp 9 Jun 2005 19:19:48 -0000 1.5 +++ openacs-4/packages/assessment/www/asm-admin/index.adp 18 Aug 2005 17:33:42 -0000 1.6 @@ -1,4 +1,5 @@ +@title;noquote@ @context;noquote@ Index: openacs-4/packages/assessment/www/asm-admin/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/index.tcl,v diff -u -r1.7 -r1.8 --- openacs-4/packages/assessment/www/asm-admin/index.tcl 9 Jun 2005 19:19:48 -0000 1.7 +++ openacs-4/packages/assessment/www/asm-admin/index.tcl 18 Aug 2005 17:33:42 -0000 1.8 @@ -17,9 +17,9 @@ set title "[_ assessment.Administration]" set context [list "[_ assessment.admin]"] set package_id [ad_conn package_id] +set folder_id [as::assessment::folder_id -package_id $package_id] set categories_url [db_string get_category_url {}] set user_id [ad_conn user_id] -set sw_admin [acs_user::site_wide_admin_p -user_id $user_id] set package_admin_p [permission::permission_p -party_id $user_id -object_id $package_id -privilege "admin"] if { $package_admin_p == 0} { @@ -33,11 +33,7 @@ {zipfile:file {label "[_ assessment.Import_QTI_ZIP_File]"}} } -if { $sw_admin } { - set actions [list "[_ assessment.New_Assessment]" assessment-form "[_ assessment.New_Assessment2]" [_ assessment.set_reg_asm] "../admin/set-reg-assessment" [_ assessment.set_reg_asm]] -} else { - set actions [list "[_ assessment.New_Assessment]" assessment-form "[_ assessment.New_Assessment2]"] -} +set actions [list "[_ assessment.New_Assessment]" assessment-form "[_ assessment.New_Assessment2]"] if {[ad_permission_p [acs_magic_object "security_context_root"] "admin"]} { # lappend actions "[_ assessment.Admin_catalog]" "catalog/" "[_ assessment.Admin_catalog]" Index: openacs-4/packages/assessment/www/asm-admin/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/index.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/asm-admin/index.xql 2 Feb 2005 19:04:46 -0000 1.2 +++ openacs-4/packages/assessment/www/asm-admin/index.xql 18 Aug 2005 17:33:42 -0000 1.3 @@ -5,10 +5,10 @@ select ci.item_id as assessment_id, cr.title - from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + from cr_items ci, cr_revisions cr where cr.revision_id = ci.latest_revision - and a.assessment_id = cr.revision_id - and ci.parent_id = cf.folder_id and cf.package_id = :package_id + and ci.content_type = 'as_assessments' + and ci.parent_id = :folder_id order by cr.title @@ -18,12 +18,12 @@ select ci.item_id as assessment_id, cr.title - from cr_folders cf, cr_items ci, cr_revisions cr, as_assessments a + from cr_items ci, cr_revisions cr where cr.revision_id = ci.latest_revision - and a.assessment_id = cr.revision_id - and ci.parent_id = cf.folder_id + and ci.content_type = 'as_assessments' + and ci.parent_id = :folder_id and ci.item_id in (select object_id from acs_permissions where - grantee_id=:user_id and privilege='admin') and cf.package_id = :package_id + grantee_id=:user_id and privilege='admin') order by cr.title Index: openacs-4/packages/assessment/www/asm-admin/results-export.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-export.tcl,v diff -u -r1.6 -r1.7 --- openacs-4/packages/assessment/www/asm-admin/results-export.tcl 18 Apr 2005 11:02:28 -0000 1.6 +++ openacs-4/packages/assessment/www/asm-admin/results-export.tcl 18 Aug 2005 17:33:42 -0000 1.7 @@ -48,25 +48,11 @@ } if {$assessment_data(anonymous_p) == "t"} { - set csv_first_row [list score submission_date] + set csv_first_row_list [list score submission_date] } else { - set csv_first_row [list score submission_date user_id email first_names last_name] + set csv_first_row_list [list score submission_date user_id email 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 $field_name] - } else { - if {[empty_string_p $description]} { - lappend csv_first_row [as::assessment::quote_export -text $title] - } else { - lappend csv_first_row [as::assessment::quote_export -text "$title / $description"] - } - } - } - set start_date_sql "" set end_date_sql "" if {![empty_string_p $start_time]} { @@ -81,36 +67,85 @@ lappend session_list $session_id if {$assessment_data(anonymous_p) == "t"} { - set csv($session_id) [list $percent_score $submission_date] + set csv_result_list($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]] + set csv_result_list($session_id) [list $percent_score $submission_date $subject_id [as::assessment::quote_export -text [party::email -party_id $subject_id]] [as::assessment::quote_export -text [person::name -person_id $subject_id]]] } } - + if {![empty_string_p $session_list]} { - 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)] + + set section_list [db_list all_sections {}] + + set item_list [list] + foreach section_id $section_list { + set mc_item_list [list] + db_foreach all_section_items {} { + lappend item_list $as_item_item_id + if {$column_format == "name"} { + set csv_first_row($as_item_item_id) [as::assessment::quote_export -text $field_name] } else { - lappend csv($session_id) "" + if {[empty_string_p $description]} { + set csv_first_row($as_item_item_id) [as::assessment::quote_export -text $title] + } else { + set csv_first_row($as_item_item_id) [as::assessment::quote_export -text "$title / $description"] + } } + set item_type [string range $object_type end-1 end] + if {$item_type == "mc"} { + lappend mc_item_list $as_item_item_id + } else { + array set results [as::item_type_$item_type\::results -as_item_item_id $as_item_item_id -section_item_id $section_id -data_type $data_type -sessions $session_list] + foreach session_id $session_list { + if {[info exists results($session_id)]} { + set csv_${as_item_item_id}($session_id) [as::assessment::quote_export -text $results($session_id)] + } else { + set csv_${as_item_item_id}($session_id) "" + } + } + array unset results + } } - - array unset results + + # Now get all MC items in one go + if {![empty_string_p $mc_item_list]} { + db_foreach mc_items {} { + if {[empty_string_p $text_value]} { + set csv_${mc_item_id}($session_id) [as::assessment::quote_export -text $title] + } else { + set csv_${mc_item_id}($session_id) [as::assessment::quote_export -text $text_value] + } + } + array unset results + } } } - set csv_text "[join $csv_first_row ";"]\r\n" + foreach item_id $item_list { + lappend csv_first_row_list $csv_first_row($item_id) + } + set csv_text "[join $csv_first_row_list ";"]\r\n" + foreach session_id $session_list { - append csv_text "[join $csv($session_id) ";"]\r\n" + foreach item_id $item_list { + if {[exists_and_not_null csv_${item_id}($session_id)]} { + lappend csv_result_list($session_id) "[set csv_${item_id}($session_id)]" + } else { + lappend csv_result_list($session_id) "" + } + } + append csv_text "[join $csv_result_list($session_id) ";"]\r\n" } } -after_submit { - ns_set put [ad_conn outputheaders] Content-Disposition "attachment;filename=results.csv" - ns_return 200 "text/plain" "$csv_text" + set tmp_filename [ns_tmpnam] + set tmp_csv_filename "$tmp_filename.csv" + set fp [open $tmp_csv_filename w] + puts $fp "$csv_text" + close $fp + ns_set put [ad_conn outputheaders] Content-Disposition "attachment;filename=results.csv" + ns_return 200 "text/plain" [encoding convertfrom iso8859-1 "$csv_text"] + ns_returnfile 200 text/csv $tmp_csv_filename + # iso-8859-1 } ad_return_template Index: openacs-4/packages/assessment/www/asm-admin/results-export.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/results-export.xql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/assessment/www/asm-admin/results-export.xql 18 Apr 2005 11:02:28 -0000 1.4 +++ openacs-4/packages/assessment/www/asm-admin/results-export.xql 18 Aug 2005 17:33:42 -0000 1.5 @@ -1,47 +1,67 @@ - + + select item_id from as_assessment_section_map asm, cr_items ci where asm.assessment_id = $assessment_rev_id and asm.section_id = ci.latest_revision + + + + + select cr.title, cr.description, o.object_type, i.data_type, i.field_name, - cr.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, - 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 + cr.item_id as as_item_item_id + from as_item_section_map ism, cr_revisions cr, cr_items ci, + as_items i, as_item_rels ir, acs_objects o + where ism.section_id = ci.latest_revision + and ci.item_id = $section_id and cr.revision_id = ism.as_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 + order by o.object_type, 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 s.session_id, s.percent_score, s.subject_id, + to_char(s.completed_datetime, 'YYYY-MM-DD HH24:MI:SS') as submission_date + from as_sessions s, (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 $start_date_sql $end_date_sql order by s.session_id + + + + select d.session_id, d.item_data_id, c.text_value, rc.title, ri.item_id as mc_item_id + 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 $session_list ,]) + and d.as_item_id = ri.revision_id + and d.section_id = rs.revision_id + and rs.item_id = $section_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 + + + +