CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-canvasapi

API wrapper for the Canvas LMS

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

course-management.mddocs/

Course Management

Comprehensive course operations including content creation, enrollment management, assignments, modules, and course administration. The Course class provides access to all course-related functionality within Canvas.

Capabilities

Course Information and Settings

Manage basic course information, settings, and metadata.

class Course(CanvasObject):
    def edit(self, **kwargs) -> Course:
        """
        Edit course details.
        
        Parameters can include:
        - name: Course name
        - course_code: Course code
        - start_at: Course start date
        - end_at: Course end date
        - description: Course description
        
        Returns:
        Updated Course object
        """
    
    def delete(self, **kwargs) -> Course:
        """Delete the course."""
    
    def conclude(self, **kwargs) -> Course:
        """Conclude the course."""
    
    def get_settings(self, **kwargs) -> dict:
        """Get course settings."""
    
    def update_settings(self, **kwargs) -> dict:
        """Update course settings."""

User and Enrollment Management

Manage course enrollments, user access, and enrollment types.

def get_users(self, **kwargs) -> PaginatedList[User]:
    """
    List users in the course.
    
    Parameters:
    - enrollment_type: Filter by enrollment type ('student', 'teacher', 'ta', etc.)
    - include: Additional data to include ('enrollments', 'avatar_url', etc.)
    
    Returns:
    Paginated list of User objects
    """

def enroll_user(self, user, enrollment_type: str, **kwargs) -> Enrollment:
    """
    Enroll a user in the course.
    
    Parameters:
    - user: User object or user ID
    - enrollment_type: Type of enrollment ('student', 'teacher', 'ta', 'observer', 'designer')
    - enrollment_state: State of enrollment ('active', 'invited', 'inactive')
    - notify: Whether to send notification (default: True)
    
    Returns:
    Enrollment object
    """

def get_enrollments(self, **kwargs) -> PaginatedList[Enrollment]:
    """
    List enrollments for this course.
    
    Parameters:
    - type: Filter by enrollment type
    - state: Filter by enrollment state
    - include: Additional data to include
    
    Returns:
    Paginated list of Enrollment objects
    """

def get_recent_students(self, **kwargs) -> PaginatedList[User]:
    """Get users who have recently been students in this course."""

Assignment Management

Create, manage, and organize course assignments and assignment groups.

def get_assignments(self, **kwargs) -> PaginatedList[Assignment]:
    """
    List assignments for the course.
    
    Parameters:
    - include: Additional data ('submission', 'assignment_visibility', etc.)
    - search_term: Search term to filter assignments
    - order_by: Order assignments by field
    
    Returns:
    Paginated list of Assignment objects
    """

def create_assignment(self, assignment: dict, **kwargs) -> Assignment:
    """
    Create a new assignment.
    
    Parameters:
    - assignment: Dictionary with assignment attributes:
        - name: Assignment name (required)
        - description: Assignment description
        - due_at: Due date (ISO 8601 format)
        - points_possible: Maximum points
        - submission_types: List of allowed submission types
        - grading_type: Grading type ('pass_fail', 'percent', 'letter_grade', 'gpa_scale', 'points')
    
    Returns:
    Assignment object
    """

def get_assignment(self, assignment, **kwargs) -> Assignment:
    """Get a single assignment by ID."""

def get_assignment_groups(self, **kwargs) -> PaginatedList[AssignmentGroup]:
    """List assignment groups for the course."""

def create_assignment_group(self, **kwargs) -> AssignmentGroup:
    """
    Create a new assignment group.
    
    Parameters:
    - name: Assignment group name
    - weight: Weight for weighted grading
    - drop_lowest: Number of lowest scores to drop
    - drop_highest: Number of highest scores to drop
    
    Returns:
    AssignmentGroup object
    """

Module Management

Organize course content into modules with sequential access control.

def get_modules(self, **kwargs) -> PaginatedList[Module]:
    """
    List modules for the course.
    
    Parameters:
    - include: Additional data ('items', 'content_details')
    - search_term: Search term to filter modules
    
    Returns:
    Paginated list of Module objects
    """

def create_module(self, module: dict, **kwargs) -> Module:
    """
    Create a new module.
    
    Parameters:
    - module: Dictionary with module attributes:
        - name: Module name (required)
        - unlock_at: Date when module becomes available
        - position: Position in module list
        - require_sequential_progress: Whether items must be completed sequentially
        - prerequisite_module_ids: List of prerequisite module IDs
    
    Returns:
    Module object
    """

def get_module(self, module, **kwargs) -> Module:
    """Get a single module by ID."""

Content Management

Manage pages, files, folders, and other course content.

def get_pages(self, **kwargs) -> PaginatedList[Page]:
    """
    List pages for the course.
    
    Parameters:
    - sort: Sort pages by field ('title', 'created_at', 'updated_at')
    - order: Sort order ('asc', 'desc')
    - search_term: Search term to filter pages
    
    Returns:
    Paginated list of Page objects
    """

def create_page(self, page: dict, **kwargs) -> Page:
    """
    Create a new page.
    
    Parameters:
    - page: Dictionary with page attributes:
        - title: Page title
        - body: Page content (HTML)
        - published: Whether page is published
        - front_page: Whether this is the front page
    
    Returns:
    Page object
    """

def get_files(self, **kwargs) -> PaginatedList[File]:
    """List files for the course."""

def get_folders(self, **kwargs) -> PaginatedList[Folder]:
    """List folders for the course."""

def create_folder(self, name: str, **kwargs) -> Folder:
    """
    Create a new folder.
    
    Parameters:
    - name: Folder name
    - parent_folder_id: Parent folder ID
    - locked: Whether folder is locked
    
    Returns:
    Folder object
    """

Discussion Management

Create and manage discussion topics and forums.

def get_discussion_topics(self, **kwargs) -> PaginatedList[DiscussionTopic]:
    """
    List discussion topics for the course.
    
    Parameters:
    - include: Additional data ('all_dates', 'sections', 'overrides')
    - order_by: Order by field ('position', 'recent_activity', 'title')
    - scope: Filter discussions ('locked', 'unlocked', 'pinned', 'unpinned')
    
    Returns:
    Paginated list of DiscussionTopic objects
    """

def create_discussion_topic(self, **kwargs) -> DiscussionTopic:
    """
    Create a new discussion topic.
    
    Parameters:
    - title: Discussion title
    - message: Discussion message/prompt
    - discussion_type: Type of discussion ('side_comment', 'threaded')
    - published: Whether discussion is published
    - delayed_post_at: When to automatically publish
    - lock_at: When to automatically lock discussion
    
    Returns:
    DiscussionTopic object
    """

Quiz Management

Create and manage quizzes and assessments.

def get_quizzes(self, **kwargs) -> PaginatedList[Quiz]:
    """
    List quizzes for the course.
    
    Parameters:
    - search_term: Search term to filter quizzes
    - include: Additional data ('assignment', 'overrides', 'all_dates')
    
    Returns:
    Paginated list of Quiz objects
    """

def create_quiz(self, quiz: dict, **kwargs) -> Quiz:
    """
    Create a new quiz.
    
    Parameters:
    - quiz: Dictionary with quiz attributes:
        - title: Quiz title (required)
        - description: Quiz description
        - due_at: Due date
        - points_possible: Maximum points
        - time_limit: Time limit in minutes
        - allowed_attempts: Number of allowed attempts
        - quiz_type: Type ('practice_quiz', 'assignment', 'graded_survey', 'survey')
    
    Returns:
    Quiz object
    """

def create_new_quiz(self, **kwargs) -> NewQuiz:
    """Create a new quiz using New Quizzes (Quizzes.Next)."""

Grading and Gradebook

Manage grades, grading standards, and gradebook operations.

def get_gradebook_history(self, **kwargs) -> PaginatedList[dict]:
    """Get gradebook history for the course."""

def add_grading_standards(self, **kwargs) -> GradingStandard:
    """Add grading standards to the course."""

def create_late_policy(self, **kwargs) -> dict:
    """
    Create a late policy for the course.
    
    Parameters:
    - late_policy: Dictionary with policy attributes:
        - missing_submission_deduction_enabled: Whether to deduct for missing submissions
        - missing_submission_deduction: Percentage to deduct
        - late_submission_deduction_enabled: Whether to deduct for late submissions
        - late_submission_deduction: Percentage to deduct per period
        - late_submission_interval: Deduction interval
    
    Returns:
    Late policy dictionary
    """

def get_custom_gradebook_columns(self, **kwargs) -> PaginatedList[CustomGradebookColumn]:
    """List custom gradebook columns."""

def create_custom_gradebook_column(self, column: dict, **kwargs) -> CustomGradebookColumn:
    """Create a custom gradebook column."""

Section Management

Manage course sections and section-specific settings.

def get_sections(self, **kwargs) -> PaginatedList[Section]:
    """
    List sections for the course.
    
    Parameters:
    - include: Additional data ('students', 'avatar_url', 'enrollments')
    
    Returns:
    Paginated list of Section objects
    """

def create_course_section(self, **kwargs) -> Section:
    """
    Create a new course section.
    
    Parameters:
    - name: Section name
    - sis_section_id: SIS section ID
    - start_at: Section start date
    - end_at: Section end date
    
    Returns:
    Section object
    """

External Tools

Manage external tools and LTI integrations.

def get_external_tools(self, **kwargs) -> PaginatedList[ExternalTool]:
    """List external tools for the course."""

def create_external_tool(self, **kwargs) -> ExternalTool:
    """
    Create an external tool.
    
    Parameters:
    - name: Tool name
    - privacy_level: Privacy level ('anonymous', 'name_only', 'public')
    - consumer_key: OAuth consumer key
    - shared_secret: OAuth shared secret
    - url: Tool launch URL
    - domain: Tool domain
    
    Returns:
    ExternalTool object
    """

Outcomes Management

Manage learning outcomes for the course.

def get_outcome_groups_in_context(self, **kwargs) -> PaginatedList[OutcomeGroup]:
    """List all outcome groups for the course."""

def get_root_outcome_group(self, **kwargs) -> OutcomeGroup:
    """Get the root outcome group for the course."""

def get_outcome_group(self, group, **kwargs) -> OutcomeGroup:
    """Get details of a specific outcome group."""

def get_all_outcome_links_in_context(self, **kwargs) -> PaginatedList[OutcomeLink]:
    """Get all outcome links for the course."""

def get_outcome_results(self, **kwargs) -> PaginatedList[OutcomeResult]:
    """Get all outcome results for the course."""

def get_outcome_result_rollups(self, **kwargs) -> dict:
    """Get all outcome result rollups for the course."""

Rubrics Management

Create and manage rubrics for assessments.

def create_rubric(self, **kwargs) -> dict:
    """Create a new rubric for the course."""

def get_rubric(self, rubric_id, **kwargs) -> Rubric:
    """Get a single rubric by ID."""

def get_rubrics(self, **kwargs) -> PaginatedList[Rubric]:
    """List active rubrics for the course."""

def create_rubric_association(self, **kwargs) -> RubricAssociation:
    """Create a new rubric association."""

Blueprints and Templates

Manage blueprint courses and templates.

def get_blueprint(self, template: str = "default", **kwargs) -> BlueprintTemplate:
    """Get a blueprint template by ID."""

def list_blueprint_subscriptions(self, **kwargs) -> PaginatedList[BlueprintSubscription]:
    """List blueprint subscriptions for the course."""

Late Policy Management

Configure late submission policies.

def create_late_policy(self, **kwargs) -> LatePolicy:
    """Create a late policy for the course."""

def get_late_policy(self, **kwargs) -> LatePolicy:
    """Get the course late policy."""

def edit_late_policy(self, **kwargs) -> bool:
    """Update the course late policy."""

Grading Standards

Manage custom grading standards.

def add_grading_standards(self, title: str, grading_scheme_entry: list, **kwargs) -> GradingStandard:
    """Create a new grading standard for the course."""

def get_grading_standards(self, **kwargs) -> PaginatedList[GradingStandard]:
    """List available grading standards."""

def get_single_grading_standard(self, grading_standard_id, **kwargs) -> GradingStandard:
    """Get a single grading standard."""

Analytics and Reporting

Access course analytics and participation data.

def get_course_level_participation_data(self, **kwargs) -> list:
    """Get course-level participation data."""

def get_course_level_assignment_data(self, **kwargs) -> list:
    """Get course-level assignment data."""

def get_student_summaries(self, **kwargs) -> PaginatedList[dict]:
    """Get student summary data for analytics."""

def get_course_level_student_summary_data(self, **kwargs) -> PaginatedList[CourseStudentSummary]:
    """Get per-user access information for all students."""

def get_user_in_a_course_level_assignment_data(self, user, **kwargs) -> dict:
    """Get assignment data for a specific user."""

def get_user_in_a_course_level_participation_data(self, user, **kwargs) -> dict:
    """Get page views and participation for a specific user."""

def get_user_in_a_course_level_messaging_data(self, user, **kwargs) -> dict:
    """Get messaging hits for a specific user."""

Usage Examples

Creating a Complete Course Setup

from canvasapi import Canvas

canvas = Canvas("https://canvas.example.com", "your-token")
course = canvas.get_course(12345)

# Create assignment groups
hw_group = course.create_assignment_group(
    name="Homework",
    weight=40
)

exam_group = course.create_assignment_group(
    name="Exams", 
    weight=60
)

# Create assignments
assignment = course.create_assignment({
    'name': 'Assignment 1',
    'description': 'Complete the reading and answer questions',
    'due_at': '2024-12-01T23:59:59Z',
    'points_possible': 100,
    'submission_types': ['online_text_entry', 'online_upload'],
    'assignment_group_id': hw_group.id
})

# Create a module
module = course.create_module({
    'name': 'Week 1: Introduction',
    'unlock_at': '2024-11-01T00:00:00Z',
    'require_sequential_progress': True
})

Enrollment Management

# Enroll students in the course
student_ids = [123, 456, 789]
for student_id in student_ids:
    enrollment = course.enroll_user(
        user=student_id,
        enrollment_type='student',
        enrollment_state='active',
        notify=True
    )
    print(f"Enrolled user {student_id}: {enrollment.id}")

# Get all students in the course
students = course.get_users(enrollment_type='student')
for student in students:
    print(f"Student: {student.name} ({student.email})")

Content Creation

# Create a course page
page = course.create_page({
    'title': 'Course Syllabus',
    'body': '<h1>Welcome to the Course</h1><p>Course description...</p>',
    'published': True,
    'front_page': True
})

# Create a discussion topic
discussion = course.create_discussion_topic(
    title="Week 1 Discussion",
    message="Please introduce yourself and share your goals for this course.",
    discussion_type='threaded',
    published=True
)

# Create a quiz
quiz = course.create_quiz({
    'title': 'Week 1 Quiz',
    'description': 'Quiz covering week 1 material',
    'quiz_type': 'assignment',
    'points_possible': 50,
    'time_limit': 30,
    'allowed_attempts': 2,
    'due_at': '2024-12-01T23:59:59Z'
})

Install with Tessl CLI

npx tessl i tessl/pypi-canvasapi

docs

account-administration.md

assignments-grading.md

communication.md

content-management.md

course-management.md

index.md

main-client.md

quizzes-assessments.md

user-management.md

tile.json