Sunday, July 18, 2010

Sample code - Quiz Application in Oracle ADF

Hi,

I finally got time to finalize the installation script (was 3 months overdue) of my sample application which i created in Oracle ADF using JDeveloper 11g PS2.

Feel free to play with it identify bugs and report to me :) and I hope it would help you to learn ADF as well.

Download Application : Quiz Application version 1.0
also download Readme

Introduction:
Quiz application allows the logged in users to take random quiz from the list questions stored in the database, No of questions to ask the Admin user can set in the profile after completion of the quiz it displays the score report.





Installation:
  • Open the Quiz Application in JDeveloper PS2.
  • Expand the Database project.
  • Right click the install.sql and run in SQL*Plus.
  • Enter sys account password. 
  • Change your database settings in the Application Resource connection settings.

Running the Application:
  • Run the main.jspx file in the ViewController Project.
  • Log in as demo or admin (default user created in ADF security).
  • Mark your choices you feel is correct (only one choice supported).
  • Press “End Quiz” button on the last question.
  • See the report and “Try Again” to go back to home page.

User Roles
  • “Demo” user can only take part in quiz.
  • “Admin” user can enter, modify the quiz questions and mark the correct choices.
  • “Admin” can also take quiz

Known limitations (would enhance in next update):
  • Currently only one correct choice per question supported.
  • There is no time limit on per question (option available to set in the quiz profile).
  • No history review of the quiz takers.
  • Register as new user option (you can create more users in ADF security)

Happy JDeveloping,
Baig

18 comments:

  1. very good example.but I need to know what is the purpose of login.html and Error.html Pages.I noticed that you use a popup window to made the user logged in,so I think that these two pages are useless? aren't they? or you use them in some way in your Application?

    ReplyDelete
  2. Hi,

    Login.html and error generated automatically by ADF security. i am not using them but instead i created my own custom login window.

    ReplyDelete
  3. I have another notice,although I made many quizes both in admin or demo.I noticed that in the table of quiz_mst(Quiz master) the column of user_name is empty and also TOTAL_CORRECT_CHOICES column is always has a zero value?

    ReplyDelete
  4. You are free to change the app upto your requirements.

    ReplyDelete
  5. I could not get the application module to be running. AM using jdeveloper 11g release 2 version. It is throwing up an exception (oracle.jbo.DMLException) JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/QuizDS.
    Could you help me with this?

    ReplyDelete
  6. Hi Das,

    Change the JDBC properties in Application module configuration to JDBC URL if you want to run the application in Integrated weblogic else create a data source with the same JNDI name in weblogic.

    Search this blog how to create data source
    ZB

    ReplyDelete
  7. Thanks it Worked... I changed it to JDBC URL in the AppModule/

    How you you can a validation where the admin or the applicant can select only one correct choice in the answers (considering the question one correct answer) ?

    ReplyDelete
  8. Das,

    You can modify the code as per your requirement :)

    ZB

    ReplyDelete
  9. I was asking... How to add that validation such that only one choice can be selected ?

    If you can help by writing the code for the bean here, it will be of great help.

    Thanks
    DJ

    ReplyDelete
  10. Hi Baig.
    It's a good example.
    But I can't run your project.

    I have this error:
    Caused by: java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00201: identifier 'QUIZ_PKG.GENERATE_QUIZ' must be declared
    ORA-06550: line1, column 7:
    PL/SQL: Statement ignored

    Could you help me?

    thanks.

    ReplyDelete
    Replies
    1. Hi,

      Plz make sure you have generated objects in the database schema.

      Z

      Delete
  11. Hi Baig,
    Thanks for sharing the information. All your posts are very informative and very helpful.

    I am working on a similar use case and could not figure out how to implement a part. Based on the user response on the current question, can we programmatically hide or display next set of questions based on some logic. Eg: For 3rd question, if i chose one specific answer, the application must not display the next 2 questions? How can we implement it?

    ReplyDelete
    Replies
    1. Hi,

      You can set the view criteria programmatically based on your selection. You might need to change database model a bit.

      Zeeshan

      Delete
  12. can you provide the documentation for this app please

    ReplyDelete
    Replies
    1. Hi,

      The source code is available but i think it is good for who is starting in ADF. I might have lot of bad practices there :)

      Zeeshan

      Delete
  13. Hi can you please provide the steps.So that it would be helpful for beginners.

    ReplyDelete
    Replies
    1. There are lot of examples and tutorials in this blog go through it.

      Delete