npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

moodletracer

v1.0.1

Published

A powerful Node.js package to scrape Moodle LMS data including assignments, grades, files, and Zybook integrations

Readme

🎓 Moodle Scraper

A powerful Node.js package to scrape Moodle LMS data including assignments, grades, files, and Zybook integrations.

🚀 Features

  • 📚 Assignments: Retrieve assignment details, due dates, and submission status
  • 📊 Grades: Extract gradebook data and feedback
  • 📁 Files: List and download course files and resources
  • 🔗 Zybook Integration: Access Zybook activities and progress
  • 🔐 Secure Authentication: Handle login with email and password
  • 🛡️ 2FA Support: Automatic detection and handling of Two-Factor Authentication
  • ⚡ Fast & Reliable: Built with Puppeteer for robust web scraping
  • 📦 Easy to Use: Simple API with TypeScript support

📦 Installation

npm install moodletracer

🛠️ Quick Start

Basic Usage

const { scrapeMoodle } = require('moodletracer');

async function getMoodleData() {
  const credentials = {
    email: '[email protected]',
    password: 'your-password',
    classUrl: 'https://your-moodle-site.com/course/view.php?id=123'
  };

  try {
    const data = await scrapeMoodle(credentials);
    
    console.log('Assignments:', data.assignments);
    console.log('Grades:', data.grades);
    console.log('Files:', data.files);
    console.log('Zybook Integrations:', data.zybookIntegrations);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

getMoodleData();

Advanced Usage

const { MoodleScraper } = require('moodletracer');

async function advancedScraping() {
  const scraper = new MoodleScraper({
    email: '[email protected]',
    password: 'your-password',
    classUrl: 'https://your-moodle-site.com/course/view.php?id=123'
  }, {
    headless: true,     // Run in background
    timeout: 60000,     // 60 second timeout
    waitForElements: true
  });

  try {
    await scraper.initialize();
    await scraper.login();
    await scraper.navigateToClass();
    
    // Scrape specific data types
    const assignments = await scraper.scrapeAssignments();
    const grades = await scraper.scrapeGrades();
    
    return { assignments, grades };
  } finally {
    await scraper.close();
  }
}

🔐 Two-Factor Authentication (2FA)

If your Moodle instance uses 2FA, the scraper can handle it automatically:

const scraper = new MoodleScraper(credentials, {
  headless: false, // Show browser for 2FA completion
  timeout: 60000   // Extended timeout for manual intervention
});

await scraper.initialize();
await scraper.login(); // Will detect and wait for 2FA if needed

2FA Methods Supported:

  • Manual completion: Browser window stays open for you to complete 2FA
  • Session persistence: Save login state to avoid repeated 2FA
  • Multiple 2FA types: SMS, authenticator apps, email verification

See examples/2fa-example.js and docs/2fa-handling-guide.md for detailed 2FA handling strategies.

🐳 Container Deployment (Red Hat Technologies)

For production deployments, this package includes enterprise-grade containerization using Red Hat technologies:

Quick Container Usage

# Build with Red Hat Universal Base Image (UBI)
npm run container:build

# Set environment variables
export MOODLE_EMAIL="[email protected]"
export MOODLE_PASSWORD="your-password"
export MOODLE_CLASS_URL="https://moodle.university.edu/course/view.php?id=12345"

# Run containerized scraping
npm run container:run

Enterprise Features

  • 🔒 Red Hat UBI: Built on enterprise-grade Universal Base Images
  • 🛡️ Podman Ready: Rootless, daemonless container execution
  • ⚡ Security First: No-new-privileges, capability dropping, read-only filesystem
  • 📊 Production Ready: Resource limits, health checks, SELinux support

Container Commands

npm run container:build    # Build container with UBI
npm run container:run      # Run scraping in container
npm run container:debug    # Interactive debugging container
npm run container:info     # Show container information
npm run container:cleanup  # Clean up containers

See docs/redhat-integration.md and examples/podman-container-example.js for comprehensive container usage.

🔧 API Reference

scrapeMoodle(credentials, options?)

Quick function to scrape all Moodle data.

Parameters:

  • credentials: Object with email, password, and classUrl
  • options: Optional scraper configuration

Returns: Promise resolving to ScrapedData object

MoodleScraper Class

Constructor

new MoodleScraper(credentials, options?)

Methods

  • initialize(): Initialize browser instance
  • login(): Authenticate with Moodle
  • navigateToClass(): Navigate to the specified class
  • scrapeAssignments(): Get all assignments
  • scrapeGrades(): Get grade information
  • scrapeFiles(): Get course files
  • scrapeZybookIntegrations(): Get Zybook activities
  • scrapeAll(): Get all data at once
  • close(): Close browser instance

📊 Data Types

Assignment

{
  id: string;
  title: string;
  description: string;
  dueDate: Date | null;
  submissionStatus: 'submitted' | 'not_submitted' | 'late';
  maxGrade: number;
  currentGrade: number | null;
  url: string;
}

Grade

{
  itemName: string;
  grade: string;
  maxGrade: string;
  percentage: number | null;
  feedback: string | null;
  dateModified: Date | null;
}

File

{
  name: string;
  url: string;
  size: string;
  type: string;
  downloadUrl: string;
}

Zybook Integration

{
  title: string;
  url: string;
  dueDate: Date | null;
  completionStatus: string;
  progress: number | null;
}

⚙️ Configuration Options

{
  headless: true,        // Run browser in background (default: true)
  timeout: 30000,        // Request timeout in ms (default: 30000)
  waitForElements: true  // Wait for page elements to load (default: true)
}

🔒 Security Notes

  • Never commit credentials: Use environment variables or secure config files
  • Rate limiting: Be respectful of Moodle server resources
  • Terms of service: Ensure compliance with your institution's policies

📋 Requirements

  • Node.js 16.0.0 or higher
  • Chrome/Chromium browser (installed automatically with Puppeteer)

🐛 Troubleshooting

Common Issues

  1. Login Failed:

    • Verify credentials are correct
    • Check if Moodle site uses SSO or 2FA
    • Ensure class URL is accessible
  2. Two-Factor Authentication:

    • Set headless: false to see 2FA prompts
    • Use session persistence to avoid repeated 2FA
    • See 2FA handling guide for detailed solutions
  3. Elements Not Found:

    • Different Moodle versions may have different HTML structures
    • Try increasing timeout values
    • Set headless: false to debug visually
  4. Memory Issues:

    • Always call scraper.close() when done
    • Use headless: true for production

📄 License

MIT License - see LICENSE file for details

🤝 Contributing

Contributions welcome! Please read our contributing guidelines and submit pull requests.

⚠️ Disclaimer

This tool is for educational purposes.