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

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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Won't Fix
    • Affects Version/s: 1.9.4
    • Fix Version/s: None
    • Component/s: Questions
    • Labels:
      None
    • Affected Branches:
      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'

        Gliffy Diagrams

          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

                • Votes:
                  1 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: