Index: openacs-4/packages/assessment/www/asm-admin/export/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/export/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/asm-admin/export/index.vuh 1 Feb 2005 22:05:51 -0000 1.1 @@ -0,0 +1,556 @@ +ad_page_contract { + + Export an assessment in IMS QTI format + + @author Natalia P�rez (nperper@it.uc3m.es) + @creation-date 2004-11-25 +} -query { + {assessment_id:integer,optional} +} + +if {[exists_and_not_null assessment_id]} { + # Get the assessment data + as::assessment::data -assessment_id $assessment_id + set download_name $assessment_data(title) + + # We get rid of spaces since they are annoying + regsub -all { } $download_name {_} download_name + + set tmp_dir $download_name + set ext "zip" + + append download_name ".${ext}" + + ad_returnredirect "${assessment_id}/${download_name}" + ad_script_abort +} + +# convenient way to get the values out of a list +foreach {assessment_id download_name} [split [ad_conn path_info] /] {break} + +ad_require_permission $assessment_id admin + +# Get the assessment data +as::assessment::data -assessment_id $assessment_id + +set assessment_id $assessment_data(assessment_rev_id) + + +# First create our top-level document +#set doc [dom createDocument questestinterop] +dom createDocument questestinterop doc +set root [$doc documentElement] + +# Build our XML document +set assessment [$doc createElement assessment] +$assessment setAttribute title $assessment_data(title) +$assessment setAttribute ident $assessment_data(name) +$root appendChild $assessment + +if {![empty_string_p $assessment_data(description)]} { + # + set qticomment [$doc createElement qticomment] + $assessment appendChild $qticomment + set text [$doc createCDATASection $assessment_data(description)] + $qticomment appendChild $text + # + set objectives [$doc createElement objectives] + $assessment appendChild $objectives + # + set material [$doc createElement material] + $objectives appendChild $material + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $assessment_data(description)] + $mattext appendChild $text +} + +if {![empty_string_p $assessment_data(instructions)]} { + # + set rubric [$doc createElement rubric] + $assessment appendChild $rubric + # + set material [$doc createElement material] + $rubric appendChild $material + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $assessment_data(instructions)] + $mattext appendChild $text +} + +# +set assessmentcontrol [$doc createElement assessmentcontrol] +$assessmentcontrol setAttribute feedbackswitch "No" +$assessmentcontrol setAttribute solutionswitch "No" +$assessment appendChild $assessmentcontrol + + +db_multirow sections query_all_sections {} { + #
+ set section [$doc createElement section] + $section setAttribute title $section_title + $section setAttribute ident $section_name + $assessment appendChild $section + # + set selection_ordering [$doc createElement selection_ordering] + $section appendChild $selection_ordering + # + set selection [$doc createElement selection] + $selection_ordering appendChild $selection + # + set selection_number [$doc createElement selection_number] + $selection appendChild $selection_number + set text [$doc createCDATASection "All"] + $selection_number appendChild $text + # + set order [$doc createElement order] + $order setAttribute order_type "Sequential" + $selection_ordering appendChild $order + + db_foreach query_all_items {} { + #reset variables + set cb__display_id {} + unset cb__display_id + set rb__display_id {} + unset rb__display_id + set tb__display_id {} + unset tb__display_id + set ta__display_id {} + unset ta__display_id + set mc_id [as::item_rels::get_target -item_rev_id $as_item_id -type as_item_type_rel] + set item_display_id [as::item_rels::get_target -item_rev_id $as_item_id -type as_item_display_rel] + set items_as_item_id [db_string items_items_as_item_id "SELECT item_id FROM cr_revisions WHERE revision_id = :as_item_id"] + #checkbox + db_0or1row as_item_display_cbx "SELECT as_item_display_id AS cb__display_id FROM as_item_display_cb WHERE as_item_display_id=:item_display_id" + #radiobutton + db_0or1row as_item_display_rbx "SELECT as_item_display_id AS rb__display_id FROM as_item_display_rb WHERE as_item_display_id=:item_display_id" + #textbox (fill-in-the-blank) + db_0or1row as_item_display_tbx "SELECT as_item_display_id AS tb__display_id FROM as_item_display_tb WHERE as_item_display_id=:item_display_id" + #textarea (short answer) + db_0or1row as_item_display_tax "SELECT as_item_display_id AS ta__display_id FROM as_item_display_ta WHERE as_item_display_id=:item_display_id" + + # + set item [$doc createElement item] + $item setAttribute ident $item_name + $section appendChild $item + if {![empty_string_p $item_subtext]} { + # + set objectives [$doc createElement objectives] + $item appendChild $objectives + # + set material [$doc createElement material] + $objectives appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $item_subtext] + $mattext appendChild $text + } + + # + set presentation [$doc createElement presentation] + $item appendChild $presentation + # + set flow [$doc createElement flow] + $presentation appendChild $flow + + if {![info exists tb__display_id]} { + # + set material [$doc createElement material] + $flow appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $item_title] + $mattext appendChild $text + } + + + #find out the item type (multiple choice or multiple response) + if {[info exists cb__display_id] || [info exists rb__display_id]} { + if {[info exists cb__display_id]} { + # checkbox + set rcardinality "Multiple" + } else { + # radiobutton + set rcardinality "Single" + } + # + set response_lid [$doc createElement response_lid] + $response_lid setAttribute ident $item_name + $response_lid setAttribute rcardinality $rcardinality + $response_lid setAttribute rtiming "No" + $flow appendChild $response_lid + # + set render_choice [$doc createElement render_choice] + $response_lid appendChild $render_choice + db_foreach query_all_choices {} { + # + set flow_label [$doc createElement flow_label] + $render_choice appendChild $flow_label + # + set response_label [$doc createElement response_label] + $response_label setAttribute ident $choice_name + $response_label setAttribute rshuffle "Yes" + $flow_label appendChild $response_label + # + set material [$doc createElement material] + $response_label appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $choice_title] + $mattext appendChild $text + } + } else { + #short answer + if {[info exists ta__display_id]} { + # + set response_str [$doc createElement response_str] + $response_str setAttribute ident $item_name + $response_str setAttribute rcardinality "Single" + $response_str setAttribute rtiming "No" + $flow appendChild $response_str + #get rows and cols for painting a textarea (in abs_size is stored as "rows value cols value", we need to add the symbol =) + db_0or1row html_rows_cols "SELECT html_display_options FROM as_item_display_ta WHERE as_item_display_id=:item_display_id" + set rows "[lindex $html_display_options 1]" + set columns "[lindex $html_display_options 3]" + # + set render_fib [$doc createElement render_fib] + $render_fib setAttribute fibtype "String" + $render_fib setAttribute prompt "Box" + $render_fib setAttribute encoding "UTF-8" + $render_fib setAttribute rows $rows + $render_fib setAttribute columns $columns + $response_str appendChild $render_fib + # + set response_label [$doc createElement response_label] + $response_label setAttribute ident $item_name + $response_label setAttribute rshuffle "Yes" + $render_fib appendChild $response_label + } else { + #fill in the blank + #whether it's a fill-in-blank I have to split by + regsub -all -line -nocase -- "" $html ":" html1 + set item_title1 [split $html1 :] + set longitud [llength $item_title1] + + for {set i 0} {$i<[llength $item_title1]-1} {incr i 2} { + set item_title [lindex $item_title1 $i] + # + set material [$doc createElement material] + $flow appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $item_title] + $mattext appendChild $text + # + set response_str [$doc createElement response_str] + $response_str setAttribute ident $item_name$i + $response_str setAttribute rcardinality "Single" + $response_str setAttribute rtiming "No" + $flow appendChild $response_str + # + set render_fib [$doc createElement render_fib] + $render_fib setAttribute fibtype "String" + $render_fib setAttribute prompt "Box" + $render_fib setAttribute encoding "UTF-8" + $response_str appendChild $render_fib + # + set response_label [$doc createElement response_label] + $response_label setAttribute ident $item_name + $response_label setAttribute rshuffle "Yes" + $render_fib appendChild $response_label + } + } + } + + if { $assessment_data(survey_p) != "t" && ![info exists ta__display_id] } { + # + set resprocessing [$doc createElement resprocessing] + $item appendChild $resprocessing + # + set respcondition [$doc createElement respcondition] + $resprocessing appendChild $respcondition + # + set conditionvar [$doc createElement conditionvar] + $respcondition appendChild $conditionvar + + #fill-in-blank + if {[info exists tb__display_id]} { + set i 0 + db_foreach query_all_choices {} { + # + set or [$doc createElement or] + $conditionvar appendChild $or + set list_choice_title $choice_title + for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name$i + $or appendChild $varequal + set text [$doc createCDATASection [lindex $list_choice_title $j]] + $varequal appendChild $text + } + incr i 2 + } + } else { + + + # + set and [$doc createElement and] + $conditionvar appendChild $and + + set exist_false 0 + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "t" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $and appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } else { + set exist_false 1 + } + } + if { $exist_false == 1 } { + # + set not [$doc createElement not] + $and appendChild $not + # + set or [$doc createElement or] + $not appendChild $or + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "f" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $or appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } + } + } + } + # + set displayfeedback [$doc createElement displayfeedback] + set linkrefid { } + append linkrefid $item_name displayRight + $displayfeedback setAttribute linkrefid $linkrefid + $respcondition appendChild $displayfeedback + + # + set respcondition [$doc createElement respcondition] + $resprocessing appendChild $respcondition + # + set conditionvar [$doc createElement conditionvar] + $respcondition appendChild $conditionvar + + #fill-in-blank + if {[info exists tb__display_id]} { + set i 0 + # + set not [$doc createElement not] + $conditionvar appendChild $not + db_foreach query_all_choices {} { + # + set or [$doc createElement or] + $not appendChild $or + set list_choice_title $choice_title + for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name$i + $or appendChild $varequal + set text [$doc createCDATASection [lindex $list_choice_title $j]] + $varequal appendChild $text + } + incr i 2 + } + + } else { + + # + set or [$doc createElement or] + $conditionvar appendChild $or + + set exist_true 0 + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "f" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $or appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } else { + set exist_true 1 + } + } + if { $exist_true == 1 } { + # + set not [$doc createElement not] + $or appendChild $not + # + set and [$doc createElement and] + $not appendChild $and + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "t" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $and appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } + } + } + } + + # + set displayfeedback [$doc createElement displayfeedback] + set linkrefid { } + append linkrefid $item_name displayWrong + $displayfeedback setAttribute linkrefid $linkrefid + $respcondition appendChild $displayfeedback + + db_foreach query_all_choices {} { + set i 0 + # [info exists tb__display_id] because for fib item choice_correct_answer_p is null + if { $choice_correct_answer_p == "t" || [info exists tb__display_id] } { + set list_choice_title $choice_title + set length_list_choice_title [llength $list_choice_title] + + if {![info exists tb__display_id]} { + set length_list_choice_title 1 + } + + for {set j 0} {$j < $length_list_choice_title} {incr j 1} { + # + set respcondition [$doc createElement respcondition] + $respcondition setAttribute title "adjustscore" + $resprocessing appendChild $respcondition + # + set conditionvar [$doc createElement conditionvar] + $respcondition appendChild $conditionvar + # + set varequal [$doc createElement varequal] + if {[info exists tb__display_id]} { + $varequal setAttribute respident $item_name$i + } else { + $varequal setAttribute respident $item_name + } + $conditionvar appendChild $varequal + if {[info exists tb__display_id]} { + set text [$doc createCDATASection [lindex $list_choice_title $j]] + } else { + set text [$doc createCDATASection $choice_name] + } + $varequal appendChild $text + # + set setvar [$doc createElement setvar] + $setvar setAttribute varname "SCORE" + $setvar setAttribute action "Add" + $respcondition appendChild $setvar + # in fib items choice_percent_score column is null + if {[empty_string_p $choice_percent_score]} { + set choice_percent_score 1 + } + set text [$doc createCDATASection $choice_percent_score] + $setvar appendChild $text + } + } + incr i 2 + } + + #feedback_wrong + if {![empty_string_p $item_feedback_wrong] } { + # + set itemfeedback [$doc createElement itemfeedback] + set ident { } + append ident $item_name displayWrong + $itemfeedback setAttribute ident $ident + $item appendChild $itemfeedback + # + set flow_mat [$doc createElement flow_mat] + $itemfeedback appendChild $flow_mat + # + set material [$doc createElement material] + $flow_mat appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $item_feedback_wrong] + $mattext appendChild $text + } + + #feedback_right + if {![empty_string_p $item_feedback_right]} { + # + set itemfeedback [$doc createElement itemfeedback] + set ident { } + append ident $item_name displayRight + $itemfeedback setAttribute ident $ident + $item appendChild $itemfeedback + # + set flow_mat [$doc createElement flow_mat] + $itemfeedback appendChild $flow_mat + # + set material [$doc createElement material] + $flow_mat appendChild $material + # + set mattext [$doc createElement mattext] + $material appendChild $mattext + set text [$doc createCDATASection $item_feedback_right] + $mattext appendChild $text + } + } + + } + } + + +#puts [$root asXML] + +set outfd "" +append outfd "" +append outfd [$root asXML] + +# publish the object to the file system +set in_path [ns_tmpnam] +file mkdir $in_path + +# store the tree xml into a file +set file_name "$in_path/$assessment_data(title).xml" +set file [open $file_name w 0600] +puts $file $outfd +close $file + +# create a temp dir to put the archive in +set out_path [ns_tmpnam] +file mkdir $out_path + +set out_file [file join ${out_path} ${download_name}] + +# get the archive command +# TODO SECURITY DONT USE GLOBBING +set cmd "zip -r -9 -X '$out_file' *" + +# create the archive +with_catch errmsg { +# TODO SECURITY DONT USE THE SHELL + exec bash -c "cd '$in_path'; $cmd; cd -" +} { + # some day we'll do something useful here + error $errmsg +} + +# return the archive to the connection. +ns_returnfile 200 [ns_guesstype $out_file] $out_file + +# clean everything up +file delete -force $in_path +file delete -force $out_path Index: openacs-4/packages/assessment/www/asm-admin/export/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/export/index.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/asm-admin/export/index.xql 1 Feb 2005 22:05:51 -0000 1.1 @@ -0,0 +1,42 @@ + + + + + + SELECT s.section_id, s.name as section_name, s.title as section_title, s.description as section_description, s.instructions as section_instructions, s.feedback_text as section_feedback_text, s.max_time_to_complete as section_max_time_to_complete + FROM as_sectionsx s, as_assessment_section_map asm, as_assessmentsx a + WHERE s.section_id = asm.section_id + AND asm.assessment_id = a.assessment_id + AND a.assessment_id = :assessment_id + ORDER BY s.section_id + + + + + + SELECT i.as_item_id, i.title as item_title, i.name as item_name, i.description as item_description, i.subtext as item_subtext, i.field_code as item_field_code, i.required_p as item_required_p, i.data_type as item_data_type, i.max_time_to_complete as item_max_time_to_complete, i.feedback_right as item_feedback_right, i.feedback_wrong as item_feedback_wrong + FROM as_itemsx i, as_item_section_map ism + WHERE i.as_item_id = ism.as_item_id AND ism.section_id = :section_id + ORDER BY ism.sort_order + + + + + + SELECT aic.object_id as choice_id, aic.title as choice_title, aic.item_id as choice_item_id, aic.name as choice_name, aic.description as choice_description, aic.choice_id, aic.mc_id, aic.data_type as choice_data_type, aic.numeric_value as choice_numeric_value, aic.text_value as choice_text_value, aic.boolean_value as choice_boolean_value, aic.content_value as choice_content_value, aic.feedback_text as choice_feedback_text, aic.selected_p as choice_selected_p, aic.correct_answer_p as choice_correct_answer_p, aic.sort_order as choice_sort_order, aic.percent_score as choice_percent_score + FROM as_item_choicesx aic + WHERE aic.mc_id=:mc_id + ORDER BY aic.sort_order + + + + + + SELECT * + FROM as_item_choicesx aic + WHERE aic.mc_id=:mc_id + ORDER BY aic.correct_answer_p + + + + Index: openacs-4/packages/assessment/www/asm-admin/view/index-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/view/index-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/asm-admin/view/index-postgresql.xql 1 Feb 2005 22:07:01 -0000 1.1 @@ -0,0 +1,15 @@ + + + + postgresql7.1 + + + + + select content_template__get_root_folder() + + + + + + Index: openacs-4/packages/assessment/www/asm-admin/view/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/view/index.vuh,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/asm-admin/view/index.vuh 1 Feb 2005 22:07:01 -0000 1.1 @@ -0,0 +1,37 @@ +ad_page_contract { + + @author Unknown + @creation-date Unknown + @cvs-id $Id: index.vuh,v 1.1 2005/02/01 22:07:01 annyf Exp $ +} { + revision_id:integer,notnull +} + +# Get the paths +set the_root [ns_info pageroot] +set package_id [ad_conn package_id] + +# Get the IDs + +db_1row revision_info { *SQL* } +set the_url $name +set content_root [as::assessment::folder_id -package_id $package_id] + +set template_root "" + +# Serve the page + +if { [content::init the_url the_root $content_root $template_root public $revision_id $content_type] } { + set file "$the_root/$the_url" + rp_internal_redirect -absolute_path $file +} else { + # ns_returnnotfound + set page "[ad_header {Content Item Not Found}]" + append page "

Content Item Not Found

" + append page "The requested item is not available for viewing. " + append page "The item is either not available on this server or it is not in a publishable state " + append page "Unpublished items can be viewed via the CMS interface if the CMS package is installed.
" + append page "[ad_footer]" + doc_return 200 text/html $page +} + Index: openacs-4/packages/assessment/www/asm-admin/view/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/view/index.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/assessment/www/asm-admin/view/index.xql 1 Feb 2005 22:07:01 -0000 1.1 @@ -0,0 +1,14 @@ + + + + + + + select cri.content_type, cri.name + from cr_items cri, cr_revisions crr + where cri.item_id = crr.item_id + and crr.revision_id = :revision_id + + + +