facebook

How to make a quiz

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #326947 Reply

    bm93
    Member

    Moved to Getting Help forum by support-octavio

    Hello, I wonder to make a quiz, and then on the end, show the result…
    Any idea?
    Thank you guys!

    #326949 Reply

    Hi,

    What kind of quiz? what would be the options? I mean:
    *More A give a result, more B give other result, …
    *Give the result in base the sum of points (a=1, b=2, c=3)
    *Others?

    That’s what I wonder atm, if you share a UI and how do you want to get the result, we could give one or two ideas.

    #326956 Reply

    bm93
    Member

    I mean for example, a quiz about soccer, ten questions, each one with four options. On the end, show the number of correct answers and phrase like, “You are great, go ahead”…
    Something like this.
    Thank you Octavio.

    #327005 Reply

    Max87
    Member

    Hi,
    if you have exact number of questions, which will be repeated, I think it’s simple.
    You have to declare variable for correct answers and wrong answers and later check it’s status.
    I’ll try to make a sample app for you, it’s interesting idea 🙂

    edit: you can try my example(attached), it’s very simple, but it’s a start…let me know, if it helped…

    Attachments:
    You must be logged in to view attached files.
    #327008 Reply

    bm93
    Member

    Oh Max, thank you.
    Well, I know programming on C language, Those like “if” or “else”… “structure repetition” I can do well but i don´t know where to insert on the code (I neither know where to go to access the code on mobione ¬¬), so, if you could help me with these basics I would be glad a lot.
    The way you thought is correct, come on ahead…

    #327009 Reply

    @bm93,

    The javascript code must be added in your <design-file>_custom.js file. Please see the next doc for more information:

    http://genuitec.com/mobile/docs/workingWithGeneratedFiles/workingWithGeneratedFiles.html#editing_javascript

    Let me know if is helpful for you.

    #327011 Reply

    Max87
    Member

    Hi,
    firstly, you have to create your design in Design center. Then, press green Play button, you will get folder <project-name-www> and then you can insert custom javascript code into <project_name_custom.js>

    In my example, open screen1.mobi, press play and screen1_www folder will be created. There you will find screen1_custom.js where you can insert your code.

    I’m working with inserting questions into local database and getting from it randomly now…

    #327012 Reply

    bm93
    Member

    Max, I went something using radiobox, I found a fews on internet but no one using them. Do you have an idea?
    Thank you.

    #327013 Reply

    Max87
    Member

    BM93: yeah, I use radio buttons too 🙂
    Check this document about how to interact with javascript widgets: http://www.genuitec.com/mobile/docs/javaScriptSnippets/javaScriptSnippets.html#radio_button_widget_snippets

    #332895 Reply

    profroofs
    Member

    Hello,

    I am in the 15 day trial period and am deciding on whether to buy the program. I am trying to make an anatomy & physiology quiz but I only know a little C++ from back in the day. I spent all day working with this program and trying to get the quiz to work. When I Unzipped the file that ‘Max87’ created and ran it, it worked perfect!

    So I assumed if I copied and pasted the js code and change the ‘#ms-…” file links that it would work. The program I get is that there is NO transition to Question 2. I can run any question on its own and it works fine, but the transition from 1 to 2 does not work. What is weird is that if I set the transition back to the Home page after the question is answered right then it will go. So why does it not want to go to page 2? I put “#ms-question2″ for when it is right (line 47 of the code).

    function question1()
    {
    value = $(‘input[name=”radio-group1”]:checked’).val()
    if(value==’right’)
    {
    alert(“Right answer”);
    rightAnswer++;
    phoneui.gotoPage(‘#m1-question2’,phoneui.transitions.slideLeft);
    }

    I attached the zip (rar) file.

    Thanks,
    John

    Attachments:
    You must be logged in to view attached files.
    #332929 Reply

    Hi profroofs,

    I’ve review your code and fond a few issues, but I think is because you didn’t share all code, please review that your rightAnswer var is declared. Also, make sure that you include your question2.mobi as Additional Project File, because it is not linked with home and question1 screens directly. I’m almost sure that this is the real problem here.

    Let me know how it goes for you.

    #332935 Reply

    profroofs
    Member

    Thanks octavio! Lovely program! I just had to add “Additional Project Files.”

    1) So I am assuming I have to do that with every new page for each question and every file in the project?

    2) Any simple code you can provide me with that will help me to display at the end what questions the user scored incorrect?

    For example, if I had 3 questions with the following topics (1-Adrenal gland; 2-Pancreas; and 3-Pancreas) and the user got questions 2 and 3 wrong then on the results page it would display:

    2-Pancreas
    3-Pancreas

    So that in this way they could know what subject they need to study more?

    Thanks,
    ProfRoofs
    http://www.profroofs.com

    #333101 Reply

    @profroofs,

    >1) So I am assuming I have to do that with every new page for each question and every file in the project?
    Yes, you should add the other mobi screen with other questions, to avoid first problem.

    >2) Any simple code you can provide me with that will help me to display at the end what questions the user scored incorrect?
    For the correct/incorrect request, please note that it requires basic-medium skill with javascript programming.

    For a better advice could you explain with more details what is the result that you want? i.e. you might want to tell user what is the correct answer of every question with wrong answer or maybe just list what were the incorrect questions, a true/false table were list all question and show what was correct/incorrect. If you can mock up a example design would be more helpful, remember that a image say more than a thousand words.

    #334071 Reply

    profroofs
    Member

    Octavio,

    Thank you for the help.

    I changed the code around a bit. I made it so when you call a function like question1() that instead of an alert it takes you to a new screen. However, my problem is that if I go back back again to the question after running the app once, the radio button is STILL CHECKED with my last response. I wanted a way to clear the radio button after the person submits their answer.

    Here is the snipet of code for the function:

    phoneui.documentReadyHandler = function() {
    }
    var rightAnswer=0;
    var wrongAnswer=0;
    var value;
    function question1()
    {
    value = $(‘input[name=”radio-group1″]:checked’).val()
    if(value==’right’)
    {
    phoneui.gotoPage(‘#m1-QuizBasic01Rans’,phoneui.transitions.flipLeft);
    }
    else
    {
    phoneui.gotoPage(‘#m1-QuizBasic01Wans’,phoneui.transitions.flipLeft);
    }
    radio-group1.clearSelection();
    }

    The last commented out part does not work, is there a substitute for this?

    radio-group1.clearSelection();

    Thanks.

    #334072 Reply

    profroofs
    Member

    Never mind, I found it in the example code:

    $(“input:radio”).removeAttr(“checked”);

    Thanks!

Viewing 15 posts - 1 through 15 (of 16 total)
Reply To: How to make a quiz

You must be logged in to post in the forum log in