Skip to content

Commit 437d0b1

Browse files
examples
1 parent 58981b8 commit 437d0b1

5 files changed

Lines changed: 61 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { codio, auth } = require('../auth.js')
2+
const { courseId, assignmentData } = require('../data.js')
3+
4+
async function main() {
5+
await auth
6+
7+
const result = await codio.assignment.createAssignment(courseId, assignmentData)
8+
console.log(result)
9+
}
10+
11+
main()

examples/course/createCourse.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { codio, auth } = require('../auth.js')
2+
const { courseData } = require('../data.js')
3+
4+
async function main() {
5+
await auth
6+
7+
const result = await codio.course.createCourse(courseData)
8+
console.log(result)
9+
}
10+
11+
main()

examples/course/createModule.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const { codio, auth } = require('../auth.js')
2+
const { courseId, moduleName } = require('../data.js')
3+
4+
async function main() {
5+
await auth
6+
7+
const result = await codio.course.createModule(courseId, moduleName)
8+
console.log(result)
9+
}
10+
11+
main()

examples/data.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,31 @@ const leanersMapping = [
2121
]
2222
}
2323
]
24+
const moduleName = "New Module Name"
25+
const courseData = {
26+
name: "Introduction to Programming",
27+
description: "This course covers the basics of programming.",
28+
start: "2024-08-29T09:32:55Z",
29+
end: "2027-09-25T09:12:00Z",
30+
timezone: "America/New_York",
31+
tags: [
32+
"programming",
33+
"beginner"
34+
]
35+
}
36+
const assignmentData = {
37+
unitId: "yout unit id",
38+
settings: {
39+
name: "My First Assignment",
40+
description: "This assignment covers the basics of programming.",
41+
gigaboxSlot: {
42+
boxType: "standard"
43+
}
44+
},
45+
projectSource: {
46+
type: "starterPack",
47+
id: "11000000-0000-0000-0000-000000000000"
48+
}
49+
}
2450

25-
module.exports = { courseId, courseName, assignmentId, studentId, studentEmail, studentLogin, libraryId, libraryName, projectPath, stackId, stackVersionId, archivePath, yamlMapDir, courseIdToArchive, leanersMapping }
51+
module.exports = { courseId, courseName, assignmentId, studentId, studentEmail, studentLogin, libraryId, libraryName, projectPath, stackId, stackVersionId, archivePath, yamlMapDir, courseIdToArchive, leanersMapping, moduleName, courseData, assignmentData }

src/lib/assignment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ export type AssignmentData = {
470470
| { type: 'import', stackVersionId: string, source: object }
471471
}
472472

473-
export async function createAssignment(courseId: string, assignmentData: any): Promise<string> {
473+
export async function createAssignment(courseId: string, assignmentData: AssignmentData): Promise<string> {
474474
const api = bent(getApiV1Url(), 'POST', 'json', 200)
475475
try {
476476
const res = await api(`/courses/${courseId}/assignments`, assignmentData, getBearer())

0 commit comments

Comments
 (0)