Building a dynamic questionnaire
379171Feb 13 2007 — edited Mar 13 2007Hi,
I'm new to APEX and would like some advice on how to build a dynamic questionnaire. The questionnaire would be constructed using meta data held in table such as these:
QUESTIONS holds the QUESTION_ID and QUESTION_TITLE
ANSWER TYPES Holds the Answer Types such as “Yes No Radio Button”, “Colour Drop Down”.
ANSWER TYPE VALUES holds Values of Answer Types Values so for the above Answer Type there would be Y, N and RED, GREEN, YELLOW, BLUE etc
RESPONSE ACTIONS holds the actions to be carried out on a certain response, so Action on Question 8 if Answer was “Y” could be go to Question 14. This table would also hold the Response Scores.
Looking at examples in the forums, I can see that I can build a dynamic report based on SQL Query (PLSQL function body returning SQL query)
e.g.
region source:
declare
q varchar2(4000);
begin
q := mark.sql_query;
return q;
end;
(package mark)
function sql_query return varchar2
is
l_query varchar2(4000);
begin
l_query := 'select q.question from questions q .... etc
-- and use HTMLDB_ITEM.HIDDEN / HTMLDB_ITEM.TEXT etc to format the report
-- and use V('nnnn') to pick up form field values
return l_query;
end sql_query;
The most difficult bit would appear to be the condional branching to a question based on a question reponse.
e.g. If the user answers 'NO' to Q5 'Is the product hazardous' then we would maybe want to skip questions 6 to 8.
Would I dynamically be able to construct a 'select list with submit' which wouild submit the page when certain select lists change and allow me to look at the reponses (G_f vars ?) => and generate a new page with only the relevant questions OR would I be able to hide/show the report form fields using javascript (DIV ? hide show built in APEX js functions ?)
Any help would be welcome
Mark