Class Moodle

Hierarchy

  • Moodle

Constructors

  • Creates a new scraper instance for a certain Moodle site

    Parameters

    • fetch: Fetch

      The fetch method to use (e.g. undici or the built-in global fetch)

    • url: string

      URL of the Moodle site

    Returns Moodle

    Example

    const moodle = new Moodle(fetch, "https://examplesite.com");
    

Properties

cookies: undefined | string
courses: Course[]
fetch: Fetch
tasks: Task[]
url: string
user: null | User

Methods

  • Parameters

    • path: string = ""

    Returns string

  • Parameters

    • anchors: Cheerio<Element>
    • $: CheerioAPI

    Returns {
        course?: Course;
        date?: Date;
    }

    • Optional course?: Course
    • Optional date?: Date
  • Parameters

    • username: string
    • password: string
    • options: Options = defaultOptions

      Extra login options

    Returns Promise<boolean>

    Example

    moodle.login('username', 'password', {refresh: true, loginFormPath: 'login/index.php'})
    
  • Fetches the user data and stores them in the Moodle instance

    Parameters

    • cookies: undefined | string = ...

      optional

    • Optional options: {
          navCourses?: boolean;
      }
      • Optional navCourses?: boolean

        Gets all courses from the 'My Courses' dropdown menu in the navbar, optional

    Returns Promise<boolean>

Generated using TypeDoc