Skip to content
Open
Show file tree
Hide file tree
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
53 changes: 53 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
> **Note:** Please fill out all required sections and remove irrelevant ones.
### 🔀 Purpose of this PR:

- [ ] Fixes a bug
- [ ] Updates for a new Moodle version
- [ ] Adds a new feature of functionality
- [ ] Improves or enhances existing features
- [ ] Refactoring: restructures code for better performance or maintainability
- [ ] Testing: add missing or improve existing tests
- [ ] Miscellaneous: code cleaning (without functional changes), documentation, configuration, ...

---

### 📝 Description:

Please describe the purpose of this PR in a few sentences.

- What feature or bug does it address?
- Why is this change or addition necessary?
- What is the expected behavior after the change?

---

### 📋 Checklist

Please confirm the following (check all that apply):

- [ ] I have `phpunit` and/or `behat` tests that cover my changes or additions.
- [ ] Code passes the code checker without errors and warnings.
- [ ] Code passes the moodle-ci/cd pipeline on all supported Moodle versions or the ones the plugin supports.
- [ ] Code does not have `var_dump()` or `var_export` or any other debugging statements (or commented out code) that
should not appear on the productive branch.
- [ ] Code only uses language strings instead of hard-coded strings.
- [ ] If there are changes in the database: I updated/created the necessary upgrade steps in `db/upgrade.php` and
updated the `version.php`.
- [ ] If there are changes in javascript: I build new `.min` files with the `grunt amd` command.
- [ ] If it is a Moodle update PR: I read the release notes, updated the `version.php` and the `CHANGES.md`.
I ran all tests thoroughly checking for errors. I checked if bootstrap had any changes/deprecations that require
changes in the plugins UI.

---

### 🔍 Related Issues

- Related to #[IssueNumber]

---

### 🧾📸🌐 Additional Information (like screenshots, documentation, links, etc.)

Any other relevant information.

---
13 changes: 10 additions & 3 deletions .github/workflows/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{
"main-moodle": "MOODLE_405_STABLE",
"main-php": "8.3",
"moodle-php": {
"MOODLE_401_STABLE": ["8.0","8.1"],
"MOODLE_405_STABLE": ["8.1","8.2","8.3"]
"main-db": "pgsql",
"moodle-testmatrix": {
"MOODLE_401_STABLE": {
"php": ["8.0", "8.1"],
"db": ["pgsql", "mariadb", "mysqli"]
},
"MOODLE_405_STABLE": {
"php": ["8.1", "8.2", "8.3"],
"db": ["pgsql", "mariadb", "mysqli"]
}
},
"moodle-plugin-ci": "4.4.5"
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Used for simulating cron during development
development.php
/.idea/
/trigger/customfieldsemester/
1 change: 1 addition & 0 deletions activeprocesses.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
require_once($CFG->libdir . '/adminlib.php');

require_login();
require_capability('moodle/site:config', context_system::instance());

$syscontext = context_system::instance();
$PAGE->set_url(new \moodle_url(urls::ACTIVE_PROCESSES));
Expand Down
1 change: 1 addition & 0 deletions activeworkflows.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
require_once($CFG->libdir . '/adminlib.php');

require_login();
require_capability('moodle/site:config', context_system::instance());

$syscontext = context_system::instance();
$PAGE->set_url(new \moodle_url(urls::ACTIVE_WORKFLOWS));
Expand Down
157 changes: 157 additions & 0 deletions classes/local/intersectedRecordset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?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/>.

/**
* Helper class which intersects multiple moodle record sets.
*
* @package tool_lifecycle
* @copyright 2025 Michael Schink JKU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_lifecycle\local;

defined('MOODLE_INTERNAL') || die();

class intersectedRecordset implements \Iterator, \Countable {
private $records = [];
private $position = 0;
private $wasFilled = false;

/**
* Constructor: Inits class & intersects passed recordsets.
*
* @param moodle_recordset|array|null $recordsets
* @param string $key
*/
public function __construct($recordsets = null, string $key = 'id') {
if($recordsets !== null) {
if(is_array($recordsets)) {
// For multiple recordsets
foreach($recordsets as $recordset) {
// If recordset is a chunked recordset
if(is_array($recordset)) {
//mtrace('Chunked recordset');
// Create new array for chunked recordset
$chunkedRecords = [];
// For each chunked recordset
foreach($recordset as $chunk_recordset) {
// For each record in chunked recordset
foreach($chunk_recordset as $record) {
if(isset($record->$key)) { $chunkedRecords[$record->$key] = $record; }
}
}
// Add all records of chunked recordsets
$this->add($chunkedRecords, $key);
} else {
//mtrace('Normal recordset');
$this->add($recordset, $key);
}
}
} else { $this->add($recordsets, $key); }
}
}

/**
* Adds recordset & saves intersection of all recordsets.
*
* @param moodle_recordset $recordset
* @param string $key
*/
public function add($recordset, string $key = 'id'): void {
// Add new records to array with key
$newRecords = [];
foreach($recordset as $record) {
if(isset($record->$key)) { $newRecords[$record->$key] = $record; }
}
//mtrace(' Found '.count($newRecords).' records in recordset');
//$recordset->close();

// Store new records without key, if no records were stored & return
if(empty($this->records) && !$this->wasFilled) {
$this->records = array_values($newRecords);
$this->wasFilled = true;

return;
}

// Add existing records to array with key
$existingRecords = [];
foreach($this->records as $record) {
if(isset($record->$key)) { $existingRecords[$record->$key] = $record; }
}

// Intersect existing & new records by keys
$intersectionKeys = array_intersect_key($existingRecords, $newRecords);
// Clear existing records
$this->records = [];
// Store intersected records by keys
foreach($intersectionKeys as $keyValue => $record) {
$this->records[] = $existingRecords[$keyValue];
}
//mtrace('Add - Intersected record sets: '.count($this->records));
}

/**
* Returns current recordset.
*
* @return mixed
*/
public function current(): mixed {
return $this->records[$this->position];
}

/**
* Returns current key (index).
*
* @return int
*/
public function key(): int {
return $this->position;
}

/**
* Moves internal pointer to next recordset.
*/
public function next(): void {
$this->position++;
}

/**
* Returns internal pointer to start.
*/
public function rewind(): void {
$this->position = 0;
}

/**
* Checks if current pointer points to a valid recordset.
*
* @return bool
*/
public function valid(): bool {
return isset($this->records[$this->position]);
}

/**
* Returns the amount of all recordsets.
*
* @return int
*/
public function count(): int {
return count($this->records);
}
}
Loading
Loading