@pipedream/canvas 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/list-assignments/list-assignments.mjs +52 -0
- package/actions/list-courses/list-courses.mjs +42 -0
- package/actions/search-course-content/search-course-content.mjs +59 -0
- package/actions/update-assignment/update-assignment.mjs +149 -0
- package/canvas.app.mjs +129 -4
- package/common/constants.mjs +26 -0
- package/package.json +2 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import canvas from "../../canvas.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "canvas-list-assignments",
|
|
5
|
+
name: "List Assignments",
|
|
6
|
+
description: "Retrieve a list of assignments for a course. [See the documentation](https://mitt.uib.no/doc/api/all_resources.html#method.assignments_api.user_index)",
|
|
7
|
+
version: "0.0.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
canvas,
|
|
16
|
+
accountId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
canvas,
|
|
19
|
+
"accountId",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
userId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
canvas,
|
|
25
|
+
"userId",
|
|
26
|
+
(c) => ({
|
|
27
|
+
accountId: c.accountId,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
courseId: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
canvas,
|
|
34
|
+
"courseId",
|
|
35
|
+
(c) => ({
|
|
36
|
+
userId: c.userId,
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
async run({ $ }) {
|
|
42
|
+
const assignments = await this.canvas.listAssignments({
|
|
43
|
+
$,
|
|
44
|
+
userId: this.userId,
|
|
45
|
+
courseId: this.courseId,
|
|
46
|
+
});
|
|
47
|
+
$.export("$summary", `${assignments.length} assignment${assignments.length > 1
|
|
48
|
+
? "s"
|
|
49
|
+
: ""} were successfully retrieved.`);
|
|
50
|
+
return assignments;
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import canvas from "../../canvas.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "canvas-list-courses",
|
|
5
|
+
name: "List Courses",
|
|
6
|
+
description: "List all the courses associated with a given user. [See the documentation](https://mitt.uib.no/doc/api/all_resources.html#method.courses.user_index)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
canvas,
|
|
16
|
+
accountId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
canvas,
|
|
19
|
+
"accountId",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
userId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
canvas,
|
|
25
|
+
"userId",
|
|
26
|
+
(c) => ({
|
|
27
|
+
accountId: c.accountId,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
async run({ $ }) {
|
|
33
|
+
const courses = await this.canvas.listCourses({
|
|
34
|
+
$,
|
|
35
|
+
userId: this.userId,
|
|
36
|
+
});
|
|
37
|
+
$.export("$summary", `${courses.length} course${courses.length > 1
|
|
38
|
+
? "s"
|
|
39
|
+
: ""} were successfully retrieved.`);
|
|
40
|
+
return courses;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import canvas from "../../canvas.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "canvas-search-course-content",
|
|
5
|
+
name: "Search Course Content",
|
|
6
|
+
description: "Search for content in a course. [See the documentation](https://mitt.uib.no/doc/api/all_resources.html#method.smart_search.search)",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
canvas,
|
|
16
|
+
accountId: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
canvas,
|
|
19
|
+
"accountId",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
userId: {
|
|
23
|
+
propDefinition: [
|
|
24
|
+
canvas,
|
|
25
|
+
"userId",
|
|
26
|
+
(c) => ({
|
|
27
|
+
accountId: c.accountId,
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
courseId: {
|
|
32
|
+
propDefinition: [
|
|
33
|
+
canvas,
|
|
34
|
+
"courseId",
|
|
35
|
+
(c) => ({
|
|
36
|
+
userId: c.userId,
|
|
37
|
+
}),
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
query: {
|
|
41
|
+
type: "string",
|
|
42
|
+
label: "Query",
|
|
43
|
+
description: "The query to search for",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
async run({ $ }) {
|
|
47
|
+
const results = await this.canvas.searchCourseContent({
|
|
48
|
+
$,
|
|
49
|
+
courseId: this.courseId,
|
|
50
|
+
params: {
|
|
51
|
+
q: this.query,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
$.export("$summary", `${results.length} result${results.length > 1
|
|
55
|
+
? "s"
|
|
56
|
+
: ""} were found.`);
|
|
57
|
+
return results;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import canvas from "../../canvas.app.mjs";
|
|
2
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
key: "canvas-update-assignment",
|
|
7
|
+
name: "Update Assignment",
|
|
8
|
+
description: "Update an assignment. [See the documentation](https://mitt.uib.no/doc/api/all_resources.html#method.assignments_api.update)",
|
|
9
|
+
version: "0.0.2",
|
|
10
|
+
type: "action",
|
|
11
|
+
annotations: {
|
|
12
|
+
destructiveHint: true,
|
|
13
|
+
openWorldHint: true,
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
canvas,
|
|
18
|
+
accountId: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
canvas,
|
|
21
|
+
"accountId",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
userId: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
canvas,
|
|
27
|
+
"userId",
|
|
28
|
+
(c) => ({
|
|
29
|
+
accountId: c.accountId,
|
|
30
|
+
}),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
courseId: {
|
|
34
|
+
propDefinition: [
|
|
35
|
+
canvas,
|
|
36
|
+
"courseId",
|
|
37
|
+
(c) => ({
|
|
38
|
+
userId: c.userId,
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
assignmentId: {
|
|
43
|
+
propDefinition: [
|
|
44
|
+
canvas,
|
|
45
|
+
"assignmentId",
|
|
46
|
+
(c) => ({
|
|
47
|
+
courseId: c.courseId,
|
|
48
|
+
userId: c.userId,
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
name: {
|
|
53
|
+
type: "string",
|
|
54
|
+
label: "Name",
|
|
55
|
+
description: "The name of the assignment",
|
|
56
|
+
optional: true,
|
|
57
|
+
},
|
|
58
|
+
description: {
|
|
59
|
+
type: "string",
|
|
60
|
+
label: "Description",
|
|
61
|
+
description: "The description of the assignment, supports HTML",
|
|
62
|
+
optional: true,
|
|
63
|
+
},
|
|
64
|
+
submissionType: {
|
|
65
|
+
type: "string",
|
|
66
|
+
label: "Submission Type",
|
|
67
|
+
description: "The type of submission for the assignment",
|
|
68
|
+
options: constants.SUBMISSION_TYPES,
|
|
69
|
+
optional: true,
|
|
70
|
+
},
|
|
71
|
+
notifyOfUpdate: {
|
|
72
|
+
type: "boolean",
|
|
73
|
+
label: "Notify of Update",
|
|
74
|
+
description: "Whether to notify the students of the update",
|
|
75
|
+
optional: true,
|
|
76
|
+
},
|
|
77
|
+
pointsPossible: {
|
|
78
|
+
type: "integer",
|
|
79
|
+
label: "Points Possible",
|
|
80
|
+
description: "The maximum points possible on the assignment",
|
|
81
|
+
optional: true,
|
|
82
|
+
},
|
|
83
|
+
gradingType: {
|
|
84
|
+
type: "string",
|
|
85
|
+
label: "Grading Type",
|
|
86
|
+
description: "The strategy used for grading the assignment. The assignment defaults to “points” if this field is omitted.",
|
|
87
|
+
options: constants.GRADING_TYPES,
|
|
88
|
+
optional: true,
|
|
89
|
+
},
|
|
90
|
+
dueAt: {
|
|
91
|
+
type: "string",
|
|
92
|
+
label: "Due At",
|
|
93
|
+
description: "The day/time the assignment is due. Accepts times in ISO 8601 format, e.g. 2014-10-21T18:48:00Z.",
|
|
94
|
+
optional: true,
|
|
95
|
+
},
|
|
96
|
+
omitFromFinalGrade: {
|
|
97
|
+
type: "boolean",
|
|
98
|
+
label: "Omit From Final Grade",
|
|
99
|
+
description: "Whether this assignment is counted towards a student's final grade.",
|
|
100
|
+
optional: true,
|
|
101
|
+
},
|
|
102
|
+
allowedAttempts: {
|
|
103
|
+
type: "integer",
|
|
104
|
+
label: "Allowed Attempts",
|
|
105
|
+
description: "The number of submission attempts allowed for this assignment. Set to -1 for unlimited attempts.",
|
|
106
|
+
optional: true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
async run({ $ }) {
|
|
110
|
+
if (
|
|
111
|
+
!this.name
|
|
112
|
+
&& !this.description
|
|
113
|
+
&& !this.submissionType
|
|
114
|
+
&& !this.notifyOfUpdate
|
|
115
|
+
&& !this.pointsPossible
|
|
116
|
+
&& !this.gradingType
|
|
117
|
+
&& !this.dueAt
|
|
118
|
+
&& !this.omitFromFinalGrade
|
|
119
|
+
&& !this.allowedAttempts
|
|
120
|
+
) {
|
|
121
|
+
throw new ConfigurationError("At least one field must be provided to update the assignment");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const assignment = await this.canvas.updateAssignment({
|
|
125
|
+
$,
|
|
126
|
+
courseId: this.courseId,
|
|
127
|
+
assignmentId: this.assignmentId,
|
|
128
|
+
data: {
|
|
129
|
+
assignment: {
|
|
130
|
+
name: this.name,
|
|
131
|
+
description: this.description,
|
|
132
|
+
submission_types: this.submissionType
|
|
133
|
+
? [
|
|
134
|
+
this.submissionType,
|
|
135
|
+
]
|
|
136
|
+
: undefined,
|
|
137
|
+
notify_of_update: this.notifyOfUpdate,
|
|
138
|
+
points_possible: this.pointsPossible,
|
|
139
|
+
grading_type: this.gradingType,
|
|
140
|
+
due_at: this.dueAt,
|
|
141
|
+
omit_from_final_grade: this.omitFromFinalGrade,
|
|
142
|
+
allowed_attempts: this.allowedAttempts,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
$.export("$summary", `Successfully updated assignment with ID: '${this.assignmentId}'`);
|
|
147
|
+
return assignment;
|
|
148
|
+
},
|
|
149
|
+
};
|
package/canvas.app.mjs
CHANGED
|
@@ -1,11 +1,136 @@
|
|
|
1
|
+
import { axios } from "@pipedream/platform";
|
|
2
|
+
|
|
1
3
|
export default {
|
|
2
4
|
type: "app",
|
|
3
5
|
app: "canvas",
|
|
4
|
-
propDefinitions: {
|
|
6
|
+
propDefinitions: {
|
|
7
|
+
accountId: {
|
|
8
|
+
type: "string",
|
|
9
|
+
label: "Account ID",
|
|
10
|
+
description: "The ID of an account",
|
|
11
|
+
async options() {
|
|
12
|
+
const accounts = await this.listAccounts();
|
|
13
|
+
return accounts?.map(({
|
|
14
|
+
id: value, name: label,
|
|
15
|
+
}) => ({
|
|
16
|
+
value,
|
|
17
|
+
label,
|
|
18
|
+
})) ?? [];
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
userId: {
|
|
22
|
+
type: "string",
|
|
23
|
+
label: "User ID",
|
|
24
|
+
description: "The ID of a user",
|
|
25
|
+
async options({ accountId }) {
|
|
26
|
+
const users = await this.listUsers({
|
|
27
|
+
accountId,
|
|
28
|
+
});
|
|
29
|
+
return users?.map(({
|
|
30
|
+
id: value, name: label,
|
|
31
|
+
}) => ({
|
|
32
|
+
value,
|
|
33
|
+
label,
|
|
34
|
+
})) ?? [];
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
courseId: {
|
|
38
|
+
type: "string",
|
|
39
|
+
label: "Course ID",
|
|
40
|
+
description: "The ID of a course",
|
|
41
|
+
async options({ userId }) {
|
|
42
|
+
const courses = await this.listCourses({
|
|
43
|
+
userId,
|
|
44
|
+
});
|
|
45
|
+
return courses?.map(({
|
|
46
|
+
id: value, name: label,
|
|
47
|
+
}) => ({
|
|
48
|
+
value,
|
|
49
|
+
label,
|
|
50
|
+
})) ?? [];
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
assignmentId: {
|
|
54
|
+
type: "string",
|
|
55
|
+
label: "Assignment ID",
|
|
56
|
+
description: "The ID of an assignment",
|
|
57
|
+
async options({
|
|
58
|
+
userId, courseId,
|
|
59
|
+
}) {
|
|
60
|
+
const assignments = await this.listAssignments({
|
|
61
|
+
userId,
|
|
62
|
+
courseId,
|
|
63
|
+
});
|
|
64
|
+
return assignments?.map(({
|
|
65
|
+
id: value, name: label,
|
|
66
|
+
}) => ({
|
|
67
|
+
value,
|
|
68
|
+
label,
|
|
69
|
+
})) ?? [];
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
5
73
|
methods: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
74
|
+
_baseUrl() {
|
|
75
|
+
return `https://${this.$auth.domain}/api/v1`;
|
|
76
|
+
},
|
|
77
|
+
_makeRequest({
|
|
78
|
+
$ = this, path, ...opts
|
|
79
|
+
}) {
|
|
80
|
+
return axios($, {
|
|
81
|
+
url: `${this._baseUrl()}${path}`,
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
|
|
84
|
+
},
|
|
85
|
+
...opts,
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
listAccounts(opts = {}) {
|
|
89
|
+
return this._makeRequest({
|
|
90
|
+
path: "/accounts",
|
|
91
|
+
...opts,
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
listUsers({
|
|
95
|
+
accountId, ...opts
|
|
96
|
+
}) {
|
|
97
|
+
return this._makeRequest({
|
|
98
|
+
path: `/accounts/${accountId}/users`,
|
|
99
|
+
...opts,
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
listCourses({
|
|
103
|
+
userId, ...opts
|
|
104
|
+
}) {
|
|
105
|
+
return this._makeRequest({
|
|
106
|
+
path: `/users/${userId}/courses`,
|
|
107
|
+
...opts,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
listAssignments({
|
|
111
|
+
userId, courseId, ...opts
|
|
112
|
+
}) {
|
|
113
|
+
return this._makeRequest({
|
|
114
|
+
path: `/users/${userId}/courses/${courseId}/assignments`,
|
|
115
|
+
...opts,
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
updateAssignment({
|
|
119
|
+
courseId, assignmentId, ...opts
|
|
120
|
+
}) {
|
|
121
|
+
return this._makeRequest({
|
|
122
|
+
method: "PUT",
|
|
123
|
+
path: `/courses/${courseId}/assignments/${assignmentId}`,
|
|
124
|
+
...opts,
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
searchCourseContent({
|
|
128
|
+
courseId, ...opts
|
|
129
|
+
}) {
|
|
130
|
+
return this._makeRequest({
|
|
131
|
+
path: `/courses/${courseId}/smartsearch`,
|
|
132
|
+
...opts,
|
|
133
|
+
});
|
|
9
134
|
},
|
|
10
135
|
},
|
|
11
136
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const SUBMISSION_TYPES = [
|
|
2
|
+
"online_quiz",
|
|
3
|
+
"none",
|
|
4
|
+
"on_paper",
|
|
5
|
+
"discussion_topic",
|
|
6
|
+
"external_tool",
|
|
7
|
+
"online_upload",
|
|
8
|
+
"online_text_entry",
|
|
9
|
+
"online_url",
|
|
10
|
+
"media_recording",
|
|
11
|
+
"student_annotation",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
const GRADING_TYPES = [
|
|
15
|
+
"pass_fail",
|
|
16
|
+
"percent",
|
|
17
|
+
"letter_grade",
|
|
18
|
+
"gpa_scale",
|
|
19
|
+
"points",
|
|
20
|
+
"not_graded",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
SUBMISSION_TYPES,
|
|
25
|
+
GRADING_TYPES,
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/canvas",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Pipedream canvas Components",
|
|
5
5
|
"main": "canvas.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^3.
|
|
16
|
+
"@pipedream/platform": "^3.1.1"
|
|
17
17
|
}
|
|
18
18
|
}
|