This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with Courses in Canvas



Overview

The following operations allow you to work with courses. Click an operation name to see details on how to use it.

For a sample proxy service that illustrates how to work with courses, see Sample configuration

OperationDescription

createCourse

Creates a new course for the teacher.

getCourse Retrieves a course by ID.
getCourseUserRetrieves a user belonging to a course.
listCoursesRetrieves courses created by the teacher.
listCourseUsersRetrieves all the users belonging to a course.
enrollUserEnrolls a user for a course.

Operation details

This section provides further details on the operations related to courses.

Creating a course

The createCourse operation creates a new course for the teacher.

createCourse
<canvas.createCourse>
	<accountId>{$ctx:accountId}</accountId>
    <name>{$ctx:name}</name>
    <code>{$ctx:code}</code>
    <startAt>{$ctx:startAt}</startAt>
    <endAt>{$ctx:endAt}</endAt>
    <license>{$ctx:license}</license>
    <isPublic>{$ctx:isPublic}</isPublic>
    <publicSyllabus>{$ctx:publicSyllabus}</publicSyllabus>
    <publicDescription>{$ctx:publicDescription}</publicDescription>
    <allowStudentWikiEdits>{$ctx:allowStudentWikiEdits}</allowStudentWikiEdits>
    <allowWikiComments>{$ctx:allowWikiComments}</allowWikiComments>
    <allowStudentForumAttachments>{$ctx:allowStudentForumAttachments}</allowStudentForumAttachments>
    <openEnrollment>{$ctx:openEnrollment}</openEnrollment>
    <selfEnrollment>{$ctx:selfEnrollment}</selfEnrollment>
    <restrictEnrollmentsToCourseDates>{$ctx:restrictEnrollmentsToCourseDates}</restrictEnrollmentsToCourseDates>
    <termId>{$ctx:termId}</termId>
    <sisCourseId>{$ctx:sisCourseId}</sisCourseId>
    <integrationId>{$ctx:integrationId}</integrationId>
    <hideFinalGrades>{$ctx:hideFinalGrades}</hideFinalGrades>
    <applyAssignmentGroupWeights>{$ctx:applyAssignmentGroupWeights}</applyAssignmentGroupWeights>
    <gradingStandardId>{$ctx:gradingStandardId}</gradingStandardId>
    <syllabusBody>{$ctx:syllabusBody}</syllabusBody>
    <enrollMe>{$ctx:enrollMe}</enrollMe>
	<offer>{$ctx:offer}</offer>
</canvas.createCourse>
Properties
  • accountId: The ID of the Canvas admin account to which the course belongs.
  • name: The name of the course. If omitted, the course is named "Unnamed Course".
  • code: The course code.
  • startAt: The course start date in the ISO8601 format, e.g., 2011-01-01T01:00Z.
  • endAt: The course end date in the ISO8601 format, e.g., 2011-01-01T01:00Z.
  • license: The name of the licensing used when publishing the course.
  • isPublic: Whether the course is public or private in Canvas.
  • publicSyllabus: Sets to "true" to make the course syllabus public.
  • publicDescription: A publicly visible description of the course.
  • allowStudentWikiEdits: If "true", allows students to modify the course wiki.
  • allowWikiComments: If "true", allows course members to comment on wiki pages.
  • allowStudentForumAttachments: If "true", allows students to attach files to forum posts.
  • openEnrollment: Set to "true" if the course is "open enrollment".
  • selfEnrollment: Set to "true" if the course is "self enrollment".
  • restrictEnrollmentsToCourseDates: Set to "true" to restrict user enrollments to the start and end dates of the course.
  • termId: The unique ID of the term to create a course.
  • sisCourseId: The unique SIS identifier.
  • integrationId: The unique integration identifier.
  • hideFinalGrades: If set to "true", hides the totals in the student grades summary.
  • applyAssignmentGroupWeights: Set to "true" to weight final grade based on assignment groups percentages.
  • gradingStandardId: The grading standard ID to set for the course. If no value is provided for this argument, the current grading standard is un-set from this course.
  • syllabusBody: The syllabus body for the course.
  • enrollMe: Set to "true" to enroll the current user as the teacher.
  • offer: If set to "true", makes the course available to students immediately.
Sample request

Following is a sample REST/JSON request that can be handled by the createCourse operation.

Sample Request for createCourse
{
    "publicSyllabus": true,
    "sisCourseId": "",
    "accountId": "81259",
    "accessToken": "7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
    "allowWikiComments": true,
    "gradingStandardId": "",
    "endAt": "2014-11-05T09:00Z",
    "allowStudentForumAttachments": "",
    "termId": "",
    "name": "Canvas EJB Course 1.0",
    "enrollMe": true,
    "license": "public_domain",
    "hideFinalGrades": false,
    "allowStudentWikiEdits": true,
    "applyAssignmentGroupWeights": true,
    "code": "Can-EJB-1.0",
    "isPublic": true,
    "offer": true,
    "publicDescription": "This is a public description.",
    "openEnrollment": true,
    "apiUrl": "https://canvas.instructure.com",
    "integrationId": "",
    "startAt": "2014-11-04T09:00Z",
    "syllabusBody": "<p>This is the Syllabus body</p>",
    "restrictEnrollmentsToCourseDates": "",
    "selfEnrollment": true
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/courses.html#method.courses.create

Retrieving a course 

The getCourse operation retrieves a course by ID.

getCourse
<canvas.getCourse>
    <accountId>{$ctx:accountId}</accountId>
    <courseId>{$ctx:courseId}</courseId>
	<include>{$ctx:include}</include>
</canvas.getCourse>
Properties
  • accountId: The ID of the Canvas admin account to which the course belongs.
  • courseId: The ID of the course whose users should be listed.
  • include: Includes optional details of the course that is being retrieved.
Sample request

Following is a sample REST/JSON request that can be handled by the getCourse operation.

Sample Request for getCourse
{
    "accountId": "81259",
    "accessToken": "7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
    "apiUrl": "https://canvas.instructure.com",
    "courseId": "893240",
    "include": "all_courses,permissions"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/courses.html#method.courses.show

Retrieving a user belonging to a course 

The getCourseUser operation retrieves a user belonging to a course by ID.

getCourseUser
<canvas.getCourseUser>
    <courseId>{$ctx:courseId}</courseId>
	<userId>{$ctx:userId}</userId>
</canvas.getCourseUser>
Properties
  • courseId: The ID of the course whose user should be retrieved.
  • userId: The ID of the user to be retrieved.
Sample request

Following is a sample REST/JSON request that can be handled by the getCourseUser operation.

Sample Request for getCourseUser
{
    "accessToken": "7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
    "userId": "4213615",
    "apiUrl": "https://canvas.instructure.com",
    "courseId": "897098"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/courses.html#method.courses.user

Retrieving courses 

The listCourses operation retrieves a list of active courses for the current user.

listCourses
<canvas.listCourses>
	<enrollmentType>{$ctx:enrollmentType}</enrollmentType>
    <enrollmentRole>{$ctx:enrollmentRole}</enrollmentRole>
    <include>{$ctx:include}</include>
    <state>{$ctx:state}</state>
    <perPage>{$ctx:perPage}</perPage>
	<page>{$ctx:page}</page>
</canvas.listCourses>
Properties
  • enrollmentType: When set, only return courses where the user is enrolled as this type. This argument is ignored if enrollment_role is given.
  • enrollmentRole: When set, only return courses where the user is enrolled with the specified course-level role.
  • include: Include optional details of each course being listed. The values that can be passed are needs_grading_count, syllabus_body, total_scores, term, course progress, section. For further information, see https://canvas.instructure.com/doc/api/courses.html#method.courses.index.
  • state: State(s) of the courses to be listed.
  • perPage: The number of results to return per page. For more information on pagination, see https://canvas.instructure.com/doc/api/file.pagination.html.
  • page: Number of the page to return.
Sample request

Following is a sample REST/JSON request that can be handled by the listCourses operation.

Sample Request for listCourses
{
    "accessToken": "7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
    "enrollmentRole": "TeacherEnrollment",
    "state": "available",
    "apiUrl": "https://canvas.instructure.com",
    "enrollmentType": "teacher",
    "perPage": "3",
    "page": "1",
    "include": "needs_grading_count,syllabus_body,total_scores,term,course_progress,sections"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/courses.html#method.courses.index

Retrieving all users 

The listCourseUsers operation retrieves all users belonging to a course.

listCourseUsers
<canvas.listCourseUsers>
    <searchTerm>{$ctx:searchTerm}</searchTerm>
    <userId>{$ctx:userId}</userId>
    <enrollmentType>{$ctx:enrollmentType}</enrollmentType>
    <enrollmentRole>{$ctx:enrollmentRole}</enrollmentRole>
    <include>{$ctx:include}</include>
    <page>{$ctx:page}</page>
    <perPage>{$ctx:perPage}</perPage>
	<courseId>{$ctx:courseId}</courseId>
</canvas.listCourseUsers>
Properties
  • searchTerm: The partial name or full ID of the users to match and return in the results list.
  • userId: If included, queries the user, and if the user is part of the users set, modifies the page parameter so that the page containing user_id is returned.
  • enrollmentType: When set, only returns users where the user is enrolled as this type. This argument is ignored if enrollment_role is given.
  • enrollmentRole: When set, only returns users enrolled with the specified course-level role.
  • include: Includes optional details of each user being listed.
  • page: The number of the page to return. For more information on pagination, see https://canvas.instructure.com/doc/api/file.pagination.html.
  • perPage: The number of results to return per page.
  • courseId: The ID of the course whose users should be listed.
Sample request

Following is a sample REST/JSON request that can be handled by the listCourseUsers operation.

Sample Request for listCourseUsers
{
    "accessToken": "7~UnsR6KCrYoap7KyAYMfNvANQeD59OinOIRp0S82FU7z1o5dz7o0VIBqNl6afoVBO",
    "searchTerm": "",
    "enrollmentRole": "",
    "userId": "",
    "apiUrl": "https://canvas.instructure.com",
    "enrollmentType": "",
    "perPage": "5",
    "page": "1",
    "courseId": "897098",
    "include": "email,enrollments,locked,avatar_url,test_student"
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/courses.html#method.courses.users

Enrolling a user 

The enrollUser operation enrolls a user for a course in Canvas.

enrollUser
<canvas.enrollUser>
    <courseSectionId>{$ctx:courseSectionId}</courseSectionId>
    <limitPrivilegesToCourseSection>{$ctx:limitPrivilegesToCourseSection}</limitPrivilegesToCourseSection>
    <enrollmentState>{$ctx:enrollmentState}</enrollmentState>
    <selfEnrollmentCode>{$ctx:selfEnrollmentCode}</selfEnrollmentCode>
    <enrollmentRole>{$ctx:enrollmentRole}</enrollmentRole>
    <enrollmentType>{$ctx:enrollmentType}</enrollmentType>
    <courseId>{$ctx:courseId}</courseId>
    <userId>{$ctx:userId}</userId>
	<notify>{$ctx:notify}</notify>
</canvas.enrollUser>
Properties
  • courseSectionId: The ID of the course section to enroll the student to.
  • limitPrivilegesToCourseSection: If a teacher or TA enrollment, restricts the teacher/TA to the section given by course_section_id.
  • enrollmentState: If set to "active", immediately enrolls the student to the course. Otherwise, the student will be required to accept a course invitation. Default: "invited".
  • selfEnrollmentCode: If the current user is not allowed to manage enrollments in this course, but the course allows self-enrollment, allows the user to self-enroll as a student in the default section by passing in a valid code.
  • enrollmentRole: Assigns a custom course-level role to the user.
  • enrollmentType: Enrolls the user as a student, teacher, TA, observer, or designer.
  • courseId: The ID of the course to which the user is being enrolled.
  • userId: The ID of the user to be enrolled in the course.
  • notify: If "true", sends a notification to the enrolled user. Notifications are not sent by default.
Sample request

Following is a sample REST/JSON request that can be handled by the enrollUser operation.

Sample Request for enrollUser
{
	"apiUrl":"https://orion-city.acme.instructure.com",
    "accessToken":"51451~fwK08jirhrTKFiuyua8H3rpFVQtZJu7D7rf3mi7pecuHxMglbY24XOxQ42UWTvam",
	"courseSectionId":"",
	"limitPrivilegesToCourseSection":true,
	"enrollmentState":"",
	"selfEnrollmentCode":"",
	"enrollmentRole":"",
	"enrollmentType":"StudentEnrollment",
	"courseId":"96",
	"userId":"14",
	"notify":true
}
Related Canvas documentation

https://canvas.instructure.com/doc/api/enrollments.html#method.enrollments_api.create

Sample configuration

Following is a sample proxy service that illustrates how to connect to Canvas with the init operation and use the createCourse operation. The sample request for this proxy can be found in the createCourse sample request. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="canvas_createCourse" startOnLoad="true" statistics="disable" trace="disable" transports="https,http" xmlns="http://ws.apache.org/ns/synapse">
    <target>
        <inSequence onError="faultHandlerSeq">
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <property name="accessToken" expression="json-eval($.accessToken)"/>
            <property name="accountId" expression="json-eval($.accountId)"/>
            <property name="name" expression="json-eval($.name)"/>
            <property name="code" expression="json-eval($.code)"/>
            <property name="startAt" expression="json-eval($.startAt)"/>
            <property name="endAt" expression="json-eval($.endAt)"/>
            <property name="license" expression="json-eval($.license)"/>
            <property name="isPublic" expression="json-eval($.isPublic)"/>
            <property name="publicSyllabus" expression="json-eval($.publicSyllabus)"/>
            <property name="publicDescription" expression="json-eval($.publicDescription)"/>
            <property name="allowStudentWikiEdits" expression="json-eval($.allowStudentWikiEdits)"/>
            <property name="allowWikiComments" expression="json-eval($.allowWikiComments)"/>
            <property name="allowStudentForumAttachments" expression="json-eval($.allowStudentForumAttachments)"/>
            <property name="openEnrollment" expression="json-eval($.openEnrollment)"/>
            <property name="selfEnrollment" expression="json-eval($.selfEnrollment)"/>
            <property name="restrictEnrollmentsToCourseDates" expression="json-eval($.restrictEnrollmentsToCourseDates)"/>
            <property name="termId" expression="json-eval($.termId)"/>
            <property name="sisCourseId" expression="json-eval($.sisCourseId)"/>
            <property name="integrationId" expression="json-eval($.integrationId)"/>
            <property name="hideFinalGrades" expression="json-eval($.hideFinalGrades)"/>
            <property name="applyAssignmentGroupWeights" expression="json-eval($.applyAssignmentGroupWeights)"/>
            <property name="gradingStandardId" expression="json-eval($.gradingStandardId)"/>
            <property name="syllabusBody" expression="json-eval($.syllabusBody)"/>
            <property name="enrollMe" expression="json-eval($.enrollMe)"/>
            <property name="offer" expression="json-eval($.offer)"/>
            <canvas.init>
                <apiUrl>{$ctx:apiUrl}</apiUrl>
                <accessToken>{$ctx:accessToken}</accessToken>
            </canvas.init>
            <canvas.createCourse>
                <accountId>{$ctx:accountId}</accountId>
                <name>{$ctx:name}</name>
                <code>{$ctx:code}</code>
                <startAt>{$ctx:startAt}</startAt>
                <endAt>{$ctx:endAt}</endAt>
                <license>{$ctx:license}</license>
                <isPublic>{$ctx:isPublic}</isPublic>
                <publicSyllabus>{$ctx:publicSyllabus}</publicSyllabus>
                <publicDescription>{$ctx:publicDescription}</publicDescription>
                <allowStudentWikiEdits>{$ctx:allowStudentWikiEdits}</allowStudentWikiEdits>
                <allowWikiComments>{$ctx:allowWikiComments}</allowWikiComments>
                <allowStudentForumAttachments>{$ctx:allowStudentForumAttachments}</allowStudentForumAttachments>
                <openEnrollment>{$ctx:openEnrollment}</openEnrollment>
                <selfEnrollment>{$ctx:selfEnrollment}</selfEnrollment>
                <restrictEnrollmentsToCourseDates>{$ctx:restrictEnrollmentsToCourseDates}</restrictEnrollmentsToCourseDates>
                <termId>{$ctx:termId}</termId>
                <sisCourseId>{$ctx:sisCourseId}</sisCourseId>
                <integrationId>{$ctx:integrationId}</integrationId>
                <hideFinalGrades>{$ctx:hideFinalGrades}</hideFinalGrades>
                <applyAssignmentGroupWeights>{$ctx:applyAssignmentGroupWeights}</applyAssignmentGroupWeights>
                <gradingStandardId>{$ctx:gradingStandardId}</gradingStandardId>
                <syllabusBody>{$ctx:syllabusBody}</syllabusBody>
                <enrollMe>{$ctx:enrollMe}</enrollMe>
                <offer>{$ctx:offer}</offer>
            </canvas.createCourse>
            <respond/>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>