5 Replies Latest reply on May 12, 2008 3:19 PM by Lukewig

    math quiz

    instructorTek
      Hi good day I'm creating a math quiz and I would like the user to enter answers to math questions in text boxes and the program would correct the answers. The problem is that I don't have any idea as to how the user will type algebraic answers that include superscript or mathematical symbols such as pi. e.g the equation "2x squared + 5y" how does the user type x squared if they can't type a superscript, I couldn't even write out the equation in its proper form in this forum because of the inability to include superscript in this message.
        • 1. Re: math quiz
          Nanomedia Level 1
          Create a short list of predefined input words (PI, SQRT,...) and process them at runtime.
          • 2. Re: math quiz
            Level 7
            You are asking for something that you are not likely going to be able to
            do. I mean, how are you going to parse these answers? There are plenty
            of notations that can be used to symbolize math concepts, but basically
            you are asking the students to not only correctly solve the problem, but
            they also need to master whatever answering scheme you come up with.

            For example, the standard way to say "x squared" is "x^2" The carat (^)
            character means 'to the power of'. So now your student needs to know
            that this is how you want the answer framed.

            Let's say the correct answer is "2x squared + 5y". That would be
            something like:

            2x^2+5y

            Of course, that is not the proper "computer" method... since
            multiplication generally requires an asterisk * as opposed to simply
            mashing the characters together like you can on paper. So another way
            of correctly stating the same thing is

            2*x^2+5*y

            And of course, parentheses are commonly used to define the order of
            operations, and sometimes just to make something look neater or more
            easy to follow... so this would be correct also

            (2*x^2)+(5*y)

            also, some people may put in spaces to make things more readable

            2 * x^2 + 5*y

            so, unless you want to make simply entering the student's answer more
            difficult than figuring out the answer to the question, you would need
            to make your scoring script able to read in multiple variants of the
            answer syntax. This is not a trivial task.

            You may be better off doing a multiple choice type answer where you can
            put in the correctly syntaxed answer using the more advanced text
            capabilities of a text member or bitmaps pulled in from other programs.
            • 3. Re: math quiz
              Level 7
              Wow. The newsgroup automatically changed all my carat syntax to actual
              superscripts. whenever you see x^2 and it is written as a superscript,
              it should be x ^ 2 (x <carat> 2)
              • 4. Re: math quiz
                Level 7
                You can always go with multiple choice.
                • 5. Re: math quiz
                  Lukewig Level 1
                  Hi,
                  Th easiest way is to provide an onscreen 'calculator' so the user clicks buttons (like a real world calculator) to enter their equations. You could use a custom font to display the formula - though with some equations you are going to have to do some gymnastics to do the layout (might be easier to create bitmaps of each character and symbol and use imaging lingo to do the layout - see http://www.lingoworkshop.com/Codelib/pixelfonts.php for an idea how this might work for normal characters).

                  For simple superscript and subscript, you can also set the HTML or RTF of text members.