Data Hub Basic

7 Importing Enrollment Information

Enrollment in Moodle is dependent on the context. If a user is enrolled as a student in a course, then they are given the role called 'student' - with permissions that are set for that role in Moodle's roles administration area, in the context of a course. A teacher could also be enrolled in a course - in this case they are given the role of teacher (with the permissions that are set for that role), in the context of a given course.

Data Hub Basic enables you to set the roles of users via the import file, once you have created courses you can enroll users in these contexts. The most common types of enrollment are for students/learners and teachers/instructors.

The Enrollment tab is where you can set the import parameters for enrollment information.

We can set the name of the csv file, as well as the file type (though currently only csv is supported). The file name entered here is the file name that Data Hub will process from the 'Import file location'.

Data Hub Enrollment tab

If you make changes to any property values, be sure to save your changes with one of the save buttons on the bottom of the screen.

The properties that can be set via the enroll.csv file are listed below with brief descriptions:

username: The username for the user that will be assigned the role.

role: The short name for the role the enrollment gives the specified user in the specified context/course. To find the role short name go to the Site Administration block > Users > Permissions > Define roles and the short names of the roles are in the 3rd column of the chart, Short name.

useridnumber: The idnumber for the user.

context: Set the context for the role at system, user, course, or block context. For example, user A is added as a teacher in course A or parent A is added to the parent role of student A.

timestart: The time for the enrollment in question - e.g. if you are enrolling a user via the csv file, and need to set a different enrollment time than the current time. If selecting a future date, the enrollment will not occur until that date.

timeend: The time/date that the user completed the course - used when importing completion data from another system.

instance: The name/shortname/username of the item you want to set the role at, e.g., the shortname of the course being updated.

group: The name of the group the user should be added to. If the group doesn't already exist it will be created.

grouping: The name of the grouping the user should be added to. If the grouping doesn't already exist it will be created.

execute: The actions for enrollment files are add or delete.

The required fields for enrollments are:
  1. role - role shortname
  2. username - of the user being assigned the role
  3. context - the role can be assigned at the system, user, course, or block level
  4. instance- name, username, shortname of the context the role is assigned in
  5. execute/action - enter add or delete

Data Hub Actions

The 'execute' field from the image above is represented by the 'action' column in the CSV files. DH tells Moodle what needs to be done with imported data via the Actions column. The following actions can be performed for enrollments:
  1. add - add users to a role in a specific context, e.g., a course.
  2. delete - remove users from a role
Data Hub Basic enroll file

In the file the following actions are taking place. Rows 2-4 are adding users to courses in a student role, the courses are identified in the "instance" column by their shortname. Row 5 is adding a user to the teacher role in a course. Row 6 is adding Roger Lee to the parent role for Lisa Lee, so the role assignment for Roger will be shown on the Roles tab of Lisa Lee's profile. Row 7 is deleting a user from a course.

Select this link to download a csv copy of the file in the image. Note that the users and courses in the file have to added to the site before this file could be processed correctly.

The Parent Role Use Case page of this book contains more information about setting up a parent role and assigning the parent role to a student user via an DH Basic upload.

Importing/Processing DH Files

The 'Import file location', specified in the Data Hub block settings, is where the files should be uploaded for processing by DH. To complete the import process for the example above I will follow these steps:
  1. Name the CSV file, for this example it's named 'enroll.csv'. Make sure the file name shown on the Enrollment tab screen is the same, enroll.csv.
  2. Load the file to the 'Import file location'. The files here are automatically processed every 24 hours.
  3. To process the file immediately, select the Save and Process button from the bottom of the screen on the Enrollment tab.
A complete log of all actions is kept in the logs file, as well as (optionally) emailed to an address or addresses each time the DH script runs. The log file location is shown on the settings screen for the Data Hub block.