1
votes

I want to implement a question-answer system an ORACLE APEX Application that uses the JQueryMobile Framework. Basically, a question text and a report containing the possible answers is shown on a page. An answer can be selected by clicking on the checkbox. After hitting the submit button, the selected checkboxes containing the Answer Text, an answer_id and the current session_id are to be inserted into a table within the database.

Within Oracle APEX 4.2, I am using a classic report to achieve this. Thich is actually a bad solution, because the checkboxes within the report are shown as simple HTML checkboxes, instead of neat JQueryMobile checkboxes). Anyway, this is my current solution:

Is use this code for creating the classic report:

SELECT 
  APEX_ITEM.CHECKBOX(1,answer_id),
  answer_id,
  answer_text
  FROM ANSWERS
  WHERE question_ID = :P10_Question_ID;

The insert of the data is done via the on submit process "On Submit - After Computations and Validations"

This is the code for the on submit process:

DECLARE
var_session_id NUMBER := :P0_SESSION_ID;
BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
        INSERT INTO STUDENT_ANSWERS
        (answer_id, answer_text, session_id)
        SELECT a.answer_id, a.answer_text, var_session_id
        FROM ANSWERS a
        WHERE a.answer_id = APEX_APPLICATION.G_F01(i)
    END LOOP;
     COMMIT;
    END;

But this solution does not work. Instead, nothing is inserted into the database.

I don't know why the process is not inserting into the database, maybe there is something wrong with this line here WHERE a.answer_id = APEX_APPLICATION.G_F01(i) ?

I even tried a simple update process for testing purposes, but this doesnt work either:

BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.COUNT LOOP
        UPDATE STUDENT_ANSWERS
        SET text = APEX_APPLICATION.G_F03(APEX_APPLICATION.G_F01(i))
        WHERE am_id = APEX_APPLICATION.G_F02(APEX_APPLICATION.G_F01(i));
    END LOOP;
    COMMIT;
END;

Can anybody tell me how to loop through a checkbox within ORACLE APEX 4.2 and how to insert the values ANSWER_ID, ANSWER_TEXT and SESSION_ID into the table STUDENT_ANSWERS after hitting the submit button? If you would know how to do it without using a report but a simple checkbox, this would be even more helpful for me!

2

2 Answers

0
votes

Do your checkboxes reside within the main form tag of your page (you can check this by viewing the page source at runtime)? The Fnn elements must reside within a HTML form to be submitted to the server.

Do you know if the G_Fnn array is even populated?

0
votes

Use APEX_ITEM.CHECKBOX2 instead of APEX_ITEM.CHECKBOX and in the where condition WHERE a.answer_id = to_number(APEX_APPLICATION.G_F01(i));