Index: openacs-4/packages/xowf/lib/edit-interaction.wf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/lib/Attic/edit-interaction.wf,v diff -u -N -r1.1.2.2 -r1.1.2.3 --- openacs-4/packages/xowf/lib/edit-interaction.wf 29 Jul 2020 12:03:40 -0000 1.1.2.2 +++ openacs-4/packages/xowf/lib/edit-interaction.wf 25 Oct 2020 19:08:51 -0000 1.1.2.3 @@ -10,24 +10,70 @@ # {entry -name New.Item.TextInteraction -form en:edit-interaction.wf -query p.item_type=Text} # -Action save +Action save -label #xowiki.Form-submit_button# Action initialize -proc activate {obj} { set name [$obj name] if {[$obj is_new_entry $name]} { - set container [[$obj wf_context] wf_container] - set item_type [$container item_type $obj] - $obj title "Fresh '$item_type' interaction ($name)" + set container [[$obj wf_context] wf_container] + set item_type [$container item_type $obj] + $obj title "Fresh '$item_type' interaction ($name)" } } +Action tryout -label #xowf.testrun# -proc activate {obj} { + # + # The action tryout renders the current test-item (question, + # exercise, ...) the same was as it is shown in an quiz/exam. The + # tryout action uses the workflow "en:answer-single-question.wf" for + # rendering it. The instance for filling out the question is created + # as a child object of the test-item. + # + set package_id [$obj package_id] + set wf [$package_id instantiate_forms \ + -forms en:answer-single-question.wf \ + -default_lang en \ + -parent_id [$obj parent_id]] + # + # Call "create-or-use" on the current item and provide the + # parent_id. + # + set url [export_vars -base [$wf pretty_link] { + {m create-or-use} {p.return_url "[::xo::cc url]"} {title "[$obj title]"} + {parent_id "[$obj item_id]" } + }] + # + # For launching the URL we have two options: + # + # (a) just render it, and potentially forget the last edit + # operations of the user (same as "view" above) + # + # ad_returnredirect $url + # ad_script_abort + # + # (b) save page first (like usual workflow options) and call then + # the try-out page. + # + set current_return_url [::xo::cc query_parameter return_url [ad_return_url]] + $obj set instance_attributes \ + [dict merge [$obj set instance_attributes] [list return_url $current_return_url]] + ::xo::cc set_query_parameter return_url $url +} -State initial -actions {save} +Action view -label #xowiki.view# -proc activate {obj} { + set url [export_vars -base [$obj pretty_link] { + {m view} {p.return_url "[::xo::cc url]"} + }] + ad_returnredirect $url + ad_script_abort +} +State initial -actions {save view tryout} + :proc item_type {obj} { set item_type [$obj property item_type] if {$item_type eq ""} { - set item_type [ns_queryget p.item_type] - if {$item_type eq ""} {set item_type ShortText} - $obj set_property -new 1 item_type $item_type + set item_type [ns_queryget p.item_type] + if {$item_type eq ""} {set item_type ShortText} + $obj set_property -new 1 item_type $item_type } return $item_type } @@ -37,8 +83,9 @@ :object-specific { - set container [[:wf_context] wf_container] - ${container}::initial form [${container} form_name_from_item_type [self]] + set container [[:wf_context] wf_container] + set form_name [${container} form_name_from_item_type [self]] + ${container}::initial form $form_name } #