Moodle (LMS)

About Moodle API

The Campus Café to Moodle API will enroll and drop students when their enrollment changes in Campus Café. The API can optionally be configured to create users (students and instructors) and courses in Moodle upon their creation in Campus Cafe. The API also supports importing final course grades from Moodle to Campus Cafe. The API does not transfer attendance or assignment grades between systems. 

These instructions are written based on Moodle Version 3.9.4. The integration will work with later versions, but the navigation instructions for Moodle may have changes.

Moodle Configuration

Follow the instructions outlined in the sections below to complete the configuration setup in Moodle.

Moodle Users

Users in Moodle include instructors and students. These users only need to be established once in Moodle and are connected to Campus Café by their Campus Café ID number. Regardless of how users are created in Moodle, each user must be associated with his or her Campus Café ID number. In the Moodle interface, the ID is added and edited on the user screen.

Students and instructors must have a user account (username and password) in Campus Cafe for enrollments to be added in Moodle.

Individually create user or tie existing user to Campus Café ID

  1. Log in to Moodle

  2. Navigate to Site administration > Users > Add a new user
      (To edit an existing user, find the user and click the gear for settings.)

  3. Complete the general fields according to your business processes

  4. Click the Optional section to show additional fields

  5. In the ID number box enter the Campus Café ID number

  6. Click Create user or Update profile

Mass import users from Campus Café

Campus Café provides a pre-defined report for a user upload. The report Moodle Student ID Number Listing is available in Base Reports under the Administrator Reports folder. Export the file as a .CSV file.

See Moodle Documentation.

  1. Log in to Moodle

  2. Navigate to Site administration > Users

  3. Click Upload users

  4. Click Choose your file

  5. For the CSV delimiter choose the comma

  6. For the Encoding choose UTF-8

  7. Click Upload Users

  8. Configure your upload settings
      Pay special attention to the settings related to creating versus updating users. To have the ID merge into existing Moodle Users, set the upload type to “Add new and update existing users” or “Update existing users only”. In the existing user details choose “Override with file” or “Override with file and defaults”.

  9. Click Upload users

Automatically create Moodle user accounts based on Campus Cafe

Campus Cafe will automatically create a user in Moodle if a student is enrolled in a class in Campus Cafe and he or she does not already exist in Moodle. (The process looks for a Moodle user with the Campus Cafe ID number in the ID number field.) Campus Cafe will also automatically create a user in Moodle if an instructor is added to a course in Campus Cafe and he or she does not already exist in Moodle. (The process looks for a Moodle user with the Campus Cafe ID number in the ID number field.) 

When a user is created, his or her Moodle username and password will be the same as the Campus Cafe username and password. Unless SSO is implemented changing a password in one system will not change it in the other.

Prior to turning on auto user creation ensure that all existing Moodle users have Campus Cafe IDs assigned to them to avoid duplicate account creation.

Set Campus Cafe to automatically create student accounts in Moodle

A student account will be created when the student is enrolled in a class and the system finds no corresponding user in Moodle.

  1. Navigate to Admin > Custom Control

  2. Locate ProgramId Moodle, Sequence 1, Parameter 5

  3. Click the pencil next to Moodle, Sequence 1, Parameter 5

  4. In Parameter Value 5 box enter Y

  5. Click Save and Back

  6. Locate ProgramId Moodle, Sequence 2, Parameter 1

  7. Click the pencil next to Moodle, Sequence 2, Parameter 1

  8. In Parameter Value 1 box enter the Moodle student role name (case sensitive)

  9. Click Save and Back

Set Campus Cafe to automatically create instructor accounts in Moodle

This process will create a user account for an instructor assigned to a course if the system finds no corresponding user in Moodle. If the instructor is later removed from the course, the instructor will remain in the Moodle course.

  1. Navigate to Admin > Custom Control

  2. Locate ProgramId Moodle, Sequence 2, Parameter 2

  3. Click the pencil next to Moodle, Sequence 2, Parameter 2

  4. In Parameter Value 2 box enter the Moodle role name (case sensitive) for the instructor listed in the Instructor 1 box of the Campus Cafe course

    1. Valid teacher roles: TEACHER, NON_EDITING_TEACHER

    2. TEACHER is the default role if no valid role supplied

  5. In Parameter Value 3 box enter the Moodle role name (case sensitive) for the instructor listed in the Instructor 2 box of the Campus Cafe course

    1. Valid teacher roles: TEACHER, NON_EDITING_TEACHER

    2. NON_EDITING_TEACHER is the default role if no valid role supplied

  6. Click Save

Moodle Courses

Each unique course requires a Course ID number to be associated with Campus Café. The Course ID number for a course in Moodle is constructed from the Term, Course Number, and Course Section with a tilde between each field. (Term~CourseNumber~CourseSection) For example, the course CIS 123, Section 1 offered in the term 202010 would be “202010~CIS123~1”.

Individually create course or tie existing course to Campus Café ID

  1. Log in to Moodle

  2. Navigate to Site Administration > Courses

  3. Click Add a New Course
      (To update an existing course, navigate to the course, click the gear and then click Edit Settings)

  4. Complete the general fields in agreement with your business processes

  5. In the Course ID number, enter the unique number to tie the course to Campus Café. For example, 202010~CIS123~1

  6. Click Save

Enable Moodle Web Services

Moodle must have Web Services enabled to make the connection to Campus Café.

  1. Log in to Moodle

  2. Navigate to Site administration > Advanced features

  3. Next to Enable web services check the box

  4. Click Save Changes

Activate Moodle Web Service Protocols

  1. Log in to Moodle

  2. Navigate to Site administration > Plugins > Web services > Manage protocols

  3. Ensure the REST protocol is enabled by looking at the eye icon (a slash means it is disabled, click the icon to enable) To enable, click the eye.

  4. Click Save changes

Create Moodle Role

This role in Moodle will tie to the Moodle user that will serve as the bridge between Moodle and Campus Café.

Note: Moodle allows the creation of a role based on an XML template attached to this document. Create the role by navigating to Site administration > Users > Permissions > Define Roles > Add a new role. Set role or archetype as manager and upload the file. Review and then click Create this Role.

Assign Role Permissions

  1. Log in to Moodle

  2. Navigate to Site Administration > Users > Category: Permissions

  3. Click Define Roles

  4. Click Add a new Role

  5. Leave the defaults blank

  6. Click Continue

  7. Give the role a short name (e.g. Campus Café)

  8. Give the role a Custom full name (e.g. Campus Café)

  9. Role archetype: Manager

  10. Context types where this role may be assigned: Check System and User

  11. Allow role assignments: Select Teacher, Non-editing teacher and student
      (Note this may need to be adjusted depending on your specific roles assigned to instructors and students)

  12. In the Capability chart, check Allow for the following:
    Configure custom fields moodle/course:configurecustomfields
    View participants moodle/site:viewparticipants
    Create users moodle/user:create
    Update user profiles moodle/user:update
    Create a web service token moodle/webservice:createtoken
    View user full information moodle/user:viewalldetails
    Manage categories moodle/category:manage
    View list of courses you are not enrolled in moodle/category:viewcourselist
    See hidden categories moodle/category:viewhiddencategories
    Create courses moodle/course:create
    Enroll users enrol/manual:enrol
    Unenroll users from the course enrol/manual:unenrol
    View the grader report gradereport/grader:view
    View the grade history gradereport/history:view
    View the outcomes report gradereport/outcomes:view
    View the overview report gradereport/overview:view
    View report gradereport/singleview:view
    View your own grade report gradereport/user:view
    Change course category moodle/course:changecategory
    Change course full name moodle/course:changefullname
    Change course ID number moodle/course:changeidnumber
    Change course short name moodle/course:changeshortname
    Change course summary moodle/course:changesummary
    Delete courses moodle/course:delete
    Control section visibility moodle/course:sectionvisibility
    Update course settings moodle/course:update
    Enable/disable email address moodle/course:useremail
    View courses without participation moodle/course:view
    View hidden courses moodle/course:viewhiddencourses
    View hidden sections moodle/course:viewhiddensections
    View hidden user fields moodle/course:viewhiddenuserfields
    View participants moodle/course:viewparticipants
    View scales moodle/course:viewscales
    View suspended users moodle/course:viewsuspendedusers
    Hide/show courses moodle/course:visibility
    View grades of other users moodle/grade:viewall
    Assign roles to users moodle/role:assign
    View user profiles moodle/user:viewdetails
    View hidden details of users moodle/user:viewhiddendetails
    Use REST protocol webservice/rest:use
    Access all groups moodle/site:accessallgroups

14. Click Save

Allow Role Assignments in Moodle

  1. Navigate to Site administration > Users > Permissions

  2. Click Define Roles

  3. Click the Role created earlier

  4. Click Allow role assignments

  5. Look for the row corresponding to the role you created

  6. Check the boxes to allow the role to have access to the teacher, non-editing teacher and student roles (or your equivalent)

  7. Click Save changes

Create Moodle Service User

A user in Moodle must be created as part of the connection between Campus Café and Moodle. Campus Café recommends creating a generic user for this purpose (e.g. Campus Café). Although the user does not need administrative access, it requires specific permissions.

Create user

  1. Log in to Moodle

  2. Navigate to Site Administration > Users

  3. Click Category: Accounts

  4. Click Add a new user

  5. Complete at least username, authentication method, password, first name, last name and email

  6. Click Create User

Assign user role

  1. Navigate to Site administration > Users > Permissions

  2. Click Assign System Roles

  3. Click the role you created earlier

  4. Add the user you created earlier to the role

Remove Manager Archetype

The role initially requires the manager archetype to assign the permissions. To take an extra step to ensure security, remove this archetype once the role is created and user assigned. 

  1. Navigate to Site Administration > Users

  2. Click Category: Permissions

  3. Click Define Roles

  4. Click the Role you created

  5. Click Edit

  6. In Role archetype, select none

  7. Click Save changes

Create Moodle Web Service

This allows the function calls to cross the web and make a connection to Campus Café.

  1. Log in to Moodle

  2. Navigate to Site administration > Server

  3. Under Services click External services

  4. Click Add

  5. Give the service a name (e.g. Campus Café)

  6. Give the service a short name

  7. Check Enabled

  8. Check Authorized users only

  9. Click Add service

  10. Back on the web services page, click Functions next to the service just created

  11. Click Add Functions

  12. Add the following functions:

auth_email_signup_user
core_auth_confirm_user
core_course_check_updates
core_course_create_categories
core_course_create_courses
core_course_delete_courses
core_course_edit_module
core_course_edit_section
core_course_get_categories
core_course_get_courses
core_course_get_courses_by_field
core_course_update_categories
core_course_update_courses
core_enrol_edit_user_enrolment – Moodle versions previous to 3.8
core_enrol_submit_user_enrolment_form – Moodle versions 3.8
core_enrol_get_enrolled_users
core_enrol_get_users_courses
core_enrol_unenrol_user_enrolment
core_role_assign_roles
core_role_unassign_roles
core_user_create_users
core_user_get_users
core_user_get_users_by_field
core_webservice_get_site_info
enrol_manual_enrol_users
enrol_manual_unenrol_users
gradereport_overview_get_course_grades
gradereport_overview_view_grade_report
gradereport_user_get_grade_items
gradereport_user_get_grades_table

  1. Click Add Functions

  2. Back on the web services page, click Authorized users next to the service just created

  3. Add the user created to make the connection to Campus Cafe

Create Moodle Token

  1. Log in to Moodle

  2. Navigate to Site administration > Server > Web Services

  3. Under Manage Tokens click Create Token

  4. In the User box, select the user created earlier

  5. In the Service box, select the service created earlier

  6. Leave IP restriction blank

  7. Check Enable

  8. Set the date the token will expire. (The Moodle-Campus Café connection will stop working on this date)

  9. Click Save Changes

  10. Copy the token for future use

Campus Café Web App Config

  1. Log in to Campus Café

  2. Navigate to Admin > Web App

  3. Update the following Parameters

    • MOODLE_API_NAME - enter CC_MDL

    • MOODLE_AUTO_QUEUE_ITEMS - If set to Y, the system will queue course sections and enrollments created prior to the number of days specified in later configuration items

    • MOODLE_BASE_URL – Unique path to your Moodle installation webservice root. Typically https://<your-Moodle-URL>/webservice/rest/server.php

    • MOODLE_COURSE_DAYS_ACTIVE_BEF_BEGIN - Enter a number representing days. Individual course sections will be created in Moodle only if created in Campus Cafe this many days or fewer prior to the course section start date unless MOODLE_AUTO_QUEUE_ITEMS is set to Y in which case they will be held for creation until the time arrives.

    • MOODLE_COURSE_TITLE_FORMAT - controls the name of the course section created in Moodle. Variables supported are @SEMESTER@, @COURSE_NUMBER@, @COURSE_SECTION@, @COURSE_TITLE@ and @SEMESTER_DESCRIPTION@. For example, for the Fall 2021 class (Intro to Math, MTH101, Section 4 setting this value to @COURSE_NUMBER@ - @COURSE_SECTION@: @COURSE_TITLE@ in @SEMESTER_DESCRIPTION@ would create the section in Moodle called "MTH101 - 4: Intro to Math in Fall 2021"

    • MOODLE_CUTOVER_SEMESTER - the Campus Cafe semester numerical code (e.g. 202210) of the first semester to sync between Campus Cafe and Moodle

    • MOODLE_EMAIL – Optionally enter an email address to receive emails when an enrollment fails

    • MOODLE_ENROLLMENT_DAYS_ACTIVE_AFT_END - Enrollments will stop syncing after the course end date if this is set to 0. Set a higher number for enrollments to stop syncing after the course end date. For example, set 5, enrollments would stop syncing file days after the course end date.

    • MOODLE_ENROLLMENT_DAYS_ACTIVE_BEF_BEGIN - Enrollments will sync for registrations starting the entered number of days prior to the course start date. Registrations that occur prior to this date will not be processed in Moodle unless MOODLE_AUTO_QUEUE_ITEMS is set to Y in which case they will be held for creation until the time arrives.

    • MOODLE_PASSWORD - For legacy Moodle only. Leave empty for Moodle 3.2+ versions.

    • MOODLE_REMOVE_DOMAIN_FROM_USERNAME - To remove @domain from Campus Cafe username for Moodle username value.

    • MOODLE_REMOVE_FROM_QUEUE_DAYS - How long to keep a technical log of sync actions. Campus Cafe recommends "30"

    • MOODLE_TIMEZONE - Enter the timezone. US/Eastern; US/Central; US/Mountain or US/Pacific Case sensitive

    • MOODLE_TOKEN – The Moodle token generated in Moodle

    • MOODLE_TURN_OFF_INTEGRATION_WITH_CC - enter ON to turn on the connection; OFF to turn it off

    • MOODLE_USERNAME - For legacy Moodle only. Leave empty for Moodle 3.2+ versions.

    • MOODLE_VERSION – 3.2 (set as 3.2 for any version 3.2 and higher)

    • GRADE_SYNC_EMAIL_ADDRESS - The email address that will receive the final course grade import exceptions report

  4. Refresh the cache by navigating to Admin > Refresh Data Cache

Configure Course End-Times and Nickname/Preferred Name Settings

The connection allows for the adjustment of course end-times.  Default is set to 0:00 z time; however, this may be adjusted from 0 to 2359 to account based on when you want the courses to end in Brightspace.  Additionally, the integration may now be configured to bring in the Campus Cafe Nickname as the Preferred Name in Moodle.  If set to Y and no Nickname exists in Campus Cafe, the First Name will be sent as the Preferred Name.

Configuring Course End-Times

  1. Log in to Campus Cafe

  2. Navigate to Admin > System Setup > Custom Control

  3. Locate ProgramID MOODLE

  4. Click the pencil icon next to Moodle Seq 2 Parm 9

  5. Update the course end-times (HHMM) to a value from 0 to 2359 (Default is 0)

Configuring Nickname Preferences

  • Log in to Campus Cafe

  • Navigate to Admin > System Setup > Custom Control

  • Locate ProgramID MOODLE

  • Click the pencil icon next to Moodle Seq 2 Parm 10

  • Enter Y to send Nickname as Preferred Name

  • Enter N to ignore Nickname field in Campus Cafe and only send First Name as preferred name (Default is 0)

Configure Create Courses Setting

Automatically create courses in Moodle when scheduled in Campus Cafe

This setting will cause a Moodle course to be created upon the course being scheduled in Campus Cafe. Caution should be exercised if using this setting because once a course is created in Moodle it may be visible to Moodle users. In addition, a course will not be removed from Moodle if the course is later deleted in Campus Cafe.

  1. Navigate to Admin > Custom Control

  2. Locate ProgramId Moodle, Sequence 1, Parameter 7

  3. Click the pencil next to Moodle, Sequence 1, Parameter 7

  4. In Parameter Value 7 box enter Y

  5. Click Save

Automatically create courses in Moodle when student registers for first time

This setting will cause a Moodle course to be created upon registration of the first student in the course in Campus Cafe. Caution should be exercised if using this setting because once a course is created in Moodle it may be visible to Moodle users. In addition, a course will not be removed from Moodle if the course is later deleted in Campus Cafe.

  1. Navigate to Admin > Custom Control

  2. Locate ProgramId Moodle, Sequence 1, Parameter 6

  3. Click the pencil next to Moodle, Sequence 1, Parameter 6

  4. In Parameter Value 6 box enter Y

  5. Click Save

Define Course Categories in Campus Cafe

Course Categories

Moodle groups courses into categories. The connector will add courses to the default Moodle category unless otherwise specified.

To set a default Moodle Category in Campus Cafe

  1. Navigate to Admin > Custom Control Maintenance

  2. Locate ProgramId Moodle, Sequence 2, Parameter 4

  3. Click the pencil next to Moodle, Sequence 2, Parameter 4

  4. In Parameter Value 4 box enter the Moodle value of field 'Category ID number' of your chosen Moodle category.

  5. Click Save and Back

To set the Campus Cafe Course 6 digit semester code to be your default Moodle Category

  1. Navigate to Admin > Custom Control Maintenance

  2. Locate ProgramId Moodle, Sequence 2, Parameter 4

  3. Click the pencil next to Moodle, Sequence 2, Parameter 4

  4. In Parameter Value 4 box enter the value @SEMESTER@

  5. Click Save and Back

Define Categories in Campus Cafe

Moodle categories must be created in Campus Cafe. If the category does not exist in Moodle, it will be created.

  1. Navigate to Admin > STPARMs

  2. In the Parameter Code box enter LMSCAT

  3. In the Parameter Value box enter the Moodle category

  4. Click Add

  5. In Description enter text to illustrate the category

  6. In Long Description enter text to further illustrate the category

  7. Click Save

  8. Refresh the cache by navigating to Admin > Refresh Data Cache

Attach Category to Course

  1. Navigate to Filters > Courses

  2. Complete the filters to return the desired course

  3. Next to the course click the magnifying glass

  4. Click the Codes tab

  5. In the LMS Category drop down choose the category

  6. Click Save

Campus Cafe Custom Control Configuration

This essentially turns on the connection although enrollments will not transfer automatically until Campus Cafe Support schedules the process to run. Enrollments may be pushed manually to Canvas by using the LMS Managment screen. Refer to Manual Sync below.

  1. Navigate to Admin > Custom Control

  2. Locate ProgramId Moodle

  3. Next to ProgramId Moodle, Sequence Number 1, Parameter 1 click the pencil

  4. In Parameter Value 1 enter YYY

  5. Click Save

  6. Refresh the cache by navigating to Admin > Refresh Data Cache

Manual Sync

Enrollments and course creations made in Campus Cafe will be queued to send to Moodle. To send these changes to Moodle for processing, launch the manual sync.

Moodle Management tab

View number of pending changes

  1. Navigate to Registrar > LMS Management

  2. The number next to Unprocessed Queue Entries Count indicates the number of changes waiting to sync. This may represent changes to an individual's name, enrollments, course creations, etc.

Queue enrollments and send to Moodle

You can direct Campus Cafe to send all enrollments for an entire semester or specific course or specific section to Moodle regardless of when the students registered.

  1. Navigate to Registrar > LMS Management

  2. In the Semester Box select the Campus Cafe semester code (e.g. 202110) from the dropdown

  3. Optional: To limit the enrollments to all sections of a course, in the Course box enter the full course number (e.g. MTH100)

  4. Optional: To limit the enrollments to a single section of a course, in the Section box enter the section number (e.g. 14)

  5. Click Enqueue Enrollments

Queue courses to be created in Moodle

You can direct Campus Cafe to create all courses for an entire semester or specific course or specific section.

  1. Navigate to Registrar > LMS Management

  2. In the Semester Box select the Campus Cafe semester code (e.g. 202110) from the dropdown

  3. Optional: To limit course creations to all sections of a course, in the Course box enter the full course code (e.g. MTH100)

  4. Optional: To limit course creations to a single section of a course, in the Section box enter the section number (e.g. 14)

  5. Click Enqueue Courses

Process pending changes

This queue represents all changes (enrollments, changes to names, etc.) made in Campus Cafe that are waiting to be sent to Moodle.

  1. Navigate to Registrar > LMS Management

  2. The number next to Unprocessed Entries count indicates the number of changes waiting to sync

  3. Enter the number of entries you wish to process in the box next the Unprocessed Entries

  4. Click Manually Run

Review Queue Log

As items are added to and processed from the LMS queue, they will appear in the LMS queue tab. All changes made to records in Campus Cafe will be added to the queue, but only relevant enrollments, course and user changes will update in the LMS.

Moodle Queue tab

Select the Moodle Queue tab to view all items on the queue.

Unprocessed items will not have a processed time.

Processed items will have a processed time and a message regarding the actions taken in the LMS. If the message is blank, the change did not impact the LMS, and no changes were made in LMS.

Results can be limited to a specific ID Number, Semester, Course/Section if looking for a specific item on the queue. Additionally, a search box is available for searching specific key words.

Reviewing Errors

Results may also be limited to messages containing errors only. To narrow the search results to show only those with error messages, check the Errors Only checkbox and click Search.

image-20241213-160350.png

 

Automatic Sync

After testing the connection, contact Campus Cafe support to request an automatic connection be activated if desired. Changes made in Campus Cafe will typically update in Moodle within an hour.

Upon Sync Error

If a change cannot be made in Moodle, the system will send an email to the email address listed in the Web App Config MOODLE_EMAIL. The email will only be sent for changes that fail. Other transactions in the queue that did not encounter issues will still process. Put another way, a single failure will not prevent other changes from processing.

Queue History Log

The queue history log shows the results of synchronization attempts between Campus Cafe and the LMS. For example, if a student's enrollment is not initiated in the LMS, the history log will show why.

Access the log

  1. Log in to Campus Cafe

  2. Navigate to Registrar > LMS Management

  3. Click Queue History Log

Import Final Course Grades

The API determines the final course grade in Moodle by looking for the grade within a course that has no weighting. 

The system will overwrite existing final grades in Campus Cafe if Custom Control Moodle, Sequence 2, Parameter 6 is set to Y. 

A report will be emailed to the email address configured in Web App Config GRADE_SYNC_EMAIL_ADDRESS.

Final Grade Sync Tab

Run a Report

Checking this will prevent the import of grades into Campus Cafe. Instead, the system will email a report showing grades that cannot be imported into Campus Cafe. The report is emailed to the email address configured in Web App Config GRADE_SYNC_EMAIL_ADDRESS. 

  1. Navigate to Registrar > LMS Management 

  2. Select the Final Grade Sync tab

  3. Select the Semester to Synchronize from the drop-down menu

  4. Optional: Enter a specific course or course section, if not importing grades for the entire semester

  5. Check Report Only

  6. Click Synchronize

  7. The Process Output Message will update to indicate the process has began

  8. Optional: Click Refresh Job Output to see updated report results in the Process Output Message box

Run the Import

  1. Navigate to Registrar > LMS Management 

  2. Select the Final Grade Sync tab

  3. Select the Semester to Synchronize from the drop-down menu

  4. Optional: Enter a specific course or course section, if not importing grades for the entire semester

  5. Check Report Only

  6. Click Synchronize