minimum score error
-
Scale value 8 must be within range from -8 to 8
Scale value 8 must be within range from -2 to 8
Scale value -9 must be within range from -4 to 8The minimum scores should be -8,-8,-9. I have several scores below 0.
BTW, how to get the InvalidArgumentException error message?
I get the error message by “echo”.
-
1. Pls provide your concrete values how to repeat it.
2.
how to get the InvalidArgumentException
Only from bad code. Not from UI I think.
3.
I get the error message by “echo”.
Where and how? Pls describe more details.
It seems to be caused by SQL in buildScalesWithRange()
1. There are 8 questions, 4 answers(ABCD) and 3 scales(XYZ).
- X: 2 1 -1 -2
- X: 2 1 -1 -2
- X: 2 1 -1 -2
- X: 2 1 -1 -2
- Y: -4 -2 0 2
- Y: -1 0 1 2
- Y: -4 -2 2 4
- Z: -8 -4 4 8
So,
sum(min(X))=-8
sum(min(Y))=-9
sum(min(Z))=-83. My debug code:
public function setValue($value) { $value = $this->filterValue($value, 'value'); echo('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum."\n"); if (!($this->minimum <= $value) || !($value <= $this->maximum)) { throw new InvalidArgumentException('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum); } $this->value = $value; return $this; }I think the minimum should be the sum of every min score, not the min of all scores, since the value here is the sum score of a scale.
I comment out these lines and the result page appears.
if (!($this->minimum <= $value) || !($value <= $this->maximum)) { throw new InvalidArgumentException('Scale value ' . $value . ' must be within range from ' . $this->minimum . ' to ' . $this->maximum); }Yes, I think it’s a bug here with negative scores.
Can you provide example for test with 1 scale 2 questions and 1 answer in each?
Also you can try to fix it in PR. Main here will be not just fix, but also provide a new test case.
Here’s a simple test case (1 scale(X), 2 questions(Q1 Q2) and 2 answers(Y N))
Q1:1 -1
Q2:1 -1When I choose N for Q1 and Q2, exception happens in setValue and no result shows.
Scale value -2 must be within range from -1 to 2
I’m not sure of the meaning of PR. So what does PR mean?
It’s a pull-request at github.
Do you know any programming language? python/ruby? If yes, then you should know PHP — it’s no so complex.
You can try to fix it and send pull request through github.
But by fix I understand not just fix in code but also adding test (in phpunit) to prove that fix working.
You can browse commits to see how it done usually.
But I don’t know how to run phpunit. Error happens:
PHP Warning: require_once(/home/osfans/prj/wp-testing/tests/phpunit/../../vendor/autoload_52.php): failed to open stream: No such file or directory in /home/osfans/prj/wp-testing/tests/phpunit/bootstrap.php on line 2
I fix the bug as follows.
diff --git a/db/sql/scale-max-right.sql b/db/sql/scale-max-right.sql index 451aba0..6a9e197 100644 --- a/db/sql/scale-max-right.sql +++ b/db/sql/scale-max-right.sql @@ -1,6 +1,6 @@ SELECT scale_id, - MIN(minimum_in_row) AS minimum_in_column, + SUM(minimum_in_row) AS minimum_in_column, SUM(maximum_in_row) AS maximum_in_column, SUM(sum_in_row) AS sum_in_column FROM ( diff --git a/src/Model/Test.php b/src/Model/Test.php index 7777fa4..943aa95 100644 --- a/src/Model/Test.php +++ b/src/Model/Test.php @@ -93,7 +93,7 @@ class WpTesting_Model_Test extends WpTesting_Model_AbstractModel $result = $db->translatedQuery(' SELECT scale_id, - MIN(minimum_in_row) AS minimum_in_column, + SUM(minimum_in_row) AS minimum_in_column, SUM(maximum_in_row) AS maximum_in_column, SUM(sum_in_row) AS sum_in_column FROM (Locally run
composer update— it will install all that needs. Then also look at some config to have locally DB available.Yes, I think it’s correct to use SUM there https://github.com/garex/wp-testing/blob/develop/src/Model/Test.php#L96
Try to run after composer just
vendor/bin/phpunit52Btw, on which OS do you working now? It’s all tools currently for linux.
OK, I’ll have a try.
I use arch linux.Good. You can see https://github.com/garex/wp-testing/blob/develop/tests/integration-environment/create.sh as an example of environment creation.
Sorry, I have to give up phpunit because of my network.
Failed: [Symfony\Component\Process\Exception\ProcessTimedOutException] The process “git clone –no-checkout ‘git://github.com/garex/phpunit’ ‘/home/kyle/prj/wp-testing/vendor/phpunit/phpunit-php52’ && cd ‘/home/kyle/prj/wp-testing/vendor/phpunit/phpunit-php52’ && git remote add composer ‘git://github.com/garex/phpunit’ && git fetch composer” exceeded the timeout of 300 seconds.
osfans, it’s sad (( May be it’s a problems on github’s side?
I’ve downloaded the repo with proxy.
But there’s an error and I can find the function in vendor/phpunit/phpunit-php52/PHPUnit/Util/Filesystem.php
kyle@~/prj/wp/wp-testing % phpunit
PHP Fatal error: Call to undefined method PHPUnit_Util_Filesystem::fileExistsInIncludePath() in /home/kyle/prj/wp/wp-testing/vendor/phpunit/phpunit-php52/PHPUnit/Autoload.php on line 209Yes, because it should be run with php5.2 compatible phpunit.
I’ve forked it and fixed for php 5.2.
See
vendor/bin/phpunit52
The topic ‘minimum score error’ is closed to new replies.