| 352 | const t: any = { id: c.id, op: c.op, expr: mathJsonToWL(c.arg), var: c.varName, points: POINTS }; |
| 353 | if (c.arg2 !== undefined) t.expr2 = mathJsonToWL(c.arg2); |
| 354 | if (c.point !== undefined && c.point !== null) t.point = wlPoint(c.point); |
| 355 | if (c.a !== undefined) t.a = c.a; |
| 356 | if (c.b !== undefined) t.b = c.b; |
| 357 | tasks.push(t); |
| 358 | } catch (e: any) { |
| 359 | by[c.id] = { status: 'error', error: String(e?.message ?? e).slice(0, 120) }; |
| 360 | } |
| 361 | } |
| 362 | if (!tasks.length) return by; |
| 363 | const tmp = join(mkdtempSync(join(tmpdir(), 'wester-wl-')), 'spec.json'); |
| 364 | writeFileSync(tmp, JSON.stringify({ real: true, tasks })); |
| 365 | try { |
| 366 | const out = execFileSync(NODE, [WOLFRAM_BATCH, tmp], { encoding: 'utf8', timeout: 1800000, maxBuffer: 64 * 1024 * 1024 }); |
| 367 | for (const line of out.trim().split('\n')) { try { const o = JSON.parse(line); if (o.id) by[o.id] = o; } catch {} } |
| 368 | } catch (e: any) { console.error('wolfram failed:', (e.message || e).toString().split('\n')[0]); } |
| 369 | return by; |
| 370 | } |
| 371 | |
| 372 | // --- grading (identical for every config) ---------------------------------- |