Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-7198

New grammar analyzer for Calculated question with pluginable packages of functions.

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Won't Fix
    • 1.9.4
    • None
    • Questions
    • None
    • MOODLE_19_STABLE

    Description

      New exptession's grammar analyzer let you use any your private functions. You can put theirs in package and attach to calculated question type. Also you can create wrappers for standard PHP functions.
      Features:
      1. Real grammar analyzer.
      2. Checking accuracy of expression without reloading question's editing page.
      3. Pluginable packages of functions (you can use any private functions).
      4. Using arrays as parameters of functions.

      Also included package of EGM Mathematical Finance class created by Enrique Garc?a M. (2003-2004) and distributed under GNU GPL.

      Note: Package should named as 'package.php' and puted in individual folder. Names of functions should start from folder name.
      For example:
      All standard functions were moved in package 'math', so now their names have prefix 'math_' (math_sin, math_abs etc.)

      Grammar of expressions:
      <Expr>::=<Term>

      {<OperationLP><Term>}

      <OperationLP>::='+'|'-'
      <Term>::=<Factor>

      {<OperationHP><Factor>}

      <OperationHP>::='*'|'/'
      <Factor>::=<UnaryOp><Factor>|<Base>
      <UnaryOp>::='+'|'-'
      <Base>::=<Variable>|<Function>|<Number>|'('<Expr>')'
      <Function>::=<Letter>

      {<Letter>|<Digit>|'_'}'('<Parameter>{','<Parameter>}')'
      <Parameter>::=<Boolean>|<Expr>
      <Boolean>::='true'|'false'
      <Variable>::='{'<Letter>{<Letter>|<Digit>|'_'}

      '}'
      <Letter>::='A'|...|'Z'|'a'|...|'z'|'_'
      <Number>::=<Digit>

      {<Digit>}['.'<Digit>{<Digit>}

      ][('E'|'e')['+'|'-']<Digit>

      {<Digit>}

      ]
      <Digit>::='0'|...|'9'

      Attachments

        1. calculated_extended_for_v19.zip
          41 kB
        2. calculated_for_v18.zip
          59 kB
        3. calculated_with_grammar.zip
          31 kB
        4. folder.PNG
          folder.PNG
          8 kB
        5. grammar.PNG
          grammar.PNG
          18 kB

        Issue Links

          Activity

            People

              ppichet Pierre Pichet
              dlnsk Dmitry Pupinin
              Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: