128 Commits

Author SHA1 Message Date
Laurent David
9117af48ac MDL-77781 core_completion: Completion view must be deleted too
When resetting a course, completion view entries should also be
deleted

Co-authored-by: Georg Moser <georg@moser.link>
2023-05-03 16:05:28 +02:00
Ilya Tregubov
3ebd25ff48 MDL-75719 completion: Fix viewed criteria.
When we unlock completion criteria and save changes 'viewed' criteria
still should be completed if user has viewed activity before. Seems
that that was broken by recent changes. Fixing here.
2023-03-02 11:04:08 +08:00
Ilya Tregubov
7e3d9db579 MDL-75719 completion: Fix completion state for hidden grade items.
For hidden grade items we used to mark students as completed if
they have any grade. But this was not working correctly when we
also set pass grade for activity and completion criteria based
on pass grade. So we will have these completion states

Competion criteria 'Receive grade':
No grade - COMPLETION_INCOMPLETE
Grade visible, achieved passing grade - COMPLETION_COMPLETE_PASS
Grade visible, failed passing grade - COMPLETION_COMPLETE_FAIL
Grade hidden - COMPLETION_COMPLETE

Completion criteris 'Receive passing grade'
No grade - COMPLETION_INCOMPLETE
Grade visible, achieved passing grade - COMPLETION_COMPLETE_PASS
Grade visible, failed passing grade - COMPLETION_COMPLETE_FAIL
Grade hidden, achieved passing grade - COMPLETION_COMPLETE_PASS
Grade hidden, failed passing grade - COMPLETION_COMPLETE_FAIL_HIDDEN
2023-03-02 11:04:08 +08:00
Marina Glancy
66dcb1683b MDL-76356 various: avoid implicit conversion to arrays
PHP before version 8.1 automatically converted stdClass or 'false' to arrays if
function parameter expects array (for example, "reset").
PHP 8.1 shows notices in these situations
2023-01-10 15:03:40 +01:00
Stephan Robotta
d7734740b2 MDL-76074 completion: fixed filter in reports with custom user fields
When the site uses custom user text fields that would show up in a
user list, the filter for firstname or lastname didnt work anymore.
If a filter was used, no result would show up. Users where shown only
when the course reports where used without filters.
2022-12-06 08:24:46 +01:00
hieuvu
c6e018e04e MDL-58266 core_completion: Add new view table. 2022-10-14 00:30:28 +07:00
Sujith Haridasan
73d604369d MDL-71062 core: Step 1 deprecation of print_error function 2022-07-13 08:20:54 +05:30
Simey Lameze
fe4fd6d817 MDL-73756 lib: deprecate modinfo parameter from get_data 2022-03-01 10:20:46 +08:00
Ferran Recio
c64bef51a9 MDL-73547 core_courseformat: enable course index cache
Adding caches to the course editor reactive state. The patch improve the
course index loading.
2022-02-21 12:33:33 +01:00
Andrew Nicols
70cc41eec8 MDL-72246 core_completion: Only fetch other completion data on requested
Prior to this patch, the code was fetching all completion data for all
activities in a course, even when the activity was not requested. This
leads to recursion issues as the data has not been added to the cache
before this operation occurs.

To handle this situation, only the requested CM is fetched in full, and
a boolean flag is used to store whether the full data has been fetched.

When returning a partially fetched value from the cache, the flag is
used to determine whether more data must be fetched, and the cache
updated.

The flag is filtered out before the value is returned.

Note: Many of the tests were updated as these were inspecting private
features of the API which should not really be tested.
2022-02-08 11:35:23 +08:00
Peter Dias
cb2afc668d MDL-72827 completion: Revert completion flow logic
- Reverts the custom flow logic introduced in the 52206
- Expand unit tests to cover different grade based completion settings
2021-10-28 11:38:10 +08:00
Peter Dias
2c7893cf9f MDL-52206 core: Update new activity_custom_completion
Update the custom_completion classes to accept the new completion
criteria
2021-10-04 19:45:47 +08:00
Peter Dias
d975251813 MDL-52206 completion: New criteria to handle behaviour between modules 2021-10-04 19:45:45 +08:00
Peter
90acd8d381 MDL-52206 core: Add completion criteria to course_modules 2021-10-04 19:44:02 +08:00
Ferran Recio
cb39d0d28d MDL-72566 completion: fix missing mod bug
MDL-71899 produces a regression. When an activity plugin is not present
but it has activities in the DB the course view returns an exception.
With this patch the code will ignore missing modules when calculating
the completion.
2021-09-16 09:59:10 +02:00
Huong Nguyen
3150612163 MDL-71899 performance: Improve activity completion data caching
- Modified SQL in get_data() to get the activity completion of all course modules without calling get_fast_modinfo() to reduce the DB queries.
 - Building activity completion cache for the whole course in one time instead of building the cache for each course module by passing $wholecourse = true to get_data()
2021-09-09 10:03:21 +07:00
Ilya Tregubov
4819625349 MDL-32103 completion: Allow instant completion updates.
For activity based course completion criteria allow instant
course completion updates if the activity completion state was changed
for a single user.
2021-07-13 12:07:53 +02:00
Luca Bösch
9fc6c45b10 MDL-71634 course: Do not show "Your progress" info any more. 2021-06-17 19:22:13 +02:00
Eloy Lafuente (stronk7)
1a8f79a177 Merge branch 'MDL-71595-master' of https://github.com/sammarshallou/moodle 2021-05-31 22:34:39 +02:00
David Mudrák
a949a151f3 MDL-71659 completion: Consider modules without grade_item incomplete
Activity modules may not have the associated grade_item created yet. It
used to throw fatal error in that case - even when trying to view the
course or edit the activity. So there was no easy way to recover from
this situation.

The patch is based on reasoning that an activity without grade item is
same as activity without any grades. And as such it is considered
incomplete.

A new unit test is added to cover this specific scenario. The existing
unit test is modified and it does not expect the exception any more.
There does not seem to be any good reason why this situation should be
exceptional.
2021-05-18 20:59:51 +02:00
sam marshall
588cb0fff6 MDL-71595 report_progress: Add custom user field support 2021-05-11 16:57:02 +01:00
Michael Hawkins
8e843696a2 MDL-71401 core_completion: Fix completion status caching
When an automatic completion condition may have had its state change,
we now unset the cached value for the user's completion in the relevant
activity, so up-to-date values are re-fetched and available to students.
The previous behaviour was that custom conditions would remain cached
until the activity reached overall completion.
2021-05-04 12:18:36 +08:00
Jun Pataleta
11df82e9f7 Merge branch 'MDL-71410-master' of git://github.com/rezaies/moodle 2021-04-27 12:36:24 +08:00
Shamim Rezaie
4ddc9fe0f4 MDL-71410 core: Prevent recursively calling getters 2021-04-27 14:32:26 +10:00
Jun Pataleta
d0963c711f MDL-71144 completion: Deprecate get_completion_state callbacks
* *_get_completion_state() callback functions have been deprecated and
should no  longer be used. Plugins that define custom completion rules
must implement the mod_[modname]\completion\custom_completion class that
extends the \core_completion\activity_custom_completion base class.
2021-04-22 09:48:50 +10:00
Simey Lameze
a4f7c1d91f MDL-70781 course: setting for displaying completion conditions
Part of MDL-70817
2021-04-02 21:53:20 +08:00
sam marshall
5e72715e4f MDL-71099 Lib: Move new user_fields class from core to core_user
This class would belong more appropriately within the 'user' API
(core_user) instead of within the 'core' API, since it is
directly related to user data.

Since the class has only just been added to Moodle, now is a good
time to move it.
2021-03-25 13:47:23 +00:00
Michael Hawkins
fd302dc842 MDL-71104 core_completion: Fix fetching of grade completion status
We should be able to fetch the grade completion status for modules
that do not have custom completion configured. This also improves
unit testing coverage.
2021-03-23 12:25:22 +08:00
Jun Pataleta
fc238f329d MDL-70815 completion: Cast custom data to array
Since cm_info::customdata can be of any type, we need to cast it to an
array first before checking for custom completion rules. Otherwise,
an exception can be thrown (e.g. customdata has been set as an stdClass)
2021-03-10 19:22:15 +01:00
Jun Pataleta
5a7c629f7c Merge branch 'MDL-45242-master' of https://github.com/sammarshallou/moodle 2021-03-10 23:39:30 +08:00
sam marshall
558cc1b85e MDL-45242 Lib: Replace calls to deprecated functions
In all cases changes have been kept to a minimum while not making
the code completely horrible. For example, there are many instances
where it would probably be better to rewrite a query entirely, but
I have not done that (in order to reduce the risk of changes).
2021-03-10 10:57:10 +00:00
Jun Pataleta
32721b3511 MDL-70815 core_completion: Update completion_info
* Update completion_info::get_data() to add other completion
information from a new method called get_other_cm_completion_data().
This allows the storage of the completion statuses of the following
completion rules to completion_info objects:
  - 'Students must receive a grade' completion rule.
  - Any custom completion rule defined by an activity.
This allows detailed completion information to be fetched for course
modules.
It also allows custom completion statuses to be cached which will help
reduce DB queries when fetching completion statuses.
* Update update_state() to fetch overall completion state from the
module's activity_custom_completion implementation. Falls back to the
*_get_completion_state() callback function.
* Update internal_set_data() to include the other cm completion data
in the updated cache data for the module instance.
2021-03-09 20:15:28 +08:00
Jun Pataleta
18ef213da5 MDL-70815 core_completion: completion_info::get_grade_completion()
Move the current logic for determining the completion status for the
"Student must receive grade" completion rule to a function so it cann
be reused.
Unit test included.
2021-03-09 20:15:28 +08:00
Paul Holden
abde761cb6 MDL-40081 completion: clean up criteria records for deleted courses. 2020-04-06 12:22:51 +01:00
Jake Dallimore
26a94308ee Merge branch 'MDL-65276-master' of git://github.com/lameze/moodle 2019-04-30 20:47:26 +02:00
Alexander Bias
d6cea5ccd9 MDL-65056 completion: Hide checkboxes on course page for teachers 2019-04-19 11:40:00 +02:00
Simey Lameze
846c585910 MDL-65276 core: fix CiBoT complains 2019-04-08 10:30:09 +08:00
Simey Lameze
fe4f55ee40 MDL-65276 core: move completion_cron_aggregate() to completionlib 2019-04-05 13:38:30 +08:00
Mark Nelson
5211efb99b MDL-37933 core_complete: fixed criteria/criterion naming confusion 2017-11-27 15:26:43 +08:00
Jake Dallimore
8fbc41d8d5 MDL-37361 completion: minor code fixes. 2017-10-10 17:12:09 +08:00
Jake Dallimore
86f359bf68 MDL-37361 completion: automatic completion disabled when overridden
Changes:
- Activities with auto completion and a completion status overridden to
COMPLETION_COMPLETE are no longer processed by normal completion
triggers.
- All activities can still be completed by students when their
completion status has been overridden to COMPLETION_INCOMPLETE, via
either auto or manual triggers.
- Completion unit tests updated
2017-10-10 17:10:49 +08:00
Eiz Eddin Al Katrib
a39918daae MDL-37361 completion: Enabled overriding activity completion status 2017-10-10 17:10:15 +08:00
Dan Poltawski
4469ae96b6 Merge branch 'wip-MDL-51917-master' of git://github.com/marinaglancy/moodle 2017-06-19 12:21:45 +01:00
Marina Glancy
fe81ef397c MDL-51917 course completion: order activities in reports
Thanks to Nick Phillips for initial patch
2017-06-13 14:46:25 +08:00
Damyon Wiese
ddce4f4ba9 MDL-58136 cache: Add a course completion cache
The last change added 1 db read per course per page which is not OK. Add a cache to compensate.
2017-06-13 10:03:00 +08:00
Jake Dallimore
f939a6d452 MDL-54751 core_completion: Exclude activities pending deletion 2016-11-07 07:41:59 +08:00
sam marshall
5c2ef08fa3 MDL-55628 Completion: Use simpledata for completion cache
The completion cache is currently not marked as simpledata. On the
course page it is frequently retrieved hundreds of times which results
in many calls to the slow unserialize function. By making a slight
change to the data format (using arrays instead of objects) we can
mark it as simpledata, which will avoid using unserialize.
2016-08-22 17:13:36 +01:00
Dan Poltawski
194a02e409 MDL-52471 completion: fix deprecated use of 'object'
And add a unit test covering completion_can_view_data() without
full course object passed.
2015-12-10 15:47:11 +00:00
Ankit Agarwal
28ac49c899 MDL-46294 completion: Final deprecation of get_incomplete_criteria 2015-06-03 07:36:40 +05:30
Marina Glancy
f79747171d MDL-46960 completion: trigger event after clearing cache 2015-04-02 11:08:22 +02:00