zdu-student-api 1.1.7 → 1.1.8

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.
@@ -146,10 +146,14 @@ export class CabinetStudent {
146
146
  if (!this.disciplines?.length)
147
147
  return [];
148
148
  const targetSemester = semester ?? this.semester;
149
+ const allScores = [];
149
150
  try {
150
- const scorePromises = this.disciplines.map((discipline) => getScores(this.sesID, this.sessGUID, discipline.prId, targetSemester));
151
- const results = await Promise.all(scorePromises);
152
- const allScores = results.filter((scores) => scores.ok);
151
+ for (const discipline of this.disciplines) {
152
+ const scores = await getScores(this.sesID, this.sessGUID, discipline.prId, targetSemester);
153
+ if (scores.ok) {
154
+ allScores.push(scores);
155
+ }
156
+ }
153
157
  this.allScores = allScores;
154
158
  return allScores;
155
159
  }
@@ -1,6 +1,6 @@
1
1
  import { Scores } from './types.js';
2
2
  /**
3
- * Отримати оцінки пвибраного предмета студента
3
+ * Отримати оцінки вибраного предмета студента
4
4
  * @category CabinetStudent
5
5
  * @param sesId - ID сесії користувача
6
6
  * @param sessGUID - GUID сесії з cookie
@@ -2,7 +2,7 @@ import fetch from 'cross-fetch';
2
2
  import iconv from 'iconv-lite';
3
3
  import { generateCookieString, isLoginPage } from '../cabinet/session.js';
4
4
  /**
5
- * Отримати оцінки пвибраного предмета студента
5
+ * Отримати оцінки вибраного предмета студента
6
6
  * @category CabinetStudent
7
7
  * @param sesId - ID сесії користувача
8
8
  * @param sessGUID - GUID сесії з cookie
@@ -35,13 +35,15 @@ export async function getScores(sesId, sessGUID, prId, semester) {
35
35
  return result;
36
36
  result.scheduleItem = parseSchedule(html1);
37
37
  result.studentScores = parseScores(html1);
38
- result.studentId = result.studentScores[0].id;
39
- result.studentScores.sort((a, b) => a.id.localeCompare(b.id));
38
+ result.studentId = result.studentScores[0]?.id;
39
+ if (result.studentScores.length > 1) {
40
+ result.studentScores.sort((a, b) => a.id.localeCompare(b.id));
41
+ }
40
42
  result.ok = true;
41
43
  return result;
42
44
  }
43
45
  catch (e) {
44
- console.error('Error in getQuestionnaireData:', e);
46
+ console.error('Error in getScores:', e);
45
47
  throw e;
46
48
  }
47
49
  }
@@ -131,7 +131,7 @@ export interface StudentScores {
131
131
  export interface Scores {
132
132
  ok: boolean;
133
133
  prId: string;
134
- studentId: string;
134
+ studentId?: string;
135
135
  scheduleItem: ScheduleItem[];
136
136
  studentScores: StudentScores[];
137
137
  }
package/dist/examples.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import 'dotenv/config';
2
- import { CabinetTeacher } from './cabinetTeacher/cabinetTeacher.js';
3
2
  // const schedule = new Schedule();
4
3
  // schedule.group = '23Бд-СОінф123'
5
4
  // schedule.type = 'group'
@@ -42,8 +41,8 @@ import { CabinetTeacher } from './cabinetTeacher/cabinetTeacher.js';
42
41
  // console.log(cb.disciplines);
43
42
  // const { sesID, sessGUID } = await getSesId(process.env.LOGIN!, process.env.PASSWORD!);
44
43
  // console.log(sesID, sessGUID);
45
- // const sesID = '2850142C-AF52-4291-90C6-7EF356F90530';
46
- // const sessGUID = '20225423078dcb37d97904b76ba534af';
44
+ // const sesID = '';
45
+ // const sessGUID = '';
47
46
  // const data = await getData(sesID, sessGUID);
48
47
  // const data = await getDisciplines(sesID, sessGUID);
49
48
  // const data = await getСurrentDisciplines(sesID, sessGUID);
@@ -51,17 +50,18 @@ import { CabinetTeacher } from './cabinetTeacher/cabinetTeacher.js';
51
50
  // const data2 = await getScores(sesID, sessGUID, '43910', 0);
52
51
  // // console.log(data2);
53
52
  // const me = data2.studentScores.find((s) => s.id === data2.studentId)!;
54
- // const sesID = '894CF1B8-9FD8-4D44-A83B-FAC11182EA9C';
55
- // const sessGUID = '558ba94ab569d8701b380dbcfcbc3a42';
56
- // const cb = new Cabinet(process.env.LOGIN!, process.env.PASSWORD!);
57
- // // await cb.auth();
53
+ // const sesID = '';
54
+ // const sessGUID = '';
55
+ // //const cb = new CabinetStudent(process.env.LOGIN!, process.env.PASSWORD!);
56
+ // //await cb.auth();
58
57
  // // console.log(cb.sesID, cb.sessGUID);
59
58
  // console.log(await cb.setSession(sesID, sessGUID));
60
59
  // // console.log(cb.sesID, cb.sessGUID);
61
- // // console.log(await cb.loadData());
60
+ // console.log(await cb.loadData());
61
+ // await cb.getDisciplines();
62
62
  // console.log(await cb.getId());
63
- // // console.log(cb.allScores);
64
- // // printFinalScores(cb.allScores!, cb.disciplines);
63
+ // console.log(cb.allScores);
64
+ // printFinalScores(cb.allScores!, cb.disciplines);
65
65
  // function printFinalScores(scoresArray: Scores[], disciplines: Discipline[]) {
66
66
  // // Створюємо мапу prId → name для швидкого доступу
67
67
  // const disciplineMap: Record<string, string> = {};
@@ -84,13 +84,13 @@ import { CabinetTeacher } from './cabinetTeacher/cabinetTeacher.js';
84
84
  // }
85
85
  // }
86
86
  // }
87
- const sesID = '6AAB1510-0D9F-45FD-9F24-3A7B4568BAA7';
88
- const sessGUID = 'fd09702e51cde3d1bb6bfccdf9fc9e37';
89
- const cb = new CabinetTeacher(process.env.LOGINT, process.env.PASSWORDT);
90
- // console.log(await cb.auth());
91
- //console.log(cb.sesID, cb.sessGUID);
92
- console.log(await cb.setSession(sesID, sessGUID));
93
- console.log(cb.sesID, cb.sessGUID);
94
- console.log(await cb.loadData());
95
- console.log(cb.data);
96
- console.log(cb.academicGroups);
87
+ // const sesID = '';
88
+ // const sessGUID = '';
89
+ // const cb = new CabinetTeacher(process.env.LOGINT!, process.env.PASSWORDT!);
90
+ // // console.log(await cb.auth());
91
+ // //console.log(cb.sesID, cb.sessGUID);
92
+ // console.log(await cb.setSession(sesID, sessGUID));
93
+ // console.log(cb.sesID, cb.sessGUID);
94
+ // console.log(await cb.loadData());
95
+ // console.log(cb.data);
96
+ // console.log(cb.academicGroups);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zdu-student-api",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "API client for ZDU student services",
5
5
  "author": "Nicita3 <ni596157@gmail.com> (https://github.com/Nicita-3)",
6
6
  "main": "dist/index.js",