Compare commits

...

224 Commits

Author SHA1 Message Date
Jun Pataleta 4d48741ed7 Moodle release 3.11.7 2022-05-07 19:34:59 +08:00
Eloy Lafuente (stronk7) 199974b45d weekly release 3.11.6+ 2022-05-06 15:58:35 +02:00
Jun Pataleta 637c6fbbca Merge branch 'MDL-74511-311' of https://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2022-05-06 11:57:59 +08:00
Andrew Nicols e2d9a7fcee MDL-74511 core: Add phpcs default config 2022-05-06 11:39:20 +08:00
Víctor Déniz b115058dc5 Merge branch 'MDL-74612-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-05-05 13:25:53 +01:00
Víctor Déniz fd5832fde9 Merge branch 'MDL-74567-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-05-05 09:40:06 +01:00
Paul Holden 8f375b3923 MDL-74567 core: re-factor flickr libraries to use shared user-agent. 2022-05-05 09:21:28 +01:00
Jun Pataleta 2970dfb52d Merge branch 'MDL-73981-311' of https://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2022-05-05 09:49:14 +08:00
Ilya Tregubov a174a570a6 MDL-73981 tool_uploadcourse: Validate enrolment role from csv. 2022-05-05 07:40:49 +06:00
Jun Pataleta 917d7e1003 Merge branch 'MDL-74511-311' of https://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2022-05-05 09:37:39 +08:00
Jake Dallimore 83a8cfb9e4 MDL-73736 core_auth: Fix concurrency issue in login_attempt_failed()
This patch wraps the login_failed_count logic in a resource lock and
forces a user preferences cache reload. Each thread must wait for the
lock and must fetch the current count before incrementing it. This
ensures that login_failed_count is correct across threads and that the
lockout threshold is correctly honoured.

Co-Authored-By: Sujith Haridasan <sujith@moodle.com>
2022-05-04 14:45:15 +06:00
Michael Hawkins 947b6f202c MDL-74333 badges: Check profile criteria valid when reviewing 2022-05-04 12:58:14 +08:00
Ferran Recio 5ab6d18354 MDL-71623 core_search: fix user document visibility 2022-05-04 04:04:14 +02:00
Amaia Anabitarte e36332c01a MDL-74318 core_user: Description field as hidden on profile 2022-05-04 04:04:14 +02:00
Paul Holden 5f399aa81a MDL-74204 mod_assign: escape identity fields in allocate marker form. 2022-05-04 04:04:14 +02:00
Jun Pataleta 5b02f3bcf7 Merge branch 'MDL-73878-311' of https://github.com/aanabit/moodle into MOODLE_311_STABLE 2022-05-04 09:44:38 +08:00
Amaia Anabitarte 692657ffc4 MDL-73878 core_user: Creating a new category for social fields 2022-05-03 17:48:05 +02:00
Amaia Anabitarte 753373d6e6 MDL-73878 core_user: Fixing social fields upgrading issue 2022-05-03 17:39:23 +02:00
Jun Pataleta 43e181f391 Merge branch 'MDL-74543_311' of https://github.com/timhunt/moodle into MOODLE_311_STABLE 2022-05-03 22:21:17 +08:00
Ilya Tregubov 0cdb291d9e Merge branch 'mdl65478-fix-311' of https://github.com/matthewhilton/moodle into MOODLE_311_STABLE 2022-05-03 15:44:05 +06:00
Jake Dallimore 031004097b Merge branch 'MDL-74441-311' of https://github.com/cameron1729/moodle into MOODLE_311_STABLE 2022-05-03 16:55:14 +08:00
Cameron Ball 869c717e72 MDL-74441 mod_forum: Fix overflow in unified grader 2022-05-03 15:52:39 +08:00
Jason den Dulk 0536942919 MDL-65478 backup, course format: Handle editor elements in course format
Modified course format options reading and writing to be able to handle Editor elements by enabling them to split array values into
multiple values before inserting into database, and combining multiple values into an array when reading from the database.
Modified backup and restore code to use backup_nested_elements, and to interact directly with the database.

Co-authored-by: Jason den Dulk <jasondendulk@catalyst-au.net>
Co-authored-by: Matthew Hilton <matthewhilton@catalyst-au.net>
2022-05-03 14:18:53 +10:00
Víctor Déniz 5e5b39ee2c Merge branch 'MDL-73951-311' of https://github.com/mickhawkins/moodle into MOODLE_311_STABLE 2022-05-02 11:13:19 +01:00
Jun Pataleta 055fff8005 Merge branch 'MDL-74436-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-05-02 16:30:19 +08:00
Paul Holden e7094cdb75 MDL-74612 cohort: use data generator for populating cohort members. 2022-04-29 16:23:38 +01:00
Michael Hawkins 3a5f610034 MDL-73951 core: Updated security.txt expiry date
Also updated expiry date format to meet latest standard.
2022-04-29 18:55:40 +08:00
Ilya Tregubov 44e3680153 weekly release 3.11.6+ 2022-04-29 07:55:36 +06:00
Ilya Tregubov 11db1b0193 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-04-29 07:55:33 +06:00
Paul Holden c4f95593a9 MDL-74567 repository_flickr: replace user-agent value for API calls.
Flickr doesn't like user agent that looks like a bot. Effectively the
same reasoning/fix as b8ee31a0.
2022-04-28 14:45:45 +01:00
Jun Pataleta 5957b238ef Merge branch 'MDL-74478-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-04-28 12:54:17 +08:00
Peter Dias 51a7a0aa3e MDL-74478 badges: Check completion_fail when awarding badge
Bring the award_criteria_activity checks in line with the observer checks
2022-04-28 12:25:54 +08:00
Ilya Tregubov 9bb6ed7c1c Merge branch 'MOODLE_311-MDL-74427-v4' of https://github.com/golenkovm/moodle into MOODLE_311_STABLE 2022-04-28 08:11:07 +06:00
Jun Pataleta 1a01e66976 Merge branch 'MDL-74537-311-enfix' of https://github.com/vmdef/moodle into MOODLE_311_STABLE 2022-04-27 15:49:00 +06:00
Jake Dallimore 899e7e2103 Merge branch 'MDL-73672-311-patch' of https://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2022-04-27 15:49:00 +06:00
Ilya Tregubov 92509cdeae Merge branch 'MDL-74481-311-LTI13-InstructorRole' of https://github.com/cengage/moodle into MOODLE_311_STABLE 2022-04-27 15:49:00 +06:00
Ilya Tregubov af84b0ea22 MDL-73672 reports: Fix Behat step for classic theme. 2022-04-27 15:49:00 +06:00
Mikhail Golenkov 10ad537723 MDL-74427 question: Implement get_real_question_ids_in_category() 2022-04-27 13:42:23 +10:00
Helen Foster a576209dd1 MDL-74537 lang: Import fixed English strings (en_fix) 2022-04-26 11:28:57 +01:00
Paul Holden 1a76f2752a MDL-74436 calendar: validate course/category field during import. 2022-04-25 18:01:23 +01:00
Ilya Tregubov 8e0da918ab Merge branch 'MDL-73672-311' of https://github.com/BruceGoodGuy/moodle into MOODLE_311_STABLE 2022-04-25 10:03:11 +06:00
AMOS bot ff3fd8a222 Automatically generated installer lang files 2022-04-23 00:07:34 +00:00
Eloy Lafuente (stronk7) 0127abe30e weekly release 3.11.6+ 2022-04-22 18:03:54 +02:00
Ilya Tregubov a0aaa3cacf Merge branch 'MDL-74394_311' of https://github.com/aolley/moodle into MOODLE_311_STABLE 2022-04-22 08:00:52 +06:00
Tim Hunt d02d01aa71 MDL-74543 quiz: correctly record time when overdue attempt submitted 2022-04-21 22:25:28 +01:00
Andrew Nicols b9e3bcb748 MDL-74511 core: Add phpcs config generator 2022-04-19 11:16:46 +08:00
Ilya Tregubov 447067d874 weekly release 3.11.6+ 2022-04-15 16:03:07 +06:00
Ilya Tregubov 282e60115d Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-04-15 16:03:05 +06:00
Claude Vervoort d3f3da7277 MDL-74481 mod_lti: fix role lookup for LTI 1.3 2022-04-13 13:03:28 -04:00
Sara Arjona 7228428479 Merge branch 'MDL-74486-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-04-13 16:59:01 +02:00
Mihail Geshoski 53a493030c MDL-73672 reports: fix navigation when clicking on parent Reports link 2022-04-13 17:08:14 +07:00
Huong Nguyen 3fc5d0dec3 MDL-74486 tool_usertours: Prevent step to inherit theme background image 2022-04-13 09:49:42 +07:00
AMOS bot b6ccf35285 Automatically generated installer lang files 2022-04-12 00:07:35 +00:00
Ilya Tregubov 4af82f5154 weekly release 3.11.6+ 2022-04-08 16:39:53 +06:00
Ilya Tregubov 5855059608 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-04-08 16:39:51 +06:00
Ilya Tregubov 9a7bdedc5a Merge branch 'MDL-73555_311_toolbrickfieldsummaryprocessing' of https://github.com/brickfield/moodle into MOODLE_311_STABLE 2022-04-08 09:24:38 +06:00
Andrew Nicols b276bfce77 Merge branch 'MDL-74438-311' of https://github.com/cameron1729/moodle into MOODLE_311_STABLE 2022-04-08 11:04:02 +08:00
Shamim Rezaie 8d2f2e7d37 Merge branch 'MDL-73874-311' of https://github.com/BruceGoodGuy/moodle into MOODLE_311_STABLE 2022-04-08 12:39:13 +10:00
Cameron Ball 705e6c5614 MDL-74438 cache: Check if cached value is boolean false 2022-04-08 10:10:44 +08:00
Víctor Déniz 48f1e6165d Merge branch 'MDL-74419-311' of https://github.com/sarjona/moodle into MOODLE_311_STABLE 2022-04-07 20:25:13 +01:00
Eloy Lafuente (stronk7) 917369b8ef Merge branch 'MDL-74434-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-04-07 17:11:58 +02:00
Khoa Nguyen Dang 81e7828600 MDL-73874 Questions: Add new validation for Drag and drop into text 2022-04-07 17:21:36 +07:00
Andrew Nicols a5776a4bbe Merge branch 'MDL-74202-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-04-07 15:29:14 +08:00
Sara Arjona 7917f9a509 Merge branch 'MDL-58044_311' of https://github.com/Chocolate-lightning/moodle into MOODLE_311_STABLE 2022-04-07 09:16:13 +02:00
Mihail Geshoski c15ffa0e88 MDL-74434 block_tag_youtube: Update instances only if category is set
Modifies the existing upgrade step to only take into consideration
block instances that have a specific category set prior to determening
if a legacy category is being used and updating them. Instances that do
not have any category set should be ignored.
2022-04-07 13:26:08 +08:00
Nadav Kavalerchik 36c1a657b4 MDL-58044 report/progress: Fix table headers labels display in RTL mode. 2022-04-07 14:15:30 +12:00
AMOS bot 9fc20a6fef Automatically generated installer lang files 2022-04-07 00:07:31 +00:00
Víctor Déniz c07e077f04 Merge branch 'MDL-74189-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-04-06 22:56:23 +01:00
Jun Pataleta 0e9eddf51e Merge branch 'MDL-74332-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-04-07 00:35:13 +08:00
Mihail Geshoski c0462feec8 MDL-74189 tool_moodlenet: Add upgrade step to remove irrelevant data
Upgrade step to identify all existing cases where users have linked
their MoodleNet profile on the site and remove the related data from
the database. Due to some recent changes on the MoodleNet platform,
this data is now irrelevant and can no longer be used to authenticate
on the MoodleNet platform.
2022-04-06 23:33:37 +08:00
Mihail Geshoski 711e2b006f MDL-74189 tool_moodlenet: Update language strings
Updates the existing language strings in order to provide more accurate
instructions on how users can link existing their MoodleNet profile on
the site.
2022-04-06 23:31:53 +08:00
Sara Arjona 45e81f4818 Merge branch 'wip_MDL-59545_m311' of https://github.com/gjb2048/moodle into MOODLE_311_STABLE 2022-04-06 12:42:14 +02:00
Sara Arjona ac822d9655 MDL-74419 search_simpledb: Search with quotes not working on Oracle
Global search with quotes is not working on DB engines without
full-text search support (i.e. Oracle).
2022-04-06 11:50:54 +02:00
Jake Dallimore 0907ff86f8 Merge branch 'MDL-74371-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-04-06 12:26:25 +08:00
Jake Dallimore a52378726e Merge branch 'MDL-74424-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-04-06 12:15:45 +08:00
Sujith Haridasan a2dd8127f0 MDL-74371 mod_survey: Wordrap long questions in response reports
Word wrap long questions in Response reports so that the users dont
see broken questions in the questions page.
2022-04-06 09:38:16 +05:30
AMOS bot e9cf945617 Automatically generated installer lang files 2022-04-06 00:07:31 +00:00
Mihail Geshoski 64bc864e2e MDL-74424 repository_googledocs: Update phpunit tests 2022-04-06 01:43:35 +08:00
Mihail Geshoski e34a301fd0 MDL-74424 repository_googledocs: Respect default import formats
Makes sure that the correct file extension is attributed when importing
a file using the Google Drive repository based on the set configuration
values for the default import format settings.
2022-04-06 01:43:34 +08:00
Eloy Lafuente (stronk7) 339c473b9c Merge branch 'MDL-74330-311-enfix' of https://github.com/vmdef/moodle into MOODLE_311_STABLE 2022-04-05 18:39:43 +02:00
Sara Arjona 62dec781bb weekly release 3.11.6+ 2022-04-05 13:24:48 +02:00
Sara Arjona a76e8e9fbe Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-04-05 13:24:46 +02:00
Víctor Déniz 1a9cb490ba Merge branch 'MDL-74113-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-04-04 20:06:25 +01:00
Sara Arjona ceef8c7e1b Merge branch 'MDL-74383-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-04-04 15:46:25 +02:00
Víctor Déniz f8a83d8a67 MDL-74330 lang: Replace modified strings in tests 2022-04-04 10:29:40 +01:00
Helen Foster a6773e6664 MDL-74330 lang: Import fixed English strings (en_fix) 2022-04-04 10:29:40 +01:00
Sujith Haridasan fb9fdc4754 MDL-74332 mod_survey: Indent the file properly
Correct the indentation of the file.
Replaced print_error with moodle_exception.
Updated the comments to start with capital and end with fullstop.
2022-04-04 11:45:40 +05:30
Jun Pataleta 4194bdf0fd Merge branch 'MDL-70014_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-04-04 13:56:23 +08:00
Jun Pataleta 710099242f Merge branch 'MDL-74096-311' of https://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2022-04-04 13:05:52 +08:00
Sujith Haridasan aee71c329d MDL-74332 mod_survey: Critical incidents dont require summary and scales
Do not show summary and scales for the survey with critical
incidents. So critical incidents survey would have questions
and participants only under response reports.
Also corrected the heading for the Questions page.
2022-04-04 09:59:03 +05:30
Mihail Geshoski b72e73d6de MDL-74383 assignfeedback_editpdf: Fix comment issues in the pdf editor 2022-04-04 10:56:32 +08:00
Mihail Geshoski 9a75af7805 MDL-74383 assignfeedback_editpdf: 'Annotated PDF' link style update 2022-04-04 10:56:31 +08:00
AMOS bot a0653230c5 Automatically generated installer lang files 2022-04-04 00:07:28 +00:00
Gareth Barnard 802f6b3fa1 MDL-59545 navigation: Missing editing icons on activity pages 2022-04-03 21:58:03 +01:00
Eloy Lafuente (stronk7) 55198f851c MDL-70014 tool_customlang: Workaround to make behat happier
This is a BEHAT_RUNNING only hack, so it doesn't affect normal
operations at all. What it achieves is to reduce the number of
strings loaded when customising a lang pack from current 31K ones
to the just needed ones for Behat testing purposes.

That way we avoid the random failures that are happening more and
more (while the "en" lang pack grows) and also save some precious
minutes in every behat run.

Also, unrelated, a couple of tiny changes:
- Modified constant (that was really outdated) to current number
  of lang strings (so the progress bar behaves better).
- Remove an elseif occurrence because it was hurting my eyes.
2022-04-01 23:57:09 +02:00
Sara Arjona a4c654d67c Merge branch 'MDL-74286-311' of https://github.com/ferranrecio/moodle into MOODLE_311_STABLE 2022-04-01 17:34:36 +02:00
Sara Arjona 6e7c7a7e2e weekly release 3.11.6+ 2022-04-01 16:40:47 +02:00
Sara Arjona eb3a220af8 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-04-01 16:40:45 +02:00
Ilya Tregubov d3b25ce4d9 MDL-74096 mlbackend_python: Update mlbackend version. 2022-04-01 16:30:15 +06:00
Adam Olley 7e29aee395 MDL-74394 mnet: Better check for openssl_get_publickey() failure
In PHP8, this func now returns an object of type OpenSSLAsymmetricKey, not a
resource.

Reference:
https://www.php.net/manual/en/function.openssl-pkey-get-public.php
2022-04-01 14:33:31 +10:30
Jun Pataleta 556236134a Merge branch 'MDL-74390_311' of https://github.com/timhunt/moodle into MOODLE_311_STABLE 2022-04-01 11:45:23 +08:00
Huong Nguyen b1bad66d46 MDL-74113 atto_media: Listen to play/pause events 2022-04-01 10:04:47 +07:00
Andrew Nicols 660b5b0045 Merge branch 'MDL-69552-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-04-01 10:57:46 +08:00
Andrew Nicols d28f836536 Merge branch 'MDL-70731-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-04-01 10:26:47 +08:00
Tim Hunt 6b8ae1c193 MDL-74390 filter admin: log filter order changes in config_log 2022-03-31 16:50:19 +01:00
Jun Pataleta 2a606b6a10 MDL-70731 mod_forum: Fix moodle_exception error messages 2022-03-31 22:51:16 +08:00
Andrew Nicols 96cbdb8452 Merge branch 'MDL-72446_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-31 22:33:10 +08:00
Ilya Tregubov 1a9775cb82 Merge branch 'MOODLE_311_MDL-73948-v4' of https://github.com/golenkovm/moodle into MOODLE_311_STABLE 2022-03-31 15:41:02 +06:00
Eloy Lafuente (stronk7) 7806534af2 MDL-72446 behat: Ensure that the day reset happens on enabled element
Before this change we were setting the month day to 1 unconditionally
and that was working ok for enabled by default elements.

But in a number or cases we were doing that against disabled elements
so the day reset was not happening. Now we wait for the element to
be enabled and only then proceed with the day reset.

Backed with tests using disabled form elements, so we have now
both enabled and disabled fields covered.
2022-03-31 11:30:22 +02:00
Mikhail Golenkov f994a89ce5 MDL-73948 report_loglive: Fix missing records 2022-03-31 18:36:38 +11:00
Huong Nguyen ae1a4cf5a7 MDL-69552 Quiz: Fix tag filter does not work when adding random question 2022-03-31 11:59:04 +07:00
AMOS bot e1d2f92bda Automatically generated installer lang files 2022-03-31 00:07:32 +00:00
Víctor Déniz 0faeb73989 Merge branch 'MDL-74205-311' of https://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2022-03-30 09:52:17 +01:00
Jun Pataleta 54ca52c917 Merge branch 'MDL-71801-311' of https://github.com/snake/moodle into MOODLE_311_STABLE 2022-03-30 16:14:03 +08:00
Jun Pataleta f3ea59897e Merge branch 'MDL-74231_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-30 14:28:19 +08:00
Ilya Tregubov d9a3ef29ce MDL-74205 navigation: Don't show participants link to user if he has no permission. 2022-03-30 10:44:13 +06:00
Eloy Lafuente (stronk7) 224038fc65 MDL-74231 grader report: Fix case where old settings are empty / null
There is an edge case in the conversion from old collapse/expand
settings (stored as user preference) to the new ones that can lead
to notices / warnings / errors.

Before PHP 8, they weren't being detected, but now they are.

Basically, if some of the expected components of the preferences
are missing, then some array (array_diff(), array_intersect()..)
operations now are failing, because now those parameter functions
do require to be arrays (so empty strings or nulls aren't allowed).

Also, there were some cases where the old preference was not being
removed ever, so its removal has been moved to a common place at
the end of the function, where it's always evaluated in case
the preference still exists but is empty of contents.

I've tried to cover all the cases I've been able to imagine with
unit tests (empty information, some component not set, all components
not set...), have moved it to a new unit test because the one
already performing some tests with those old preferences was
already too long to add more cases.
2022-03-29 23:47:50 +02:00
Eloy Lafuente (stronk7) 3ab09c775d weekly release 3.11.6+ 2022-03-29 17:53:55 +02:00
Eloy Lafuente (stronk7) 065bcc9a3a Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-03-29 17:53:51 +02:00
Jake Dallimore 962f75ec53 MDL-71801 mod_lti: set default keytype value when upgrading tool types
MDL-66920 added this field but didn't set defaults for upgrading tool
types. This patch fixes that for any 1.3 tools which don't yet have a
value for this field.
2022-03-29 14:10:23 +08:00
Andrew Nicols 982e4df1f1 Merge branch 'MDL-74117-311' of https://github.com/rezaies/moodle into MOODLE_311_STABLE 2022-03-29 11:25:06 +08:00
Jun Pataleta d1d96d4902 Merge branch 'MDL-74110-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-29 10:51:00 +08:00
Víctor Déniz 5c2be62c94 Merge branch 'MDL-74321-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-03-28 22:48:59 +01:00
Jun Pataleta cc05ca22da Merge branch 'MDL-74279_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-28 23:29:05 +08:00
Andrew Nicols f5b9056370 Merge branch 'MDL-74299-311' of https://github.com/ericmerrill/moodle into MOODLE_311_STABLE 2022-03-28 15:52:34 +08:00
Shamim Rezaie 03a003289a MDL-74117 theme_boost: Only focus the trigger if nothing else is focused 2022-03-28 18:20:10 +11:00
Jun Pataleta a8011f89c8 MDL-74321 mod_forum: Add forum_check_throttling unit tests 2022-03-28 14:40:29 +08:00
Jun Pataleta 8a9fea33e2 MDL-74321 mod_forum: Forum_check_throttling improvements and fixes
* Fetch only the fields required by the function.
* Quick validation of the passed forum parameter. If the forum parameter
is an object, it should have the forum ID and the course ID.
* Default return when there's no need to show a warning yet.
2022-03-28 14:40:28 +08:00
Jun Pataleta 9d827a29a4 MDL-74321 mod_forum: Pass course module to forum_check_throttling() 2022-03-28 14:40:26 +08:00
Jun Pataleta 2c2686d66e MDL-74321 mod_forum: forum_check_throttling performance improvements
* Return early if the forum's blockafter or blockperiod attributes
are empty.
* If $cm is not passed in forum_check_throttling(), try to fetch it
using get_fast_modinfo() which avoids DB reads. Fetch it via
get_coursemodule_from_instance() as a last resort (though it's unlikely
to happen).
2022-03-28 14:40:25 +08:00
Ilya Tregubov 0d05e7696f Merge branch 'MDL-59681-recursive-file-311' of https://github.com/ilyatregubov/moodle into MOODLE_311_STABLE 2022-03-28 12:06:10 +06:00
Brendan Heywood 56846834e4 MDL-59681 file: Stop recursive file serving 2022-03-28 11:57:04 +06:00
Eloy Lafuente (stronk7) 5e1cee2bd4 Merge branch 'MDL-72634-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-27 16:50:46 +02:00
Eloy Lafuente (stronk7) e34536fc05 Merge branch 'MDL-74306-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-27 16:04:25 +02:00
Eloy Lafuente (stronk7) 54ecc0d0d7 MDL-74279 phpunit: Tests using sqlsrv AdoDB must reset settings
AdoDB SQL*Server drivers use to modify some error and
logging preferences. As far as the connection is shared
with the main one, that implies that those settings
remain for the whole remaining execution.

We don't want his in tests, because can affect to other
tests at distance.

We are fixing this here, only for tests, because it
doesn't affect normal requests and because, once we
remove AdoDB this won't be needed anymore.
2022-03-26 18:43:30 +01:00
AMOS bot 419f6d6d5c Automatically generated installer lang files 2022-03-26 00:07:28 +00:00
Víctor Déniz 49171c9f6e weekly release 3.11.6+ 2022-03-25 15:00:24 +00:00
Víctor Déniz 53a2efa29f Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-03-25 15:00:19 +00:00
Paul Holden 8e19d73c2b MDL-74202 webservice: fix protocol type in exception message. 2022-03-25 09:53:15 +00:00
Jun Pataleta 432bd19d5a Merge branch 'MDL-74143_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-25 13:12:38 +08:00
Ferran Recio 7eee5bff29 MDL-74286 gradereport_grader: fix overlap scale selector 2022-03-24 15:50:58 +01:00
Víctor Déniz 60d07529d0 Merge branch 'MDL-74307-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-03-24 09:19:48 +00:00
Jun Pataleta 81d104300b Merge branch 'MDL-74274-311' of https://github.com/peterRd/moodle into MOODLE_311_STABLE 2022-03-24 16:33:26 +08:00
Eric Merrill 7fc6677853 MDL-74299 question: Don't use a strict comparison for DB objects 2022-03-23 19:20:37 -04:00
Eloy Lafuente (stronk7) f8037d326d MDL-74143 database: Make get_indexes() to return original column names
Sometimes, in order to provide a cross-db behaviour of unique indexes
mixing null and not null columns, we create, under the hood, some
function based indexes.

When that happens get_indexes() is returning the name of the
expression objects used to calculate that function index. But we need
the original column names to be able to compare indexes and get
column dependencies properly.

So, this patch just looks, when the index is unique and function based,
to the expressions (pretty standard CASE statements) and gets the
original column name from it.

Covered with tests.
2022-03-23 23:17:30 +01:00
Paul Holden baba2c573e MDL-74306 mod_assign: fix undefined property in override cache key. 2022-03-23 18:56:17 +00:00
Sara Arjona 08b121599e Merge branch 'MOODLE_311_MDL-48633' of https://github.com/golenkovm/moodle into MOODLE_311_STABLE 2022-03-23 15:14:32 +01:00
Sara Arjona 2532fc2a15 Merge branch 'MDL-74283-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-23 13:53:23 +01:00
Sara Arjona f31b3f4d55 Merge branch 'MDL-57383-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-23 13:51:16 +01:00
Ilya Tregubov b6327f4435 Merge branch 'MDL-74121-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-03-23 17:22:33 +06:00
Sujith Haridasan 7745c451fd MDL-74307 core_search: Use PARAM_ALPHANUMEXT for $areaid
Use PARAM_ALPHANUMEXT for $areaid as areaid can also be
say mod_h5pactivity. When PARAM_ALPHAEXT is used it would
become mod_hpactivity and would cause exception in code flow.
2022-03-23 14:53:16 +05:30
Sujith Haridasan 290ee98681 MDL-74121 mod_forum: Fix the posting threshold issue
When a student post exceeds the posting threshold
block then 'Add discussion topic' button should not be shown.
Also the student cannot reply to a topic if this is exceeded.
2022-03-23 14:23:13 +05:30
Peter Dias 12c5859ad2 MDL-74274 lesson: Set maxattempts reached when retries allowed 2022-03-23 10:36:38 +08:00
AMOS bot b364d2b8fe Automatically generated installer lang files 2022-03-23 00:07:26 +00:00
Paul Holden 3dd97076d9 MDL-74283 dml: replace hardcoded concat SQL with appropriate API. 2022-03-22 17:32:41 +00:00
Paul Holden 4a61fc1e76 MDL-72634 user: populate default city/country during user creation. 2022-03-22 17:28:01 +00:00
Sara Arjona ced37870e6 MDL-74184 behat: Unrelated, remove the @skip_interim tag
This commit is UNRELATED to the MDL-74184, but we need the
@skip_interim tag removed to a couple of scenarios that were
causing lots of noise and failures @ci infrastructure.
MDL-74265 was created to deal with this issue but these jobs
are now passing, and nothing has been changed...

So we are using MDL-74184 (this extra commit) to remove that
tag (sorry for the noise).
2022-03-22 17:23:38 +01:00
Sara Arjona 008443efdd Merge branch 'MDL-74184_311' of https://github.com/timhunt/moodle into MOODLE_311_STABLE 2022-03-22 16:42:08 +01:00
Mikhail Golenkov a01201ec4c MDL-48633 mod_lesson: Fix lesson grade handling when scales in use 2022-03-22 23:03:41 +11:00
Sara Arjona 25f22a3cb7 weekly release 3.11.6+ 2022-03-22 12:54:47 +01:00
Sara Arjona 7c585543e9 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-03-22 12:54:44 +01:00
Tim Hunt 039953f01a MDL-74184 quiz: prevent repagination of quizzes with attepts
There was a loophole to this rule on the settings form, which is now fixed.
2022-03-22 10:35:40 +00:00
Ilya Tregubov 66165e081d Merge branch 'MDL-74169-311' of https://github.com/FMCorz/moodle into MOODLE_311_STABLE 2022-03-22 08:48:12 +06:00
Jun Pataleta 5a8d478e3d Merge branch 'MDL-72698_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-22 10:19:26 +08:00
Eloy Lafuente (stronk7) 81da9e8ab2 MDL-72698 behat: fix problem with FF, not able to auto-scroll iframes
The "Save changes" button in the SCORM package falls out from the
viewport and that seems to be a problem for Firefox, not being able
to auto-scroll to it before clicking.

So we are just making the window 200 points taller and that
makes the button to be visible (within the viewport) and clickable.

Also, change the way we "wait" at the end of the scenario and,
instead of reloading, we re-visit one of the contents to allow
completion to be ready for final assertions.
2022-03-22 01:37:39 +01:00
AMOS bot 39d832251f Automatically generated installer lang files 2022-03-22 00:07:28 +00:00
Sara Arjona 6f5dd17b43 Merge branch 'MDL-74225-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-21 12:59:36 +01:00
Sara Arjona a15d2100b4 Merge branch 'MDL-74183-311' of https://github.com/ericmerrill/moodle into MOODLE_311_STABLE 2022-03-21 12:41:17 +01:00
Frédéric Massart 7eb557e695 MDL-74169 core_message: Hide preferences link when permissions lacking 2022-03-21 18:38:05 +08:00
Paul Holden 1e2c2c5a2a MDL-74110 forms: disable calendar link when date selector disabled. 2022-03-21 09:34:14 +00:00
Jun Pataleta 0b463d4203 Merge branch 'MDL-72698_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-03-21 17:13:50 +08:00
Eloy Lafuente (stronk7) c74979a798 MDL-72698 behat: Reduce random lesson behat failures on slow envs
In very slow environments viewing the lesson page for a student takes
more than 1 second and, because of this, the "Spend at least 1 sec"
completion condition is considered done.

So, in order to alleviate this problem, that leads to random failures
in CIs with slow databases, we have changed the condition to be 3
seconds instead.

That seems to do the work in super-slow environments, with 100
executions passing ok (when previously the scenario was failing 33%
of times).

The only cost is that now the behat run will be 2 seconds slower (there
is a wait changed from 2 to 4 seconds), but that's an acceptable
price to pay to get the scenarios consistent passing.

See the issue for more details.
2022-03-19 18:11:02 +01:00
Eloy Lafuente (stronk7) 7bd1ca51c9 MDL-72698 behat: Reduce random scorm behat failures on slow envs
This just applies two "tricks" to make the test to behave better:
- Ensuring that the "wait until the page is loaded" happens in the scorm frame.
- Ensuring that the last item in the package gets some extra time
  by reloading the page completely at the end.

With them, a testing environment with a 100% of failures has become 100%
passing (25 repetitions). That should be good enough to reduce the
impact of that failure everywhere.

See the issue for more details.
2022-03-19 18:10:54 +01:00
Andrew Nicols b463787e70 Merge branch 'MDL-74199-311' of https://github.com/aanabit/moodle into MOODLE_311_STABLE 2022-03-19 22:00:41 +08:00
Andrew Nicols dd1cd6cd8b Merge branch 'MDL-74258-311' of https://github.com/cescobedo/moodle into MOODLE_311_STABLE 2022-03-19 21:54:52 +08:00
Andrew Nicols cd112cf93f Merge branch 'MDL-74270_311' of https://github.com/timhunt/moodle into MOODLE_311_STABLE 2022-03-19 21:42:54 +08:00
Tim Hunt 5ab43fb1b3 MDL-74270 format_float: fix bug with $decimalpoints=0, $stripzeros=true 2022-03-18 22:23:31 +00:00
cescobedo 08e4bc556c MDL-74258 mod_h5pactivity: Add global search to h5pactivity 2022-03-18 17:10:42 +01:00
Sara Arjona 8a5bea2bc3 weekly release 3.11.6+ 2022-03-18 16:28:17 +01:00
Sara Arjona 263a17676b MDL-74116 behat: Unrelated, add the @skip_interim tag
This commit is UNRELATED to the MDL-74116, but we need the
@skip_interim tag added to a couple of scenarios that are
causing lots of noise and failures  @CI infrastructure.
MDL-74265 has been created to deal with this issue.

So we are using MDL-74116 (this extra commit) to add that tag
(sorry for the noise).
2022-03-18 13:46:10 +01:00
Eloy Lafuente (stronk7) 3f6999f42e Merge branch 'MDL-69078-M311_better-error-message-for-wrong-encoding' of https://github.com/ziegenberg/moodle into MOODLE_311_STABLE 2022-03-17 22:24:12 +01:00
Daniel Ziegenberg 8b7d96ca68 MDL-69078 questions: check for UTF-8 encoding of the import file
Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2022-03-17 21:36:27 +01:00
Eloy Lafuente (stronk7) 4f5bdfcc0c Merge branch 'MDL-74159-311' of https://github.com/sarjona/moodle into MOODLE_311_STABLE 2022-03-17 18:08:37 +01:00
Andrew Nicols 77655b1ba3 Merge branch 'MDL-72991-311-2' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-03-17 22:25:19 +08:00
Sara Arjona 2fae9b9849 Merge branch 'MDL-74214-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-17 13:11:54 +01:00
Jun Pataleta e9827edb0a Merge branch 'MDL-74112-311' of https://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2022-03-17 17:08:55 +08:00
Sara Arjona bce68bd0c4 Merge branch 'MDL-74127-311' of https://github.com/peterRd/moodle into MOODLE_311_STABLE 2022-03-17 09:15:08 +01:00
Jun Pataleta 8c34c3ed08 Merge branch 'MDL-73597-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-03-17 15:50:30 +08:00
Andrew Nicols 7da1d94956 MDL-74112 course: Support multiple mforms in format chooser
The format chooser JS assumes that it is the only mform on the page. If
it is not, and another mform appears before it, then the jump will not
work.
2022-03-17 10:55:43 +08:00
Peter Dias 125b689a5c MDL-74127 lesson: Show remaining attempts on all types of jumps
- Show remaining attempts on all types of jumps
- Highlight the lesson tab when viewing the continue page.
2022-03-17 09:10:28 +08:00
Eloy Lafuente (stronk7) 8e2b50aec5 Merge branch 'MDL-74116-311' of https://github.com/andrewnicols/moodle into MOODLE_311_STABLE 2022-03-16 22:19:20 +01:00
Andrew Nicols 74f0fe1e77 MDL-74116 behat: Fix browser instantiation for Selenium 4 2022-03-16 22:29:10 +08:00
Sara Arjona 55e1312f88 Merge branch 'MDL-74073-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-03-16 12:05:24 +01:00
Paul Holden 0c6b884060 MDL-74225 dataformat: load plugin settings into admin tree. 2022-03-16 09:43:01 +00:00
Huong Nguyen 7d764cde8b MDL-73597 Questions: Form checker integration for D&D question types 2022-03-16 16:29:19 +07:00
Jun Pataleta 576020ce6a MDL-74073 core_form: Set aria-expanded values for expand/collapse all 2022-03-16 14:00:28 +08:00
Ilya Tregubov 22fb553178 Merge branch 'MDL-74144-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-03-16 10:37:35 +06:00
Ilya Tregubov 820cac7677 Merge branch 'MDL-73344-311' of https://github.com/peterRd/moodle into MOODLE_311_STABLE 2022-03-16 10:05:20 +06:00
Eloy Lafuente (stronk7) 1dcfa8fffe Merge branch 'MDL-74141-311' of https://github.com/sarjona/moodle into MOODLE_311_STABLE 2022-03-15 23:38:26 +01:00
Paul Holden ba53bf48a7 MDL-57383 tool_uploaduser: don't overwrite auth during update.
If updating users during upload along with the option to fill in
missing fields from file content, then we should exclude the auth
column because it will always be present for a user.
2022-03-15 17:20:09 +00:00
Amaia Anabitarte 7b8c92106a MDL-74199 core_user: Remove breadcrumbs on private files 2022-03-15 18:10:35 +01:00
Eloy Lafuente (stronk7) b25dce473b Merge branch 'MDL-74131-311' of https://github.com/aanabit/moodle into MOODLE_311_STABLE 2022-03-15 16:54:47 +01:00
Eloy Lafuente (stronk7) 911441bf43 Merge branch 'MDL-74156-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-03-15 15:38:15 +01:00
Paul Holden 8dc128313a MDL-74214 forms: re-calculate calendar panel zIndex each time.
The previous iteration only calculated it's zIndex value on
initial load. This meant that any nodes added subsequent to this
would not be taken into account (e.g. modal forms).
2022-03-15 13:57:29 +00:00
Sara Arjona e14a534ce1 Merge branch 'MDL-73979-311-2' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-03-15 12:29:03 +01:00
Sara Arjona 5aacd4ba77 Merge branch 'MDL-74130_311' of https://github.com/timhunt/moodle into MOODLE_311_STABLE 2022-03-15 12:19:17 +01:00
Sara Arjona ed0dacbb5d weekly release 3.11.6+ 2022-03-15 11:30:30 +01:00
Huong Nguyen 62a909f91a MDL-72991 Course: Improve coursemodinfo cache performance
- New course_modinfo::get_array_of_activities() function was created to reduce
   the unnecessary DB call
 - New course_modinfo::purge_course_cache function was created to purge the cache of a given course
2022-03-15 10:57:12 +07:00
Huong Nguyen 1f85802f86 MDL-72991 Course: Fix move_section_to is not updating correct section
When we change the position of two sections, we just need to update
the position of the affected sections, not all the sections in the course.
This will improve the performance since the system only executes the queries to affected sections.
Also, the system only clears the cache for affected sections, not all the sections in the course.
2022-03-15 10:37:55 +07:00
Eric Merrill 109bac00c8 MDL-74183 completion: Protect against index conflict in cron 2022-03-14 22:56:38 -04:00
Sara Arjona d789be92ae Merge branch 'MDL-74179-311' of https://github.com/cescobedo/moodle into MOODLE_311_STABLE 2022-03-14 18:48:49 +01:00
cescobedo ba26cf7c90 MDL-74179 mod_chat: Fix warnings header when accessing as a guest
Initialize  before showing the no guest message
when user is accesing as a guest.
2022-03-14 11:08:58 +01:00
Amaia Anabitarte f0170da7ec MDL-74131 tags: Fix flagged tags color contrast 2022-03-14 09:59:54 +01:00
Sara Arjona 2fe08752e6 Merge branch 'MDL-73629-311_color_errors' of https://github.com/brickfield/moodle into MOODLE_311_STABLE 2022-03-14 08:37:14 +01:00
Mike Churchward 42c4d51f7c MDL-73629 tool_brickfield: Ensuring colour check causes no errors. 2022-03-11 15:21:07 -05:00
Huong Nguyen b635c658c8 MDL-73979 timeline: Views should display consistent information
The course view is updated to display the events that match
the filter condition, no matter the course start date is in the future
or the course end date is in the past
2022-03-11 09:46:05 +07:00
Sara Arjona c604750339 MDL-74159 output: Add icon near docs link
An icon has been added near the 'Help and documentation' link in the
site footer When the site admin setting 'Open in new window' (doctonewwindow)
is enabled, for consistency with other similar links like 'Give feedback
about this software'.

Apart from that, now the link will be opened using the standard target
'_blank' instead of using the new window Javascript, to let users decide
whether the new page should be opened in a new tab or a new window.
2022-03-10 17:18:01 +01:00
Sara Arjona 87a6da0d59 MDL-74141 tool_task: Display error when Path to CLI not defined
When "Path to PHP CLI" is not defined, an exception with the message
in cannotfindthepathtothecli should be displayed, and the page should
be redirected to System paths settings page.

Apart from that, this patch also replaced core_task to tool_task,
because this message wasn't traslated properly.
2022-03-10 16:25:02 +01:00
Tim Hunt 37b3397bea MDL-74130 question behat: Update tests to use the new navigation steps 2022-03-10 09:29:24 +00:00
Jun Pataleta f8ebec2da5 MDL-74156 block: Remove redundant configure block headings 2022-03-10 16:47:27 +08:00
Tim Hunt 8af6174946 MDL-74130 question behat: support I am on ... page or key qbank pages 2022-03-09 14:46:36 +00:00
Paul Holden 767d46be4c MDL-74144 user: add cancel button to user private files form. 2022-03-09 11:43:43 +00:00
Peter Dias c64dc2e545 MDL-73344 reports: Include the user/report node based on context
Properly indicate the report node based on context.
2022-03-08 14:02:22 +08:00
Max Larkin 4c53ddf46b MDL-73555 tool_brickfield: More efficient summary data processing 2022-01-20 11:42:21 -05:00
314 changed files with 4903 additions and 1710 deletions
+1
View File
@@ -51,3 +51,4 @@ moodle-plugin-ci.phar
.eslintignore
.stylelintignore
/jsdoc
.phpcs.xml
+39
View File
@@ -21,6 +21,43 @@
*/
module.exports = grunt => {
/**
* Generate the PHPCS configuration.
*
* @param {Object} thirdPartyPaths
*/
const phpcsIgnore = (thirdPartyPaths) => {
const {toXML} = require('jstoxml');
const config = {
_name: 'ruleset',
_attrs: {
name: "MoodleCore",
},
_content: [
{
rule: {
_attrs: {
ref: './.phpcs.xml.dist',
},
},
},
],
};
thirdPartyPaths.forEach(library => {
config._content.push({
'exclude-pattern': library,
});
});
grunt.file.write('.phpcs.xml', toXML(config, {
header: true,
indent: ' ',
}) + "\n");
};
/**
* Generate ignore files (utilising thirdpartylibs.xml data)
*/
@@ -52,6 +89,8 @@ module.exports = grunt => {
'jsdoc/styles/*.css',
].concat(thirdPartyPaths);
grunt.file.write('.stylelintignore', stylelintIgnores.join('\n') + '\n');
phpcsIgnore(thirdPartyPaths);
};
grunt.registerTask('ignorefiles', 'Generate ignore files for linters', handler);
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="MoodleCore">
<rule ref="moodle"/>
</ruleset>
+1 -1
View File
@@ -26,7 +26,7 @@ require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('searchareas');
$areaid = optional_param('areaid', null, PARAM_ALPHAEXT);
$areaid = optional_param('areaid', null, PARAM_ALPHANUMEXT);
$action = optional_param('action', null, PARAM_ALPHA);
$indexingenabled = \core_search\manager::is_indexing_enabled(); // This restricts many of the actions on this page.
+7
View File
@@ -308,6 +308,13 @@ if ($hassiteconfig) {
$temp->add(new admin_setting_managedataformats());
$ADMIN->add('dataformatsettings', $temp);
$plugins = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
core_collator::asort_objects_by_property($plugins, 'displayname');
foreach ($plugins as $plugin) {
/** @var \core\plugininfo\dataformat $plugin */
$plugin->load_settings($ADMIN, 'dataformatsettings', $hassiteconfig);
}
//== Portfolio settings ==
require_once($CFG->libdir. '/portfoliolib.php');
$catname = new lang_string('portfolios', 'portfolio');
+4 -2
View File
@@ -18,6 +18,10 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
And the following "cohorts" exist:
| name | idnumber |
| Cohort 1 | CH1 |
And the following "cohort members" exist:
| user | cohort |
| user2 | CH1 |
| user3 | CH1 |
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
@@ -27,8 +31,6 @@ Feature: An administrator can filter user accounts by role, cohort and other pro
| user2 | C1 | student |
| user3 | C1 | student |
And I log in as "admin"
And I add "User Two (two@example.com)" user to "CH1" cohort members
And I add "User Three (three@example.com)" user to "CH1" cohort members
And I navigate to "Users > Accounts > Browse list of users" in site administration
Scenario: Filter user accounts by role and cohort
+12 -12
View File
@@ -477,8 +477,6 @@ class accessibility {
public static function get_summary_data(int $id): \stdClass {
global $CFG, $DB;
$components = $DB->get_records(manager::DB_AREAS);
$summarydata = new \stdClass();
$summarydata->siteurl = (substr($CFG->wwwroot, -1) !== '/') ? $CFG->wwwroot . '/' : $CFG->wwwroot;
$summarydata->moodlerelease = (preg_match('/^(\d+\.\d.*?)[. ]/', $CFG->release, $matches)) ? $matches[1] : $CFG->release;
@@ -488,7 +486,7 @@ class accessibility {
$summarydata->numfactivities = $DB->count_records('course_modules');
$summarydata->mobileservice = (int)$CFG->enablemobilewebservice === 1 ? true : false;
$summarydata->usersmobileregistered = $DB->count_records('user_devices');
$summarydata->contenttyperesults = static::get_contenttyperesults($id, $components);
$summarydata->contenttyperesults = static::get_contenttyperesults($id);
$summarydata->contenttypeerrors = static::get_contenttypeerrors();
$summarydata->percheckerrors = static::get_percheckerrors();
return $summarydata;
@@ -497,22 +495,24 @@ class accessibility {
/**
* Get content type results.
* @param int $id
* @param array $components
* @return \stdClass
*/
private static function get_contenttyperesults(int $id, array $components): \stdClass {
private static function get_contenttyperesults(int $id): \stdClass {
global $DB;
$sql = 'SELECT component, COUNT(id) AS count
FROM {' . manager::DB_AREAS . '}
GROUP BY component';
$components = $DB->get_recordset_sql($sql);
$contenttyperesults = new \stdClass();
$contenttyperesults->id = $id;
$datacomponents = array();
foreach ($components as $component) {
$datacomponents[$component->component][] = $component;
}
$contenttyperesults->contenttype = new \stdClass();
foreach ($datacomponents as $key => $component) {
$contenttyperesults->contenttype->$key = count($component);
foreach ($components as $component) {
$componentname = $component->component;
$contenttyperesults->contenttype->$componentname = $component->count;
}
$components->close();
$contenttyperesults->summarydatastorage = static::get_summary_data_storage();
$contenttyperesults->datachecked = time(); // Correct??
$contenttyperesults->datachecked = time();
return $contenttyperesults;
}
@@ -25,7 +25,7 @@ namespace tool_brickfield\local\htmlchecker\common;
*/
class brickfield_accessibility_color_test extends brickfield_accessibility_test {
/** @var string[] Mapping of colours to hex codes. */
/** @var string[] Define colour codes. */
public $colornames = [
'aliceblue' => 'f0f8ff',
'antiquewhite' => 'faebd7',
@@ -183,6 +183,12 @@ class brickfield_accessibility_color_test extends brickfield_accessibility_test
}
$forergb = $this->get_rgb($foreground);
$backrgb = $this->get_rgb($background);
// If get_rgb returns null for either, return 0.
if ($forergb === null || $backrgb === null) {
return 0;
}
return $this->luminosity($forergb['r'], $backrgb['r'],
$forergb['g'], $backrgb['g'],
$forergb['b'], $backrgb['b']);
@@ -227,15 +233,15 @@ class brickfield_accessibility_color_test extends brickfield_accessibility_test
/**
* Returns the decimal equivalents for a HEX color
* Returns the decimal equivalents for a HEX color. Returns null if it cannot be determined.
* @param string $color The hex color value
* @return array An array where 'r' is the Red value, 'g' is Green, and 'b' is Blue
* @return array|null An array where 'r' is the Red value, 'g' is Green, and 'b' is Blue
*/
public function get_rgb(string $color) {
public function get_rgb(string $color): ?array {
$color = $this->convert_color($color);
$c = str_split($color, 2);
if (count($c) != 3) {
return false;
return null;
}
$results = ['r' => hexdec($c[0]), 'g' => hexdec($c[1]), 'b' => hexdec($c[2])];
return $results;
@@ -307,6 +313,12 @@ class brickfield_accessibility_color_test extends brickfield_accessibility_test
public function get_wai_ert_contrast(string $foreground, string $background): array {
$forergb = $this->get_rgb($foreground);
$backrgb = $this->get_rgb($background);
// If get_rgb returns null for either, return 0.
if ($forergb === null || $backrgb === null) {
return [];
}
$diffs = $this->get_wai_diffs($forergb, $backrgb);
return $diffs['red'] + $diffs['green'] + $diffs['blue'];
@@ -321,12 +333,18 @@ class brickfield_accessibility_color_test extends brickfield_accessibility_test
public function get_wai_ert_brightness(string $foreground, string $background): float {
$forergb = $this->get_rgb($foreground);
$backrgb = $this->get_rgb($background);
// If get_rgb returns null for either, return 0.
if ($forergb === null || $backrgb === null) {
return 0;
}
$color = $this->get_wai_diffs($forergb, $backrgb);
return (($color['red'] * 299) + ($color['green'] * 587) + ($color['blue'] * 114)) / 1000;
}
/**
* Get wai diffs.
* Get the wai differences.
* @param array $forergb
* @param array $backrgb
* @return array
@@ -248,7 +248,7 @@ $string['printable:toolname'] = 'Summary report';
$string['printable:toolshortname'] = 'Summary report';
$string['printable:downloadpdf'] = 'Download PDF';
$string['printable:printreport'] = 'Printable report';
$string['error:nocoursespecified'] = 'This summary report requires a valid course id. Please access the accessibility toolkit from within a course, via the actions menu, which will then supply this required course id.';
$string['error:nocoursespecified'] = 'The summary report requires a valid course ID. Please access the accessibility toolkit from within a course.';
$string['pdf:filename'] = 'Brickfield_Summaryreport_CourseID-{$a}';
// Advanced page.
@@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* tool_brickfield check test.
* Class test_css_text_has_contrast test
*
* @package tool_brickfield
* @copyright 2020 onward: Brickfield Education Labs, https://www.brickfield.ie
@@ -29,14 +29,79 @@ defined('MOODLE_INTERNAL') || die();
require_once('all_checks.php');
/**
* Class test_css_text_has_contrast_testcase
* Class test_css_text_has_contrast_test
*/
class css_text_has_contrast_test extends all_checks {
/** @var string Check type */
/** @var string The check type. */
protected $checktype = 'css_text_has_contrast';
/** @var string Html fail */
private $htmlfail = <<<EOD
/** @var string HTML that should get flagged. */
private $htmlfail1 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:#333333; background-color:#000000; font-weight: bold;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML that should get flagged. */
private $htmlfail2 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:#333333; background-color:#000000; font-size: 18px;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML that should get flagged. */
private $htmlfail3 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:#333333; background-color:#000000; font-size: 18%;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML that should get flagged. */
private $htmlfail4 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:#333333; background-color:#000000; font-size: 18em;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML that should get flagged. */
private $htmlfail5 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:#333333; background-color:#000000; font-size: 18ex;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML that should get flagged. */
private $htmlfail6 = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
@@ -48,7 +113,7 @@ class css_text_has_contrast_test extends all_checks {
</html>
EOD;
/** @var string Html pass */
/** @var string HTML that should not get flagged. */
private $htmlpass = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
@@ -61,14 +126,113 @@ EOD;
</html>
EOD;
/** @var string HTML that should get flagged. */
private $namecolours = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color: red; background-color: blue;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML with invalid colour names. */
private $invalidcolours = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color: grog; background-color: numpi;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML with invalid colour numeric values. */
private $invalidvalue = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color: 10000500; background-color: -10234;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/** @var string HTML with empty colour values. */
private $emptyvalue = <<<EOD
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<title>OAC Testfile - Check #6 - Positive</title>
</head>
<body>
<p style="color:; background-color:;">This is not contrasty enough.</p>
</body>
</html>
EOD;
/**
* Test for the area assign intro
*/
public function test_check() {
$results = $this->get_checker_results($this->htmlfail);
$results = $this->get_checker_results($this->htmlfail1);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlfail2);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlfail3);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlfail4);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlfail5);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlfail6);
$this->assertTrue($results[0]->element->tagName == 'p');
$results = $this->get_checker_results($this->htmlpass);
$this->assertEmpty($results);
}
/**
* Test with valid colour names.
*/
public function test_check_for_namedcolours() {
$results = $this->get_checker_results($this->namecolours);
$this->assertTrue($results[0]->element->tagName == 'p');
}
/**
* Test with invalid colour names.
*/
public function test_check_for_invalidcolours() {
$results = $this->get_checker_results($this->invalidcolours);
$this->assertTrue($results[0]->element->tagName == 'p');
}
/**
* Test with invalid colour numeric values.
*/
public function test_check_for_invalidvalues() {
$results = $this->get_checker_results($this->invalidvalue);
$this->assertTrue($results[0]->element->tagName == 'p');
}
/**
* Test with empty colour values.
*/
public function test_check_for_emptyvalues() {
$results = $this->get_checker_results($this->emptyvalue);
$this->assertEmpty($results);
}
}
+6
View File
@@ -0,0 +1,6 @@
This files describes API changes in /admin/tool/brickfield/*.
=== 3.11.7 ===
* classes/local/htmlchecker/common/brickfield_accessibility_color_test::get_rgb() has been modified to return either an
array or null. Previously it returned either an array or false.
+15 -2
View File
@@ -36,7 +36,7 @@ class tool_customlang_utils {
* Rough number of strings that are being processed during a full checkout.
* This is used to estimate the progress of the checkout.
*/
const ROUGH_NUMBER_OF_STRINGS = 16500;
const ROUGH_NUMBER_OF_STRINGS = 32000;
/** @var array cache of {@link self::list_components()} results */
private static $components = null;
@@ -91,9 +91,22 @@ class tool_customlang_utils {
public static function checkout($lang, progress_bar $progressbar = null) {
global $DB;
// For behat executions we are going to load only a few components in the
// language customisation structures. Using the whole "en" langpack is
// too much slow (leads to Selenium 30s timeouts, especially on slow
// environments) and we don't really need the whole thing for tests. So,
// apart from escaping from the timeouts, we are also saving some good minutes
// in tests. See MDL-70014 and linked issues for more info.
$behatneeded = ['core', 'core_langconfig', 'tool_customlang'];
// make sure that all components are registered
$current = $DB->get_records('tool_customlang_components', null, 'name', 'name,version,id');
foreach (self::list_components() as $component) {
// Filter out unwanted components when running behat.
if (defined('BEHAT_SITE_RUNNING') && !in_array($component, $behatneeded)) {
continue;
}
if (empty($current[$component])) {
$record = new stdclass();
$record->name = $component;
@@ -103,7 +116,7 @@ class tool_customlang_utils {
$record->version = $version;
}
$DB->insert_record('tool_customlang_components', $record);
} elseif ($version = get_component_version($component)) {
} else if ($version = get_component_version($component)) {
if (is_null($current[$component]->version) or ($version > $current[$component]->version)) {
$DB->set_field('tool_customlang_components', 'version', $version, array('id' => $current[$component]->id));
}
@@ -0,0 +1,45 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
declare(strict_types=1);
namespace tool_moodlenet\task;
use core\message\message;
/**
* Ad-hoc task to send a notification to admin stating that the user data related to the linked MoodleNet profiles has
* been removed.
*
* @package tool_moodlenet
* @copyright 2022 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class send_mnet_profiles_data_removed_notification extends \core\task\adhoc_task {
public function execute(): void {
$message = new message();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = \core_user::get_noreply_user();
$message->userto = get_admin();
$message->notification = 1;
$message->subject = get_string('removedmnetprofilenotification_subject', 'tool_moodlenet');
$message->fullmessageformat = FORMAT_HTML;
$message->fullmessagehtml = get_string('removedmnetprofilenotification', 'tool_moodlenet');
$message->smallmessage = strip_tags($message->fullmessagehtml);
message_send($message);
}
}
+19
View File
@@ -129,5 +129,24 @@ function xmldb_tool_moodlenet_upgrade(int $oldversion) {
// Automatically generated Moodle v3.11.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2021051701) {
$selectsql = "moodlenetprofile IS NOT NULL AND moodlenetprofile != ''";
// If there are any users with MoodleNet profile set.
if ($DB->count_records_select('user', $selectsql)) {
// Remove the value set for the MoodleNet profile as this format can no longer be used to authenticate
// MoodleNet users.
$DB->set_field_select('user', 'moodlenetprofile', '', $selectsql);
// Use an adhoc task to send a notification to admin stating that the user data related to the linked
// MoodleNet profiles has been removed.
$notificationtask = new tool_moodlenet\task\send_mnet_profiles_data_removed_notification();
core\task\manager::queue_adhoc_task($notificationtask);
}
upgrade_plugin_savepoint(true, 2021051701, 'tool', 'moodlenet');
}
return true;
}
@@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();
$string['addingaresource'] = 'Adding content from MoodleNet';
$string['aria:enterprofile'] = "Enter your MoodleNet profile URL";
$string['aria:enterprofile'] = "Enter your MoodleNet profile ID";
$string['aria:footermessage'] = "Browse for content on MoodleNet";
$string['browsecontentmoodlenet'] = "Or browse for content on MoodleNet";
$string['clearsearch'] = "Clear search";
@@ -39,11 +39,11 @@ $string['defaultmoodlenetname_desc'] = 'The name of the MoodleNet instance avail
$string['enablemoodlenet'] = 'Enable MoodleNet integration';
$string['enablemoodlenet_desc'] = 'If enabled, a user with the capability to create and manage activities can browse MoodleNet via the activity chooser and import MoodleNet resources into their course. In addition, a user with the capability to restore backups can select a backup file on MoodleNet and restore it into Moodle.';
$string['errorduringdownload'] = 'An error occurred while downloading the file: {$a}';
$string['forminfo'] = 'Your MoodleNet profile will be automatically saved in your profile on this site.';
$string['forminfo'] = 'Your MoodleNet profile ID will be automatically saved in your profile on this site.';
$string['footermessage'] = "Or browse for content on";
$string['instancedescription'] = "MoodleNet is an open social media platform for educators, with a focus on the collaborative curation of collections of open resources. ";
$string['instanceplaceholder'] = '@yourprofile@moodle.net';
$string['inputhelp'] = 'Or if you have a MoodleNet account already, enter your MoodleNet profile:';
$string['instanceplaceholder'] = 'a1b2c3d4e5f6-example@moodle.net';
$string['inputhelp'] = 'Or if you have a MoodleNet account already, copy the ID from your MoodleNet profile and paste it here:';
$string['invalidmoodlenetprofile'] = '$userprofile is not correctly formatted';
$string['importconfirm'] = 'You are about to import the content "{$a->resourcename} ({$a->resourcetype})" into the course "{$a->coursename}". Are you sure you want to continue?';
$string['importconfirmnocourse'] = 'You are about to import the content "{$a->resourcename} ({$a->resourcetype})" into your site. Are you sure you want to continue?';
@@ -56,12 +56,14 @@ $string['mnetprofiledesc'] = '<p>Enter your MoodleNet profile details here to be
$string['moodlenetsettings'] = 'MoodleNet settings';
$string['moodlenetnotenabled'] = 'The MoodleNet integration must be enabled in Site administration / MoodleNet before resource imports can be processed.';
$string['notification'] = 'You are about to import the content "{$a->name} ({$a->type})" into your site. Select the course in which it should be added, or <a href="{$a->cancellink}">cancel</a>.';
$string['removedmnetprofilenotification'] = 'Due to recent changes on the MoodleNet platform, any users who previously saved their MoodleNet profile ID on the site will need to enter a MoodleNet profile ID in the new format in order to authenticate on the MoodleNet platform.';
$string['removedmnetprofilenotification_subject'] = 'MoodleNet profile ID format change';
$string['searchcourses'] = "Search courses";
$string['selectpagetitle'] = 'Select page';
$string['pluginname'] = 'MoodleNet';
$string['privacy:metadata'] = "The MoodleNet tool only facilitates communication with MoodleNet. It stores no data.";
$string['profilevalidationerror'] = 'There was a problem trying to validate your profile';
$string['profilevalidationfail'] = 'Please enter a valid MoodleNet profile';
$string['profilevalidationerror'] = 'There was a problem trying to validate your MoodleNet profile ID';
$string['profilevalidationfail'] = 'Please enter a valid MoodleNet profile ID';
$string['profilevalidationpass'] = 'Looks good!';
$string['saveandgo'] = "Save and go";
$string['uploadlimitexceeded'] = 'The file size {$a->filesize} exceeds the user upload limit of {$a->uploadlimit} bytes.';
+1 -1
View File
@@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = 'tool_moodlenet';
$plugin->version = 2021051700;
$plugin->version = 2021051701;
$plugin->requires = 2021051100;
$plugin->maturity = MATURITY_ALPHA;
+2 -2
View File
@@ -22,8 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['acceptrisk'] = 'I understand that disabling email verification can be a security issue';
$string['acceptrisk_help'] = 'Disabling email verification can be a security issue. As it potentially allows users to authenticate as another in the right circumstances.';
$string['acceptrisk'] = 'I understand that disabling email verification can be a security issue.';
$string['acceptrisk_help'] = 'Disabling email verification can potentially allow a user to authenticate as another user.';
$string['authconfirm'] = 'This action will grant permanent API access to Moodle for the authenticated account. This is intended to be used as a system account for managing files owned by Moodle.';
$string['authconnected'] = 'The system account is now connected for offline access';
$string['authnotconnected'] = 'The system account was not connected for offline access';
@@ -16,10 +16,10 @@ Feature: OAuth2 email verification
| Name | Testing service |
| Client ID | thisistheclientid |
| Client secret | supersecret |
Then I should not see "I understand that disabling email verification can be a security issue"
Then I should not see "I understand that disabling email verification can be a security issue."
And I click on "Require email verification" "checkbox"
And I should see "I understand that disabling email verification can be a security issue"
And I click on "I understand that disabling email verification can be a security issue" "checkbox"
And I should see "I understand that disabling email verification can be a security issue."
And I click on "I understand that disabling email verification can be a security issue." "checkbox"
And I press "Save changes"
And I should see "Changes saved"
And I click on "Edit" "link" in the "Testing service" "table_row"
+6 -2
View File
@@ -54,12 +54,16 @@ if (!$task) {
throw new moodle_exception('cannotfindinfo', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'), $taskname);
}
if (!\core\task\manager::is_runnable()) {
$redirecturl = new \moodle_url('/admin/settings.php', ['section' => 'systempaths']);
throw new moodle_exception('cannotfindthepathtothecli', 'tool_task', $redirecturl->out());
}
$plugininfo = core_plugin_manager::instance()->get_plugin_info($task->get_component());
$plugindisabled = $plugininfo && $plugininfo->is_enabled() === false &&
!$task->get_run_if_component_disabled();
$canruntasks = \core\task\manager::is_runnable() && get_config('tool_task', 'enablerunnow');
if (!$canruntasks || $plugindisabled) {
if (!get_config('tool_task', 'enablerunnow') || $plugindisabled) {
throw new moodle_exception('nopermissions', 'error', new moodle_url('/admin/tool/task/scheduledtasks.php'),
get_string('runnow', 'tool_task'), $task->get_name());
}
+108 -38
View File
@@ -44,6 +44,12 @@ class tool_uploadcourse_course {
/** Outcome of the process: deleting the course */
const DO_DELETE = 3;
/** @var array assignable roles. */
protected $assignableroles = [];
/** @var array Roles context levels. */
protected $contextlevels = [];
/** @var array final import data. */
protected $data = array();
@@ -794,16 +800,15 @@ class tool_uploadcourse_course {
// Get enrolment data. Where the course already exists, we can also perform validation.
$this->enrolmentdata = tool_uploadcourse_helper::get_enrolment_data($this->rawdata);
if ($exists) {
$errors = $this->validate_enrolment_data($coursedata['id'], $this->enrolmentdata);
$courseid = $coursedata['id'] ?? 0;
$errors = $this->validate_enrolment_data($courseid, $this->enrolmentdata);
if (!empty($errors)) {
foreach ($errors as $key => $message) {
$this->error($key, $message);
}
return false;
if (!empty($errors)) {
foreach ($errors as $key => $message) {
$this->error($key, $message);
}
return false;
}
if (isset($this->rawdata['tags']) && strval($this->rawdata['tags']) !== '') {
@@ -913,6 +918,8 @@ class tool_uploadcourse_course {
* @return lang_string[] Errors keyed on error code
*/
protected function validate_enrolment_data(int $courseid, array $enrolmentdata): array {
global $DB;
// Nothing to validate.
if (empty($enrolmentdata)) {
return [];
@@ -924,46 +931,67 @@ class tool_uploadcourse_course {
$instances = enrol_get_instances($courseid, false);
foreach ($enrolmentdata as $method => $options) {
$plugin = $enrolmentplugins[$method];
// Find matching instances by enrolment method.
$methodinstances = array_filter($instances, static function(stdClass $instance) use ($method) {
return (strcmp($instance->enrol, $method) == 0);
});
if (isset($options['role'])) {
$role = $options['role'];
if ($courseid) {
if (!$this->validate_role_context($courseid, $role)) {
$errors['contextrolenotallowed'] = new lang_string('contextrolenotallowed', 'core_role', $role);
if (!empty($options['delete'])) {
// Ensure user is able to delete the instances.
foreach ($methodinstances as $methodinstance) {
if (!$plugin->can_delete_instance($methodinstance)) {
$errors['errorcannotdeleteenrolment'] = new lang_string('errorcannotdeleteenrolment', 'tool_uploadcourse',
$plugin->get_instance_name($methodinstance));
break;
}
} else {
// We can at least check that context level is correct while actual context not exist.
$roleid = $DB->get_field('role', 'id', ['shortname' => $role], MUST_EXIST);
if (!$this->validate_role_context_level($roleid)) {
$errors['contextrolenotallowed'] = new lang_string('contextrolenotallowed', 'core_role', $role);
break;
}
}
} else if (!empty($options['disable'])) {
// Ensure user is able to toggle instance statuses.
foreach ($methodinstances as $methodinstance) {
if (!$plugin->can_hide_show_instance($methodinstance)) {
$errors['errorcannotdisableenrolment'] =
new lang_string('errorcannotdisableenrolment', 'tool_uploadcourse',
}
if ($courseid) {
$plugin = $enrolmentplugins[$method];
// Find matching instances by enrolment method.
$methodinstances = array_filter($instances, static function (stdClass $instance) use ($method) {
return (strcmp($instance->enrol, $method) == 0);
});
if (!empty($options['delete'])) {
// Ensure user is able to delete the instances.
foreach ($methodinstances as $methodinstance) {
if (!$plugin->can_delete_instance($methodinstance)) {
$errors['errorcannotdeleteenrolment'] = new lang_string('errorcannotdeleteenrolment',
'tool_uploadcourse', $plugin->get_instance_name($methodinstance));
break;
}
}
} else if (!empty($options['disable'])) {
// Ensure user is able to toggle instance statuses.
foreach ($methodinstances as $methodinstance) {
if (!$plugin->can_hide_show_instance($methodinstance)) {
$errors['errorcannotdisableenrolment'] =
new lang_string('errorcannotdisableenrolment', 'tool_uploadcourse',
$plugin->get_instance_name($methodinstance));
break;
}
}
} else {
// Ensure user is able to create/update instance.
$methodinstance = empty($methodinstances) ? null : reset($methodinstances);
if ((empty($methodinstance) && !$plugin->can_add_instance($courseid)) ||
(!empty($methodinstance) && !$plugin->can_edit_instance($methodinstance))) {
$errors['errorcannotcreateorupdateenrolment'] =
new lang_string('errorcannotcreateorupdateenrolment', 'tool_uploadcourse',
$plugin->get_instance_name($methodinstance));
break;
}
}
} else {
// Ensure user is able to create/update instance.
$methodinstance = empty($methodinstances) ? null : reset($methodinstances);
if ((empty($methodinstance) && !$plugin->can_add_instance($courseid)) ||
(!empty($methodinstance) && !$plugin->can_edit_instance($methodinstance))) {
$errors['errorcannotcreateorupdateenrolment'] =
new lang_string('errorcannotcreateorupdateenrolment', 'tool_uploadcourse',
$plugin->get_instance_name($methodinstance));
break;
}
}
}
@@ -1079,8 +1107,15 @@ class tool_uploadcourse_course {
$instance->enrolenddate = $instance->enrolstartdate;
}
// Sort out the given role. This does not filter the roles allowed in the course.
// Sort out the given role.
if (isset($method['role'])) {
$role = $method['role'];
if (!$this->validate_role_context($course->id, $role)) {
$this->error('contextrolenotallowed',
new lang_string('contextrolenotallowed', 'core_role', $role));
break;
}
$roleids = tool_uploadcourse_helper::get_role_ids();
if (isset($roleids[$method['role']])) {
$instance->roleid = $roleids[$method['role']];
@@ -1093,6 +1128,41 @@ class tool_uploadcourse_course {
}
}
/**
* Check if role is allowed in course context
*
* @param int $courseid course context.
* @param string $role Role.
* @return bool
*/
protected function validate_role_context(int $courseid, string $role) : bool {
if (empty($this->assignableroles[$courseid])) {
$coursecontext = \context_course::instance($courseid);
$this->assignableroles[$courseid] = get_assignable_roles($coursecontext, ROLENAME_SHORT);
}
if (!in_array($role, $this->assignableroles[$courseid])) {
return false;
}
return true;
}
/**
* Check if role is allowed at this context level.
*
* @param int $roleid Role ID.
* @return bool
*/
protected function validate_role_context_level(int $roleid) : bool {
if (empty($this->contextlevels[$roleid])) {
$this->contextlevels[$roleid] = get_role_contextlevels($roleid);
}
if (!in_array(CONTEXT_COURSE, $this->contextlevels[$roleid])) {
return false;
}
return true;
}
/**
* Reset the current course.
*
@@ -325,6 +325,11 @@ class tool_uploadcourse_helper {
continue;
}
$rolenames['role_' . $rolesids[$matches[1]]] = $value;
} else if (preg_match('/^(.+)?_role$/', $field, $matches)) {
if (!isset($rolesids[$value])) {
$invalidroles[] = $value;
break;
}
}
}
@@ -219,6 +219,10 @@ class tool_uploadcourse_processor {
$data = array_merge($data, $course->get_data(), array('id' => $course->get_id()));
$tracker->output($this->linenb, true, $status, $data);
if ($course->has_errors()) {
$errors++;
$tracker->output($this->linenb, false, $course->get_errors(), $data);
}
} else {
$errors++;
$tracker->output($this->linenb, false, $course->get_errors(), $data);
@@ -105,3 +105,28 @@ Feature: An admin can create courses using a CSV file
And I should see "Field 3: b"
And I should see "Field 4: Hello"
And I should see "Field 5: Some text"
@javascript
Scenario: Validation of role for uploaded courses
Given I navigate to "Users > Permissions > Define roles" in site administration
And I click on "Add a new role" "button"
And I click on "Continue" "button"
And I set the following fields to these values:
| Short name | notallowed |
| Custom full name | notallowed |
| contextlevel80 | 1 |
And I click on "Create this role" "button"
And I navigate to "Courses > Upload courses" in site administration
And I upload "admin/tool/uploadcourse/tests/fixtures/enrolment_role.csv" file to "File" filemanager
And I click on "Preview" "button"
And I should see "Invalid role names: notexist"
And I should see "Role notallowed not allowed in this context."
When I click on "Upload courses" "button"
And I should see "Course created"
And I should see "Courses total: 3"
And I should see "Courses created: 1"
And I should see "Courses errors: 2"
And I should see "Invalid role names: notexist"
And I should see "Role notallowed not allowed in this context."
And I am on site homepage
And I should see "coursez"
@@ -1561,6 +1561,94 @@ class course_test extends \advanced_testcase {
$this->assertArrayHasKey('cannotrenameshortnamealreadyinuse', $co->get_errors());
}
/**
* Test when role doesn't exist.
*
* @covers \tool_uploadcourse_course::prepare
*/
public function test_role_not_exist() {
$this->resetAfterTest();
$this->setAdminUser();
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
$updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
$upload = new tool_uploadcourse_course($mode, $updatemode, [
'category' => 1,
'fullname' => 'Testing',
'shortname' => 'T101',
'enrolment_1' => 'manual',
'enrolment_1_role' => 'notexist'
]);
$this->assertFalse($upload->prepare());
$this->assertArrayHasKey('invalidroles', $upload->get_errors());
}
/**
* Test when role not allowed in course context.
*
* @covers \tool_uploadcourse_course::proceed
*/
public function test_role_not_allowed() {
$this->resetAfterTest();
$this->setAdminUser();
$roleid = create_role('New student role', 'student2', 'New student description', 'student');
set_role_contextlevels($roleid, [CONTEXT_BLOCK]);
$mode = tool_uploadcourse_processor::MODE_CREATE_NEW;
$updatemode = tool_uploadcourse_processor::UPDATE_NOTHING;
$upload = new tool_uploadcourse_course($mode, $updatemode, [
'category' => 1,
'fullname' => 'Testing',
'shortname' => 'T101',
'enrolment_1' => 'manual',
'enrolment_1_role' => 'student2'
]);
$this->assertFalse($upload->prepare());
$this->assertArrayHasKey('contextrolenotallowed', $upload->get_errors());
}
/**
* Test when role is allowed.
*
* @covers \tool_uploadcourse_course::proceed
*/
public function test_role_allowed() {
global $DB;
$this->resetAfterTest();
$this->setAdminUser();
$mode = tool_uploadcourse_processor::MODE_UPDATE_ONLY;
$updatemode = tool_uploadcourse_processor::UPDATE_MISSING_WITH_DATA_OR_DEFAUTLS;
$course = $this->getDataGenerator()->create_course([
'shortname' => 'c1',
]);
$instances = enrol_get_instances($course->id, true);
$studentrole = $DB->get_record('role', ['shortname' => 'student']);
$teacherrole = $DB->get_record('role', ['shortname' => 'teacher']);
$instance = reset($instances);
$this->assertEquals($studentrole->id, $instance->roleid);
$upload = new tool_uploadcourse_course($mode, $updatemode, [
'shortname' => 'c1',
'enrolment_1' => 'manual',
'enrolment_1_role' => 'teacher'
]);
$this->assertTrue($upload->prepare());
$upload->proceed();
$instances = enrol_get_instances($course->id, true);
$instance = reset($instances);
$this->assertEquals($teacherrole->id, $instance->roleid);
}
/**
* Get custom field plugin generator
*
@@ -0,0 +1,4 @@
shortname,fullname,category,enrolment_1,enrolment_1_role
CX,coursex,1,manual,notexist
CY,coursey,1,manual,notallowed
CZ,coursez,1,manual,student
1 shortname fullname category enrolment_1 enrolment_1_role
2 CX coursex 1 manual notexist
3 CY coursey 1 manual notallowed
4 CZ coursez 1 manual student
+5 -1
View File
@@ -692,7 +692,11 @@ class process {
$dologout = false;
if ($this->get_update_type() != UU_UPDATE_NOCHANGES and !$remoteuser) {
if (!empty($user->auth) and $user->auth !== $existinguser->auth) {
// Handle 'auth' column separately, the field can never be missing from a user.
if (!empty($user->auth) && ($user->auth !== $existinguser->auth) &&
($this->get_update_type() != UU_UPDATE_MISSING)) {
$this->upt->track('auth', s($existinguser->auth).'-->'.s($user->auth), 'info', false);
$existinguser->auth = $user->auth;
if (!isset($this->supportedauths[$user->auth])) {
+1
View File
@@ -18,6 +18,7 @@ body div[data-flexitour="step-background-fader"],
body div[data-flexitour="step-background"] {
position: absolute;
background: inherit;
background-image: none;
}
div[data-flexitour="step-background-fader"],
+11
View File
@@ -34,6 +34,17 @@ class auth_db_testcase extends advanced_testcase {
/** @var int The amount of users to create for the large user set deletion test */
protected $largedeletionsetsize = 128;
public static function tearDownAfterClass(): void {
global $DB;
// Apply sqlsrv native driver error and logging default
// settings while finishing the AdoDB tests.
if ($DB->get_dbfamily() === 'mssql') {
sqlsrv_configure("WarningsReturnAsErrors", false);
sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_OFF);
sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ERROR);
}
}
protected function init_auth_database() {
global $DB, $CFG;
require_once("$CFG->dirroot/auth/db/auth.php");
+12 -6
View File
@@ -408,6 +408,11 @@ class backup_course_structure_step extends backup_structure_step {
'shortname', 'type', 'value', 'valueformat'
));
$courseformatoptions = new backup_nested_element('courseformatoptions');
$courseformatoption = new backup_nested_element('courseformatoption', [], [
'courseid', 'format', 'sectionid', 'name', 'value'
]);
// attach format plugin structure to $course element, only one allowed
$this->add_plugin_structure('format', $course, false);
@@ -445,17 +450,14 @@ class backup_course_structure_step extends backup_structure_step {
$course->add_child($customfields);
$customfields->add_child($customfield);
$course->add_child($courseformatoptions);
$courseformatoptions->add_child($courseformatoption);
// Set the sources
$courserec = $DB->get_record('course', array('id' => $this->task->get_courseid()));
$courserec->contextid = $this->task->get_contextid();
$formatoptions = course_get_format($courserec)->get_format_options();
$course->add_final_elements(array_keys($formatoptions));
foreach ($formatoptions as $key => $value) {
$courserec->$key = $value;
}
// Add 'numsections' in order to be able to restore in previous versions of Moodle.
// Even though Moodle does not officially support restore into older verions of Moodle from the
// version where backup was made, without 'numsections' restoring will go very wrong.
@@ -477,6 +479,10 @@ class backup_course_structure_step extends backup_structure_step {
backup_helper::is_sqlparam('course'),
backup::VAR_PARENTID));
$courseformatoption->set_source_sql('SELECT id, format, sectionid, name, value
FROM {course_format_options}
WHERE courseid = ?', [ backup::VAR_PARENTID ]);
$handler = core_course\customfield\course_handler::create();
$fieldsforbackup = $handler->get_instance_data_for_backup($this->task->get_courseid());
$customfield->set_source_array($fieldsforbackup);
+23 -4
View File
@@ -1806,7 +1806,8 @@ class restore_course_structure_step extends restore_structure_step {
$category = new restore_path_element('category', '/course/category');
$tag = new restore_path_element('tag', '/course/tags/tag');
$customfield = new restore_path_element('customfield', '/course/customfields/customfield');
$allowed_module = new restore_path_element('allowed_module', '/course/allowed_modules/module');
$courseformatoptions = new restore_path_element('course_format_option', '/course/courseformatoptions/courseformatoption');
$allowedmodule = new restore_path_element('allowed_module', '/course/allowed_modules/module');
// Apply for 'format' plugins optional paths at course level
$this->add_plugin_structure('format', $course);
@@ -1829,7 +1830,7 @@ class restore_course_structure_step extends restore_structure_step {
// Apply for admin tool plugins optional paths at course level.
$this->add_plugin_structure('tool', $course);
return array($course, $category, $tag, $customfield, $allowed_module);
return array($course, $category, $tag, $customfield, $allowedmodule, $courseformatoptions);
}
/**
@@ -1951,8 +1952,6 @@ class restore_course_structure_step extends restore_structure_step {
// Course record ready, update it
$DB->update_record('course', $data);
course_get_format($data)->update_course_format_options($data);
// Role name aliases
restore_dbops::set_course_role_names($this->get_restoreid(), $this->get_courseid());
}
@@ -1980,6 +1979,26 @@ class restore_course_structure_step extends restore_structure_step {
$handler->restore_instance_data_from_backup($this->task, $data);
}
/**
* Processes a course format option.
*
* @param array $data The record being restored.
* @throws base_step_exception
* @throws dml_exception
*/
public function process_course_format_option(array $data) : void {
global $DB;
$courseid = $this->get_courseid();
$record = $DB->get_record('course_format_options', [ 'courseid' => $courseid, 'name' => $data['name'] ], 'id');
if ($record !== false) {
$DB->update_record('course_format_options', (object) [ 'id' => $record->id, 'value' => $data['value'] ]);
} else {
$data['courseid'] = $courseid;
$DB->insert_record('course_format_options', (object) $data);
}
}
public function process_allowed_module($data) {
$data = (object)$data;
+6 -1
View File
@@ -248,8 +248,11 @@ class award_criteria_activity extends award_criteria {
if (!empty($moduledata)) {
$extraon = implode(' OR ', $moduledata);
$join = " JOIN {course_modules_completion} cmc ON cmc.userid = u.id AND
( cmc.completionstate = :completionpass OR cmc.completionstate = :completioncomplete ) AND ({$extraon})";
( cmc.completionstate = :completionfail OR
cmc.completionstate = :completionpass OR
cmc.completionstate = :completioncomplete ) AND ({$extraon})";
$params["completionpass"] = COMPLETION_COMPLETE_PASS;
$params["completionfail"] = COMPLETION_COMPLETE_FAIL;
$params["completioncomplete"] = COMPLETION_COMPLETE;
}
return array($join, $where, $params);
@@ -259,10 +262,12 @@ class award_criteria_activity extends award_criteria {
cmc{$param['module']}.userid = u.id AND
cmc{$param['module']}.coursemoduleid = :completedmodule{$param['module']} AND
( cmc{$param['module']}.completionstate = :completionpass{$param['module']} OR
cmc{$param['module']}.completionstate = :completionfail{$param['module']} OR
cmc{$param['module']}.completionstate = :completioncomplete{$param['module']} )";
$where .= " AND cmc{$param['module']}.coursemoduleid IS NOT NULL ";
$params["completedmodule{$param['module']}"] = $param['module'];
$params["completionpass{$param['module']}"] = COMPLETION_COMPLETE_PASS;
$params["completionfail{$param['module']}"] = COMPLETION_COMPLETE_FAIL;
$params["completioncomplete{$param['module']}"] = COMPLETION_COMPLETE;
}
return array($join, $where, $params);
+2 -2
View File
@@ -202,8 +202,8 @@ class award_criteria_profile extends award_criteria {
$join .= " LEFT JOIN {user_info_data} uid{$idx} ON uid{$idx}.userid = u.id AND uid{$idx}.fieldid = :fieldid{$idx} ";
$sqlparams["fieldid{$idx}"] = $param['field'];
$whereparts[] = "uid{$idx}.id IS NOT NULL";
} else {
// This is a field from {user} table.
} else if (in_array($param['field'], $this->allowed_default_fields)) {
// This is a valid field from {user} table.
if ($param['field'] == 'picture') {
// The picture field is numeric and requires special handling.
$whereparts[] = "u.{$param['field']} != 0";
+56 -4
View File
@@ -8,6 +8,7 @@ Feature: Award badges based on activity completion
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 1 | student2@example.com |
| teacher1 | Teacher | 1 | teacher1@example.com |
And the following "courses" exist:
| fullname | shortname | category | enablecompletion |
@@ -16,6 +17,7 @@ Feature: Award badges based on activity completion
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
| student2 | C1 | student |
And the following config values are set as admin:
| grade_item_advanced | hiddenuntil |
And the following "question categories" exist:
@@ -33,6 +35,9 @@ Feature: Award badges based on activity completion
And user "student1" has attempted "Test quiz name" with responses:
| slot | response |
| 1 | False |
And user "student2" has attempted "Test quiz name" with responses:
| slot | response |
| 1 | False |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Badges > Add a new badge" in current page administration
@@ -42,6 +47,12 @@ Feature: Award badges based on activity completion
| Description | Course badge description |
And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
And I press "Create badge"
Scenario: Student earns a badge using activity completion, but does not get passing grade
Given I am on the "Course 1" course page logged in as teacher1
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I follow "Criteria"
And I set the field "type" to "Activity completion"
And I set the field "Quiz - Test quiz name" to "1"
And I press "Save"
@@ -49,10 +60,7 @@ Feature: Award badges based on activity completion
And I press "Continue"
And I should see "Recipients (0)"
And I log out
Scenario: Student earns a badge using activity completion, but does not get passing grade
Given I log in as "student1"
And I am on "Course 1" course homepage
And I am on the "Course 1" course page logged in as student1
And the "Receive a grade" completion condition of "Test quiz name" is displayed as "failed"
And the "Receive a pass grade or complete all available attempts" completion condition of "Test quiz name" is displayed as "todo"
When I am on the "Test quiz name" "quiz activity" page
@@ -67,3 +75,47 @@ Feature: Award badges based on activity completion
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
Then I should see "Recipients (1)"
Scenario Outline: Previously graded pass/fail students should earn a badge after enabling a badge
Given I am on the "Course 1" course page logged in as teacher1
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
And I follow "Criteria"
And I set the field "type" to "Activity completion"
And I click on "Expand all" "link"
And I set the field "Quiz - Test quiz name" to "1"
And I set the field "<aggregationcriteria>" to "1"
And I press "Save"
# Fail grade with student2
And I am on the "Course 1" course page logged in as student2
And I am on the "Test quiz name" "quiz activity" page
And I press "Re-attempt quiz"
And I set the field "False" to "1"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
And I log out
# Pass grade with student1
And I am on the "Course 1" course page logged in as student1
And I am on the "Test quiz name" "quiz activity" page
And I press "Re-attempt quiz"
And I set the field "False" to "0"
And I press "Finish attempt ..."
And I press "Submit all and finish"
And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
And I log out
# Enable badge access once all students have completed an activity.
And I am on the "Course 1" course page logged in as teacher1
And I navigate to "Badges > Manage badges" in current page administration
And I follow "Course Badge"
When I press "Enable access"
And I press "Continue"
Then I should see "Recipients (2)"
Examples:
| aggregationcriteria |
| Any of the selected activities is complete |
| All of the selected activities are complete |
+8 -6
View File
@@ -401,6 +401,12 @@ Feature: Award badges based on cohort
| user1 | First | User | first@example.com |
| user2 | Second | User | second@example.com |
| user3 | Third | User | third@example.com |
And the following "cohort members" exist:
| user | cohort |
| user1 | CH1 |
| user1 | CH2 |
| user2 | CH2 |
| user2 | CH3 |
And I log in as "admin"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
@@ -415,7 +421,7 @@ Feature: Award badges based on cohort
And I press "Save"
And I press "Enable access"
When I press "Continue"
And I should see "Recipients (0)"
And I should see "Recipients (1)"
And I navigate to "Badges > Add a new badge" in site administration
And I set the following fields to these values:
| Name | Site Badge 2 |
@@ -429,11 +435,7 @@ Feature: Award badges based on cohort
And I press "Save"
And I press "Enable access"
And I press "Continue"
Then I navigate to "Users > Accounts >Cohorts" in site administration
And I add "First User (first@example.com)" user to "CH1" cohort members
And I add "First User (first@example.com)" user to "CH2" cohort members
And I add "Second User (second@example.com)" user to "CH2" cohort members
And I add "Second User (second@example.com)" user to "CH3" cohort members
And I should see "Recipients (1)"
And I log out
And I log in as "user1"
And I follow "Profile" in the user menu
@@ -35,7 +35,7 @@ $string['aria:coursesummary'] = 'Course summary text:';
$string['aria:courseprogress'] = 'Course progress:';
$string['aria:customfield'] = 'Show {$a} courses';
$string['aria:displaydropdown'] = 'Display drop-down menu';
$string['aria:favourites'] = 'Show starred courses';
$string['aria:favourites'] = 'Show starred courses only';
$string['aria:future'] = 'Show future courses';
$string['aria:groupingdropdown'] = 'Grouping drop-down menu';
$string['aria:inprogress'] = 'Show courses in progress';
@@ -35,6 +35,35 @@ Feature: Displaying the link to the Participants page
And "Student One" "link" should exist
And "Student Two" "link" should not exist
@javascript
Scenario: Course participants link is displayed to users depending on role permissions settings
And I log in as "admin"
And I am on "Course1" course homepage with editing mode on
And I add a "Forum" to section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I navigate to "Users > Enrolment methods" in current page administration
And I click on "Edit" "link" in the "Guest access" "table_row"
And I set the following fields to these values:
| Allow guest access | Yes |
And I press "Save changes"
And I log out
When I log in as "guest"
And I am on "Course1" course homepage
Then I should not see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should not see "Participants" in the "Navigation" "block"
And I log out
And I log in as "admin"
And I set the following system permissions of "Guest" role:
| capability | permission |
| moodle/course:viewparticipants | Allow |
And I log in as "guest"
And I am on "Course1" course homepage
And I should see "Participants" in the "Navigation" "block"
And I am on the "Test forum name" "forum activity" page
And I should see "Participants" in the "Navigation" "block"
Scenario: Site participants link is displayed to admins
When I log in as "admin"
Then "Participants" "link" should exist in the "Navigation" "block"
+6
View File
@@ -101,6 +101,12 @@ function xmldb_block_tag_youtube_upgrade($oldversion) {
// If the block uses a legacy category name, update it to use the current category ID instead.
foreach ($blockinstances as $blockinstance) {
$blockconfig = unserialize(base64_decode($blockinstance->configdata));
// Skip if the block does not have a specific category set.
if (!isset($blockconfig->category)) {
continue;
}
$blockcategoryconfig = $blockconfig->category;
// The block is using a legacy category name as a category config.
if (array_key_exists($blockcategoryconfig, $categorynamemap)) {
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -58,7 +58,7 @@ function(
LOADING_ICON: 'core/loading'
};
var COURSE_CLASSIFICATION = 'inprogress';
var COURSE_CLASSIFICATION = 'all';
var COURSE_SORT = 'fullname asc';
var COURSE_EVENT_LIMIT = 5;
var COURSE_LIMIT = 2;
@@ -66,10 +66,10 @@ Feature: The timeline block allows users to see upcoming courses
And I should see "Test feedback 2 closes" in the "Timeline" "block"
And I should see "Test feedback 3 closes" in the "Timeline" "block"
And I should see "Test assign 1 is due" in the "Timeline" "block"
And I should not see "More courses" in the "Timeline" "block"
And I should not see "Course 4" in the "Timeline" "block"
And I should see "More courses" in the "Timeline" "block"
And I should see "Course 4" in the "Timeline" "block"
And I should not see "Test choice 2 closes" in the "Timeline" "block"
And I should not see "Test feedback 4 closes" in the "Timeline" "block"
And I should see "Test feedback 4 closes" in the "Timeline" "block"
Scenario: Persistent sort filter
Given I log in as "student1"
@@ -107,10 +107,10 @@ Feature: The timeline block allows users to see upcoming courses
And I should see "Test feedback 2 closes" in the "Timeline" "block"
And I should see "Test feedback 3 closes" in the "Timeline" "block"
And I should see "Test assign 1 is due" in the "Timeline" "block"
And I should not see "More courses" in the "Timeline" "block"
And I should not see "Course 4" in the "Timeline" "block"
And I should see "More courses" in the "Timeline" "block"
And I should see "Course 4" in the "Timeline" "block"
And I should not see "Test choice 2 closes" in the "Timeline" "block"
And I should not see "Test feedback 4 closes" in the "Timeline" "block"
And I should see "Test feedback 4 closes" in the "Timeline" "block"
Scenario: Current filtering always applies in courses view
Given I log in as "student1"
+1 -1
View File
@@ -466,7 +466,7 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
*/
protected function prep_data_after_read($data) {
$result = @unserialize($data);
if ($result === false) {
if ($result === false && $data != serialize(false)) {
throw new coding_exception('Failed to unserialise data from file. Either failed to read, or failed to write.');
}
return $result;
@@ -139,6 +139,13 @@ class managesubscriptions extends \moodleform {
$errors['url'] = get_string('errorrequiredurlorfile', 'calendar');
}
// Validate course/category event types (ensure appropriate field is also filled in).
if ($eventtype === 'course' && empty($data['courseid'])) {
$errors['courseid'] = get_string('selectacourse');
} else if ($eventtype === 'category' && empty($data['categoryid'])) {
$errors['categoryid'] = get_string('required');
}
return $errors;
}
+75 -9
View File
@@ -662,15 +662,13 @@ abstract class format_base {
'format' => $this->format,
'sectionid' => $sectionid
), '', 'id,name,value');
$indexedrecords = [];
foreach ($records as $record) {
if (array_key_exists($record->name, $this->formatoptions[$sectionid])) {
$value = $record->value;
if ($value !== null && isset($options[$record->name]['type'])) {
// this will convert string value to number if needed
$value = clean_param($value, $options[$record->name]['type']);
}
$this->formatoptions[$sectionid][$record->name] = $value;
}
$indexedrecords[$record->name] = $record->value;
}
foreach ($options as $optionname => $option) {
contract_value($this->formatoptions[$sectionid], $indexedrecords, $option, $optionname);
}
}
}
@@ -765,7 +763,7 @@ abstract class format_base {
$data = array_intersect_key($rawdata, $allformatoptions);
foreach ($data as $key => $value) {
$option = $allformatoptions[$key] + ['type' => PARAM_RAW, 'element_type' => null, 'element_attributes' => [[]]];
$data[$key] = clean_param($value, $option['type']);
expand_value($data, $data, $option, $key);
if ($option['element_type'] === 'select' && !array_key_exists($data[$key], $option['element_attributes'][0])) {
// Value invalid for select element, skip.
unset($data[$key]);
@@ -814,6 +812,7 @@ abstract class format_base {
if (array_key_exists('default', $option)) {
$defaultoptions[$key] = $option['default'];
}
expand_value($defaultoptions, $defaultoptions, $option, $key);
$cached[$key] = ($sectionid === 0 || !empty($option['cache']));
}
$records = $DB->get_records('course_format_options',
@@ -1400,3 +1399,70 @@ class format_site extends format_base {
return true;
}
}
/**
* 'Converts' a value from what is stored in the database into what is used by edit forms.
*
* @param array $dest The destination array
* @param array $source The source array
* @param array $option The definition structure of the option.
* @param string $optionname The name of the option, as provided in the definition.
* @author Jason den Dulk
*/
function contract_value(array &$dest, array $source, array $option, string $optionname) : void {
if (substr($optionname, -7) == '_editor') { // Suffix '_editor' indicates that the element is an editor.
$name = substr($optionname, 0, -7);
if (isset($source[$name])) {
$dest[$optionname] = [
'text' => clean_param_if_not_null($source[$name], $option['type'] ?? PARAM_RAW),
'format' => clean_param_if_not_null($source[$name . 'format'], PARAM_INT),
];
}
} else {
if (isset($source[$optionname])) {
$dest[$optionname] = clean_param_if_not_null($source[$optionname], $option['type'] ?? PARAM_RAW);
}
}
}
/**
* Cleans the given param, unless it is null.
*
* @param mixed $param The variable we are cleaning.
* @param string $type Expected format of param after cleaning.
* @return mixed Null if $param is null, otherwise the cleaned value.
* @throws coding_exception
* @author Jason den Dulk
*/
function clean_param_if_not_null($param, string $type = PARAM_RAW) {
if ($param === null) {
return null;
} else {
return clean_param($param, $type);
}
}
/**
* 'Converts' a value from what is used in edit forms into a value(s) to be stored in the database.
*
* @param array $dest The destination array
* @param array $source The source array
* @param array $option The definition structure of the option.
* @param string $optionname The name of the option, as provided in the definition.
* @author Jason den Dulk
*/
function expand_value(array &$dest, array $source, array $option, string $optionname) : void {
if (substr($optionname, -7) == '_editor') { // Suffix '_editor' indicates that the element is an editor.
$name = substr($optionname, 0, -7);
if (is_string($source[$optionname])) {
$dest[$name] = clean_param($source[$optionname], $option['type'] ?? PARAM_RAW);
$dest[$name.'format'] = 1;
} else {
$dest[$name] = clean_param($source[$optionname]['text'], $option['type'] ?? PARAM_RAW);
$dest[$name.'format'] = clean_param($source[$optionname]['format'], PARAM_INT);
}
unset($dest[$optionname]);
} else {
$dest[$optionname] = clean_param($source[$optionname], $option['type'] ?? PARAM_RAW);
}
}
+3 -167
View File
@@ -388,171 +388,7 @@ function course_integrity_check($courseid, $rawmods = null, $sections = null, $f
* Each item in the array contains he following properties:
*/
function get_array_of_activities($courseid) {
// cm - course module id
// mod - name of the module (eg forum)
// section - the number of the section (eg week or topic)
// name - the name of the instance
// visible - is the instance visible or not
// groupingid - grouping id
// extra - contains extra string to include in any link
global $CFG, $DB;
$course = $DB->get_record('course', array('id'=>$courseid));
if (empty($course)) {
throw new moodle_exception('courseidnotfound');
}
$mod = array();
$rawmods = get_course_mods($courseid);
if (empty($rawmods)) {
return $mod; // always return array
}
$courseformat = course_get_format($course);
if ($sections = $DB->get_records('course_sections', array('course' => $courseid),
'section ASC', 'id,section,sequence,visible')) {
// First check and correct obvious mismatches between course_sections.sequence and course_modules.section.
if ($errormessages = course_integrity_check($courseid, $rawmods, $sections)) {
debugging(join('<br>', $errormessages));
$rawmods = get_course_mods($courseid);
$sections = $DB->get_records('course_sections', array('course' => $courseid),
'section ASC', 'id,section,sequence,visible');
}
// Build array of activities.
foreach ($sections as $section) {
if (!empty($section->sequence)) {
$sequence = explode(",", $section->sequence);
foreach ($sequence as $seq) {
if (empty($rawmods[$seq])) {
continue;
}
// Adjust visibleoncoursepage, value in DB may not respect format availability.
$rawmods[$seq]->visibleoncoursepage = (!$rawmods[$seq]->visible
|| $rawmods[$seq]->visibleoncoursepage
|| empty($CFG->allowstealth)
|| !$courseformat->allow_stealth_module_visibility($rawmods[$seq], $section)) ? 1 : 0;
// Create an object that will be cached.
$mod[$seq] = new stdClass();
$mod[$seq]->id = $rawmods[$seq]->instance;
$mod[$seq]->cm = $rawmods[$seq]->id;
$mod[$seq]->mod = $rawmods[$seq]->modname;
// Oh dear. Inconsistent names left here for backward compatibility.
$mod[$seq]->section = $section->section;
$mod[$seq]->sectionid = $rawmods[$seq]->section;
$mod[$seq]->module = $rawmods[$seq]->module;
$mod[$seq]->added = $rawmods[$seq]->added;
$mod[$seq]->score = $rawmods[$seq]->score;
$mod[$seq]->idnumber = $rawmods[$seq]->idnumber;
$mod[$seq]->visible = $rawmods[$seq]->visible;
$mod[$seq]->visibleoncoursepage = $rawmods[$seq]->visibleoncoursepage;
$mod[$seq]->visibleold = $rawmods[$seq]->visibleold;
$mod[$seq]->groupmode = $rawmods[$seq]->groupmode;
$mod[$seq]->groupingid = $rawmods[$seq]->groupingid;
$mod[$seq]->indent = $rawmods[$seq]->indent;
$mod[$seq]->completion = $rawmods[$seq]->completion;
$mod[$seq]->extra = "";
$mod[$seq]->completiongradeitemnumber =
$rawmods[$seq]->completiongradeitemnumber;
$mod[$seq]->completionview = $rawmods[$seq]->completionview;
$mod[$seq]->completionexpected = $rawmods[$seq]->completionexpected;
$mod[$seq]->showdescription = $rawmods[$seq]->showdescription;
$mod[$seq]->availability = $rawmods[$seq]->availability;
$mod[$seq]->deletioninprogress = $rawmods[$seq]->deletioninprogress;
$modname = $mod[$seq]->mod;
$functionname = $modname."_get_coursemodule_info";
if (!file_exists("$CFG->dirroot/mod/$modname/lib.php")) {
continue;
}
include_once("$CFG->dirroot/mod/$modname/lib.php");
if ($hasfunction = function_exists($functionname)) {
if ($info = $functionname($rawmods[$seq])) {
if (!empty($info->icon)) {
$mod[$seq]->icon = $info->icon;
}
if (!empty($info->iconcomponent)) {
$mod[$seq]->iconcomponent = $info->iconcomponent;
}
if (!empty($info->name)) {
$mod[$seq]->name = $info->name;
}
if ($info instanceof cached_cm_info) {
// When using cached_cm_info you can include three new fields
// that aren't available for legacy code
if (!empty($info->content)) {
$mod[$seq]->content = $info->content;
}
if (!empty($info->extraclasses)) {
$mod[$seq]->extraclasses = $info->extraclasses;
}
if (!empty($info->iconurl)) {
// Convert URL to string as it's easier to store. Also serialized object contains \0 byte and can not be written to Postgres DB.
$url = new moodle_url($info->iconurl);
$mod[$seq]->iconurl = $url->out(false);
}
if (!empty($info->onclick)) {
$mod[$seq]->onclick = $info->onclick;
}
if (!empty($info->customdata)) {
$mod[$seq]->customdata = $info->customdata;
}
} else {
// When using a stdclass, the (horrible) deprecated ->extra field
// is available for BC
if (!empty($info->extra)) {
$mod[$seq]->extra = $info->extra;
}
}
}
}
// When there is no modname_get_coursemodule_info function,
// but showdescriptions is enabled, then we use the 'intro'
// and 'introformat' fields in the module table
if (!$hasfunction && $rawmods[$seq]->showdescription) {
if ($modvalues = $DB->get_record($rawmods[$seq]->modname,
array('id' => $rawmods[$seq]->instance), 'name, intro, introformat')) {
// Set content from intro and introformat. Filters are disabled
// because we filter it with format_text at display time
$mod[$seq]->content = format_module_intro($rawmods[$seq]->modname,
$modvalues, $rawmods[$seq]->id, false);
// To save making another query just below, put name in here
$mod[$seq]->name = $modvalues->name;
}
}
if (!isset($mod[$seq]->name)) {
$mod[$seq]->name = $DB->get_field($rawmods[$seq]->modname, "name", array("id"=>$rawmods[$seq]->instance));
}
// Minimise the database size by unsetting default options when they are
// 'empty'. This list corresponds to code in the cm_info constructor.
foreach (array('idnumber', 'groupmode', 'groupingid',
'indent', 'completion', 'extra', 'extraclasses', 'iconurl', 'onclick', 'content',
'icon', 'iconcomponent', 'customdata', 'availability', 'completionview',
'completionexpected', 'score', 'showdescription', 'deletioninprogress') as $property) {
if (property_exists($mod[$seq], $property) &&
empty($mod[$seq]->{$property})) {
unset($mod[$seq]->{$property});
}
}
// Special case: this value is usually set to null, but may be 0
if (property_exists($mod[$seq], 'completiongradeitemnumber') &&
is_null($mod[$seq]->completiongradeitemnumber)) {
unset($mod[$seq]->completiongradeitemnumber);
}
}
}
}
}
return $mod;
return course_modinfo::get_array_of_activities(get_course($courseid));
}
/**
@@ -1378,12 +1214,12 @@ function move_section_to($course, $section, $destination, $ignorenumsections = f
// uniqueness constraint
$transaction = $DB->start_delegated_transaction();
foreach ($movedsections as $id => $position) {
if ($sections[$id] !== $position) {
if ((int) $sections[$id] !== $position) {
$DB->set_field('course_sections', 'section', -$position, array('id' => $id));
}
}
foreach ($movedsections as $id => $position) {
if ($sections[$id] !== $position) {
if ((int) $sections[$id] !== $position) {
$DB->set_field('course_sections', 'section', $position, array('id' => $id));
}
}
+1 -1
View File
@@ -1699,7 +1699,7 @@ class core_course_renderer extends plugin_renderer_base {
// Only show the collapse/expand if there are children to expand.
$content .= html_writer::start_tag('div', array('class' => 'collapsible-actions'));
$content .= html_writer::link('#', $linkname, array('class' => implode(' ', $classes)));
$content .= html_writer::link('#', $linkname, array('class' => implode(' ', $classes), 'aria-expanded' => false));
$content .= html_writer::end_tag('div');
$this->page->requires->strings_for_js(array('collapseall', 'expandall'), 'moodle');
}
+45
View File
@@ -26,6 +26,7 @@ global $CFG;
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
require_once($CFG->dirroot . '/course/tests/fixtures/format_theunittest.php');
/**
* Course restore testcase.
@@ -534,4 +535,48 @@ class restore_test extends \advanced_testcase {
$this->assertEquals($chat2->chattime, $restoredchat2->chattime);
$this->assertEquals($c2->startdate + 1 * WEEKSECS, $restoredchat2->chattime);
}
/**
* Tests course restore with editor in course format.
*
* @author Matthew Hilton
*/
public function test_restore_editor_courseformat() {
$this->resetAfterTest();
// Setup user with restore permissions.
$dg = $this->getDataGenerator();
$u1 = $dg->create_user();
$managers = get_archetype_roles('manager');
$manager = array_shift($managers);
$dg->role_assign($manager->id, $u1->id);
// Create a course with an editor item in the course format.
$courseformatoptiondata = (object) [
"hideoddsections" => 1,
'summary_editor' => [
'text' => '<p>Somewhere over the rainbow</p><p>The <b>quick</b> brown fox jumpos over the lazy dog.</p>',
'format' => 1
]
];
$course1 = $dg->create_course(['format' => 'theunittest']);
$course2 = $dg->create_course(['format' => 'theunittest']);
$this->assertEquals('theunittest', $course1->format);
course_create_sections_if_missing($course1, array(0, 1));
// Set the course format.
$courseformat = course_get_format($course1);
$courseformat->update_course_format_options($courseformatoptiondata);
// Backup and restore the course.
$backupid = $this->backup_course($course1->id);
$this->restore_to_existing_course($backupid, $course2->id, $u1->id);
// Get the restored course format.
$restoredformat = course_get_format($course2);
$restoredformatoptions = $restoredformat->get_format_options();
$this->assertEqualsCanonicalizing($courseformatoptiondata, (object) $restoredformatoptions);
}
}
@@ -0,0 +1,49 @@
@core @core_course
Feature: Report navigation
As a teacher
I will be redirected to the first report page on the navigation if I can't access to other reports.
Background:
Given the following "users" exist:
| username |
| teacher |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
Scenario: The teacher will be redirected to the first report page if they can't access to most recently report
Given I am on the "C1" "Course" page logged in as "teacher"
When I navigate to "Reports > Logs" in current page administration
Then I should see "Choose which logs you want to see"
When I click on "Reports" "link"
Then I should see "Choose which logs you want to see"
When the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| report/log:view | Prohibit | editingteacher | System | |
And I click on "Reports" "link"
Then I should see "Competency breakdown"
And I should not see "Sorry, but you do not currently have permissions to do that"
Scenario: If capability Log view is unset, the teacher will be redirected to the first valid report page
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| report/log:view | Prohibit | editingteacher | System | |
When I am on the "C1" "Course" page logged in as "teacher"
And I navigate to "Reports" in current page administration
Then I should see "Competency breakdown"
And I should not see "Sorry, but you do not currently have permissions to do that"
Scenario: A warning message will be shown if the user cannot access any report page
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| report/log:view | Prohibit | editingteacher | System | |
| report/loglive:view | Prohibit | editingteacher | System | |
| report/outline:view | Prohibit | editingteacher | System | |
| report/participation:view | Prohibit | editingteacher | System | |
| moodle/competency:coursecompetencyview | Prohibit | editingteacher | System | |
When I am on the "C1" "Course" page logged in as "teacher"
And I navigate to "Reports" in current page administration
Then I should see "No reports accessible"
@@ -0,0 +1,92 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_course;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/course/tests/fixtures/format_theunittest.php');
require_once($CFG->dirroot . '/course/format/lib.php');
/**
* Course related unit tests
*
* @package core_course
* @copyright 2021 Catalyst IT Pty Ltd
* @author Jason den Dulk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_format_function_test extends \basic_testcase {
public function test_clean_param_if_not_null() {
$this->assertNull(clean_param_if_not_null(null));
$n = '3x';
$this->assertEquals(clean_param($n, PARAM_INT), clean_param_if_not_null($n, PARAM_INT));
$this->assertEquals(clean_param($n, PARAM_RAW), clean_param_if_not_null($n, PARAM_RAW));
$this->assertEquals(clean_param($n, PARAM_ALPHANUM), clean_param_if_not_null($n, PARAM_ALPHANUM));
$this->assertEquals(clean_param($n, PARAM_ALPHA), clean_param_if_not_null($n, PARAM_ALPHA));
$s = '<abc>xyz</abc>';
$this->assertEquals(clean_param($s, PARAM_ALPHANUM), clean_param_if_not_null($s, PARAM_ALPHANUM));
$this->assertEquals(clean_param($s, PARAM_RAW), clean_param_if_not_null($s, PARAM_RAW));
}
public function test_contract_value() {
$input = [
'abc' => '<p>All together Now</p>',
'abcformat' => '1',
'jolly' => 'Roger'
];
$expected = [
'abc_editor' => [ 'text' => $input['abc'], 'format' => $input['abcformat'] ],
'jolly' => $input['jolly'],
];
$defs = [
'abc_editor' => [],
'jolly' => [ 'type' => PARAM_ALPHA ],
];
$dest = [];
foreach ($defs as $name => $def) {
contract_value($dest, $input, $def, $name);
}
$this->assertEquals($expected, $dest);
}
public function test_expand_value() {
$input = [
'abc_editor' => [ 'text' => '<p>All together Now</p>', 'format' => '1' ],
'jolly' => 'Roger',
];
$expected = [
'abc' => $input['abc_editor']['text'],
'abcformat' => $input['abc_editor']['format'],
'jolly' => $input['jolly'],
];
$defs = [
'abc_editor' => [],
'jolly' => [ 'type' => PARAM_ALPHA ],
];
$dest = [];
foreach ($defs as $name => $def) {
expand_value($dest, $input, $def, $name);
}
$this->assertEquals($expected, $dest);
}
}
+29
View File
@@ -29,6 +29,35 @@ require_once($CFG->dirroot . '/course/lib.php');
require_once($CFG->dirroot . '/course/tests/fixtures/format_theunittest.php');
class core_course_courseformat_testcase extends advanced_testcase {
/**
* Tests the save and load functionality.
*
* @author Jason den Dulk
*/
public function test_courseformat_saveandload() {
$this->resetAfterTest();
$courseformatoptiondata = (object) [
"hideoddsections" => 1,
'summary_editor' => [
'text' => '<p>Somewhere over the rainbow</p><p>The <b>quick</b> brown fox jumpos over the lazy dog.</p>',
'format' => 1
]
];
$generator = $this->getDataGenerator();
$course1 = $generator->create_course(array('format' => 'theunittest'));
$this->assertEquals('theunittest', $course1->format);
course_create_sections_if_missing($course1, array(0, 1));
$courseformat = course_get_format($course1);
$courseformat->update_course_format_options($courseformatoptiondata);
$savedcourseformatoptiondata = $courseformat->get_format_options();
$this->assertEqualsCanonicalizing($courseformatoptiondata, (object) $savedcourseformatoptiondata);
}
public function test_available_hook() {
global $DB;
$this->resetAfterTest();
+28
View File
@@ -996,6 +996,34 @@ class core_course_courselib_testcase extends advanced_testcase {
$this->assertEquals(3, $course->marker);
}
/**
* Test move_section_to method.
* Make sure that we only update the moving sections, not all the sections in the current course.
*
* @return void
*/
public function test_move_section_to() {
global $DB, $CFG;
$this->resetAfterTest();
$this->setAdminUser();
// Generate the course and pre-requisite module.
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 3], ['createsections' => true]);
ob_start();
$DB->set_debug(true);
// Move section.
move_section_to($course, 2, 3);
$DB->set_debug(false);
$debuginfo = ob_get_contents();
ob_end_clean();
$sectionmovequerycount = substr_count($debuginfo, 'UPDATE ' . $CFG->phpunit_prefix . 'course_sections SET');
// We are updating the course_section table in steps to avoid breaking database uniqueness constraint.
// So the queries will be doubled. See: course/lib.php:1423
// Make sure that we only need 4 queries to update the position of section 2 and section 3.
$this->assertEquals(4, $sectionmovequerycount);
}
public function test_course_can_delete_section() {
global $DB;
$this->resetAfterTest(true);
+9 -1
View File
@@ -41,6 +41,10 @@ class format_theunittest extends format_base {
'default' => 0,
'type' => PARAM_INT,
),
'summary_editor' => array(
'default' => '',
'type' => PARAM_RAW,
),
);
}
if ($foreditform && !isset($courseformatoptions['hideoddsections']['label'])) {
@@ -55,6 +59,10 @@ class format_theunittest extends format_base {
'element_type' => 'select',
'element_attributes' => array($sectionmenu),
),
'summary_editor' => array(
'label' => 'Summary Text',
'element_type' => 'editor',
),
);
$courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit);
}
@@ -78,4 +86,4 @@ class format_theunittest extends format_base {
}
}
}
}
}
@@ -7,14 +7,15 @@ var FORMATCHOOSER = function() {
Y.extend(FORMATCHOOSER, Y.Base, {
initializer: function(params) {
if (params && params.formid) {
var updatebut = Y.one('#' + params.formid + ' #id_updatecourseformat');
var formatselect = Y.one('#' + params.formid + ' #id_format');
var form = Y.one('#' + params.formid);
var updatebut = form.one('#id_updatecourseformat');
var formatselect = form.one('#id_format');
var ancestor = updatebut.ancestor('fieldset');
var action = Y.one('form.mform').get('action');
var action = form.get('action');
if (updatebut && formatselect) {
updatebut.setStyle('display', 'none');
formatselect.on('change', function() {
Y.one('form.mform').set('action', action + '#' + ancestor.get('id'));
form.set('action', action + '#' + ancestor.get('id'));
updatebut.simulate('click');
});
}
@@ -1 +1 @@
YUI.add("moodle-course-formatchooser",function(t,o){var e=function(){e.superclass.constructor.apply(this,arguments)};t.extend(e,t.Base,{initializer:function(o){var e,n,r;o&&o.formid&&(e=t.one("#"+o.formid+" #id_updatecourseformat"),o=t.one("#"+o.formid+" #id_format"),n=e.ancestor("fieldset"),r=t.one("form.mform").get("action"),e&&o&&(e.setStyle("display","none"),o.on("change",function(){t.one("form.mform").set("action",r+"#"+n.get("id")),e.simulate("click")})))}}),M.course=M.course||{},M.course.init_formatchooser=function(o){return new e(o)}},"@VERSION@",{requires:["base","node","node-event-simulate"]});
YUI.add("moodle-course-formatchooser",function(r,e){var o=function(){o.superclass.constructor.apply(this,arguments)};r.extend(o,r.Base,{initializer:function(e){var o,n,t,i;e&&e.formid&&(o=r.one("#"+e.formid),n=o.one("#id_updatecourseformat"),e=o.one("#id_format"),t=n.ancestor("fieldset"),i=o.get("action"),n&&e&&(n.setStyle("display","none"),e.on("change",function(){o.set("action",i+"#"+t.get("id")),n.simulate("click")})))}}),M.course=M.course||{},M.course.init_formatchooser=function(e){return new o(e)}},"@VERSION@",{requires:["base","node","node-event-simulate"]});
@@ -7,14 +7,15 @@ var FORMATCHOOSER = function() {
Y.extend(FORMATCHOOSER, Y.Base, {
initializer: function(params) {
if (params && params.formid) {
var updatebut = Y.one('#' + params.formid + ' #id_updatecourseformat');
var formatselect = Y.one('#' + params.formid + ' #id_format');
var form = Y.one('#' + params.formid);
var updatebut = form.one('#id_updatecourseformat');
var formatselect = form.one('#id_format');
var ancestor = updatebut.ancestor('fieldset');
var action = Y.one('form.mform').get('action');
var action = form.get('action');
if (updatebut && formatselect) {
updatebut.setStyle('display', 'none');
formatselect.on('change', function() {
Y.one('form.mform').set('action', action + '#' + ancestor.get('id'));
form.set('action', action + '#' + ancestor.get('id'));
updatebut.simulate('click');
});
}
+5 -4
View File
@@ -5,14 +5,15 @@ var FORMATCHOOSER = function() {
Y.extend(FORMATCHOOSER, Y.Base, {
initializer: function(params) {
if (params && params.formid) {
var updatebut = Y.one('#' + params.formid + ' #id_updatecourseformat');
var formatselect = Y.one('#' + params.formid + ' #id_format');
var form = Y.one('#' + params.formid);
var updatebut = form.one('#id_updatecourseformat');
var formatselect = form.one('#id_format');
var ancestor = updatebut.ancestor('fieldset');
var action = Y.one('form.mform').get('action');
var action = form.get('action');
if (updatebut && formatselect) {
updatebut.setStyle('display', 'none');
formatselect.on('change', function() {
Y.one('form.mform').set('action', action + '#' + ancestor.get('id'));
form.set('action', action + '#' + ancestor.get('id'));
updatebut.simulate('click');
});
}
+12
View File
@@ -36,6 +36,18 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lib_test extends \advanced_testcase {
public static function tearDownAfterClass(): void {
global $DB;
// Apply sqlsrv native driver error and logging default
// settings while finishing the AdoDB tests.
if ($DB->get_dbfamily() === 'mssql') {
sqlsrv_configure("WarningsReturnAsErrors", false);
sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_OFF);
sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ERROR);
}
}
/**
* Test for getting user enrolment actions.
*/
+11
View File
@@ -35,6 +35,17 @@ class sync_test extends \advanced_testcase {
/** @var string Original error log */
protected $oldlog;
public static function tearDownAfterClass(): void {
global $DB;
// Apply sqlsrv native driver error and logging default
// settings while finishing the AdoDB tests.
if ($DB->get_dbfamily() === 'mssql') {
sqlsrv_configure("WarningsReturnAsErrors", false);
sqlsrv_configure("LogSubsystems", SQLSRV_LOG_SYSTEM_OFF);
sqlsrv_configure("LogSeverity", SQLSRV_LOG_SEVERITY_ERROR);
}
}
protected function init_enrol_database() {
global $DB, $CFG;
+27 -11
View File
@@ -1782,9 +1782,10 @@ class grade_report_grader extends grade_report {
*/
protected static function filter_collapsed_categories($courseid, $collapsed) {
global $DB;
if (empty($collapsed)) {
$collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
}
// Ensure we always have an element for aggregatesonly and another for gradesonly, no matter it's empty.
$collapsed['aggregatesonly'] = $collapsed['aggregatesonly'] ?? [];
$collapsed['gradesonly'] = $collapsed['gradesonly'] ?? [];
if (empty($collapsed['aggregatesonly']) && empty($collapsed['gradesonly'])) {
return $collapsed;
}
@@ -1805,12 +1806,23 @@ class grade_report_grader extends grade_report {
*/
protected static function get_collapsed_preferences($courseid) {
if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories'.$courseid)) {
return json_decode($collapsed, true);
$collapsed = json_decode($collapsed, true);
// Ensure we always have an element for aggregatesonly and another for gradesonly, no matter it's empty.
$collapsed['aggregatesonly'] = $collapsed['aggregatesonly'] ?? [];
$collapsed['gradesonly'] = $collapsed['gradesonly'] ?? [];
return $collapsed;
}
// Try looking for old location of user setting that used to store all courses in one serialized user preference.
$collapsed = ['aggregatesonly' => [], 'gradesonly' => []]; // Use this if old settings are not found.
$collapsedall = [];
$oldprefexists = false;
if (($oldcollapsedpref = get_user_preferences('grade_report_grader_collapsed_categories')) !== null) {
$oldprefexists = true;
if ($collapsedall = unserialize_array($oldcollapsedpref)) {
// Ensure we always have an element for aggregatesonly and another for gradesonly, no matter it's empty.
$collapsedall['aggregatesonly'] = $collapsedall['aggregatesonly'] ?? [];
$collapsedall['gradesonly'] = $collapsedall['gradesonly'] ?? [];
// We found the old-style preference, filter out only categories that belong to this course and update the prefs.
$collapsed = static::filter_collapsed_categories($courseid, $collapsedall);
if (!empty($collapsed['aggregatesonly']) || !empty($collapsed['gradesonly'])) {
@@ -1819,17 +1831,21 @@ class grade_report_grader extends grade_report {
$collapsedall['gradesonly'] = array_diff($collapsedall['gradesonly'], $collapsed['gradesonly']);
if (!empty($collapsedall['aggregatesonly']) || !empty($collapsedall['gradesonly'])) {
set_user_preference('grade_report_grader_collapsed_categories', serialize($collapsedall));
} else {
unset_user_preference('grade_report_grader_collapsed_categories');
}
}
} else {
// We found the old-style preference, but it is unreadable, discard it.
unset_user_preference('grade_report_grader_collapsed_categories');
}
} else {
$collapsed = array('aggregatesonly' => array(), 'gradesonly' => array());
}
// Arrived here, if the old pref exists and it doesn't contain
// more information, it means that the migration of all the
// data to new, by course, preferences is completed, so
// the old one can be safely deleted.
if ($oldprefexists &&
empty($collapsedall['aggregatesonly']) &&
empty($collapsedall['gradesonly'])) {
unset_user_preference('grade_report_grader_collapsed_categories');
}
return $collapsed;
}
+6 -2
View File
@@ -119,6 +119,9 @@
*/
.path-grade-report-grader .gradeparent .avg .cell {
text-align: right;
max-width: 200px;
text-overflow: ellipsis;
overflow: hidden;
}
/**
* Content styling.
@@ -162,8 +165,9 @@
* Editing fields.
*/
.path-grade-report-grader .gradeparent select {
margin: 0;
padding: 0;
text-overflow: ellipsis;
min-width: 8rem;
width: 100%;
}
.path-grade-report-grader .gradeparent .text {
+220
View File
@@ -230,6 +230,226 @@ class core_grade_report_graderlib_testcase extends advanced_testcase {
$this->assertEquals(count($toobigvalue['gradesonly']) - 1, count($report1->collapsed['gradesonly']));
}
/**
* Test some special cases of the conversion from old preferences to new ones
*
* @covers \grade_report_grader::get_collapsed_preferences
* @covers \grade_report_grader::filter_collapsed_categories
*/
public function test_old_collapsed_preferences() {
$this->resetAfterTest(true);
$user1 = $this->getDataGenerator()->create_user();
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$course3 = $this->getDataGenerator()->create_course();
$course1cats = $course2cats = $course3cats = [];
for ($i = 0; $i < 10; $i++) {
$course1cats[] = $this->create_grade_category($course1)->id;
$course2cats[] = $this->create_grade_category($course2)->id;
$course3cats[] = $this->create_grade_category($course3)->id;
}
$report1 = $this->create_report($course1);
// Collapse all the cats in course1.
foreach ($course1cats as $catid) {
$report1->process_action('cg'. $catid, 'switch_minus');
}
// Expand all the cats in course2.
$report2 = $this->create_report($course2);
foreach ($course2cats as $catid) {
$report2->process_action('cg'.$catid, 'switch_minus');
$report2->process_action('cg'.$catid, 'switch_plus');
}
// Collapse odd cats and expand even cats in course3.
$report3 = $this->create_report($course3);
foreach ($course3cats as $catid) {
$report3->process_action('cg'.$catid, 'switch_minus');
if (($i++) % 2) {
$report3->process_action('cg'.$catid, 'switch_plus');
}
}
$report1 = $this->create_report($course1);
$this->assertEquals(10, count($report1->collapsed['aggregatesonly']));
$this->assertEquals(0, count($report1->collapsed['gradesonly']));
$report2 = $this->create_report($course2);
$this->assertEquals(0, count($report2->collapsed['aggregatesonly']));
$this->assertEquals(10, count($report2->collapsed['gradesonly']));
$report3 = $this->create_report($course3);
$this->assertEquals(5, count($report3->collapsed['aggregatesonly']));
$this->assertEquals(5, count($report3->collapsed['gradesonly']));
// Use the preferences generated for user1 and set it in the old format for other users.
// User2: both gradesonly and aggregatesonly.
$user2 = $this->getDataGenerator()->create_user();
$alldata = [
'gradesonly' => array_merge(
$report1->collapsed['gradesonly'],
$report2->collapsed['gradesonly'],
$report3->collapsed['gradesonly']),
'aggregatesonly' => array_merge(
$report1->collapsed['aggregatesonly'],
$report2->collapsed['aggregatesonly'],
$report3->collapsed['aggregatesonly']),
];
set_user_preference('grade_report_grader_collapsed_categories', serialize($alldata), $user2);
$this->setUser($user2);
$convertedreport1 = $this->create_report($course1);
$this->assertEquals($report1->collapsed['gradesonly'], $convertedreport1->collapsed['gradesonly']);
$this->assertEquals($report1->collapsed['aggregatesonly'], $convertedreport1->collapsed['aggregatesonly']);
$newprefs1 = get_user_preferences('grade_report_grader_collapsed_categories' . $course1->id); // Also verify new prefs.
$this->assertEquals($report1->collapsed['gradesonly'], json_decode($newprefs1, true)['gradesonly']);
$this->assertEquals($report1->collapsed['aggregatesonly'], json_decode($newprefs1, true)['aggregatesonly']);
$convertedreport2 = $this->create_report($course2);
$this->assertEquals($report2->collapsed['gradesonly'], $convertedreport2->collapsed['gradesonly']);
$this->assertEquals($report2->collapsed['aggregatesonly'], $convertedreport2->collapsed['aggregatesonly']);
$newprefs2 = get_user_preferences('grade_report_grader_collapsed_categories' . $course2->id); // Also verify new prefs.
$this->assertEquals($report2->collapsed['gradesonly'], json_decode($newprefs2, true)['gradesonly']);
$this->assertEquals($report2->collapsed['aggregatesonly'], json_decode($newprefs2, true)['aggregatesonly']);
$convertedreport3 = $this->create_report($course3);
$this->assertEquals($report3->collapsed['gradesonly'], $convertedreport3->collapsed['gradesonly']);
$this->assertEquals($report3->collapsed['aggregatesonly'], $convertedreport3->collapsed['aggregatesonly']);
$newprefs3 = get_user_preferences('grade_report_grader_collapsed_categories' . $course3->id); // Also verify new prefs.
$this->assertEquals($report3->collapsed['gradesonly'], json_decode($newprefs3, true)['gradesonly']);
$this->assertEquals($report3->collapsed['aggregatesonly'], json_decode($newprefs3, true)['aggregatesonly']);
// Make sure the old style user preference is removed now.
$this->assertEmpty(get_user_preferences('grade_report_grader_collapsed_categories'));
// User3: only gradesonly (missing aggregatesonly).
$user3 = $this->getDataGenerator()->create_user();
$alldata = [
'gradesonly' => array_merge(
$report1->collapsed['gradesonly'],
$report2->collapsed['gradesonly'],
$report3->collapsed['gradesonly']),
];
set_user_preference('grade_report_grader_collapsed_categories', serialize($alldata), $user3);
$this->setUser($user3);
$convertedreport1 = $this->create_report($course1);
$this->assertEquals($report1->collapsed['gradesonly'], $convertedreport1->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport1->collapsed['aggregatesonly']);
$newprefs1 = get_user_preferences('grade_report_grader_collapsed_categories' . $course1->id); // Also verify new prefs.
$this->assertNull($newprefs1);
$convertedreport2 = $this->create_report($course2);
$this->assertEquals($report2->collapsed['gradesonly'], $convertedreport2->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport2->collapsed['aggregatesonly']);
$newprefs2 = get_user_preferences('grade_report_grader_collapsed_categories' . $course2->id); // Also verify new prefs.
$this->assertEquals($report2->collapsed['gradesonly'], json_decode($newprefs2, true)['gradesonly']);
$this->assertEquals([], json_decode($newprefs2, true)['aggregatesonly']);
$convertedreport3 = $this->create_report($course3);
$this->assertEquals($report3->collapsed['gradesonly'], $convertedreport3->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport3->collapsed['aggregatesonly']);
$newprefs3 = get_user_preferences('grade_report_grader_collapsed_categories' . $course3->id); // Also verify new prefs.
$this->assertEquals($report3->collapsed['gradesonly'], json_decode($newprefs3, true)['gradesonly']);
$this->assertEquals([], json_decode($newprefs3, true)['aggregatesonly']);
// Make sure the old style user preference is removed now.
$this->assertEmpty(get_user_preferences('grade_report_grader_collapsed_categories'));
// User4: only aggregatesonly (missing gradesonly).
$user4 = $this->getDataGenerator()->create_user();
$alldata = [
'aggregatesonly' => array_merge(
$report1->collapsed['aggregatesonly'],
$report2->collapsed['aggregatesonly'],
$report3->collapsed['aggregatesonly']),
];
set_user_preference('grade_report_grader_collapsed_categories', serialize($alldata), $user4);
$this->setUser($user4);
$convertedreport1 = $this->create_report($course1);
$this->assertEquals([], $convertedreport1->collapsed['gradesonly']);
$this->assertEquals($report1->collapsed['aggregatesonly'], $convertedreport1->collapsed['aggregatesonly']);
$newprefs1 = get_user_preferences('grade_report_grader_collapsed_categories' . $course1->id); // Also verify new prefs.
$this->assertEquals([], json_decode($newprefs1, true)['gradesonly']);
$this->assertEquals($report1->collapsed['aggregatesonly'], json_decode($newprefs1, true)['aggregatesonly']);
$convertedreport2 = $this->create_report($course2);
$this->assertEquals([], $convertedreport2->collapsed['gradesonly']);
$this->assertEquals($report2->collapsed['aggregatesonly'], $convertedreport2->collapsed['aggregatesonly']);
$newprefs2 = get_user_preferences('grade_report_grader_collapsed_categories' . $course2->id); // Also verify new prefs.
$this->assertNull($newprefs2);
$convertedreport3 = $this->create_report($course3);
$this->assertEquals([], $convertedreport3->collapsed['gradesonly']);
$this->assertEquals($report3->collapsed['aggregatesonly'], $convertedreport3->collapsed['aggregatesonly']);
$newprefs3 = get_user_preferences('grade_report_grader_collapsed_categories' . $course3->id); // Also verify new prefs.
$this->assertEquals([], json_decode($newprefs3, true)['gradesonly']);
$this->assertEquals($report3->collapsed['aggregatesonly'], json_decode($newprefs3, true)['aggregatesonly']);
// Make sure the old style user preference is removed now.
$this->assertEmpty(get_user_preferences('grade_report_grader_collapsed_categories'));
// User5: both missing gradesonly and aggregatesonly.
$user5 = $this->getDataGenerator()->create_user();
$alldata = [];
set_user_preference('grade_report_grader_collapsed_categories', serialize($alldata), $user5);
$this->setUser($user5);
$convertedreport1 = $this->create_report($course1);
$this->assertEquals([], $convertedreport1->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport1->collapsed['aggregatesonly']);
$newprefs1 = get_user_preferences('grade_report_grader_collapsed_categories' . $course1->id); // Also verify new prefs.
$this->assertNull($newprefs1);
$convertedreport2 = $this->create_report($course2);
$this->assertEquals([], $convertedreport2->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport2->collapsed['aggregatesonly']);
$newprefs2 = get_user_preferences('grade_report_grader_collapsed_categories' . $course2->id); // Also verify new prefs.
$this->assertNull($newprefs2);
$convertedreport3 = $this->create_report($course3);
$this->assertEquals([], $convertedreport3->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport3->collapsed['aggregatesonly']);
$newprefs3 = get_user_preferences('grade_report_grader_collapsed_categories' . $course3->id); // Also verify new prefs.
$this->assertNull($newprefs3);
// Make sure the old style user preference is removed now.
$this->assertEmpty(get_user_preferences('grade_report_grader_collapsed_categories'));
// User6: both empty gradesonly and aggregatesonly.
$user6 = $this->getDataGenerator()->create_user();
$alldata = [
'gradesonly' => [],
'aggregatesonly' => []
];
set_user_preference('grade_report_grader_collapsed_categories', serialize($alldata), $user6);
$this->setUser($user6);
$convertedreport1 = $this->create_report($course1);
$this->assertEquals([], $convertedreport1->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport1->collapsed['aggregatesonly']);
$newprefs1 = get_user_preferences('grade_report_grader_collapsed_categories' . $course1->id); // Also verify new prefs.
$this->assertNull($newprefs1);
$convertedreport2 = $this->create_report($course2);
$this->assertEquals([], $convertedreport2->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport2->collapsed['aggregatesonly']);
$newprefs2 = get_user_preferences('grade_report_grader_collapsed_categories' . $course2->id); // Also verify new prefs.
$this->assertNull($newprefs2);
$convertedreport3 = $this->create_report($course3);
$this->assertEquals([], $convertedreport3->collapsed['gradesonly']);
$this->assertEquals([], $convertedreport3->collapsed['aggregatesonly']);
$newprefs3 = get_user_preferences('grade_report_grader_collapsed_categories' . $course3->id); // Also verify new prefs.
$this->assertNull($newprefs3);
// Make sure the old style user preference is removed now.
$this->assertEmpty(get_user_preferences('grade_report_grader_collapsed_categories'));
}
/**
* Tests the get_right_rows function with one 'normal' and one 'ungraded' quiz.
*
+14 -14
View File
@@ -31,10 +31,9 @@ use core_h5p\helper;
use file_archive;
use moodle_exception;
use ReflectionMethod;
use stored_file;
use zip_archive;
defined('MOODLE_INTERNAL') || die();
/**
* Test class covering the H5PFileStorage interface implementation.
*
@@ -782,7 +781,6 @@ class h5p_file_storage_test extends \advanced_testcase {
* Tests that the content folder of an H5P content is imported in the Moodle filesystem.
*/
public function test_moveContentDiretory(): void {
global $DB;
// Create temp folder.
$tempfolder = make_request_directory(false);
@@ -818,19 +816,21 @@ class h5p_file_storage_test extends \advanced_testcase {
$this->h5p_file_storage->moveContentDirectory($h5pcontentfolder, $targeth5pcontentid);
// Get database records.
$sql = "SELECT concat(filepath, filename)
FROM {files}
WHERE filearea = :filearea AND itemid = :itemid AND component = :component AND filename != '.'";
$params = [
'component' => file_storage::COMPONENT,
'filearea' => file_storage::CONTENT_FILEAREA,
'itemid' => $targeth5pcontentid
];
$filesdb = $DB->get_fieldset_sql($sql, $params);
sort($filesdb);
$files = $this->h5p_fs_fs->get_area_files(
$this->h5p_fs_context->id,
file_storage::COMPONENT,
file_storage::CONTENT_FILEAREA,
$targeth5pcontentid,
'filepath, filename',
false
);
$filepaths = array_map(static function(stored_file $file): string {
return $file->get_filepath() . $file->get_filename();
}, $files);
// Check that created files match with database records.
$this->assertEquals($filesexpected, $filesdb);
$this->assertEquals($filesexpected, array_values($filepaths));
}
/**
+1 -1
View File
@@ -36,7 +36,7 @@ $string['chooselanguagesub'] = 'Pasirinkite diegimo kalbą. Ši kalba bus naudoj
$string['clialreadyconfigured'] = 'Failas config.php jau yra, prašau naudoti admin/cli/install_database.php jei norite įrašyti šią svetainę.';
$string['clialreadyinstalled'] = 'Failas config.php jau yra. Jei norite atnaujinti svetainę, naudokite admin/cli/upgrade.php.';
$string['cliinstallheader'] = '„Moodle“ {$a} komandų eilutės diegimo programa';
$string['clitablesexist'] = 'Duomenų bazės lentelės jau yra, „cli“ diegimo tęsti negalima.';
$string['clitablesexist'] = 'Jau yra duomenų bazės lentelės; CLI diegimas negali tęstis.';
$string['databasehost'] = 'Duomenų bazės pagrindinis kompiuteris';
$string['databasename'] = 'Duomenų bazės pavadinimas';
$string['databasetypehead'] = 'Pasirinkite duomenų bazės tvarkyklę';
+1 -1
View File
@@ -30,4 +30,4 @@
defined('MOODLE_INTERNAL') || die();
$string['parentlanguage'] = 'lt';
$string['thislanguage'] = 'Lietuvių';
$string['thislanguage'] = 'Lietuvių (universitetas)';
+2
View File
@@ -38,3 +38,5 @@ $string['clitypevaluedefault'] = 'တန်ဖိုး ထည့်သွင်
$string['cliunknowoption'] = 'အသိအမှတ် မပြုထားသော ရွေးချယ်မှုများ :
{$a}
ကျေးဇူးပြု၍ -- အကူအညီရယူရန် ကိုနှိပ်ပါ။';
$string['environmentrequireinstall'] = 'ထည့်သွင်းပြီး အသုံးပြုခွင့်ဖွင့်ပါ';
$string['environmentrequireversion'] = 'ဗားရှင်း{$a->needed} ကို လိုအပ်ပြီး သင်သည် {$a->current} ကိုအသုံးပြုနေပါသည်';
+4
View File
@@ -39,4 +39,8 @@ $string['cannotdownloadzipfile'] = 'ZIP ဖိုင်ကိုဒေါင်
$string['cannotfindcomponent'] = 'အစိတ်အပိုင်းကို ရှာဖွေမတွေ့ရှိပါ။';
$string['cannotsavemd5file'] = 'md5 ဖိုင်ကို မသိမ်းဆည်းနိုင်ပါ';
$string['cannotsavezipfile'] = 'ZIP ဖိုင်ကို မသိမ်းဆည်းနိုင်ပါ';
$string['cannotunzipfile'] = 'ZIP ဖိုင် ဖြည်၍မရပါ';
$string['componentisuptodate'] = 'Component နောက်ဆုံးပေါ်ဖြစ်သည်။';
$string['dmlexceptiononinstall'] = '<p>A database error has occurred [{$a->errorcode}].<br />{$a->debuginfo}</p>';
$string['downloadedfilecheckfailed'] = 'ဒေါင်းလုဒ်ပြုလုပ်ထားသော ဖိုင် စစ်ဆေးခြင်း မအောင်မြင်ပါ';
$string['invalidmd5'] = 'ပြောင်းလဲမှုစစ်ဆေးခြင်း မှားယွင်း‌နေပါသည် - ထပ်မံကြိုးစားကြည့်ပါ';
+1
View File
@@ -32,3 +32,4 @@ defined('MOODLE_INTERNAL') || die();
$string['language'] = 'ဘာသာစကား';
$string['moodlelogo'] = 'Moodle Logo';
$string['next'] = 'နောက်သို့';
$string['previous'] = 'ရှေ့သို့';
+2 -1
View File
@@ -45,7 +45,8 @@ $string['dmlexceptiononinstall'] = '<p>Došlo k chybe databázy [{$a->errorcode}
$string['downloadedfilecheckfailed'] = 'Kontrola stiahnutého súboru bola neúspešná';
$string['invalidmd5'] = 'Kontrolovaná premenná bola nesprávna - skúste znova';
$string['missingrequiredfield'] = 'Chýba niektoré z povinných polí';
$string['remotedownloaderror'] = 'Stiahnutie komponentu na server zlyhalo, skontrolujte nastavenia proxy, doporučené je PHP rozšírenie cURL. <br /><br />Musíte stiahnuť súbor <a href="{$a->url}">{$a->url}</a> manuálne, skopírovať ho do "{$a->dest}" na serveri a rozzipovať ho tam.';
$string['remotedownloaderror'] = '<p>Sťahovanie komponentu na váš server zlyhalo. Preverte nastavenia proxy. Vrelo odporúčame PHP rozšírenie cURL.</p>
<p>Teraz musíte stiahnuť súbor <a href="{$a->url}">{$a->url}</a> ručne, prekopírovať ho do "{$a->dest}" na vašom serveri a tam ho rozbaliť.</p>';
$string['wrongdestpath'] = 'Chybné umiestnenie cieľa';
$string['wrongsourcebase'] = 'Chybné základné URL serveru';
$string['wrongzipfilename'] = 'Chybné meno súboru ZIP';
+1 -1
View File
@@ -316,7 +316,7 @@ $string['configpasswordresettime'] = 'This specifies the amount of time people h
$string['configpathtodu'] = 'Path to du. Probably something like /usr/bin/du. If you enter this, pages that display directory contents will run much faster for directories with a lot of files.';
$string['configpathtophp'] = 'Path to PHP CLI. Probably something like /usr/bin/php. If you enter this, cron scripts can be executed from admin web interface.';
$string['configperfdebug'] = 'If you turn this on, performance info will be printed in the footer of the standard theme';
$string['configprofileroles'] = 'List of roles that are visible on user profiles and participation page.';
$string['configprofileroles'] = 'Roles that are listed in user profiles and on the participants page.';
$string['configprofilesforenrolledusersonly'] = 'To prevent misuse by spammers, profile descriptions of users who are not yet enrolled in any course are hidden. New users must enrol in at least one course before they can add a profile description.';
$string['configprotectusernames'] = 'If enabled, the forgotten password form will not display any hints allowing account usernames or email addresses to be guessed.';
$string['configproxybypass'] = 'Comma separated list of (partial) hostnames or IPs that should bypass proxy (e.g., 192.168., .mydomain.com)';
+1 -1
View File
@@ -30,7 +30,7 @@ $string['activemethodinfonone'] = 'There is no advanced grading method selected
$string['changeactivemethod'] = 'Change active grading method to';
$string['clicktoclose'] = 'click to close';
$string['exc_gradingformelement'] = 'Unable to instantiate grading form element';
$string['formnotavailable'] = 'An advanced grading method was selected to use but the grading form is not available yet. You may need to define it first via a link in the actions menu or administration block.';
$string['formnotavailable'] = 'An advanced grading method was selected but the grading form still needs to be defined.';
$string['gradingformunavailable'] = 'Please note: the advanced grading form is not ready at the moment. Simple grading method will be used until the form has a valid status.';
$string['gradingmanagement'] = 'Advanced grading';
$string['gradingmanagementtitle'] = 'Advanced grading: {$a->component} ({$a->area})';
+1 -1
View File
@@ -759,7 +759,7 @@ $string['emptydragdropregion'] = 'empty region';
$string['enable'] = 'Enable';
$string['encryptedcode'] = 'Encrypted code';
$string['enddate'] = 'Course end date';
$string['enddate_help'] = 'The course end date is used for determining whether a course should be included in a user\'s list of courses. When the end date is past, the course is no longer listed in the navigation and is listed as past in the course overview. The course end date may also be used by custom reports. Users can still enter the course after the end date; in other words the date does not restrict access.';
$string['enddate_help'] = 'The course end date determines whether a course is listed as past in the course overview. The course end date may also be used by custom reports. Note that users can still enter the course after the end date; in other words the date does not restrict access.';
$string['english'] = 'English';
$string['enrolmentmethods'] = 'Enrolment methods';
$string['entercourse'] = 'Click to enter this course';
+1
View File
@@ -202,6 +202,7 @@ $string['importparseerror'] = 'Error(s) found parsing the import file. No questi
$string['importquestions'] = 'Import questions from file';
$string['importquestions_help'] = 'This function enables questions in a variety of formats to be imported via text file. Note that the file must use UTF-8 encoding.';
$string['importquestions_link'] = 'question/import';
$string['importwrongfileencoding'] = 'The file you selected does not use UTF-8 character encoding. {$a} files must use UTF-8.';
$string['importwrongfiletype'] = 'The type of the file you selected ({$a->actualtype}) does not match the type expected by this import format ({$a->expectedtype}).';
$string['invalidarg'] = 'No valid arguments supplied or incorrect server configuration';
$string['invalidcategoryidforparent'] = 'Invalid category id for parent!';
+1 -1
View File
@@ -53,7 +53,7 @@ $string['ratinginvalid'] = 'Rating is invalid';
$string['ratingtime'] = 'Restrict ratings to items with dates in this range:';
$string['ratings'] = 'Ratings';
$string['rolewarning'] = 'Roles with permission to rate';
$string['rolewarning_help'] = 'To submit ratings users require the moodle/rating:rate capability and any module specific capabilities. Users assigned the following roles should be able to rate items. The list of roles may be amended via the permissions link in the actions menu or administration block, depending on the theme.';
$string['rolewarning_help'] = 'Roles with permission to rate are roles with the capability moodle/rating:rate plus any activity-specific rating capabilities. You can give more roles permission to rate via the page Permissions.';
$string['scaleselectionrequired'] = 'When selecting a ratings aggregate type you must also select to use either a scale or set a maximum points.';
$string['privacy:metadata:rating'] = 'The user-entered rating is stored alongside a mapping of the item which was rated.';
$string['privacy:metadata:rating:userid'] = 'The user who made the rating.';
+2 -1
View File
@@ -160,6 +160,7 @@ $string['contentbank:viewunlistedcontent'] = 'View unlisted content from the con
$string['contentbank:upload'] = 'Upload new content to the content bank';
$string['contentbank:useeditor'] = 'Create or edit content using a content type editor';
$string['context'] = 'Context';
$string['contextrolenotallowed'] = 'Role <b>{$a}</b> not allowed in this context.';
$string['course:activityvisibility'] = 'Hide/show activities';
$string['course:bulkmessaging'] = 'Send a message to many people';
$string['course:create'] = 'Create courses';
@@ -251,7 +252,7 @@ $string['extusers'] = 'Existing users';
$string['extusersmatching'] = 'Existing users matching \'{$a}\'';
$string['filter:manage'] = 'Manage local filter settings';
$string['frontpageuser'] = 'Authenticated user on frontpage';
$string['frontpageuserdescription'] = 'All logged in users in the frontpage course.';
$string['frontpageuserdescription'] = 'All logged-in users in the frontpage course.';
$string['globalrole'] = 'System role';
$string['globalroleswarning'] = 'Warning: Any roles you assign from this page will apply to users throughout the entire system, including the front page and all courses.';
$string['gotoassignroles'] = 'Go to Assign roles for this {$a->contextlevel}';
+2 -2
View File
@@ -36,8 +36,8 @@ $string['filtersetmatchdescription'] = 'How multiple filters should be combined'
$string['filtertype'] = 'Filter type';
$string['match'] = 'Match';
$string['matchofthefollowing'] = 'of the following:';
$string['moodlenetprofile'] = 'MoodleNet profile';
$string['moodlenetprofile_help'] = 'This field is to link your MoodleNet profile to Moodle. It expects a WebFinger-compliant URI.';
$string['moodlenetprofile'] = 'MoodleNet profile ID';
$string['moodlenetprofile_help'] = 'Your MoodleNet profile ID links your MoodleNet profile with this site.';
$string['placeholdertypeorselect'] = 'Type or select...';
$string['placeholdertype'] = 'Type...';
$string['privacy:courserequestpath'] = 'Requested courses';
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -110,9 +110,9 @@ define([
if (e.ajaxreturn.itemtype === 'tagflag') {
var row = $(e.target).closest('tr');
if (e.ajaxreturn.value === '0') {
row.removeClass('flagged-tag');
row.removeClass('table-warning');
} else {
row.addClass('flagged-tag');
row.addClass('table-warning');
}
}
});
+43 -19
View File
@@ -877,6 +877,7 @@ function login_attempt_valid($user) {
/**
* To be called after failed user login.
* @param stdClass $user
* @throws moodle_exception
*/
function login_attempt_failed($user) {
global $CFG;
@@ -888,30 +889,53 @@ function login_attempt_failed($user) {
return;
}
$count = get_user_preferences('login_failed_count', 0, $user);
$last = get_user_preferences('login_failed_last', 0, $user);
$sincescuccess = get_user_preferences('login_failed_count_since_success', $count, $user);
$sincescuccess = $sincescuccess + 1;
set_user_preference('login_failed_count_since_success', $sincescuccess, $user);
// Force user preferences cache reload to ensure the most up-to-date login_failed_count is fetched.
// This is perhaps overzealous but is the documented way of reloading the cache, as per the test method
// 'test_check_user_preferences_loaded'.
unset($user->preference);
if (empty($CFG->lockoutthreshold)) {
// No threshold means no lockout.
// Always unlock here, there might be some race conditions or leftovers when switching threshold.
login_unlock_account($user);
return;
}
$resource = 'user:' . $user->id;
$lockfactory = \core\lock\lock_config::get_lock_factory('core_failed_login_count_lock');
if (!empty($CFG->lockoutwindow) and time() - $last > $CFG->lockoutwindow) {
$count = 0;
}
// Get a new lock for the resource, waiting for it for a maximum of 10 seconds.
if ($lock = $lockfactory->get_lock($resource, 10)) {
try {
$count = get_user_preferences('login_failed_count', 0, $user);
$last = get_user_preferences('login_failed_last', 0, $user);
$sincescuccess = get_user_preferences('login_failed_count_since_success', $count, $user);
$sincescuccess = $sincescuccess + 1;
set_user_preference('login_failed_count_since_success', $sincescuccess, $user);
$count = $count+1;
if (empty($CFG->lockoutthreshold)) {
// No threshold means no lockout.
// Always unlock here, there might be some race conditions or leftovers when switching threshold.
login_unlock_account($user);
$lock->release();
return;
}
set_user_preference('login_failed_count', $count, $user);
set_user_preference('login_failed_last', time(), $user);
if (!empty($CFG->lockoutwindow) and time() - $last > $CFG->lockoutwindow) {
$count = 0;
}
if ($count >= $CFG->lockoutthreshold) {
login_lock_account($user);
$count = $count + 1;
set_user_preference('login_failed_count', $count, $user);
set_user_preference('login_failed_last', time(), $user);
if ($count >= $CFG->lockoutthreshold) {
login_lock_account($user);
}
// Release locks when we're done.
$lock->release();
} catch (Exception $e) {
// Always release the lock on a failure.
$lock->release();
}
} else {
// We did not get access to the resource in time, give up.
throw new moodle_exception('locktimeout');
}
}
@@ -41,10 +41,31 @@ class WebDriverFactory extends UpstreamFactory implements DriverFactory {
$extracapabilities = $config['capabilities']['extra_capabilities'];
unset($config['capabilities']['extra_capabilities']);
// Ensure that the capabilites.browser is set correctly.
$config['capabilities']['browser'] = $config['browser'];
// Normalise the Edge browser name.
if ($config['browser'] === 'edge') {
$config['browser'] = 'MicrosoftEdge';
}
$capabilities = array_replace($this->guessCapabilities(), $extracapabilities, $config['capabilities']);
// Ensure that the capabilites.browserName is set correctly.
$config['capabilities']['browserName'] = $config['browser'];
$capabilities = array_replace($extracapabilities, $config['capabilities']);
// Incorrect top level capabilities lead to invalid Selenium browser selection.
// See https://github.com/SeleniumHQ/selenium/issues/10410 for more information.
// If any of these settings are mentioned then additional empty Capability options are created and a random
// browser is chosen.
$filteredcapabilities = [
'tags',
'ignoreZoomSetting',
'marionette',
'browser',
'name',
];
foreach ($filteredcapabilities as $capabilityname) {
unset($capabilities[$capabilityname]);
}
// Build driver definition.
return new Definition(WebDriver::class, [
+10 -8
View File
@@ -56,17 +56,19 @@ class behat_form_date extends behat_form_group {
// Disable the given date selector field.
$this->set_child_field_value('enabled', false);
} else if (is_numeric($value)) { // The value is numeric (unix timestamp).
// First, reset the day always to an existing one (1st). Without that
// undesired modifications (JS) happens when changing of month and day if
// the interim combination doesn't exists (for example, 31 March => 01 April).
// Note that instead of always setting the day to 1, this could be a little more
// clever, for example only changing when the day > 28, or only when the
// months (current or changed) have less days that the other. But that would
// require more complex calculations than the simpler line below.
$this->set_child_field_value('day', 1);
// Assign the mapped values to each form element in the date selector field.
foreach ($this->get_mapped_fields($value) as $childname => $childvalue) {
$this->set_child_field_value($childname, $childvalue);
if ($childname === 'enabled') {
// As soon as the form is enabled, reset the day to an existing one (1st). Without that
// undesired modifications (JS) happens when changing of month and day if
// the interim combination doesn't exists (for example, 31 March => 01 April).
// Note that instead of always setting the day to 1, this could be a little more
// clever, for example only changing when the day > 28, or only when the
// months (current or changed) have less days that the other. But that would
// require more complex calculations than the simpler line below.
$this->set_child_field_value('day', 1);
}
}
} else { // Invalid value.
// Get the name of the field.
-1
View File
@@ -1815,7 +1815,6 @@ class block_manager {
$editpage->navbar->add($block->get_title());
$editpage->navbar->add(get_string('configuration'));
echo $output->header();
echo $output->heading($strheading, 2);
$mform->display();
echo $output->footer();
exit;
+33 -3
View File
@@ -121,10 +121,40 @@ class completion_daily_task extends scheduled_task {
if ($prev->completionid) {
$completion->id = $prev->completionid;
}
$completion->mark_enrolled();
if (debugging()) {
mtrace('Marked started user ' . $prev->userid . ' in course ' . $prev->course);
try {
$completion->mark_enrolled();
if (debugging()) {
mtrace('Marked started user '.$prev->userid.' in course '.$prev->course);
}
} catch (\dml_write_exception $e) {
// Most likely this happened because the completion object was created while we were working.
// So get the record and make sure it has a time enrolled set.
if (debugging()) {
mtrace('Exception while marking started user '.$prev->userid.' in course '.$prev->course.', retrying');
}
$params = ['userid' => $completion->userid, 'course' => $completion->course];
$existing = new \completion_completion($params);
if (!empty($existing->id) && empty($existing->timeenrolled)) {
$existing->timeenrolled = $completion->timeenrolled;
try {
$existing->mark_enrolled();
} catch (\Exception $e) {
// Catch everything, so we can continue on to other records.
if (debugging()) {
mtrace('Exception again while marking started user '.$prev->userid.' in course '.$prev->course.
': '.$e->getMessage()."\n".$e->getTraceAsString());
}
}
}
} catch (\Exception $e) {
// Catch anything else, so we can continue on to other records.
if (debugging()) {
mtrace('Exception while marking started user '.$prev->userid.' in course '.$prev->course.
': '.$e->getMessage()."\n".$e->getTraceAsString());
}
}
} else if ($prev && $current) {
// Else, if this record is for the same user/course use oldest timeenrolled.
+3 -3
View File
@@ -986,7 +986,7 @@ class manager {
$params = ['now1' => time(), 'now2' => time()];
$sql = "SELECT subquery.*
FROM (SELECT concat('s', ts.id) as uniqueid,
FROM (SELECT " . $DB->sql_concat("'s'", 'ts.id') . " as uniqueid,
ts.id,
'scheduled' as type,
ts.classname,
@@ -997,7 +997,7 @@ class manager {
FROM {task_scheduled} ts
WHERE ts.timestarted IS NOT NULL
UNION ALL
SELECT concat('a', ta.id) as uniqueid,
SELECT " . $DB->sql_concat("'a'", 'ta.id') . " as uniqueid,
ta.id,
'adhoc' as type,
ta.classname,
@@ -1116,7 +1116,7 @@ class manager {
if (!self::is_runnable()) {
$redirecturl = new \moodle_url('/admin/settings.php', ['section' => 'systempaths']);
throw new \moodle_exception('cannotfindthepathtothecli', 'core_task', $redirecturl->out());
throw new \moodle_exception('cannotfindthepathtothecli', 'tool_task', $redirecturl->out());
} else {
// Shell-escaped path to the PHP binary.
$phpbinary = escapeshellarg(self::find_php_cli_path());
+18
View File
@@ -2682,5 +2682,23 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021051700.05);
}
if ($oldversion < 2021051706.12) {
// Social custom fields could had been created linked to category id = 1. Let's check category 1 exists.
if (!$DB->get_record('user_info_category', ['id' => 1])) {
// Let's check if we have any custom field linked to category id = 1.
$fields = $DB->get_records('user_info_field', ['categoryid' => 1]);
if (!empty($fields)) {
$categoryid = $DB->get_field_sql('SELECT min(id) from {user_info_category}');
foreach ($fields as $field) {
$field->categoryid = $categoryid;
$DB->update_record('user_info_field', $field);
}
}
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2021051706.12);
}
return true;
}
+16 -1
View File
@@ -438,9 +438,10 @@ class oci_native_moodle_database extends moodle_database {
$indexes = array();
$tablename = strtoupper($this->prefix.$table);
$sql = "SELECT i.INDEX_NAME, i.UNIQUENESS, c.COLUMN_POSITION, c.COLUMN_NAME, ac.CONSTRAINT_TYPE
$sql = "SELECT i.INDEX_NAME, i.INDEX_TYPE, i.UNIQUENESS, c.COLUMN_POSITION, c.COLUMN_NAME, e.COLUMN_EXPRESSION, ac.CONSTRAINT_TYPE
FROM ALL_INDEXES i
JOIN ALL_IND_COLUMNS c ON c.INDEX_NAME=i.INDEX_NAME
LEFT JOIN ALL_IND_EXPRESSIONS e ON (e.INDEX_NAME = c.INDEX_NAME AND e.COLUMN_POSITION = c.COLUMN_POSITION)
LEFT JOIN ALL_CONSTRAINTS ac ON (ac.TABLE_NAME=i.TABLE_NAME AND ac.CONSTRAINT_NAME=i.INDEX_NAME AND ac.CONSTRAINT_TYPE='P')
WHERE i.TABLE_NAME = '$tablename'
ORDER BY i.INDEX_NAME, c.COLUMN_POSITION";
@@ -463,6 +464,20 @@ class oci_native_moodle_database extends moodle_database {
'unique' => ($record['UNIQUENESS'] === 'UNIQUE'),
'columns' => array());
}
// If this is an unique, function-based, index, then we have to look to the expression
// and calculate the column name by parsing it.
if ($record['UNIQUENESS'] === 'UNIQUE' && $record['INDEX_TYPE'] === 'FUNCTION-BASED NORMAL') {
// Only if there is an expression to look.
if (!empty($record['COLUMN_EXPRESSION'])) {
// Let's parse the usual code used for these unique indexes.
$regex = '/^CASE *WHEN .* THEN "(?<column_name>[^"]+)" ELSE NULL END *$/';
if (preg_match($regex, $record['COLUMN_EXPRESSION'], $matches)) {
$record['COLUMN_NAME'] = $matches['column_name'] ?? $record['COLUMN_NAME'];
}
}
}
$indexes[$indexname]['columns'][] = strtolower($record['COLUMN_NAME']);
}
+35
View File
@@ -711,6 +711,41 @@ EOD;
$this->assertSame('id', $composed['columns'][1]);
}
/**
* Let's verify get_indexes() when we mix null and not null columns in unique indexes.
*
* Some databases, for unique indexes of this type, need to create function indexes to
* provide cross-db behaviour. Here we check that those indexes don't break get_indexes().
*
* Note that, strictly speaking, unique indexes on null columns are far from ideal. Both
* conceptually and also in practice, because they cause DBs to use full scans in a
* number of situations. But if we support them, we need to ensure get_indexes() work on them.
*/
public function test_get_indexes_unique_mixed_nullability() {
$DB = $this->tdb;
$dbman = $this->tdb->get_manager();
$table = $this->get_test_table();
$tablename = $table->getName();
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('nullable01', XMLDB_TYPE_INTEGER, 10, null, null, null, null);
$table->add_field('nullable02', XMLDB_TYPE_INTEGER, 10, null, null, null, null);
$table->add_field('nonullable01', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_field('nonullable02', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$indexcolumns = ['nullable01', 'nonullable01', 'nullable02', 'nonullable02'];
$table->add_index('course-id', XMLDB_INDEX_UNIQUE, $indexcolumns);
$dbman->create_table($table);
$indexes = $DB->get_indexes($tablename);
$this->assertIsArray($indexes);
$this->assertCount(1, $indexes);
$index = array_shift($indexes);
$this->assertTrue($index['unique']);
$this->assertSame($indexcolumns, $index['columns']);
}
public function test_get_columns() {
$DB = $this->tdb;
$dbman = $this->tdb->get_manager();
@@ -434,6 +434,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this.editor.delegate('dblclick', this._displayDialogue, 'video', this);
this.editor.delegate('click', this._handleClick, 'video', this);
// For some reason, clicking the video on Firefox does not trigger the click event, while in Chrome it does.
// We also need to handle the play/pause instead.
this._attachPlayPauseEvents();
var changeHandler = this._attachPlayPauseEvents.bind(this);
this.get('host').on('change', changeHandler, null);
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue,
@@ -443,6 +449,26 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Attaches Play/Pause events to the video nodes.
*
* @private
*/
_attachPlayPauseEvents: function() {
if (this._handlePlayEndBound === undefined) {
this._handlePlayEndBound = this._handlePlayEnd.bind(this);
}
var videos = this.editor.getDOMNode().querySelectorAll('video');
videos.forEach(function(video) {
// Prevent duplicated event listeners.
video.removeEventListener('play', this._handlePlayEndBound);
video.removeEventListener('pause', this._handlePlayEndBound);
// Add event listeners.
video.addEventListener('play', this._handlePlayEndBound);
video.addEventListener('pause', this._handlePlayEndBound);
}.bind(this));
},
/**
* Gets the root context for all templates, with extra supplied context.
*
@@ -478,6 +504,23 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Handles a play/end on a media element.
*
* @method _handlePlayEnd
* @param {Event} e
* @private
*/
_handlePlayEnd: function(e) {
var medium = Y.one(e.target);
var selection = this.get('host').getSelectionFromNode(medium);
if (this.get('host').getSelection() !== selection) {
this.get('host').setSelection(selection);
this.get('host')._hasSelectionChanged(e);
}
},
/**
* Display the media editing tool.
*
File diff suppressed because one or more lines are too long
@@ -434,6 +434,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this.editor.delegate('dblclick', this._displayDialogue, 'video', this);
this.editor.delegate('click', this._handleClick, 'video', this);
// For some reason, clicking the video on Firefox does not trigger the click event, while in Chrome it does.
// We also need to handle the play/pause instead.
this._attachPlayPauseEvents();
var changeHandler = this._attachPlayPauseEvents.bind(this);
this.get('host').on('change', changeHandler, null);
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue,
@@ -443,6 +449,26 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Attaches Play/Pause events to the video nodes.
*
* @private
*/
_attachPlayPauseEvents: function() {
if (this._handlePlayEndBound === undefined) {
this._handlePlayEndBound = this._handlePlayEnd.bind(this);
}
var videos = this.editor.getDOMNode().querySelectorAll('video');
videos.forEach(function(video) {
// Prevent duplicated event listeners.
video.removeEventListener('play', this._handlePlayEndBound);
video.removeEventListener('pause', this._handlePlayEndBound);
// Add event listeners.
video.addEventListener('play', this._handlePlayEndBound);
video.addEventListener('pause', this._handlePlayEndBound);
}.bind(this));
},
/**
* Gets the root context for all templates, with extra supplied context.
*
@@ -478,6 +504,23 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Handles a play/end on a media element.
*
* @method _handlePlayEnd
* @param {Event} e
* @private
*/
_handlePlayEnd: function(e) {
var medium = Y.one(e.target);
var selection = this.get('host').getSelectionFromNode(medium);
if (this.get('host').getSelection() !== selection) {
this.get('host').setSelection(selection);
this.get('host')._hasSelectionChanged(e);
}
},
/**
* Display the media editing tool.
*
@@ -432,6 +432,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this.editor.delegate('dblclick', this._displayDialogue, 'video', this);
this.editor.delegate('click', this._handleClick, 'video', this);
// For some reason, clicking the video on Firefox does not trigger the click event, while in Chrome it does.
// We also need to handle the play/pause instead.
this._attachPlayPauseEvents();
var changeHandler = this._attachPlayPauseEvents.bind(this);
this.get('host').on('change', changeHandler, null);
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue,
@@ -441,6 +447,26 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Attaches Play/Pause events to the video nodes.
*
* @private
*/
_attachPlayPauseEvents: function() {
if (this._handlePlayEndBound === undefined) {
this._handlePlayEndBound = this._handlePlayEnd.bind(this);
}
var videos = this.editor.getDOMNode().querySelectorAll('video');
videos.forEach(function(video) {
// Prevent duplicated event listeners.
video.removeEventListener('play', this._handlePlayEndBound);
video.removeEventListener('pause', this._handlePlayEndBound);
// Add event listeners.
video.addEventListener('play', this._handlePlayEndBound);
video.addEventListener('pause', this._handlePlayEndBound);
}.bind(this));
},
/**
* Gets the root context for all templates, with extra supplied context.
*
@@ -476,6 +502,23 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
}
},
/**
* Handles a play/end on a media element.
*
* @method _handlePlayEnd
* @param {Event} e
* @private
*/
_handlePlayEnd: function(e) {
var medium = Y.one(e.target);
var selection = this.get('host').getSelectionFromNode(medium);
if (this.get('host').getSelection() !== selection) {
this.get('host').setSelection(selection);
this.get('host')._hasSelectionChanged(e);
}
},
/**
* Display the media editing tool.
*
+9
View File
@@ -2672,6 +2672,8 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownload=false, array $options=array()) {
global $CFG, $COURSE;
static $recursion = 0;
if (empty($options['filename'])) {
$filename = null;
} else {
@@ -2715,6 +2717,13 @@ function send_stored_file($stored_file, $lifetime=null, $filter=0, $forcedownloa
// handle external resource
if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) {
// Have we been here before?
$recursion++;
if ($recursion > 10) {
throw new coding_exception('Recursive file serving detected');
}
$stored_file->send_file($lifetime, $filter, $forcedownload, $options);
die;
}
+14
View File
@@ -664,6 +664,13 @@ function filter_set_global_state($filtername, $state, $move = 0) {
// Move only active.
if ($move != 0 and isset($on[$filter->filter])) {
// Capture the old order for logging.
$oldorder = implode(', ', array_map(
function($f) {
return $f->filter;
}, $on));
// Work out the new order.
$i = 1;
foreach ($on as $f) {
$f->newsortorder = $i;
@@ -686,6 +693,13 @@ function filter_set_global_state($filtername, $state, $move = 0) {
}
core_collator::asort_objects_by_property($on, 'newsortorder', core_collator::SORT_NUMERIC);
// Log in config_log.
$neworder = implode(', ', array_map(
function($f) {
return $f->filter;
}, $on));
add_to_config_log('order', $oldorder, $neworder, 'core_filter');
}
// Inactive are sorted by filter name.
+17 -5
View File
@@ -60,19 +60,31 @@ class flickr_client extends oauth_helper {
* @param moodle_url|string $callbackurl
*/
public function __construct($consumerkey, $consumersecret, $callbackurl = '') {
global $CFG;
$version = moodle_major_version();
$useragent = "MoodleSite/$version (+{$CFG->wwwroot})";
parent::__construct([
'api_root' => self::OAUTH_ROOT,
'oauth_consumer_key' => $consumerkey,
'oauth_consumer_secret' => $consumersecret,
'oauth_callback' => $callbackurl,
'http_options' => ['CURLOPT_USERAGENT' => $useragent]
'http_options' => [
'CURLOPT_USERAGENT' => static::user_agent(),
],
]);
}
/**
* Return User-Agent string suitable for calls to Flickr endpoint, avoiding problems caused by the string returned by
* the {@see core_useragent::get_moodlebot_useragent} helper, which is often rejected due to presence of "Bot" within
*
* @return string
*/
public static function user_agent(): string {
global $CFG;
$version = moodle_major_version();
return "MoodleSite/{$version} (+{$CFG->wwwroot})";
}
/**
* Temporarily store the request token secret in the session.
*
+10
View File
@@ -32,6 +32,11 @@
* @subpackage 3rd-party
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->libdir}/flickrclient.php");
/**
* Flickr Class
* @package moodlecore
@@ -78,7 +83,12 @@ class phpFlickr {
//Find the PHP version and store it for future reference
$this->php_version = explode("-", phpversion());
$this->php_version = explode(".", $this->php_version[0]);
// Initialize curl helper, set custom user agent as Flickr blocks our "MoodleBot" agent string.
$this->curl = new curl(array('cache'=>true, 'module_cache'=>'repository'));
$this->curl->setopt([
'CURLOPT_USERAGENT' => flickr_client::user_agent(),
]);
}
function request ($command, $args = array())
@@ -80,16 +80,18 @@ M.form.dateselector = {
this.panel.render(document.body);
// Determine the correct zindex by looking at all existing dialogs and menubars in the page.
var highestzindex = 0;
Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) {
var zindex = this.findZIndex(node);
if (zindex > highestzindex) {
highestzindex = zindex;
}
this.panel.on('focus', function() {
var highestzindex = 0;
Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) {
var zindex = this.findZIndex(node);
if (zindex > highestzindex) {
highestzindex = zindex;
}
}, this);
// Only set the zindex if we found a wrapper.
var zindexvalue = (highestzindex + 1).toString();
Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue);
}, this);
// Only set the zindex if we found a wrapper.
var zindexvalue = (highestzindex + 1).toString();
Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue);
this.panel.on('heightChange', this.fix_position, this);
@@ -358,14 +360,14 @@ CALENDAR.prototype = {
}
},
toggle_calendar_image: function() {
// If the enable checkbox is det checked, disable the image.
// If the enable checkbox is not checked, disable the calendar image and prevent focus.
if (!this.enablecheckbox.get('checked')) {
this.calendarimage.set('disabled', 'disabled');
this.calendarimage.setStyle('cursor', 'default');
this.calendarimage.addClass('disabled');
this.calendarimage.setAttribute('tabindex', -1);
this.release_calendar();
} else {
this.calendarimage.set('disabled', false);
this.calendarimage.setStyle('cursor', null);
this.calendarimage.removeClass('disabled');
this.calendarimage.setAttribute('tabindex', 0);
}
}
};
File diff suppressed because one or more lines are too long
@@ -80,16 +80,18 @@ M.form.dateselector = {
this.panel.render(document.body);
// Determine the correct zindex by looking at all existing dialogs and menubars in the page.
var highestzindex = 0;
Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) {
var zindex = this.findZIndex(node);
if (zindex > highestzindex) {
highestzindex = zindex;
}
this.panel.on('focus', function() {
var highestzindex = 0;
Y.all(DIALOGUE_SELECTOR + ', ' + MENUBAR_SELECTOR + ', ' + DOT + HAS_ZINDEX).each(function(node) {
var zindex = this.findZIndex(node);
if (zindex > highestzindex) {
highestzindex = zindex;
}
}, this);
// Only set the zindex if we found a wrapper.
var zindexvalue = (highestzindex + 1).toString();
Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue);
}, this);
// Only set the zindex if we found a wrapper.
var zindexvalue = (highestzindex + 1).toString();
Y.one('#dateselector-calendar-panel').setStyle('zIndex', zindexvalue);
this.panel.on('heightChange', this.fix_position, this);
@@ -358,14 +360,14 @@ CALENDAR.prototype = {
}
},
toggle_calendar_image: function() {
// If the enable checkbox is det checked, disable the image.
// If the enable checkbox is not checked, disable the calendar image and prevent focus.
if (!this.enablecheckbox.get('checked')) {
this.calendarimage.set('disabled', 'disabled');
this.calendarimage.setStyle('cursor', 'default');
this.calendarimage.addClass('disabled');
this.calendarimage.setAttribute('tabindex', -1);
this.release_calendar();
} else {
this.calendarimage.set('disabled', false);
this.calendarimage.setStyle('cursor', null);
this.calendarimage.removeClass('disabled');
this.calendarimage.setAttribute('tabindex', 0);
}
}
};
@@ -228,9 +228,11 @@ Y.extend(SHORTFORMS, Y.Base, {
// Updating the button.
if (expandbtn) {
btn.removeClass(CSS.COLLAPSEALL);
btn.setAttribute('aria-expanded', false);
btn.setHTML(M.util.get_string('expandall', 'moodle'));
} else {
btn.addClass(CSS.COLLAPSEALL);
btn.setAttribute('aria-expanded', true);
btn.setHTML(M.util.get_string('collapseall', 'moodle'));
}
@@ -1 +1 @@
YUI.add("moodle-form-shortforms",function(r,e){function t(){t.superclass.constructor.apply(this,arguments)}var o=".collapsible-actions .collapseexpand",a=".collapsed",i="fieldset.collapsible",l="fieldset.collapsible .fheader",n=".fheader",d="legend.ftoggler",c="collapse-all",f="collapsed",h="fheader",s={formid:{value:null}};r.extend(t,r.Base,{form:null,initializer:function(){var e,t,s,a=r.one("#"+this.get("formid"));a&&((this.form=a).all(i).each(this.process_fieldset,this),a.delegate("click",this.switch_state,l,this),a.delegate("key",this.switch_state,"down:enter,32",l,this),r.Global.on(M.core.globalEvents.FORM_ERROR,this.expand_fieldset,this),(e=a.one(o))&&((t=r.Node.create('<a href="#"></a>')).setHTML(e.getHTML()),t.setAttribute("class",e.getAttribute("class")),t.setAttribute("role","button"),s=[],a.all(l).each(function(e){s[s.length]=e.generateID()}),t.setAttribute("aria-controls",s.join(" ")),t.on("click",this.set_state_all,this,!0),t.on("key",this.set_state_all,"down:enter,32",this,!0),e.replace(t),this.update_btns(a)))},process_fieldset:function(e){var t=e.one(d),s=r.Node.create('<a href="#"></a>');return s.addClass(h),s.appendChild(t.get("firstChild")),s.setAttribute("role","button"),s.setAttribute("aria-controls",e.generateID()),t.ancestor(a)?s.setAttribute("aria-expanded","false"):s.setAttribute("aria-expanded","true"),t.prepend(s),this},set_state:function(e,t){var s=e.one(n);return t?(e.addClass(f),s&&s.setAttribute("aria-expanded","false")):(e.removeClass(f),s&&s.setAttribute("aria-expanded","true")),(s=this.form.one("input[name=mform_isexpanded_"+e.get("id")+"]"))&&s.set("value",t?0:1),this},set_state_all:function(e){e.preventDefault();var t=e.target.hasClass(c);this.form.all(i).each(function(e){this.set_state(e,t)},this),this.update_btns()},switch_state:function(e){e.preventDefault();e=e.target.ancestor(i);this.set_state(e,!e.hasClass(f)),this.update_btns()},update_btns:function(){var t=0,e=!1,s=this.form.one(o);return s&&(this.form.all(i).each(function(e){e.hasClass(f)&&t++}),(e=0!==t?!0:e)?(s.removeClass(c),s.setHTML(M.util.get_string("expandall","moodle"))):(s.addClass(c),s.setHTML(M.util.get_string("collapseall","moodle")))),this},expand_fieldset:function(e){var t;e.stopPropagation(),e.formid===this.form.getAttribute("id")&&(t=r.one("#"+e.elementid).ancestor("fieldset"))&&this.set_state(t,!1)}},{NAME:"moodle-form-shortforms",ATTRS:s}),M.form=M.form||{},M.form.shortforms=M.form.shortforms||function(e){return new t(e)}},"@VERSION@",{requires:["node","base","selector-css3","moodle-core-event"]});
YUI.add("moodle-form-shortforms",function(r,e){function t(){t.superclass.constructor.apply(this,arguments)}var i=".collapsible-actions .collapseexpand",a=".collapsed",o="fieldset.collapsible",l="fieldset.collapsible .fheader",n=".fheader",d="legend.ftoggler",c="collapse-all",f="collapsed",h="fheader",s={formid:{value:null}};r.extend(t,r.Base,{form:null,initializer:function(){var e,t,s,a=r.one("#"+this.get("formid"));a&&((this.form=a).all(o).each(this.process_fieldset,this),a.delegate("click",this.switch_state,l,this),a.delegate("key",this.switch_state,"down:enter,32",l,this),r.Global.on(M.core.globalEvents.FORM_ERROR,this.expand_fieldset,this),(e=a.one(i))&&((t=r.Node.create('<a href="#"></a>')).setHTML(e.getHTML()),t.setAttribute("class",e.getAttribute("class")),t.setAttribute("role","button"),s=[],a.all(l).each(function(e){s[s.length]=e.generateID()}),t.setAttribute("aria-controls",s.join(" ")),t.on("click",this.set_state_all,this,!0),t.on("key",this.set_state_all,"down:enter,32",this,!0),e.replace(t),this.update_btns(a)))},process_fieldset:function(e){var t=e.one(d),s=r.Node.create('<a href="#"></a>');return s.addClass(h),s.appendChild(t.get("firstChild")),s.setAttribute("role","button"),s.setAttribute("aria-controls",e.generateID()),t.ancestor(a)?s.setAttribute("aria-expanded","false"):s.setAttribute("aria-expanded","true"),t.prepend(s),this},set_state:function(e,t){var s=e.one(n);return t?(e.addClass(f),s&&s.setAttribute("aria-expanded","false")):(e.removeClass(f),s&&s.setAttribute("aria-expanded","true")),(s=this.form.one("input[name=mform_isexpanded_"+e.get("id")+"]"))&&s.set("value",t?0:1),this},set_state_all:function(e){e.preventDefault();var t=e.target.hasClass(c);this.form.all(o).each(function(e){this.set_state(e,t)},this),this.update_btns()},switch_state:function(e){e.preventDefault();e=e.target.ancestor(o);this.set_state(e,!e.hasClass(f)),this.update_btns()},update_btns:function(){var t=0,e=!1,s=this.form.one(i);return s&&(this.form.all(o).each(function(e){e.hasClass(f)&&t++}),(e=0!==t?!0:e)?(s.removeClass(c),s.setAttribute("aria-expanded",!1),s.setHTML(M.util.get_string("expandall","moodle"))):(s.addClass(c),s.setAttribute("aria-expanded",!0),s.setHTML(M.util.get_string("collapseall","moodle")))),this},expand_fieldset:function(e){var t;e.stopPropagation(),e.formid===this.form.getAttribute("id")&&(t=r.one("#"+e.elementid).ancestor("fieldset"))&&this.set_state(t,!1)}},{NAME:"moodle-form-shortforms",ATTRS:s}),M.form=M.form||{},M.form.shortforms=M.form.shortforms||function(e){return new t(e)}},"@VERSION@",{requires:["node","base","selector-css3","moodle-core-event"]});

Some files were not shown because too many files have changed in this diff Show More