hischool.js 0.0.48 → 0.0.49
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/lib/cjs/api/params.d.ts +12 -1
- package/lib/cjs/api/params.d.ts.map +1 -1
- package/lib/cjs/api/params.js +5 -3
- package/lib/cjs/api/routes.d.ts +8 -8
- package/lib/cjs/api/routes.d.ts.map +1 -1
- package/lib/cjs/api/schema.d.ts +1 -1
- package/lib/cjs/api/schema.d.ts.map +1 -1
- package/lib/cjs/classes/Course.d.ts +7 -2
- package/lib/cjs/classes/Course.d.ts.map +1 -1
- package/lib/cjs/classes/Course.js +12 -1
- package/lib/cjs/classes/CourseLearner.js +1 -1
- package/lib/cjs/hydration/course.d.ts +1 -1
- package/lib/cjs/hydration/course.d.ts.map +1 -1
- package/lib/cjs/hydration/course.js +5 -2
- package/lib/esm/api/params.d.ts +12 -1
- package/lib/esm/api/params.d.ts.map +1 -1
- package/lib/esm/api/params.js +5 -3
- package/lib/esm/api/routes.d.ts +8 -8
- package/lib/esm/api/routes.d.ts.map +1 -1
- package/lib/esm/api/schema.d.ts +1 -1
- package/lib/esm/api/schema.d.ts.map +1 -1
- package/lib/esm/classes/Course.d.ts +7 -2
- package/lib/esm/classes/Course.d.ts.map +1 -1
- package/lib/esm/classes/Course.js +10 -1
- package/lib/esm/classes/CourseLearner.js +1 -1
- package/lib/esm/hydration/course.d.ts +1 -1
- package/lib/esm/hydration/course.d.ts.map +1 -1
- package/lib/esm/hydration/course.js +5 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Course.d.ts","sourceRoot":"","sources":["../../../src/classes/Course.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuB,cAAc,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Course.d.ts","sourceRoot":"","sources":["../../../src/classes/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ject(this.id).lessons;
|
|
95
95
|
}
|
|
96
96
|
get lessons() {
|
|
97
|
-
return this.
|
|
97
|
+
return [...this.#collection.getUnderlyingObject(this.id).lessons.values()]
|
|
98
|
+
.map((id) => this.#collection.client.courseLessons.get(id))
|
|
99
|
+
.filter((x) => x);
|
|
98
100
|
}
|
|
99
101
|
/* ------------------------------------------------------------------ */
|
|
100
102
|
/* PRICING */
|
|
@@ -120,6 +122,13 @@ export class Course {
|
|
|
120
122
|
/* ------------------------------------------------------------------ */
|
|
121
123
|
/* API ACTIONS */
|
|
122
124
|
/* ------------------------------------------------------------------ */
|
|
125
|
+
/**
|
|
126
|
+
* Create lesson in this course
|
|
127
|
+
*/
|
|
128
|
+
async createLesson(data) {
|
|
129
|
+
const lesson = await this.#collection.client.api.post(`/courses/${this.id}/lessons`, data);
|
|
130
|
+
return this.#collection.client.courseLessons.getOrCreate(lesson._id, lesson);
|
|
131
|
+
}
|
|
123
132
|
/**
|
|
124
133
|
* Edit this course
|
|
125
134
|
*/
|
|
@@ -35,7 +35,7 @@ export class CourseLearner {
|
|
|
35
35
|
}
|
|
36
36
|
/* ---------------- PROGRESS ---------------- */
|
|
37
37
|
get progress() {
|
|
38
|
-
const total = this.#collection.client.courses.get(this.id)?.lessonIds?.
|
|
38
|
+
const total = this.#collection.client.courses.get(this.id)?.lessonIds?.size ?? 0;
|
|
39
39
|
if (!total)
|
|
40
40
|
return 0;
|
|
41
41
|
return Math.round((this.completedLessonIds.length / total) * 100);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"course.d.ts","sourceRoot":"","sources":["../../../src/hydration/course.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAU,IAAI,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,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MAAM,CAAC,CAAC;IAC7B,IAAI,EAAE,MAAM,EAAE,CAAC;IAEf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAE/B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,cAAc,CAgCrE,CAAC"}
|
|
@@ -21,12 +21,15 @@ export const courseHydration = {
|
|
|
21
21
|
price: (course) => course.price,
|
|
22
22
|
currency: (course) => course.currency,
|
|
23
23
|
sections: (course) => course.section?.map((s) => s.id) || [],
|
|
24
|
-
lessons: (course) => course.lessons,
|
|
24
|
+
lessons: (course) => new ReactiveSet(course.lessons),
|
|
25
25
|
tags: (course) => course.tags || [],
|
|
26
26
|
ownerId: (course) => course.owner,
|
|
27
27
|
schoolId: (course) => course.school,
|
|
28
28
|
authorIds: (course) => new ReactiveSet(course.authors),
|
|
29
29
|
published: (course) => course.published || false,
|
|
30
30
|
},
|
|
31
|
-
initialHydration: () => ({
|
|
31
|
+
initialHydration: () => ({
|
|
32
|
+
lessons: new ReactiveSet(),
|
|
33
|
+
authorIds: new ReactiveSet(),
|
|
34
|
+
}),
|
|
32
35
|
};
|