Compare commits

..

440 Commits

Author SHA1 Message Date
Jake Dallimore b8fd606243 Moodle release 3.11.8 2022-07-08 11:28:39 +08:00
Jun Pataleta 5cb257b4c3 weekly release 3.11.7+ 2022-07-07 21:33:10 +08:00
Jun Pataleta 64b6bca053 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-07-07 21:33:08 +08:00
Jake Dallimore d3d988fcc6 Merge branch 'MDL-69400-311' of https://github.com/abgreeve/moodle into MOODLE_311_STABLE 2022-07-07 11:49:05 +08:00
Jun Pataleta bf3f06bb82 Merge branch 'MDL-75116_311' of https://github.com/aolley/moodle into MOODLE_311_STABLE 2022-07-07 10:47:50 +08:00
Víctor Déniz fb714c7cf6 Merge branch 'MDL-74835-M311_update-nodejs-version-in-travis-integration-to-lts-gallium' of https://github.com/ziegenberg/moodle into MOODLE_311_STABLE 2022-07-06 12:16:56 +01:00
Jun Pataleta 4ce6dc7b4d Merge branch 'MDL-74741-311' of https://github.com/rezaies/moodle into MOODLE_311_STABLE 2022-07-06 16:45:52 +08:00
stevando cd6e0bf763 MDL-72171 tool_mobile: Ensure auto login URL is always local 2022-07-06 14:28:39 +08:00
Adrian Greeve 69ce532809 MDL-69400 mod_forum: Added calender event refreshing. 2022-07-06 12:42:47 +08:00
Mihail Geshoski 0f4e8413fc MDL-71921 scorm: Sanitize element names before outputting track details 2022-07-06 05:24:15 +02:00
Alex Morris 919f5bfb36 MDL-75044 assignfeedback_editpdf: Add SAFER option to GS command
Adds the SAFER option to the Ghostscript command to limit interaction
with IO and OS commands
2022-07-06 05:24:15 +02:00
Huong Nguyen 46ee4f4062 MDL-72029 Lesson: Prevent arbitrary file read when importing lesson questions in blackboard format 2022-07-06 05:24:15 +02:00
Huong Nguyen edc7eb06b7 MDL-72029 lib: Prevent path traversal for clean_param with PARAM_SAFEPATH 2022-07-06 05:24:15 +02:00
Laurent David 8af0c977d0 MDL-74473 core_analytics: Upgrade ML Backend to 2.6.6 2022-07-06 05:24:15 +02:00
Jake Dallimore f1c0f2849b MDL-72299 mod_lti: fix html escaping when reposting cross site posts 2022-07-06 05:24:15 +02:00
Andrew Nicols 00f0ebf5ea Merge branch 'MDL-73305_MOODLE_311_STABLE' of https://github.com/tasosb/moodle into MOODLE_311_STABLE 2022-07-06 11:16:28 +08:00
Andrew Nicols 8c87a29d2e Merge branch 'MDL-74408-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-07-06 11:03:12 +08:00
Andrew Nicols 26fe42c16e Merge branch 'MDL-74972-311' of https://github.com/marinaglancy/moodle into MOODLE_311_STABLE 2022-07-06 10:58:29 +08:00
Jun Pataleta d7f72ffdc8 Merge branch 'MDL-74813-311' of https://github.com/mihailges/moodle into MOODLE_311_STABLE 2022-07-06 10:53:53 +08:00
Mihail Geshoski 60d8572d4e MDL-74813 filepicker: Replace the dnd gif animation with a static icon 2022-07-06 10:24:44 +08:00
Jun Pataleta b7d79061f1 Merge branch 'MDL-74821-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-07-05 22:13:27 +08:00
Laurent David cc7ccb6c42 MDL-74821 mod_feedback: Fix HTML validator error
* Remove align attribute on table elements
* Fix dangling tr/td on multichoice rated
* Remove colspan as it is not used
2022-07-05 21:41:12 +08:00
Jake Dallimore d16e3a8141 Merge branch 'MDL-74815-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-07-05 14:53:18 +08:00
Jake Dallimore 05bc504e4e Merge branch '311_mdl-73498' of https://github.com/daniil-berg/moodle into MOODLE_311_STABLE 2022-07-05 12:01:20 +08:00
AMOS bot 7197b264b1 Automatically generated installer lang files 2022-07-05 00:08:20 +00:00
Adam Olley 83e6407074 MDL-75116 mod_feedback: Check array values exist before using them
Without this, the @list will emit a PHP warning under php8.0+ when the array
doesn't have a second element to assign.
2022-07-05 09:18:10 +09:30
Jun Pataleta 93e30fbe3c Merge branch 'MDL-74516_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-07-04 23:17:53 +08:00
Jun Pataleta 287d51323f Merge branch 'MDL-75008-311-enfix' of https://github.com/mudrd8mz/moodle into MOODLE_311_STABLE 2022-07-04 22:17:48 +08:00
Jun Pataleta 8acd5f7390 MDL-74815 pix: Convert PNG version of darkened SVG icons
* Conversion was done using rsvg-convert from librsvg
2022-07-04 14:00:55 +08:00
Jun Pataleta f7c7b7cb73 MDL-74815 pix: Darken colour of grey icons
* Change the fill colour of grey icons from #999 to #888.
2022-07-04 12:55:02 +08:00
Eloy Lafuente (stronk7) 1271286cf5 MDL-74516 activities: Better handling of floats for gradepass fields
Note that in 311_STABLE the patch is different from the 400 and master
fixes. The API for grade_floatval() was only changed for 4.0 and up.

Hence, for this branch we are just:

- Changing the form definition to use proper "float" element (instead
  of text + raw.
- Backporting the behat tests to verify that everything continues
  working ok.

Also, in 311_STABLE, the workshop module did not have the grade
to pass completion condition, so we aren't modifying anything
in that activity for that branch.
2022-07-01 13:55:57 +02:00
Víctor Déniz fda6e143af weekly release 3.11.7+ 2022-07-01 11:28:48 +01:00
David Mudrák 03c7f3dc87 MDL-75008 lang: Use the fixed strings in Behat scenario files 2022-06-30 22:10:57 +02:00
Helen Foster 985be80d1f MDL-75008 lang: Import fixed English strings (en_fix) 2022-06-30 22:06:42 +02:00
Jun Pataleta ef6bb4439d Merge branch 'MDL-74613-311' of https://github.com/NoelDeMartin/moodle into MOODLE_311_STABLE 2022-06-30 20:24:14 +08:00
Noel De Martin 787e36fea8 MDL-74613 grade: Fix undefined behat step 2022-06-30 11:26:27 +02:00
Shamim Rezaie 79af8fb2f5 Merge branch 'MDL-74812-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-30 13:34:52 +10:00
Shamim Rezaie f247f5b048 Merge branch 'MDL-75055-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-30 13:20:39 +10:00
Andrew Nicols 3176d756e0 Merge branch 'MDL-75084-311' of https://github.com/NoelDeMartin/moodle into MOODLE_311_STABLE 2022-06-30 11:13:53 +08:00
Andrew Nicols 5de3c84461 Merge branch 'MDL-74613-311' of https://github.com/NoelDeMartin/moodle into MOODLE_311_STABLE 2022-06-30 11:04:56 +08:00
Andrew Nicols b08a9e0b66 Merge branch 'MDL-74220-311' of https://github.com/NoelDeMartin/moodle into MOODLE_311_STABLE 2022-06-30 11:00:01 +08:00
Andrew Nicols ef6a03ea51 Merge branch 'MDL-74744-311' of https://github.com/andelacruz/moodle into MOODLE_311_STABLE 2022-06-30 10:55:54 +08:00
Andrew Nicols ce8237d5fd Merge branch 'MDL-74841-311' of https://github.com/andelacruz/moodle into MOODLE_311_STABLE 2022-06-30 10:44:47 +08:00
Andrew Nicols 8db9ab4908 Merge branch 'MDL-72292-311' of https://github.com/lameze/moodle into MOODLE_311_STABLE 2022-06-30 10:40:40 +08:00
Andrew Nicols eda6b9ba8f MDL-74379 core: Update date_format_string to use x-os functions 2022-06-30 10:36:14 +08:00
Andrew Nicols f85d5e9e5d Merge branch 'MDL-74379_311' of https://github.com/aya-saad1/moodle into MOODLE_311_STABLE 2022-06-30 10:36:10 +08:00
Andrew Nicols dd4702ee80 Merge branch 'MDL-74287-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-30 10:02:29 +08:00
Víctor Déniz ad5e6f00df Merge branch 'MDL-72885-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-29 22:47:49 +01:00
Jun Pataleta a3af9f65bf Merge branch 'MDL74387_MOODLE_311_STABLE' of https://github.com/Amrita1991/moodle into MOODLE_311_STABLE 2022-06-29 23:21:05 +08:00
Jun Pataleta 3584a14e78 MDL-75055 templates: Apply .alert-dismissible class
- Apply the .alert-dismissible class for notification alerts with
close button to fix its positioning. As an added bonus, the
.alert-dismissible class also enlarges the clickable area of the
close button which is great for accessibility.
- Improve example context for the notification alerts templates.
2022-06-29 22:27:35 +08:00
Jun Pataleta 77abe66d2c MDL-75055 theme_boost: Darken close button colour in notification alerts
This is in order for the close button to have a good contrast against
the alert background and meet the minimum Level AA contrast ratio of 3:1
2022-06-29 22:27:35 +08:00
Ilya Tregubov ab22e012d8 Merge branch 'MDL-74548-311' of https://github.com/cameron1729/moodle into MOODLE_311_STABLE 2022-06-29 16:17:18 +04:00
Jun Pataleta 758281716e Merge branch 'MDL-74886-311' of https://github.com/lameze/moodle into MOODLE_311_STABLE 2022-06-29 17:47:12 +08:00
Anastasios Bithas 9b64f0afcd MDL-73305 mod_folder: Download Folder in a mlang formated folder 2022-06-29 12:42:50 +03:00
Jake Dallimore 9c611755d4 Merge branch 'MDL-74674-311' of https://github.com/alfonso-salces/moodle into MOODLE_311_STABLE 2022-06-29 16:45:02 +08:00
Alfonso Salces 96b7a7d066 MDL-74674 core: create notification generators 2022-06-29 10:30:55 +02:00
Noel De Martin cc68de58d1 MDL-75084 blog: Implement behat generators 2022-06-29 09:40:16 +02:00
Jake Dallimore 79c83bfcef Merge branch 'MDL-74864-311' of https://github.com/dpalou/moodle into MOODLE_311_STABLE 2022-06-29 13:41:15 +08:00
Cameron Ball 79e0d92848 MDL-74548 backup: Deprecate get/set copy from base controller 2022-06-29 09:39:51 +08:00
Cameron Ball f7189aea98 MDL-74548 backup: Deprecate core_backup\copy\copy 2022-06-29 09:39:49 +08:00
Cameron Ball 58fcbe9678 MDL-74548 backup: Unit tests for course copy refactor 2022-06-29 09:36:06 +08:00
Cameron Ball 4751e672e3 MDL-74548 backup: Refactor course copies
This patch modifies the way copy data is shared in order to mitigate potential race conditions
and ensure that the serialised controller stored in the DB is always in a valid state.

The restore controller is now considered the "source of truth" for all information about the
copy operation. Backup controllers can no longer contain information about course copies.

As copy creation is not atomic, it is still possible for copy controllers to become orphaned or
exist in an invalid state. To mitigate this the backup cleanup task has been modified to call
a new helper method copy_helper::cleanup_orphaned_copy_controllers.

Summary of changes in this patch:

    - Copy data must now be passed through the restore controller's constructor
    - base_controller::get_copy has been deprecated in favour of restore_controller::get_copy
    - base_controller::set_copy has been deprecated without replacement
    - core_backup\copy\copy has been deprecated, use copy_helper.class.php's copy_helper instead
    - backup_cleanup_task will now clean up orphaned controllers from copy operations that went awry

Thanks to Peter Burnett for assiting with testing this patch.
2022-06-29 09:36:06 +08:00
Jun Pataleta ba64cce68d Merge branch 'MDL-74701-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-06-28 23:53:10 +08:00
Jun Pataleta 0d20c1c2d6 Merge branch 'MDL-74906-311' of https://github.com/snake/moodle into MOODLE_311_STABLE 2022-06-28 23:33:29 +08:00
Shamim Rezaie 539d1b3c89 Merge branch 'MDL-73121-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-28 16:09:17 +10:00
Dani Palou 6d047756d2 MDL-74864 forum: Allow specifying group in discussions generator 2022-06-28 07:00:12 +02:00
Jun Pataleta 6ba7009a11 Merge branch 'MDL-68867-311' of https://github.com/lameze/moodle into MOODLE_311_STABLE 2022-06-28 11:23:51 +08:00
Jun Pataleta 56ab65f46a Merge branch 'MDL-74781_311' of https://github.com/aya-saad1/moodle into MOODLE_311_STABLE 2022-06-28 10:45:09 +08:00
Aya Saad ca13d3e05c MDL-74781 search: Fix heading repetition in global search page 2022-06-26 10:37:26 +02:00
Aya Saad df32c00ab5 MDL-74379 language: injecting am/pm in date string
patching the date_format_string() function in moodlelib to add am/pm for languages that don't suuport it.
2022-06-26 10:34:41 +02:00
Shamim Rezaie f375246427 MDL-74741 javascript: Set the role of d&d links to button 2022-06-24 14:27:40 +10:00
Shamim Rezaie 544947c9c7 MDL-74741 javascript: A11y fix for dialogues visible from beginning 2022-06-24 14:26:46 +10:00
Jun Pataleta 1f6ab2b676 weekly release 3.11.7+ 2022-06-24 11:59:10 +08:00
Jun Pataleta 5f098189dd Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-06-24 11:59:09 +08:00
Jun Pataleta 9e530add9e Merge branch 'MDL-69939-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-23 09:53:27 +08:00
Jun Pataleta a349ae01e9 Merge branch 'MDL-74713-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-23 09:51:27 +08:00
Jun Pataleta 99b5fb3a3b Merge branch 'MDL-73156-M311' of https://github.com/michael-milette/moodle into MOODLE_311_STABLE 2022-06-23 09:50:21 +08:00
Simey Lameze a47525cbc9 MDL-68867 calendar: remove dependency on USER->groupmember hack 2022-06-22 07:57:28 +08:00
Jun Pataleta 762fb71a1f Merge branch 'MDL-73212_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-06-21 23:53:43 +08:00
Eloy Lafuente (stronk7) 146d84ebde MDL-73212 gha: Allow parameters to be passed via secret
We are disabling the -v (verbose) option, used by default. Still,
now we support a secret (that can be added to everyone's repository)
to accept any PHPUnit's command line options and run the tests with
them.

Some examples:

phpunit_options = -v (to keep the verbose option enabled)
phpunit_options = --testdox (to print information about every test...)

... (basically anything supported by the CLI)

Also, we are raising here the environment from Ubuntu 18.04 to 20.04

(self tested by GHA, heh)
2022-06-21 16:52:36 +02:00
Jun Pataleta c0b0f6f411 MDL-74812 gradingform_rubric: Add radiogroup role properly
Do not add the radiogroup role to the rubric criterion when the rubric
table is being displayed on edit or preview modes.
2022-06-21 12:33:05 +08:00
Jun Pataleta 6e6260f6d0 MDL-74812 gradingform_rubric: Fix text overlap in rubric levels 2022-06-21 12:33:05 +08:00
Jun Pataleta d0a2de670b MDL-74812 gradingform_rubric: Do not use deprecated width attribute
Use inline CSS style to define level width instead.
2022-06-21 12:33:05 +08:00
Jun Pataleta d82af28545 MDL-74812 gradingform_rubric: Fix contrast issues in rubric table
* Darken the score value using the green theme colour
* Use a light green theme colour for selection backgrounds
* Unify rubric styles related to background and text colour within the
  criteria.
2022-06-21 12:32:22 +08:00
Jun Pataleta ad408bbfdf Merge branch 'MDL-74630-311' of https://github.com/aanabit/moodle into MOODLE_311_STABLE 2022-06-21 10:12:00 +08:00
AMOS bot 0ff0d1d66a Automatically generated installer lang files 2022-06-21 00:09:39 +00:00
Daniil Fajnberg 0957e83d8d MDL-73498 mod_lti: iframe allowed domain fixed 2022-06-20 15:53:13 +02:00
Jun Pataleta 4dd37348b4 Merge branch 'MDL-74358_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-06-20 14:35:56 +08:00
Paul Holden c5c6758ed7 MDL-69939 webservice: correct AJAX bool value in services definition. 2022-06-17 11:03:32 +01:00
Eloy Lafuente (stronk7) 78cbd77c0d MDL-74358 availability: Avoid php8 problem with array_values(null) 2022-06-17 11:09:53 +02:00
Jun Pataleta 8303206ae0 weekly release 3.11.7+ 2022-06-17 15:30:35 +08:00
Eloy Lafuente (stronk7) d13ed5575c Merge branch 'MDL-72324-311-fix' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-17 08:38:59 +02:00
Jun Pataleta 1d40ffaf55 MDL-72324 core: Add upgrade.txt note about $plugin->incompatible 2022-06-17 10:42:29 +08:00
Jun Pataleta 146048903b Merge branch 'MDL-74529-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-17 10:20:47 +08:00
Jun Pataleta 57d119a43f Merge branch 'MDL-72555-311' of https://github.com/laurentdavid/moodle into MOODLE_311_STABLE 2022-06-17 10:20:47 +08:00
Simey Lameze 3b18f7884f MDL-72292 core: add param type and polishing 2022-06-17 09:54:41 +08:00
Alexander Bias 3cc3d83b7e MDL-72292 core: Check if fulldir is set when loading renamed classes 2022-06-17 09:54:40 +08:00
Marina Glancy bd2cb3c4e8 MDL-74972 core_form: frozen autocomplete element does not display values 2022-06-16 10:24:56 +02:00
Paul Holden c8aa905ef0 MDL-74287 forms: request changesmade string as required.
Unconditionally requesting the string was triggering exceptions
during installation, before the required external functions had
been populated.
2022-06-16 08:07:44 +01:00
Paul Holden d1e8870fb5 MDL-74287 media_videojs: skip dynamic loader during install/upgrade. 2022-06-16 08:07:44 +01:00
Michael Milette e34b09be48 MDL-73156 user: Custom user profile field names now filtered. 2022-06-15 11:50:13 -04:00
Jun Pataleta 94d025a912 Merge branch 'MDL-72324-incompatible-check-311' of https://github.com/Peterburnett/moodle into MOODLE_311_STABLE 2022-06-15 23:03:38 +08:00
Jun Pataleta 1a87e306e9 Merge branch 'MDL-73966-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-15 18:06:04 +08:00
Paul Holden 9bbeeaa557 MDL-74713 admin: format custom profile fields in identify config. 2022-06-14 17:19:33 +01:00
Jun Pataleta 598845e3ff Merge branch 'MDL-74790-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-14 22:52:29 +08:00
Jun Pataleta 0c2cd0de2a Merge branch 'MDL-74573_311' of https://github.com/aya-saad1/moodle into MOODLE_311_STABLE 2022-06-14 22:35:25 +08:00
Jun Pataleta 170a12537b Merge branch 'MDL-74649-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-14 22:26:11 +08:00
Víctor Déniz 1662bae0ab Merge branch 'MDL-74449_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-06-14 10:02:10 +01:00
Laurent David a0727a15d5 MDL-72555 block_site_main_menu: Fix activity chooser issue
* When adding the block_site_main_menu on every page, the activity chooser generated
for this entire page is set with courseid = 1. So any activity is then added to the
home page instead of a course.
2022-06-14 10:03:42 +02:00
Jun Pataleta 834e634c9f Merge branch 'MDL-74816-311' of https://github.com/dpalou/moodle into MOODLE_311_STABLE 2022-06-14 13:58:47 +08:00
Amrita ac7eedb851 MDL-74387 url: exception for php to correct icon 2022-06-13 08:53:51 +02:00
Jake Dallimore 78a4febfb4 Merge branch 'MDL_74310_311' of https://github.com/cengage/moodle into MOODLE_311_STABLE 2022-06-13 11:46:24 +08:00
Jake Dallimore 99e43efb1e Merge branch 'MDL69756_MOODLE_311_STABLE' of https://github.com/Amrita1991/moodle into MOODLE_311_STABLE 2022-06-13 11:13:27 +08:00
Jake Dallimore 51c5405e6f Merge branch 'MDL-74718-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-06-13 10:53:45 +08:00
Huong Nguyen 01222cbb06 MDL-74701 core: Fix popover elements are focusable even when hidden 2022-06-13 09:45:37 +07:00
Eloy Lafuente (stronk7) df048de49d MDL-74449 gradebook: Protect flatten_dependencies_array() a little bit
It has been detected that the flatten_dependencies_array() was fragile
and leading to wrong results when some incorrect data was passed to it.

This includes:

- Missing elements.
- Null dependencies.
- Non array dependencies.

While the existing behaviour (testing-wise) has been preserved, now the
situations above are better controlled and the function ignores all
those incorrect cases that shouldn't happen ever.

That implies that a good number of notices/warnings/errors aren't
happening anymore. That was impacting both results (when the problems
were  only notices and warnings) and execution (when the problems
were errors).

Covered with tests.
2022-06-10 18:18:00 +02:00
Sara Arjona 22dffcd0c2 weekly release 3.11.7+ 2022-06-10 17:08:25 +02:00
Sara Arjona e5ec14cc01 Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-06-10 17:08:22 +02:00
Amrita fa82e4aa00 MDL-69756 nextcloud: copy-overwrite handling 2022-06-10 16:30:52 +02:00
Jun Pataleta afa1b6f0ad MDL-74802 core: Remove tooltip on the notification close button
Reverting the addition of a Boostrap tooltip on the alert notification's
close button. It introduced a bug where the tooltip remains after
dismissing the notification alert. We can manually toggle the state of
the tooltip via JS, but I don't think it's worth the effort. The tooltip
is meant as an added bonus for sighted users to see what the close
button is about.
2022-06-10 13:17:01 +02:00
Jun Pataleta 4cb53f71b3 MDL-74802 core_user: Use button label to close notification alert
With the notification alert's close button now properly labelled, it is
better for Behat to interact on it using its label.
2022-06-10 13:17:01 +02:00
Andrew Nicols 7e180482ca MDL-73013 filelib: Fix code lint 2022-06-10 13:17:01 +02:00
Andrew Nicols a9af3c9cd4 MDL-73013 filelib: Address coding style violations 2022-06-10 13:17:01 +02:00
Andrew Nicols a37caf6126 Merge branch 'MDL-73013-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Jake Dallimore 8e0205ec56 Merge branch 'MDL-72377-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Andrew Nicols 3156398c54 Merge branch 'MDL-73466-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Andrew Nicols 21f43574fd Merge branch 'MDL-74764-311' of https://github.com/BruceGoodGuy/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Shamim Rezaie f83929ab57 Merge branch 'MDL-73702-fix_report_helper' of https://github.com/praxisdigital/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Víctor Déniz faa4d5ab56 Merge branch 'MDL-69970_311' of https://github.com/aya-saad1/moodle into MOODLE_311_STABLE 2022-06-10 13:17:00 +02:00
Sara Arjona d89301add2 Merge branch 'MDL-74802-311-2' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-10 13:16:59 +02:00
Sara Arjona 15e127fe7e Merge branch 'MDL-74577-311' of https://github.com/sharidas/moodle into MOODLE_311_STABLE 2022-06-10 13:16:59 +02:00
Jun Pataleta 79b5632ce9 Merge branch 'mdl-69637_311' of https://github.com/james-cnz/moodle into MOODLE_311_STABLE 2022-06-10 13:16:59 +02:00
Angelia Dela Cruz 75715efdfa MDL-74841 behat: Label behat generators use UI
Replace steps that manually add Label instances via the UI and use
Behat generators. This improves the speed of Behat test runs.
2022-06-10 13:34:11 +08:00
Paul Holden d80a7c43dc MDL-74649 course: render scale information using page popup layout. 2022-06-09 12:18:55 +01:00
Jake Dallimore 439e4edc99 MDL-74906 mod_lti: fix form selector in multi-item content item post
Use #region-main-box and not .mform in the selector, otherwise it may
return the wrong mform, such as global search, if enabled. This is the
same way the form is selected in showMultipleSummaryAndHideForm().
2022-06-09 17:06:07 +08:00
Paul Holden a39feaefe7 MDL-74408 core: exclude empty patterns in divert email config. 2022-06-09 09:39:32 +01:00
Sujith Haridasan 8c8e5eba2c MDL-74718 webdav: correct the loop when reading chunks
Adjusted the condition while reading the streams
in chunks. Read till the end to make sure we have got all
the data. Else we might not get all the data to show
in file picker.
2022-06-09 12:03:11 +05:30
Paul Holden 16b9813aae MDL-73466 forumreport_summary: use formatted course module name. 2022-06-08 21:36:46 +01:00
Víctor Déniz 07a07679a1 Merge branch 'MDL-73774-311' of https://github.com/HuongNV13/moodle into MOODLE_311_STABLE 2022-06-08 10:16:01 +01:00
Sara Arjona 1207c31c78 Merge branch 'MDL-74182-311' of https://github.com/ericmerrill/moodle into MOODLE_311_STABLE 2022-06-08 10:41:56 +02:00
Adam Olley c8ade37695 MDL-74886 core_admin: Add unit test
Simple unit test to verify we don't get the TypeError anymore.
2022-06-08 10:08:21 +08:00
Simey Lameze 23bb2275d9 MDL-74886 core_admin: cast value and unit to integer 2022-06-08 10:08:20 +08:00
Peter Burnett 1f7a90fbe2 MDL-72324 upgrade: Fix incompatible check in upgrade to match docs 2022-06-08 10:52:54 +10:00
AMOS bot 82d55b7455 Automatically generated installer lang files 2022-06-08 00:08:14 +00:00
Sara Arjona 064c473a4e Merge branch 'MDL-74344-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-07 16:51:58 +02:00
Sara Arjona bf6e018f9d Merge branch 'MDL-72983-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-07 16:09:01 +02:00
Paul Holden 5c418c72f3 MDL-74529 theme_boost: accessible autolink styles from filters.
The `autolink` class is used by various filter types to create
hyperlinks within text. Extend existing `aalink` class so they
behave in the same way.
2022-06-07 10:57:49 +01:00
Huong Nguyen 47e66ef9d1 MDL-73774 timeline: Prevent ID duplication 2022-06-07 12:05:27 +07:00
Jun Pataleta 335b09205b Merge branch 'MDL-70223_311' of https://github.com/aya-saad1/moodle into MOODLE_311_STABLE 2022-06-07 10:29:38 +08:00
AMOS bot 9b779e3d53 Automatically generated installer lang files 2022-06-07 00:08:10 +00:00
Paul Holden e084b47f92 MDL-72983 tool_dataprivacy: respect capability to export own data. 2022-06-06 20:50:17 +01:00
Paul Holden 44b49b5651 MDL-72377 grade: fix category form hidden/until fields.
Ensure the saved values for the hidden and hidden until fields are
populated when editing a grade category. Fix behaviour on enabling
the hidden until field.

Re-enable tests commented out in eba1d32c.
2022-06-06 15:29:09 +01:00
Paul Holden 2742b32ed8 MDL-72377 grade: increase size of category hidden fields.
As well as storing 1/0 to indicate hidden state, they are also used
to store a timestamp indicating hidden until date. Increasing field
size allows these values to be stored without triggering exceptions.
2022-06-06 15:29:09 +01:00
Paul Holden df6d634d57 MDL-73121 atto_managefiles: match used files enclosed by quotes. 2022-06-06 15:17:26 +01:00
Ilya Tregubov b2b0d0795e Merge branch 'MDL-69951-remove_drop-font-tags-311' of https://github.com/leonstr/moodle into MOODLE_311_STABLE 2022-06-06 11:38:48 +06:00
aya.saad 39f39999be MDL-74573 mod_assign: convert view other attempt link to a button 2022-06-05 09:21:23 +02:00
aya.saad 088519178f MDL-70223 h5p: fix invalid id when adding h5p activity 2022-06-05 09:19:11 +02:00
aya.saad 7ee20257b0 MDL-69970 icons: flip help icon direction in RTL languages 2022-06-05 09:17:02 +02:00
Shamim Rezaie 4fc3052a73 Merge branch 'MDL-74250-311' of https://github.com/adpe/moodle into MOODLE_311_STABLE 2022-06-03 18:42:50 +10:00
Andrew Nicols fc056f1aa6 Merge branch 'MDL-73898-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-03 13:32:24 +08:00
Andrew Nicols 2fe2cd8eab weekly release 3.11.7+ 2022-06-03 11:04:08 +08:00
Andrew Nicols 4c0a1ffaab Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-06-03 11:04:06 +08:00
AMOS bot c9d14b4ce8 Automatically generated installer lang files 2022-06-03 00:08:06 +00:00
Jun Pataleta 6368b3f055 Merge branch 'MDL-74631-invalid-tag-311' of https://github.com/leonstr/moodle into MOODLE_311_STABLE 2022-06-02 12:20:33 +08:00
Jun Pataleta 544d1ab453 Merge branch 'MDL-57065-311' of https://github.com/ferranrecio/moodle into MOODLE_311_STABLE 2022-06-02 12:03:27 +08:00
Jun Pataleta 4ba43b851d Merge branch 'MDL-71301-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-02 11:22:49 +08:00
Issam Taboubi fbbb7da0f6 MDL-71301 qtype_gapselect: Make blank answer box labels more meaningful 2022-06-02 10:51:26 +08:00
Jun Pataleta e78978ec6b Merge branch 'MDL-67966-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-06-02 10:30:09 +08:00
Joshua Ebarvia 394f65e91e MDL-67966 mod_workshop: Use condition to verify form is using editor
This adds a condition to check if Online text is used
for the submission. The functions file_postupdate_standard_editor
and file_postupdate_standard_filemanager needs the property
content_editor of the formdata.
2022-06-02 10:28:24 +08:00
Sara Arjona 2432ac2c08 Merge branch 'MDL-71276-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-06-01 18:38:00 +02:00
Noel De Martin 986cf06e55 MDL-74613 grade: Add missing generators 2022-05-31 18:13:48 +02:00
Amaia Anabitarte 3619147c76 MDL-74630 core_contenbank: Add contextid to URL parameters 2022-05-31 09:49:49 +02:00
AMOS bot de03dfa066 Automatically generated installer lang files 2022-05-31 00:08:08 +00:00
AMOS bot bd9c3fd5db Automatically generated installer lang files 2022-05-30 00:08:02 +00:00
AMOS bot e6b39085a8 Automatically generated installer lang files 2022-05-28 00:08:10 +00:00
Jun Pataleta 3c982ce134 MDL-72885 output: Add lang attribute for language custom menu items 2022-05-27 19:44:17 +08:00
Jun Pataleta eefd6bbf54 MDL-72885 output: Allow additional attributes for custom menu items
* Plus don't render the link title if it's the same as the link text.
2022-05-27 19:44:17 +08:00
Adrian Perez b5157c8153 MDL-74250 core: Improve indicator that link opens in new window 2022-05-27 07:21:43 +02:00
Khoa Nguyen Dang 53cc3870e1 MDL-74764 core_course: Activity is not in alphabetical order. 2022-05-27 11:07:38 +07:00
Jake Dallimore 72b408772c weekly release 3.11.7+ 2022-05-27 10:02:13 +08:00
Noel De Martin b08d4ea2ed MDL-74220 data: Implement behat generators 2022-05-26 10:39:14 +02:00
Jake Dallimore 0ed76e9316 Merge branch 'MDL-73801-311' of https://github.com/paulholden/moodle into MOODLE_311_STABLE 2022-05-26 12:12:17 +08:00
Jake Dallimore 3cca8ba5d8 Merge branch 'MDL-73386-311' of https://github.com/junpataleta/moodle into MOODLE_311_STABLE 2022-05-26 11:47:48 +08:00
Dani Palou bfad8c4dd1 MDL-74816 mod_resource: Allow specify default file name in generator 2022-05-25 10:41:37 +02:00
Paul Holden da60508071 MDL-74790 mod_resource: better detection of empty module intro. 2022-05-24 21:21:40 +01:00
Angelia Dela Cruz ca14e2d950 MDL-74744 behat: Quiz behat generators use UI
Replace steps that manually add Quiz instances via the UI and use
Behat generators. This improves the speed of Behat test runs.
2022-05-24 10:52:04 +08:00
Jun Pataleta a7db400e61 MDL-74802 core: Improve the accessibility of alert notifications
* Make the ordering of the message and the close button logical on
  the DOM.
* Hide the times HTML entity
* Add sr-only label on the close button for non-sighted users
* Add tooltip on the close button sighted users
2022-05-23 13:01:32 +08:00
Daniel Ziegenberg 59d7b57a7a MDL-74835 ci: Update nodejs version in travis integration to lts/gallium
In MDL-73915 the nodejs version was switched to lts/gallium but the
travis integration was not updated.

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2022-05-22 23:51:53 +02:00
Jun Pataleta 4bdedd7d56 MDL-73386 mod_quiz: Use plain text for quiz navigation fake block title
* No need to enclose the title of the quiz navigation fake block in
a span tag. The block title also gets appended to the skip link which
means that a block title with a span tag assigned with an identifier
can cause duplicate ID errors on the DOM.
2022-05-21 00:33:46 +08:00
Sujith Haridasan dbe2390e97 MDL-74577 core: Reset login_failed_count_since_success after login
When the user is logged in successfully then reset the value
of login_failed_count_since_success to zero, if the value of
login_failed_count_since_success is greater than zero.
2022-05-20 10:14:08 +05:30
james-cnz b24bef6b97 MDL-69637 course: Avoid unnecessary aria labels 2022-05-20 10:09:05 +12:00
Ilya Tregubov 2affa30359 weekly release 3.11.7+ 2022-05-19 19:24:34 +06:00
Ilya Tregubov 83ccb2913b Merge branch 'install_311_STABLE' of https://git.in.moodle.com/amosbot/moodle-install into MOODLE_311_STABLE 2022-05-19 19:24:32 +06:00
Paul Holden a2a37f3cb5 MDL-73801 backup: set predictably ordered backup next start time.
Prior to this change, the testcase would assert ordering based on
identical fields which could lead to random failures. Set distinct
next start time of course backup, and also remove random ordering
by sorting on defined course order (all other fields being equal).
2022-05-19 08:18:56 +01:00
Jun Pataleta b388341f47 Merge branch 'MDL-73163-311' of https://github.com/lameze/moodle into MOODLE_311_STABLE 2022-05-19 10:11:09 +08:00
Jun Pataleta 7261abf98d Merge branch 'MDL-74416-311' of https://github.com/lameze/moodle into MOODLE_311_STABLE 2022-05-19 09:53:49 +08:00
Paul Holden 10de05f5d6 MDL-73966 grade: fetch required user name fields of unenrolled users. 2022-05-17 16:03:12 +01:00
AMOS bot 4091db771e Automatically generated installer lang files 2022-05-17 00:07:36 +00:00
Paul Holden 8978466354 MDL-71276 message_email: include alternate email in privacy export. 2022-05-16 09:41:39 +01:00
Paul Holden 590088f118 MDL-74344 comment: consistent capability check for accessing report.
Co-authored-by: David Wipperfurth <dwipperfurth@webcourseworks.com>
2022-05-13 10:31:24 +01:00
AMOS bot 796a14a5ce Automatically generated installer lang files 2022-05-13 00:07:35 +00:00
Paul Holden 9b302f133a MDL-73013 calendar: fix serving of files added to category events. 2022-05-12 16:12:23 +01:00
Jun Pataleta b8e9cb31e9 weekly release 3.11.7+ 2022-05-12 22:16:09 +08:00
Leon Stringer 972744ee12 MDL-69951 filter_tidy: Replace drop-font-tags
The option drop-font-tags was removed in HTML Tidy version 5.5.14.  It
had been deprecated since 5.1.25, the docs said "Use the clean option
instead" which is what this commit does (see
https://api.html-tidy.org/tidy/quickref_5.1.25.html#drop-font-tags).
2022-05-12 11:36:55 +01:00
Jun Pataleta 98104be4f4 Merge branch 'MDL-74413_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-05-12 12:08:48 +08:00
Jun Pataleta e7e690e3b8 Merge branch 'MDL-73971_311' of https://github.com/stronk7/moodle into MOODLE_311_STABLE 2022-05-12 11:54:30 +08:00
Kordan 6ded74cc2a MDL-73163 behat: Changed most to must 2022-05-12 10:11:46 +08:00
Petr Skoda 1099b3f022 MDL-74416 phpunit: fix generator counters reset 2022-05-12 10:10:21 +08:00
Paul Holden 93315ab389 MDL-73898 user: exclude guest user from participants table. 2022-05-10 17:21:10 +01:00
Eloy Lafuente (stronk7) 875591f589 MDL-74413 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

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

Special mention to:

- Moved to the level2 "privacy" namespace:
  - \mod_assign\privacy\feedback_legacy_polyfill_test
  - \mod_assign\privacy\submission_legacy_polyfill_test

- Moved to the level2 "task" namespace:
  - \core_message\task\migrate_message_data_test
  - \ltiservice_gradebookservices\task\cleanup_test
  - \message_email\task\send_email_test
  - \mod_lti\task\clean_access_tokens_test
  - \mod_workshop\task\cron_task_test

- Moved to the level2 "event" namespace:
  - \core_h5p\event\deleted_test
  - \core_h5p\event\viewed_test

- Renamed to a better name:
  - backup_forum_activity_task_test.php (missing "task")
2022-05-07 20:33:48 +02:00
Jun Pataleta 4d48741ed7 Moodle release 3.11.7 2022-05-07 19:34:59 +08:00
Eloy Lafuente (stronk7) 1c33085ede MDL-73971 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

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

Special mention to:

- Some fixtures, initially defined in the test files have been
  moved to new files in fixtures subdirectory, leaving the unit
  test files clearer:
  - moodle2_course_format_test.php
- Rename wrong named test:
  - baseoptiogroup_test = baseoptigroup_test
2022-05-06 18:29:24 +02:00
Eloy Lafuente (stronk7) 199974b45d weekly release 3.11.6+ 2022-05-06 15:58:35 +02:00
Ferran Recio 464a4cb4d5 MDL-57065 theme_boost: fix debug messages
The first debug message is covered by the top navbar header. This patch
will move the body's first debug message down below the navbar.
2022-05-06 12:27:21 +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
Leon Stringer 8a6e4904bf MDL-74631 mod_lti: Remove </img>
Remove illegal HTML tag.

Added example context to pass CI checks.
2022-05-03 17:30:36 +01: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
Claude Vervoort 411416a37a MDL-74310 mod_lti: fix ltilinkid on lineitems import 2022-03-23 16:38:56 -04: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
Eric Merrill 313aedcf13 MDL-74182 core_task: Obey CFG debug settings 2022-03-13 23:57:27 -04: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
Frederik Milling Pytlick c73673f2f3 MDL-73702 reports: Fixed report_helper
Made the report_helper make sure there was an action before trying to output it
2022-01-27 11:04:27 +01:00
Max Larkin 4c53ddf46b MDL-73555 tool_brickfield: More efficient summary data processing 2022-01-20 11:42:21 -05:00
1430 changed files with 11022 additions and 6923 deletions
+5 -4
View File
@@ -13,7 +13,7 @@ env:
jobs:
Grunt:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Checking out code
@@ -54,11 +54,11 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
php: 7.3
extensions:
db: mysqli
- os: ubuntu-18.04
- os: ubuntu-20.04
php: 8.0
db: pgsql
extensions: xmlrpc-beta
@@ -111,4 +111,5 @@ jobs:
- name: Running PHPUnit tests
env:
dbtype: ${{ matrix.db }}
run: vendor/bin/phpunit -v
phpunit_options: ${{ secrets.phpunit_options }}
run: vendor/bin/phpunit $phpunit_options
+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>
+2 -2
View File
@@ -36,7 +36,7 @@ jobs:
- php: 7.3
env: DB=none TASK=CITEST
- php: 7.3
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
env: DB=none TASK=GRUNT NVM_VERSION='lts/gallium'
- if: env(MOODLE_DATABASE) = "pgsql" OR env(MOODLE_DATABASE) = "all" OR env(MOODLE_DATABASE) IS NOT present
php: 7.3
@@ -52,7 +52,7 @@ jobs:
env: DB=none TASK=CITEST
- if: env(MOODLE_PHP) = "all"
php: 8.0
env: DB=none TASK=GRUNT NVM_VERSION='lts/carbon'
env: DB=none TASK=GRUNT NVM_VERSION='lts/gallium'
- if: env(MOODLE_PHP) = "all" AND (env(MOODLE_DATABASE) = "pgsql" OR env(MOODLE_DATABASE) = "all" OR env(MOODLE_DATABASE) IS NOT present)
php: 8.0
+2 -2
View File
@@ -69,11 +69,11 @@ if ($options['help'] or (!$options['list'] and !$options['execute'])) {
die;
}
if ($options['showdebugging']) {
if ($options['showdebugging'] || !empty($CFG->showcrondebugging)) {
set_debugging(DEBUG_DEVELOPER, true);
}
if ($options['showsql']) {
if ($options['showsql'] || !empty($CFG->showcronsql)) {
$DB->set_debug(true);
}
if ($options['list']) {
+7 -7
View File
@@ -14,19 +14,19 @@
// 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_role;
use core_role_preset;
/**
* Role XML presets test case.
*
* @package core_role
* @category phpunit
* @category test
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class core_role_preset_testcase extends advanced_testcase {
class preset_test extends \advanced_testcase {
public function test_xml() {
global $DB;
@@ -61,7 +61,7 @@ class core_role_preset_testcase extends advanced_testcase {
FROM {role_capabilities}
WHERE contextid = :syscontext AND roleid = :roleid
ORDER BY capability ASC",
array('syscontext'=>context_system::instance()->id, 'roleid'=>$role->id));
array('syscontext' => \context_system::instance()->id, 'roleid' => $role->id));
foreach ($capabilities as $cap) {
$this->assertEquals($cap->permission, $info['permissions'][$cap->capability]);
+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.
+11 -1
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');
@@ -485,7 +492,10 @@ if ($hassiteconfig && !empty($CFG->enableplagiarism)) {
$plugin->load_settings($ADMIN, 'plagiarism', $hassiteconfig);
}
}
$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot.'/comment/', 'moodle/site:viewreports'));
// Comments report, note this page is really just a means to delete comments so check that.
$ADMIN->add('reports', new admin_externalpage('comments', new lang_string('comments'), $CFG->wwwroot . '/comment/index.php',
'moodle/comment:delete'));
// Course reports settings
if ($hassiteconfig) {
+2 -1
View File
@@ -236,7 +236,8 @@ if ($hassiteconfig
if ($field->param2 > 255 || $field->datatype != 'text') {
continue;
}
$fields['profile_field_' . $field->shortname] = $field->name . ' *';
$fields['profile_field_' . $field->shortname] = format_string($field->name, true,
['context' => context_system::instance()]) . ' *';
}
return $fields;
+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
@@ -20,9 +20,10 @@ Feature: Forms manipulation
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Quiz" to section "1"
And the following "activities" exist:
| activity | course | section | name |
| quiz | C1 | 1 | Quiz 1 |
And I am on the "Quiz 1" "quiz activity editing" page logged in as admin
When I expand all fieldsets
Then I should see "Close the quiz"
And I should see "Group mode"
+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));
}
+13 -1
View File
@@ -786,6 +786,18 @@ class api {
return true;
}
/**
* Check if user has permission to create data download request for themselves
*
* @param int|null $userid
* @return bool
*/
public static function can_create_data_download_request_for_self(int $userid = null): bool {
global $USER;
$userid = $userid ?: $USER->id;
return has_capability('tool/dataprivacy:downloadownrequest', \context_user::instance($userid), $userid);
}
/**
* Check if user has permisson to create data deletion request for themselves.
*
@@ -847,7 +859,7 @@ class api {
$usercontext = \context_user::instance($userid);
// If it's your own and you have the right capability, you can download it.
if ($userid == $downloaderid && has_capability('tool/dataprivacy:downloadownrequest', $usercontext, $downloaderid)) {
if ($userid == $downloaderid && self::can_create_data_download_request_for_self($downloaderid)) {
return true;
}
// If you can download anyone's in that context, you can download it.
@@ -96,6 +96,11 @@ if ($data = $mform->get_data()) {
throw new moodle_exception('nopermissions', 'error', '',
get_string('errorcannotrequestdeleteforother', 'tool_dataprivacy'));
}
} else if ($data->type == \tool_dataprivacy\api::DATAREQUEST_TYPE_EXPORT) {
if ($data->userid == $USER->id && !\tool_dataprivacy\api::can_create_data_download_request_for_self()) {
throw new moodle_exception('nopermissions', 'error', '',
get_string('errorcannotrequestexportforself', 'tool_dataprivacy'));
}
}
\tool_dataprivacy\api::create_data_request($data->userid, $data->type, $data->comments);
@@ -97,10 +97,11 @@ class tool_dataprivacy_data_request_form extends \core\form\persistent {
$mform->setType('userid', PARAM_INT);
// Subject access request type.
$options = [
api::DATAREQUEST_TYPE_EXPORT => get_string('requesttypeexport', 'tool_dataprivacy'),
api::DATAREQUEST_TYPE_DELETE => get_string('requesttypedelete', 'tool_dataprivacy')
];
$options = [];
if ($this->manage || api::can_create_data_download_request_for_self()) {
$options[api::DATAREQUEST_TYPE_EXPORT] = get_string('requesttypeexport', 'tool_dataprivacy');
}
$options[api::DATAREQUEST_TYPE_DELETE] = get_string('requesttypedelete', 'tool_dataprivacy');
$mform->addElement('select', 'type', get_string('requesttype', 'tool_dataprivacy'), $options);
$mform->addHelpButton('type', 'requesttype', 'tool_dataprivacy');
@@ -174,7 +175,7 @@ class tool_dataprivacy_data_request_form extends \core\form\persistent {
$errors['type'] = get_string('errorrequestalreadyexists', 'tool_dataprivacy');
}
// Check if current user can create data deletion request.
// Check if current user can create data requests.
if ($data->type == api::DATAREQUEST_TYPE_DELETE) {
if ($userid == $USER->id) {
if (!api::can_create_data_deletion_request_for_self()) {
@@ -184,6 +185,10 @@ class tool_dataprivacy_data_request_form extends \core\form\persistent {
&& !api::can_create_data_deletion_request_for_children($userid)) {
$errors['type'] = get_string('errorcannotrequestdeleteforother', 'tool_dataprivacy');
}
} else if ($data->type == api::DATAREQUEST_TYPE_EXPORT) {
if ($userid == $USER->id && !api::can_create_data_download_request_for_self()) {
$errors['type'] = get_string('errorcannotrequestexportforself', 'tool_dataprivacy');
}
}
return $errors;
@@ -135,6 +135,7 @@ $string['effectiveretentionperioduser'] = '{$a} (since the last time the user ac
$string['emailsalutation'] = 'Dear {$a},';
$string['errorcannotrequestdeleteforself'] = 'You don\'t have permission to create deletion request for yourself.';
$string['errorcannotrequestdeleteforother'] = 'You don\'t have permission to create deletion request for this user.';
$string['errorcannotrequestexportforself'] = 'You don\'t have permission to create export request for yourself.';
$string['errorcontactdpodisabled'] = 'The option to contact the privacy officer is disabled.';
$string['errorinvalidrequestcomments'] = 'The comments field may contain plain text only.';
$string['errorinvalidrequestcreationmethod'] = 'Invalid request creation method!';
+3 -2
View File
@@ -68,8 +68,9 @@ function tool_dataprivacy_myprofile_navigation(tree $tree, $user, $iscurrentuser
// Check if the user has an ongoing data export request.
$hasexportrequest = \tool_dataprivacy\api::has_ongoing_request($user->id, \tool_dataprivacy\api::DATAREQUEST_TYPE_EXPORT);
// Show data export link only if the user doesn't have an ongoing data export request.
if (!$hasexportrequest) {
// Show data export link only if the user doesn't have an ongoing data export request and has permission
// to download own data.
if (!$hasexportrequest && \tool_dataprivacy\api::can_create_data_download_request_for_self()) {
$exportparams = ['type' => \tool_dataprivacy\api::DATAREQUEST_TYPE_EXPORT];
$exporturl = new moodle_url('/admin/tool/dataprivacy/createdatarequest.php', $exportparams);
$exportnode = new core_user\output\myprofile\node('privacyandpolicies', 'requestdataexport',
+22
View File
@@ -26,6 +26,7 @@ use tool_dataprivacy\task\process_data_request_task;
* API tests.
*
* @package tool_dataprivacy
* @covers \tool_dataprivacy\api
* @copyright 2018 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -2174,6 +2175,27 @@ class api_test extends \advanced_testcase {
return $request;
}
/**
* Test whether user can create data download request for themselves
*/
public function test_can_create_data_download_request_for_self(): void {
global $DB;
$this->resetAfterTest();
$user = $this->getDataGenerator()->create_user();
$this->setUser($user);
// The default user role allows for the creation of download data requests.
$this->assertTrue(api::can_create_data_download_request_for_self());
// Prohibit that capability.
$userrole = $DB->get_field('role', 'id', ['shortname' => 'user'], MUST_EXIST);
assign_capability('tool/dataprivacy:downloadownrequest', CAP_PROHIBIT, $userrole, \context_user::instance($user->id));
$this->assertFalse(api::can_create_data_download_request_for_self());
}
/**
* Test user cannot create data deletion request for themselves if they don't have
* "tool/dataprivacy:requestdelete" capability.
@@ -14,17 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the data_registry class.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use \tool_dataprivacy\data_registry;
namespace tool_dataprivacy;
/**
* Unit tests for the data_registry class.
@@ -33,7 +23,7 @@ use \tool_dataprivacy\data_registry;
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_dataregistry_testcase extends advanced_testcase {
class data_registry_test extends \advanced_testcase {
/**
* Ensure that the get_effective_context_value only errors if provided an inappropriate element.
@@ -41,7 +31,7 @@ class tool_dataprivacy_dataregistry_testcase extends advanced_testcase {
* This test is not great because we only test a limited set of values. This is a fault of the underlying API.
*/
public function test_get_effective_context_value_invalid_element() {
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
data_registry::get_effective_context_value(\context_system::instance(), 'invalid');
}
@@ -51,7 +41,7 @@ class tool_dataprivacy_dataregistry_testcase extends advanced_testcase {
* This test is not great because we only test a limited set of values. This is a fault of the underlying API.
*/
public function test_get_effective_contextlevel_value_invalid_element() {
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
data_registry::get_effective_contextlevel_value(\context_system::instance(), 'invalid');
}
}
@@ -14,19 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for the data_request persistent.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;
use data_privacy_testcase;
defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');
use tool_dataprivacy\api;
/**
* Tests for the data_request persistent.
*
@@ -34,7 +28,7 @@ use tool_dataprivacy\api;
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_data_request_testcase extends data_privacy_testcase {
class data_request_test extends data_privacy_testcase {
/**
* Data provider for testing is_resettable, and is_active.
@@ -14,25 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Expired contexts tests.
*
* @package tool_dataprivacy
* @copyright 2018 David Monllao
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use tool_dataprivacy\api;
use tool_dataprivacy\data_registry;
use tool_dataprivacy\expired_context;
use tool_dataprivacy\purpose;
use tool_dataprivacy\purpose_override;
use tool_dataprivacy\category;
use tool_dataprivacy\contextlevel;
use tool_dataprivacy\expired_contexts_manager;
defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_dataprivacy;
/**
* Expired contexts tests.
@@ -41,7 +23,7 @@ global $CFG;
* @copyright 2018 David Monllao
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
class expired_contexts_test extends \advanced_testcase {
/**
* Setup the basics with the specified retention period.
@@ -14,21 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Expired data requests tests.
*
* @package tool_dataprivacy
* @copyright 2018 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;
use tool_dataprivacy\api;
use tool_dataprivacy\category;
use tool_dataprivacy\data_request;
use tool_dataprivacy\purpose;
use data_privacy_testcase;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once('data_privacy_testcase.php');
@@ -39,7 +29,7 @@ require_once('data_privacy_testcase.php');
* @copyright 2018 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testcase {
class expired_data_requests_test extends data_privacy_testcase {
/**
* Test tearDown.
@@ -59,7 +49,7 @@ class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testc
// Set up test users.
$this->setAdminUser();
$studentuser = $this->getDataGenerator()->create_user();
$studentusercontext = context_user::instance($studentuser->id);
$studentusercontext = \context_user::instance($studentuser->id);
$dpouser = $this->getDataGenerator()->create_user();
$this->assign_site_dpo($dpouser);
@@ -14,13 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the filtered_userlist.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;
/**
* Unit tests for the filtered_userlist.
@@ -29,7 +23,7 @@
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_filtered_userlist_testcase extends advanced_testcase {
class filtered_userlist_test extends \advanced_testcase {
/**
* Test the apply_expired_contexts_filters function with arange of options.
*
@@ -14,6 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_dataprivacy;
use data_privacy_testcase;
defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');
/**
* Tests for the manager observer.
*
@@ -21,18 +28,7 @@
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');
/**
* API tests.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_manager_observer_testcase extends data_privacy_testcase {
class manager_observer_test extends data_privacy_testcase {
/**
* Ensure that when users are configured as DPO, they are sent an message upon failure.
*/
@@ -14,16 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Metadata registry tests.
*
* @package tool_dataprivacy
* @copyright 2018 Adrian Greeve <adriangreeve.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_dataprivacy;
/**
* Metadata registry tests.
@@ -32,7 +23,7 @@ global $CFG;
* @copyright 2018 Adrian Greeve <adriangreeve.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_metadata_registry_testcase extends advanced_testcase {
class metadata_registry_test extends \advanced_testcase {
/**
* Fetch the meta data and return it in a form that we can easily unit test.
@@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for the event observer.
*
* @package tool_dataprivacy
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;
defined('MOODLE_INTERNAL') || die();
use \tool_dataprivacy\event\user_deleted_observer;
use \tool_dataprivacy\api;
use tool_dataprivacy\event\user_deleted_observer;
/**
* Event observer test.
@@ -34,7 +25,7 @@ use \tool_dataprivacy\api;
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase {
class user_deleted_observer_test extends \advanced_testcase {
/**
* Ensure that a delete data request is created upon user deletion.
+6
View File
@@ -0,0 +1,6 @@
This file describes API changes in /admin/tool/dataprivacy/*
Information provided here is intended especially for developers.
=== 3.11.8 ===
* New `api::can_create_data_download_request_for_self` method for determining whether user has permission to create their
own data download requests
@@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
namespace tool_generator;
use tool_generator_course_backend;
/**
* Automated unit testing. This tests the 'make large course' backend,
@@ -24,7 +26,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_generator_maketestcourse_testcase extends advanced_testcase {
class maketestcourse_test extends \advanced_testcase {
/**
* Creates a small test course and checks all the components have been put in place.
*/
@@ -52,7 +54,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
// Get course details.
$course = get_course($courseid);
$context = context_course::instance($courseid);
$context = \context_course::instance($courseid);
$modinfo = get_fast_modinfo($course);
// Check course names.
@@ -88,7 +90,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
// Check it contains 2 files (the default txt and a dat file).
$fs = get_file_storage();
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
$files = array_values($files);
$this->assertEquals(2, count($files));
@@ -106,7 +108,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
$this->assertTrue($ok);
// Check it contains 2 files.
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
$files = array_values($files);
$this->assertEquals(2, count($files));
@@ -155,7 +157,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
$lastusernumber = 0;
$discussionstarters = array();
foreach ($discussions as $discussion) {
$usernumber = core_user::get_user($discussion->userid, 'id, idnumber')->idnumber;
$usernumber = \core_user::get_user($discussion->userid, 'id, idnumber')->idnumber;
// Checks that the users are odd numbers.
$this->assertEquals(1, $usernumber % 2);
@@ -190,7 +192,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
$fs = get_file_storage();
$resources = $modinfo->get_instances_of('resource');
foreach ($resources as $resource) {
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
foreach ($files as $file) {
if ($file->get_mimetype() == 'application/octet-stream') {
@@ -210,7 +212,7 @@ class tool_generator_maketestcourse_testcase extends advanced_testcase {
$fs = get_file_storage();
$resources = $modinfo->get_instances_of('resource');
foreach ($resources as $resource) {
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
foreach ($files as $file) {
if ($file->get_mimetype() == 'application/octet-stream') {
@@ -22,27 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_generator;
use tool_generator_site_backend;
defined('MOODLE_INTERNAL') || die();
/**
* Silly class to access site_backend internal methods.
*
* @package tool_generator
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_tool_generator_site_backend extends tool_generator_site_backend {
/**
* Public accessor.
*
* @return int
*/
public static function get_last_testcourse_id() {
return parent::get_last_testcourse_id();
}
}
/**
* Unit test for the site generator
*
@@ -50,7 +35,7 @@ class testable_tool_generator_site_backend extends tool_generator_site_backend {
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_generator_maketestsite_testcase extends advanced_testcase {
class maketestsite_test extends \advanced_testcase {
/**
* Checks that site courses shortnames are properly generated.
@@ -102,5 +87,22 @@ class tool_generator_maketestsite_testcase extends advanced_testcase {
$lastshortname = testable_tool_generator_site_backend::get_last_testcourse_id();
$this->assertEquals(20, $lastshortname);
}
}
/**
* Silly class to access site_backend internal methods.
*
* @copyright 2013 David Monllaó
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_tool_generator_site_backend extends tool_generator_site_backend {
/**
* Public accessor.
*
* @return int
*/
public static function get_last_testcourse_id() {
return parent::get_last_testcourse_id();
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 207 B

After

Width:  |  Height:  |  Size: 329 B

+1 -1
View File
@@ -1,3 +1,3 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M16 9v6c0 .5-.5 1-1 1H1c-.5 0-1-.5-1-1V9c0-.5.5-1 1-1h1c.5 0 1 .5 1 1v4h10V9c0-.5.5-1 1-1h1c.5 0 1 .5 1 1zm-3.6-3.9l-.7-.7c-.4-.4-1-.4-1.4 0l-.8.8V1c0-.5-.4-1-1-1h-1c-.5 0-1 .5-1 1v4.2l-.8-.8c-.4-.4-1-.4-1.4 0l-.7.7c-.4.4-.4 1 0 1.4l3.7 3.7c.2.2.5.3.7.3.3 0 .5-.1.7-.3l3.7-3.7c.4-.3.4-1 0-1.4z" fill="#999"/></svg>
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M16 9v6c0 .5-.5 1-1 1H1c-.5 0-1-.5-1-1V9c0-.5.5-1 1-1h1c.5 0 1 .5 1 1v4h10V9c0-.5.5-1 1-1h1c.5 0 1 .5 1 1zm-3.6-3.9l-.7-.7c-.4-.4-1-.4-1.4 0l-.8.8V1c0-.5-.4-1-1-1h-1c-.5 0-1 .5-1 1v4.2l-.8-.8c-.4-.4-1-.4-1.4 0l-.7.7c-.4.4-.4 1 0 1.4l3.7 3.7c.2.2.5.3.7.3.3 0 .5-.1.7-.3l3.7-3.7c.4-.3.4-1 0-1.4z" fill="#888"/></svg>

Before

Width:  |  Height:  |  Size: 618 B

After

Width:  |  Height:  |  Size: 618 B

@@ -15,14 +15,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the unit tests class and some helper classes
*
* @package tool_installaddon
* @category test
* @copyright 2013 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_installaddon;
use testable_tool_installaddon_installer;
use tool_installaddon_installer;
defined('MOODLE_INTERNAL') || die();
@@ -32,10 +28,12 @@ require_once(__DIR__.'/fixtures/testable_installer.php');
/**
* Unit tests for the {@link tool_installaddon_installer} class
*
* @package tool_installaddon
* @category test
* @copyright 2013 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_installaddon_installer_testcase extends advanced_testcase {
class installer_test extends \advanced_testcase {
public function test_get_addons_repository_url() {
$installer = testable_tool_installaddon_installer::instance();
+5 -3
View File
@@ -22,15 +22,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace tool_langimport;
/**
* Tests for \tool_langimport\locale class.
*
* @package tool_langimport
* @category test
* @copyright 2018 Université Rennes 2 {@link https://www.univ-rennes2.fr}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class locale_testcase extends \advanced_testcase {
class locale_test extends \advanced_testcase {
/**
* Test that \tool_langimport\locale::check_locale_availability() works as expected.
*
@@ -65,7 +67,7 @@ class locale_testcase extends \advanced_testcase {
// Test an invalid parameter.
$locale = new \tool_langimport\locale();
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
$locale->check_locale_availability('');
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 510 B

+1 -1
View File
@@ -9,7 +9,7 @@
xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<defs>
</defs>
<path style="fill:#999999;" d="M8.5,9.5C8.8,10,9,10.6,9,11.2c0,0.6-0.3,1.1-0.7,1.6l-2.5,2.5C5.2,15.8,4.7,16,4,16
<path style="fill:#888;" d="M8.5,9.5C8.8,10,9,10.6,9,11.2c0,0.6-0.3,1.1-0.7,1.6l-2.5,2.5C5.2,15.8,4.7,16,4,16
s-1.3-0.2-1.7-0.7l-1.5-1.5C0.2,13.3,0,12.7,0,12c0-0.7,0.2-1.3,0.7-1.7l2.5-2.5C3.7,7.3,4.3,7,5,7c0.5,0,1,0.2,1.5,0.5l-1,1
C5.3,8.5,5.2,8.4,5,8.4c-0.3,0-0.5,0.1-0.8,0.3l-2.5,2.5c-0.2,0.2-0.3,0.5-0.3,0.7c0,0.3,0.1,0.5,0.3,0.7l1.5,1.5
c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l2.5-2.5c0.2-0.2,0.3-0.5,0.3-0.8c0-0.2,0-0.3-0.1-0.4L8.5,9.5z M5,10L10,5

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

+2 -1
View File
@@ -27,7 +27,8 @@ require_once($CFG->libdir . '/externallib.php');
$userid = required_param('userid', PARAM_INT); // The user id the key belongs to (for double-checking).
$key = required_param('key', PARAM_ALPHANUMEXT); // The key generated by the tool_mobile_external::get_autologin_key() external function.
$urltogo = optional_param('urltogo', $CFG->wwwroot, PARAM_URL); // URL to redirect.
$urltogo = optional_param('urltogo', $CFG->wwwroot, PARAM_LOCALURL); // URL to redirect.
$urltogo = $urltogo ?: $CFG->wwwroot;
$context = context_system::instance();
$PAGE->set_context($context);
@@ -14,14 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for event observers.
*
* @package tool_monitor
* @category test
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_monitor;
defined('MOODLE_INTERNAL') || die();
@@ -30,11 +23,14 @@ require_once($CFG->dirroot . '/blog/locallib.php');
require_once($CFG->dirroot . '/blog/lib.php');
/**
* Class tool_monitor_eventobservers_testcase
* Unit tests for event observers.
*
* Tests for event observers
* @package tool_monitor
* @category test
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_monitor_eventobservers_testcase extends advanced_testcase {
class eventobservers_test extends \advanced_testcase {
/**
* Set up method.
*/
@@ -57,12 +53,12 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$course2 = $this->getDataGenerator()->create_course();
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = $course1->id;
$rule->plugin = 'test';
$sub = new stdClass();
$sub = new \stdClass();
$sub->courseid = $course1->id;
$sub->userid = $user->id;
@@ -83,7 +79,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
}
// Add a site rule.
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = 0;
$rule->plugin = 'core';
@@ -135,7 +131,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
// Fire a bunch of events.
// Trigger a bunch of other events.
$eventparams = array(
'context' => context_course::instance($course->id)
'context' => \context_course::instance($course->id)
);
for ($i = 0; $i < 5; $i++) {
\core\event\course_viewed::create($eventparams)->trigger();
@@ -148,14 +144,14 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$this->assertEquals(0, $DB->count_records('tool_monitor_events'));
// Now, let's create a rule so an event can be stored.
$rule = new stdClass();
$rule = new \stdClass();
$rule->courseid = $course->id;
$rule->plugin = 'mod_book';
$rule->eventname = '\mod_book\event\course_module_instance_list_viewed';
$rule = $monitorgenerator->create_rule($rule);
// Let's subscribe to this rule.
$sub = new stdClass;
$sub = new \stdClass;
$sub->courseid = $course->id;
$sub->ruleid = $rule->id;
$sub->userid = $user->id;
@@ -187,14 +183,14 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$DB->delete_records('tool_monitor_events');
// Now, let's create a site wide rule.
$rule = new stdClass();
$rule = new \stdClass();
$rule->courseid = 0;
$rule->plugin = 'mod_book';
$rule->eventname = '\mod_book\event\course_module_instance_list_viewed';
$rule = $monitorgenerator->create_rule($rule);
// Let's subscribe to this rule.
$sub = new stdClass;
$sub = new \stdClass;
$sub->courseid = 0;
$sub->ruleid = $rule->id;
$sub->userid = $user->id;
@@ -231,14 +227,14 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$toolgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rulerecord = new stdClass();
$rulerecord = new \stdClass();
$rulerecord->courseid = $course->id;
$rulerecord->eventname = '\mod_book\event\course_module_instance_list_viewed';
$rulerecord->frequency = 1;
$rule = $toolgenerator->create_rule($rulerecord);
$subrecord = new stdClass();
$subrecord = new \stdClass();
$subrecord->courseid = $course->id;
$subrecord->ruleid = $rule->id;
$subrecord->userid = $USER->id;
@@ -279,7 +275,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$DB->delete_records('tool_monitor_events');
// Now let us create a rule specific to a module instance.
$cm = new stdClass();
$cm = new \stdClass();
$cm->course = $course->id;
$book = $this->getDataGenerator()->create_module('book', $cm);
$rulerecord->eventname = '\mod_book\event\course_module_viewed';
@@ -290,7 +286,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
// Let us trigger events.
$params = array(
'context' => context_module::instance($book->cmid),
'context' => \context_module::instance($book->cmid),
'objectid' => $book->id
);
for ($i = 0; $i < 5; $i++) {
@@ -337,10 +333,10 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$toolgenerator->create_subscription($subrecord);
// Let us trigger events.
$blog = new blog_entry();
$blog = new \blog_entry();
$blog->subject = "Subject of blog";
$blog->userid = $USER->id;
$states = blog_entry::get_applicable_publish_states();
$states = \blog_entry::get_applicable_publish_states();
$blog->publishstate = reset($states);
for ($i = 0; $i < 5; $i++) {
$newblog = fullclone($blog);
@@ -367,14 +363,14 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$toolgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rulerecord = new stdClass();
$rulerecord = new \stdClass();
$rulerecord->courseid = $course->id;
$rulerecord->eventname = '\mod_book\event\course_module_instance_list_viewed';
$rulerecord->frequency = 5;
$rule = $toolgenerator->create_rule($rulerecord);
$subrecord = new stdClass();
$subrecord = new \stdClass();
$subrecord->courseid = $course->id;
$subrecord->ruleid = $rule->id;
$subrecord->userid = $USER->id;
@@ -416,7 +412,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
*
* @param phpunit_message_sink $msgsink Message sink
*/
protected function verify_processed_data(phpunit_message_sink $msgsink) {
protected function verify_processed_data(\phpunit_message_sink $msgsink) {
global $DB, $USER;
$recordexists = $DB->count_records('task_adhoc', array('component' => 'tool_monitor'));
@@ -435,7 +431,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
*
* @param phpunit_message_sink $msgsink Message sink
*/
protected function verify_message_not_sent_yet(phpunit_message_sink $msgsink) {
protected function verify_message_not_sent_yet(\phpunit_message_sink $msgsink) {
$msgs = $msgsink->get_messages();
$this->assertCount(0, $msgs);
$msgsink->clear();
@@ -457,12 +453,12 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$context = \context_user::instance($USER->id, IGNORE_MISSING);
// Creating book.
$cm = new stdClass();
$cm = new \stdClass();
$cm->course = $course->id;
$book = $this->getDataGenerator()->create_module('book', $cm);
// Creating rule.
$rulerecord = new stdClass();
$rulerecord = new \stdClass();
$rulerecord->courseid = $course->id;
$rulerecord->eventname = '\mod_book\event\course_module_viewed';
$rulerecord->cmid = $book->cmid;
@@ -478,7 +474,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$rule = $toolgenerator->create_rule($rulerecord);
// Creating subscription.
$subrecord = new stdClass();
$subrecord = new \stdClass();
$subrecord->courseid = $course->id;
$subrecord->ruleid = $rule->id;
$subrecord->userid = $USER->id;
@@ -486,7 +482,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
// Now let us trigger the event.
$params = array(
'context' => context_module::instance($book->cmid),
'context' => \context_module::instance($book->cmid),
'objectid' => $book->id
);
@@ -496,7 +492,7 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$msgs = $msgsink->get_messages();
$msg = array_pop($msgs);
$modurl = new moodle_url('/mod/book/view.php', array('id' => $book->cmid));
$modurl = new \moodle_url('/mod/book/view.php', array('id' => $book->cmid));
$this->assertMatchesRegularExpression('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~',
$msg->fullmessagehtml);
@@ -529,12 +525,12 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$course2 = $this->getDataGenerator()->create_course();
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = $course1->id;
$rule->plugin = 'test';
$sub = new stdClass();
$sub = new \stdClass();
$sub->courseid = $course1->id;
$sub->userid = $user->id;
@@ -585,16 +581,16 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
// Now let us create a rule specific to a module instance.
$cm = new stdClass();
$cm = new \stdClass();
$cm->course = $course1->id;
$book = $this->getDataGenerator()->create_module('book', $cm);
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = $course1->id;
$rule->plugin = 'test';
$sub = new stdClass();
$sub = new \stdClass();
$sub->courseid = $course1->id;
$sub->userid = $user->id;
$sub->cmid = $book->cmid;
+11 -19
View File
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_monitor;
/**
* Unit tests for rule manager api.
*
@@ -22,17 +24,7 @@
* @copyright 2014 onwards Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Tests for rule manager.
*
* Class tool_monitor_rule_manager_testcase
*/
class tool_monitor_rule_manager_testcase extends advanced_testcase {
class rule_manager_test extends \advanced_testcase {
/**
* Set up method.
@@ -53,7 +45,7 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$now = time();
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = $course->id;
$rule->name = 'test rule 1';
@@ -98,7 +90,7 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rule = $monitorgenerator->create_rule();
$ruledata = new stdClass;
$ruledata = new \stdClass;
$ruledata->id = $rule->id;
$ruledata->frequency = 25;
@@ -119,10 +111,10 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
$course1 = $this->getDataGenerator()->create_course();
$course2 = $this->getDataGenerator()->create_course();
$record = new stdClass();
$record = new \stdClass();
$record->courseid = $course1->id;
$record2 = new stdClass();
$record2 = new \stdClass();
$record2->courseid = $course2->id;
$ruleids = array();
@@ -147,10 +139,10 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$record = new stdClass();
$record = new \stdClass();
$record->plugin = 'core';
$record2 = new stdClass();
$record2 = new \stdClass();
$record2->plugin = 'mod_assign';
$ruleids = array();
@@ -175,10 +167,10 @@ class tool_monitor_rule_manager_testcase extends advanced_testcase {
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$rule = $monitorgenerator->create_rule();
$record = new stdClass();
$record = new \stdClass();
$record->eventname = '\core\event\calendar_event_created';
$record2 = new stdClass();
$record2 = new \stdClass();
$record2->eventname = '\core\event\calendar_event_updated';
$ruleids = array();
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_monitor;
/**
* Unit tests for subscription manager api.
*
@@ -22,17 +24,7 @@
* @copyright 2014 onwards Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Tests for subscription manager.
*
* Class tool_monitor_subscription_manager_testcase.
*/
class tool_monitor_subscription_manager_testcase extends advanced_testcase {
class subscription_manager_test extends \advanced_testcase {
/**
* Test count_rule_subscriptions method.
@@ -56,7 +48,7 @@ class tool_monitor_subscription_manager_testcase extends advanced_testcase {
$this->assertEquals(0, $subs);
// Subscribe user 1 to rule 1.
$record = new stdClass;
$record = new \stdClass;
$record->ruleid = $rule1->id;
$record->userid = $user1->id;
$monitorgenerator->create_subscription($record);
@@ -75,4 +67,4 @@ class tool_monitor_subscription_manager_testcase extends advanced_testcase {
$this->assertEquals(2, $subs1);
$this->assertEquals(1, $subs2);
}
}
}
@@ -13,7 +13,8 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || exit();
namespace tool_monitor;
/**
* Unit tests for the subscription class.
@@ -24,7 +25,7 @@ defined('MOODLE_INTERNAL') || exit();
* @copyright 2016 Jake Dallimore <jrhdallimore@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_monitor_subscription_testcase extends advanced_testcase {
class subscription_test extends \advanced_testcase {
/**
* @var \tool_monitor\subscription $subscription object.
@@ -38,7 +39,7 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
$this->resetAfterTest(true);
// Create the mock subscription.
$sub = new stdClass();
$sub = new \stdClass();
$sub->id = 100;
$sub->name = 'My test rule';
$sub->courseid = 20;
@@ -62,7 +63,7 @@ class tool_monitor_subscription_testcase extends advanced_testcase {
*/
public function test_magic_get() {
$this->assertEquals(20, $this->subscription->courseid);
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
$this->subscription->ruleid;
}
}
@@ -13,7 +13,8 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || exit();
namespace tool_monitor;
/**
* Unit tests for the tool_monitor clean events task.
@@ -24,7 +25,7 @@ defined('MOODLE_INTERNAL') || exit();
* @copyright 2016 Jake Dallimore <jrhdallimore@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
class task_check_subscriptions_test extends \advanced_testcase {
private $course;
private $user;
@@ -45,7 +46,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
$this->user = $this->getDataGenerator()->create_user();
$this->course = $this->getDataGenerator()->create_course();
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = 2; // Rule created by admin.
$rule->courseid = $this->course->id;
$rule->plugin = 'mod_book';
@@ -54,7 +55,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$this->rule = $monitorgenerator->create_rule($rule);
$sub = new stdClass();
$sub = new \stdClass();
$sub->courseid = $this->course->id;
$sub->userid = $this->user->id;
$sub->ruleid = $this->rule->id;
@@ -90,7 +91,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
public function test_site_level_subscription() {
// Create a site level subscription.
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
$sub = new stdClass();
$sub = new \stdClass();
$sub->userid = $this->user->id;
$sub->ruleid = $this->rule->id;
$this->subscription = $monitorgenerator->create_subscription($sub);
@@ -104,7 +105,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
$this->assertEquals(false, \tool_monitor\subscription_manager::subscription_is_active($this->subscription));
// Now, assign the user as a teacher role at system context.
$this->getDataGenerator()->role_assign($this->teacherrole->id, $this->user->id, context_system::instance());
$this->getDataGenerator()->role_assign($this->teacherrole->id, $this->user->id, \context_system::instance());
// Run the task.
$task = new \tool_monitor\task\check_subscriptions();
@@ -238,7 +239,7 @@ class tool_monitor_task_check_subscriptions_testcase extends advanced_testcase {
$book = $this->getDataGenerator()->create_module('book', array('course' => $this->course->id));
// And add a subscription to it.
$sub = new stdClass();
$sub = new \stdClass();
$sub->courseid = $this->course->id;
$sub->userid = $this->user->id;
$sub->ruleid = $this->rule->id;
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_monitor;
/**
* Unit tests for the tool_monitor clean events task.
*
@@ -22,15 +24,7 @@
* @copyright 2014 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Class used to test the tool_monitor clean events task.
*/
class tool_monitor_task_clean_events_testcase extends advanced_testcase {
class task_clean_events_test extends \advanced_testcase {
/**
* Test set up.
@@ -51,16 +45,16 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
$course = $this->getDataGenerator()->create_course();
$bookgenerator = $this->getDataGenerator()->get_plugin_generator('mod_book');
$book = $this->getDataGenerator()->create_module('book', array('course' => $course->id));
$bookcontext = context_module::instance($book->cmid);
$bookcontext = \context_module::instance($book->cmid);
$bookchapter = $bookgenerator->create_chapter(array('bookid' => $book->id));
$course2 = $this->getDataGenerator()->create_course();
$book2 = $this->getDataGenerator()->create_module('book', array('course' => $course2->id));
$book2context = context_module::instance($book2->cmid);
$book2context = \context_module::instance($book2->cmid);
$book2chapter = $bookgenerator->create_chapter(array('bookid' => $book2->id));
$monitorgenerator = $this->getDataGenerator()->get_plugin_generator('tool_monitor');
// Let's set some data for the rules we need before we can generate them.
$rule = new stdClass();
$rule = new \stdClass();
$rule->userid = $user->id;
$rule->courseid = $course->id;
$rule->plugin = 'mod_book';
@@ -96,7 +90,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
// Let's subscribe to these rules.
$sub = new stdClass;
$sub = new \stdClass;
$sub->courseid = $course->id;
$sub->ruleid = $rule1->id;
$sub->userid = $user->id;
@@ -133,7 +127,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
// Trigger a bunch of other events.
$eventparams = array(
'context' => context_course::instance($course->id)
'context' => \context_course::instance($course->id)
);
for ($i = 0; $i < 5; $i++) {
\mod_quiz\event\course_module_instance_list_viewed::create($eventparams)->trigger();
@@ -164,7 +158,7 @@ class tool_monitor_task_clean_events_testcase extends advanced_testcase {
$this->assertEquals($course2->id, $event4->courseid);
// Update the timewindow for two of the rules.
$updaterule = new stdClass();
$updaterule = new \stdClass();
$updaterule->id = $rule1->id;
$updaterule->timewindow = 0;
\tool_monitor\rule_manager::update_rule($updaterule);
@@ -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.';
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_moodlenet;
/**
* Unit tests for the import_backup_helper
*
@@ -22,15 +24,7 @@
* @copyright 2020 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Class import_backup_helper tests
*/
class tool_moodlenet_import_backup_helper_testcase extends advanced_testcase {
class import_backup_helper_test extends \advanced_testcase {
/**
* Test that the first available context with the capability to upload backup files is returned.
@@ -47,7 +41,7 @@ class tool_moodlenet_import_backup_helper_testcase extends advanced_testcase {
$user5 = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course();
$coursecontext = context_course::instance($course->id);
$coursecontext = \context_course::instance($course->id);
$this->getDataGenerator()->enrol_user($user1->id, $course->id, 'student');
$this->getDataGenerator()->enrol_user($user2->id, $course->id, 'editingteacher');
@@ -55,12 +49,12 @@ class tool_moodlenet_import_backup_helper_testcase extends advanced_testcase {
$category = $this->getDataGenerator()->create_category();
$rolerecord = $DB->get_record('role', ['shortname' => 'manager']);
$categorycontext = context_coursecat::instance($category->id);
$categorycontext = \context_coursecat::instance($category->id);
$this->getDataGenerator()->role_assign($rolerecord->id, $user3->id, $categorycontext->id);
$this->getDataGenerator()->role_assign($rolerecord->id, $user5->id, $categorycontext->id);
$roleid = $this->getDataGenerator()->create_role();
$sitecontext = context_system::instance();
$sitecontext = \context_system::instance();
assign_capability('moodle/restore:uploadfile', CAP_ALLOW, $roleid, $sitecontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$this->getDataGenerator()->role_assign($roleid, $user4->id, $sitecontext->id);
@@ -81,4 +75,4 @@ class tool_moodlenet_import_backup_helper_testcase extends advanced_testcase {
$this->assertEquals(CONTEXT_COURSECAT, $result->contextlevel);
}
}
}
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace tool_moodlenet;
/**
* Unit tests for the profile manager
*
@@ -22,15 +24,7 @@
* @copyright 2020 Adrian Greeve <adrian@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Class profile_manager tests
*/
class tool_moodlenet_profile_manager_testcase extends advanced_testcase {
class profile_manager_test extends \advanced_testcase {
/**
* Test that on this site we use the user table to hold moodle net profile information.
@@ -57,7 +51,7 @@ class tool_moodlenet_profile_manager_testcase extends advanced_testcase {
$this->resetAfterTest();
$user = $this->getDataGenerator()->create_user();
$this->expectException(moodle_exception::class);
$this->expectException(\moodle_exception::class);
$this->expectExceptionMessage(get_string('invalidmoodlenetprofile', 'tool_moodlenet'));
$result = new \tool_moodlenet\moodlenet_user_profile("", $user->id);
}
+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"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 345 B

After

Width:  |  Height:  |  Size: 294 B

+1 -1
View File
@@ -56,5 +56,5 @@
d="m 10.60981,13.748496 q -0.42076,-0.2046 -0.42076,-0.6595 v -2.1834 H 0.36389001 q -0.15919999,0 -0.26154001,-0.102297 Q 0,10.700897 0,10.541796 V 2.5361969 q 0,-0.2388 0.20469002,-0.3297 0.22743999,-0.091 0.39800999,0.045 L 2.7860701,4.0708971 q 0.1250916,0.1024 0.1250916,0.2842998 v 3.639 H 10.18905 V 5.810797 q 0,-0.4548999 0.42076,-0.6596001 0.42075,-0.1932998 0.77327,0.1024 L 15.749821,8.892496 Q 16,9.0971966 16,9.4496973 16,9.8022974 15.749821,10.006998 l -4.366741,3.638798 q -0.36389,0.307 -0.77327,0.102297 z"
id="path4552"
inkscape:connector-curvature="0"
style="fill:#999999;fill-opacity:1;stroke-width:0.9999997" />
style="fill:#888;fill-opacity:1;stroke-width:0.9999997" />
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

@@ -14,31 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the {@link tool_policy_sitepolicy_handler_testcase} class.
*
* @package tool_policy
* @category test
* @copyright 2018 David Mudrák <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_policy;
use tool_policy\api;
use tool_policy\policy_version;
use tool_policy\privacy\local\sitepolicy\handler;
use tool_policy\test\helper;
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Unit tests for the {@link \tool_policy\privacy\local\sitepolicy\handler} class.
*
* @package tool_policy
* @category test
* @copyright 2018 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_policy_sitepolicy_handler_testcase extends advanced_testcase {
class sitepolicy_handler_test extends \advanced_testcase {
/**
* Test behaviour of the {@link \tool_policy\privacy\local\sitepolicy\handler::get_redirect_url()} method.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 247 B

+1 -1
View File
@@ -9,7 +9,7 @@
xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<defs>
</defs>
<path style="fill:#999999;" d="M2,5v9c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V5H2z M5,13.5C5,13.8,4.8,14,4.5,14S4,13.8,4,13.5v-6
<path style="fill:#888;" d="M2,5v9c0,1.1,0.9,2,2,2h8c1.1,0,2-0.9,2-2V5H2z M5,13.5C5,13.8,4.8,14,4.5,14S4,13.8,4,13.5v-6
C4,7.2,4.2,7,4.5,7S5,7.2,5,7.5V13.5z M8.5,13.5C8.5,13.8,8.3,14,8,14s-0.5-0.2-0.5-0.5v-6C7.5,7.2,7.7,7,8,7s0.5,0.2,0.5,0.5V13.5z
M12,13.5c0,0.3-0.2,0.5-0.5,0.5S11,13.8,11,13.5v-6C11,7.2,11.2,7,11.5,7S12,7.2,12,7.5V13.5z M0,4c0-1.1,0.9-2,2-2h4v0
c0-1.1,0.9-2,2-2s2,0.9,2,2v0h4c1.1,0,2,0.9,2,2H0z"/>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

@@ -19,14 +19,13 @@ Feature: Backup user data
And the following config values are set as admin:
| coursebinenable | 1 | tool_recyclebin |
| autohide | 0 | tool_recyclebin |
And the following "activities" exist:
| activity | course | section | name | intro |
| quiz | C1 | 1 | Quiz 1 | Test quiz description |
@javascript
Scenario: Delete and restore a quiz with user data
Given I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Quiz" to section "1" and I fill the form with:
| Name | Quiz 1 |
| Description | Test quiz description |
Given I am on the "Quiz 1" "quiz activity" page logged in as teacher1
And I add a "True/False" question to the "Quiz 1" quiz with:
| Question name | TF1 |
| Question text | First question |
@@ -41,6 +40,8 @@ Feature: Backup user data
| Correct answer | False |
| Feedback for the response 'True'. | So you think it is true |
| Feedback for the response 'False'. | So you think it is false |
And I set the field "maxgrade" to "10.0"
And I press "savechanges"
And I log out
When I am on the "Quiz 1" "quiz activity" page logged in as student1
And I press "Attempt quiz now"
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Recycle bin tests.
*
* @package tool_recyclebin
* @copyright 2015 University of Kent
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace tool_recyclebin;
/**
* Recycle bin category tests.
@@ -31,15 +23,15 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2015 University of Kent
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_recyclebin_category_bin_tests extends advanced_testcase {
class category_bin_test extends \advanced_testcase {
/**
* @var stdClass $course
* @var \stdClass $course
*/
protected $course;
/**
* @var stdClass $coursebeingrestored
* @var \stdClass $coursebeingrestored
*/
protected $coursebeingrestored;
@@ -96,7 +88,7 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase {
$this->assertEquals(1, $DB->count_records('tool_recyclebin_category'));
// Now let's delete the course category.
$category = core_course_category::get($this->course->category);
$category = \core_course_category::get($this->course->category);
$category->delete_full(false);
// Check that the course was deleted from the category recycle bin.
@@ -242,7 +234,7 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase {
$this->assertEquals(0, count($recyclebin->get_items()));
// Verify that student DOES continue enrolled.
$this->assertTrue(is_enrolled(context_course::instance($newcourse->id), $student->id));
$this->assertTrue(is_enrolled(\context_course::instance($newcourse->id), $student->id));
}
/**
@@ -286,6 +278,6 @@ class tool_recyclebin_category_bin_tests extends advanced_testcase {
$this->assertEquals(0, count($recyclebin->get_items()));
// Verify that student DOES NOT continue enrolled.
$this->assertFalse(is_enrolled(context_course::instance($newcourse->id), $student->id));
$this->assertFalse(is_enrolled(\context_course::instance($newcourse->id), $student->id));
}
}
+14 -22
View File
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Recycle bin tests.
*
* @package tool_recyclebin
* @copyright 2015 University of Kent
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace tool_recyclebin;
/**
* Recycle bin course tests.
@@ -31,10 +23,10 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2015 University of Kent
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_recyclebin_course_bin_tests extends advanced_testcase {
class course_bin_test extends \advanced_testcase {
/**
* @var stdClass $course
* @var \stdClass $course
*/
protected $course;
@@ -72,7 +64,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
course_delete_module($this->quiz->cmid);
// Now, run the course module deletion adhoc task.
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
// Check the course module is now in the recycle bin.
$this->assertEquals(1, $DB->count_records('tool_recyclebin_course'));
@@ -116,7 +108,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
course_delete_module($this->quiz->cmid);
// Now, run the course module deletion adhoc task.
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
// Try purging.
$recyclebin = new \tool_recyclebin\course_bin($this->course->id);
@@ -141,7 +133,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
course_delete_module($this->quiz->cmid);
// Now, run the course module deletion adhoc task.
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
// Set deleted date to the distant past.
$recyclebin = new \tool_recyclebin\course_bin($this->course->id);
@@ -157,7 +149,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
course_delete_module($book->cmid);
// Now, run the course module deletion adhoc task.
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
// Should have 2 items now.
$this->assertEquals(2, count($recyclebin->get_items()));
@@ -223,7 +215,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
// Delete quiz.
$cm = get_coursemodule_from_instance('quiz', $this->quiz->id);
course_delete_module($cm->id);
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
$quizzes = get_coursemodules_in_course('quiz', $this->course->id);
$this->assertEquals(0, count($quizzes));
@@ -240,7 +232,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
$attempts = quiz_get_user_attempts($cm->instance, $student->id);
$this->assertEquals(1, count($attempts));
$attempt = array_pop($attempts);
$attemptobj = quiz_attempt::create($attempt->id);
$attemptobj = \quiz_attempt::create($attempt->id);
$this->assertEquals($student->id, $attemptobj->get_userid());
$this->assertEquals(true, $attemptobj->is_finished());
}
@@ -270,7 +262,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
// Delete quiz.
$cm = get_coursemodule_from_instance('quiz', $this->quiz->id);
course_delete_module($cm->id);
phpunit_util::run_all_adhoc_tasks();
\phpunit_util::run_all_adhoc_tasks();
$quizzes = get_coursemodules_in_course('quiz', $this->course->id);
$this->assertEquals(0, count($quizzes));
@@ -303,17 +295,17 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
quiz_add_quiz_question($numq->id, $quiz);
// Create quiz attempt.
$quizobj = quiz::create($quiz->id, $student->id);
$quba = question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
$quizobj = \quiz::create($quiz->id, $student->id);
$quba = \question_engine::make_questions_usage_by_activity('mod_quiz', $quizobj->get_context());
$quba->set_preferred_behaviour($quizobj->get_quiz()->preferredbehaviour);
$timenow = time();
$attempt = quiz_create_attempt($quizobj, 1, false, $timenow, false, $student->id);
quiz_start_new_attempt($quizobj, $quba, $attempt, 1, $timenow);
quiz_attempt_save_started($quizobj, $quba, $attempt);
$attemptobj = quiz_attempt::create($attempt->id);
$attemptobj = \quiz_attempt::create($attempt->id);
$tosubmit = array(1 => array('answer' => '0'));
$attemptobj->process_submitted_actions($timenow, false, $tosubmit);
$attemptobj = quiz_attempt::create($attempt->id);
$attemptobj = \quiz_attempt::create($attempt->id);
$attemptobj->process_finish($timenow, false);
}
}
+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());
}
+3 -13
View File
@@ -14,26 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* File containing tests for the mform class.
*
* @package tool_task
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_task;
/**
* Mform test class.
* Test for the task mform class.
*
* @package tool_task
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
*/
class tool_task_form_testcase extends advanced_testcase {
class form_test extends \advanced_testcase {
/**
* Test validations for minute field.
+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])) {
+8 -16
View File
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for CLI tool_uploaduser.
*
* @package tool_uploaduser
* @copyright 2020 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use \tool_uploaduser\cli_helper;
namespace tool_uploaduser;
/**
* Tests for CLI tool_uploaduser.
@@ -31,7 +23,7 @@ use \tool_uploaduser\cli_helper;
* @copyright 2020 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_uploaduser_cli_testcase extends advanced_testcase {
class cli_test extends \advanced_testcase {
/**
* Generate cli_helper and mock $_SERVER['argv']
@@ -117,7 +109,7 @@ class tool_uploaduser_cli_testcase extends advanced_testcase {
$this->assertEquals('Users created: 2', $stats[0]);
// Users have default values applied.
$user1 = core_user::get_user_by_username('jonest');
$user1 = \core_user::get_user_by_username('jonest');
$this->assertEquals('Brighton', $user1->city);
$this->assertEquals('Purchasing', $user1->department);
}
@@ -149,7 +141,7 @@ class tool_uploaduser_cli_testcase extends advanced_testcase {
$this->assertEquals('Users created: 2', $stats[0]);
// Created users have data in the profile fields.
$user1 = core_user::get_user_by_username('reznort');
$user1 = \core_user::get_user_by_username('reznort');
$profilefields1 = profile_user_record($user1->id);
$this->assertEquals((object)['superfield' => 'Loves cats'], $profilefields1);
}
@@ -244,9 +236,9 @@ class tool_uploaduser_cli_testcase extends advanced_testcase {
$enrols = array_values(enrol_get_course_users($course->id));
$this->assertEqualsCanonicalizing(['jonest'], [$enrols[0]->username]);
// User reznor is not created.
$this->assertFalse(core_user::get_user_by_username('reznor'));
$this->assertFalse(\core_user::get_user_by_username('reznor'));
// User jonest is not updated.
$this->assertEquals('OLDNAME', core_user::get_user_by_username('jonest')->firstname);
$this->assertEquals('OLDNAME', \core_user::get_user_by_username('jonest')->firstname);
}
/**
@@ -287,8 +279,8 @@ class tool_uploaduser_cli_testcase extends advanced_testcase {
$enrols = array_values(enrol_get_course_users($course->id));
$this->assertEqualsCanonicalizing(['jonest'], [$enrols[0]->username]);
// User reznor is not created.
$this->assertFalse(core_user::get_user_by_username('reznor'));
$this->assertFalse(\core_user::get_user_by_username('reznor'));
// User jonest is updated, new first name is Tom.
$this->assertEquals('Tom', core_user::get_user_by_username('jonest')->firstname);
$this->assertEquals('Tom', \core_user::get_user_by_username('jonest')->firstname);
}
}
@@ -14,20 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for field value validators of tool_uploaduser.
*
* @package tool_uploaduser
* @copyright 2019 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_uploaduser;
use tool_uploaduser\local\field_value_validators;
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Tests for field value validators of tool_uploaduser.
*
@@ -35,7 +25,7 @@ global $CFG;
* @copyright 2019 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class field_value_validators_testcase extends advanced_testcase {
class field_value_validators_test extends \advanced_testcase {
/**
* Data provider for \field_value_validators_testcase::test_validate_theme().
Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 511 B

+1 -1
View File
@@ -1,3 +1,3 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M7.9 16c4 0 7.4-3 7.8-7h-3c-.5 2-2.5 4-4.9 4-2.8 0-5-2.2-5-5s2.2-5 5-5c1.1 0 2.1 0 3 1h-1c-.5 0-.8.5-.8 1.1v1c0 .5.3.9.8.9h5c.6 0 1.2-.4 1.2-.9v-5c0-.6-.6-1.1-1.2-1.1h-1c-.5 0-.8.5-.8 1.1V2C12 .9 9.9.2 8 .2 3.6.2 0 3.7 0 8.1 0 12.4 3.5 16 7.9 16z" fill="#999"/></svg>
]><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" preserveAspectRatio="xMinYMid meet" overflow="visible"><path d="M7.9 16c4 0 7.4-3 7.8-7h-3c-.5 2-2.5 4-4.9 4-2.8 0-5-2.2-5-5s2.2-5 5-5c1.1 0 2.1 0 3 1h-1c-.5 0-.8.5-.8 1.1v1c0 .5.3.9.8.9h5c.6 0 1.2-.4 1.2-.9v-5c0-.6-.6-1.1-1.2-1.1h-1c-.5 0-.8.5-.8 1.1V2C12 .9 9.9.2 8 .2 3.6.2 0 3.7 0 8.1 0 12.4 3.5 16 7.9 16z" fill="#888"/></svg>

Before

Width:  |  Height:  |  Size: 569 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

After

Width:  |  Height:  |  Size: 342 B

+1 -1
View File
@@ -9,7 +9,7 @@
xml:space="preserve" preserveAspectRatio="xMinYMid meet">
<defs>
</defs>
<path style="fill:#999999;" d="M12,7v4c0,0.5-0.5,1-1,1h-0.5l0,0H1c-0.5,0-1-0.5-1-1V7c0-0.5,0.5-1,1-1h0.5c0.5,0,1,0.5,1,1l0,2.5h7
<path style="fill:#888;" d="M12,7v4c0,0.5-0.5,1-1,1h-0.5l0,0H1c-0.5,0-1-0.5-1-1V7c0-0.5,0.5-1,1-1h0.5c0.5,0,1,0.5,1,1l0,2.5h7
V7c0-0.5,0.5-1,1-1H11C11.5,6,12,6.5,12,7z M9.9,3.6L6.6,0.3C6.4,0.1,6.2,0,5.9,0C5.7,0,5.4,0.1,5.2,0.3L1.9,3.6
C1.5,4,1.5,4.6,1.9,5l0.3,0.3c0.4,0.4,1,0.4,1.4,0l1-1.1l0,2.7c0,0.5,0.5,1,1,1l0.5,0c0.5,0,1-0.5,1-1l0-2.7l1,1
c0.4,0.4,1,0.4,1.4,0L10,5C10.3,4.6,10.3,4,9.9,3.6z"/>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

+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"],
@@ -14,17 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for time filter.
*
* @package tool_usertours
* @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_usertours;
defined('MOODLE_INTERNAL') || die();
use tool_usertours\tour;
use tool_usertours\local\filter\accessdate;
/**
@@ -34,7 +25,7 @@ use tool_usertours\local\filter\accessdate;
* @copyright 2019 Tom Dickman <tomdickman@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_usertours_accessdate_filter_test extends advanced_testcase {
class accessdate_filter_test extends \advanced_testcase {
public function setUp(): void {
$this->resetAfterTest(true);
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for role filter.
*
* @package tool_usertours
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace tool_usertours;
/**
* Tests for role filter.
@@ -31,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_usertours_role_filter_testcase extends advanced_testcase {
class role_filter_test extends \advanced_testcase {
/**
* @var $course Test course
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for theme filter.
*
* @package tool_usertours
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace tool_usertours;
/**
* Tests for theme filter.
@@ -31,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_usertours_theme_filter_testcase extends advanced_testcase {
class theme_filter_test extends \advanced_testcase {
/**
* Data Provider for filter_matches function.
+2 -10
View File
@@ -14,21 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Tests for tour.
*
* @package tool_usertours
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_usertours;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->libdir . '/formslib.php');
use tool_usertours\tour;
/**
* Tests for tour.
*
@@ -36,7 +28,7 @@ use tool_usertours\tour;
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tour_testcase extends advanced_testcase {
class tour_test extends \advanced_testcase {
/**
* @var moodle_database
+19 -10
View File
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace auth_db;
/**
* External database auth sync tests, this also tests adodb drivers
* that are matching our four supported Moodle database drivers.
@@ -23,17 +25,24 @@
* @copyright 2012 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
class auth_db_testcase extends advanced_testcase {
class db_test extends \advanced_testcase {
/** @var string Original error log */
protected $oldlog;
/** @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");
@@ -112,7 +121,7 @@ class auth_db_testcase extends advanced_testcase {
throw new exception('Unknown database family ' . $DB->get_dbfamily());
}
$table = new xmldb_table('auth_db_users');
$table = new \xmldb_table('auth_db_users');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('name', XMLDB_TYPE_CHAR, '255', null, null, null);
$table->add_field('pass', XMLDB_TYPE_CHAR, '255', null, null, null);
@@ -157,7 +166,7 @@ class auth_db_testcase extends advanced_testcase {
global $DB;
$dbman = $DB->get_manager();
$table = new xmldb_table('auth_db_users');
$table = new \xmldb_table('auth_db_users');
$dbman->drop_table($table);
ini_set('error_log', $this->oldlog);
@@ -211,7 +220,7 @@ class auth_db_testcase extends advanced_testcase {
$this->assertCount(2, $DB->get_records('user'));
$trace = new null_progress_trace();
$trace = new \null_progress_trace();
// Sync users and make sure that two events user_created werer triggered.
$sink = $this->redirectEvents();
@@ -472,7 +481,7 @@ class auth_db_testcase extends advanced_testcase {
$extdbuser3 = (object)array('name'=>'u3', 'pass'=>'heslo', 'email'=>'u3@example.com',
'lastname' => 'user<script>alert(1);</script>xss');
$extdbuser3->id = $DB->insert_record('auth_db_users', $extdbuser3);
$trace = new null_progress_trace();
$trace = new \null_progress_trace();
// Let's test user sync make sure still works as expected..
$auth->sync_users($trace, true);
@@ -518,7 +527,7 @@ class auth_db_testcase extends advanced_testcase {
}
// Sync to moodle.
$trace = new null_progress_trace();
$trace = new \null_progress_trace();
$auth->sync_users($trace, true);
// Check user is there.
+4 -9
View File
@@ -14,14 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Manual authentication tests.
*
* @package auth_manual
* @category test
* @copyright 2014 Gilles-Philippe Leblanc <gilles-philippe.leblanc@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace auth_manual;
use auth_plugin_manual;
defined('MOODLE_INTERNAL') || die();
@@ -36,7 +31,7 @@ require_once($CFG->dirroot.'/auth/manual/auth.php');
* @copyright 2014 Gilles-Philippe Leblanc <gilles-philippe.leblanc@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_manual_testcase extends advanced_testcase {
class manual_test extends \advanced_testcase {
/** @var auth_plugin_manual Keeps the authentication plugin. */
protected $authplugin;
+3 -12
View File
@@ -14,26 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace auth_oauth2;
/**
* Auth oauth2 auth functions tests.
*
* @package auth_oauth2
* @category test
* @copyright 2019 Shamim Rezaie <shamim@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
/**
* Tests for the \auth_oauth2\auth class.
*
* @copyright 2019 Shamim Rezaie
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_oauth2_auth_testcase extends advanced_testcase {
class auth_test extends \advanced_testcase {
public function test_get_password_change_info() {
$this->resetAfterTest();
+2 -10
View File
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for core_auth\digital_consent.
*
* @package core_auth
* @copyright 2018 Mihail Geshoski
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace core_auth;
/**
* Digital consent helper testcase.
@@ -31,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2018 Mihail Geshoski
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_auth_digital_consent_testcase extends advanced_testcase {
class digital_consent_test extends \advanced_testcase {
public function test_is_age_digital_consent_verification_enabled() {
global $CFG;
+1 -1
View File
@@ -684,7 +684,7 @@ class tree extends tree_node {
} else {
unset($this->children[$index]);
unset($this->showchildren[$index]);
$this->showchildren = array_values($this->showchildren);
$this->showchildren = !is_null($this->showchildren) ? array_values($this->showchildren) : null;
$changed = true;
}
}
+3 -13
View File
@@ -14,17 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the capability checker class.
*
* @package core_availability
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_availability\capability_checker;
defined('MOODLE_INTERNAL') || die();
namespace core_availability;
/**
* Unit tests for the capability checker class.
@@ -33,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_availability_capability_checker_testcase extends advanced_testcase {
class capability_checker_test extends \advanced_testcase {
/**
* Tests loading a class from /availability/classes.
*/
@@ -51,7 +41,7 @@ class core_availability_capability_checker_testcase extends advanced_testcase {
$generator->enrol_user($student->id, $course->id, $roleids['student']);
// Check a capability which they both have.
$context = context_course::instance($course->id);
$context = \context_course::instance($course->id);
$checker = new capability_checker($context);
$result = array_keys($checker->get_users_by_capability('mod/forum:replypost'));
sort($result);
+3 -11
View File
@@ -14,15 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the component and plugin definitions for availability system.
*
* @package core_availability
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace core_availability;
/**
* Unit tests for the component and plugin definitions for availability system.
@@ -31,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_availability_component_testcase extends advanced_testcase {
class component_test extends \advanced_testcase {
/**
* Tests loading a class from /availability/classes.
*/
@@ -47,7 +39,7 @@ class core_availability_component_testcase extends advanced_testcase {
// This code will throw debugging information if the plugininfo class
// is missing. Unfortunately it doesn't actually cause the test to
// fail, but it's obvious when running test at least.
$pluginmanager = core_plugin_manager::instance();
$pluginmanager = \core_plugin_manager::instance();
$list = $pluginmanager->get_enabled_plugins('availability');
$this->assertArrayHasKey('completion', $list);
$this->assertArrayHasKey('date', $list);
+4 -16
View File
@@ -14,19 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for info and subclasses.
*
* @package core_availability
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
use core_availability\info;
use core_availability\info_module;
use core_availability\info_section;
namespace core_availability;
/**
* Unit tests for info and subclasses.
@@ -35,7 +23,7 @@ use core_availability\info_section;
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class info_testcase extends advanced_testcase {
class info_test extends \advanced_testcase {
public function setUp(): void {
// Load the mock condition so that it can be used.
require_once(__DIR__ . '/fixtures/mock_condition.php');
@@ -491,7 +479,7 @@ class info_testcase extends advanced_testcase {
// If the students have viewhiddenactivities, they get past the module
// restriction.
role_change_permission($studentroleid, context_module::instance($page2->cmid),
role_change_permission($studentroleid, \context_module::instance($page2->cmid),
'moodle/course:ignoreavailabilityrestrictions', CAP_ALLOW);
$expected = array($u1->id, $u2->id);
$this->assertEquals($expected, array_keys($info->filter_user_list($allusers)));
@@ -502,7 +490,7 @@ class info_testcase extends advanced_testcase {
// If they have viewhiddensections, they also get past the section
// restriction.
role_change_permission($studentroleid, context_course::instance($course->id),
role_change_permission($studentroleid, \context_course::instance($course->id),
'moodle/course:ignoreavailabilityrestrictions', CAP_ALLOW);
$expected = array($u1->id, $u2->id, $u3->id);
$this->assertEquals($expected, array_keys($info->filter_user_list($allusers)));
+17 -28
View File
@@ -14,18 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the condition tree class and related logic.
*
* @package core_availability
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use core_availability\capability_checker;
use \core_availability\tree;
defined('MOODLE_INTERNAL') || die();
namespace core_availability;
/**
* Unit tests for the condition tree class and related logic.
@@ -34,7 +23,7 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tree_testcase extends \advanced_testcase {
class tree_test extends \advanced_testcase {
public function setUp(): void {
// Load the mock classes so they can be used.
require_once(__DIR__ . '/fixtures/mock_condition.php');
@@ -48,83 +37,83 @@ class tree_testcase extends \advanced_testcase {
try {
new tree('frog');
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('not object', $e->getMessage());
}
try {
new tree((object)array());
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('missing ->op', $e->getMessage());
}
try {
new tree((object)array('op' => '*'));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('unknown ->op', $e->getMessage());
}
try {
new tree((object)array('op' => '|'));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('missing ->show', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => 0));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('->show not bool', $e->getMessage());
}
try {
new tree((object)array('op' => '&'));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('missing ->showc', $e->getMessage());
}
try {
new tree((object)array('op' => '&', 'showc' => 0));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('->showc not array', $e->getMessage());
}
try {
new tree((object)array('op' => '&', 'showc' => array(0)));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('->showc value not bool', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => true));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('missing ->c', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => true,
'c' => 'side'));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('->c not array', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => true,
'c' => array(3)));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('child not object', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => true,
'c' => array((object)array('type' => 'doesnotexist'))));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('Unknown condition type: doesnotexist', $e->getMessage());
}
try {
new tree((object)array('op' => '|', 'show' => true,
'c' => array((object)array())));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('missing ->op', $e->getMessage());
}
try {
@@ -133,7 +122,7 @@ class tree_testcase extends \advanced_testcase {
'showc' => array(true, true)
));
$this->fail();
} catch (coding_exception $e) {
} catch (\coding_exception $e) {
$this->assertStringContainsString('->c, ->showc mismatch', $e->getMessage());
}
}
@@ -336,7 +325,7 @@ class tree_testcase extends \advanced_testcase {
/**
* Shortcut function to check availability and also get information.
*
* @param stdClass $structure Tree structure
* @param \stdClass $structure Tree structure
* @param \core_availability\info $info Location info
* @param int $userid User id
*/
@@ -111,8 +111,13 @@ abstract class base_controller extends backup implements loggable {
*
* @param \stdClass $data The course copy data.
* @throws backup_controller_exception
* @deprecated since Moodle 4.1 MDL-74548 - please do not use this method anymore.
* @todo MDL-75025 This method will be deleted in Moodle 4.5
* @see restore_controller::__construct()
*/
public function set_copy(\stdClass $data): void {
debugging('The method base_controller::set_copy() is deprecated.
Please use the restore_controller class instead.', DEBUG_DEVELOPER);
// Only allow setting of copy data when controller is in copy mode.
if ($this->mode != backup::MODE_COPY) {
throw new backup_controller_exception('cannot_set_copy_vars_wrong_mode');
@@ -124,8 +129,13 @@ abstract class base_controller extends backup implements loggable {
* Get the course copy data.
*
* @return \stdClass
* @deprecated since Moodle 4.1 MDL-74548 - please do not use this method anymore.
* @todo MDL-75026 This method will be deleted in Moodle 4.5
* @see restore_controller::get_copy()
*/
public function get_copy(): \stdClass {
debugging('The method base_controller::get_copy() is deprecated.
Please use restore_controller::get_copy() instead.', DEBUG_DEVELOPER);
return $this->copy;
}
}
+28 -1
View File
@@ -65,6 +65,13 @@ class restore_controller extends base_controller {
/** @var int Number of restore_controllers that are currently executing */
protected static $executing = 0;
/**
* Holds the relevant destination information for course copy operations.
*
* @var \stdClass.
*/
protected $copy;
/**
* Constructor.
*
@@ -79,10 +86,17 @@ class restore_controller extends base_controller {
* @param int $userid
* @param int $target backup::TARGET_[ NEW_COURSE | CURRENT_ADDING | CURRENT_DELETING | EXISTING_ADDING | EXISTING_DELETING ]
* @param \core\progress\base $progress Optional progress monitor
* @param \stdClass $copydata Course copy data, required when in MODE_COPY
* @param bool $releasesession Should release the session? backup::RELEASESESSION_YES or backup::RELEASESESSION_NO
*/
public function __construct($tempdir, $courseid, $interactive, $mode, $userid, $target,
\core\progress\base $progress = null, $releasesession = backup::RELEASESESSION_NO) {
\core\progress\base $progress = null, $releasesession = backup::RELEASESESSION_NO, ?\stdClass $copydata = null) {
if ($mode == backup::MODE_COPY && is_null($copydata)) {
throw new restore_controller_exception('cannot_instantiate_missing_copydata');
}
$this->copy = $copydata;
$this->tempdir = $tempdir;
$this->courseid = $courseid;
$this->interactive = $interactive;
@@ -563,6 +577,19 @@ class restore_controller extends base_controller {
$this->progress->end_progress();
}
/**
* Get the course copy data.
*
* @return \stdClass
*/
public function get_copy(): \stdClass {
if ($this->mode != backup::MODE_COPY) {
throw new restore_controller_exception('cannot_get_copy_wrong_mode');
}
return $this->copy;
}
// Protected API starts here
protected function calculate_restoreid() {
+35 -13
View File
@@ -16,22 +16,33 @@
/**
* @package core_backup
* @category phpunit
* @category test
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_backup;
use backup;
use backup_controller;
use restore_controller;
defined('MOODLE_INTERNAL') || die();
// Include all the needed stuff
// Include all the needed stuff.
global $CFG;
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
require_once($CFG->dirroot . '/backup/util/includes/restore_includes.php');
/*
* controller tests (all)
/**
* Tests for the backup and restore controller classes.
*
* @package core_backup
* @category test
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_backup_controller_testcase extends advanced_testcase {
class controller_test extends \advanced_testcase {
protected $moduleid; // course_modules id used for testing
protected $sectionid; // course_sections id used for testing
@@ -61,17 +72,28 @@ class core_backup_controller_testcase extends advanced_testcase {
}
/**
* Test set copy method.
* Test get_copy
*
* @covers \restore_controller::get_copy
*/
public function test_base_controller_set_copy() {
$this->expectException(\backup_controller_exception::class);
$copy = new \stdClass();
public function test_restore_controller_get_copy() {
$copydata = (object)["some" => "copydata"];
$rc = new \restore_controller(1729, $this->courseid, backup::INTERACTIVE_NO, backup::MODE_COPY,
$this->userid, backup::TARGET_NEW_COURSE, null, backup::RELEASESESSION_NO, $copydata);
// Set up controller as a non-copy operation.
$bc = new \backup_controller(backup::TYPE_1COURSE, $this->courseid, backup::FORMAT_MOODLE,
backup::INTERACTIVE_NO, backup::MODE_GENERAL, $this->userid, backup::RELEASESESSION_YES);
$this->assertEquals($copydata, $rc->get_copy());
}
$bc->set_copy($copy);
/**
* Test instantiating a restore controller for a course copy without providing copy data.
*
* @covers \restore_controller::__construct
*/
public function test_restore_controller_copy_without_copydata() {
$this->expectException(\restore_controller_exception::class);
new \restore_controller(1729, $this->courseid, backup::INTERACTIVE_NO, backup::MODE_COPY,
$this->userid, backup::TARGET_NEW_COURSE);
}
/*
@@ -14,23 +14,33 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unit tests for the moodle1 converter
*
* @package core_backup
* @subpackage backup-convert
* @category phpunit
* @copyright 2011 Mark Nielsen <mark@moodlerooms.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_backup;
use backup;
use convert_path;
use convert_path_exception;
use convert_factory;
use convert_helper;
use moodle1_converter;
use moodle1_convert_empty_storage_exception;
use moodle1_convert_exception;
use moodle1_convert_storage_exception;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/backup/converter/moodle1/lib.php');
class core_backup_moodle1_converter_testcase extends advanced_testcase {
/**
* Unit tests for the moodle1 converter
*
* @package core_backup
* @subpackage backup-convert
* @category test
* @copyright 2011 Mark Nielsen <mark@moodlerooms.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class moodle1_converter_test extends \advanced_testcase {
/** @var string the name of the directory containing the unpacked Moodle 1.9 backup */
protected $tempdir;
@@ -68,7 +78,7 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
"$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
"$this->tempdirpath/moddata/unittest/4/icon.gif"
);
$this->iconhash = file_storage::hash_from_path($this->tempdirpath.'/moddata/unittest/4/icon.gif');
$this->iconhash = \file_storage::hash_from_path($this->tempdirpath.'/moddata/unittest/4/icon.gif');
copy(
"$CFG->dirroot/backup/converter/moodle1/tests/fixtures/icon.gif",
"$this->tempdirpath/moddata/unittest/4/7/icon.gif"
@@ -351,8 +361,8 @@ class core_backup_moodle1_converter_testcase extends advanced_testcase {
$this->assertEquals('array', gettype($files['/file1.gif']));
$this->assertEquals('array', gettype($files['/sub1/.']));
$this->assertEquals('array', gettype($files['/sub1/file2.gif']));
$this->assertEquals(file_storage::hash_from_string(''), $files['/.']['contenthash']);
$this->assertEquals(file_storage::hash_from_string(''), $files['/sub1/.']['contenthash']);
$this->assertEquals(\file_storage::hash_from_string(''), $files['/.']['contenthash']);
$this->assertEquals(\file_storage::hash_from_string(''), $files['/sub1/.']['contenthash']);
$this->assertEquals($this->iconhash, $files['/file1.gif']['contenthash']);
$this->assertEquals($this->iconhash, $files['/sub1/file2.gif']['contenthash']);
+3 -2
View File
@@ -24,6 +24,7 @@
*/
require_once('../config.php');
require_once($CFG->dirroot . '/backup/util/includes/backup_includes.php');
defined('MOODLE_INTERNAL') || die();
@@ -70,8 +71,8 @@ if ($mform->is_cancelled()) {
} else if ($mdata = $mform->get_data()) {
// Process the form and create the copy task.
$backupcopy = new \core_backup\copy\copy($mdata);
$backupcopy->create_copy();
$copydata = \copy_helper::process_formdata($mdata);
\copy_helper::create_copy($copydata);
if (!empty($mdata->submitdisplay)) {
// Redirect to the copy progress overview.
+2 -2
View File
@@ -388,8 +388,8 @@ class core_backup_external extends external_api {
if ($mdata) {
// Create the copy task.
$backupcopy = new \core_backup\copy\copy($mdata);
$copyids = $backupcopy->create_copy();
$copydata = \copy_helper::process_formdata($mdata);
$copyids = \copy_helper::create_copy($copydata);
} else {
throw new moodle_exception('copyformfail', 'backup');
}
+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);

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