# ### States # State initial \ -actions {submit} \ -label "OK" \ -form_loader start_form \ -view_method edit State done \ -actions {commit} \ -form_loader start_form \ -view_method view # ### Actions # Action submit \ -next_state done \ -proc activate {obj} { $obj set_property -new 1 extra_menu_entries "{config -use survey}" #create wf-iterate item set package_id [$obj package_id] set wf [$package_id lookup -name en:workflow.wf -parent_id [$package_id set folder_id]] ::xowiki::FormPage create wf_iter -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $wf \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set text {} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:wf-iterate \ -set title "Survey" \ -set publish_status ready \ -set parent_id [$obj item_id]\ -instance_attributes { workflow_context_class ::SurveyIterateContext workflow_definition {#setup order of questions here set pages [list en:f0 en:f1 en:f2] Property pages -default $pages :object-specific { :proc eval_filters {position} { #place filters here return [incr position] } } } form_constraints {@cr_fields:hidden} } set iterate [wf_iter save_new] #::xo::db::CrClass get_instance_from_db -item_id $iterate #$iterate set publish_status production #$iterate save #start, done set frage [$package_id lookup -name en:Frage -parent_id [$package_id set folder_id]] ::xowiki::FormPage create start_frage -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set instance_attributes {form {
Thank you for your participation in this online survey.
\ If you choose not to complete the survey in one sitting, you can stop and resume it at a later time.
\ You will automatically be taken back to the page where you left off.
\ Thank you very much for your time! \
} anon_instances yes form_constraints @cr_fields:hidden} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:start \ -set title "Welcome to this survey" \ -set publish_status ready \ -set parent_id [$obj item_id] start_frage save_new ::xowiki::FormPage create done_frage -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set instance_attributes {form {
Thank you very much for your cooperation and for taking the time to respond \ to our survey!
} form_constraints @cr_fields:hidden anon_instances yes} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:done \ -set title "Thank you" \ -set publish_status ready \ -set parent_id [$obj item_id] done_frage save_new #sample question 0 ::xowiki::FormPage create sample0 -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set instance_attributes {form {
 

A: Looked for job using (Multiple answers possible)

B: Found job (Select only one)
I was approached by the employer
"Initiative application"
Contact in conjunction with my master thesis
} \ form_constraints \ {@cr_fields:hidden 0_2:required=no,label=Frage} anon_instances yes} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:f0 \ -set title "Sample Question 0" \ -set publish_status ready \ -set parent_id [$obj item_id] sample0 save_new #sample question 1 ::xowiki::FormPage create sample1 -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set instance_attributes {form {

Which program did you complete? (multiple answers possible)

@1a@

 

} \ form_constraints \ {@cr_fields:hidden {1a:checkbox,required=no,label=Studium,inline=yes,options={{Export and Internationalization \ Management} 16} {{Finance and Accounting} 1} {{Information Systems} 2} {{Management} 4} {{Marketing} 5} {{Supply Chain Management} 11} {{Economics} 12} {{Business Education} 13} {{Business Law} 14} }} anon_instances yes} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:f1 \ -set title "Sample Question 1" \ -set publish_status ready \ -set parent_id [$obj item_id] sample1 save_new #sample question 2 ::xowiki::FormPage create sample2 -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set instance_attributes {form {

Which of the skills and knowledge you acquired during your master’s program do you find most important for your current job?

} \ form_constraints \ {@cr_fields:hidden} anon_instances yes} \ -set package_id $package_id \ -set nls_language en_US \ -set name en:f2 \ -set title "Sample Question 2" \ -set publish_status ready \ -set parent_id [$obj item_id] sample2 save_new } Action commit \ -next_state done ## :object-specific { set ctx [:wf_context] $ctx proc start_form {title} { set default_menu { {survey} } set f [::xowiki::Form new -childof [self] \ -set name en:finish \ -form {{
@_title@ @_name@ @_description@ @_creator@ @extra_menu_entries@ @workflow_definition@ @form_constraints@ @anon_survey@ @survey_text@
} text/html} \ -text { {{child-resources -publish_status "all"}} } \ -anon_instances f \ -form_constraints [subst {@cr_fields:hidden extra_menu_entries:hidden _name:text,label=#tlf-survey.Shortname#,required,validator=name _title:text,label=#tlf-survey.Title#,required _page_order:hidden _creator:label,label=#tlf-survey.Creator# form_constraints:hidden workflow_definition:hidden {anon_survey:select, label=#tlf-survey.Members#, options={{#tlf-survey.Members_closed#} member_list} {{#tlf-survey.Members_all#} login} {{#tlf-survey.Members_anon#} anon},required} {survey_text:richtext,\ editor=ckeditor4,\ label=Popup-Text,\ help_text=#tlf-survey.popup_helptext#, width=500,\ height=500} }] ] } :proc -deprecated view {args} { ad_log Warning "calling deprecated proc (fix me)" :www-view {*}$args } :proc www-view {args} { if {[permission::permission_p -object_id ${:package_id} -privilege "admin"]} { next } else { set wf_iter [${:package_id} lookup -name en:wf-iterate -parent_id ${:item_id} -default_lang all] if {$wf_iter eq 0} { ad_returnredirect [subsite::get_url] ad_script_abort } ::xo::db::CrClass get_instance_from_db -item_id $wf_iter if {${:publish_status} eq "ready"} { set parent [$wf_iter parent_id] switch [:get_property -name anon_survey] { login { auth::require_login set ref [expr {[ns_queryget ref] ne "" ? "&ref=[ns_queryget ref]" : ""}] ad_returnredirect [$wf_iter pretty_link]?m=create-or-use&parent_id=${parent}${ref} ad_script_abort } anon { set token [expr {[ns_queryget p.0token] ne "" ? "&p.0token=[ns_queryget p.0token]" : ""}] ad_returnredirect [$wf_iter pretty_link]?m=create-or-use&parent_id=$parent${token} ad_script_abort } member_list { set survey_id ${:item_id} set user_id [::xo::cc set user_id] if {[::xo::dc 0or1row -prepare integer,integer is_member { select 1 from dual where exists (select 1 from tlf_survey where survey_id = :survey_id and user_id = :user_id and not survey_completed_p ) }]} { ad_returnredirect [$wf_iter pretty_link]?m=create-or-use&parent_id=$parent ad_script_abort } else { #case: survey already completed #let the user access it set survey_item [${:package_id} lookup -name en:___$user_id \ -parent_id $parent -default_lang all] if {$survey_item > 0} { ::xo::db::CrClass get_instance_from_db -item_id $survey_item if {[$survey_item set state] eq "done"} { ad_returnredirect [$survey_item pretty_link] ad_script_abort } } util_user_message -message [_ acs-subsite.403_message] #if a source url has been provided, return to this url set source_url [ns_queryget source ""] if {$source_url ne ""} { ad_returnredirect $source_url ad_script_abort } else { ad_returnredirect [subsite::get_url] ad_script_abort } } } } } else { util_user_message -message "#tlf-survey.closed#" ad_returnredirect . ad_script_abort } } } :proc www-clone {args} { #clone contents as separate survey set x [[::xowiki::FormPage get_folder_children -folder_id ${:item_id} -object_types {::xowiki::FormPage} -publish_status all] children] set survey [${:package_id} lookup -name en:folder.form -parent_id [${:package_id} set folder_id]] set wf [${:package_id} lookup -name en:workflow.wf -parent_id [${:package_id} set folder_id]] set frage [${:package_id} lookup -name en:Frage -parent_id [${:package_id} set folder_id]] ::xowiki::FormPage create folder -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $survey \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1\ -set text {} \ -set package_id ${:package_id} \ -set nls_language en_US \ -set name ${:name}_1 \ -set title ${:title}_1\ -set publish_status production \ -set parent_id ${:parent_id} \ -set state done \ -instance_attributes ${:instance_attributes} set survey_item [folder save_new] #wf-iterate set wf_item [${:package_id} lookup -name en:wf-iterate -parent_id ${:item_id}] if {$wf_item eq 0} { set wf_item [${:package_id} lookup -name de:wf-iterate -parent_id ${:item_id}] if {$wf_item eq 0} { set wf_item [${:package_id} lookup -name wf-iterate -parent_id ${:item_id}] } } set wf_iter [::xo::db::CrClass get_instance_from_db -item_id $wf_item] ::xowiki::FormPage create iter -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $wf \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set text {} \ -set package_id ${:package_id} \ -set nls_language en_US \ -set name en:wf-iterate \ -set title "Survey" \ -set publish_status ready \ -set parent_id $survey_item \ -instance_attributes [$wf_iter instance_attributes] set iterate [iter save_new] foreach item $x { set i [::xo::db::CrClass get_instance_from_db -item_id [$item item_id]] set pt [$i page_template] set pt_name [::xo::dc get_value -prepare integer get_template_name { select title from acs_objects where object_id = :pt }] ns_log notice "tlf-survey import: trying to import [$item item_id] with page_template $pt_name" switch $pt_name { de:Frage - en:Frage { ::xowiki::FormPage create frage -noinit \ -set object_type ::xowiki::FormPage \ -set page_template $frage \ -set do_substitutions 1 \ -set description {} \ -set render_adp 1 \ -set text {} \ -set package_id ${:package_id} \ -set nls_language en_US \ -set name [$i set name] \ -set title [$i set title] \ -set publish_status ready \ -set parent_id $survey_item \ -set instance_attributes [$i set instance_attributes] frage save_new } } } ad_returnredirect . ad_script_abort } } # # Local variables: # mode: tcl # tcl-indent-level: 4 # indent-tabs-mode: nil # End: