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
8 changes: 8 additions & 0 deletions examples/course/deleteCourse.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { codio, auth } = require('../auth.js')

async function main() {
await auth
await codio.course.createCourse({id: "your course id", removeOutdatedStudents: false})
}

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.0",
"description": "JS client to Codio API",
"repository": {
"type": "git",
Expand Down
20 changes: 20 additions & 0 deletions 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${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
Loading