Commit Graph

35 Commits

Author SHA1 Message Date
Mark Johnson
958da5b67e MDL-68093 groups: Add visibility and participation settings
These new settings are designed to enchance user privacy surrounding
groups. They allow groups to be configured so that users outside the
group cannot see the group, so that users in the group cannot see each
other, or so that users cannot see the group at all, even if they are in
it. This avoids issues where a group may be assigned based on sensitive
personal information (such as a person requiring special arrangements
due to a disability).

By default, groups are visible to all and available for participation in
activities, which maintains the current behaviour.

For performance, a new cache has been added to track the number of
groups on a course that are not visible to non-members. This allows us
to revert to the existing behaviour if the new features are not being
used at all on a course, and only apply the new visibility conditions if
they are.

Users who have the moodle/course:viewhiddengroups capability should be
concious of exposing hidden groups when showing their screen to other
users. The "Switch role to..." feature can be used to show a course page
on screen without exposing private availability conditions, for example.

The changes cover several specific areas:
* grouplib functions, which most code should use to get lists of groups
  and members (this includes the participants page).
* Activities supporting group overrides will not allow overrides for
  groups that are hidden from all users.
* Activities supporting separate/visible groups modes will only allow
  groups with the new "participation" flag enabled to be selected.
* Group messaging will be disabled for groups where members cannot see
  each other, or cannot see the group at all.
2023-03-14 08:52:25 +00:00
Eloy Lafuente (stronk7)
83b490a594 MDL-75111 phpunit: Move tests to use correct names and ns (take#4)
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:

- The following task tests have been moved within the level2 directory:
  - \core\adhoc_task_test => \core\task\adhoc_task_test
  - \core\scheduled_task_test => \core\task\scheduled_task_test
  - \core\calendar_cron_task_test => \core\task\calendar_cron_task_test
  - \core\h5p_get_content_types_task_test => \core\task\h5p_get_content_types_task_test
  - \core\task_database_logger_test => \core\task\database_logger_test
  - \core\task_logging_test => \core\task\logging_test

- The following event tests have been moved within level2 directory:
  - \core\event_context_locked_test => \core\event\context_locked_test
  - \core\event_deprecated_test => \core\event\deprecated_test
  - \core\event_grade_deleted_test => \core\event\grade_deleted_test
  - \core\event_profile_field_test => \core\event\profile_field_test
  - \core\event_unknown_logged_test => \core\event\unknown_logged_test
  - \core\event_user_graded_test => \core\event\user_graded_test
  - \core\event_user_password_updated_test => \core\event\user_password_updated_test

- The following output tests have been moved within level2 directory:
  - \core\mustache_template_finder_test => \core\output\mustache_template_finder_test
  - \core\mustache_template_source_loader_test => \core\output\mustache_template_source_loader_test
  - \core\output_mustache_helper_collection_test => \core\output\mustache_helper_collection_test

- The following tests have been moved to their correct tests directories:
  - lib/tests/time_splittings_test.php => analytics/tests/time_splittings_test.php

- All the classes and tests under lib/filebrowser and lib/filestorage
  belong to core, not to core_files. Some day we should move
  them to their correct subsystem.
- All the classes and tests under lib/grade belong to core, not
  to core_grades. Some day we should move them to their correct
  subsystem.
- The core_grades_external class and its \core\grades_external_test
  unit test should belong to the grades subsystem or, alternatively,
  to \core\external, they both should be moved together.
- The core_grading_external class and its \core\grading_external_test
  unit test should belong to the grading subsystem or, alternatively,
  to \core\external, they both should be moved together.
- The \core\message\message and \core\message\inbound (may be others)
  classes, and their associated tests should go to the core_message
  subsystem.
- The core_user class, and its associated tests should go to the
  core_user subsystem.
- The \core\update namespace is plain wrong (update is not valid API)
  and needs action 1) create it or 2) move elsewhere.
2022-08-26 16:34:20 +02:00
Paul Holden
c260bad774 MDL-69908 user: include groups with exported course participants. 2021-06-14 09:31:30 +01:00
Eloy Lafuente (stronk7)
8a14a7bd22 MDL-71036 phpunit: assertContains() now performs strict comparison
The methods assertContains() and assertNotContains() now perform
strict (type and value) comparison, pretty much like assertSame()
does.

A couple of new assertContainsEquals() and assertNotContainsEquals()
methods have been created to provide old (non-strict) behavior, pretty
much like assertEquals() do.

Apart from replacing the calls needing a relaxed comparison to those
new methods, there are also a couple of alternative, about how to
fix this, depending of every case:

- If the test is making any array_values() conversion, then it's better
  to remove that conversion and use assertArrayHasKey(), that is not
  strict.
- Sometimes if may be also possible to, simply, cast the expectation
  to the exact type coming in the array. I've not applied this technique
  to any of the cases in core.

Link: https://github.com/sebastianbergmann/phpunit/issues/3426
2021-03-11 23:04:31 +01:00
Eloy Lafuente (stronk7)
3a5641cb74 MDL-67673 phpunit: Remove deprecated assertEquals() params
The optional parameters of assertEquals() and assertNotEquals()
are deprecated in PHPUnit 8 (to be removed in PHPUnit 9):

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

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

Initial search done with:

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

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

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

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

Regexp to find all uses:

ag 'assert(Not)?Contains\('
2020-10-21 12:46:00 +02:00
Michael Hawkins
03397c817b MDL-68348 lib: User filter match types support - groups
Updated groups_get_members_join to support different filter match types
2020-05-25 18:35:08 +08:00
Michael Hawkins
44e47eff9a MDL-68246 lib: Prepare for participants filter multiple groups support
These function updates are in preparation for the participants_search
class, which will be used to support multiple values per filter when
filtering the participants page.
2020-05-14 15:47:52 +08:00
Shamim Rezaie
cb64dfbeb1 MDL-34411 groups: copy/paste error in test_groups_user_groups_visible 2019-07-02 08:54:36 +02:00
Shamim Rezaie
bc15800927 MDL-64521 groups: add more unit tests
These tests were created for MDL-64526, just before MDL-64521 came along
and removed the buggy code. These are good tests, so they are being
kept.
2019-01-22 16:42:38 +00:00
Sara Arjona
5290d0604b MDL-61967 core_user: Allow filtering by No groups on participants page
A new optional parameter $context has been added to the
core_group::groups_get_members_join() function.
Besides, some core_group methods now accept -1 (USERSWITHOUTHGROUP) for
the groupid field.
2018-09-24 18:33:45 +02:00
Simey Lameze
e2b7dca006 MDL-60826 groups: deprecate groups_get_all_groups_for_courses function 2018-07-24 07:58:35 +08:00
Andrew Nicols
63ce49df9b MDL-59748 groupslib: Fix time issue in unit test 2017-08-08 10:07:46 +08:00
Simey Lameze
705eea84d1 MDL-59382 core: make CiBoT happy. 2017-08-02 07:52:20 +00:00
Ryan Wyllie
aa0912258d MDL-59382 calendar: add modal to create and update events 2017-08-02 04:47:43 +00:00
Damyon Wiese
bfd42c1a88 MDL-59368 groups: More phpunit coverage
Cover $withmembers parameter to groups_get_all_groups with a unit test.
2017-07-12 10:41:32 +08:00
Jun Pataleta
d3679c37af MDL-58563 group: Specify table alias in sort parameter for group test 2017-04-11 12:40:41 +08:00
Juan Leyva
8c60d198c2 MDL-57411 groups: Fix tests for MSSQL 2017-04-05 13:17:46 +02:00
Juan Leyva
a7d9c5373e MDL-57411 groups: New helper functions
- groups_get_groups_members
- groups_get_activity_shared_group_members
2017-03-31 09:04:58 +02:00
John Beedell
905953909f MDL-31243 access/enrol libs: rename new groups functions 2016-09-30 09:27:59 +01:00
John Beedell
9121bb2d23 MDL-31243 access/enrol libs: new fns returning useful SQL fragments
Refactor similar SQL generation code from get_users_by_capability
and get_enrolled_uses to make get_with_capability_sql.
Modified files: accesslib.php, enrollib.php, grouplib.php, new tests.
2016-09-30 09:27:56 +01:00
Juan Leyva
aa5faf0070 MDL-49314 groups: Unit tests for groups_user_groups_visible 2015-04-01 10:19:26 +02:00
Jason Platts
a75a381f04 MDL-48437 Make Visible/All groups selector show own groups first 2015-02-18 09:32:23 +00:00
Simey Lameze
a0372a4019 MDL-44794 group: unit test for groups_get_user_groups method. 2014-08-04 11:59:06 +08:00
sam marshall
4c31243fc7 MDL-43252 Group menu in wrong order when groupings used 2013-12-09 13:02:12 +00:00
Aaron Barnes
2eaa440c34 MDL-42913 lib/grouplib.php: Avoid cache sometimes for groups_get_all_groups
The new groups cache returns unexpected results when you pass
in a field parameter than would normally change the result array index
2013-11-20 11:56:42 +13:00
Ankit Agarwal
ef9ca10699 MDL-21415 reports: We should fetch active group from session not page params
Also donot allow active group to be set to something that user doesn't have access to
2013-09-12 11:18:25 +08:00
Ankit Agarwal
28c4399b6b MDL-21415 reports: Adding support of groups to course participation reports
Also introducing new api groups_allgroups_course_menu() that generates a selector for all groups in course"
2013-09-10 13:14:33 +08:00
Sam Hemelryk
4960ca0738 Merge branch 'w31_MDL-39915_m26_tests' of https://github.com/skodak/moodle 2013-07-30 10:19:41 +12:00
Marina Glancy
1171ad564b MDL-40897 avoid extra DB queries in groups_get_activity_groupmode() 2013-07-28 18:47:57 +10:00
Petr Škoda
87288183a4 MDL-39915 cleanup core_grouplib_testcase 2013-07-27 18:48:18 +02:00
Ankit Agarwal
e481f05c0d MDL-40354 groups: Fix issues in groups_group_visible() 2013-07-10 10:50:22 +08:00
Ankit Agarwal
f4d46f6848 MDL-40354 groups: Add unit tests for the api groups_group_visible() 2013-07-10 10:50:21 +08:00
Sam Hemelryk
e17dbeeb1a MDL-34398 groups: implemented caching of group information. 2013-01-17 09:24:58 +13:00
Andrew Robert Nicols
74b714df7e MDL-32005 Add idnumber field to groups and groupings 2012-05-15 09:38:51 +01:00