Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ API keys.
- zstd

## How to build
- Run `yarn`
- Run `yarn build`
- Run `npm install`
- Run `npm run build`


## Authentication
Expand Down Expand Up @@ -525,6 +525,12 @@ Returns `Date` of archivation
await codio.course.archive(<courseId>)
```

#### Delete course

```
await codio.course.deleteCourse({id: <courseId>, removeOutdatedStudents: <boolean>})
```

#### Filter Learners For Mentors

Specify mentors for LTI-base course
Expand Down
13 changes: 13 additions & 0 deletions examples/course/deleteCourse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { codio, auth } = require('../auth.js')

async function main() {
await auth
try {
await codio.course.deleteCourse({id: "your course id", removeOutdatedStudents: false})
console.log("Course deleted successfully.")
} catch (error) {
console.error("Error deleting course:", error)
}
}

main()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codio-api-js",
"version": "0.18.0",
"version": "0.19.1",
"description": "JS client to Codio API",
"repository": {
"type": "git",
Expand Down
23 changes: 22 additions & 1 deletion src/lib/course.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,26 @@ export async function createModule(courseId: string, moduleName: string): Promis
}
}

export type DeleteCourseRequest = {
id: string,
removeOutdatedStudents?: boolean
}

export async function deleteCourse(data: DeleteCourseRequest): Promise<void> {
const api = bent(getApiV1Url(), 'DELETE', 'json', 200)
try {
const paramString = data.removeOutdatedStudents ? `?removeOutdatedStudents=${data.removeOutdatedStudents}` : ''
await api(`/courses/${data.id}${paramString}`, data, getBearer())
return
} catch (error: any) {
if (error.json) {
const message = JSON.stringify(await error.json())
throw new Error(message)
}
throw error
}
}

export async function addTeacher(courseId: string, userId: string, readOnly = false): Promise<boolean> {
const api = bent(getApiV1Url(), 'POST', 'json', 200)
try {
Expand Down Expand Up @@ -685,7 +705,8 @@ const course = {
filterLearnersForMentors,
createCourse,
createModule,
addTeacher
addTeacher,
deleteCourse
}

export default course
Loading