Commit 73682bd8 authored by Frank Bergmann's avatar Frank Bergmann

- added code to allow executing simple surveys as part of a workflow

parent d6f9287e
<master>
<property name=title>One Survey: @name;noquote@</property>
<property name="context">@context;noquote@</property>
<br>
@project_menu;noquote@
<if "" ne @message@>
@message;noquote@
<if @enable_master_p@>
<master>
<property name=title>One Survey: @name;noquote@</property>
<property name="context">@context;noquote@</property>
<br>
@project_menu;noquote@
<if "" ne @message@>
@message;noquote@
</if>
<h1><%= [lang::message::lookup "" simple-survey.Fill_out_survey "Please fill out the survey below. Thank you for your cooperation."] %><h1>
<br>
<p>
@description;noquote@
</p>
</if>
<h1><%= [lang::message::lookup "" simple-survey.Fill_out_survey "Please fill out the survey below. Thank you for your cooperation."] %><h1>
<br>
<p>
@description;noquote@
</p>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<form enctype=multipart/form-data method="post" action="process-response">
<%= [export_form_vars return_url ] %>
<tr>
<td class="tabledata"><hr noshade size="1" color="#dddddd"></td>
</tr>
<form enctype=multipart/form-data method="post" action="@package_url;noquote@/process-response">
<%= [export_form_vars survey_id related_object_id related_context_id task_id return_url] %>
<tr>
<td class="tabledata">
<%= [export_form_vars survey_id related_object_id related_context_id] %>
<include src=one_@display_type;noquote@ questions=@questions;noquote@>
<hr noshapde size="1" color="#dddddd">
<input type=submit value="Continue">
......
ad_page_contract {
Display a questionnaire for one survey.
@param survey_id id of displayed survey
# Is this page called as part of a workflow panel?
if {![info exists task]} {
# Skip if this page is called as part of a Workflow panel
ad_page_contract {
Display a questionnaire for one survey.
@param survey_id id of displayed survey
@author philg@mit.edu
@author nstrug@arsdigita.com
@creation-date 28th September 2000
@cvs-id $Id$
} {
survey_id:integer,notnull
{ related_object_id:integer "" }
{ related_context_id:integer "" }
return_url:optional
{ message "" }
{ project_id 0 }
} -validate {
survey_exists -requires {survey_id} {
if ![db_0or1row survey_exists {
select 1 from survsimp_surveys where survey_id = :survey_id
}] {
ad_complain "Survey $survey_id does not exist"
}
}
} -properties {
name:onerow
survey_id:onerow
button_label:onerow
questions:onerow
description:onerow
modification_allowed_p:onerow
return_url:onerow
}
@author philg@mit.edu
@author nstrug@arsdigita.com
@creation-date 28th September 2000
@cvs-id $Id$
# Enable the normal ]po[ master template.
# Queried in the one.adp page
set enable_master_p 1
} else {
} {
survey_id:integer,notnull
{ related_object_id:integer "" }
{ related_context_id:integer "" }
return_url:optional
{ message "" }
{ project_id 0 }
} -validate {
survey_exists -requires {survey_id} {
if ![db_0or1row survey_exists {
select 1 from survsimp_surveys where survey_id = :survey_id
}] {
ad_complain "Survey $survey_id does not exist"
}
# Yes, we are running as part of a WF
set task_id $task(task_id)
set case_id $task(case_id)
set workflow_key $task(workflow_key)
set transition_key $task(transition_key)
# Determine the business object of the WF
# This is usally a im_project, but could be different.
set related_object_id [db_string pid "select object_id from wf_cases where case_id = :case_id" -default ""]
# The "related context" is not used. It could be another business object.
set related_context_id ""
# Deprecated
set project_id 0
if {![info exists return_url]} { set return_url [im_url_with_query] }
set message ""
# Determine the simple-survey from the "Header" of the panel.
# This is not the intended use of the "Header", but comes in very handy.
set wf_panel_header [db_string panel_header "
select header
from wf_context_task_panels
where workflow_key = :workflow_key and
transition_key = :transition_key
" -default ""]
# Check for a survey with the given name:
set survey_id [db_string survey "
select survey_id
from survsimp_surveys
where name = :wf_panel_header
" -default 0]
if {0 == $survey_id} {
ad_return_complaint 1 "<b>Didn't find survey '$wf_panel_header'</b>:
<br>&nbsp;<br>
This page uses the 'Panel Header' of a workflow panel to identify the
simple survey to present to the user.<br>
Please edit your workflow's Panel definition and choose as the header
for this transition the name of an existing Simple Survey.<br>
You can setup new Simple Surveys in Admin -&gt; Simple Survey.<br>"
ad_script_abort
}
} -properties {
name:onerow
survey_id:onerow
button_label:onerow
questions:onerow
description:onerow
modification_allowed_p:onerow
return_url:onerow
# Disable the normal ]po[ master template
# Queried in the one.adp page
set enable_master_p 0
}
ad_require_permission $survey_id survsimp_take_survey
set user_id [ad_maybe_redirect_for_registration]
set package_url "/simple-survey"
db_1row survey_info "select name, description, single_response_p, single_editable_p, display_type
from survsimp_surveys where survey_id = :survey_id"
......
......@@ -8,17 +8,20 @@ ad_page_contract {
@param return_url optional redirect address
@param group_id
@param response_to_question since form variables are now named as response_to_question.$question_id, this is actually array holding user responses to all survey questions.
@param task_id Optionally specified workflow task_id from acs-workflow.
Behave like the user would have clicked the "Task done" button.
@author jsc@arsdigita.com
@author nstrug@arsdigita.com
@creation-date 28th September 2000
@cvs-id $Id$
} {
survey_id:integer,notnull
{ related_object_id:integer "" }
{ related_context_id:integer "" }
return_url:optional
response_to_question:array,optional,multiple,html
survey_id:integer,notnull
{ related_object_id:integer "" }
{ related_context_id:integer "" }
return_url:optional
response_to_question:array,optional,multiple,html
{ task_id "" }
} -validate {
survey_exists -requires { survey_id } {
......@@ -128,11 +131,33 @@ ad_require_permission $survey_id survsimp_take_survey
set user_id [ad_verify_and_get_user_id]
# Do the inserts.
set response_id [db_nextval acs_object_id_seq]
set creation_ip [ad_conn peeraddr]
# -----------------------------------------------------
# Workflow Action
# -----------------------------------------------------
# Close the workflow task if task_id is available
if {"" != $task_id} {
set the_action "finish"
set message [lang::message::lookup "" simple-survey.Task_finished_by_simple_survey "Task finished by Simple Survey"]
set journal_id [wf_task_action \
-user_id $user_id \
-msg $message \
-attributes {} \
-assignments {} \
$task_id \
$the_action \
]
}
# -----------------------------------------------------
# Do the inserts.
# -----------------------------------------------------
db_transaction {
db_exec_plsql create_response {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment