378 Commits

Author SHA1 Message Date
Marina Glancy
41b93bd7e5 MDL-73424 general: Internal methods must have same type as parent
Otherwise the error is thrown in PHP8.1
2022-10-10 16:46:13 +02:00
Andrew Nicols
f54d6b0144 Merge branch 'MDL-74883' of https://github.com/timhunt/moodle 2022-09-29 11:58:10 +08:00
Jun Pataleta
50fe735e5a Merge branch 'MDL-75777' of https://github.com/stronk7/moodle 2022-09-20 15:12:34 +08:00
Eloy Lafuente (stronk7)
839c2e5c18 MDL-75777 phpunit: Move tests to use correct names and ns (take#6)
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.
2022-09-19 11:01:21 +02:00
Eloy Lafuente (stronk7)
6be384ee8f MDL-75757 phpunit: Add some tolerance to a few failing assertions
Recently, PHPUnit (all versions) did some changes about how the
comparators worked and this has caused some float comparisons
to stop working.

We need to move them to assertEqualsWithDelta(), allowing a small
tolerance to workaround the floats comparison problem.

0.00001 has been decided. And applied to all the similar assertions
within the unittest function, so if more cases are added to them
better be copied with the agreed tolerance.
2022-09-18 15:55:36 +02:00
Safat Shahin
497a644b48 MDL-73376 qbank_comment: Version selection in modal
This commit implements version selection in the comment
modal to allow users to change the version of question
using that dropdown.
2022-09-01 11:43:55 +10:00
Tim Hunt
39abc01197 MDL-74752 question regrading: implement the required hooks
This commit implements the necessary core hooks to ensure we only
allow a regrade of a quetion attempt to take place if the new and old
versions of the question are sufficiently similar.

It will be followed by commits to each question type where the
new method needs to be implemented.

Automated tests will be included in the first of those (mulitple choice)
becuse we need a question type that implements the hooks to test
the core changes.
2022-05-31 09:22:22 +01:00
Tim Hunt
2069c8d480 MDL-74883 question: fix question_attempt_step_subquestion_adapter typos
During the late stages of developing MDL-20636, some key concepts
in the code got renamed. However, at the time, this class was not
updated properly so updating it now.
2022-05-30 16:10:03 +01:00
Jun Pataleta
def7df4825 Merge branch 'master_MDL-72890_quiz-regrade' of https://github.com/catalyst/moodle-MDL-70329 2022-03-14 14:19:56 +08:00
Jun Pataleta
2431f7bff8 Merge branch 'MDL-71305-master' of git://github.com/rezaies/moodle 2022-03-11 11:51:00 +08:00
Víctor Déniz
9a0a05ef39 Merge branch 'MDL-54724-master' of https://github.com/cameron1729/moodle 2022-03-10 23:21:24 +00:00
Shamim Rezaie
bc8bf406c8 MDL-71305 core_question: Use toggle button for flag question element 2022-03-08 13:45:18 +11:00
Marc-Alexandre Ghaly
3e09319e7a MDL-72890 core_question : Question regrade for question versions
This commit implements a question regrade for the selected
version in the quiz for a slot.

Co-Authored-By: Safat Shahin <safatshahin@catalyst-au.net>
Co-Authored-By: Tim Hunt <tim.hunt@open.ac.uk>
2022-03-04 23:06:50 +11:00
Eloy Lafuente (stronk7)
68b4a13cec MDL-73799 phpunit: various question & quiz testcase names
To all the walkthrough, questiontype, question, upgradelibnewqe,
behaviourtype_test and edit_form testcase classes::

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:
- When belonging to other component and being valid api:
  - form related tests have been moved to tests/form subdir.
2022-03-03 12:22:36 +01:00
Cameron Ball
53d3843955 MDL-54724 qtype_multianswer: Better handle corrupted questions
When questions are deleted, we now check if the parent is in use before deletion.

Prior to this, it would be possible for multianswer questions to reference
questions that have been deleted. This results in fatal errors when the quiz
is viewed.

This patch uses a dummy 'subquestion_replacement' to handle this case and
display some information to the end user about what has happened so that
they may take action to repair the corrupted question.

As a result of the bug described above, the sequence column of
mdl_question_multianswer can contiain references to questions that no
longer exist, and these IDs can make their way in to backups.

When this happens, the backups cannot be restored. To avoid this,
this patch skips trying to restore those questions that reference
question IDs that no longer exist (as there is no way to recover them).
2022-03-02 17:12:19 +08:00
Safat Shahin
83e6b3d8d8 MDL-73778 mod_quiz: Oracle Manual grading scenario
This change will resolve Manual grading settings are
remembered as user preferences - failed behat test in
oracle.
2022-02-22 11:34:37 +11:00
Safat Shahin
bf55e5a481 MDL-71696 core_question: class autoload changes
This commit implements some class autoloading
fixes to align with core question structure.
2022-02-03 22:22:50 +11:00
Safat Shahin
3008edd366 MDL-71696 core_question: Implement question status change
This commit implements the status change pop up for a question
in the base view. This feature update will allow the change of
status of a question without creating a new version.
This commit also implements the status as a char rather than
an int value.
2022-02-03 22:22:50 +11:00
Safat Shahin
111951d861 MDL-71696 mod_quiz: quiz updates and behat coverage
The versioning changes will require some major changes
in the backup and restore of question bank and its
elements. This change introduces those changes to make
it compatible with the new world of versioning in question
bank. This commit also removes quiz_slots fields and
quiz_slot_tags table.
This commit will also introduce the versioning db
structure and some major changes to the quiz
and quiz attempts for the question, random
question and the view.
This commit implements the behat changes for versioning
in core question and associated locations.
2022-02-03 22:22:44 +11:00
Guillermo Gomez
c6cfca2a08 MDL-71696 core_question: Changes for versioning
This commit adds the changes in questiontype base
to work with new question tables and the new structure in the
databse. Also needed for versioning.
This implementation will also introduct the question status
which allows a question to be in draft and ready status.
I also introduces changes to the base view where it shows
the latest version of the questions. The view of versions
for a question is not implemented in this commit.
This implementation will also introduce changes in the core
qtype plugins to support versioning and the changed
db schema.
2022-02-03 22:22:44 +11:00
Paul Holden
3c90926f05 MDL-69624 question: add missing test required library. 2022-01-13 15:08:02 +00:00
Tim Hunt
8950a974dd MDL-72912 questions: fix type of question_display_options::$context 2021-10-26 07:52:22 +01:00
Safat Shahin
f9fc355ec7 MDL-71679 mod_quiz: Updates for new qbank api
This implementation will introduct changes to
the mod_quiz to implement the new qbank api
for view. Major changes are introduced in
the custom view and also all the legacy points
to the old qbank are changed to qbank plugins
where needed. It also deprecated and deletes
classes and scripts which were kept not to
break mod_quiz for the new api implementation.
2021-10-04 15:44:25 +11:00
Safat Shahin
0d55b26da8 MDL-71614 qbank_previewquestion: Add Preview question plugin to core
This implementation will introduce a qbank plugin "previewquestion"
which will view the preview question action in the question bank
actions by replacing the core classes, scripts and yui modules.
This plugin will also replace the preview option in the edit
question form. Having this plugin will give users the
flexibility of enabling or disabling this feature from
the question bank view.
This change will also allow other qbank plugins to add
elements or information in the preview question page
by implementing a callback. It also changes the pop
up to page redirect from base view page to make sure
any changes in preview reflects in the base view, for
example, comments added and the number of comments in
the comments colum changes while back from the preview
page. Other locations like edit and qtype plugins where
the preview is implemented, stays the same.

Co-Authored-By: Guillermo Gomez Arias <guillermogomez@catalyst-au.net>
Co-Authored-By: Safat Shahin <safatshahin@catalyst-au.net>
2021-09-08 16:21:06 +10:00
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