We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25979
    • 178 Posts
    Hi, I need to make a couple of test on my site. I need users choose what they think a right queston is and after clicking submit i want it to be summarized, that means - checked whether given answers are correct or not. After that user shold get nmber of points he got and I should have been mailed this.

    I thoght maybe eform would be ok fo that use, but I am not sure. If could give me some pointers it wold be great.

    Now I got cgi scripts, but layout and other stuff must be put inside it so it is not very usefull...

    Regards,

    Mike
      //Why use windows since there is a door?//
      • 25979
      • 178 Posts
      Anybody?
        //Why use windows since there is a door?//
        • 7231
        • 4,205 Posts
        I would set the answers in variables or an array (in a snippet) and have the form on submit check the form values against the correct answer variables. Then it is a matter of doing some math and then sending out the email. You could do this with e-form by making use of one of the built in e-form events to run the function to check the answers. Then output the score to the report chunk and send it out to you by email.

        The e-form documentation has some examples of using events. I have limited experience with e-form so I can’t get into details.

        The principal is to basically set up a series of if statements to compare the form submitted value with the answer stored in the variables. If correct do something, if wrong then do something else. Then calculate the score.

        This is a bit vague answer (sorry) but it is as far as I can go without trying it myself.
          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I would presume that this would require some custom tables in the database, and would need a module for managing the questions and answers as well.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 25979
            • 178 Posts
            hmm, so I should start reading "how to make a module" documentation then? smiley isn’t there any simpler way?
              //Why use windows since there is a door?//
              • 25979
              • 178 Posts
              :) I think I need an easy way to add/change questions and answers. I don’t need to store results. How to mail results I know, I don’t know how to do the est because my knowledge of php is limited smiley

                //Why use windows since there is a door?//
                • 33372
                • 1,611 Posts
                I’ve used eForm with events functions for things like this before and it works very well. It’s a bit more complex to split up something like this into multiple pages using eForm, so I’ve usually created a tabbed interface on the page (using jQuery tabs or some other JavaScript/CSS tabs) to split it up without actually making it multiple pages. That way you don’t need to store anything in a session, cookie, or database table, and the scripting is a lot easier as a result.

                Basically all you need to do is to write an eForm function that fires on the eFormOnBeforeMailSent event. You can check their answers and score the test in there, and you can set placeholders for the emails as well. Any new variables that you add to eForm’s $fields array automatically become placeholders that you can use in your email templates, e.g. if you have

                $fields['test-score']=$score;


                in your function (obviously after calculating the score and formating it properly), then you can just place [+test-score+] in your emails and it will be filled in automatically.

                You can just change the questions and answers in your eForm template and function, or you could work up a module for managing those if they’ll need to be changed frequently by non-technical people. eForm validation doesn’t work as well for forms that are generated dynamically, but that may not matter in this case since people probably won’t submit more than once and if they leave a question blank or something that’s their tough luck. If you do need eForm validation to work completely then you’d probably want your module to generate the eForm chunk so that eForm could parse it properly, which would not be all that difficult to code but is a little bit more advanced than just changing it yourself.
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 25979
                  • 178 Posts
                  oh! Yhis gives some light to my thoughts! I’ll give a try smiley

                  Thx very much each one of you smiley guys & Ladies of course smiley
                    //Why use windows since there is a door?//
                    • 3749
                    • 24,544 Posts
                    I know this is blasphemy, but I have a friend who barely knows HTML and doesn’t know what .CSS and PHP are. He wrote some tutorial quizzes in MS FrontPage and said it was very easy for him.

                    Also, this link will lead you do dozens of programs (some very inexpensive) that will do it for you:

                    http://www.google.com/search?q=making+online+tests&rls=com.microsoft:*&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1

                    You could certainly do it in MODx, but if you’re unfamiliar with MODx and PHP, it might well be a long and difficult task.

                    Bob
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Seems to me this would just be a variation on a poll... maybe modify one of the polling snippets?
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org