-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathed_auto.js
More file actions
185 lines (160 loc) · 6.82 KB
/
Copy pathed_auto.js
File metadata and controls
185 lines (160 loc) · 6.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
const axios = require('axios');
const fs = require('fs');
/**
* ============================================================================
* ENGLISH DISCOVERIES (ED) AUTOMATED TOOL - PUBLIC SHOWCASE BUILD
* ============================================================================
* Repository : https://github.com/Datdaocong/edis_auto_tool
* Author : Dao Cong Dat
* Description: Architecture framework, CLI reporter & progress management engine.
* License : Public Showcase Edition.
* Note : Core solver algorithms and proprietary API payloads are omitted
* from the public release. Contact maintainer for full access.
* ============================================================================
*/
// Default configuration framework
let USER_CONFIG = {
target_courses: ["Intermediate 2", "Intermediate 3"],
target_units: "all",
max_tasks_per_unit: "all",
speed_mode: "balanced",
auto_logout: true,
report_file: "./report.txt",
accounts_file: "./accounts.json"
};
try {
if (fs.existsSync('./config.json')) {
const fileConfig = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
USER_CONFIG = { ...USER_CONFIG, ...fileConfig };
}
} catch (e) {
console.log(`[CONFIG] Using default options (${e.message})`);
}
const SPEED_SETTINGS = {
fast: { concurrency: 3, delayMs: 50 },
balanced: { concurrency: 2, delayMs: 100 },
safe: { concurrency: 1, delayMs: 250 }
};
const activeSpeed = SPEED_SETTINGS[USER_CONFIG.speed_mode] || SPEED_SETTINGS.balanced;
const CONFIG = {
INSTITUTION_ID: '5235245',
COMMUNITY_VERSION: '109',
BASE_URL: 'https://edwebservices2.engdis.com/api/',
ACCOUNTS_FILE: USER_CONFIG.accounts_file || './accounts.json',
REPORT_FILE: USER_CONFIG.report_file || './report.txt'
};
const delay = ms => new Promise(r => setTimeout(r, ms));
function log(emoji, message) {
const time = new Date().toLocaleTimeString('en-US', { hour12: false });
console.log(`[${time}] ${emoji} ${message}`);
}
function formatDuration(seconds) {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins}m ${secs}s`;
}
async function pMap(array, fn, limit = activeSpeed.concurrency) {
const results = [];
const executing = [];
for (const item of array) {
const p = Promise.resolve().then(() => fn(item));
results.push(p);
if (limit <= array.length) {
const e = p.then(() => executing.splice(executing.indexOf(e), 1));
executing.push(e);
if (executing.length >= limit) {
await Promise.race(executing);
}
}
}
return Promise.all(results);
}
function isTaskCompleted(task) {
if (!task) return true;
if (task.IsDone === true) return true;
if (typeof task.Progress === 'number' && task.Progress >= 1) return true;
if (typeof task.CompletionPercentage === 'number' && task.CompletionPercentage >= 100) return true;
return false;
function maskUsername(username) {
if (!username || typeof username !== 'string') return '****';
if (username.length <= 4) return '****';
return username.substring(0, 3) + '****' + username.substring(username.length - 3);
}
class EngDisAPI {
constructor(username, password) {
this.username = username;
this.maskedUser = maskUsername(username);
this.password = password;
this.token = null;
this.api = null;
}
async login() {
log('🔄', `Authenticating user: ${this.maskedUser}...`);
try {
const loginRes = await axios.post(CONFIG.BASE_URL + 'Auth/ForceLogin', {
CommunityVersion: CONFIG.COMMUNITY_VERSION,
InstitutionId: CONFIG.INSTITUTION_ID,
Password: this.password,
UserName: this.username,
});
this.token = loginRes.data?.UserInfo?.Token;
// Immediate in-memory password scrubbing
this.password = null;
if (!this.token) throw new Error("Invalid credentials or authentication token missing.");
log('✅', `Authentication successful!`);
return true;
} catch (e) {
this.password = null;
log('❌', `Authentication error: ${e.message}`);
return false;
}
}
async logout() {
log('🔒', `Session terminated for user ${this.maskedUser || '****'}.`);
return true;
}
async getAssignedCourses() {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Engine License required for GetAssignedCourses.");
}
async getCourseProgress(courseId) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Engine License required for GetCourseProgress.");
}
async getCourseTree(unitNodeId, rootCourseId) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Engine License required for GetCourseTree.");
}
async setTaskSuccess(courseId, taskId) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Engine License required for SetTaskSuccess.");
}
async getTestStructure(lessonCode) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Test Parsing Module required.");
}
async getTaskAnswers(taskCode) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Answer Extraction Module required.");
}
async submitTest(courseId, testStepNodeId, answersPayload) {
/* [PROPRIETARY CORE] Contact repository maintainer for access key */
throw new Error("[CORE_RESTRICTED] Private Test Solver Module required.");
}
}
function buildTestAnswers(allTasks, answerDataMap) {
/* [PROPRIETARY CORE] Algorithm restricted in public showcase build */
return [];
}
async function runAutoTool() {
console.log(`==================================================`);
console.log(`🚀 ED AUTOMATED TOOL (PUBLIC SHOWCASE BUILD) 🚀`);
console.log(`==================================================`);
console.log(`🎯 Target Courses : ${USER_CONFIG.target_courses.join(', ')}`);
console.log(`⚡ Speed Mode : ${USER_CONFIG.speed_mode.toUpperCase()}`);
console.log(`🔒 License Status : DEMO SHOWCASE (Core Solvers Restricted)`);
console.log(`==================================================\n`);
log('ℹ️', 'Public build active. Core solver modules are restricted.');
log('💡', 'Contact the repository maintainer for commercial license & private key.');
}
runAutoTool();