Moodle local plugin for transferring prepared results from an external MIS database/view to a configurable remote stored procedure.
The plugin is intentionally:
- schema-agnostic
- procedure-agnostic
- driver-agnostic
- fully admin-configurable
It supports configurable source mappings, configurable stored procedure parameter mappings, configurable success handling, retry handling, and configurable transfer tracking.
The latest Plymouth testing update expects the transfer to read from the published results view and call:
insertTestComponentOfferingAssociationStudentResult
with ordered parameters:
associationIdrolestateattempttestComponentOfferingIdpersonIdresultStateresultPassresultScoreresultDateTimeotherCodesSPRotherCodesSubmissionStateSTATUSOUTPUT parameter
The expected success value is:
SUCCESS
Any other returned value is treated as failure and the source row remains retryable.
local_srs_webservice
↓
mis.exported_grades
↓
mis.published_TestComponentAssociationStudentResults
↓
local_results_transfer
↓
Remote stored procedure
The plugin owns only the second-hop transfer process.
Site administration
→ Plugins
→ Local plugins
→ Results Transfer
Accessed from the main Results Transfer settings page via:
Open field mapping configuration
The mapping page stores ordered procedure mapping as JSON in Moodle config:
local_results_transfer/procedure_parameters_json
- Input rows require a source column.
- Output rows do not require a source column.
- Output rows automatically disable source-column editing.
- The
Ordervalue controls stored procedure parameter order. - Parameters are sorted automatically before execution.
- Mapping is schema-agnostic and procedure-agnostic.
- Procedure parameters are passed positionally.
The plugin currently supports:
| Driver | Purpose |
|---|---|
mysqli |
Source database and local development testing |
sqlsrv |
Optional MSSQL/sqlsrv support |
odbc |
Preferred Plymouth production/UAT approach |
The plugin now supports:
php8.1-odbc
+
Microsoft ODBC Driver 18 for SQL Server
via:
odbc_target_driver
This avoids requiring:
sqlsrv.so
and aligns with Debian/Ubuntu packaged-extension management.
For ODBC mode, the stored procedure should also return:
SELECT @STATUS AS status;so the plugin can read the returned status row cleanly through ODBC.
Current Plymouth-oriented configuration:
| Setting | Value |
|---|---|
| Source table/view to read | mis.published_TestComponentAssociationStudentResults |
| Source table to update | mis.exported_grades |
| Transferred/status field | grade_transferred |
| Transfer field type | Datetime / NOW() |
| Remote procedure success value | SUCCESS |
For datetime transfer fields, the plugin treats the following values as "not transferred":
NULL- blank
0000-00-00 00:00:001970-01-01 00:00:001970-01-01 01:00:00
Successful rows are stamped using:
NOW()Run manually from Moodle root:
php admin/cli/scheduled_task.php --execute="\\local_results_transfer\\task\\transfer_task"Default cadence:
Every 15 minutes
via Moodle scheduled tasks.
The scheduled task:
- Connects to source database
- Selects untransferred rows
- Builds ordered procedure parameters dynamically
- Calls configured stored procedure
- Processes returned SUCCESS/FAIL value
- Marks successful rows as transferred
- Leaves failed rows retryable
- Logs all activity through
mtrace()
The scheduled task reads mapping configuration from:
procedure_parameters_json
The legacy textarea configuration is only used as fallback if no JSON mapping exists.
The plugin supports fully local simulation using:
- local MySQL/MariaDB
- mock source tables/views
- mock stored procedures
- configurable mappings
- configurable retry handling
This allows end-to-end testing without requiring client infrastructure access.
Validated locally:
- Plugin installation
- Configurable source DB
- Configurable target DB
- Dynamic parameter mapping
- Ordered parameter execution
- SUCCESS / FAIL handling
- Retry handling
- Datetime transfer tracking
- Dynamic JSON mapping runtime
- End-to-end transfer simulation
- ODBC-compatible architecture