mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-25 23:28:33 -06:00
added a lot of canvas data types
This commit is contained in:
3
nextjs/.eslintrc.json
Normal file
3
nextjs/.eslintrc.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
||||
36
nextjs/.gitignore
vendored
Normal file
36
nextjs/.gitignore
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
.yarn/install-state.gz
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
36
nextjs/README.md
Normal file
36
nextjs/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
# or
|
||||
pnpm dev
|
||||
# or
|
||||
bun dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||
|
||||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
4
nextjs/next.config.mjs
Normal file
4
nextjs/next.config.mjs
Normal file
@@ -0,0 +1,4 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {};
|
||||
|
||||
export default nextConfig;
|
||||
7233
nextjs/package-lock.json
generated
Normal file
7233
nextjs/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
31
nextjs/package.json
Normal file
31
nextjs/package.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "canvas-mangement",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "14.2.5",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@testing-library/dom": "^10.4.0",
|
||||
"@testing-library/react": "^16.0.0",
|
||||
"@types/node": "^20",
|
||||
"@types/react": "^18",
|
||||
"@types/react-dom": "^18",
|
||||
"@vitejs/plugin-react": "^4.3.1",
|
||||
"eslint": "^8",
|
||||
"eslint-config-next": "14.2.5",
|
||||
"jsdom": "^24.1.1",
|
||||
"postcss": "^8",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"typescript": "^5",
|
||||
"vitest": "^2.0.5"
|
||||
}
|
||||
}
|
||||
8
nextjs/postcss.config.mjs
Normal file
8
nextjs/postcss.config.mjs
Normal file
@@ -0,0 +1,8 @@
|
||||
/** @type {import('postcss-load-config').Config} */
|
||||
const config = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
1
nextjs/public/next.svg
Normal file
1
nextjs/public/next.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
1
nextjs/public/vercel.svg
Normal file
1
nextjs/public/vercel.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 283 64"><path fill="black" d="M141 16c-11 0-19 7-19 18s9 18 20 18c7 0 13-3 16-7l-7-5c-2 3-6 4-9 4-5 0-9-3-10-7h28v-3c0-11-8-18-19-18zm-9 15c1-4 4-7 9-7s8 3 9 7h-18zm117-15c-11 0-19 7-19 18s9 18 20 18c6 0 12-3 16-7l-8-5c-2 3-5 4-8 4-5 0-9-3-11-7h28l1-3c0-11-8-18-19-18zm-10 15c2-4 5-7 10-7s8 3 9 7h-19zm-39 3c0 6 4 10 10 10 4 0 7-2 9-5l8 5c-3 5-9 8-17 8-11 0-19-7-19-18s8-18 19-18c8 0 14 3 17 8l-8 5c-2-3-5-5-9-5-6 0-10 4-10 10zm83-29v46h-9V5h9zM37 0l37 64H0L37 0zm92 5-27 48L74 5h10l18 30 17-30h10zm59 12v10l-3-1c-6 0-10 4-10 10v15h-9V17h9v9c0-5 6-9 13-9z"/></svg>
|
||||
|
After Width: | Height: | Size: 629 B |
33
nextjs/src/app/globals.css
Normal file
33
nextjs/src/app/globals.css
Normal file
@@ -0,0 +1,33 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--foreground-rgb: 0, 0, 0;
|
||||
--background-start-rgb: 214, 219, 220;
|
||||
--background-end-rgb: 255, 255, 255;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--foreground-rgb: 255, 255, 255;
|
||||
--background-start-rgb: 0, 0, 0;
|
||||
--background-end-rgb: 0, 0, 0;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
color: rgb(var(--foreground-rgb));
|
||||
background: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
rgb(var(--background-end-rgb))
|
||||
)
|
||||
rgb(var(--background-start-rgb));
|
||||
}
|
||||
|
||||
@layer utilities {
|
||||
.text-balance {
|
||||
text-wrap: balance;
|
||||
}
|
||||
}
|
||||
22
nextjs/src/app/layout.tsx
Normal file
22
nextjs/src/app/layout.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Inter } from "next/font/google";
|
||||
import "./globals.css";
|
||||
|
||||
const inter = Inter({ subsets: ["latin"] });
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Create Next App",
|
||||
description: "Generated by create next app",
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body className={inter.className}>{children}</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
9
nextjs/src/app/page.tsx
Normal file
9
nextjs/src/app/page.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import Image from "next/image";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<main className="flex min-h-screen flex-col items-center justify-between p-24">
|
||||
|
||||
</main>
|
||||
);
|
||||
}
|
||||
7
nextjs/src/models/canvas/assignments/CanvasLockInfo.ts
Normal file
7
nextjs/src/models/canvas/assignments/CanvasLockInfo.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export interface CanvasLockInfo {
|
||||
asset_string: string;
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
context_module?: any;
|
||||
manually_locked?: boolean;
|
||||
}
|
||||
82
nextjs/src/models/canvas/assignments/canvasAssignment.ts
Normal file
82
nextjs/src/models/canvas/assignments/canvasAssignment.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { DiscussionTopicModel } from "../discussions/canvasDiscussionModelTopic";
|
||||
import { SubmissionModel } from "../submissions/canvasSubmissionModel";
|
||||
import { CanvasAssignmentDate } from "./canvasAssignmentDate";
|
||||
import { CanvasAssignmentOverride } from "./canvasAssignmentOverride";
|
||||
import { CanvasExternalToolTagAttributes } from "./canvasExternalToolTagAttributes";
|
||||
import { CanvasLockInfo } from "./CanvasLockInfo";
|
||||
import { CanvasRubricCriteria } from "./canvasRubricCriteria";
|
||||
import { CanvasTurnitinSettings } from "./canvasTurnitinSettings";
|
||||
|
||||
export interface CanvasAssignment {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
created_at: string; // ISO 8601 date string
|
||||
has_overrides: boolean;
|
||||
course_id: number;
|
||||
html_url: string;
|
||||
submissions_download_url: string;
|
||||
assignment_group_id: number;
|
||||
due_date_required: boolean;
|
||||
max_name_length: number;
|
||||
peer_reviews: boolean;
|
||||
automatic_peer_reviews: boolean;
|
||||
position: number;
|
||||
grading_type: string;
|
||||
published: boolean;
|
||||
unpublishable: boolean;
|
||||
only_visible_to_overrides: boolean;
|
||||
locked_for_user: boolean;
|
||||
moderated_grading: boolean;
|
||||
grader_count: number;
|
||||
allowed_attempts: number;
|
||||
is_quiz_assignment: boolean;
|
||||
submission_types: string[];
|
||||
updated_at?: string; // ISO 8601 date string
|
||||
due_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
all_dates?: CanvasAssignmentDate[];
|
||||
allowed_extensions?: string[];
|
||||
turnitin_enabled?: boolean;
|
||||
vericite_enabled?: boolean;
|
||||
turnitin_settings?: CanvasTurnitinSettings;
|
||||
grade_group_students_individually?: boolean;
|
||||
external_tool_tag_attributes?: CanvasExternalToolTagAttributes;
|
||||
peer_review_count?: number;
|
||||
peer_reviews_assign_at?: string; // ISO 8601 date string
|
||||
intra_group_peer_reviews?: boolean;
|
||||
group_category_id?: number;
|
||||
needs_grading_count?: number;
|
||||
needs_grading_count_by_section?: {
|
||||
section_id: string;
|
||||
needs_grading_count: number;
|
||||
}[];
|
||||
post_to_sis?: boolean;
|
||||
integration_id?: string;
|
||||
integration_data?: any;
|
||||
muted?: boolean;
|
||||
points_possible?: number;
|
||||
has_submitted_submissions?: boolean;
|
||||
grading_standard_id?: number;
|
||||
lock_info?: CanvasLockInfo;
|
||||
lock_explanation?: string;
|
||||
quiz_id?: number;
|
||||
anonymous_submissions?: boolean;
|
||||
discussion_topic?: DiscussionTopicModel;
|
||||
freeze_on_copy?: boolean;
|
||||
frozen?: boolean;
|
||||
frozen_attributes?: string[];
|
||||
submission?: SubmissionModel;
|
||||
use_rubric_for_grading?: boolean;
|
||||
rubric_settings?: any;
|
||||
rubric?: CanvasRubricCriteria[];
|
||||
assignment_visibility?: number[];
|
||||
overrides?: CanvasAssignmentOverride[];
|
||||
omit_from_final_grade?: boolean;
|
||||
final_grader_id?: number;
|
||||
grader_comments_visible_to_graders?: boolean;
|
||||
graders_anonymous_to_graders?: boolean;
|
||||
grader_names_visible_to_final_grader?: boolean;
|
||||
anonymous_grading?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export interface CanvasAssignmentDate {
|
||||
title: string;
|
||||
id?: number;
|
||||
base?: boolean;
|
||||
due_at?: string; // ISO 8601 date string
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export interface CanvasAssignmentOverride {
|
||||
id: number;
|
||||
assignment_id: number;
|
||||
course_section_id: number;
|
||||
title: string;
|
||||
student_ids?: number[];
|
||||
group_id?: number;
|
||||
due_at?: string; // ISO 8601 date string
|
||||
all_day?: boolean;
|
||||
all_day_date?: string; // ISO 8601 date string
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface CanvasExternalToolTagAttributes {
|
||||
url: string;
|
||||
resource_link_id: string;
|
||||
new_tab?: boolean;
|
||||
}
|
||||
13
nextjs/src/models/canvas/assignments/canvasRubric.ts
Normal file
13
nextjs/src/models/canvas/assignments/canvasRubric.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export interface CanvasRubric {
|
||||
id?: number;
|
||||
title: string;
|
||||
context_id: number;
|
||||
context_type: string;
|
||||
points_possible: number;
|
||||
reusable: boolean;
|
||||
read_only: boolean;
|
||||
hide_score_total?: boolean;
|
||||
// Uncomment and define if needed
|
||||
// data: CanvasRubricCriteria[];
|
||||
// free_form_criterion_comments?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export interface CanvasRubricAssociation {
|
||||
id: number;
|
||||
rubric_id: number;
|
||||
association_id: number;
|
||||
association_type: string;
|
||||
use_for_grading: boolean;
|
||||
summary_data?: string;
|
||||
purpose: string;
|
||||
hide_score_total?: boolean;
|
||||
hide_points: boolean;
|
||||
hide_outcome_results: boolean;
|
||||
}
|
||||
16
nextjs/src/models/canvas/assignments/canvasRubricCriteria.ts
Normal file
16
nextjs/src/models/canvas/assignments/canvasRubricCriteria.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface CanvasRubricCriteria {
|
||||
id: string;
|
||||
description: string;
|
||||
long_description: string;
|
||||
points?: number;
|
||||
learning_outcome_id?: string;
|
||||
vendor_guid?: string;
|
||||
criterion_use_range?: boolean;
|
||||
ratings?: {
|
||||
points: number;
|
||||
id: string;
|
||||
description: string;
|
||||
long_description: string;
|
||||
}[];
|
||||
ignore_for_scoring?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export interface CanvasTurnitinSettings {
|
||||
originality_report_visibility: string;
|
||||
s_paper_check: boolean;
|
||||
internet_check: boolean;
|
||||
journal_check: boolean;
|
||||
exclude_biblio: boolean;
|
||||
exclude_quoted: boolean;
|
||||
exclude_small_matches_type?: boolean;
|
||||
exclude_small_matches_value?: number;
|
||||
}
|
||||
3
nextjs/src/models/canvas/courses/calendarLinkModel.ts
Normal file
3
nextjs/src/models/canvas/courses/calendarLinkModel.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export interface CalendarLinkModel {
|
||||
ics: string;
|
||||
}
|
||||
54
nextjs/src/models/canvas/courses/courseModel.ts
Normal file
54
nextjs/src/models/canvas/courses/courseModel.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { EnrollmentModel } from "../enrollments/enrollmentModel";
|
||||
import { CalendarLinkModel } from "./calendarLinkModel";
|
||||
import { CourseProgressModel } from "./courseProgressModel";
|
||||
import { TermModel } from "./termModel";
|
||||
|
||||
export interface CourseModel {
|
||||
id: number;
|
||||
sis_course_id: string;
|
||||
uuid: string;
|
||||
integration_id: string;
|
||||
name: string;
|
||||
course_code: string;
|
||||
workflow_state: string;
|
||||
account_id: number;
|
||||
root_account_id: number;
|
||||
enrollment_term_id: number;
|
||||
created_at: string; // ISO 8601 date string
|
||||
locale: string;
|
||||
calendar: CalendarLinkModel;
|
||||
default_view: string;
|
||||
syllabus_body: string;
|
||||
permissions: { [key: string]: boolean };
|
||||
storage_quota_mb: number;
|
||||
storage_quota_used_mb: number;
|
||||
license: string;
|
||||
course_format: string;
|
||||
time_zone: string;
|
||||
sis_import_id?: number;
|
||||
grading_standard_id?: number;
|
||||
start_at?: string; // ISO 8601 date string
|
||||
end_at?: string; // ISO 8601 date string
|
||||
enrollments?: EnrollmentModel[];
|
||||
total_students?: number;
|
||||
needs_grading_count?: number;
|
||||
term?: TermModel;
|
||||
course_progress?: CourseProgressModel;
|
||||
apply_assignment_group_weights?: boolean;
|
||||
is_public?: boolean;
|
||||
is_public_to_auth_users?: boolean;
|
||||
public_syllabus?: boolean;
|
||||
public_syllabus_to_auth?: boolean;
|
||||
public_description?: string;
|
||||
hide_final_grades?: boolean;
|
||||
allow_student_assignment_edits?: boolean;
|
||||
allow_wiki_comments?: boolean;
|
||||
allow_student_forum_attachments?: boolean;
|
||||
open_enrollment?: boolean;
|
||||
self_enrollment?: boolean;
|
||||
restrict_enrollments_to_course_dates?: boolean;
|
||||
access_restricted_by_date?: boolean;
|
||||
blueprint?: boolean;
|
||||
blueprint_restrictions?: { [key: string]: boolean };
|
||||
blueprint_restrictions_by_object_type?: { [key: string]: { [key: string]: boolean } };
|
||||
}
|
||||
6
nextjs/src/models/canvas/courses/courseProgressModel.ts
Normal file
6
nextjs/src/models/canvas/courses/courseProgressModel.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface CourseProgressModel {
|
||||
requirement_count?: number;
|
||||
requirement_completed_count?: number;
|
||||
next_requirement_url?: string;
|
||||
completed_at?: string; // ISO 8601 date string
|
||||
}
|
||||
16
nextjs/src/models/canvas/courses/courseSettingsModel.ts
Normal file
16
nextjs/src/models/canvas/courses/courseSettingsModel.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface CourseSettingsModel {
|
||||
allow_final_grade_override: boolean;
|
||||
allow_student_discussion_topics: boolean;
|
||||
allow_student_forum_attachments: boolean;
|
||||
allow_student_discussion_editing: boolean;
|
||||
grading_standard_enabled: boolean;
|
||||
allow_student_organized_groups: boolean;
|
||||
hide_final_grades: boolean;
|
||||
hide_distribution_graphs: boolean;
|
||||
lock_all_announcements: boolean;
|
||||
restrict_student_past_view: boolean;
|
||||
restrict_student_future_view: boolean;
|
||||
show_announcements_on_home_page: boolean;
|
||||
home_page_announcement_limit: number;
|
||||
grading_standard_id?: number;
|
||||
}
|
||||
6
nextjs/src/models/canvas/courses/termModel.ts
Normal file
6
nextjs/src/models/canvas/courses/termModel.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export interface TermModel {
|
||||
id: number;
|
||||
name: string;
|
||||
start_at?: string; // ISO 8601 date string
|
||||
end_at?: string; // ISO 8601 date string
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { UserDisplayModel } from "../users/userDisplayModel";
|
||||
import { FileAttachmentModel } from "./canvasFileAttachmentModel";
|
||||
|
||||
export interface DiscussionTopicModel {
|
||||
id: number;
|
||||
title: string;
|
||||
message: string;
|
||||
html_url: string;
|
||||
read_state: string;
|
||||
subscription_hold: string;
|
||||
assignment_id: number;
|
||||
lock_explanation: string;
|
||||
user_name: string;
|
||||
topic_children: number[];
|
||||
podcast_url: string;
|
||||
discussion_type: string;
|
||||
attachments: FileAttachmentModel[];
|
||||
permissions: { [key: string]: boolean };
|
||||
author: UserDisplayModel;
|
||||
unread_count?: number;
|
||||
subscribed?: boolean;
|
||||
posted_at?: string; // ISO 8601 date string
|
||||
last_reply_at?: string; // ISO 8601 date string
|
||||
require_initial_post?: boolean;
|
||||
user_can_see_posts?: boolean;
|
||||
discussion_subentry_count?: number;
|
||||
delayed_post_at?: string; // ISO 8601 date string
|
||||
published?: boolean;
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
locked?: boolean;
|
||||
pinned?: boolean;
|
||||
locked_for_user?: boolean;
|
||||
lock_info?: any;
|
||||
group_topic_children?: any;
|
||||
root_topic_id?: number;
|
||||
group_category_id?: number;
|
||||
allow_rating?: boolean;
|
||||
only_graders_can_rate?: boolean;
|
||||
sort_by_rating?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export interface FileAttachmentModel {
|
||||
content_type: string;
|
||||
url: string;
|
||||
filename: string;
|
||||
display_name: string;
|
||||
}
|
||||
48
nextjs/src/models/canvas/enrollments/enrollmentModel.ts
Normal file
48
nextjs/src/models/canvas/enrollments/enrollmentModel.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { UserDisplayModel } from "../users/userDisplayModel";
|
||||
import { GradeModel } from "./gradeModel";
|
||||
|
||||
export interface EnrollmentModel {
|
||||
id: number;
|
||||
course_id: number;
|
||||
enrollment_state: string;
|
||||
type: string;
|
||||
user_id: number;
|
||||
role: string;
|
||||
role_id: number;
|
||||
html_url: string;
|
||||
grades: GradeModel;
|
||||
user: UserDisplayModel;
|
||||
override_grade: string;
|
||||
sis_course_id?: string;
|
||||
course_integration_id?: string;
|
||||
course_section_id?: number;
|
||||
section_integration_id?: string;
|
||||
sis_account_id?: string;
|
||||
sis_section_id?: string;
|
||||
sis_user_id?: string;
|
||||
limit_privileges_to_course_section?: boolean;
|
||||
sis_import_id?: number;
|
||||
root_account_id?: number;
|
||||
associated_user_id?: number;
|
||||
created_at?: string; // ISO 8601 date string
|
||||
updated_at?: string; // ISO 8601 date string
|
||||
start_at?: string; // ISO 8601 date string
|
||||
end_at?: string; // ISO 8601 date string
|
||||
last_activity_at?: string; // ISO 8601 date string
|
||||
last_attended_at?: string; // ISO 8601 date string
|
||||
total_activity_time?: number;
|
||||
override_score?: number;
|
||||
unposted_current_grade?: string;
|
||||
unposted_final_grade?: string;
|
||||
unposted_current_score?: string;
|
||||
unposted_final_score?: string;
|
||||
has_grading_periods?: boolean;
|
||||
totals_for_all_grading_periods_option?: boolean;
|
||||
current_grading_period_title?: string;
|
||||
current_grading_period_id?: number;
|
||||
current_period_override_grade?: string;
|
||||
current_period_override_score?: number;
|
||||
current_period_unposted_final_score?: number;
|
||||
current_period_unposted_current_grade?: string;
|
||||
current_period_unposted_final_grade?: string;
|
||||
}
|
||||
11
nextjs/src/models/canvas/enrollments/gradeModel.ts
Normal file
11
nextjs/src/models/canvas/enrollments/gradeModel.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export interface GradeModel {
|
||||
html_url?: string;
|
||||
current_grade?: number;
|
||||
final_grade?: number;
|
||||
current_score?: number;
|
||||
final_score?: number;
|
||||
unposted_current_grade?: number;
|
||||
unposted_final_grade?: number;
|
||||
unposted_current_score?: number;
|
||||
unposted_final_score?: number;
|
||||
}
|
||||
18
nextjs/src/models/canvas/modules/canvasModule.ts
Normal file
18
nextjs/src/models/canvas/modules/canvasModule.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { CanvasModuleItem } from "./canvasModuleItems";
|
||||
|
||||
export interface CanvasModule {
|
||||
id: number;
|
||||
workflow_state: string;
|
||||
position: number;
|
||||
name: string;
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
require_sequential_progress?: boolean;
|
||||
prerequisite_module_ids?: number[];
|
||||
items_count: number;
|
||||
items_url: string;
|
||||
items?: CanvasModuleItem[];
|
||||
state?: string;
|
||||
completed_at?: string; // ISO 8601 date string
|
||||
publish_final_grade?: boolean;
|
||||
published?: boolean;
|
||||
}
|
||||
28
nextjs/src/models/canvas/modules/canvasModuleItems.ts
Normal file
28
nextjs/src/models/canvas/modules/canvasModuleItems.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
export interface CanvasModuleItem {
|
||||
id: number;
|
||||
module_id: number;
|
||||
position: number;
|
||||
title: string;
|
||||
indent?: number;
|
||||
type: string;
|
||||
content_id?: number;
|
||||
html_url: string;
|
||||
url?: string;
|
||||
page_url?: string;
|
||||
external_url?: string;
|
||||
new_tab: boolean;
|
||||
completion_requirement?: {
|
||||
type: string;
|
||||
min_score?: number;
|
||||
completed?: boolean;
|
||||
};
|
||||
published?: boolean;
|
||||
content_details?: CanvasModuleItemContentDetails;
|
||||
}
|
||||
|
||||
export interface CanvasModuleItemContentDetails {
|
||||
due_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
points_possible: number;
|
||||
locked_for_user: boolean;
|
||||
}
|
||||
16
nextjs/src/models/canvas/pages/canvasPageModel.ts
Normal file
16
nextjs/src/models/canvas/pages/canvasPageModel.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
export interface CanvasPage {
|
||||
page_id: number;
|
||||
url: string;
|
||||
title: string;
|
||||
published: boolean;
|
||||
front_page: boolean;
|
||||
body?: string;
|
||||
// Uncomment and define if needed
|
||||
// created_at: string; // ISO 8601 date string
|
||||
// updated_at: string; // ISO 8601 date string
|
||||
// editing_roles: string;
|
||||
// last_edited_by: UserDisplayModel;
|
||||
// locked_for_user: boolean;
|
||||
// lock_info?: LockInfoModel;
|
||||
// lock_explanation?: string;
|
||||
}
|
||||
44
nextjs/src/models/canvas/quizzes/canvasQuizModel.ts
Normal file
44
nextjs/src/models/canvas/quizzes/canvasQuizModel.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { CanvasLockInfo } from "../assignments/CanvasLockInfo";
|
||||
import { CanvasQuizPermissions } from "./canvasQuizPermission";
|
||||
|
||||
export interface CanvasQuiz {
|
||||
id: number;
|
||||
title: string;
|
||||
html_url: string;
|
||||
mobile_url: string;
|
||||
preview_url?: string;
|
||||
description: string;
|
||||
quiz_type: string;
|
||||
assignment_group_id?: number;
|
||||
time_limit?: number;
|
||||
shuffle_answers?: boolean;
|
||||
hide_results?: string;
|
||||
show_correct_answers?: boolean;
|
||||
show_correct_answers_last_attempt?: boolean;
|
||||
show_correct_answers_at?: string; // ISO 8601 date string
|
||||
hide_correct_answers_at?: string; // ISO 8601 date string
|
||||
one_time_results?: boolean;
|
||||
scoring_policy?: string;
|
||||
allowed_attempts: number;
|
||||
one_question_at_a_time?: boolean;
|
||||
question_count?: number;
|
||||
points_possible?: number;
|
||||
cant_go_back?: boolean;
|
||||
access_code?: string;
|
||||
ip_filter?: string;
|
||||
due_at?: string; // ISO 8601 date string
|
||||
lock_at?: string; // ISO 8601 date string
|
||||
unlock_at?: string; // ISO 8601 date string
|
||||
published?: boolean;
|
||||
unpublishable?: boolean;
|
||||
locked_for_user?: boolean;
|
||||
lock_info?: CanvasLockInfo;
|
||||
lock_explanation?: string;
|
||||
speedgrader_url?: string;
|
||||
quiz_extensions_url?: string;
|
||||
permissions: CanvasQuizPermissions;
|
||||
all_dates?: any; // Depending on the structure of the dates, this could be further specified
|
||||
version_number?: number;
|
||||
question_types?: string[];
|
||||
anonymous_submissions?: boolean;
|
||||
}
|
||||
9
nextjs/src/models/canvas/quizzes/canvasQuizPermission.ts
Normal file
9
nextjs/src/models/canvas/quizzes/canvasQuizPermission.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface CanvasQuizPermissions {
|
||||
read: boolean;
|
||||
submit: boolean;
|
||||
create: boolean;
|
||||
manage: boolean;
|
||||
read_statistics: boolean;
|
||||
review_grades: boolean;
|
||||
update: boolean;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { CanvasAssignment } from "../assignments/canvasAssignment";
|
||||
import { CourseModel } from "../courses/courseModel";
|
||||
import { UserModel } from "../users/canvasUserModel";
|
||||
import { UserDisplayModel } from "../users/userDisplayModel";
|
||||
|
||||
export interface SubmissionModel {
|
||||
assignment_id: number;
|
||||
grade: string;
|
||||
html_url: string;
|
||||
preview_url: string;
|
||||
submission_type: string;
|
||||
user_id: number;
|
||||
user: UserModel;
|
||||
workflow_state: string;
|
||||
late_policy_status: string;
|
||||
assignment?: CanvasAssignment;
|
||||
course?: CourseModel;
|
||||
attempt?: number;
|
||||
body?: string;
|
||||
grade_matches_current_submission?: boolean;
|
||||
score?: number;
|
||||
submission_comments?: {
|
||||
id: number;
|
||||
author_id: number;
|
||||
author_name: string;
|
||||
author: UserDisplayModel;
|
||||
comment: string;
|
||||
created_at: string; // ISO 8601 date string
|
||||
edited_at?: string; // ISO 8601 date string
|
||||
media_comment?: {
|
||||
content_type: string;
|
||||
display_name: string;
|
||||
media_id: string;
|
||||
media_type: string;
|
||||
url: string;
|
||||
};
|
||||
}[];
|
||||
submitted_at?: string; // ISO 8601 date string
|
||||
url?: string;
|
||||
grader_id?: number;
|
||||
graded_at?: string; // ISO 8601 date string
|
||||
late?: boolean;
|
||||
assignment_visible?: boolean;
|
||||
excused?: boolean;
|
||||
missing?: boolean;
|
||||
points_deducted?: number;
|
||||
seconds_late?: number;
|
||||
extra_attempts?: number;
|
||||
anonymous_id?: string;
|
||||
}
|
||||
21
nextjs/src/models/canvas/users/canvasUserModel.ts
Normal file
21
nextjs/src/models/canvas/users/canvasUserModel.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { EnrollmentModel } from "../enrollments/enrollmentModel";
|
||||
|
||||
export interface UserModel {
|
||||
id: number;
|
||||
name: string;
|
||||
sortable_name: string;
|
||||
short_name: string;
|
||||
sis_user_id: string;
|
||||
integration_id: string;
|
||||
login_id: string;
|
||||
avatar_url: string;
|
||||
enrollments: EnrollmentModel[];
|
||||
email: string;
|
||||
locale: string;
|
||||
effective_locale: string;
|
||||
time_zone: string;
|
||||
bio: string;
|
||||
permissions: { [key: string]: boolean };
|
||||
sis_import_id?: number;
|
||||
last_login?: string; // ISO 8601 date string
|
||||
}
|
||||
9
nextjs/src/models/canvas/users/userDisplayModel.ts
Normal file
9
nextjs/src/models/canvas/users/userDisplayModel.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export interface UserDisplayModel {
|
||||
avatar_image_url: string;
|
||||
html_url: string;
|
||||
anonymous_id: string;
|
||||
id?: number;
|
||||
short_name?: string;
|
||||
display_name?: string;
|
||||
pronouns?: string;
|
||||
}
|
||||
199
nextjs/src/services/canvas/requestUtils.ts
Normal file
199
nextjs/src/services/canvas/requestUtils.ts
Normal file
@@ -0,0 +1,199 @@
|
||||
|
||||
type FetchOptions = Omit<RequestInit, "method">;
|
||||
|
||||
const token = process.env.CANVAS_TOKEN;
|
||||
if (!token) {
|
||||
throw new Error("CANVAS_TOKEN not in environment");
|
||||
}
|
||||
|
||||
const baseUrl = `${process.env.CANVAS_URL}/api/v1/`;
|
||||
const rateLimitRetryCount = 6;
|
||||
const rateLimitSleepInterval = 1000;
|
||||
|
||||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
const isRateLimited = async (response: Response): Promise<boolean> => {
|
||||
const content = await response.text();
|
||||
return (
|
||||
response.status === 403 &&
|
||||
content.includes("403 Forbidden (Rate Limit Exceeded)")
|
||||
);
|
||||
};
|
||||
|
||||
const deserialize = async <T>(response: Response): Promise<T | null> => {
|
||||
if (!response.ok) {
|
||||
console.error(`Error with response to ${response.url} ${response.status}`);
|
||||
throw new Error(
|
||||
`Error with response to ${response.url} ${response.status}`
|
||||
);
|
||||
}
|
||||
try {
|
||||
return (await response.json()) as T;
|
||||
} catch (e) {
|
||||
console.error(`An error occurred during deserialization: ${e}`);
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
const rateLimitAwarePostAsync = async (
|
||||
url: string,
|
||||
options: FetchOptions,
|
||||
retryCount = 0
|
||||
): Promise<Response> => {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "POST",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (await isRateLimited(response)) {
|
||||
if (retryCount < rateLimitRetryCount) {
|
||||
console.info(
|
||||
`Hit rate limit on post, retry count is ${retryCount} / ${rateLimitRetryCount}, retrying`
|
||||
);
|
||||
await sleep(rateLimitSleepInterval);
|
||||
return await rateLimitAwarePostAsync(url, options, retryCount + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const content = await response.text();
|
||||
console.error(`Error with response, response content: ${content}`);
|
||||
throw new Error(
|
||||
`Error post response, retrycount: ${retryCount}, ratelimited: ${await isRateLimited(
|
||||
response
|
||||
)}, code: ${response.status}, response content: ${content}`
|
||||
);
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
const recursiveDeleteAsync = async (
|
||||
url: string,
|
||||
options: FetchOptions,
|
||||
retryCount = 0
|
||||
): Promise<Response> => {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (await isRateLimited(response)) {
|
||||
console.info("After delete response in rate limited");
|
||||
await sleep(rateLimitSleepInterval);
|
||||
return await recursiveDeleteAsync(url, options, retryCount + 1);
|
||||
}
|
||||
|
||||
return response;
|
||||
} catch (e) {
|
||||
const error = e as Error & { response?: Response };
|
||||
if (error.response?.status === 403) {
|
||||
if (retryCount < rateLimitRetryCount) {
|
||||
console.info(
|
||||
`Hit rate limit in delete, retry count is ${retryCount} / ${rateLimitRetryCount}, retrying`
|
||||
);
|
||||
await sleep(rateLimitSleepInterval);
|
||||
return await recursiveDeleteAsync(url, options, retryCount + 1);
|
||||
} else {
|
||||
console.info(
|
||||
`Hit rate limit in delete, ${rateLimitRetryCount} retries did not fix it`
|
||||
);
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
export const WebRequestor = {
|
||||
getManyAsync: async <T>(
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<[T[] | null, Response]> => {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "GET",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return [await deserialize<T[]>(response), response];
|
||||
},
|
||||
|
||||
getAsync: async <T>(
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<[T | null, Response]> => {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "GET",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return [await deserialize<T>(response), response];
|
||||
},
|
||||
|
||||
postAsync: async (
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<Response> => {
|
||||
return await rateLimitAwarePostAsync(url, options);
|
||||
},
|
||||
|
||||
postAsyncWithDeserialize: async <T>(
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<[T | null, Response]> => {
|
||||
const response = await rateLimitAwarePostAsync(url, options);
|
||||
return [await deserialize<T>(response), response];
|
||||
},
|
||||
|
||||
putAsync: async (
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<Response> => {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "PUT",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return response;
|
||||
},
|
||||
|
||||
putAsyncWithDeserialize: async <T>(
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<[T | null, Response]> => {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
method: "PUT",
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
return [await deserialize<T>(response), response];
|
||||
},
|
||||
|
||||
deleteAsync: async (
|
||||
url: string,
|
||||
options: FetchOptions = {}
|
||||
): Promise<Response> => {
|
||||
return await recursiveDeleteAsync(url, options);
|
||||
},
|
||||
};
|
||||
20
nextjs/tailwind.config.ts
Normal file
20
nextjs/tailwind.config.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { Config } from "tailwindcss";
|
||||
|
||||
const config: Config = {
|
||||
content: [
|
||||
"./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
backgroundImage: {
|
||||
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
|
||||
"gradient-conic":
|
||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
export default config;
|
||||
26
nextjs/tsconfig.json
Normal file
26
nextjs/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Reference in New Issue
Block a user