354 Commits

Author SHA1 Message Date
Tim Hunt
b4bbbf15a3 MDL-71927 reports: show time to the second in logs report
And in the question history in quiz reviews.

Without this, it can be difficult to investigate some problems.
2021-06-14 21:41:16 +01:00
Thong Bui
a8c868822f MDL-71030 Quiz: Add 'who' made changes in question response history 2021-04-20 09:06:15 +07:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Thong Bui
017b1252ed MDL-70324 Question: get_all_response_file_areas() not work correctly 2020-12-01 16:03:44 +07:00
Eloy Lafuente (stronk7)
3a5641cb74 MDL-67673 phpunit: Remove deprecated assertEquals() params
The optional parameters of assertEquals() and assertNotEquals()
are deprecated in PHPUnit 8 (to be removed in PHPUnit 9):

- delta => use assertEqualsWithDelta()
- canonicalize => use assertEqualsCanonicalizing()
- ignoreCase => use assertEqualsIgnoringCase
- maxDepth => removed without replacement.

More info @ https://github.com/sebastianbergmann/phpunit/issues/3341

Initial search done with:

ag 'assert(Not)?Equals\(.*,.*,' --php

Then, running tests and fixing remaining cases.
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
40de097e65 MDL-67673 phpunit: Remove deprecated assertContains() uses on strings
Both assertContains() and assertNotContains() are deprecated in PHPUnit 8
for operations on strings. Also the optional case parameter is. All uses
must be changed to one of:

- assertStringContainsString()
- assertStringContainsStringIgnoringCase()
- assertStringNotContainsString()
- assertStringNotContainsStringIgnoringCase()

More info: https://github.com/sebastianbergmann/phpunit/issues/3422

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
d95c378771 MDL-67673 phpunit: Remove expectedException annotations
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

The annotations `@expectedException`, `@expectedExceptionCode`,
`@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp`
are now deprecated.
Using these annotations will trigger a deprecation warning
in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.

Also, all uses of expectExceptionMessageRegExp() has been moved
to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957

TODO: Various weirdness found while doing the changes with these tests:
- vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700)
- vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one)
- vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624)
- vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688)
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Tim Hunt
de3d216c5a MDL-69246 questions: allow for float issues when validating manual marks
As well as fixing the bug, I also rewrote the test to use
data providers, which should lead to more useful failure messages.

And, I moved the magic number we used as the float tolerence to
be a named constant.
2020-08-27 17:37:31 +01:00
Adrian Greeve
d602189874 Merge branch 'MDL-63812' of https://github.com/timhunt/moodle 2020-05-25 14:40:14 +08:00
Jun Pataleta
7750dd55e8 Merge branch 'MDL-68367' of https://github.com/mkassaei/moodle 2020-05-21 17:10:16 +08:00
Mahmoud Kassaei
00055ef6ab MDL-68367 Question: Multi-choice Option to hide systemtext 2020-05-21 09:47:15 +01:00
Tim Hunt
64207dab65 MDL-67183 questions: get_question & get_behaviour only init if required
This reviews all the code code, and sets $requirequestioninitialised
whenever possible in these calls, which should improve performance.
2020-05-19 20:52:07 +01:00
Tim Hunt
9cbbb779eb MDL-67183 question engine: allow lazy-init of question_attempts
That is, we don't call apply_attempt_state as soon as a
the data is loaded from the database. Instead, we wait
and only call it if really needed.

This should (especially after the next commit) be a performance win
during quizzes, particularly for people using advanced question
types liks STACK, or people making extensive use of the
'Try another question like this one' feature.
2020-05-19 20:49:33 +01:00
Tim Hunt
2bfb8d4a3d MDL-63812 qtype_gapselect: fix questions with non-consecutive gap nos 2020-04-23 14:39:52 +01:00
Tim Hunt
9440b54f8a MDL-68149 qtype_match: correctly distinguish 0 and 0.0 answers
Also added a test for backup & restore (which was working).
2020-03-11 13:43:21 +00:00
Tim Hunt
b060e7495c MDL-68149 qtype_match: Updatey tests to follow make_question() pattern 2020-03-11 13:41:13 +00:00
Tim Hunt
1aacbb72d3 MDL-67832 quiz: fix lots of PHPdoc in attemptlib.php 2020-01-31 19:09:03 +00:00
Tim Hunt
76a49e4a1e MDL-67653 questions: prevent the flag flickering as the page loads 2020-01-10 14:27:42 +00:00
Eloy Lafuente (stronk7)
4621917c62 MDL-67114 core: php74 fix. Fix use of scalar as array in core
There are various places where it's not guaranteed that the
variable being used is array, and instead, can be null, bool, int...

We need to check that because php74 warns about it.

Where possible we have used the coalesce operator as
replacement for isset() ternary operations.
2020-01-03 11:33:15 +01:00
Bas Brands
aa100b767f MDL-66999 theme_boost: @extend remove extends for questions 2019-12-12 11:27:58 +01:00
Eloy Lafuente (stronk7)
88d29a1bb8 MDL-66965 core: php74 curly 2 square braces changes
Note this only modified core files, still there are a lot
of curly brace uses but all them are within 3rd part
libraries and will be handled apart.
2019-10-25 17:41:10 +02:00
Tim Hunt
471c39b361 MDL-66980 question bank: fix load_many_for_cache missing record check 2019-10-21 11:18:12 +01:00
Eloy Lafuente (stronk7)
9c5796a3f0 Merge branch 'MDL-66754' of https://github.com/timhunt/moodle 2019-10-07 22:33:02 +02:00
Tim Hunt
824d1f8f52 MDL-66754 question engine: fix lots of PHPdoc errors
This fixes essentially all the things PHPstorm was warning about in
question/engine/datalib.php and question/engine/questionusage.php.
2019-09-24 10:25:29 +01:00
Tim Hunt
7b1b478761 MDL-66754 question engine: make $slots argument optional
Sometimes there is not a fixed list of slots, and you just want all data.
2019-09-23 18:03:23 +01:00
Tim Hunt
a3624fdf0f MDL-66685 questions: should able to save an empty question usage 2019-09-16 14:35:18 +01:00
Martin Gauk
09fd8aec27 MDL-58026 question: fix regrading in progress attempt
Do not convert autosave steps to true steps when regrading.

Thanks Eric Merrill for providing the unit test code.
2019-07-08 09:35:34 +00:00
Tim Hunt
e900b2f34f MDL-65864 question engine: fix re-saving a new usage
Before this fix, test_repeated_usage_saving_new_usage was failing but
test_repeated_usage_saving_existing_usage was passing. Now the
behaviour is consistent and they both pass.
2019-06-13 18:04:02 +01:00
Andrew Nicols
dd457c4fa6 Merge branch 'MDL-65245' of https://github.com/timhunt/moodle 2019-05-03 10:50:32 +08:00
David Monllaó
03876f0b89 Merge branch 'MDL-65207-master' of git://github.com/lameze/moodle 2019-04-24 17:52:10 +02:00
David Monllaó
3d15deff15 Merge branch 'MDL-65222' of git://github.com/timhunt/moodle 2019-04-22 09:08:37 +02:00
Tim Hunt
be492e2a8f MDL-65245 question engine: response vars should always be PHP strings 2019-04-02 16:32:40 +01:00
Tim Hunt
6c91e515b0 MDL-65245 question_attempt: fix PHPdoc and other PHPstorm warnings 2019-04-02 16:32:36 +01:00
Simey Lameze
9bec0e7e74 MDL-65207 core: replace typos by actually 2019-04-01 08:49:18 +08:00
Tim Hunt
05ea7ab19e MDL-65222 questions: explain question walkthrough tests 2019-03-29 14:49:39 +00:00
Eloy Lafuente (stronk7)
01cdf16c0e Merge branch 'MDL-65029-master' of git://github.com/timhunt/moodle 2019-04-05 00:39:10 +02:00
Eloy Lafuente (stronk7)
87f196af93 MDL-65204 phpunit: more isEqual() strict string fixes
This is a followup of 85f47ba, where we were relaxing
the (new since phpunit 7.x) strict (===) isEqual()
comparison for strings. Copying the explanations for
easier understanding.

Link: https://github.com/sebastianbergmann/phpunit/issues/3185
Solution here is one of:
  a) Return to the previous situation, making the comparison
     softer. That can achieved by forcing different types, so
     float == string works.
  b) Changing APIs (both forms and database return strings) to
     perform some conversion to floats. That would make float
     comparison (with floats or strings) to work too.
The patch here follows the a) approach. Changing all the internals
for proper float handling sounds excesive when it has been working
perfectly since ever. So we went the easier route, just getting
rid of the new === comparisons when needed by changing expectation
types to float.
2019-04-03 22:08:16 +02:00
Simey Lameze
d499cb3593 MDL-65050 core: delete orphaned files and functions 2019-04-01 12:57:05 +08:00
Simey Lameze
9c164d26fc MDL-65050 core: add question_stats_cleanup_task scheduled task
This commit also removes orphaned question/engine/statisticslib.php
2019-04-01 12:57:05 +08:00
Tim Hunt
f1ffd134d3 MDL-65029 questions: change question div id to acutally be unique
This is largely based on Simey Lameze's work.
2019-03-29 13:37:44 +00:00
Eloy Lafuente (stronk7)
752e2f85e7 Merge branch 'MDL-64420-2' of https://github.com/timhunt/moodle 2019-02-12 12:56:18 +01:00
John Beedell
0d3be6d648 MDL-64420 qtype: gapselect unit tests unsafe 2019-02-11 13:53:24 +00:00
M Kassaei
5179a01ab6 MDL-64646 drag-drop questions: improve editing forms
Users were getting confused between choice numbers and
group numbers. So choice numbers now show as [[1]] to
match what appears in the question text. Groups are now
letters A, B, ...
2019-02-01 10:20:08 +00:00
Shamim Rezaie
305d2716f6 MDL-52132 qbehaviour_manualgraded: unit test for changing comment format 2019-01-15 18:56:03 +11:00
Shamim Rezaie
8e93e515ed MDL-63809 question: handling bad questions in question_has_capability_on 2018-12-18 15:05:37 +11:00
John Beedell
6189fda47f MDL-62708 question: Add idnumbers to question and question category 2018-09-21 12:26:24 +01:00
Tim Hunt
802ff4c933 MDL-63371 question: USE_RAW_DATA case in check_qt_var_name_restrictions 2018-09-14 16:43:41 +01:00
Huong Nguyen
628b4c86af MDL-62358 Question: Improve number function
Support all 'question numbers' that might be needed
2018-06-14 19:43:55 +07:00
Simey Lameze
2cf7bde8e9 MDL-61364 question: adjust code and fix phpunit errors 2018-03-27 16:14:46 +08:00