Index: openacs-4/packages/xowf/tcl/test-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/test-item-procs.tcl,v diff -u -r1.7.2.97 -r1.7.2.98 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 8 Jan 2021 11:56:33 -0000 1.7.2.97 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 11 Jan 2021 11:04:43 -0000 1.7.2.98 @@ -35,6 +35,7 @@ Class create TestItemField -superclass FormGeneratorField -parameter { {feedback_level full} {auto_correct:boolean false} + {nr_attachments 15} } -ad_doc { Abstract class for defining common attributes for all Test Item @@ -45,6 +46,26 @@ } TestItemField set abstract 1 + TestItemField instproc text_attachments {} { + set attachments_html "" + if {[:exists_named_sub_component attachments]} { + set attachments_ff [:get_named_sub_component attachments] + set attachments_count [$attachments_ff count_values [$attachments_ff value]] + for {set i 1} {$i <= $attachments_count} {incr i} { + set attachment_label [dict get [:get_named_sub_component_value attachments $i] name] + append attachments_links \ + "
" \ + "\[\[file:question.interaction.attachments.$i|$attachment_label\]\]" \ + "
" + } + if {$attachments_count > 0} { + append attachments_html "
[$attachments_ff label] $attachments_links

" + } + } + #ns_log notice text_attachments=>$attachments_html + return $attachments_html + } + Class create test_item_name -superclass text \ -extend_slot_default validator name -ad_doc { Name sanitizer for test items @@ -57,6 +78,7 @@ return $valid } + ########################################################### # # ::xowiki::formfield::test_item @@ -831,12 +853,15 @@ set widget [test_item set richtextWidget] :create_components [subst { {text {$widget,height=150px,label=#xowf.exercise-text#,plugins=OacsFs}} + {attachments {file,repeat=0..${:nr_attachments},label=#general-comments.Attachments#}} }] set :__initialized 1 } upload_interaction instproc convert_to_internal {} { + next set intro_text [:get_named_sub_component_value text] + append intro_text [:text_attachments] append form \ "
\n" \ "
\n" \