Skip to content

MDL-81714 Update stored progress API example #1273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docs/apis/subsystems/output/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ class stored_progress_scheduled_task_example extends \core\task\scheduled_task {
// This simulates a specific count of iterations the task will do, e.g. x number of courses to loop through and do something.
$iterations = 100;

$this->start_stored_progress(); // This creates the stored progress record for the named task.
$this->start_stored_progress(); // Updates the stored progress record with a start time.

for ($i = 1; $i <= $iterations; $i++) {

Expand All @@ -498,6 +498,9 @@ class stored_progress_scheduled_task_example extends \core\task\scheduled_task {
}

}

$task = new stored_progress_scheduled_task_example();
$task->initialise_stored_progress(); // Creates a stored progress record, so the progress can be displayed in "pending" state.
```

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.
Expand Down