@jutge.org/toolkit 4.4.9 → 4.4.17
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/README.md +1 -0
- package/assets/prompts/funcs/creators/create-solution.tpl.txt +23 -0
- package/assets/prompts/funcs/creators/create-statement.tpl.txt +28 -0
- package/assets/prompts/funcs/creators/private-test-cases.tpl.txt +12 -0
- package/assets/prompts/funcs/creators/sample-test-cases.tpl.txt +16 -0
- package/assets/prompts/funcs/creators/sample.dt.tpl.txt +15 -0
- package/assets/prompts/funcs/examples/statement.tex +23 -0
- package/assets/prompts/funcs/proglangs/py.md +9 -0
- package/assets/prompts/io/examples/statement-coda.tex +7 -0
- package/assets/python/pyexec.py +9 -2
- package/dist/index.js +707 -467
- package/docs/getting-started-guide.md +1 -1
- package/docs/login.md +0 -1
- package/docs/problem-anatomy.md +1 -1
- package/docs/quiz-anatomy.md +367 -0
- package/package.json +14 -11
- package/toolkit/ask.ts +1 -1
- package/toolkit/dummies.ts +5 -4
- package/toolkit/generate.ts +83 -14
- package/toolkit/lint.ts +3 -4
- package/toolkit/make.ts +20 -23
- package/toolkit/quiz.ts +22 -14
- package/toolkit/share.ts +5 -4
- package/toolkit/submit.ts +4 -1
- /package/assets/prompts/{examples → funcs/examples}/statement-coda.tex +0 -0
- /package/assets/prompts/{creators → io/creators}/create-solution.tpl.txt +0 -0
- /package/assets/prompts/{creators → io/creators}/create-statement.tpl.txt +0 -0
- /package/assets/prompts/{creators → io/creators}/create-translation.tpl.txt +0 -0
- /package/assets/prompts/{creators → io/creators}/private-test-cases.txt +0 -0
- /package/assets/prompts/{creators → io/creators}/sample-test-cases.txt +0 -0
- /package/assets/prompts/{examples → io/examples}/statement.tex +0 -0
- /package/assets/prompts/{generators → io/generators}/efficiency.md +0 -0
- /package/assets/prompts/{generators → io/generators}/hard.md +0 -0
- /package/assets/prompts/{generators → io/generators}/random.md +0 -0
- /package/assets/prompts/{proglangs → io/proglangs}/cc.md +0 -0
- /package/assets/prompts/{proglangs → io/proglangs}/py.md +0 -0
package/toolkit/make.ts
CHANGED
|
@@ -243,27 +243,27 @@ async function runWatch(maker: Maker): Promise<void> {
|
|
|
243
243
|
tui.print('╭───╮ ╭───╮ ╭───╮ ╭───╮ ')
|
|
244
244
|
tui.print(
|
|
245
245
|
'│ ' +
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
chalk.bold('A') +
|
|
247
|
+
' │ │ ' +
|
|
248
|
+
chalk.bold('L') +
|
|
249
|
+
' │ │ ' +
|
|
250
|
+
chalk.bold('H') +
|
|
251
|
+
' │ │ ' +
|
|
252
|
+
chalk.bold('Q') +
|
|
253
|
+
' │ ',
|
|
254
254
|
)
|
|
255
255
|
tui.print('╰───╯ ╰───╯ ╰───╯ ╰───╯ ')
|
|
256
256
|
tui.print(' ♻️ 🔍 ❓ 🚫')
|
|
257
257
|
tui.print(
|
|
258
258
|
' ' +
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
259
|
+
chalk.blue('All') +
|
|
260
|
+
' ' +
|
|
261
|
+
chalk.blue('Lint') +
|
|
262
|
+
' ' +
|
|
263
|
+
chalk.blue('Help') +
|
|
264
|
+
' ' +
|
|
265
|
+
chalk.blue('Quit') +
|
|
266
|
+
' ',
|
|
267
267
|
)
|
|
268
268
|
tui.print(chalk.gray('Waiting for changes or keypress...'))
|
|
269
269
|
}
|
|
@@ -291,11 +291,7 @@ async function runWatch(maker: Maker): Promise<void> {
|
|
|
291
291
|
}
|
|
292
292
|
} else if (/^problem\.\w+\.tex$/.test(name)) {
|
|
293
293
|
pending.statementTex = true
|
|
294
|
-
} else if (
|
|
295
|
-
name === 'handler.yml' ||
|
|
296
|
-
name === 'problem.yml' ||
|
|
297
|
-
/^problem\.\w+\.yml$/.test(name)
|
|
298
|
-
) {
|
|
294
|
+
} else if (name === 'handler.yml' || name === 'problem.yml' || /^problem\.\w+\.yml$/.test(name)) {
|
|
299
295
|
pending.ymlSchema = true
|
|
300
296
|
}
|
|
301
297
|
scheduleRun()
|
|
@@ -309,7 +305,9 @@ async function runWatch(maker: Maker): Promise<void> {
|
|
|
309
305
|
await new Promise<void>((resolveExit, rejectExit) => {
|
|
310
306
|
function printHelp() {
|
|
311
307
|
tui.print()
|
|
312
|
-
tui.print(
|
|
308
|
+
tui.print(
|
|
309
|
+
'Under watch mode, the toolkit automatically rebuilds the necessary files in the problem directory when you make changes to your files.',
|
|
310
|
+
)
|
|
313
311
|
tui.print(
|
|
314
312
|
[
|
|
315
313
|
'Key bindings:',
|
|
@@ -320,7 +318,6 @@ async function runWatch(maker: Maker): Promise<void> {
|
|
|
320
318
|
' Q Quit watch mode',
|
|
321
319
|
'',
|
|
322
320
|
].join('\n'),
|
|
323
|
-
|
|
324
321
|
)
|
|
325
322
|
tui.print('The watch mode is under development. Please report any issues to the developers.')
|
|
326
323
|
printIdleMessage()
|
package/toolkit/quiz.ts
CHANGED
|
@@ -1,44 +1,52 @@
|
|
|
1
1
|
import { Command } from '@commander-js/extra-typings'
|
|
2
|
-
import {
|
|
2
|
+
import { runQuiz, lintQuiz } from '../lib/quiz'
|
|
3
3
|
import tui from '../lib/tui'
|
|
4
4
|
import { findRealDirectories } from '../lib/helpers'
|
|
5
5
|
import { random } from 'radash'
|
|
6
6
|
|
|
7
7
|
export const quizCmd = new Command('quiz')
|
|
8
|
-
.
|
|
8
|
+
.summary('Commands related to quizzes')
|
|
9
9
|
|
|
10
10
|
.action(() => {
|
|
11
11
|
quizCmd.help()
|
|
12
12
|
})
|
|
13
13
|
|
|
14
14
|
quizCmd
|
|
15
|
-
.command('
|
|
16
|
-
.
|
|
15
|
+
.command('lint')
|
|
16
|
+
.summary('Lint a quiz problem')
|
|
17
17
|
|
|
18
18
|
.option('-d, --directory <directory>', 'problem directory', '.')
|
|
19
19
|
|
|
20
20
|
.action(async ({ directory }) => {
|
|
21
21
|
const realDirectories = await findRealDirectories([directory])
|
|
22
22
|
for (const directory of realDirectories) {
|
|
23
|
-
await tui.section(`
|
|
24
|
-
await
|
|
23
|
+
await tui.section(`Linting quiz in directory ${tui.hyperlink(directory)}`, async () => {
|
|
24
|
+
await lintQuiz(directory)
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
})
|
|
28
28
|
|
|
29
29
|
quizCmd
|
|
30
|
-
.command('
|
|
31
|
-
.
|
|
30
|
+
.command('run')
|
|
31
|
+
.summary('Run a quiz problem')
|
|
32
|
+
.description(
|
|
33
|
+
`Run a quiz problem. This command is work-in-progress and may not work as expected yet.
|
|
34
|
+
|
|
35
|
+
This command will run the quiz problem and print the resulting object to stdout.
|
|
36
|
+
A random seed will be generated if not provided.
|
|
37
|
+
`,
|
|
38
|
+
)
|
|
32
39
|
|
|
33
40
|
.option('-d, --directory <directory>', 'problem directory', '.')
|
|
34
41
|
.option('-s, --seed <seed>', 'random seed')
|
|
42
|
+
.option('-f, --format <format>', 'output format (json|yaml)', 'json')
|
|
35
43
|
|
|
36
|
-
.action(async ({ directory, seed }) => {
|
|
37
|
-
tui.warning('The quiz make command is work-in-progress and may not work as expected yet.')
|
|
38
|
-
const realDirectories = await findRealDirectories([directory])
|
|
44
|
+
.action(async ({ directory, seed, format }) => {
|
|
39
45
|
const seedValue = seed ? parseInt(seed, 10) : random(1000000, 9999999)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
const object = await runQuiz(directory, seedValue)
|
|
47
|
+
if (format === 'json') {
|
|
48
|
+
tui.json(object)
|
|
49
|
+
} else {
|
|
50
|
+
tui.yaml(object)
|
|
43
51
|
}
|
|
44
52
|
})
|
package/toolkit/share.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { password } from '@inquirer/prompts'
|
|
|
2
2
|
import { Command } from '@commander-js/extra-typings'
|
|
3
3
|
import { updateSharingSettings } from '../lib/share'
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export const cmdShare = new Command('share')
|
|
7
6
|
.summary('Update and show sharing settings')
|
|
8
7
|
|
|
9
|
-
.description(
|
|
8
|
+
.description(
|
|
9
|
+
`Update and show sharing settings
|
|
10
10
|
|
|
11
11
|
First, this command updates the sharing settings in problem.yml file with the ones on Jutge.org to ensure they are consistent.
|
|
12
12
|
|
|
@@ -18,7 +18,8 @@ Then, it updates the sharing settings in Jutge.org with the requested changes. T
|
|
|
18
18
|
--solutions Share solutions
|
|
19
19
|
--no-solutions Stop sharing solutions
|
|
20
20
|
|
|
21
|
-
Finally, it updates problem.yml file with the current sharing settings and shows them
|
|
21
|
+
Finally, it updates problem.yml file with the current sharing settings and shows them.`,
|
|
22
|
+
)
|
|
22
23
|
|
|
23
24
|
.option('-d, --directory <directory>', 'problem directory', '.')
|
|
24
25
|
.option('--passcode [code]', 'Set a passcode (prompted if omitted)')
|
|
@@ -46,4 +47,4 @@ Finally, it updates problem.yml file with the current sharing settings and shows
|
|
|
46
47
|
const solutions = this.getOptionValueSource('solutions') !== 'default' ? opts.solutions : undefined
|
|
47
48
|
|
|
48
49
|
await updateSharingSettings(opts.directory, { passcode, testcases, solutions })
|
|
49
|
-
})
|
|
50
|
+
})
|
package/toolkit/submit.ts
CHANGED
|
@@ -10,7 +10,10 @@ export const submitCmd = new Command('submit')
|
|
|
10
10
|
.option('-c, --compiler <id>', 'compiler to use (default: auto-detect from file extension)', 'auto')
|
|
11
11
|
.option('-l, --language <code>', 'language code (ca, es, en, ...)', 'en')
|
|
12
12
|
.option('-n, --no-wait', 'do not wait for submissions to be judged')
|
|
13
|
-
.option(
|
|
13
|
+
.option(
|
|
14
|
+
'--no-browser',
|
|
15
|
+
'do not open the submission URL in the browser (only print URL and/or wait for verdict in terminal)',
|
|
16
|
+
)
|
|
14
17
|
.option('-a, --annotation <annotation>', "annotation for the submission (default: 'jtk-submit-<nanoid16>')")
|
|
15
18
|
|
|
16
19
|
.action(async (programs, { directory, compiler, language, wait, browser, annotation }) => {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|