zdu-student-api 1.1.8 → 1.1.9
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.
|
@@ -76,6 +76,11 @@ export declare class CabinetStudent {
|
|
|
76
76
|
* @returns Об'єкт {@link Data}
|
|
77
77
|
*/
|
|
78
78
|
getData(): Promise<DataStudent>;
|
|
79
|
+
/**
|
|
80
|
+
* Отримати курс студента
|
|
81
|
+
* @returns курс (число) або undefined
|
|
82
|
+
*/
|
|
83
|
+
getCourse(): Promise<number | undefined>;
|
|
79
84
|
/**
|
|
80
85
|
* Отримати оцінки з всіх предметів
|
|
81
86
|
*/
|
|
@@ -130,6 +130,7 @@ export class CabinetStudent {
|
|
|
130
130
|
const data = await getDataStudent(this.sesID, this.sessGUID);
|
|
131
131
|
if (data.ok) {
|
|
132
132
|
this.data = data;
|
|
133
|
+
await this.getCourse();
|
|
133
134
|
}
|
|
134
135
|
return data;
|
|
135
136
|
}
|
|
@@ -137,6 +138,37 @@ export class CabinetStudent {
|
|
|
137
138
|
return { ok: false };
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Отримати курс студента
|
|
143
|
+
* @returns курс (число) або undefined
|
|
144
|
+
*/
|
|
145
|
+
async getCourse() {
|
|
146
|
+
if (!this.data) {
|
|
147
|
+
const data = await this.getData();
|
|
148
|
+
if (!data.ok || !this.data)
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
if (this.data.course)
|
|
152
|
+
return this.data.course;
|
|
153
|
+
if (!this.data.enrollmentDate || !this.data.studyDuration)
|
|
154
|
+
return undefined;
|
|
155
|
+
const [d, m, y] = this.data.enrollmentDate.split('.').map(Number);
|
|
156
|
+
const enrollmentDate = new Date(y, m - 1, d);
|
|
157
|
+
const now = new Date();
|
|
158
|
+
const academicYear = (date) => date.getMonth() >= 7 ? date.getFullYear() : date.getFullYear() - 1;
|
|
159
|
+
const enrollmentYear = academicYear(enrollmentDate);
|
|
160
|
+
const currentYear = academicYear(now);
|
|
161
|
+
let course = currentYear - enrollmentYear + 1;
|
|
162
|
+
const durationYears = parseInt(this.data.studyDuration);
|
|
163
|
+
if (isNaN(durationYears))
|
|
164
|
+
return undefined;
|
|
165
|
+
if (course < 1)
|
|
166
|
+
course = 1;
|
|
167
|
+
if (course > durationYears)
|
|
168
|
+
return durationYears;
|
|
169
|
+
this.data.course = course;
|
|
170
|
+
return course;
|
|
171
|
+
}
|
|
140
172
|
/**
|
|
141
173
|
* Отримати оцінки з всіх предметів
|
|
142
174
|
*/
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* - `phones` — Масив телефонних номерів студента
|
|
26
26
|
*
|
|
27
27
|
* **Дані про навчання:**
|
|
28
|
+
* - `course` — Поточний курс
|
|
28
29
|
* - `faculty` — Факультет
|
|
29
30
|
* - `specialty` — Спеціальність (назва освітньої програми)
|
|
30
31
|
* - `degree` — Ступінь / Освітньо-професійний ступінь (бакалавр, магістр тощо)
|
|
@@ -51,6 +52,7 @@ export interface DataStudent {
|
|
|
51
52
|
middleNameEng?: string;
|
|
52
53
|
email?: string;
|
|
53
54
|
phones?: string[];
|
|
55
|
+
course?: number;
|
|
54
56
|
faculty?: string;
|
|
55
57
|
specialty?: string;
|
|
56
58
|
degree?: string;
|
package/dist/examples.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CabinetStudent, } from './index.js';
|
|
1
2
|
import 'dotenv/config';
|
|
2
3
|
// const schedule = new Schedule();
|
|
3
4
|
// schedule.group = '23Бд-СОінф123'
|
|
@@ -52,12 +53,14 @@ import 'dotenv/config';
|
|
|
52
53
|
// const me = data2.studentScores.find((s) => s.id === data2.studentId)!;
|
|
53
54
|
// const sesID = '';
|
|
54
55
|
// const sessGUID = '';
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const cb = new CabinetStudent(process.env.LOGIN, process.env.PASSWORD);
|
|
57
|
+
await cb.auth();
|
|
57
58
|
// // console.log(cb.sesID, cb.sessGUID);
|
|
58
59
|
// console.log(await cb.setSession(sesID, sessGUID));
|
|
59
60
|
// // console.log(cb.sesID, cb.sessGUID);
|
|
60
61
|
// console.log(await cb.loadData());
|
|
62
|
+
console.log(await cb.getData());
|
|
63
|
+
// console.log(cb.data);
|
|
61
64
|
// await cb.getDisciplines();
|
|
62
65
|
// console.log(await cb.getId());
|
|
63
66
|
// console.log(cb.allScores);
|