@ueu/ueu-canvas 0.0.2
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/LICENSE +21 -0
- package/html-loader.js +7 -0
- package/jest.config.js +20 -0
- package/package.json +45 -0
- package/src/Account.ts +69 -0
- package/src/NotImplementedException.ts +3 -0
- package/src/__mocks__/Account.ts +55 -0
- package/src/__mocks__/index.ts +8 -0
- package/src/__mocks__/mockAccountData.ts +43 -0
- package/src/__mocks__/mockEnrollment.ts +22 -0
- package/src/__mocks__/mockRubricData.ts +71 -0
- package/src/__mocks__/mockTabData.ts +13 -0
- package/src/__mocks__/mockTermData.ts +7 -0
- package/src/__mocks__/mockUserData.ts +14 -0
- package/src/__mocks__/utils.ts +9 -0
- package/src/__tests__/canvasUtils.test.ts +527 -0
- package/src/__tests__/fetch.test.ts +310 -0
- package/src/__tests__/profile.test.ts +19 -0
- package/src/__tests__/rubrics.test.ts +131 -0
- package/src/baseCanvasObject.ts +139 -0
- package/src/canvasDataDefs.ts +124 -0
- package/src/canvasUtils.ts +420 -0
- package/src/consts.ts +2 -0
- package/src/content/BaseContentItem.ts +219 -0
- package/src/content/ContentKind.ts +85 -0
- package/src/content/__mocks__/determineContent.ts +27 -0
- package/src/content/__mocks__/mockAssignmentSubmission.ts +37 -0
- package/src/content/__mocks__/mockContentData.ts +98 -0
- package/src/content/__mocks__/openThisContentInTarget.ts +2 -0
- package/src/content/__testingUtils__/utils.ts +47 -0
- package/src/content/__tests__/determineContent.test.ts +101 -0
- package/src/content/__tests__/getContentFuncs.test.ts +78 -0
- package/src/content/assignments/Assignment.ts +69 -0
- package/src/content/assignments/AssignmentKind.ts +29 -0
- package/src/content/assignments/__tests__/AssignmentKind.test.ts +31 -0
- package/src/content/assignments/__tests__/assignments.test.ts +72 -0
- package/src/content/assignments/deleteAssignmentGroup.ts +15 -0
- package/src/content/assignments/genAssignmentGroups.ts +15 -0
- package/src/content/assignments/index.ts +31 -0
- package/src/content/assignments/legacy.ts +11 -0
- package/src/content/assignments/updateAssignmentDueDates.ts +25 -0
- package/src/content/determineContent.ts +72 -0
- package/src/content/discussions/Discussion.ts +32 -0
- package/src/content/discussions/DiscussionKind.ts +30 -0
- package/src/content/discussions/__tests__/DiscussionKind.test.ts +31 -0
- package/src/content/discussions/genEquivalentDiscussionData.ts +97 -0
- package/src/content/discussions/index.ts +2 -0
- package/src/content/getContentFuncs.ts +30 -0
- package/src/content/index.ts +11 -0
- package/src/content/openThisContentInTarget.ts +38 -0
- package/src/content/pages/Page.ts +35 -0
- package/src/content/pages/PageKind.ts +39 -0
- package/src/content/pages/__tests__/PageKind.test.ts +86 -0
- package/src/content/pages/__tests__/learningMaterialsForModule.ts +57 -0
- package/src/content/pages/index.ts +12 -0
- package/src/content/pages/learningMaterialsForModule.ts +16 -0
- package/src/content/pages/types.ts +11 -0
- package/src/content/quizzes/Quiz.ts +25 -0
- package/src/content/quizzes/QuizKind.ts +23 -0
- package/src/content/quizzes/__tests__/QuizKind.test.ts +30 -0
- package/src/content/quizzes/index.ts +3 -0
- package/src/content/quizzes/types.ts +101 -0
- package/src/content/types.ts +302 -0
- package/src/course/Course.ts +538 -0
- package/src/course/IBlueprintCourse.ts +8 -0
- package/src/course/__mocks__/blueprint.ts +31 -0
- package/src/course/__mocks__/mockCourseData.ts +49 -0
- package/src/course/__mocks__/mockLatePolicy.ts +14 -0
- package/src/course/__mocks__/mockModuleData.ts +60 -0
- package/src/course/__mocks__/mockProgressData.ts +28 -0
- package/src/course/__mocks__/syllabus.gallant.html +302 -0
- package/src/course/__mocks__/syllabus.goofus.html +288 -0
- package/src/course/__mocks__/syllabus.grad.html +282 -0
- package/src/course/__tests__/Course.test.ts +91 -0
- package/src/course/__tests__/blueprint.test.ts +292 -0
- package/src/course/__tests__/changeStartDate.test.ts +180 -0
- package/src/course/__tests__/index.test.ts +104 -0
- package/src/course/blueprint.ts +116 -0
- package/src/course/cachedGetAssociatedCoursesFunc.ts +13 -0
- package/src/course/changeStartDate.ts +139 -0
- package/src/course/code.ts +32 -0
- package/src/course/courseTypes.ts +161 -0
- package/src/course/getCourseIdFromUrl.ts +7 -0
- package/src/course/getSections.ts +9 -0
- package/src/course/getTermNameFromSections.ts +9 -0
- package/src/course/index.ts +12 -0
- package/src/course/migration/__mocks__/mockMigrationData.ts +39 -0
- package/src/course/migration/__tests__/migration.test.ts +173 -0
- package/src/course/migration/__tests__/migrationCache.test.ts +45 -0
- package/src/course/migration/index.ts +134 -0
- package/src/course/migration/migrationCache.ts +56 -0
- package/src/course/modules.ts +113 -0
- package/src/course/notABlueprintError.ts +3 -0
- package/src/course/references/getReferencesForText.test.ts +18 -0
- package/src/course/references/getReferencesForText.ts +12 -0
- package/src/course/references/getReferencesTemplate.ts +28 -0
- package/src/course/references/mockCiteAsResponse.ts +320 -0
- package/src/course/retireBlueprint.ts +21 -0
- package/src/course/toolbox.ts +107 -0
- package/src/date.ts +119 -0
- package/src/enrollments/EnrollmentTypes.ts +76 -0
- package/src/enrollments/enrollmentRole.ts +6 -0
- package/src/enrollments/getEnrollmentGenerator.ts +79 -0
- package/src/enrollments/index.ts +3 -0
- package/src/fetch/__mocks__/fetchJson.ts +1 -0
- package/src/fetch/__mocks__/getPagedDataGenerator.ts +8 -0
- package/src/fetch/__mocks__/index.ts +6 -0
- package/src/fetch/apiGetConfig.ts +10 -0
- package/src/fetch/apiWriteConfig.ts +13 -0
- package/src/fetch/canvasDataFetchGenFunc.ts +20 -0
- package/src/fetch/fetchJson.ts +22 -0
- package/src/fetch/getPagedDataGenerator.ts +157 -0
- package/src/fetch/index.ts +5 -0
- package/src/fetch/utils.ts +16 -0
- package/src/files.ts +60 -0
- package/src/fixes/annotations.ts +105 -0
- package/src/fixes/index.ts +81 -0
- package/src/index.ts +29 -0
- package/src/profile.ts +253 -0
- package/src/rubricTypes.ts +82 -0
- package/src/rubrics.ts +48 -0
- package/src/term/Term.ts +77 -0
- package/src/term/__tests__/dateFromTermName.test.ts +22 -0
- package/src/term/__tests__/getTermsGenerator.test.ts +24 -0
- package/src/term/dateFromTermName.ts +17 -0
- package/src/term/getTermsGenerator.ts +21 -0
- package/src/term/index.ts +3 -0
- package/src/toolbox.ts +19 -0
- package/src/types.ts +134 -0
- package/src/users/getUserGenerator.ts +39 -0
- package/src/users/index.ts +1 -0
- package/tsconfig.json +46 -0
- package/webpack.config.js +122 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import {CanvasData} from "@/canvasDataDefs";
|
|
2
|
+
import {IQueryParams} from "@/canvasUtils";
|
|
3
|
+
import {IQuizData} from "@/content/quizzes/types";
|
|
4
|
+
import {IPageData} from "@/content/pages/types";
|
|
5
|
+
import {FileAttachment, ICourseData, TopicPermissions} from "@/types";
|
|
6
|
+
import {IRubricCriterionData, RubricAssessment} from "@/rubricTypes";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export type DateString = string;
|
|
11
|
+
|
|
12
|
+
export interface AssignmentDate extends CanvasData {
|
|
13
|
+
id: number,
|
|
14
|
+
base?: boolean,
|
|
15
|
+
title: string,
|
|
16
|
+
due_at?: DateString | null,
|
|
17
|
+
lock_at?: DateString | null,
|
|
18
|
+
unlock_at?: DateString | null,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type SubmissionType = 'discussion_topic' | 'online_quiz' | 'on_paper' | 'none' |
|
|
22
|
+
'external_tool' | 'online_text_entry' | 'online_url'
|
|
23
|
+
|
|
24
|
+
export interface IGradingRules {
|
|
25
|
+
drop_lowest?: number,
|
|
26
|
+
drop_highest?: number,
|
|
27
|
+
never_drop?: number[],
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type DiscussionType = 'side_comment' | 'threaded' | 'not_threaded';
|
|
31
|
+
|
|
32
|
+
export interface IDiscussionData extends CanvasData {
|
|
33
|
+
id: number,
|
|
34
|
+
title: string,
|
|
35
|
+
message: string,
|
|
36
|
+
html_url: string,
|
|
37
|
+
posted_at?: DateString | null | undefined,
|
|
38
|
+
last_reply_at?: DateString | null | undefined,
|
|
39
|
+
require_initial_post: boolean,
|
|
40
|
+
discussion_subentry_count: number,
|
|
41
|
+
read_state: "read" | "unread",
|
|
42
|
+
unread_count: number,
|
|
43
|
+
subscribed: boolean,
|
|
44
|
+
subscription_hold?: 'initial_post_required' | 'not_in_group_set' | 'not_in_group' | 'topic_is_announcement',
|
|
45
|
+
assignment_id: number | null,
|
|
46
|
+
delayed_post_at?: string | null,
|
|
47
|
+
published: boolean,
|
|
48
|
+
lock_at?: DateString | null | undefined,
|
|
49
|
+
locked: boolean,
|
|
50
|
+
pinned: boolean,
|
|
51
|
+
locked_for_user: boolean,
|
|
52
|
+
lock_info?: LockInfo | null,
|
|
53
|
+
user_can_see_posts: boolean,
|
|
54
|
+
lock_explanation?: string | null,
|
|
55
|
+
user_name: string,
|
|
56
|
+
topic_children: number[],
|
|
57
|
+
group_topic_children?: { id: number, group_id: number }[],
|
|
58
|
+
root_topic_id?: number | null,
|
|
59
|
+
podcast_url?: string,
|
|
60
|
+
discussion_type: DiscussionType,
|
|
61
|
+
group_category_id?: number | null,
|
|
62
|
+
attachments?: FileAttachment[] | null,
|
|
63
|
+
permissions: TopicPermissions,
|
|
64
|
+
allow_rating: boolean,
|
|
65
|
+
only_graders_can_rate: boolean,
|
|
66
|
+
sort_by_grading: boolean,
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface SaveDiscussionData {
|
|
71
|
+
title?: string;
|
|
72
|
+
message?: string;
|
|
73
|
+
discussion_type?: DiscussionType;
|
|
74
|
+
published?: boolean;
|
|
75
|
+
delayed_post_at?: Date;
|
|
76
|
+
lock_at?: Date;
|
|
77
|
+
podcast_enabled?: boolean;
|
|
78
|
+
podcast_has_student_posts?: boolean;
|
|
79
|
+
require_initial_post?: boolean;
|
|
80
|
+
assignment?: IAssignmentData;
|
|
81
|
+
is_announcement?: boolean;
|
|
82
|
+
pinned?: boolean;
|
|
83
|
+
position_after?: string;
|
|
84
|
+
group_category_id?: number;
|
|
85
|
+
allow_rating?: boolean;
|
|
86
|
+
only_graders_can_rate?: boolean;
|
|
87
|
+
sort_by_rating?: boolean;
|
|
88
|
+
specific_sections?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface IAssignmentData extends CanvasData {
|
|
92
|
+
id: number,
|
|
93
|
+
name: string,
|
|
94
|
+
description: string,
|
|
95
|
+
created_at: DateString, //ISO string
|
|
96
|
+
updated_at: DateString | null,
|
|
97
|
+
due_at: DateString | null,
|
|
98
|
+
lock_at: DateString | null,
|
|
99
|
+
unlock_at: DateString | null,
|
|
100
|
+
has_overrides: boolean,
|
|
101
|
+
all_dates?: AssignmentDate[],
|
|
102
|
+
course_id: number,
|
|
103
|
+
html_url: string,
|
|
104
|
+
discussion_topic?: IDiscussionData,
|
|
105
|
+
submissions_download_url: string,
|
|
106
|
+
assignment_group_id: number,
|
|
107
|
+
due_date_required: boolean,
|
|
108
|
+
allowed_extensions: string[],
|
|
109
|
+
max_name_length: number,
|
|
110
|
+
turnitin_enabled?: boolean,
|
|
111
|
+
vericite_enabled?: boolean,
|
|
112
|
+
turnitin_settings?: Record<string, any>,
|
|
113
|
+
grade_group_students_individually: boolean,
|
|
114
|
+
external_tool_tag_attributes?: {
|
|
115
|
+
url: string,
|
|
116
|
+
new_tab: boolean
|
|
117
|
+
},
|
|
118
|
+
peer_reviews: boolean,
|
|
119
|
+
automatic_peer_reviews: boolean,
|
|
120
|
+
peer_review_count?: number,
|
|
121
|
+
peer_reviews_assign_at?: DateString,
|
|
122
|
+
intra_group_peer_reviews: boolean,
|
|
123
|
+
group_category_id?: number,
|
|
124
|
+
needs_grading_count?: number,
|
|
125
|
+
needs_grading_count_by_section?: { section_id: number, needs_grading_count: number }[],
|
|
126
|
+
position: number,
|
|
127
|
+
post_to_sis?: boolean,
|
|
128
|
+
integration_id?: string,
|
|
129
|
+
integration_data?: Record<string, unknown>,
|
|
130
|
+
points_possible: number,
|
|
131
|
+
submission_types: SubmissionType[]
|
|
132
|
+
omit_from_final_grade: boolean,
|
|
133
|
+
hide_in_gradebook: boolean,
|
|
134
|
+
moderated_grading: boolean,
|
|
135
|
+
grader_count: number,
|
|
136
|
+
final_grader_id: number,
|
|
137
|
+
grader_comments_visible_to_graders: boolean,
|
|
138
|
+
graders_anonymous_to_graders: boolean,
|
|
139
|
+
grader_names_visible_to_final_grader: boolean,
|
|
140
|
+
anonymous_grading: boolean,
|
|
141
|
+
|
|
142
|
+
rubric?: IRubricCriterionData[],
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type ContentData = IPageData | IAssignmentData | IQuizData | IDiscussionData
|
|
146
|
+
|
|
147
|
+
export type ContentFuncsOptions<
|
|
148
|
+
GetOptionsType extends IQueryParams,
|
|
149
|
+
GetAllOptionsType extends IQueryParams = GetOptionsType,
|
|
150
|
+
PutDataType extends Record<string, any> = Record<string, any>,
|
|
151
|
+
PostDataType extends Record<string, any> = PutDataType
|
|
152
|
+
> = {
|
|
153
|
+
|
|
154
|
+
defaultGetQuery?: GetOptionsType,
|
|
155
|
+
defaultGetAllQuery?: GetAllOptionsType,
|
|
156
|
+
defaultPutQuery?: PutDataType,
|
|
157
|
+
defaultPostQuery?: PostDataType,
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface IAssignmentGroup extends CanvasData {
|
|
162
|
+
id: number,
|
|
163
|
+
name: string,
|
|
164
|
+
position: number,
|
|
165
|
+
group_weight: number,
|
|
166
|
+
assignments?: IAssignmentData[],
|
|
167
|
+
rules?: IGradingRules[]
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export type AssignmentOverride = {
|
|
171
|
+
id: number,
|
|
172
|
+
assignment_id: number,
|
|
173
|
+
quiz_id?: number,
|
|
174
|
+
context_module_id?: number,
|
|
175
|
+
discussion_topic_id?: number,
|
|
176
|
+
wiki_page_id?: number,
|
|
177
|
+
attachment_id?: number,
|
|
178
|
+
student_ids?: number[],
|
|
179
|
+
group_id?: number,
|
|
180
|
+
course_section_id?: number,
|
|
181
|
+
title: string,
|
|
182
|
+
due_at: string,
|
|
183
|
+
all_day: boolean,
|
|
184
|
+
all_day_date?: DateString,
|
|
185
|
+
unlock_at?: DateString,
|
|
186
|
+
lock_at?: DateString,
|
|
187
|
+
|
|
188
|
+
};
|
|
189
|
+
export type UpdateAssignmentDataOptions = {
|
|
190
|
+
assignment: Partial<Omit<IAssignmentData,
|
|
191
|
+
'id' | 'created_at' | 'has_overrides' | 'all_dates' | 'html_url' |
|
|
192
|
+
'max_name_length' | 'peer_review_count' | 'peer_reviews_assign_at'
|
|
193
|
+
> & {
|
|
194
|
+
sis_assignment_id: string,
|
|
195
|
+
notify_of_update: boolean,
|
|
196
|
+
grading_type: 'pass_fail' | 'percent' | 'letter_grade' | 'gpa_scale' | 'points' | 'not_graded',
|
|
197
|
+
assignment_overrides: AssignmentOverride[],
|
|
198
|
+
only_visible_to_overrides: boolean,
|
|
199
|
+
published: boolean,
|
|
200
|
+
grading_standard_id: number,
|
|
201
|
+
allowed_attempts: number,
|
|
202
|
+
annotatable_attachment_id: number,
|
|
203
|
+
force_updated_at: boolean,
|
|
204
|
+
}>
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface IAssignmentSubmission {
|
|
208
|
+
// The submission's assignment id
|
|
209
|
+
assignment_id: number;
|
|
210
|
+
// The submission's assignment (see the assignments API) (optional)
|
|
211
|
+
assignment?: IAssignmentData | null;
|
|
212
|
+
// The submission's course (see the course API) (optional)
|
|
213
|
+
course?: ICourseData | null;
|
|
214
|
+
// This is the submission attempt number.
|
|
215
|
+
attempt: number;
|
|
216
|
+
// The content of the submission, if it was submitted directly in a text field.
|
|
217
|
+
body: string;
|
|
218
|
+
// The grade for the submission, translated into the assignment grading scheme
|
|
219
|
+
// (so a letter grade, for example).
|
|
220
|
+
grade: string;
|
|
221
|
+
// A boolean flag which is false if the student has re-submitted since the
|
|
222
|
+
// submission was last graded.
|
|
223
|
+
grade_matches_current_submission: boolean;
|
|
224
|
+
// URL to the submission. This will require the user to log in.
|
|
225
|
+
html_url: string;
|
|
226
|
+
// URL to the submission preview. This will require the user to log in.
|
|
227
|
+
preview_url: string;
|
|
228
|
+
// The raw score
|
|
229
|
+
score: number;
|
|
230
|
+
// Associated comments for a submission (optional)
|
|
231
|
+
submission_comments?: unknown | null;
|
|
232
|
+
// The types of submission ex:
|
|
233
|
+
// ('online_text_entry'|'online_url'|'online_upload'|'online_quiz'|'media_record
|
|
234
|
+
// ing'|'student_annotation')
|
|
235
|
+
submission_type: 'online_text_entry' | 'online_url' | 'online_upload' | 'online_quiz' | 'media_recording' | 'student_annotation';
|
|
236
|
+
// The timestamp when the assignment was submitted
|
|
237
|
+
submitted_at: string;
|
|
238
|
+
// The URL of the submission (for 'online_url' submissions).
|
|
239
|
+
url?: string | null;
|
|
240
|
+
// The id of the user who created the submission
|
|
241
|
+
user_id: number;
|
|
242
|
+
// The id of the user who graded the submission. This will be null for
|
|
243
|
+
// submissions that haven't been graded yet. It will be a positive number if a
|
|
244
|
+
// real user has graded the submission and a negative number if the submission
|
|
245
|
+
// was graded by a process (e.g. Quiz autograder and autograding LTI tools).
|
|
246
|
+
// Specifically autograded quizzes set grader_id to the negative of the quiz id.
|
|
247
|
+
// Submissions autograded by LTI tools set grader_id to the negative of the tool
|
|
248
|
+
// id.
|
|
249
|
+
grader_id: number;
|
|
250
|
+
graded_at: string;
|
|
251
|
+
// The submissions user (see user API) (optional)
|
|
252
|
+
user?: unknown | null;
|
|
253
|
+
// Whether the submission was made after the applicable due date
|
|
254
|
+
late: boolean;
|
|
255
|
+
// Whether the assignment is visible to the user who submitted the assignment.
|
|
256
|
+
// Submissions where `assignment_visible` is false no longer count towards the
|
|
257
|
+
// student's grade and the assignment can no longer be accessed by the student.
|
|
258
|
+
// `assignment_visible` becomes false for submissions that do not have a grade
|
|
259
|
+
// and whose assignment is no longer assigned to the student's section.
|
|
260
|
+
assignment_visible: boolean;
|
|
261
|
+
// Whether the assignment is excused. Excused assignments have no impact on a
|
|
262
|
+
// user's grade.
|
|
263
|
+
excused: boolean;
|
|
264
|
+
// Whether the assignment is missing.
|
|
265
|
+
missing: boolean;
|
|
266
|
+
// The status of the submission in relation to the late policy. Can be late,
|
|
267
|
+
// missing, extended, none, or null.
|
|
268
|
+
late_policy_status: 'late' | 'missing' | 'extended' | 'none' | null;
|
|
269
|
+
// The amount of points automatically deducted from the score by the
|
|
270
|
+
// missing/late policy for a late or missing assignment.
|
|
271
|
+
points_deducted: number;
|
|
272
|
+
// The amount of time, in seconds, that an submission is late by.
|
|
273
|
+
seconds_late: number;
|
|
274
|
+
// The current state of the submission
|
|
275
|
+
workflow_state: 'submitted' | 'graded' | 'pending_review';
|
|
276
|
+
// Extra submission attempts allowed for the given user and assignment.
|
|
277
|
+
extra_attempts: number;
|
|
278
|
+
// A unique short ID identifying this submission without reference to the owning
|
|
279
|
+
// user. Only included if the caller has administrator access for the current
|
|
280
|
+
// account.
|
|
281
|
+
anonymous_id: string;
|
|
282
|
+
// The date this submission was posted to the student, or nil if it has not been
|
|
283
|
+
// posted.
|
|
284
|
+
posted_at?: string | null;
|
|
285
|
+
// The read status of this submission for the given user (optional). Including
|
|
286
|
+
// read_status will mark submission(s) as read.
|
|
287
|
+
read_status?: 'read' | 'unread' | null;
|
|
288
|
+
// This indicates whether the submission has been reassigned by the instructor.
|
|
289
|
+
redo_request: boolean;
|
|
290
|
+
rubric_assessment?: RubricAssessment,
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export type AssignmentGroup = {
|
|
294
|
+
id: number,
|
|
295
|
+
name: string,
|
|
296
|
+
position: number,
|
|
297
|
+
group_weight: number,
|
|
298
|
+
sis_source_id?: string,
|
|
299
|
+
integration_data?: Record<string, string>,
|
|
300
|
+
assignments: IAssignmentData[],
|
|
301
|
+
rules: unknown,
|
|
302
|
+
}
|