You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/apis/subsystems/check/index.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ Checks are broken down into types, which roughly map to a step in the life cycle
55
55
56
56
Available from _/admin/environment.php_, environmental checks make sure that a Moodle instance is fully configured.
57
57
58
-
This page is a potential candidate to move to the new Check API but it slightly more complex than the other checks so hasn't been tackled yet. It would be a deeper change and this is intrinsically part of the install and upgrade system. It is not as critical to refactor as it is already possible for a plugin to declare its own checks, via either declarative [Environment checking](https://docs.moodle.org/dev/Environment_checking) or programmatically with a custom check:
58
+
This page is a potential candidate to move to the new Check API but it slightly more complex than the other checks so it hasn't been tackled yet. It would be a deeper change and this is intrinsically part of the install and upgrade system. It is not as critical to refactor as it is already possible for a plugin to declare its own checks, via either declarative [Environment checking](https://docs.moodle.org/dev/Environment_checking) or programmatically with a custom check:
Copy file name to clipboardexpand all lines: docs/apis/subsystems/output/index.md
+97-2
Original file line number
Diff line number
Diff line change
@@ -278,11 +278,11 @@ Please note that this function is a stripped version of the full `format_text()`
278
278
279
279
Some interesting parameters for this function are:
280
280
281
-
-`striplinks`: Set to `false` to remove all links after the text has been processed by filters. Used when we want to show the text inside menus, page titles, etc. (Default is `true`)
281
+
-`striplinks`: Set to `false` to keep all links after the text has been processed by filters. Used when we want to show the text inside menus, page titles, etc. (Default is `true`)
282
282
-`options`
283
283
-`options->context`: Context (id or object) for applying filters. If context is not specified it will be taken from `$PAGE->context` and may potentially result in displaying the same text differently on different pages. For example, all module-related information should have module context even when it appears in course-level reports, all course-related information such as name and description should have course context even when they are displayed on the front page or system pages.
284
284
-`options->escape`: Set to `false` if you do not want to escape HTML entities. (Default is `true`)
285
-
-`options->filter`: Set to `false` if you want to allow filters to process the text. This is ignored by `FORMAT_PLAIN` for which filters are never applied. (Default to`true`)
285
+
-`options->filter`: Set to `false` if you do not want to allow filters to process the text. This is ignored by `FORMAT_PLAIN` for which filters are never applied. (Default is`true`)
286
286
287
287
### Simple elements rendering
288
288
@@ -346,6 +346,101 @@ In the standard Boost theme this method will output a span using the [Bootstrap
346
346
<spanclass="sr-only">Contents</span>
347
347
```
348
348
349
+
### Other
350
+
351
+
#### Progress Bars
352
+
353
+
There are two types of progress bars you can use in Moodle.
354
+
355
+
##### Standard Progress Bars
356
+
357
+
The first is the old standard progress bar which updates as the page loads (ie. the page won't fully load until the progress bar is finished). It can be used to render the current process on the page, or via cli to render the progress of a script.
358
+
359
+
Example:
360
+
361
+
```php
362
+
<?php
363
+
define('NO_OUTPUT_BUFFERING', true); // Required if not used via cli.
364
+
require 'config.php';
365
+
366
+
$PAGE->set_context(context_system::instance());
367
+
$PAGE->set_url('/');
368
+
369
+
echo $OUTPUT->header();
370
+
371
+
$pb = new \core\output\progress_bar('bar', 500);
372
+
$pb->create();
373
+
$num_tasks = 500; // the number of tasks to be completed.
The other type of progress bar you can use is a stored progress bar, which can be used to store and update the progress of a long-running task in the database, and render live updates to the web page via AJAX web service polling.
389
+
390
+
It can be implemented into a CLI script. Example:
391
+
392
+
```php
393
+
<?php
394
+
395
+
define('CLI_SCRIPT', true);
396
+
397
+
require_once('config.php');
398
+
require_once($CFG->libdir . '/clilib.php');
399
+
400
+
$num_tasks = 5000; // the number of tasks to be completed.
401
+
402
+
$progress = new \core\output\stored_progress_bar('example-cli-bar');
$progress->update($cur_task, $num_tasks, 'this is '. $cur_task . '/' . $num_tasks);
408
+
}
409
+
410
+
mtrace('DONE');
411
+
```
412
+
413
+
Or a scheduled or adhoc task, via a trait. Example:
414
+
415
+
```php
416
+
class stored_progress_scheduled_task_example extends \core\task\scheduled_task {
417
+
418
+
use \core\task\stored_progress_task_trait;
419
+
420
+
public function execute() {
421
+
422
+
// This simulates a specific count of iterations the task will do, e.g. x number of courses to loop through and do something.
423
+
$iterations = 100;
424
+
425
+
$this->start_stored_progress(); // This creates the stored progress record for the named task.
426
+
427
+
for ($i = 1; $i <= $iterations; $i++) {
428
+
429
+
// Here we just update and tell it which one we are on and it will work out % from those.
430
+
$this->progress->update($i, $iterations, 'i am at ' . $i . ' of ' . $iterations);
431
+
sleep(1);
432
+
433
+
}
434
+
435
+
return true;
436
+
437
+
}
438
+
439
+
}
440
+
```
441
+
442
+
With the stored progress bars, you can update the progress either via iterations, by passing in the total amount expected and then the current iteration, using `->update()`(see: previous example), this will calculate the percentage complete for you. Or you can use `->update_full()` to manually set the percentage complete.
Prior to Moodle 4.5 only a small number of classes were compatible with scripts using the `ABORT_AFTER_CONFIG` constant.
41
41
@@ -47,6 +47,27 @@ Please note that the same limitations regarding access to the Database, Session,
47
47
48
48
:::
49
49
50
+
#### Autoloading legacy classes
51
+
52
+
<Sinceversion="4.5"issueNumber="MDL-81919" />
53
+
54
+
The Moodle class autoloader is now able to load legacy classes defined in the relevant `db/legacyclasses.php`. Files should only contain a single class.
55
+
56
+
```php title="Example entry in lib/db/legacyclasses.php"
57
+
$legacyclasses = [
58
+
// The legacy \moodle_exception class can be loaded from lib/classes/exception/moodle_exception.php.
// The legacy \cache class can be loaded from cache/classes/cache.php.
62
+
\cache::class => [
63
+
'core_cache',
64
+
'cache.php',
65
+
],
66
+
];
67
+
```
68
+
69
+
See MDL-81919 for further information on the rationale behind this change.
70
+
50
71
### SMS API
51
72
52
73
A new SMS API was introduced. See the [SMS API documentation](./apis/subsystems/sms/index.md) for more information.
@@ -142,3 +163,11 @@ class core_renderer extends \core_renderer {
142
163
</TabItem>
143
164
144
165
</Tabs>
166
+
167
+
### Refactoring BS4 features dropped in BS5 using a "bridge"
168
+
169
+
<Sinceversion="4.5"issueNumber="MDL-79917" />
170
+
171
+
Some of the Bootstrap 4 classes will be deprecated or dropped in its version 5. To prepare for this, some of the current Bootstrap 4 classes usages have been replaced with version 5 compatible classes using a "bridge". This will help us to upgrade to Bootstrap 5 in the future.
172
+
173
+
See more information in [Bootstrap 5 migration](./guides/bs5migration/index.md).
Copy file name to clipboardexpand all lines: general/development/policies/codingstyle/index.md
+19-1
Original file line number
Diff line number
Diff line change
@@ -1936,7 +1936,21 @@ All functions and methods should have a complete docblock like this:
1936
1936
1937
1937
You must include a description even if it appears to be obvious from the `@param` and/or `@return` lines.
1938
1938
1939
-
An exception is made for overridden methods which make no change to the meaning of the parent method and maintain the same arguments/return values. In this case you should omit the comment completely. Use of the `@inheritdoc` or `@see` tags is explicitly forbidden as a replacement for any complete docblock.
1939
+
An exception is made for overridden methods which make no change to the meaning of the parent method and maintain the same arguments/return values. In this case you should omit the comment completely, and apply the `#[\Override]` attribute. This can safely be applied in older versions of PHP before the attribute was supported. Use of the `@inheritdoc` or `@see` tags is explicitly forbidden as a replacement for any complete docblock.
1940
+
1941
+
<ValidExample>
1942
+
1943
+
```php
1944
+
class example implements templatable {
1945
+
1946
+
#[\Override]
1947
+
public function export_for_template(renderer_base $output) {
1948
+
return ['foo' => 'bar'];
1949
+
}
1950
+
}
1951
+
```
1952
+
1953
+
</ValidExample>
1940
1954
1941
1955
### Defines
1942
1956
@@ -2056,6 +2070,10 @@ To get the full list of exception types, search for the regular expression 'clas
2056
2070
2057
2071
Where appropriate, you should create new subclasses of moodle_exception for use in your code.
2058
2072
2073
+
<Sinceversion="4.5"issueNumber="MDL-81903" />
2074
+
2075
+
If you create a custom exception class it *may* live in the `classes/exception/` directory, and be namespaced in `<plugin>/exception/`
2076
+
2059
2077
A few notable exception types:
2060
2078
2061
2079
-`moodle_exception`: base class for exceptions in Moodle. Use this when a more specific type is not appropriate.
Copy file name to clipboardexpand all lines: general/development/tools/behat/writing.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -113,7 +113,7 @@ In PhpStorm or IntelliJ you can install the behat extension. Then you get auto c
113
113
114
114
Most of the steps requires values, there are methods to provide values to steps, the method depends on the step specification.
115
115
116
-
-**A string/text** is the most common case, the texts are wrapped between double quotes (`"` character) you have to replace the info about the expected value for your value; for example something like **I press "BUTTON_STRING"** should become **I press "Save and return to course"**. If you want to add a string which contains a " character, you can escape it with \", for example **I fill the "Name" field with "Alan alias \"the legend\""**. You can identify this steps because they ends with **_STRING**
116
+
-**A string/text** is the most common case, the texts are wrapped between double quotes (`"` character) you have to replace the info about the expected value for your value; for example something like **I press "BUTTON_STRING"** should become **I press "Save and return to course"**. If you want to add a string which contains a " character, you can escape it with a backslash `\"`, for example **I fill the "Name" field with "Alan alias \\"the legend\\""**. You can identify this steps because they ends with **_STRING**
117
117
-**A number** some steps requires numbers as values, to be more specific an undetermined number of digits from 0 to 9 (Natural numbers + 0) you can identify them because the expected value info string ends with **_NUMBER**
118
118
-**A table**; is a relation between values, the most common use of it is to fill forms. The steps which requires tables are easily identifiable because they finish with **:** The steps description gives info about what the table columns must contain, for example **Fills a moodle form with field/value data**. Here you don't need to escape the double quotes if you want to include them as part of the value.
119
119
-**A PyString** is a multiline string, most commonly used to fill out forms when a newline is required. Like steps with tables, steps which require PyStrings will end with ":"
0 commit comments