lms-sync 1.0.7 → 1.0.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.
- package/apiConnections/apiConnects.js +22 -14
- package/apiConnections/semesterPick.js +57 -0
- package/app.js +2 -3
- package/package.json +1 -1
@@ -2,7 +2,7 @@ const axios = require('axios')
|
|
2
2
|
const axiosRetry = require('axios-retry')
|
3
3
|
const fs = require('fs')
|
4
4
|
const path = require('path')
|
5
|
-
|
5
|
+
const { Picked } = require('./semesterPick')
|
6
6
|
|
7
7
|
const Apis = {
|
8
8
|
async ApiConnections() {
|
@@ -138,13 +138,21 @@ const Apis = {
|
|
138
138
|
const { login, apis } = await this.Login();
|
139
139
|
|
140
140
|
//get the current date
|
141
|
-
let defaultDate = new Date()
|
141
|
+
// let defaultDate = new Date()
|
142
|
+
|
143
|
+
// //get the current year
|
144
|
+
// let currentYear = defaultDate.getFullYear()
|
145
|
+
|
146
|
+
// //get the current year and minus it to 1 for the previous year
|
147
|
+
// let previousYear = currentYear - 1
|
148
|
+
|
149
|
+
// let fromPrompts = await semesterPick.Picked()
|
142
150
|
|
143
|
-
|
144
|
-
let currentYear = defaultDate.getFullYear()
|
151
|
+
let fromPrompts = await Picked()
|
145
152
|
|
146
|
-
|
147
|
-
let
|
153
|
+
let semester = fromPrompts.semester
|
154
|
+
let currentYear = fromPrompts.yearTo
|
155
|
+
let previousYear = fromPrompts.yearFrom
|
148
156
|
|
149
157
|
//join the previous year and the current year
|
150
158
|
let currentSchoolYear = previousYear + '-' + currentYear
|
@@ -158,7 +166,8 @@ const Apis = {
|
|
158
166
|
// console.log('acadYearResult.data :>> ', acadYearResult.data);
|
159
167
|
return {
|
160
168
|
acadYearResult:acadYearResult.data,
|
161
|
-
currentSchoolYear: currentSchoolYear
|
169
|
+
currentSchoolYear: currentSchoolYear,
|
170
|
+
semester
|
162
171
|
}
|
163
172
|
} catch (error) {
|
164
173
|
console.error('Academic Year Api Error:', error)
|
@@ -205,13 +214,12 @@ const Apis = {
|
|
205
214
|
async Student(){
|
206
215
|
try {
|
207
216
|
const { login, apis } = await this.Login();
|
208
|
-
const {currentSchoolYear} = await this.AcademicYear()
|
209
|
-
// console.log('currentSchoolYear :>> ', currentSchoolYear);
|
217
|
+
const {currentSchoolYear, semester} = await this.AcademicYear()
|
210
218
|
const student = await apis.instance.post('/students/enrolled',
|
211
219
|
{
|
212
220
|
"school_year": `${currentSchoolYear}`,
|
213
|
-
"school_term":
|
214
|
-
"limit":
|
221
|
+
"school_term": `${semester}`,
|
222
|
+
"limit": 999999999,
|
215
223
|
},
|
216
224
|
{
|
217
225
|
headers:{
|
@@ -230,12 +238,12 @@ const Apis = {
|
|
230
238
|
async Section(){
|
231
239
|
try {
|
232
240
|
const { login, apis } = await this.Login();
|
233
|
-
const {currentSchoolYear} = await this.AcademicYear()
|
241
|
+
const {currentSchoolYear, semester} = await this.AcademicYear()
|
234
242
|
const sectionResult = await apis.instance.post('/sections',
|
235
243
|
{
|
236
244
|
"school_year": `${currentSchoolYear}`,
|
237
|
-
"school_term":
|
238
|
-
"limit":
|
245
|
+
"school_term": `${semester}`,
|
246
|
+
"limit": 999999999,
|
239
247
|
},
|
240
248
|
{
|
241
249
|
headers:{
|
@@ -0,0 +1,57 @@
|
|
1
|
+
const prompts = require('prompts')
|
2
|
+
|
3
|
+
let picker = null;
|
4
|
+
|
5
|
+
async function promptYearSem(){
|
6
|
+
const response = await prompts([
|
7
|
+
{
|
8
|
+
type: 'text',
|
9
|
+
name: 'Academic Year From',
|
10
|
+
message: 'Please insert the Academic Year From:'
|
11
|
+
},
|
12
|
+
{
|
13
|
+
type: 'text',
|
14
|
+
name: 'Academic Year To',
|
15
|
+
message: 'Please insert the Academic Year To:'
|
16
|
+
},
|
17
|
+
{
|
18
|
+
type: 'select',
|
19
|
+
name: 'Semester',
|
20
|
+
message: 'Please pick Semester:',
|
21
|
+
choices:[
|
22
|
+
{ title: '1st Semester', value: '1st Semester' },
|
23
|
+
{ title: '2nd Semester', value: '2nd Semester' },
|
24
|
+
{ title: 'School Year', value: 'School Year' },
|
25
|
+
]
|
26
|
+
}
|
27
|
+
])
|
28
|
+
|
29
|
+
picker = {
|
30
|
+
semester: response.Semester,
|
31
|
+
yearFrom: response['Academic Year From'],
|
32
|
+
yearTo: response['Academic Year To']
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
async function Picked(){
|
37
|
+
try {
|
38
|
+
|
39
|
+
if (!picker) {
|
40
|
+
await promptYearSem()
|
41
|
+
}
|
42
|
+
|
43
|
+
let pickYearSem = picker
|
44
|
+
|
45
|
+
return pickYearSem
|
46
|
+
|
47
|
+
} catch (error) {
|
48
|
+
console.error(error);
|
49
|
+
return
|
50
|
+
}
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
module.exports = {
|
55
|
+
// YearSec: promptYearSem
|
56
|
+
Picked
|
57
|
+
}
|
package/app.js
CHANGED
@@ -17,11 +17,10 @@ async function start(){
|
|
17
17
|
if (startSequel) {
|
18
18
|
console.log('Connected to Sequelize.');
|
19
19
|
console.log(`Sequelize host:`, startSequel.config.host);
|
20
|
-
}
|
20
|
+
}
|
21
21
|
if(apis && startSequel){
|
22
22
|
console.log('Both connections successful. Starting migrations...');
|
23
|
-
|
24
|
-
await mappings.Enrolled()
|
23
|
+
await mappings.Server()
|
25
24
|
}
|
26
25
|
else {
|
27
26
|
console.error('Failed to establish database and api connections. Migrations not started.');
|