copy paste this in two classroom project

// ray.services/automation/classroom-sync.gs

function onOpen() {
const ui = SpreadsheetApp.getUi();
ui.createMenu(‘RayNV Automation’)
.addItem(‘1. Invite Students from Sheet’, ‘inviteFromSheet’)
.addToUi();
}

function inviteFromSheet() {
// Replace the ID below with the one from your Classroom URL
const courseId = ‘YOUR_COURSE_ID_HERE’;

const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const data = sheet.getDataRange().getValues();
const headers = data[0];

// Find the column labeled ’email’ or ’email address’
const emailColIndex = headers.findIndex(h => h.toString().toLowerCase().includes(’email’));

if (emailColIndex === -1) {
SpreadsheetApp.getUi().alert(“Could not find a column named ‘Email’.”);
return;
}

let count = 0;
for (let i = 1; i < data.length; i++) {
const email = data[i][emailColIndex];
if (email) {
try {
Classroom.Invitations.create({
userId: email,
courseId: courseId,
role: “STUDENT”
});
count++;
} catch (e) {
Logger.log(“Error inviting ” + email + “: ” + e.message);
}
}
}

SpreadsheetApp.getUi().alert(“Success: ” + count + ” invitations sent.”);
}

Kids who learn AI automation do not commit crimes as they are busy having fun, making money. One hour. One skill. Zero recidivism. We turn “hustle” into high-level AI workflow engineering.

Leave a comment