• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FormulasQuestion / moodle-qtype_formulas / 13217446514

08 Feb 2025 04:37PM UTC coverage: 76.899% (+1.9%) from 75.045%
13217446514

Pull #62

github

web-flow
Merge b36f9931f into acd272945
Pull Request #62: Rewrite the parser

2547 of 3139 new or added lines in 22 files covered. (81.14%)

146 existing lines in 6 files now uncovered.

3006 of 3909 relevant lines covered (76.9%)

438.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/conversion_rules.php
1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16

17
namespace qtype_formulas;
18

19
/* Each entry of $basicunitconversionrule is a pair:
20
 *  - The first string is the name of the rule, which is used when editing the form
21
 *  - The second string is the actual rule that will be parsed and used as unit conversion
22
 *  - The array index is the unique id for the rule, which will be stored in the database
23
 * Note: the id from 0 to 99 are reserved, please do not use to create you own rules
24
 */
25
class unit_conversion_rules {
26
    private $basicunitconversionrule = [];
27

28
    // Initialize the internal conversion rule.
29
    public function __construct() {
NEW
30
        $this->basicunitconversionrule[0] = [get_string('none', 'qtype_formulas'), ''];
×
NEW
31
        $this->basicunitconversionrule[1] = [get_string('commonsiunit', 'qtype_formulas'), '
×
32
m: k c d m u n p f;
33
s: m u n p f;
34
g: k m u n p f;
35
mol: m u n p;
36
N: M k m u n p f;
37
A: m u n p f;
38
J: k M G T P m u n p f;
39
J = 6.24150947e+18 eV;
40
eV: k M G T P m u;
41
W: k M G T P m u n p f;
42
Pa: k M G T P;
43
Hz: k M G T P E;
44
C: k m u n p f;
45
V: k M G m u n p f;
46
ohm: m k M G T P;
47
F: m u n p f;
48
T: k m u n p;
49
H: k m u n p;
NEW
50
'];
×
51

52
        /* You can define your own rules here, for instance:
53
         * $this->basicunitconversionrule[100] = array(
54
         * $this->basicunitconversionrule[1][0] + ' and your own conversion rules',
55
         * $this->basicunitconversionrule[1][1] + '');
56
         */
57

58
    }
59

60
    public function entry($n) {
NEW
61
        if (!isset($this->basicunitconversionrule[$n])) {
×
NEW
62
            return null;
×
63
        }
UNCOV
64
        return $this->basicunitconversionrule[$n];
×
65
    }
66

67
    public function allrules() {
UNCOV
68
        return $this->basicunitconversionrule;
×
69
    }
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc