|
|
3 weeks ago | |
|---|---|---|
| classes | 3 weeks ago | |
| db | 3 weeks ago | |
| lang | 3 weeks ago | |
| tests | 3 weeks ago | |
| .gitignore | 3 weeks ago | |
| LICENSE | 3 weeks ago | |
| README.md | 3 weeks ago | |
| client.php | 3 weeks ago | |
| manage.php | 3 weeks ago | |
| settings.php | 3 weeks ago | |
| version.php | 3 weeks ago |
local_sharixMoodle-side integration boundary for ShariX Open / Platform.
This repository is the standalone GPLv3 Moodle plugin described by the ShariX ↔ Moodle integration specification. The Moodle component name is fixed as local_sharix.
The plugin is licensed as GPL-3.0-only.
This source contains the accepted Stage 1 foundation, the Moodle-side Stage 2 course contract, the Stage 4 managed-access contract, and the Stage 5 normalized course-user-state contract:
allow_existing_courses, allow_provider_courses, allow_course_creation);local/sharix:useintegration;local_sharix_api;local_sharix_get_info handshake / feature discovery;local_sharix_resolve_users exact bulk username resolution;local_sharix_get_courses;local_sharix_get_actor_courses, using native moodle/course:update capability rather than role ids;local_sharix_create_course;local_sharix_access_binding ownership records keyed by (client, external_key);local_sharix_sync_cohort_access with plugin-owned hidden cohorts and standard Moodle cohort-enrolment instances;local_sharix_ensure_user_enrolment for controlled individual access;local_sharix_get_course_user_state for one scoped course and exact canonical username;RequirementCheck pass/fail.Stage 5 keeps business evaluation in ShariX. Moodle reports facts; ShariX applies completion and minimum-score policy.
The target deployment is confirmed as Moodle 5.0.2+ (Build: 20250926). This plugin therefore requires Moodle 5.0.2 (2025041402) or later within the Moodle 5.0 branch and declares $plugin->supported = [500, 500].
Stage 1 through Stage 5 implementation must be checked against the Moodle 5.0 External API, Access API, Course API, Enrolment API, Cohort API, Upgrade API, and locking APIs. The plugin does not claim compatibility with Moodle 4.x or with Moodle 5.1+ until that range is explicitly tested and released.
Copy or clone this repository as:
<moodle-root>/local/sharix
Then run the normal Moodle plugin upgrade procedure. Do not patch Moodle core.
The ShariX Integration API now exposes normalized Stage 4 managed-access and Stage 5 course-user-state endpoints. The check workflow no longer needs direct manual-enrolment, completion-status, or grade-report core web-service functions. A small set of standard read-only core functions remains temporarily for compatibility paths outside Stage 5 and can be removed in a later cleanup once those paths are fully retired.
local/sharix:useintegration, and assign it to that user at system context.ShariX Integration API (local_sharix_api). Authorize only the intended technical user for that service and issue an individual token for that user.local_sharix never stores raw tokens.Use a separate technical user, client record, and token for every ShariX deployment (for example production and testing).
local_sharix_get_infoNo business parameters. The authenticated web-service user must:
local/sharix:useintegration;local_sharix_client record;The response exposes API version, current client flags and feature flags. At Stage 5 both managed_cohort_access and course_user_state are true.
local_sharix_resolve_usersInput:
{
"usernames": ["+31611111111", "+31622222222"]
}
The lookup is exact and local-site-only. Duplicate inputs are collapsed to the first occurrence. Missing users are normal results, not exceptions. Only username, Moodle id, active/suspended/deleted state are returned; profile names and e-mail addresses are not exposed.
The canonical ShariX deployment convention remains:
ShariX user.phone_number = LDAP uid = Moodle username
The plugin itself does not create users and does not become an identity source.
local_sharix_get_coursesReturns only curated existing courses in the authenticated client scope. Scope is the union of explicit course mappings and enabled existing category scopes. Empty scope is empty; it never means all courses.
local_sharix_get_actor_coursesInput is exact actor_uid. The plugin resolves the actor by exact Moodle username, limits candidate courses to the client provider scope, and then applies Moodle's native moodle/course:update capability for that actor. Missing or inactive actors return a normalized result with an empty course list.
local_sharix_create_courseCreates a course only when allow_course_creation is enabled and the client has a valid provider category and course-context provider role. The operation requires an opaque idempotency_key. A retry with the same key and same payload returns the same course; the same key with a different payload is rejected.
The course is created in the configured provider category. The actor receives the configured role at course context with plugin ownership metadata. Creation uses a Moodle lock and a unique (clientid, idempotencyhash) database index.
local_sharix_sync_cohort_accessInputs are an opaque stable external_key, a Moodle courseid, canonical Moodle usernames, and remove_stale. The course must belong to the authenticated client's Moodle-side scope.
The first call creates or reuses exactly one local_sharix-owned hidden system cohort and one standard Moodle cohort-enrolment instance. Repeated calls reconcile membership idempotently. When remove_stale=true, removals are performed only from that exact owned cohort. The plugin never removes a user's LDAP enrolment, another cohort membership, administrator-managed manual access, or another client's cohort.
The response reports binding/cohort/enrolment-instance ids, requested/resolved counts, additions/removals, and missing usernames. Missing users are a structured result and do not turn the whole reconciliation into an opaque server error.
local_sharix_ensure_user_enrolmentInputs are an opaque stable external_key, a Moodle courseid, and one exact Moodle username. If the user already has active access by any Moodle enrolment path, the call succeeds without creating redundant ShariX access. Otherwise the plugin idempotently uses the standard Moodle manual-enrolment plugin and records the ShariX binding.
Stage 4 deliberately has no automatic unenrol counterpart. Completing or deleting a ShariX check does not revoke access.
local_sharix_get_course_user_stateInputs are a scoped Moodle courseid, one exact Moodle username, and optional grade_item_id (0 means the Moodle course total). The endpoint is read-only. It returns normalized Moodle facts:
user_found / active / userid
enrolled
completion_enabled / completion_tracked / completed / completion_time
grade.available / itemid / value / max / percent
The course must be in the authenticated client's persisted Moodle-side scope. A missing, suspended, or deleted user is returned as a normal normalized state rather than an opaque exception. Existing LDAP, cohort, manual, or other active enrolment is observed without creating a local_sharix_access_binding.
The plugin does not decide whether the result passes a ShariX training requirement. It does not know CheckDefinition, minimum_score, Provider relationships, or ShariX service semantics. Those decisions remain in ShariX.
Completion is reported from Moodle's native completion subsystem. Grade lookup uses the requested item when supplied and otherwise the course-total grade item; the API returns both the raw final grade and a normalized percentage. If no numeric grade exists, grade.available=false.
The machine-readable error contract currently uses:
CLIENT_NOT_CONFIGURED
CLIENT_DISABLED
FEATURE_NOT_ALLOWED
COURSE_OUT_OF_SCOPE
ACTOR_NOT_FOUND
ACTOR_INACTIVE
ACTOR_CANNOT_MANAGE_COURSE
PROVIDER_CATEGORY_NOT_CONFIGURED
PROVIDER_ROLE_NOT_CONFIGURED
COURSE_CREATE_FAILED
IDEMPOTENCY_CONFLICT
LOCK_TIMEOUT
INVALID_REQUEST
USER_NOT_FOUND
USER_INACTIVE
ACCESS_BINDING_CONFLICT
ACCESS_PROVISION_FAILED
OWNERSHIP_MISMATCH
ENROLMENT_METHOD_UNAVAILABLE
Localized error text is presentation only. ShariX adapters must branch on stable error codes, never translated text.
local_sharix-owned cohort.external_key is opaque integration data; the plugin does not parse ShariX business semantics from it.Run within a matching Moodle test environment:
vendor/bin/phpunit --testsuite local_sharix_testsuite
At minimum, the current acceptance suite must cover:
get_info returns API v1 and client flags;+ phone UID;moodle/course:update with a custom role;The supplied source bundle does not contain a Moodle core checkout, so PHPUnit and install/upgrade execution must be run in the real/sandbox Moodle 5.0.2+ environment before acceptance.
The standard Moodle enrolment plugins Cohort sync (cohort) and Manual enrolments (manual) remain required for Stage 4 managed access. Moodle site/course completion must be enabled on courses where completion is a ShariX requirement. Existing ShariX client records, technical users, tokens, policy flags and course scopes are retained across the plugin upgrade. No third-party completion or grade web-service plugin is required.
Stage 5 does not introduce a new Moodle-side training-status domain and does not replace ShariX document/manual evidence. local_sharix_get_course_user_state is only an integration evidence source for the existing shared RequirementCheck workflow.