Automations and Integrations
Organisation structures are often managed by an existing HR system that has to synchronise data with other systems. Moodle Workplace offers two main options to automate this process:
CSV files
The Migration tool supports the creation of departments and positions in bulk. The Import wizard allows you to specify how columns in the CSV file should be mapped onto the properties of departments and positions.
Only the name field is required, that is, the smallest working CSV file can have only a single column.
Below a sample CSV file adding 10 nodes to the department hierarchy
id,code,parent,name,description,descriptionformat 1,SAL,,Sales,Sales department,1 2,SAD,SAL,Sales development,Sales development department,1 3,CSC,SAL,Customer Success,Customer Success department,1 4,EDI,,Editorial,Editorial department,400 5,AND,EDI,Art and design,Art and design department,1 6,PRO,EDI,Production,Production department,1 7,RNE,EDI,Research and Education,Research and Education department,1 8,MED,RNE,Medical advising,Medical advising department,1 9,MHR,RNE,Mental Health research,Mental Health research department,1 10,ONR,RNE,Oncology research,Oncology research department,1
The Upload users tool has been enhanced in Moodle Workplace to assign job assignments in bulk or change existing jobs (set the end date).
The Moodle CLI has been extended to support the import of CSV files for departments and positions. In order to import organisation elements into a department framework, the CLI syntax is as follows:
php admin/tool/wp/cli/import.php --file=<CSV file> --importer="tool_organisation\\tool_wp\\importer\\departments_csv" --tenant=<tenant_id> --user=<user_id> --settings=<settings>
Example of the CLI command that will import the above sample department file with the following settings:
- departments need to be imported into a new framework,
- the column 'code' should be used as the identifier for the parent lookup
- column 'code' should be mapped to 'idnumber'
- in case when idnumber is not unique, importer should increment it (other options would be 'skip' - not to import at all, and 'empty' - to set idnumber to empty).
php admin/tool/wp/cli/import.php --file="/var/www/html/organisation1.csv" --importer="tool_organisation\\tool_wp\\importer\\departments_csv" --tenant=1 --user=admin --settings="{\"target_framework\":\"new\",\"hierarchy\":\"selected\",\"identifier\":\"code\",\"csvmapping:name\":\"name\",\"csvmapping:idnumber\":\"code\",\"csvmapping:description\":\"description\",\"csvdefault:descriptionformat\":\"1\",\"csvmapping:parentid\":\"parent\",\"conflict:csvdata:idnumberconflict:action\":\"increment\"}"
The following command imports the above sample department file into an existing framework with the idnumber "org2":
php admin/tool/wp/cli/import.php --file="/var/www/html/organisation1.csv" --importer="tool_organisation\\tool_wp\\importer\\departments_csv" --tenant=1 --user=admin --settings="{\"target_framework\":\"selected\",\"select_frameworkidnumber\":\"org2\",\"hierarchy\":\"selected\",\"identifier\":\"code\",\"csvmapping:name\":\"name\",\"csvmapping:idnumber\":\"code\",\"csvmapping:description\":\"description\",\"csvdefault:descriptionformat\":\"1\",\"csvmapping:parentid\":\"parent\",\"conflict:csvdata:idnumberconflict:action\":\"increment\"}"
For more information on the importing and exporting data can be found in the Migration CLI section.
Web services
The following web services have been introduced to handle organisations:
- tool_organisation_create_departments
- tool_organisation_create_job
- tool_organisation_create_positions
- tool_organisation_department_delete
- tool_organisation_department_move
- tool_organisation_get_managed_users
- tool_organisation_get_potential_parent_departments
- tool_organisation_get_potential_parent_positions
- tool_organisation_get_teams_tab_filters
- tool_organisation_is_jobs_tab_available
- tool_organisation_job_delete
- tool_organisation_position_delete
- tool_organisation_position_move
- tool_organisation_update_departments
- tool_organisation_update_job
- tool_organisation_update_positions
Parameters descriptions are available inside Moodle itself - see Using web services
Organisation structure manager role
The role allows the creation and management of jobs, positions and departments within the current tenant.
The role is created automatically when Moodle Workplace is installed.
By default the Tenant administrator can assign this role to other users inside the same tenant.
Capabilities
The following capabilities are available for handling organisations:
- tool/organisation:assigninlocked: Assign jobs in locked departments and positions
- tool/organisation:assignjobs: Assign jobs
- tool/organisation:assignmanuallymgr: Add manually assigned managers
- tool/organisation:managedepartments: Manage departments
- tool/organisation:managepositions: Manage positions