richie-education 2.25.0-b2.dev130 → 2.25.0-b2.dev131
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/js/api/lms/dummy.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AuthenticationBackend, LMSBackend } from 'types/commonDataProps';
|
|
|
2
2
|
import { Maybe, Nullable } from 'types/utils';
|
|
3
3
|
import { User } from 'types/User';
|
|
4
4
|
import { APILms } from 'types/api';
|
|
5
|
-
import {
|
|
5
|
+
import { UnknownEnrollment, OpenEdXEnrollment } from 'types';
|
|
6
6
|
import { location } from 'utils/indirection/window';
|
|
7
7
|
import { CURRENT_JOANIE_DEV_DEMO_USER, RICHIE_USER_TOKEN } from 'settings';
|
|
8
8
|
import { base64Decode } from 'utils/base64Parser';
|
|
@@ -139,7 +139,7 @@ const API = (APIConf: LMSBackend | AuthenticationBackend): APILms => {
|
|
|
139
139
|
}
|
|
140
140
|
resolve(null);
|
|
141
141
|
}),
|
|
142
|
-
isEnrolled: async (enrollment: Maybe<Nullable<
|
|
142
|
+
isEnrolled: async (enrollment: Maybe<Nullable<UnknownEnrollment>>) =>
|
|
143
143
|
new Promise((resolve) => resolve(!!(enrollment as OpenEdXEnrollment)?.is_active)),
|
|
144
144
|
set: (url: string, user: User): Promise<boolean> =>
|
|
145
145
|
new Promise((resolve) => {
|
|
@@ -7,7 +7,7 @@ import { APILms, APIOptions } from 'types/api';
|
|
|
7
7
|
import { location } from 'utils/indirection/window';
|
|
8
8
|
import { handle } from 'utils/errors/handle';
|
|
9
9
|
import { EDX_CSRF_TOKEN_COOKIE_NAME } from 'settings';
|
|
10
|
-
import {
|
|
10
|
+
import { UnknownEnrollment, OpenEdXEnrollment } from 'types';
|
|
11
11
|
import { HttpError, HttpStatusCode } from 'utils/errors/HttpError';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -88,7 +88,7 @@ const API = (APIConf: AuthenticationBackend | LMSBackend, options?: APIOptions):
|
|
|
88
88
|
throw new HttpError(response.status, response.statusText);
|
|
89
89
|
});
|
|
90
90
|
},
|
|
91
|
-
isEnrolled: async (enrollment: Maybe<Nullable<
|
|
91
|
+
isEnrolled: async (enrollment: Maybe<Nullable<UnknownEnrollment>>) => {
|
|
92
92
|
return new Promise((resolve) => resolve(!!(enrollment as OpenEdXEnrollment)?.is_active));
|
|
93
93
|
},
|
|
94
94
|
set: async (url: string, user: User): Promise<boolean> => {
|
package/js/types/api.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Maybe, Nullable } from 'types/utils';
|
|
2
2
|
import { User } from 'types/User';
|
|
3
|
-
import {
|
|
3
|
+
import { UnknownEnrollment } from 'types';
|
|
4
4
|
|
|
5
5
|
export interface APIListRequestParams {
|
|
6
6
|
[key: string]: Maybe<string | string[]>;
|
|
@@ -23,12 +23,12 @@ export interface APIAuthentication {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface APIEnrollment {
|
|
26
|
-
get(url: string, user: Nullable<User>): Promise<Nullable<
|
|
27
|
-
isEnrolled(enrollment: Maybe<Nullable<
|
|
26
|
+
get(url: string, user: Nullable<User>): Promise<Nullable<UnknownEnrollment>>;
|
|
27
|
+
isEnrolled(enrollment: Maybe<Nullable<UnknownEnrollment>>): Promise<Maybe<boolean>>;
|
|
28
28
|
set(
|
|
29
29
|
url: string,
|
|
30
30
|
user: User,
|
|
31
|
-
enrollment?: Maybe<Nullable<
|
|
31
|
+
enrollment?: Maybe<Nullable<UnknownEnrollment>>,
|
|
32
32
|
isActive?: boolean,
|
|
33
33
|
): Promise<boolean>;
|
|
34
34
|
meta?: {
|
package/js/types/index.ts
CHANGED
|
@@ -69,5 +69,4 @@ export interface OpenEdXEnrollment {
|
|
|
69
69
|
* Use an unknown type to make sure we do not depend on any LMS-specific fields
|
|
70
70
|
* on enrollment objects, just use HTTP response codes.
|
|
71
71
|
*/
|
|
72
|
-
|
|
73
|
-
export type Enrollment = unknown;
|
|
72
|
+
export type UnknownEnrollment = unknown;
|
|
@@ -2,14 +2,7 @@ import { faker } from '@faker-js/faker';
|
|
|
2
2
|
import { User } from 'types/User';
|
|
3
3
|
import { APIBackend } from 'types/api';
|
|
4
4
|
import { CommonDataProps } from 'types/commonDataProps';
|
|
5
|
-
import {
|
|
6
|
-
CourseRun,
|
|
7
|
-
CourseRunDisplayMode,
|
|
8
|
-
CourseState,
|
|
9
|
-
CourseStateTextEnum,
|
|
10
|
-
Enrollment,
|
|
11
|
-
Priority,
|
|
12
|
-
} from 'types';
|
|
5
|
+
import { CourseRun, CourseRunDisplayMode, CourseState, CourseStateTextEnum, Priority } from 'types';
|
|
13
6
|
import { Course } from 'types/Course';
|
|
14
7
|
import { FactoryHelper } from 'utils/test/factories/helper';
|
|
15
8
|
import { factory } from './factories';
|
|
@@ -142,15 +135,6 @@ export const CourseRunFactoryFromPriority = (priority: Priority) => {
|
|
|
142
135
|
});
|
|
143
136
|
};
|
|
144
137
|
|
|
145
|
-
export const EnrollmentFactory = factory<Enrollment>(() => {
|
|
146
|
-
return {
|
|
147
|
-
id: faker.string.uuid(),
|
|
148
|
-
created_at: faker.date.past().toISOString(),
|
|
149
|
-
user: faker.string.uuid(),
|
|
150
|
-
course_run: faker.string.uuid(),
|
|
151
|
-
};
|
|
152
|
-
});
|
|
153
|
-
|
|
154
138
|
export const UserFactory = factory<User>(() => ({
|
|
155
139
|
access_token: faker.lorem.word(12),
|
|
156
140
|
full_name: faker.person.fullName(),
|