# Link a Moodle or Google Classroom course

A course can carry one or more learning-platform links so students open the theory materials from their portal. Moodle links also register the student on the Moodle course and sign them in from PiGi once Moodle is connected under Company → Settings → Integrations; Google Classroom links are self-join invite links only.

Source: https://help.pigi.io/guides/courses/lms/link-a-learning-platform

## Quick answers

**Where do I add a Moodle or Google Classroom link to a course?**
On the course's **Details** tab (/school/admin/courses/edit/&lt;ref&gt;), in the
**Learning platforms** block. Click **Add**, choose **Platform** (Moodle or
Google Classroom), paste the **Link**, then click **Done** and **Save changes**.

**Can a course have more than one learning platform?**
Yes. **Learning platforms** is a repeating list — add as many rows as you need.
Students get a button per platform on the course in their portal.

**Do students get enrolled into Moodle automatically?**
Yes, if two things are true: your school has Moodle connected under **Company →
Settings → Integrations**, and the student is enrolled on a **scheduled run** of
the course. PiGi then finds or creates their Moodle account by email address and
enrols them on the linked Moodle course.

**Does Google Classroom auto-enrol students?**
No. A Google Classroom link is a self-join invite
(`classroom.google.com/c/…?cjc=…`). The student opens it and joins themselves.
PiGi does not track whether they joined.

**Where do I connect Moodle?**
**Company → Settings → Integrations**, in the **Learning Management Systems
(LMS)** section. Open the **Moodle** tile, click **Add credentials**, enter the
**Moodle URL** and **Web-service token**, and click **Save**. The sheet then
shows **Connected** and "Credentials saved". The full Moodle-side setup is in
[Connect Moodle for theory courses](../integrations/moodle.md).

**What Moodle permissions does the token need?**
A dedicated Moodle external service exposing all five of
`core_user_get_users_by_field`, `core_user_create_users`,
`core_user_update_users`, `enrol_manual_enrol_users` and
`auth_userkey_request_login_url`. The last one comes from Moodle's **User key
authentication** plugin (`auth_userkey`), which must be installed and enabled.
Without it, enrolment still works but students cannot be signed in to Moodle
from PiGi.

**What if the student has no Moodle account?**
PiGi creates one, using their email address as the username, with a random
password nobody is told. Moodle sends the student no email and no password.
Students reach Moodle by clicking the **Moodle** button on the course in their
PiGi portal, which signs them in automatically.

**Do I need "Allow extended characters in usernames" on in Moodle?**
No. Moodle allows the `@` in an email-address username with that setting off.

**Students were on the course before I added the Moodle link. How do I register them?**
Open the student's course in PiGi and go to its **Learning** tab. Click
**Register in Moodle**. The button shows while any Moodle link on the course is
not yet registered for that student. A student who clicks the **Moodle** button
in their portal is also registered at that moment.

**Why did the token field go blank after I saved?**
By design. The token is never shown again. Leave the field blank when you edit
the URL and the stored token is kept.

**Which Moodle link format works?**
A course view link, e.g. `https://learn.pigi.io/course/view.php?id=42`. PiGi
reads the `id` to know which Moodle course to enrol into. A link without a
readable `id` is still shown to students, but registration is skipped with
"Couldn't read a course id from …".

## What this is

Learning platforms are labelled links stored on a course: one row per external
system that hosts the course's theory material. Students open them from the
course page in their PiGi portal, and — for Moodle — PiGi places them on the
right Moodle course without anyone doing it by hand.

The two providers behave differently. **Moodle** is a real connection: PiGi uses
your token to create the student's Moodle account, enrol them, and sign them in
when they click through. **Google Classroom** is a plain invite link: the class
code in the link lets the student join themselves. Setting up Google Classroom
links is covered in
[Link a Google Classroom class to a course](../integrations/google-classroom.md).

## Before you start

- You need the company admin role.
- For Moodle registration and sign-in you need a Moodle site you administer,
  connected to PiGi — see [Connect Moodle for theory courses](../integrations/moodle.md).
  Without that connection, Moodle links are just links.
- The course must already exist. Links are added on the course's Details tab.

## Steps

1. Connect Moodle once, if you use Moodle. Open **Company → Settings →
   Integrations**, open the **Moodle** tile, click **Add credentials**, fill in
   **Moodle URL** and **Web-service token**, and click **Save**.
2. Open the course at **/school/admin/courses/edit/&lt;ref&gt;**, on the
   **Details** tab.
3. In **Learning platforms**, click **Add**. A new row opens in edit mode.
4. Choose **Platform** — *Moodle* or *Google Classroom*.
5. Paste the **Link**. For Moodle use the course view link
   (`.../course/view.php?id=NN`); for Google Classroom use the class invite link.
6. Click **Done**. The row collapses to a clickable chip with the platform name.
7. Click **Save changes**.
8. Repeat for additional platforms. Use the pencil icon to edit a saved row and
   the bin icon to remove one.
9. For students already on the course, open each student's course, go to the
   **Learning** tab and click **Register in Moodle**.

## Fields

| Field | Required | What to enter |
|---|---|---|
| Platform | Yes | Moodle or Google Classroom. |
| Link | Yes | Moodle: `.../course/view.php?id=NN`. Google Classroom: the class invite link. |
| Moodle URL | For Moodle | Your Moodle site address, e.g. `https://learn.pigi.io`. |
| Web-service token | For Moodle | The token from your Moodle external service. Leave blank to keep the stored one. |

## Known limitations

- **Adding a Moodle link does not register students already on the course.**
  Automatic registration happens when a student joins a scheduled run. For
  anyone already enrolled, use **Register in Moodle** on the student's
  **Learning** tab, or wait for them to click the **Moodle** button in their
  portal.
- **Moodle problems never block the PiGi enrolment.** The **Learning** tab shows
  each Moodle link as **Registered**, **Not registered** or **Failed**, with the
  reason under a failed row.
- **Students get no Moodle password.** They sign in through PiGi. If sign-in
  fails, the student sees "Couldn't sign you in to Moodle" with an **Open Moodle
  anyway** button, which opens the Moodle course without signing them in.
- **Sign-in needs the User key authentication plugin.** Enrolment can work while
  every sign-in from PiGi fails, if the plugin is missing or its function was not
  added to your Moodle service.
- **Google Classroom is not tracked.** PiGi does not know whether the student
  accepted the invite.

## Related

- [Connect Moodle for theory courses](../integrations/moodle.md)
- [Link a Google Classroom class to a course](../integrations/google-classroom.md)
- [Create a course](create-a-course.md)
- [Enrol a student on a course](enrol-a-student.md)
- [Set up integrations](../company-setup/integrations.md)
