@mo7yw4ng/openape 1.0.0
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/LICENSE +21 -0
- package/README.md +97 -0
- package/esm/_dnt.polyfills.d.ts +24 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/_dnt.shims.d.ts +5 -0
- package/esm/_dnt.shims.js +61 -0
- package/esm/deno.d.ts +23 -0
- package/esm/deno.js +22 -0
- package/esm/package.json +3 -0
- package/package.json +34 -0
- package/script/_dnt.polyfills.d.ts +24 -0
- package/script/_dnt.polyfills.js +2 -0
- package/script/_dnt.shims.d.ts +5 -0
- package/script/_dnt.shims.js +65 -0
- package/script/deno.d.ts +23 -0
- package/script/deno.js +24 -0
- package/script/package.json +3 -0
- package/script/src/commands/announcements.d.ts +2 -0
- package/script/src/commands/announcements.js +288 -0
- package/script/src/commands/auth.d.ts +2 -0
- package/script/src/commands/auth.js +238 -0
- package/script/src/commands/calendar.d.ts +2 -0
- package/script/src/commands/calendar.js +375 -0
- package/script/src/commands/courses.d.ts +2 -0
- package/script/src/commands/courses.js +484 -0
- package/script/src/commands/forums.d.ts +2 -0
- package/script/src/commands/forums.js +403 -0
- package/script/src/commands/grades.d.ts +2 -0
- package/script/src/commands/grades.js +259 -0
- package/script/src/commands/materials.d.ts +2 -0
- package/script/src/commands/materials.js +423 -0
- package/script/src/commands/quizzes.d.ts +2 -0
- package/script/src/commands/quizzes.js +228 -0
- package/script/src/commands/skills.d.ts +2 -0
- package/script/src/commands/skills.js +117 -0
- package/script/src/commands/videos.d.ts +2 -0
- package/script/src/commands/videos.js +334 -0
- package/script/src/index.d.ts +26 -0
- package/script/src/index.js +156 -0
- package/script/src/lib/auth.d.ts +24 -0
- package/script/src/lib/auth.js +203 -0
- package/script/src/lib/config.d.ts +5 -0
- package/script/src/lib/config.js +43 -0
- package/script/src/lib/logger.d.ts +2 -0
- package/script/src/lib/logger.js +28 -0
- package/script/src/lib/moodle.d.ts +234 -0
- package/script/src/lib/moodle.js +966 -0
- package/script/src/lib/session.d.ts +7 -0
- package/script/src/lib/session.js +71 -0
- package/script/src/lib/token.d.ts +27 -0
- package/script/src/lib/token.js +154 -0
- package/script/src/lib/types.d.ts +261 -0
- package/script/src/lib/types.js +2 -0
- package/script/src/lib/utils.d.ts +5 -0
- package/script/src/lib/utils.js +43 -0
- package/skills/openape/SKILL.md +328 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { AppConfig, Logger, SessionInfo } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Extract Moodle sesskey from the current page.
|
|
5
|
+
* The sesskey is required for all AJAX calls.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractSessionInfo(page: Page, config: AppConfig, log: Logger, wsToken?: string): Promise<SessionInfo>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.extractSessionInfo = void 0;
|
|
27
|
+
const dntShim = __importStar(require("../../_dnt.shims.js"));
|
|
28
|
+
/**
|
|
29
|
+
* Extract Moodle sesskey from the current page.
|
|
30
|
+
* The sesskey is required for all AJAX calls.
|
|
31
|
+
*/
|
|
32
|
+
async function extractSessionInfo(page, config, log, wsToken) {
|
|
33
|
+
// Ensure we're on a Moodle page
|
|
34
|
+
const url = page.url();
|
|
35
|
+
if (!url.includes(config.moodleBaseUrl.replace("https://", ""))) {
|
|
36
|
+
await page.goto(`${config.moodleBaseUrl}/my/`, {
|
|
37
|
+
waitUntil: "domcontentloaded",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Try extracting sesskey from M.cfg (Moodle's JS config object)
|
|
41
|
+
let sesskey = await page.evaluate(() => {
|
|
42
|
+
return dntShim.dntGlobalThis.M?.cfg?.sesskey ?? null;
|
|
43
|
+
});
|
|
44
|
+
// Fallback: extract from a hidden input
|
|
45
|
+
if (!sesskey) {
|
|
46
|
+
sesskey = await page.evaluate(() => {
|
|
47
|
+
const el = document.querySelector('input[name="sesskey"]');
|
|
48
|
+
return el?.value ?? null;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
// Fallback: regex on page source
|
|
52
|
+
if (!sesskey) {
|
|
53
|
+
const content = await page.content();
|
|
54
|
+
const match = content.match(/"sesskey"\s*:\s*"([a-zA-Z0-9]+)"/);
|
|
55
|
+
sesskey = match?.[1] ?? null;
|
|
56
|
+
}
|
|
57
|
+
if (!sesskey) {
|
|
58
|
+
throw new Error("Failed to extract sesskey from Moodle page.");
|
|
59
|
+
}
|
|
60
|
+
log.debug(`Extracted sesskey: ${sesskey}`);
|
|
61
|
+
const sessionInfo = {
|
|
62
|
+
sesskey,
|
|
63
|
+
moodleBaseUrl: config.moodleBaseUrl,
|
|
64
|
+
};
|
|
65
|
+
if (wsToken) {
|
|
66
|
+
sessionInfo.wsToken = wsToken;
|
|
67
|
+
log.debug("Web Service Token included in session");
|
|
68
|
+
}
|
|
69
|
+
return sessionInfo;
|
|
70
|
+
}
|
|
71
|
+
exports.extractSessionInfo = extractSessionInfo;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
import type { AppConfig, Logger } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Get the WS token file path from the auth state path.
|
|
5
|
+
* E.g., .auth/storage-state.json -> .auth/ws-token.json
|
|
6
|
+
*/
|
|
7
|
+
export declare function getWsTokenPath(authStatePath: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Load WS token from file if it exists.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadWsToken(authStatePath: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Save WS token to file.
|
|
14
|
+
*/
|
|
15
|
+
export declare function saveWsToken(authStatePath: string, token: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Acquire Moodle Web Service Token via mobile app launch endpoint.
|
|
18
|
+
*
|
|
19
|
+
* Process:
|
|
20
|
+
* 1. Visit admin/tool/mobile/launch.php with service=moodle_mobile_app
|
|
21
|
+
* 2. Server redirects to moodlemobile://token=BASE64_DATA (which causes ERR_ABORTED)
|
|
22
|
+
* 3. We catch the redirect from the response and extract the token
|
|
23
|
+
*
|
|
24
|
+
* @returns The Web Service Token for Moodle API calls
|
|
25
|
+
* @throws Error if token acquisition fails
|
|
26
|
+
*/
|
|
27
|
+
export declare function acquireWsToken(page: Page, config: AppConfig, log: Logger): Promise<string>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.acquireWsToken = exports.saveWsToken = exports.loadWsToken = exports.getWsTokenPath = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* Get the WS token file path from the auth state path.
|
|
11
|
+
* E.g., .auth/storage-state.json -> .auth/ws-token.json
|
|
12
|
+
*/
|
|
13
|
+
function getWsTokenPath(authStatePath) {
|
|
14
|
+
const dir = path_1.default.dirname(authStatePath);
|
|
15
|
+
return path_1.default.join(dir, "ws-token.json");
|
|
16
|
+
}
|
|
17
|
+
exports.getWsTokenPath = getWsTokenPath;
|
|
18
|
+
/**
|
|
19
|
+
* Load WS token from file if it exists.
|
|
20
|
+
*/
|
|
21
|
+
function loadWsToken(authStatePath) {
|
|
22
|
+
const tokenPath = getWsTokenPath(authStatePath);
|
|
23
|
+
try {
|
|
24
|
+
if (fs_1.default.existsSync(tokenPath)) {
|
|
25
|
+
const content = fs_1.default.readFileSync(tokenPath, "utf8");
|
|
26
|
+
const data = JSON.parse(content);
|
|
27
|
+
// Check if token is not too old (Moodle tokens typically expire after some time)
|
|
28
|
+
if (data.token && data.timestamp) {
|
|
29
|
+
const age = Date.now() - data.timestamp;
|
|
30
|
+
// Consider token valid if less than 24 hours old
|
|
31
|
+
if (age < 24 * 60 * 60 * 1000) {
|
|
32
|
+
return data.token;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Ignore errors, token will be re-acquired
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
exports.loadWsToken = loadWsToken;
|
|
43
|
+
/**
|
|
44
|
+
* Save WS token to file.
|
|
45
|
+
*/
|
|
46
|
+
function saveWsToken(authStatePath, token) {
|
|
47
|
+
const tokenPath = getWsTokenPath(authStatePath);
|
|
48
|
+
try {
|
|
49
|
+
const data = {
|
|
50
|
+
token,
|
|
51
|
+
timestamp: Date.now(),
|
|
52
|
+
};
|
|
53
|
+
fs_1.default.writeFileSync(tokenPath, JSON.stringify(data, null, 2));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Ignore save errors
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.saveWsToken = saveWsToken;
|
|
60
|
+
/**
|
|
61
|
+
* Extract and decode the Web Service Token from moodlemobile:// URL
|
|
62
|
+
* Format: moodlemobile://token=BASE64_DATA
|
|
63
|
+
* Decoded: token:::site_url:::other_params
|
|
64
|
+
*/
|
|
65
|
+
function extractTokenFromCustomScheme(url) {
|
|
66
|
+
try {
|
|
67
|
+
const match = url.match(/token=([A-Za-z0-9+/=]+)/);
|
|
68
|
+
if (!match)
|
|
69
|
+
return null;
|
|
70
|
+
// Base64 decode the token data
|
|
71
|
+
const decoded = atob(match[1]);
|
|
72
|
+
const parts = decoded.split(":::");
|
|
73
|
+
// The second part (index 1) is the actual WS token
|
|
74
|
+
return parts.length >= 2 ? parts[1] : null;
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Acquire Moodle Web Service Token via mobile app launch endpoint.
|
|
82
|
+
*
|
|
83
|
+
* Process:
|
|
84
|
+
* 1. Visit admin/tool/mobile/launch.php with service=moodle_mobile_app
|
|
85
|
+
* 2. Server redirects to moodlemobile://token=BASE64_DATA (which causes ERR_ABORTED)
|
|
86
|
+
* 3. We catch the redirect from the response and extract the token
|
|
87
|
+
*
|
|
88
|
+
* @returns The Web Service Token for Moodle API calls
|
|
89
|
+
* @throws Error if token acquisition fails
|
|
90
|
+
*/
|
|
91
|
+
async function acquireWsToken(page, config, log) {
|
|
92
|
+
log.info("Acquiring Moodle Web Service Token...");
|
|
93
|
+
// Generate random UUID for passport parameter
|
|
94
|
+
const passport = crypto.randomUUID();
|
|
95
|
+
const launchUrl = `${config.moodleBaseUrl}/admin/tool/mobile/launch.php?service=moodle_mobile_app&passport=${passport}`;
|
|
96
|
+
log.debug(`Token acquisition URL: ${launchUrl}`);
|
|
97
|
+
// Set up response listener to catch the redirect
|
|
98
|
+
let tokenFound = false;
|
|
99
|
+
const tokenPromise = new Promise((resolve, reject) => {
|
|
100
|
+
const timeout = setTimeout(() => {
|
|
101
|
+
if (!tokenFound) {
|
|
102
|
+
page.off("response", responseHandler);
|
|
103
|
+
reject(new Error("Token acquisition timed out - no redirect received"));
|
|
104
|
+
}
|
|
105
|
+
}, 15000);
|
|
106
|
+
const responseHandler = async (response) => {
|
|
107
|
+
try {
|
|
108
|
+
const status = response.status();
|
|
109
|
+
const headers = response.headers();
|
|
110
|
+
// Check for redirect to custom scheme
|
|
111
|
+
const location = headers["location"] || headers["Location"];
|
|
112
|
+
if (location && location.startsWith("moodlemobile://")) {
|
|
113
|
+
clearTimeout(timeout);
|
|
114
|
+
tokenFound = true;
|
|
115
|
+
page.off("response", responseHandler);
|
|
116
|
+
const token = extractTokenFromCustomScheme(location);
|
|
117
|
+
if (token) {
|
|
118
|
+
resolve(token);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
reject(new Error("Failed to extract token from custom scheme URL"));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
// Ignore errors in response handler
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
page.on("response", responseHandler);
|
|
130
|
+
});
|
|
131
|
+
try {
|
|
132
|
+
// Navigate to the launch endpoint - expect it to fail with ERR_ABORTED
|
|
133
|
+
// because the browser can't handle moodlemobile:// scheme
|
|
134
|
+
await page.goto(launchUrl, {
|
|
135
|
+
waitUntil: "domcontentloaded",
|
|
136
|
+
timeout: 10000,
|
|
137
|
+
}).catch(() => {
|
|
138
|
+
// Expected: navigation will fail due to custom scheme redirect
|
|
139
|
+
// The token should have been captured by our response handler
|
|
140
|
+
log.debug("Navigation failed as expected (custom scheme redirect)");
|
|
141
|
+
});
|
|
142
|
+
// Wait for the intercepted token
|
|
143
|
+
const token = await tokenPromise;
|
|
144
|
+
log.success("Web Service Token acquired successfully");
|
|
145
|
+
log.debug(`Token (first 10 chars): ${token.substring(0, 10)}...`);
|
|
146
|
+
return token;
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
150
|
+
log.warn(`Failed to acquire WS Token: ${message}`);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.acquireWsToken = acquireWsToken;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import type { Page } from "playwright-core";
|
|
2
|
+
export interface AppConfig {
|
|
3
|
+
courseUrl: string;
|
|
4
|
+
moodleBaseUrl: string;
|
|
5
|
+
headless: boolean;
|
|
6
|
+
slowMo: number;
|
|
7
|
+
authStatePath: string;
|
|
8
|
+
ollamaModel?: string;
|
|
9
|
+
ollamaBaseUrl: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SessionInfo {
|
|
12
|
+
sesskey: string;
|
|
13
|
+
moodleBaseUrl: string;
|
|
14
|
+
wsToken?: string;
|
|
15
|
+
wsTokenExpires?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface Logger {
|
|
18
|
+
info: (msg: string) => void;
|
|
19
|
+
success: (msg: string) => void;
|
|
20
|
+
warn: (msg: string) => void;
|
|
21
|
+
error: (msg: string) => void;
|
|
22
|
+
debug: (msg: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface EnrolledCourse {
|
|
25
|
+
id: number;
|
|
26
|
+
fullname: string;
|
|
27
|
+
shortname: string;
|
|
28
|
+
idnumber?: string;
|
|
29
|
+
category?: string;
|
|
30
|
+
progress?: number;
|
|
31
|
+
startdate?: number;
|
|
32
|
+
enddate?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SuperVideoModule {
|
|
35
|
+
cmid: string;
|
|
36
|
+
name: string;
|
|
37
|
+
url: string;
|
|
38
|
+
isComplete: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface VideoActivity {
|
|
41
|
+
name: string;
|
|
42
|
+
url: string;
|
|
43
|
+
viewId: number;
|
|
44
|
+
duration: number;
|
|
45
|
+
existingPercent: number;
|
|
46
|
+
}
|
|
47
|
+
export interface QuizModule {
|
|
48
|
+
cmid: string;
|
|
49
|
+
name: string;
|
|
50
|
+
url: string;
|
|
51
|
+
isComplete: boolean;
|
|
52
|
+
timeOpen?: number;
|
|
53
|
+
timeClose?: number;
|
|
54
|
+
}
|
|
55
|
+
export interface ForumModule {
|
|
56
|
+
cmid: string;
|
|
57
|
+
forumId: number;
|
|
58
|
+
name: string;
|
|
59
|
+
url: string;
|
|
60
|
+
courseId: number;
|
|
61
|
+
forumType: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ForumPost {
|
|
64
|
+
id: number;
|
|
65
|
+
subject: string;
|
|
66
|
+
author: string;
|
|
67
|
+
authorId?: number;
|
|
68
|
+
created: number;
|
|
69
|
+
modified: number;
|
|
70
|
+
message: string;
|
|
71
|
+
discussionId: number;
|
|
72
|
+
replies?: ForumPost[];
|
|
73
|
+
unread?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface ForumDiscussion {
|
|
76
|
+
id: number;
|
|
77
|
+
forumId: number;
|
|
78
|
+
name: string;
|
|
79
|
+
firstPostId: number;
|
|
80
|
+
userId: number;
|
|
81
|
+
groupId?: number;
|
|
82
|
+
timedue?: number;
|
|
83
|
+
timeModified: number;
|
|
84
|
+
userModified?: number;
|
|
85
|
+
postCount?: number;
|
|
86
|
+
unread?: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface AnnouncementPost {
|
|
89
|
+
id: number;
|
|
90
|
+
subject: string;
|
|
91
|
+
content: string;
|
|
92
|
+
author: string;
|
|
93
|
+
authorId?: number;
|
|
94
|
+
courseId: number;
|
|
95
|
+
createdAt: number;
|
|
96
|
+
modifiedAt?: number;
|
|
97
|
+
attachments?: AnnouncementAttachment[];
|
|
98
|
+
unread?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface AnnouncementAttachment {
|
|
101
|
+
filename: string;
|
|
102
|
+
url: string;
|
|
103
|
+
filesize: number;
|
|
104
|
+
mimetype: string;
|
|
105
|
+
}
|
|
106
|
+
export interface ResourceModule {
|
|
107
|
+
cmid: string;
|
|
108
|
+
name: string;
|
|
109
|
+
url: string;
|
|
110
|
+
courseId: number;
|
|
111
|
+
modType: string;
|
|
112
|
+
mimetype?: string;
|
|
113
|
+
filesize?: number;
|
|
114
|
+
modified?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface FolderContents {
|
|
117
|
+
files: ResourceFile[];
|
|
118
|
+
folders: FolderInfo[];
|
|
119
|
+
}
|
|
120
|
+
export interface ResourceFile {
|
|
121
|
+
filename: string;
|
|
122
|
+
url: string;
|
|
123
|
+
filesize: number;
|
|
124
|
+
mimetype: string;
|
|
125
|
+
modified: number;
|
|
126
|
+
path?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface FolderInfo {
|
|
129
|
+
name: string;
|
|
130
|
+
id: number;
|
|
131
|
+
path: string;
|
|
132
|
+
}
|
|
133
|
+
export interface AssignmentModule {
|
|
134
|
+
cmid: string;
|
|
135
|
+
name: string;
|
|
136
|
+
url: string;
|
|
137
|
+
courseId: number;
|
|
138
|
+
duedate?: number;
|
|
139
|
+
cutoffdate?: number;
|
|
140
|
+
allowSubmissionsFromDate?: number;
|
|
141
|
+
gradingduedate?: number;
|
|
142
|
+
submissionStatus?: string;
|
|
143
|
+
grade?: GradeInfo;
|
|
144
|
+
lateSubmission?: boolean;
|
|
145
|
+
extensionduedate?: number;
|
|
146
|
+
}
|
|
147
|
+
export interface AssignmentSubmission {
|
|
148
|
+
id: number;
|
|
149
|
+
assignmentId: number;
|
|
150
|
+
userId: number;
|
|
151
|
+
timemodified: number;
|
|
152
|
+
status: string;
|
|
153
|
+
files?: SubmissionFile[];
|
|
154
|
+
grade?: GradeInfo;
|
|
155
|
+
feedback?: string;
|
|
156
|
+
}
|
|
157
|
+
export interface SubmissionFile {
|
|
158
|
+
filename: string;
|
|
159
|
+
url: string;
|
|
160
|
+
filesize: number;
|
|
161
|
+
mimetype: string;
|
|
162
|
+
timemodified: number;
|
|
163
|
+
}
|
|
164
|
+
export interface GradeInfo {
|
|
165
|
+
grade: string;
|
|
166
|
+
gradeFormatted: string;
|
|
167
|
+
grader?: string;
|
|
168
|
+
timedue?: number;
|
|
169
|
+
timemodified?: number;
|
|
170
|
+
}
|
|
171
|
+
export interface CourseGrade {
|
|
172
|
+
courseId: number;
|
|
173
|
+
courseName: string;
|
|
174
|
+
grade?: string;
|
|
175
|
+
gradeFormatted?: string;
|
|
176
|
+
rank?: number;
|
|
177
|
+
totalUsers?: number;
|
|
178
|
+
items?: GradeItem[];
|
|
179
|
+
}
|
|
180
|
+
export interface GradeItem {
|
|
181
|
+
id: number;
|
|
182
|
+
name: string;
|
|
183
|
+
grade?: string;
|
|
184
|
+
gradeFormatted?: string;
|
|
185
|
+
range?: string;
|
|
186
|
+
percentage?: number;
|
|
187
|
+
weight?: number;
|
|
188
|
+
feedback?: string;
|
|
189
|
+
graded?: boolean;
|
|
190
|
+
}
|
|
191
|
+
export interface CalendarEvent {
|
|
192
|
+
id: number;
|
|
193
|
+
name: string;
|
|
194
|
+
description?: string;
|
|
195
|
+
format: number;
|
|
196
|
+
courseid?: number;
|
|
197
|
+
categoryid?: number;
|
|
198
|
+
groupid?: number;
|
|
199
|
+
userid?: number;
|
|
200
|
+
moduleid?: number;
|
|
201
|
+
modulename?: string;
|
|
202
|
+
instance?: number;
|
|
203
|
+
eventtype: string;
|
|
204
|
+
timestart: number;
|
|
205
|
+
timeduration?: number;
|
|
206
|
+
timedue?: number;
|
|
207
|
+
visible?: number;
|
|
208
|
+
location?: string;
|
|
209
|
+
}
|
|
210
|
+
export interface QuestionParsing {
|
|
211
|
+
id: string;
|
|
212
|
+
text: string;
|
|
213
|
+
options: {
|
|
214
|
+
value: string;
|
|
215
|
+
text: string;
|
|
216
|
+
}[];
|
|
217
|
+
type: "radio" | "checkbox";
|
|
218
|
+
}
|
|
219
|
+
export interface QuestionAnswer {
|
|
220
|
+
questionId: string;
|
|
221
|
+
reasoning: string;
|
|
222
|
+
answerValues: string[];
|
|
223
|
+
}
|
|
224
|
+
export type OutputFormat = "json" | "csv" | "table" | "silent";
|
|
225
|
+
export interface OutputOptions {
|
|
226
|
+
format: OutputFormat;
|
|
227
|
+
fields?: string[];
|
|
228
|
+
pretty?: boolean;
|
|
229
|
+
}
|
|
230
|
+
export interface ProgressPayload {
|
|
231
|
+
view_id: number;
|
|
232
|
+
currenttime: number;
|
|
233
|
+
duration: number;
|
|
234
|
+
percent: number;
|
|
235
|
+
mapa: string;
|
|
236
|
+
}
|
|
237
|
+
export interface AjaxResponse {
|
|
238
|
+
error: boolean;
|
|
239
|
+
data?: {
|
|
240
|
+
success?: boolean;
|
|
241
|
+
exec?: string;
|
|
242
|
+
};
|
|
243
|
+
exception?: {
|
|
244
|
+
message: string;
|
|
245
|
+
errorcode: string;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
export interface CommandContext {
|
|
249
|
+
page: Page;
|
|
250
|
+
session: SessionInfo;
|
|
251
|
+
config: AppConfig;
|
|
252
|
+
log: Logger;
|
|
253
|
+
}
|
|
254
|
+
export interface CommandOptions {
|
|
255
|
+
output?: OutputFormat;
|
|
256
|
+
courseUrl?: string;
|
|
257
|
+
courseId?: number;
|
|
258
|
+
verbose?: boolean;
|
|
259
|
+
headed?: boolean;
|
|
260
|
+
dryRun?: boolean;
|
|
261
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.getBaseDir = void 0;
|
|
27
|
+
const dntShim = __importStar(require("../../_dnt.shims.js"));
|
|
28
|
+
const path_1 = require("path");
|
|
29
|
+
/**
|
|
30
|
+
* Returns the base directory for config/storage resolving.
|
|
31
|
+
* Handles both Deno (raw/compiled) and Node.js (npx).
|
|
32
|
+
*/
|
|
33
|
+
function getBaseDir() {
|
|
34
|
+
// @ts-ignore - Deno global is available in Deno
|
|
35
|
+
if (typeof dntShim.Deno !== "undefined" && typeof dntShim.Deno.execPath === "function") {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
const exeDir = (0, path_1.dirname)(dntShim.Deno.execPath());
|
|
38
|
+
return exeDir.includes("deno") ? process.cwd() : exeDir;
|
|
39
|
+
}
|
|
40
|
+
// Node.js or dnt runtime
|
|
41
|
+
return process.cwd();
|
|
42
|
+
}
|
|
43
|
+
exports.getBaseDir = getBaseDir;
|